@comet/admin 9.0.0-beta.5 → 9.0.0-beta.6
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/lib/common/ClearInputAdornment.d.ts.map +1 -1
- package/lib/common/ClearInputAdornment.js +6 -2
- package/lib/dataGrid/excelExport/generateExcelFile.d.ts.map +1 -1
- package/lib/dataGrid/excelExport/generateExcelFile.js +23 -1
- package/lib/dateTime/timePicker/TimePicker.d.ts.map +1 -1
- package/lib/dateTime/timePicker/TimePicker.js +2 -17
- package/lib/dateTime/timeRangePicker/TimeRangePicker.d.ts +71 -0
- package/lib/dateTime/timeRangePicker/TimeRangePicker.d.ts.map +1 -0
- package/lib/dateTime/timeRangePicker/TimeRangePicker.js +191 -0
- package/lib/dateTime/timeRangePickerField/TimeRangePickerField.d.ts +13 -0
- package/lib/dateTime/timeRangePickerField/TimeRangePickerField.d.ts.map +1 -0
- package/lib/dateTime/timeRangePickerField/TimeRangePickerField.js +31 -0
- package/lib/dateTime/utils.d.ts +6 -0
- package/lib/dateTime/utils.d.ts.map +1 -1
- package/lib/dateTime/utils.js +19 -1
- package/lib/{EditDialog.d.ts → editDialog/EditDialog.d.ts} +1 -1
- package/lib/editDialog/EditDialog.d.ts.map +1 -0
- package/lib/{EditDialog.js → editDialog/EditDialog.js} +5 -5
- package/lib/editDialog/EditDialogApiContext.d.ts.map +1 -0
- package/lib/form/FinalFormNumberInput.d.ts.map +1 -1
- package/lib/form/FinalFormNumberInput.js +2 -3
- package/lib/index.d.ts +4 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +4 -2
- package/package.json +19 -12
- package/lib/EditDialog.d.ts.map +0 -1
- package/lib/EditDialogApiContext.d.ts.map +0 -1
- package/lib/alert/__stories__/Alert.stories.js +0 -152
- package/lib/common/__stories__/Tooltip.stories.js +0 -404
- package/lib/common/buttons/__stories__/Button.stories.js +0 -445
- package/lib/common/buttons/delete/__stories__/DeleteButton.stories.js +0 -8
- package/lib/common/toolbar/__stories__/DataGridToolbar.stories.js +0 -76
- package/lib/common/toolbar/__stories__/Toolbar.stories.js +0 -82
- package/lib/dataGrid/__stories__/ClickableRows.stories.js +0 -109
- package/lib/dataGrid/__stories__/CrudMoreActionsMenu.stories.js +0 -50
- package/lib/dataGrid/__stories__/DataGrid.stories.js +0 -94
- package/lib/dataGrid/__stories__/DataGridSingleSelectFilter.stories.js +0 -492
- package/lib/dateTime/datePicker/__stories__/DatePicker.stories.js +0 -214
- package/lib/dateTime/datePickerField/__stories__/DatePickerField.stories.js +0 -220
- package/lib/dateTime/dateRangePicker/__stories__/DateRangePicker.stories.js +0 -238
- package/lib/dateTime/dateRangePickerField/__stories__/DateRangePickerField.stories.js +0 -224
- package/lib/dateTime/dateTimePicker/__stories__/DateTimePicker.stories.js +0 -214
- package/lib/dateTime/dateTimePickerField/__stories__/DateTimePickerField.stories.js +0 -220
- package/lib/dateTime/dateTimeRangePicker/__stories__/DateTimeRangePicker.stories.js +0 -238
- package/lib/dateTime/dateTimeRangePickerField/__stories__/DateTimeRangePickerField.stories.js +0 -223
- package/lib/dateTime/timePicker/__stories__/TimePicker.stories.js +0 -219
- package/lib/dateTime/timePickerField/__stories__/TimePickerField.stories.js +0 -229
- package/lib/form/__stories__/AsyncAutocompleteField.stories.js +0 -660
- package/lib/form/__stories__/AsyncSelectField.stories.js +0 -513
- package/lib/form/__stories__/Autocomplete.stories.js +0 -188
- package/lib/form/__stories__/AutocompleteField.stories.js +0 -48
- package/lib/form/__stories__/Checkbox.stories.js +0 -70
- package/lib/form/__stories__/CheckboxField.stories.js +0 -87
- package/lib/form/__stories__/CheckboxListField.stories.js +0 -172
- package/lib/form/__stories__/CustomButtons.stories.js +0 -78
- package/lib/form/__stories__/DependentAsyncSelects.stories.js +0 -91
- package/lib/form/__stories__/DisableAutoNavigation.stories.js +0 -132
- package/lib/form/__stories__/DisabledSubmitIfNotDirty.stories.js +0 -54
- package/lib/form/__stories__/FieldContainer.stories.js +0 -87
- package/lib/form/__stories__/FinalFormFileSelect.stories.js +0 -155
- package/lib/form/__stories__/FormInStack.stories.js +0 -133
- package/lib/form/__stories__/FormLayouts.stories.js +0 -174
- package/lib/form/__stories__/FormValidation.stories.js +0 -82
- package/lib/form/__stories__/Input.stories.js +0 -37
- package/lib/form/__stories__/NumberField.stories.js +0 -38
- package/lib/form/__stories__/Radio.stories.js +0 -101
- package/lib/form/__stories__/RadioGroupField.stories.js +0 -172
- package/lib/form/__stories__/RangeInput.stories.js +0 -239
- package/lib/form/__stories__/RouterTabs.stories.js +0 -96
- package/lib/form/__stories__/RouterTabsInForm.stories.js +0 -73
- package/lib/form/__stories__/RouterTabsInFormWithSubroutes.stories.js +0 -96
- package/lib/form/__stories__/ScrollToErrorField.stories.js +0 -82
- package/lib/form/__stories__/SearchField.stories.js +0 -38
- package/lib/form/__stories__/Select.stories.js +0 -187
- package/lib/form/__stories__/SelectField.stories.js +0 -100
- package/lib/form/__stories__/ShowErrorStrategies.stories.js +0 -107
- package/lib/form/__stories__/SingleTextField.stories.js +0 -108
- package/lib/form/__stories__/StackInForm.stories.js +0 -53
- package/lib/form/__stories__/SubmitErrors.stories.js +0 -90
- package/lib/form/__stories__/Switch.stories.js +0 -49
- package/lib/form/__stories__/SwitchField.stories.js +0 -87
- package/lib/form/__stories__/Tabs.stories.js +0 -78
- package/lib/form/__stories__/TextAreaField.stories.js +0 -38
- package/lib/form/__stories__/TextField.stories.js +0 -67
- package/lib/form/__stories__/ToggleButtonGroupField.stories.js +0 -312
- package/lib/form/__stories__/TwoLevelValidation.stories.js +0 -168
- package/lib/form/__stories__/Typography.stories.js +0 -71
- package/lib/form/file/__stories__/FileDropzone.stories.js +0 -81
- package/lib/form/file/__stories__/FileSelect.stories.js +0 -139
- package/lib/form/file/__stories__/FileSelectListItem.stories.js +0 -108
- package/lib/form/file/__stories__/FileSelectMultipleExamples.stories.js +0 -187
- package/lib/section/__stories__/SectionHeadline.stories.js +0 -71
- package/lib/stack/__stories__/RouterTabsNestedStack.stories.js +0 -51
- package/lib/stack/__stories__/Stack.stories.js +0 -14
- package/lib/stack/__stories__/StackBackButton.stories.js +0 -50
- package/lib/stack/__stories__/StackBreadcrumbs.stories.js +0 -139
- package/lib/stack/__stories__/StackBreadcrumbsTabs.stories.js +0 -47
- package/lib/stack/__stories__/StackCustomSeparator.stories.js +0 -47
- package/lib/stack/__stories__/StackLink.stories.js +0 -41
- package/lib/stack/__stories__/StackNested.stories.js +0 -58
- package/lib/stack/__stories__/StackNestedOnInitialPage.stories.js +0 -78
- package/lib/stack/__stories__/StackNestedOneStack.stories.js +0 -90
- package/lib/stack/__stories__/StackPageTitle.stories.js +0 -121
- package/lib/stack/__stories__/StackReactNodeTitle.stories.js +0 -54
- package/lib/stack/__stories__/StackRefApi.stories.js +0 -56
- package/lib/stack/__stories__/StackTableFormQueryAtStack.stories.js +0 -155
- package/lib/stack/__stories__/StackTableFormQueryInTable.stories.js +0 -160
- package/lib/stack/__stories__/StackUrl.stories.js +0 -66
- package/lib/tabs/__stories__/DynamicTabs.stories.js +0 -84
- package/lib/tabs/__stories__/NestedStackSwitchWithRouterTabs.stories.js +0 -84
- package/lib/tabs/__stories__/OverflowIssues.stories.js +0 -224
- package/lib/tabs/__stories__/RouterTabs.stories.js +0 -31
- package/lib/tabs/__stories__/RouterTabsInStack.stories.js +0 -74
- package/lib/tabs/__stories__/RouterTabsInSubroute.stories.js +0 -68
- package/lib/tabs/__stories__/Tabs.stories.js +0 -219
- package/lib/translator/__stories__/ContentTranslation.stories.js +0 -104
- /package/lib/{EditDialogApiContext.d.ts → editDialog/EditDialogApiContext.d.ts} +0 -0
- /package/lib/{EditDialogApiContext.js → editDialog/EditDialogApiContext.js} +0 -0
|
@@ -1,187 +0,0 @@
|
|
|
1
|
-
import { Account } from "@comet/admin-icons";
|
|
2
|
-
import { Box, Checkbox, InputAdornment, ListItemIcon, ListItemText, MenuItem } from "@mui/material";
|
|
3
|
-
import { Form } from "react-final-form";
|
|
4
|
-
import { FieldSet } from "../../common/FieldSet";
|
|
5
|
-
import { SelectField } from "../../form/fields/SelectField";
|
|
6
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
7
|
-
export default {
|
|
8
|
-
title: "components/form"
|
|
9
|
-
};
|
|
10
|
-
export var Select = function Select() {
|
|
11
|
-
var options = [{
|
|
12
|
-
value: "chocolate",
|
|
13
|
-
label: "Chocolate"
|
|
14
|
-
}, {
|
|
15
|
-
value: "strawberry",
|
|
16
|
-
label: "Strawberry"
|
|
17
|
-
}, {
|
|
18
|
-
value: "raspberry",
|
|
19
|
-
label: "Raspberry"
|
|
20
|
-
}, {
|
|
21
|
-
value: "vanilla",
|
|
22
|
-
label: "Vanilla",
|
|
23
|
-
disabled: true
|
|
24
|
-
}, {
|
|
25
|
-
value: "mango",
|
|
26
|
-
label: "Mango"
|
|
27
|
-
}];
|
|
28
|
-
var numberOptions = [{
|
|
29
|
-
value: 0,
|
|
30
|
-
label: "Zero"
|
|
31
|
-
}, {
|
|
32
|
-
value: 1,
|
|
33
|
-
label: "One"
|
|
34
|
-
}, {
|
|
35
|
-
value: 2,
|
|
36
|
-
label: "Two"
|
|
37
|
-
}, {
|
|
38
|
-
value: 3,
|
|
39
|
-
label: "Three"
|
|
40
|
-
}, {
|
|
41
|
-
value: 4,
|
|
42
|
-
label: "Four",
|
|
43
|
-
disabled: true
|
|
44
|
-
}, {
|
|
45
|
-
value: 5,
|
|
46
|
-
label: "Five"
|
|
47
|
-
}];
|
|
48
|
-
return /*#__PURE__*/_jsx(Box, {
|
|
49
|
-
width: 500,
|
|
50
|
-
children: /*#__PURE__*/_jsx(Form, {
|
|
51
|
-
initialValues: {
|
|
52
|
-
multipleFlavors: [],
|
|
53
|
-
multipleNumbers: [],
|
|
54
|
-
multipleRequiredFlavors: []
|
|
55
|
-
},
|
|
56
|
-
onSubmit: function onSubmit() {
|
|
57
|
-
//
|
|
58
|
-
},
|
|
59
|
-
render: function render(_ref) {
|
|
60
|
-
var handleSubmit = _ref.handleSubmit,
|
|
61
|
-
values = _ref.values;
|
|
62
|
-
return /*#__PURE__*/_jsxs("form", {
|
|
63
|
-
onSubmit: handleSubmit,
|
|
64
|
-
children: [/*#__PURE__*/_jsxs(FieldSet, {
|
|
65
|
-
title: "Basic selects",
|
|
66
|
-
children: [/*#__PURE__*/_jsx(SelectField, {
|
|
67
|
-
name: "flavor",
|
|
68
|
-
label: "Select a flavor",
|
|
69
|
-
options: options,
|
|
70
|
-
fullWidth: true
|
|
71
|
-
}), /*#__PURE__*/_jsx(SelectField, {
|
|
72
|
-
name: "number",
|
|
73
|
-
label: "Select a number",
|
|
74
|
-
options: numberOptions,
|
|
75
|
-
fullWidth: true
|
|
76
|
-
}), /*#__PURE__*/_jsx(Box, {
|
|
77
|
-
component: "pre",
|
|
78
|
-
children: JSON.stringify({
|
|
79
|
-
flavor: values.flavor,
|
|
80
|
-
number: values.number
|
|
81
|
-
}, null, 2)
|
|
82
|
-
})]
|
|
83
|
-
}), /*#__PURE__*/_jsxs(FieldSet, {
|
|
84
|
-
title: "Multi selects",
|
|
85
|
-
children: [/*#__PURE__*/_jsx(SelectField, {
|
|
86
|
-
name: "multipleFlavors",
|
|
87
|
-
label: "Select multiple flavors",
|
|
88
|
-
options: options,
|
|
89
|
-
multiple: true,
|
|
90
|
-
fullWidth: true
|
|
91
|
-
}), /*#__PURE__*/_jsx(SelectField, {
|
|
92
|
-
name: "multipleNumbers",
|
|
93
|
-
label: "Select multiple numbers",
|
|
94
|
-
options: numberOptions,
|
|
95
|
-
multiple: true,
|
|
96
|
-
fullWidth: true
|
|
97
|
-
}), /*#__PURE__*/_jsx(Box, {
|
|
98
|
-
component: "pre",
|
|
99
|
-
children: JSON.stringify({
|
|
100
|
-
multipleFlavors: values.multipleFlavors,
|
|
101
|
-
multipleNumbers: values.multipleNumbers
|
|
102
|
-
}, null, 2)
|
|
103
|
-
})]
|
|
104
|
-
}), /*#__PURE__*/_jsxs(FieldSet, {
|
|
105
|
-
title: "Required selects",
|
|
106
|
-
children: [/*#__PURE__*/_jsx(SelectField, {
|
|
107
|
-
name: "requiredFlavor",
|
|
108
|
-
label: "Select a flavor",
|
|
109
|
-
options: options,
|
|
110
|
-
fullWidth: true,
|
|
111
|
-
required: true
|
|
112
|
-
}), /*#__PURE__*/_jsx(SelectField, {
|
|
113
|
-
name: "requiredNumber",
|
|
114
|
-
label: "Select a number",
|
|
115
|
-
options: numberOptions,
|
|
116
|
-
fullWidth: true,
|
|
117
|
-
required: true
|
|
118
|
-
}), /*#__PURE__*/_jsx(SelectField, {
|
|
119
|
-
name: "multipleRequiredFlavors",
|
|
120
|
-
label: "Select multiple flavors",
|
|
121
|
-
options: options,
|
|
122
|
-
multiple: true,
|
|
123
|
-
fullWidth: true,
|
|
124
|
-
required: true
|
|
125
|
-
}), /*#__PURE__*/_jsx(Box, {
|
|
126
|
-
component: "pre",
|
|
127
|
-
children: JSON.stringify({
|
|
128
|
-
requiredFlavor: values.requiredFlavor,
|
|
129
|
-
requiredNumber: values.requiredNumber,
|
|
130
|
-
multipleRequiredFlavors: values.multipleRequiredFlavors
|
|
131
|
-
}, null, 2)
|
|
132
|
-
})]
|
|
133
|
-
}), /*#__PURE__*/_jsxs(FieldSet, {
|
|
134
|
-
title: "Customization",
|
|
135
|
-
children: [/*#__PURE__*/_jsx(SelectField, {
|
|
136
|
-
name: "flavorMultipleAdornments",
|
|
137
|
-
label: "Flavor with adornments",
|
|
138
|
-
options: options,
|
|
139
|
-
fullWidth: true,
|
|
140
|
-
componentsProps: {
|
|
141
|
-
finalFormSelect: {
|
|
142
|
-
startAdornment: /*#__PURE__*/_jsx(InputAdornment, {
|
|
143
|
-
position: "start",
|
|
144
|
-
children: /*#__PURE__*/_jsx(Account, {})
|
|
145
|
-
})
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
}), /*#__PURE__*/_jsx(SelectField, {
|
|
149
|
-
name: "flavorWithCustomOptionsRendering",
|
|
150
|
-
label: "Flavor with adornments",
|
|
151
|
-
fullWidth: true,
|
|
152
|
-
componentsProps: {
|
|
153
|
-
finalFormSelect: {
|
|
154
|
-
renderValue: function renderValue(value) {
|
|
155
|
-
var _options$find;
|
|
156
|
-
return (_options$find = options.find(function (option) {
|
|
157
|
-
return option.value === value;
|
|
158
|
-
})) === null || _options$find === void 0 ? void 0 : _options$find.label;
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
},
|
|
162
|
-
children: options.map(function (option) {
|
|
163
|
-
return /*#__PURE__*/_jsxs(MenuItem, {
|
|
164
|
-
value: option.value,
|
|
165
|
-
children: [/*#__PURE__*/_jsx(Checkbox, {
|
|
166
|
-
checked: option.value === values.flavorWithCustomOptionsRendering
|
|
167
|
-
}), /*#__PURE__*/_jsx(ListItemText, {
|
|
168
|
-
primary: option.label,
|
|
169
|
-
secondary: "The value is ".concat(option.value)
|
|
170
|
-
}), /*#__PURE__*/_jsx(ListItemIcon, {
|
|
171
|
-
children: /*#__PURE__*/_jsx(Account, {})
|
|
172
|
-
})]
|
|
173
|
-
}, option.value);
|
|
174
|
-
})
|
|
175
|
-
}), /*#__PURE__*/_jsx(Box, {
|
|
176
|
-
component: "pre",
|
|
177
|
-
children: JSON.stringify({
|
|
178
|
-
flavorMultipleAdornments: values.flavorMultipleAdornments,
|
|
179
|
-
flavorWithCustomOptionsRendering: values.flavorWithCustomOptionsRendering
|
|
180
|
-
}, null, 2)
|
|
181
|
-
})]
|
|
182
|
-
})]
|
|
183
|
-
});
|
|
184
|
-
}
|
|
185
|
-
})
|
|
186
|
-
});
|
|
187
|
-
};
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
import { Lock } from "@comet/admin-icons";
|
|
2
|
-
import { InputAdornment } from "@mui/material";
|
|
3
|
-
import { Alert } from "../../alert/Alert";
|
|
4
|
-
import { FinalForm } from "../../FinalForm";
|
|
5
|
-
import { SelectField } from "../../form/fields/SelectField";
|
|
6
|
-
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
7
|
-
var config = {
|
|
8
|
-
component: SelectField,
|
|
9
|
-
title: "components/form/SelectField"
|
|
10
|
-
};
|
|
11
|
-
export default config;
|
|
12
|
-
export var Default = {
|
|
13
|
-
render: function render() {
|
|
14
|
-
return /*#__PURE__*/_jsx(FinalForm, {
|
|
15
|
-
initialValues: {
|
|
16
|
-
type: "value-1"
|
|
17
|
-
},
|
|
18
|
-
mode: "edit",
|
|
19
|
-
onSubmit: function onSubmit() {
|
|
20
|
-
// not handled
|
|
21
|
-
},
|
|
22
|
-
subscription: {
|
|
23
|
-
values: true
|
|
24
|
-
},
|
|
25
|
-
children: function children(_ref) {
|
|
26
|
-
var values = _ref.values;
|
|
27
|
-
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
28
|
-
children: [/*#__PURE__*/_jsx(SelectField, {
|
|
29
|
-
name: "type",
|
|
30
|
-
label: "SelectField",
|
|
31
|
-
fullWidth: true,
|
|
32
|
-
variant: "horizontal",
|
|
33
|
-
options: [{
|
|
34
|
-
value: "value-1",
|
|
35
|
-
label: "Value 1"
|
|
36
|
-
}, {
|
|
37
|
-
value: "value-2",
|
|
38
|
-
label: "Value 2"
|
|
39
|
-
}, {
|
|
40
|
-
value: "value-3",
|
|
41
|
-
label: "Value 3"
|
|
42
|
-
}]
|
|
43
|
-
}), /*#__PURE__*/_jsx(Alert, {
|
|
44
|
-
title: "FormState",
|
|
45
|
-
children: /*#__PURE__*/_jsx("pre", {
|
|
46
|
-
children: JSON.stringify(values, null, 2)
|
|
47
|
-
})
|
|
48
|
-
})]
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
export var Readonly = {
|
|
55
|
-
render: function render() {
|
|
56
|
-
return /*#__PURE__*/_jsx(FinalForm, {
|
|
57
|
-
initialValues: {
|
|
58
|
-
type: "value-1"
|
|
59
|
-
},
|
|
60
|
-
mode: "edit",
|
|
61
|
-
onSubmit: function onSubmit() {
|
|
62
|
-
// not handled
|
|
63
|
-
},
|
|
64
|
-
subscription: {
|
|
65
|
-
values: true
|
|
66
|
-
},
|
|
67
|
-
children: function children(_ref2) {
|
|
68
|
-
var values = _ref2.values;
|
|
69
|
-
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
70
|
-
children: [/*#__PURE__*/_jsx(SelectField, {
|
|
71
|
-
name: "type",
|
|
72
|
-
label: "SelectField",
|
|
73
|
-
fullWidth: true,
|
|
74
|
-
variant: "horizontal",
|
|
75
|
-
disabled: true,
|
|
76
|
-
endAdornment: /*#__PURE__*/_jsx(InputAdornment, {
|
|
77
|
-
position: "end",
|
|
78
|
-
children: /*#__PURE__*/_jsx(Lock, {})
|
|
79
|
-
}),
|
|
80
|
-
options: [{
|
|
81
|
-
value: "value-1",
|
|
82
|
-
label: "Value 1"
|
|
83
|
-
}, {
|
|
84
|
-
value: "value-2",
|
|
85
|
-
label: "Value 2"
|
|
86
|
-
}, {
|
|
87
|
-
value: "value-3",
|
|
88
|
-
label: "Value 3"
|
|
89
|
-
}]
|
|
90
|
-
}), /*#__PURE__*/_jsx(Alert, {
|
|
91
|
-
title: "FormState",
|
|
92
|
-
children: /*#__PURE__*/_jsx("pre", {
|
|
93
|
-
children: JSON.stringify(values, null, 2)
|
|
94
|
-
})
|
|
95
|
-
})]
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
};
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
import { Stack, Typography } from "@mui/material";
|
|
2
|
-
import { Button } from "../../common/buttons/Button";
|
|
3
|
-
import { FinalForm } from "../../FinalForm";
|
|
4
|
-
import { Field } from "../../form/Field";
|
|
5
|
-
import { FinalFormInput } from "../../form/FinalFormInput";
|
|
6
|
-
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
7
|
-
function validate(_ref) {
|
|
8
|
-
var foo = _ref.foo,
|
|
9
|
-
bar = _ref.bar;
|
|
10
|
-
var errors = {};
|
|
11
|
-
if (foo !== "foo") {
|
|
12
|
-
errors.foo = "".concat(foo, " is not foo");
|
|
13
|
-
}
|
|
14
|
-
if (bar !== "bar") {
|
|
15
|
-
errors.bar = "".concat(bar, " is not bar");
|
|
16
|
-
}
|
|
17
|
-
return errors;
|
|
18
|
-
}
|
|
19
|
-
var strategies = {
|
|
20
|
-
always: function always() {
|
|
21
|
-
return true;
|
|
22
|
-
},
|
|
23
|
-
"on-blur": function onBlur(_ref2) {
|
|
24
|
-
var touched = _ref2.touched;
|
|
25
|
-
return !!touched;
|
|
26
|
-
},
|
|
27
|
-
"while-typing": function whileTyping(_ref3) {
|
|
28
|
-
var touched = _ref3.touched,
|
|
29
|
-
active = _ref3.active;
|
|
30
|
-
return !!(touched || active);
|
|
31
|
-
},
|
|
32
|
-
"when-submitted": function whenSubmitted(_ref4) {
|
|
33
|
-
var submitFailed = _ref4.submitFailed;
|
|
34
|
-
return !!submitFailed;
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
export default {
|
|
38
|
-
title: "components/form",
|
|
39
|
-
args: {
|
|
40
|
-
strategy: "when-submitted"
|
|
41
|
-
},
|
|
42
|
-
argTypes: {
|
|
43
|
-
strategy: {
|
|
44
|
-
name: "Show Error Strategy",
|
|
45
|
-
control: "select",
|
|
46
|
-
options: ["always", "on-blur", "while-typing", "when-submitted"]
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
export var ShowErrorStrategies = {
|
|
51
|
-
render: function render(_ref5) {
|
|
52
|
-
var strategy = _ref5.strategy;
|
|
53
|
-
var initialValues = {
|
|
54
|
-
foo: "foo",
|
|
55
|
-
bar: ""
|
|
56
|
-
};
|
|
57
|
-
var shouldShowFieldError = strategies[strategy];
|
|
58
|
-
return /*#__PURE__*/_jsx(FinalForm, {
|
|
59
|
-
mode: "edit",
|
|
60
|
-
onSubmit: function onSubmit() {
|
|
61
|
-
// noop
|
|
62
|
-
},
|
|
63
|
-
initialValues: initialValues,
|
|
64
|
-
validate: validate,
|
|
65
|
-
formContext: {
|
|
66
|
-
shouldShowFieldError: shouldShowFieldError
|
|
67
|
-
},
|
|
68
|
-
children: function children(_ref6) {
|
|
69
|
-
var form = _ref6.form;
|
|
70
|
-
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
71
|
-
children: [/*#__PURE__*/_jsx(Typography, {
|
|
72
|
-
variant: "body1",
|
|
73
|
-
children: "Demonstrates different implementations of \"shouldShowFieldError\". Use Knob to switch strategies."
|
|
74
|
-
}), /*#__PURE__*/_jsxs(Typography, {
|
|
75
|
-
variant: "h3",
|
|
76
|
-
children: ["Show-Error-Strategy: \"", strategy, "\""]
|
|
77
|
-
}), /*#__PURE__*/_jsx(Field, {
|
|
78
|
-
label: "Foo",
|
|
79
|
-
name: "foo",
|
|
80
|
-
component: FinalFormInput,
|
|
81
|
-
fullWidth: true
|
|
82
|
-
}), /*#__PURE__*/_jsx(Field, {
|
|
83
|
-
label: "Bar",
|
|
84
|
-
name: "bar",
|
|
85
|
-
component: FinalFormInput,
|
|
86
|
-
fullWidth: true
|
|
87
|
-
}), /*#__PURE__*/_jsxs(Stack, {
|
|
88
|
-
direction: "row",
|
|
89
|
-
spacing: 2,
|
|
90
|
-
children: [/*#__PURE__*/_jsx(Button, {
|
|
91
|
-
type: "submit",
|
|
92
|
-
children: "Submit"
|
|
93
|
-
}), /*#__PURE__*/_jsx(Button, {
|
|
94
|
-
variant: "secondary",
|
|
95
|
-
onClick: function onClick() {
|
|
96
|
-
form.reset();
|
|
97
|
-
form.resetFieldState("foo");
|
|
98
|
-
form.resetFieldState("bar");
|
|
99
|
-
},
|
|
100
|
-
children: "Reset form and field state"
|
|
101
|
-
})]
|
|
102
|
-
})]
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
};
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
2
|
-
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
3
|
-
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
4
|
-
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
5
|
-
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
6
|
-
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
7
|
-
import { Search } from "@comet/admin-icons";
|
|
8
|
-
import { Card, CardContent, Checkbox, FormControlLabel, Grid, InputAdornment, InputBase, Typography } from "@mui/material";
|
|
9
|
-
import { useState } from "react";
|
|
10
|
-
import { FieldContainer } from "../../form/FieldContainer";
|
|
11
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
12
|
-
export default {
|
|
13
|
-
title: "components/form"
|
|
14
|
-
};
|
|
15
|
-
export var SingleTextField = {
|
|
16
|
-
render: function render() {
|
|
17
|
-
var _useState = useState(""),
|
|
18
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
19
|
-
searchString1 = _useState2[0],
|
|
20
|
-
setSearchString1 = _useState2[1];
|
|
21
|
-
var _useState3 = useState(""),
|
|
22
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
23
|
-
searchString2 = _useState4[0],
|
|
24
|
-
setSearchString2 = _useState4[1];
|
|
25
|
-
var _useState5 = useState(false),
|
|
26
|
-
_useState6 = _slicedToArray(_useState5, 2),
|
|
27
|
-
checkboxValue = _useState6[0],
|
|
28
|
-
setCheckboxValue = _useState6[1];
|
|
29
|
-
return /*#__PURE__*/_jsxs("div", {
|
|
30
|
-
style: {
|
|
31
|
-
width: 400
|
|
32
|
-
},
|
|
33
|
-
children: [/*#__PURE__*/_jsxs(Grid, {
|
|
34
|
-
container: true,
|
|
35
|
-
spacing: 4,
|
|
36
|
-
children: [/*#__PURE__*/_jsx(Grid, {
|
|
37
|
-
size: 12,
|
|
38
|
-
children: /*#__PURE__*/_jsx(Card, {
|
|
39
|
-
variant: "outlined",
|
|
40
|
-
children: /*#__PURE__*/_jsxs(CardContent, {
|
|
41
|
-
children: [/*#__PURE__*/_jsx(Typography, {
|
|
42
|
-
variant: "h4",
|
|
43
|
-
gutterBottom: true,
|
|
44
|
-
children: "Single TextField outside of form"
|
|
45
|
-
}), /*#__PURE__*/_jsx(FieldContainer, {
|
|
46
|
-
fullWidth: true,
|
|
47
|
-
children: /*#__PURE__*/_jsx(InputBase, {
|
|
48
|
-
autoFocus: true,
|
|
49
|
-
placeholder: "Search...",
|
|
50
|
-
startAdornment: /*#__PURE__*/_jsx(InputAdornment, {
|
|
51
|
-
position: "start",
|
|
52
|
-
children: /*#__PURE__*/_jsx(Search, {})
|
|
53
|
-
}),
|
|
54
|
-
onChange: function onChange(e) {
|
|
55
|
-
return setSearchString1(e.target.value);
|
|
56
|
-
},
|
|
57
|
-
value: searchString1
|
|
58
|
-
})
|
|
59
|
-
})]
|
|
60
|
-
})
|
|
61
|
-
})
|
|
62
|
-
}), /*#__PURE__*/_jsx(Grid, {
|
|
63
|
-
size: 12,
|
|
64
|
-
children: /*#__PURE__*/_jsx(Card, {
|
|
65
|
-
variant: "outlined",
|
|
66
|
-
children: /*#__PURE__*/_jsxs(CardContent, {
|
|
67
|
-
children: [/*#__PURE__*/_jsx(Typography, {
|
|
68
|
-
variant: "h4",
|
|
69
|
-
gutterBottom: true,
|
|
70
|
-
children: "With Checkbox"
|
|
71
|
-
}), /*#__PURE__*/_jsx(FieldContainer, {
|
|
72
|
-
fullWidth: true,
|
|
73
|
-
children: /*#__PURE__*/_jsx(InputBase, {
|
|
74
|
-
placeholder: "Search...",
|
|
75
|
-
startAdornment: /*#__PURE__*/_jsx(InputAdornment, {
|
|
76
|
-
position: "start",
|
|
77
|
-
children: /*#__PURE__*/_jsx(Search, {})
|
|
78
|
-
}),
|
|
79
|
-
onChange: function onChange(e) {
|
|
80
|
-
return setSearchString2(e.target.value);
|
|
81
|
-
},
|
|
82
|
-
value: searchString2
|
|
83
|
-
})
|
|
84
|
-
}), /*#__PURE__*/_jsx(FormControlLabel, {
|
|
85
|
-
control: /*#__PURE__*/_jsx(Checkbox, {
|
|
86
|
-
checked: checkboxValue,
|
|
87
|
-
onChange: function onChange(e) {
|
|
88
|
-
return setCheckboxValue(e.target.checked);
|
|
89
|
-
}
|
|
90
|
-
}),
|
|
91
|
-
label: "Additional Setting"
|
|
92
|
-
})]
|
|
93
|
-
})
|
|
94
|
-
})
|
|
95
|
-
})]
|
|
96
|
-
}), /*#__PURE__*/_jsx("div", {
|
|
97
|
-
children: /*#__PURE__*/_jsx("pre", {
|
|
98
|
-
children: JSON.stringify({
|
|
99
|
-
searchString1: searchString1,
|
|
100
|
-
searchString2: searchString2,
|
|
101
|
-
checkboxValue: checkboxValue
|
|
102
|
-
}, undefined, 2)
|
|
103
|
-
})
|
|
104
|
-
})]
|
|
105
|
-
});
|
|
106
|
-
},
|
|
107
|
-
name: "Single TextField"
|
|
108
|
-
};
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { FinalForm } from "../../FinalForm";
|
|
2
|
-
import { Field } from "../../form/Field";
|
|
3
|
-
import { FinalFormInput } from "../../form/FinalFormInput";
|
|
4
|
-
import { StackBreadcrumbs } from "../../stack/breadcrumbs/StackBreadcrumbs";
|
|
5
|
-
import { StackPage } from "../../stack/Page";
|
|
6
|
-
import { Stack } from "../../stack/Stack";
|
|
7
|
-
import { StackLink } from "../../stack/StackLink";
|
|
8
|
-
import { StackSwitch } from "../../stack/Switch";
|
|
9
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
10
|
-
export default {
|
|
11
|
-
title: "components/form"
|
|
12
|
-
};
|
|
13
|
-
export var StackInForm = {
|
|
14
|
-
render: function render() {
|
|
15
|
-
return /*#__PURE__*/_jsx(FinalForm, {
|
|
16
|
-
mode: "edit",
|
|
17
|
-
onSubmit: function onSubmit(values) {
|
|
18
|
-
alert(JSON.stringify(values));
|
|
19
|
-
},
|
|
20
|
-
initialValues: {
|
|
21
|
-
foo: "foo",
|
|
22
|
-
bar: "bar"
|
|
23
|
-
},
|
|
24
|
-
children: function children() {
|
|
25
|
-
return /*#__PURE__*/_jsxs(Stack, {
|
|
26
|
-
topLevelTitle: "Stack",
|
|
27
|
-
children: [/*#__PURE__*/_jsx(StackBreadcrumbs, {}), /*#__PURE__*/_jsxs(StackSwitch, {
|
|
28
|
-
children: [/*#__PURE__*/_jsxs(StackPage, {
|
|
29
|
-
name: "page1",
|
|
30
|
-
children: [/*#__PURE__*/_jsx(Field, {
|
|
31
|
-
label: "Foo",
|
|
32
|
-
name: "foo",
|
|
33
|
-
component: FinalFormInput
|
|
34
|
-
}), /*#__PURE__*/_jsx(StackLink, {
|
|
35
|
-
pageName: "page2",
|
|
36
|
-
payload: "xx",
|
|
37
|
-
children: "go to page2"
|
|
38
|
-
})]
|
|
39
|
-
}), /*#__PURE__*/_jsx(StackPage, {
|
|
40
|
-
name: "page2",
|
|
41
|
-
children: /*#__PURE__*/_jsx(Field, {
|
|
42
|
-
label: "Bar",
|
|
43
|
-
name: "bar",
|
|
44
|
-
component: FinalFormInput
|
|
45
|
-
})
|
|
46
|
-
})]
|
|
47
|
-
})]
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
},
|
|
52
|
-
name: "StackInForm"
|
|
53
|
-
};
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
|
|
2
|
-
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
3
|
-
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
4
|
-
import { Box, Card, CardContent } from "@mui/material";
|
|
5
|
-
import { FinalForm } from "../../FinalForm";
|
|
6
|
-
import { FinalFormSaveCancelButtonsLegacy } from "../../FinalFormSaveCancelButtonsLegacy";
|
|
7
|
-
import { Field } from "../../form/Field";
|
|
8
|
-
import { FinalFormInput } from "../../form/FinalFormInput";
|
|
9
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
10
|
-
var onSubmit = function onSubmit(_ref) {
|
|
11
|
-
var foo = _ref.foo,
|
|
12
|
-
bar = _ref.bar;
|
|
13
|
-
var errors = [];
|
|
14
|
-
if (foo !== "foo") {
|
|
15
|
-
errors.push({
|
|
16
|
-
foo: "".concat(foo, " is not foo")
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
if (bar !== "bar") {
|
|
20
|
-
errors.push({
|
|
21
|
-
bar: "".concat(bar, " is not bar")
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
return Promise.reject({
|
|
25
|
-
errors: errors
|
|
26
|
-
});
|
|
27
|
-
};
|
|
28
|
-
var resolveSubmitErrors = function resolveSubmitErrors(error) {
|
|
29
|
-
// error = { errors: [{fieldName: errorMessage},...] }
|
|
30
|
-
var result = {};
|
|
31
|
-
if (error) {
|
|
32
|
-
var _iterator = _createForOfIteratorHelper(error.errors),
|
|
33
|
-
_step;
|
|
34
|
-
try {
|
|
35
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
36
|
-
var submitError = _step.value;
|
|
37
|
-
Object.assign(result, submitError);
|
|
38
|
-
}
|
|
39
|
-
} catch (err) {
|
|
40
|
-
_iterator.e(err);
|
|
41
|
-
} finally {
|
|
42
|
-
_iterator.f();
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
// result = {fieldName: errorMessage, ...}
|
|
47
|
-
return result;
|
|
48
|
-
};
|
|
49
|
-
export default {
|
|
50
|
-
title: "components/form"
|
|
51
|
-
};
|
|
52
|
-
export var SubmitErrors = {
|
|
53
|
-
render: function render() {
|
|
54
|
-
var initialValues = {
|
|
55
|
-
foo: "foo"
|
|
56
|
-
};
|
|
57
|
-
return /*#__PURE__*/_jsxs(FinalForm, {
|
|
58
|
-
mode: "edit",
|
|
59
|
-
onSubmit: onSubmit,
|
|
60
|
-
initialValues: initialValues,
|
|
61
|
-
resolveSubmitErrors: resolveSubmitErrors,
|
|
62
|
-
children: [/*#__PURE__*/_jsx(Box, {
|
|
63
|
-
marginBottom: 4,
|
|
64
|
-
children: /*#__PURE__*/_jsx(Card, {
|
|
65
|
-
variant: "outlined",
|
|
66
|
-
children: /*#__PURE__*/_jsx(CardContent, {
|
|
67
|
-
children: /*#__PURE__*/_jsx(Field, {
|
|
68
|
-
label: "Foo",
|
|
69
|
-
name: "foo",
|
|
70
|
-
component: FinalFormInput
|
|
71
|
-
})
|
|
72
|
-
})
|
|
73
|
-
})
|
|
74
|
-
}), /*#__PURE__*/_jsx(Box, {
|
|
75
|
-
marginBottom: 4,
|
|
76
|
-
children: /*#__PURE__*/_jsx(Card, {
|
|
77
|
-
variant: "outlined",
|
|
78
|
-
children: /*#__PURE__*/_jsx(CardContent, {
|
|
79
|
-
children: /*#__PURE__*/_jsx(Field, {
|
|
80
|
-
label: "Bar",
|
|
81
|
-
name: "bar",
|
|
82
|
-
component: FinalFormInput
|
|
83
|
-
})
|
|
84
|
-
})
|
|
85
|
-
})
|
|
86
|
-
}), /*#__PURE__*/_jsx(FinalFormSaveCancelButtonsLegacy, {})]
|
|
87
|
-
});
|
|
88
|
-
},
|
|
89
|
-
name: "SubmitErrors"
|
|
90
|
-
};
|