|
1 | | -import React, { useState } from 'react'; |
2 | | -import { FormFactory } from '@schepta/factory-react'; |
3 | | -import { globalComponents } from './components/ProviderComponents'; |
4 | | -import { SubmittedValuesDisplay } from './components/SubmittedValuesDisplay'; |
5 | | -import templateFormSchemaJson from '../../../instances/form/template-form.json'; |
6 | | -import type { FormSchema } from '@schepta/core'; |
| 1 | +// import React, { useState } from 'react'; |
| 2 | +// import { FormFactory } from '@schepta/factory-react'; |
| 3 | +// import { globalComponents } from './components/ProviderComponents'; |
| 4 | +// import { SubmittedValuesDisplay } from './components/SubmittedValuesDisplay'; |
| 5 | +// // import templateFormSchemaJson from '../../../instances/form/template-form.json'; |
| 6 | +// import type { FormSchema } from '@schepta/core'; |
7 | 7 |
|
8 | | -const templateFormSchema = templateFormSchemaJson as FormSchema; |
| 8 | +// const templateFormSchema = templateFormSchemaJson as FormSchema; |
9 | 9 |
|
10 | | -export function ExpressionExample() { |
11 | | - const [submittedValues, setSubmittedValues] = useState<any>(null); |
12 | | - const [providerInfo, setProviderInfo] = useState<string>(''); |
| 10 | +// export function ExpressionExample() { |
| 11 | +// const [submittedValues, setSubmittedValues] = useState<any>(null); |
| 12 | +// const [providerInfo, setProviderInfo] = useState<string>(''); |
13 | 13 |
|
14 | | - const handleSubmit = (values: any) => { |
15 | | - console.log('Form submitted:', values); |
16 | | - setSubmittedValues(values); |
17 | | - setProviderInfo(`Form submitted. User ID from externalContext: 1`); |
18 | | - }; |
| 14 | +// const handleSubmit = (values: any) => { |
| 15 | +// console.log('Form submitted:', values); |
| 16 | +// setSubmittedValues(values); |
| 17 | +// setProviderInfo(`Form submitted. User ID from externalContext: 1`); |
| 18 | +// }; |
19 | 19 |
|
20 | | - return ( |
21 | | - <div style={{ padding: '24px', maxWidth: '800px', margin: '0 auto' }}> |
22 | | - <h1>schepta Template Expressions Example</h1> |
| 20 | +// return ( |
| 21 | +// <div style={{ padding: '24px', maxWidth: '800px', margin: '0 auto' }}> |
| 22 | +// <h1>schepta Template Expressions Example</h1> |
23 | 23 |
|
24 | | - <div style={{ |
25 | | - marginBottom: '24px', |
26 | | - padding: '20px', |
27 | | - backgroundColor: '#fff3cd', |
28 | | - border: '1px solid #ffc107', |
29 | | - borderRadius: '8px' |
30 | | - }}> |
31 | | - <h3 style={{ marginTop: 0 }}>Template Expressions Features:</h3> |
32 | | - <ul> |
33 | | - <li>✅ Use {'{{ $externalContext.* }}'} in schema values</li> |
34 | | - <li>✅ Use {'{{ $formState.* }}'} for dynamic form values</li> |
35 | | - <li>✅ Automatic processing of all template expressions</li> |
36 | | - <li>✅ Recursive processing in nested objects</li> |
37 | | - </ul> |
38 | | - </div> |
| 24 | +// <div style={{ |
| 25 | +// marginBottom: '24px', |
| 26 | +// padding: '20px', |
| 27 | +// backgroundColor: '#fff3cd', |
| 28 | +// border: '1px solid #ffc107', |
| 29 | +// borderRadius: '8px' |
| 30 | +// }}> |
| 31 | +// <h3 style={{ marginTop: 0 }}>Template Expressions Features:</h3> |
| 32 | +// <ul> |
| 33 | +// <li>✅ Use {'{{ $externalContext.* }}'} in schema values</li> |
| 34 | +// <li>✅ Use {'{{ $formState.* }}'} for dynamic form values</li> |
| 35 | +// <li>✅ Automatic processing of all template expressions</li> |
| 36 | +// <li>✅ Recursive processing in nested objects</li> |
| 37 | +// </ul> |
| 38 | +// </div> |
39 | 39 |
|
40 | | - <div style={{ border: '1px solid #ddd', padding: '24px', borderRadius: '8px' }}> |
41 | | - <h3 style={{ marginTop: 0 }}>Template Form (with {'{{ $externalContext.* }}'} and {'{{ $formState.* }}'})</h3> |
42 | | - <p style={{ fontSize: '13px', color: '#666', marginBottom: '16px' }}> |
43 | | - This example demonstrates two key template expression features you can observe: |
44 | | - <br /> |
45 | | - <strong>1. $externalContext expressions:</strong> The First Name label uses {'{{ $externalContext.user.name }}'} which resolves to <strong>"Test User"</strong> from the factory's externalContext prop. |
46 | | - <br /> |
47 | | - <strong>2. $formState expressions:</strong> The Email field's placeholder uses {'{{ $formState.personalInfo.firstName }}'} which dynamically updates to show the current value of the First Name field as you type. |
48 | | - </p> |
49 | | - <FormFactory |
50 | | - schema={templateFormSchema} |
51 | | - components={globalComponents} |
52 | | - externalContext={{ |
53 | | - user: { id: 1, name: 'Test User' }, |
54 | | - api: 'https://api.example.com', |
55 | | - fieldName: 'last name', |
56 | | - }} |
57 | | - onSubmit={handleSubmit} |
58 | | - debug={true} |
59 | | - /> |
60 | | - </div> |
| 40 | +// <div style={{ border: '1px solid #ddd', padding: '24px', borderRadius: '8px' }}> |
| 41 | +// <h3 style={{ marginTop: 0 }}>Template Form (with {'{{ $externalContext.* }}'} and {'{{ $formState.* }}'})</h3> |
| 42 | +// <p style={{ fontSize: '13px', color: '#666', marginBottom: '16px' }}> |
| 43 | +// This example demonstrates two key template expression features you can observe: |
| 44 | +// <br /> |
| 45 | +// <strong>1. $externalContext expressions:</strong> The First Name label uses {'{{ $externalContext.user.name }}'} which resolves to <strong>"Test User"</strong> from the factory's externalContext prop. |
| 46 | +// <br /> |
| 47 | +// <strong>2. $formState expressions:</strong> The Email field's placeholder uses {'{{ $formState.personalInfo.firstName }}'} which dynamically updates to show the current value of the First Name field as you type. |
| 48 | +// </p> |
| 49 | +// <FormFactory |
| 50 | +// schema={templateFormSchema} |
| 51 | +// components={globalComponents} |
| 52 | +// externalContext={{ |
| 53 | +// user: { id: 1, name: 'Test User' }, |
| 54 | +// api: 'https://api.example.com', |
| 55 | +// fieldName: 'last name', |
| 56 | +// }} |
| 57 | +// onSubmit={handleSubmit} |
| 58 | +// debug={true} |
| 59 | +// /> |
| 60 | +// </div> |
61 | 61 |
|
62 | | - <SubmittedValuesDisplay |
63 | | - submittedValues={submittedValues} |
64 | | - providerInfo={providerInfo} |
65 | | - /> |
66 | | - </div> |
67 | | - ); |
68 | | -} |
| 62 | +// <SubmittedValuesDisplay |
| 63 | +// submittedValues={submittedValues} |
| 64 | +// providerInfo={providerInfo} |
| 65 | +// /> |
| 66 | +// </div> |
| 67 | +// ); |
| 68 | +// } |
69 | 69 |
|
0 commit comments