@applica-software-guru/react-admin 1.5.282 → 1.5.283
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/ra-forms/LongForm/Tab.d.ts.map +1 -1
- package/dist/components/ra-forms/WizardForm/Content.d.ts +15 -0
- package/dist/components/ra-forms/WizardForm/Content.d.ts.map +1 -0
- package/dist/components/ra-forms/WizardForm/Form.d.ts +38 -0
- package/dist/components/ra-forms/WizardForm/Form.d.ts.map +1 -0
- package/dist/components/ra-forms/WizardForm/Provider.d.ts +48 -0
- package/dist/components/ra-forms/WizardForm/Provider.d.ts.map +1 -0
- package/dist/components/ra-forms/WizardForm/Stepper.d.ts +18 -0
- package/dist/components/ra-forms/WizardForm/Stepper.d.ts.map +1 -0
- package/dist/components/ra-forms/WizardForm/Toolbar.d.ts +20 -0
- package/dist/components/ra-forms/WizardForm/Toolbar.d.ts.map +1 -0
- package/dist/components/ra-forms/WizardForm/index.d.ts +4 -0
- package/dist/components/ra-forms/WizardForm/index.d.ts.map +1 -0
- package/dist/components/ra-forms/index.d.ts +1 -0
- package/dist/components/ra-forms/index.d.ts.map +1 -1
- package/dist/react-admin.cjs.js +54 -54
- package/dist/react-admin.cjs.js.gz +0 -0
- package/dist/react-admin.cjs.js.map +1 -1
- package/dist/react-admin.es.js +8991 -8792
- package/dist/react-admin.es.js.gz +0 -0
- package/dist/react-admin.es.js.map +1 -1
- package/dist/react-admin.umd.js +54 -54
- package/dist/react-admin.umd.js.gz +0 -0
- package/dist/react-admin.umd.js.map +1 -1
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/react.d.ts +14 -0
- package/dist/utils/react.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/components/ra-forms/LongForm/Tab.tsx +2 -11
- package/src/components/ra-forms/WizardForm/Content.tsx +82 -0
- package/src/components/ra-forms/WizardForm/Form.tsx +113 -0
- package/src/components/ra-forms/WizardForm/Provider.tsx +62 -0
- package/src/components/ra-forms/WizardForm/Stepper.tsx +113 -0
- package/src/components/ra-forms/WizardForm/Toolbar.tsx +58 -0
- package/src/components/ra-forms/WizardForm/index.ts +4 -0
- package/src/components/ra-forms/index.ts +1 -0
- package/src/playground/App.jsx +2 -1
- package/src/playground/components/ra-forms/TestWizardForm/AdvancedUsage.jsx +176 -0
- package/src/playground/components/ra-forms/TestWizardForm/BaseUsage.jsx +115 -0
- package/src/playground/components/ra-forms/TestWizardForm/TestWizardForm.jsx +27 -0
- package/src/playground/components/ra-forms/TestWizardForm/index.jsx +1 -0
- package/src/playground/components/ra-forms/index.jsx +1 -0
- package/src/playground/menu.jsx +8 -0
- package/src/utils/index.ts +1 -0
- package/src/utils/react.ts +25 -0
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BooleanInput,
|
|
3
|
+
ReadonlyField,
|
|
4
|
+
TextInput,
|
|
5
|
+
Toolbar,
|
|
6
|
+
WizardForm,
|
|
7
|
+
required,
|
|
8
|
+
useThemeConfig,
|
|
9
|
+
useTranslate,
|
|
10
|
+
useWizardFormContext
|
|
11
|
+
} from '@applica-software-guru/react-admin';
|
|
12
|
+
import { Box, Button, Grid, Step, StepLabel, Stepper, Typography } from '@mui/material';
|
|
13
|
+
import { SaveButton } from 'ra-ui-materialui';
|
|
14
|
+
import { useFormContext } from 'react-hook-form';
|
|
15
|
+
|
|
16
|
+
//il seguente form non avrà uno stile coerente, ma è solo per testare il funzionamento del WizardForm
|
|
17
|
+
|
|
18
|
+
function CustomToolbar({ ...props }) {
|
|
19
|
+
const { hasNextStep, hasPreviousStep, goToNextStep, goToPreviousStep } = useWizardFormContext();
|
|
20
|
+
const translate = useTranslate();
|
|
21
|
+
const { handleSubmit } = useFormContext();
|
|
22
|
+
|
|
23
|
+
const handleNext = handleSubmit(() => {
|
|
24
|
+
goToNextStep();
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
return (
|
|
28
|
+
<Toolbar {...props}>
|
|
29
|
+
{hasPreviousStep() && (
|
|
30
|
+
<Button variant="text" color="primary" onClick={goToPreviousStep}>
|
|
31
|
+
{translate('ra.action.back')}
|
|
32
|
+
</Button>
|
|
33
|
+
)}
|
|
34
|
+
{hasNextStep() ? (
|
|
35
|
+
<>
|
|
36
|
+
<Button variant="contained" color="primary" onClick={goToNextStep}>
|
|
37
|
+
Skip
|
|
38
|
+
</Button>
|
|
39
|
+
<Button variant="contained" color="primary" onClick={handleNext}>
|
|
40
|
+
{translate('ra.action.next')}
|
|
41
|
+
</Button>
|
|
42
|
+
</>
|
|
43
|
+
) : (
|
|
44
|
+
<SaveButton />
|
|
45
|
+
)}
|
|
46
|
+
</Toolbar>
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function CustomProgress() {
|
|
51
|
+
const { steps, currentStep } = useWizardFormContext();
|
|
52
|
+
return (
|
|
53
|
+
<Stepper activeStep={currentStep} orientation="vertical">
|
|
54
|
+
{steps.map((step, index) => (
|
|
55
|
+
<Step key={index}>
|
|
56
|
+
<StepLabel>{step.props.label}</StepLabel>
|
|
57
|
+
</Step>
|
|
58
|
+
))}
|
|
59
|
+
</Stepper>
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function AdvancedUsage() {
|
|
64
|
+
const { spacing } = useThemeConfig();
|
|
65
|
+
return (
|
|
66
|
+
<WizardForm
|
|
67
|
+
defaultValues={{ name: 'Mario', surname: 'Rossi' }}
|
|
68
|
+
toolbar={<CustomToolbar />}
|
|
69
|
+
progress={<CustomProgress />}
|
|
70
|
+
title="Conferma ordine"
|
|
71
|
+
validate={(values) => {
|
|
72
|
+
const errors = {};
|
|
73
|
+
if (values.terms !== true) {
|
|
74
|
+
errors.terms = 'Devi accettare i termini e le condizioni';
|
|
75
|
+
}
|
|
76
|
+
return errors;
|
|
77
|
+
}}
|
|
78
|
+
secondary="Ordine #1"
|
|
79
|
+
subheader="Wizard Form"
|
|
80
|
+
>
|
|
81
|
+
<WizardForm.Step label="Indirizzo di spedizione">
|
|
82
|
+
<Grid container spacing={spacing}>
|
|
83
|
+
<Grid item xs={6}>
|
|
84
|
+
<TextInput source="name" label="Nome" validate={required()} fullWidth />
|
|
85
|
+
</Grid>
|
|
86
|
+
<Grid item xs={6}>
|
|
87
|
+
<TextInput source="surname" label="Cognome" validate={required()} fullWidth />
|
|
88
|
+
</Grid>
|
|
89
|
+
<Grid item xs={12}>
|
|
90
|
+
<TextInput source="address" label="Indirizzo" fullWidth />
|
|
91
|
+
</Grid>
|
|
92
|
+
<Grid item xs={6}>
|
|
93
|
+
<TextInput source="nation" label="Nazione" fullWidth />
|
|
94
|
+
</Grid>
|
|
95
|
+
<Grid item xs={6}>
|
|
96
|
+
<TextInput source="province" label="Provincia" fullWidth />
|
|
97
|
+
</Grid>
|
|
98
|
+
<Grid item xs={6}>
|
|
99
|
+
<TextInput source="city" label="Città" fullWidth />
|
|
100
|
+
</Grid>
|
|
101
|
+
<Grid item xs={6}>
|
|
102
|
+
<TextInput source="zip" label="Codice Postale" fullWidth />
|
|
103
|
+
</Grid>
|
|
104
|
+
</Grid>
|
|
105
|
+
</WizardForm.Step>
|
|
106
|
+
<WizardForm.Step label="Dati di fatturazione">
|
|
107
|
+
<Grid container spacing={spacing}>
|
|
108
|
+
<Grid item xs={6}>
|
|
109
|
+
<TextInput source="billingName" label="Nome sulla carta" validate={required()} fullWidth />
|
|
110
|
+
</Grid>
|
|
111
|
+
<Grid item xs={6}>
|
|
112
|
+
<TextInput source="cardNumber" label="Numero carta" validate={required()} fullWidth />
|
|
113
|
+
</Grid>
|
|
114
|
+
<Grid item xs={12}>
|
|
115
|
+
<TextInput source="expirationDate" label="Data di scadenza" fullWidth />
|
|
116
|
+
</Grid>
|
|
117
|
+
<Grid item xs={12}>
|
|
118
|
+
<TextInput source="cvv" label="CVV" fullWidth />
|
|
119
|
+
</Grid>
|
|
120
|
+
</Grid>
|
|
121
|
+
</WizardForm.Step>
|
|
122
|
+
<WizardForm.Step label="Controlla il tuo ordine">
|
|
123
|
+
<Grid container spacing={spacing}>
|
|
124
|
+
<Grid item xs={12}>
|
|
125
|
+
<Box display="flex" justifyContent="space-between">
|
|
126
|
+
<Box>
|
|
127
|
+
<Typography variant="h6">Prodotto 1</Typography>
|
|
128
|
+
<Typography variant="body2">Descrizione del prodotto 1</Typography>
|
|
129
|
+
</Box>
|
|
130
|
+
<Typography variant="body2" align="right">
|
|
131
|
+
€100.00
|
|
132
|
+
</Typography>
|
|
133
|
+
</Box>
|
|
134
|
+
</Grid>
|
|
135
|
+
<Grid item xs={12}>
|
|
136
|
+
<Box display="flex" justifyContent="space-between">
|
|
137
|
+
<Box>
|
|
138
|
+
<Typography variant="h6">Prodotto 2</Typography>
|
|
139
|
+
<Typography variant="body2">Descrizione del prodotto 2</Typography>
|
|
140
|
+
</Box>
|
|
141
|
+
<Typography variant="body2" align="right">
|
|
142
|
+
€42.00
|
|
143
|
+
</Typography>
|
|
144
|
+
</Box>
|
|
145
|
+
</Grid>
|
|
146
|
+
<Grid item xs={12}>
|
|
147
|
+
<Box display="flex" justifyContent="space-between">
|
|
148
|
+
<Box>
|
|
149
|
+
<Typography variant="h6">Prodotto 3</Typography>
|
|
150
|
+
<Typography variant="body2">Descrizione del prodotto 3</Typography>
|
|
151
|
+
</Box>
|
|
152
|
+
<Typography variant="body2" align="right">
|
|
153
|
+
€37.00
|
|
154
|
+
</Typography>
|
|
155
|
+
</Box>
|
|
156
|
+
</Grid>
|
|
157
|
+
<Grid item xs={12}>
|
|
158
|
+
<Box display="flex" justifyContent="space-between">
|
|
159
|
+
<Box>
|
|
160
|
+
<Typography variant="h6">Totale</Typography>
|
|
161
|
+
</Box>
|
|
162
|
+
<Typography variant="h6" align="right">
|
|
163
|
+
€179.00
|
|
164
|
+
</Typography>
|
|
165
|
+
</Box>
|
|
166
|
+
</Grid>
|
|
167
|
+
<Grid item xs={12}>
|
|
168
|
+
<BooleanInput source="terms" label="Accetto i termini e le condizioni" />
|
|
169
|
+
</Grid>
|
|
170
|
+
</Grid>
|
|
171
|
+
</WizardForm.Step>
|
|
172
|
+
</WizardForm>
|
|
173
|
+
);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
export { AdvancedUsage };
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { CreateInDialogButton } from '@/components';
|
|
2
|
+
import { ContainerOutlined, CreditCardOutlined, UserOutlined } from '@ant-design/icons';
|
|
3
|
+
import {
|
|
4
|
+
BooleanInput,
|
|
5
|
+
Create,
|
|
6
|
+
ReadonlyField,
|
|
7
|
+
TextInput,
|
|
8
|
+
WizardForm,
|
|
9
|
+
required,
|
|
10
|
+
useThemeConfig
|
|
11
|
+
} from '@applica-software-guru/react-admin';
|
|
12
|
+
import { Box, Grid, Typography } from '@mui/material';
|
|
13
|
+
|
|
14
|
+
function BaseUsage() {
|
|
15
|
+
const { spacing } = useThemeConfig();
|
|
16
|
+
return (
|
|
17
|
+
//<CreateInDialogButton maxWidth="sm" resource="a">
|
|
18
|
+
<WizardForm>
|
|
19
|
+
<WizardForm.Step label="Indirizzo di spedizione" icon={<UserOutlined />}>
|
|
20
|
+
<Grid container spacing={spacing}>
|
|
21
|
+
<Grid item xs={6}>
|
|
22
|
+
<TextInput source="name" label="Nome" validate={required()} fullWidth />
|
|
23
|
+
</Grid>
|
|
24
|
+
<Grid item xs={6}>
|
|
25
|
+
<TextInput source="surname" label="Cognome" validate={required()} fullWidth />
|
|
26
|
+
</Grid>
|
|
27
|
+
<Grid item xs={12}>
|
|
28
|
+
<TextInput source="address" label="Indirizzo" fullWidth />
|
|
29
|
+
</Grid>
|
|
30
|
+
<Grid item xs={6}>
|
|
31
|
+
<TextInput source="nation" label="Nazione" fullWidth />
|
|
32
|
+
</Grid>
|
|
33
|
+
<Grid item xs={6}>
|
|
34
|
+
<TextInput source="province" label="Provincia" fullWidth />
|
|
35
|
+
</Grid>
|
|
36
|
+
<Grid item xs={6}>
|
|
37
|
+
<TextInput source="city" label="Città" fullWidth />
|
|
38
|
+
</Grid>
|
|
39
|
+
<Grid item xs={6}>
|
|
40
|
+
<TextInput source="zip" label="Codice Postale" fullWidth />
|
|
41
|
+
</Grid>
|
|
42
|
+
</Grid>
|
|
43
|
+
</WizardForm.Step>
|
|
44
|
+
<WizardForm.Step label="Dati di fatturazione" icon={<CreditCardOutlined />}>
|
|
45
|
+
<Grid container spacing={spacing}>
|
|
46
|
+
<Grid item xs={6}>
|
|
47
|
+
<TextInput source="billingName" label="Nome sulla carta" validate={required()} fullWidth />
|
|
48
|
+
</Grid>
|
|
49
|
+
<Grid item xs={6}>
|
|
50
|
+
<TextInput source="cardNumber" label="Numero carta" validate={required()} fullWidth />
|
|
51
|
+
</Grid>
|
|
52
|
+
<Grid item xs={12}>
|
|
53
|
+
<TextInput source="expirationDate" label="Data di scadenza" fullWidth />
|
|
54
|
+
</Grid>
|
|
55
|
+
<Grid item xs={12}>
|
|
56
|
+
<TextInput source="cvv" label="CVV" fullWidth />
|
|
57
|
+
</Grid>
|
|
58
|
+
</Grid>
|
|
59
|
+
</WizardForm.Step>
|
|
60
|
+
<WizardForm.Step label="Controlla il tuo ordine" icon={<ContainerOutlined />}>
|
|
61
|
+
<Grid container spacing={spacing}>
|
|
62
|
+
<Grid item xs={12}>
|
|
63
|
+
<Box display="flex" justifyContent="space-between">
|
|
64
|
+
<Box>
|
|
65
|
+
<Typography variant="h6">Prodotto 1</Typography>
|
|
66
|
+
<Typography variant="body2">Descrizione del prodotto 1</Typography>
|
|
67
|
+
</Box>
|
|
68
|
+
<Typography variant="body2" align="right">
|
|
69
|
+
€100.00
|
|
70
|
+
</Typography>
|
|
71
|
+
</Box>
|
|
72
|
+
</Grid>
|
|
73
|
+
<Grid item xs={12}>
|
|
74
|
+
<Box display="flex" justifyContent="space-between">
|
|
75
|
+
<Box>
|
|
76
|
+
<Typography variant="h6">Prodotto 2</Typography>
|
|
77
|
+
<Typography variant="body2">Descrizione del prodotto 2</Typography>
|
|
78
|
+
</Box>
|
|
79
|
+
<Typography variant="body2" align="right">
|
|
80
|
+
€42.00
|
|
81
|
+
</Typography>
|
|
82
|
+
</Box>
|
|
83
|
+
</Grid>
|
|
84
|
+
<Grid item xs={12}>
|
|
85
|
+
<Box display="flex" justifyContent="space-between">
|
|
86
|
+
<Box>
|
|
87
|
+
<Typography variant="h6">Prodotto 3</Typography>
|
|
88
|
+
<Typography variant="body2">Descrizione del prodotto 3</Typography>
|
|
89
|
+
</Box>
|
|
90
|
+
<Typography variant="body2" align="right">
|
|
91
|
+
€37.00
|
|
92
|
+
</Typography>
|
|
93
|
+
</Box>
|
|
94
|
+
</Grid>
|
|
95
|
+
<Grid item xs={12}>
|
|
96
|
+
<Box display="flex" justifyContent="space-between">
|
|
97
|
+
<Box>
|
|
98
|
+
<Typography variant="h6">Totale</Typography>
|
|
99
|
+
</Box>
|
|
100
|
+
<Typography variant="h6" align="right">
|
|
101
|
+
€179.00
|
|
102
|
+
</Typography>
|
|
103
|
+
</Box>
|
|
104
|
+
</Grid>
|
|
105
|
+
<Grid item xs={12}>
|
|
106
|
+
<BooleanInput source="terms" label="Accetto i termini e le condizioni" />
|
|
107
|
+
</Grid>
|
|
108
|
+
</Grid>
|
|
109
|
+
</WizardForm.Step>
|
|
110
|
+
</WizardForm>
|
|
111
|
+
//</CreateInDialogButton>
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export { BaseUsage };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BooleanInput,
|
|
3
|
+
ReadonlyField,
|
|
4
|
+
TextInput,
|
|
5
|
+
WizardForm,
|
|
6
|
+
required,
|
|
7
|
+
useThemeConfig
|
|
8
|
+
} from '@applica-software-guru/react-admin';
|
|
9
|
+
import { Box, Grid, Typography } from '@mui/material';
|
|
10
|
+
import { BaseUsage } from './BaseUsage';
|
|
11
|
+
import { AdvancedUsage } from './AdvancedUsage';
|
|
12
|
+
|
|
13
|
+
function TestWizardForm() {
|
|
14
|
+
const { spacing } = useThemeConfig();
|
|
15
|
+
return (
|
|
16
|
+
<Grid container spacing={spacing}>
|
|
17
|
+
<Grid item xs={12}>
|
|
18
|
+
<BaseUsage />
|
|
19
|
+
</Grid>
|
|
20
|
+
<Grid item xs={12}>
|
|
21
|
+
<AdvancedUsage />
|
|
22
|
+
</Grid>
|
|
23
|
+
</Grid>
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export { TestWizardForm };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './TestWizardForm';
|
package/src/playground/menu.jsx
CHANGED
|
@@ -36,6 +36,14 @@ export const menu = [
|
|
|
36
36
|
url: '/custom-page',
|
|
37
37
|
resource: false,
|
|
38
38
|
icon: TableOutlined
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
id: 'custom-pages/wizard-form',
|
|
42
|
+
title: 'ra.menu.item.wizard_form',
|
|
43
|
+
type: 'item',
|
|
44
|
+
url: '/wizard-form',
|
|
45
|
+
resource: false,
|
|
46
|
+
icon: TableOutlined
|
|
39
47
|
}
|
|
40
48
|
]
|
|
41
49
|
},
|
package/src/utils/index.ts
CHANGED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ReactElement, ReactNode, isValidElement } from 'react';
|
|
2
|
+
import _ from 'lodash';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* This file contains utility functions that can be reused across the project.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Originally made for LongForm component to find sources.
|
|
10
|
+
* Walks the children of a React element and calls a callback function for each child.
|
|
11
|
+
*
|
|
12
|
+
* @param {ReactNode} children - The children of a React element.
|
|
13
|
+
* @param {Function} callback - The callback function to call for each child.
|
|
14
|
+
*/
|
|
15
|
+
function walkChildren(children: ReactNode = [], callback: (el: ReactElement) => void) {
|
|
16
|
+
const _children = _.isArray(children) ? children : [children];
|
|
17
|
+
const validChildren = _.filter(_children, (child) => isValidElement(child));
|
|
18
|
+
_.each(validChildren, (child) => {
|
|
19
|
+
callback(child);
|
|
20
|
+
// @ts-ignore @ts-expect-error Property 'children' does not exist on type '{}'.
|
|
21
|
+
walkChildren(child?.props?.children ?? [], callback);
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export { walkChildren };
|