@comet/admin 9.0.0-beta.4 → 9.0.0-beta.5
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/DeleteDialog.d.ts +1 -0
- package/lib/common/DeleteDialog.d.ts.map +1 -1
- package/lib/common/DeleteDialog.js +8 -1
- package/lib/common/buttons/clearinput/ClearInputButton.js +1 -1
- package/lib/common/toolbar/__stories__/DataGridToolbar.stories.js +76 -0
- package/lib/common/toolbar/__stories__/Toolbar.stories.js +82 -0
- package/lib/dataGrid/__stories__/ClickableRows.stories.js +109 -0
- package/lib/dataGrid/__stories__/CrudMoreActionsMenu.stories.js +50 -0
- package/lib/dataGrid/__stories__/DataGrid.stories.js +94 -0
- package/lib/dataGrid/__stories__/DataGridSingleSelectFilter.stories.js +492 -0
- package/lib/form/__stories__/AsyncAutocompleteField.stories.js +660 -0
- package/lib/form/__stories__/AsyncSelectField.stories.js +513 -0
- package/lib/form/__stories__/Autocomplete.stories.js +188 -0
- package/lib/form/__stories__/AutocompleteField.stories.js +48 -0
- package/lib/form/__stories__/Checkbox.stories.js +70 -0
- package/lib/form/__stories__/CheckboxField.stories.js +87 -0
- package/lib/form/__stories__/CheckboxListField.stories.js +172 -0
- package/lib/form/__stories__/CustomButtons.stories.js +78 -0
- package/lib/form/__stories__/DependentAsyncSelects.stories.js +91 -0
- package/lib/form/__stories__/DisableAutoNavigation.stories.js +132 -0
- package/lib/form/__stories__/DisabledSubmitIfNotDirty.stories.js +54 -0
- package/lib/form/__stories__/FieldContainer.stories.js +87 -0
- package/lib/form/__stories__/FinalFormFileSelect.stories.js +155 -0
- package/lib/form/__stories__/FormInStack.stories.js +133 -0
- package/lib/form/__stories__/FormLayouts.stories.js +174 -0
- package/lib/form/__stories__/FormValidation.stories.js +82 -0
- package/lib/form/__stories__/Input.stories.js +37 -0
- package/lib/form/__stories__/NumberField.stories.js +38 -0
- package/lib/form/__stories__/Radio.stories.js +101 -0
- package/lib/form/__stories__/RadioGroupField.stories.js +172 -0
- package/lib/form/__stories__/RangeInput.stories.js +239 -0
- package/lib/form/__stories__/RouterTabs.stories.js +96 -0
- package/lib/form/__stories__/RouterTabsInForm.stories.js +73 -0
- package/lib/form/__stories__/RouterTabsInFormWithSubroutes.stories.js +96 -0
- package/lib/form/__stories__/ScrollToErrorField.stories.js +82 -0
- package/lib/form/__stories__/SearchField.stories.js +38 -0
- package/lib/form/__stories__/Select.stories.js +187 -0
- package/lib/form/__stories__/SelectField.stories.js +100 -0
- package/lib/form/__stories__/ShowErrorStrategies.stories.js +107 -0
- package/lib/form/__stories__/SingleTextField.stories.js +108 -0
- package/lib/form/__stories__/StackInForm.stories.js +53 -0
- package/lib/form/__stories__/SubmitErrors.stories.js +90 -0
- package/lib/form/__stories__/Switch.stories.js +49 -0
- package/lib/form/__stories__/SwitchField.stories.js +87 -0
- package/lib/form/__stories__/Tabs.stories.js +78 -0
- package/lib/form/__stories__/TextAreaField.stories.js +38 -0
- package/lib/form/__stories__/TextField.stories.js +67 -0
- package/lib/form/__stories__/ToggleButtonGroupField.stories.js +312 -0
- package/lib/form/__stories__/TwoLevelValidation.stories.js +168 -0
- package/lib/form/__stories__/Typography.stories.js +71 -0
- package/lib/form/file/__stories__/FileDropzone.stories.js +81 -0
- package/lib/form/file/__stories__/FileSelect.stories.js +139 -0
- package/lib/form/file/__stories__/FileSelectListItem.stories.js +108 -0
- package/lib/form/file/__stories__/FileSelectMultipleExamples.stories.js +187 -0
- package/lib/helpers/useTopOffset.js +1 -1
- package/lib/tabs/__stories__/DynamicTabs.stories.js +84 -0
- package/lib/tabs/__stories__/NestedStackSwitchWithRouterTabs.stories.js +84 -0
- package/lib/tabs/__stories__/OverflowIssues.stories.js +224 -0
- package/lib/tabs/__stories__/RouterTabs.stories.js +31 -0
- package/lib/tabs/__stories__/RouterTabsInStack.stories.js +74 -0
- package/lib/tabs/__stories__/RouterTabsInSubroute.stories.js +68 -0
- package/lib/tabs/__stories__/Tabs.stories.js +219 -0
- package/lib/theme/componentsTheme/MuiDataGrid.js +1 -1
- package/package.json +13 -13
|
@@ -0,0 +1,660 @@
|
|
|
1
|
+
var _templateObject;
|
|
2
|
+
function _taggedTemplateLiteral(e, t) { return t || (t = e.slice(0)), Object.freeze(Object.defineProperties(e, { raw: { value: Object.freeze(t) } })); }
|
|
3
|
+
function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i["return"]) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
|
|
4
|
+
function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
|
|
5
|
+
function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
|
|
6
|
+
function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
|
|
7
|
+
import { gql, useApolloClient } from "@apollo/client";
|
|
8
|
+
import { WarningSolid } from "@comet/admin-icons";
|
|
9
|
+
import { Alert } from "../../alert/Alert";
|
|
10
|
+
import { SaveButton } from "../../common/buttons/SaveButton";
|
|
11
|
+
import { FinalForm } from "../../FinalForm";
|
|
12
|
+
import { AsyncAutocompleteField } from "../../form/fields/AsyncAutocompleteField";
|
|
13
|
+
import { TextField } from "../../form/fields/TextField";
|
|
14
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
15
|
+
var config = {
|
|
16
|
+
component: AsyncAutocompleteField,
|
|
17
|
+
title: "components/form/AsyncAutocompleteField"
|
|
18
|
+
};
|
|
19
|
+
export default config;
|
|
20
|
+
var allOptions = [{
|
|
21
|
+
label: "Marketing & Communications",
|
|
22
|
+
value: "marketing"
|
|
23
|
+
}, {
|
|
24
|
+
label: "Human Resources",
|
|
25
|
+
value: "hr"
|
|
26
|
+
}, {
|
|
27
|
+
label: "Software Development",
|
|
28
|
+
value: "dev"
|
|
29
|
+
}, {
|
|
30
|
+
label: "Product Management",
|
|
31
|
+
value: "product"
|
|
32
|
+
}, {
|
|
33
|
+
label: "Customer Support",
|
|
34
|
+
value: "support"
|
|
35
|
+
}, {
|
|
36
|
+
label: "Sales & Business Development",
|
|
37
|
+
value: "sales"
|
|
38
|
+
}, {
|
|
39
|
+
label: "Quality Assurance",
|
|
40
|
+
value: "qa"
|
|
41
|
+
}, {
|
|
42
|
+
label: "Research & Development",
|
|
43
|
+
value: "rd"
|
|
44
|
+
}, {
|
|
45
|
+
label: "Finance & Accounting",
|
|
46
|
+
value: "finance"
|
|
47
|
+
}, {
|
|
48
|
+
label: "Legal & Compliance",
|
|
49
|
+
value: "legal"
|
|
50
|
+
}, {
|
|
51
|
+
label: "Operations Management",
|
|
52
|
+
value: "operations"
|
|
53
|
+
}, {
|
|
54
|
+
label: "Data Analytics",
|
|
55
|
+
value: "analytics"
|
|
56
|
+
}, {
|
|
57
|
+
label: "User Experience Design",
|
|
58
|
+
value: "ux"
|
|
59
|
+
}, {
|
|
60
|
+
label: "Information Technology",
|
|
61
|
+
value: "it"
|
|
62
|
+
}, {
|
|
63
|
+
label: "Project Management",
|
|
64
|
+
value: "pm"
|
|
65
|
+
}, {
|
|
66
|
+
label: "Content Creation",
|
|
67
|
+
value: "content"
|
|
68
|
+
}, {
|
|
69
|
+
label: "Supply Chain Management",
|
|
70
|
+
value: "supply"
|
|
71
|
+
}, {
|
|
72
|
+
label: "Training & Development",
|
|
73
|
+
value: "training"
|
|
74
|
+
}, {
|
|
75
|
+
label: "Strategic Planning",
|
|
76
|
+
value: "strategy"
|
|
77
|
+
}, {
|
|
78
|
+
label: "Business Intelligence",
|
|
79
|
+
value: "bi"
|
|
80
|
+
}];
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Simple example of using AsyncAutocompleteField with a list of options, where the options are loaded as objects.
|
|
84
|
+
* The options are loaded asynchronously, simulating a network request.
|
|
85
|
+
*/
|
|
86
|
+
export var WithObjectOptions = {
|
|
87
|
+
render: function render() {
|
|
88
|
+
return /*#__PURE__*/_jsx(FinalForm, {
|
|
89
|
+
initialValues: {
|
|
90
|
+
department: allOptions[0]
|
|
91
|
+
},
|
|
92
|
+
mode: "edit",
|
|
93
|
+
onSubmit: function onSubmit() {
|
|
94
|
+
// not handled
|
|
95
|
+
},
|
|
96
|
+
subscription: {
|
|
97
|
+
values: true
|
|
98
|
+
},
|
|
99
|
+
children: function children(_ref) {
|
|
100
|
+
var values = _ref.values;
|
|
101
|
+
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
102
|
+
children: [/*#__PURE__*/_jsx(AsyncAutocompleteField, {
|
|
103
|
+
loadOptions: (/*#__PURE__*/function () {
|
|
104
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(search) {
|
|
105
|
+
var searchLower;
|
|
106
|
+
return _regenerator().w(function (_context) {
|
|
107
|
+
while (1) switch (_context.n) {
|
|
108
|
+
case 0:
|
|
109
|
+
_context.n = 1;
|
|
110
|
+
return new Promise(function (resolve) {
|
|
111
|
+
return setTimeout(resolve, 200);
|
|
112
|
+
});
|
|
113
|
+
case 1:
|
|
114
|
+
if (search) {
|
|
115
|
+
_context.n = 2;
|
|
116
|
+
break;
|
|
117
|
+
}
|
|
118
|
+
return _context.a(2, allOptions);
|
|
119
|
+
case 2:
|
|
120
|
+
searchLower = search.toLowerCase();
|
|
121
|
+
return _context.a(2, allOptions.filter(function (option) {
|
|
122
|
+
return option.label.toLowerCase().includes(searchLower) || option.value.toLowerCase().includes(searchLower);
|
|
123
|
+
}));
|
|
124
|
+
}
|
|
125
|
+
}, _callee);
|
|
126
|
+
}));
|
|
127
|
+
return function (_x) {
|
|
128
|
+
return _ref2.apply(this, arguments);
|
|
129
|
+
};
|
|
130
|
+
}()),
|
|
131
|
+
name: "department",
|
|
132
|
+
label: "Department",
|
|
133
|
+
fullWidth: true,
|
|
134
|
+
variant: "horizontal",
|
|
135
|
+
getOptionLabel: function getOptionLabel(option) {
|
|
136
|
+
return option.label;
|
|
137
|
+
}
|
|
138
|
+
}), /*#__PURE__*/_jsx(Alert, {
|
|
139
|
+
title: "FormState",
|
|
140
|
+
children: /*#__PURE__*/_jsx("pre", {
|
|
141
|
+
children: JSON.stringify(values, null, 2)
|
|
142
|
+
})
|
|
143
|
+
})]
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
export var Required = {
|
|
150
|
+
render: function render() {
|
|
151
|
+
return /*#__PURE__*/_jsx(FinalForm, {
|
|
152
|
+
initialValues: {
|
|
153
|
+
anotherField: ""
|
|
154
|
+
},
|
|
155
|
+
mode: "edit",
|
|
156
|
+
onSubmit: function onSubmit(values) {
|
|
157
|
+
window.alert("Form submitted with Values: ".concat(JSON.stringify(values)));
|
|
158
|
+
},
|
|
159
|
+
subscription: {
|
|
160
|
+
values: true,
|
|
161
|
+
dirty: true
|
|
162
|
+
},
|
|
163
|
+
children: function children(_ref3) {
|
|
164
|
+
var values = _ref3.values,
|
|
165
|
+
dirty = _ref3.dirty;
|
|
166
|
+
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
167
|
+
children: [/*#__PURE__*/_jsx(TextField, {
|
|
168
|
+
name: "anotherField",
|
|
169
|
+
label: "Anotherfield",
|
|
170
|
+
variant: "horizontal"
|
|
171
|
+
}), /*#__PURE__*/_jsx(AsyncAutocompleteField, {
|
|
172
|
+
required: true,
|
|
173
|
+
clearable: true,
|
|
174
|
+
loadOptions: (/*#__PURE__*/function () {
|
|
175
|
+
var _ref4 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(search) {
|
|
176
|
+
var searchLower;
|
|
177
|
+
return _regenerator().w(function (_context2) {
|
|
178
|
+
while (1) switch (_context2.n) {
|
|
179
|
+
case 0:
|
|
180
|
+
_context2.n = 1;
|
|
181
|
+
return new Promise(function (resolve) {
|
|
182
|
+
return setTimeout(resolve, 200);
|
|
183
|
+
});
|
|
184
|
+
case 1:
|
|
185
|
+
if (search) {
|
|
186
|
+
_context2.n = 2;
|
|
187
|
+
break;
|
|
188
|
+
}
|
|
189
|
+
return _context2.a(2, allOptions);
|
|
190
|
+
case 2:
|
|
191
|
+
searchLower = search.toLowerCase();
|
|
192
|
+
return _context2.a(2, allOptions.filter(function (option) {
|
|
193
|
+
return option.label.toLowerCase().includes(searchLower) || option.value.toLowerCase().includes(searchLower);
|
|
194
|
+
}));
|
|
195
|
+
}
|
|
196
|
+
}, _callee2);
|
|
197
|
+
}));
|
|
198
|
+
return function (_x2) {
|
|
199
|
+
return _ref4.apply(this, arguments);
|
|
200
|
+
};
|
|
201
|
+
}()),
|
|
202
|
+
name: "department",
|
|
203
|
+
label: "Department",
|
|
204
|
+
fullWidth: true,
|
|
205
|
+
variant: "horizontal",
|
|
206
|
+
getOptionLabel: function getOptionLabel(option) {
|
|
207
|
+
return option.label;
|
|
208
|
+
}
|
|
209
|
+
}), /*#__PURE__*/_jsx(SaveButton, {
|
|
210
|
+
type: "submit",
|
|
211
|
+
disabled: !dirty
|
|
212
|
+
}), /*#__PURE__*/_jsx(Alert, {
|
|
213
|
+
title: "FormState",
|
|
214
|
+
children: /*#__PURE__*/_jsx("pre", {
|
|
215
|
+
children: JSON.stringify(values, null, 2)
|
|
216
|
+
})
|
|
217
|
+
})]
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
};
|
|
223
|
+
export var MultipleSelect = {
|
|
224
|
+
render: function render() {
|
|
225
|
+
return /*#__PURE__*/_jsx(FinalForm, {
|
|
226
|
+
initialValues: {
|
|
227
|
+
departments: [allOptions[0]]
|
|
228
|
+
},
|
|
229
|
+
mode: "edit",
|
|
230
|
+
onSubmit: function onSubmit() {
|
|
231
|
+
// not handled
|
|
232
|
+
},
|
|
233
|
+
subscription: {
|
|
234
|
+
values: true
|
|
235
|
+
},
|
|
236
|
+
children: function children(_ref5) {
|
|
237
|
+
var values = _ref5.values;
|
|
238
|
+
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
239
|
+
children: [/*#__PURE__*/_jsx(AsyncAutocompleteField, {
|
|
240
|
+
multiple: true,
|
|
241
|
+
loadOptions: (/*#__PURE__*/function () {
|
|
242
|
+
var _ref6 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(search) {
|
|
243
|
+
var searchLower;
|
|
244
|
+
return _regenerator().w(function (_context3) {
|
|
245
|
+
while (1) switch (_context3.n) {
|
|
246
|
+
case 0:
|
|
247
|
+
_context3.n = 1;
|
|
248
|
+
return new Promise(function (resolve) {
|
|
249
|
+
return setTimeout(resolve, 200);
|
|
250
|
+
});
|
|
251
|
+
case 1:
|
|
252
|
+
if (search) {
|
|
253
|
+
_context3.n = 2;
|
|
254
|
+
break;
|
|
255
|
+
}
|
|
256
|
+
return _context3.a(2, allOptions);
|
|
257
|
+
case 2:
|
|
258
|
+
searchLower = search.toLowerCase();
|
|
259
|
+
return _context3.a(2, allOptions.filter(function (option) {
|
|
260
|
+
return option.label.toLowerCase().includes(searchLower) || option.value.toLowerCase().includes(searchLower);
|
|
261
|
+
}));
|
|
262
|
+
}
|
|
263
|
+
}, _callee3);
|
|
264
|
+
}));
|
|
265
|
+
return function (_x3) {
|
|
266
|
+
return _ref6.apply(this, arguments);
|
|
267
|
+
};
|
|
268
|
+
}()),
|
|
269
|
+
name: "departments",
|
|
270
|
+
label: "Department",
|
|
271
|
+
fullWidth: true,
|
|
272
|
+
variant: "horizontal",
|
|
273
|
+
getOptionLabel: function getOptionLabel(option) {
|
|
274
|
+
return option.label;
|
|
275
|
+
}
|
|
276
|
+
}), /*#__PURE__*/_jsx(Alert, {
|
|
277
|
+
title: "FormState",
|
|
278
|
+
children: /*#__PURE__*/_jsx("pre", {
|
|
279
|
+
children: JSON.stringify(values, null, 2)
|
|
280
|
+
})
|
|
281
|
+
})]
|
|
282
|
+
});
|
|
283
|
+
}
|
|
284
|
+
});
|
|
285
|
+
}
|
|
286
|
+
};
|
|
287
|
+
export var MultipleWithRequired = {
|
|
288
|
+
render: function render() {
|
|
289
|
+
return /*#__PURE__*/_jsx(FinalForm, {
|
|
290
|
+
initialValues: {
|
|
291
|
+
departments: []
|
|
292
|
+
},
|
|
293
|
+
mode: "edit",
|
|
294
|
+
onSubmit: function onSubmit(values) {
|
|
295
|
+
window.alert("Form submitted with Values: ".concat(JSON.stringify(values)));
|
|
296
|
+
},
|
|
297
|
+
subscription: {
|
|
298
|
+
values: true,
|
|
299
|
+
dirty: true
|
|
300
|
+
},
|
|
301
|
+
children: function children(_ref7) {
|
|
302
|
+
var values = _ref7.values,
|
|
303
|
+
dirty = _ref7.dirty;
|
|
304
|
+
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
305
|
+
children: [/*#__PURE__*/_jsx(TextField, {
|
|
306
|
+
name: "anotherField",
|
|
307
|
+
label: "Anotherfield",
|
|
308
|
+
variant: "horizontal"
|
|
309
|
+
}), /*#__PURE__*/_jsx(AsyncAutocompleteField, {
|
|
310
|
+
multiple: true,
|
|
311
|
+
clearable: true,
|
|
312
|
+
loadOptions: (/*#__PURE__*/function () {
|
|
313
|
+
var _ref8 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(search) {
|
|
314
|
+
var searchLower;
|
|
315
|
+
return _regenerator().w(function (_context4) {
|
|
316
|
+
while (1) switch (_context4.n) {
|
|
317
|
+
case 0:
|
|
318
|
+
_context4.n = 1;
|
|
319
|
+
return new Promise(function (resolve) {
|
|
320
|
+
return setTimeout(resolve, 200);
|
|
321
|
+
});
|
|
322
|
+
case 1:
|
|
323
|
+
if (search) {
|
|
324
|
+
_context4.n = 2;
|
|
325
|
+
break;
|
|
326
|
+
}
|
|
327
|
+
return _context4.a(2, allOptions);
|
|
328
|
+
case 2:
|
|
329
|
+
searchLower = search.toLowerCase();
|
|
330
|
+
return _context4.a(2, allOptions.filter(function (option) {
|
|
331
|
+
return option.label.toLowerCase().includes(searchLower) || option.value.toLowerCase().includes(searchLower);
|
|
332
|
+
}));
|
|
333
|
+
}
|
|
334
|
+
}, _callee4);
|
|
335
|
+
}));
|
|
336
|
+
return function (_x4) {
|
|
337
|
+
return _ref8.apply(this, arguments);
|
|
338
|
+
};
|
|
339
|
+
}()),
|
|
340
|
+
name: "departments",
|
|
341
|
+
label: "Department",
|
|
342
|
+
fullWidth: true,
|
|
343
|
+
required: true,
|
|
344
|
+
variant: "horizontal",
|
|
345
|
+
getOptionLabel: function getOptionLabel(option) {
|
|
346
|
+
return option.label;
|
|
347
|
+
}
|
|
348
|
+
}), /*#__PURE__*/_jsx(SaveButton, {
|
|
349
|
+
type: "submit",
|
|
350
|
+
disabled: !dirty,
|
|
351
|
+
children: "Submit"
|
|
352
|
+
}), /*#__PURE__*/_jsx(Alert, {
|
|
353
|
+
title: "FormState",
|
|
354
|
+
children: /*#__PURE__*/_jsx("pre", {
|
|
355
|
+
children: JSON.stringify(values, null, 2)
|
|
356
|
+
})
|
|
357
|
+
})]
|
|
358
|
+
});
|
|
359
|
+
}
|
|
360
|
+
});
|
|
361
|
+
}
|
|
362
|
+
};
|
|
363
|
+
export var MultipleAutocompleteNoInitialValues = {
|
|
364
|
+
render: function render() {
|
|
365
|
+
return /*#__PURE__*/_jsx(FinalForm, {
|
|
366
|
+
mode: "edit",
|
|
367
|
+
onSubmit: function onSubmit() {
|
|
368
|
+
// not handled
|
|
369
|
+
},
|
|
370
|
+
subscription: {
|
|
371
|
+
values: true
|
|
372
|
+
},
|
|
373
|
+
children: function children(_ref9) {
|
|
374
|
+
var values = _ref9.values;
|
|
375
|
+
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
376
|
+
children: [/*#__PURE__*/_jsx(AsyncAutocompleteField, {
|
|
377
|
+
multiple: true,
|
|
378
|
+
loadOptions: (/*#__PURE__*/function () {
|
|
379
|
+
var _ref0 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(search) {
|
|
380
|
+
var searchLower;
|
|
381
|
+
return _regenerator().w(function (_context5) {
|
|
382
|
+
while (1) switch (_context5.n) {
|
|
383
|
+
case 0:
|
|
384
|
+
_context5.n = 1;
|
|
385
|
+
return new Promise(function (resolve) {
|
|
386
|
+
return setTimeout(resolve, 200);
|
|
387
|
+
});
|
|
388
|
+
case 1:
|
|
389
|
+
if (search) {
|
|
390
|
+
_context5.n = 2;
|
|
391
|
+
break;
|
|
392
|
+
}
|
|
393
|
+
return _context5.a(2, allOptions);
|
|
394
|
+
case 2:
|
|
395
|
+
searchLower = search.toLowerCase();
|
|
396
|
+
return _context5.a(2, allOptions.filter(function (option) {
|
|
397
|
+
return option.label.toLowerCase().includes(searchLower) || option.value.toLowerCase().includes(searchLower);
|
|
398
|
+
}));
|
|
399
|
+
}
|
|
400
|
+
}, _callee5);
|
|
401
|
+
}));
|
|
402
|
+
return function (_x5) {
|
|
403
|
+
return _ref0.apply(this, arguments);
|
|
404
|
+
};
|
|
405
|
+
}()),
|
|
406
|
+
name: "departments",
|
|
407
|
+
label: "Department",
|
|
408
|
+
fullWidth: true,
|
|
409
|
+
variant: "horizontal",
|
|
410
|
+
getOptionLabel: function getOptionLabel(option) {
|
|
411
|
+
return option.label;
|
|
412
|
+
}
|
|
413
|
+
}), /*#__PURE__*/_jsx(Alert, {
|
|
414
|
+
title: "FormState",
|
|
415
|
+
children: /*#__PURE__*/_jsx("pre", {
|
|
416
|
+
children: JSON.stringify(values, null, 2)
|
|
417
|
+
})
|
|
418
|
+
})]
|
|
419
|
+
});
|
|
420
|
+
}
|
|
421
|
+
});
|
|
422
|
+
}
|
|
423
|
+
};
|
|
424
|
+
export var LongLoading = {
|
|
425
|
+
render: function render() {
|
|
426
|
+
return /*#__PURE__*/_jsx(FinalForm, {
|
|
427
|
+
initialValues: {
|
|
428
|
+
department: allOptions[0]
|
|
429
|
+
},
|
|
430
|
+
mode: "edit",
|
|
431
|
+
onSubmit: function onSubmit() {
|
|
432
|
+
// not handled
|
|
433
|
+
},
|
|
434
|
+
subscription: {
|
|
435
|
+
values: true
|
|
436
|
+
},
|
|
437
|
+
children: function children(_ref1) {
|
|
438
|
+
var values = _ref1.values;
|
|
439
|
+
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
440
|
+
children: [/*#__PURE__*/_jsx(AsyncAutocompleteField, {
|
|
441
|
+
loadOptions: (/*#__PURE__*/function () {
|
|
442
|
+
var _ref10 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6(search) {
|
|
443
|
+
var searchLower;
|
|
444
|
+
return _regenerator().w(function (_context6) {
|
|
445
|
+
while (1) switch (_context6.n) {
|
|
446
|
+
case 0:
|
|
447
|
+
_context6.n = 1;
|
|
448
|
+
return new Promise(function (resolve) {
|
|
449
|
+
return setTimeout(resolve, 5000);
|
|
450
|
+
});
|
|
451
|
+
case 1:
|
|
452
|
+
if (search) {
|
|
453
|
+
_context6.n = 2;
|
|
454
|
+
break;
|
|
455
|
+
}
|
|
456
|
+
return _context6.a(2, allOptions);
|
|
457
|
+
case 2:
|
|
458
|
+
searchLower = search.toLowerCase();
|
|
459
|
+
return _context6.a(2, allOptions.filter(function (option) {
|
|
460
|
+
return option.label.toLowerCase().includes(searchLower) || option.value.toLowerCase().includes(searchLower);
|
|
461
|
+
}));
|
|
462
|
+
}
|
|
463
|
+
}, _callee6);
|
|
464
|
+
}));
|
|
465
|
+
return function (_x6) {
|
|
466
|
+
return _ref10.apply(this, arguments);
|
|
467
|
+
};
|
|
468
|
+
}()),
|
|
469
|
+
name: "department",
|
|
470
|
+
label: "Department",
|
|
471
|
+
fullWidth: true,
|
|
472
|
+
variant: "horizontal",
|
|
473
|
+
getOptionLabel: function getOptionLabel(option) {
|
|
474
|
+
return option.label;
|
|
475
|
+
}
|
|
476
|
+
}), /*#__PURE__*/_jsx(Alert, {
|
|
477
|
+
title: "FormState",
|
|
478
|
+
children: /*#__PURE__*/_jsx("pre", {
|
|
479
|
+
children: JSON.stringify(values, null, 2)
|
|
480
|
+
})
|
|
481
|
+
})]
|
|
482
|
+
});
|
|
483
|
+
}
|
|
484
|
+
});
|
|
485
|
+
}
|
|
486
|
+
};
|
|
487
|
+
export var AsyncAutocompleteLoadingDataFromApi = {
|
|
488
|
+
render: function render() {
|
|
489
|
+
var client = useApolloClient();
|
|
490
|
+
return /*#__PURE__*/_jsx(FinalForm, {
|
|
491
|
+
initialValues: {},
|
|
492
|
+
mode: "edit",
|
|
493
|
+
onSubmit: function onSubmit() {
|
|
494
|
+
// not handled
|
|
495
|
+
},
|
|
496
|
+
subscription: {
|
|
497
|
+
values: true
|
|
498
|
+
},
|
|
499
|
+
children: function children(_ref11) {
|
|
500
|
+
var values = _ref11.values;
|
|
501
|
+
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
502
|
+
children: [/*#__PURE__*/_jsx(AsyncAutocompleteField, {
|
|
503
|
+
loadOptions: (/*#__PURE__*/function () {
|
|
504
|
+
var _ref12 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee7(search) {
|
|
505
|
+
var _yield$client$query, data;
|
|
506
|
+
return _regenerator().w(function (_context7) {
|
|
507
|
+
while (1) switch (_context7.n) {
|
|
508
|
+
case 0:
|
|
509
|
+
_context7.n = 1;
|
|
510
|
+
return client.query({
|
|
511
|
+
query: gql(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n query Manufacturers($search: String) {\n manufacturers(search: $search) {\n id\n name\n }\n }\n "]))),
|
|
512
|
+
variables: {
|
|
513
|
+
search: search
|
|
514
|
+
}
|
|
515
|
+
});
|
|
516
|
+
case 1:
|
|
517
|
+
_yield$client$query = _context7.v;
|
|
518
|
+
data = _yield$client$query.data;
|
|
519
|
+
return _context7.a(2, data.manufacturers.map(function (manufacturer) {
|
|
520
|
+
return {
|
|
521
|
+
value: manufacturer.id,
|
|
522
|
+
label: manufacturer.name
|
|
523
|
+
};
|
|
524
|
+
}));
|
|
525
|
+
}
|
|
526
|
+
}, _callee7);
|
|
527
|
+
}));
|
|
528
|
+
return function (_x7) {
|
|
529
|
+
return _ref12.apply(this, arguments);
|
|
530
|
+
};
|
|
531
|
+
}()),
|
|
532
|
+
name: "manufacturer",
|
|
533
|
+
label: "Manufacturer",
|
|
534
|
+
fullWidth: true,
|
|
535
|
+
variant: "horizontal",
|
|
536
|
+
getOptionLabel: function getOptionLabel(option) {
|
|
537
|
+
return option.label;
|
|
538
|
+
}
|
|
539
|
+
}), /*#__PURE__*/_jsx(Alert, {
|
|
540
|
+
title: "FormState",
|
|
541
|
+
children: /*#__PURE__*/_jsx("pre", {
|
|
542
|
+
children: JSON.stringify(values, null, 2)
|
|
543
|
+
})
|
|
544
|
+
})]
|
|
545
|
+
});
|
|
546
|
+
}
|
|
547
|
+
});
|
|
548
|
+
}
|
|
549
|
+
};
|
|
550
|
+
export var ErrorLoadingOptions = {
|
|
551
|
+
render: function render() {
|
|
552
|
+
return /*#__PURE__*/_jsx(FinalForm, {
|
|
553
|
+
initialValues: {
|
|
554
|
+
department: allOptions[0]
|
|
555
|
+
},
|
|
556
|
+
mode: "edit",
|
|
557
|
+
onSubmit: function onSubmit() {
|
|
558
|
+
// not handled
|
|
559
|
+
},
|
|
560
|
+
subscription: {
|
|
561
|
+
values: true
|
|
562
|
+
},
|
|
563
|
+
children: function children(_ref13) {
|
|
564
|
+
var values = _ref13.values;
|
|
565
|
+
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
566
|
+
children: [/*#__PURE__*/_jsx(AsyncAutocompleteField, {
|
|
567
|
+
loadOptions: /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee8() {
|
|
568
|
+
return _regenerator().w(function (_context8) {
|
|
569
|
+
while (1) switch (_context8.n) {
|
|
570
|
+
case 0:
|
|
571
|
+
_context8.n = 1;
|
|
572
|
+
return new Promise(function (resolve) {
|
|
573
|
+
return setTimeout(resolve, 500);
|
|
574
|
+
});
|
|
575
|
+
case 1:
|
|
576
|
+
throw Error("Error loading options");
|
|
577
|
+
case 2:
|
|
578
|
+
return _context8.a(2);
|
|
579
|
+
}
|
|
580
|
+
}, _callee8);
|
|
581
|
+
})),
|
|
582
|
+
name: "department",
|
|
583
|
+
label: "Department",
|
|
584
|
+
fullWidth: true,
|
|
585
|
+
variant: "horizontal",
|
|
586
|
+
getOptionLabel: function getOptionLabel(option) {
|
|
587
|
+
return option.label;
|
|
588
|
+
}
|
|
589
|
+
}), /*#__PURE__*/_jsx(Alert, {
|
|
590
|
+
title: "FormState",
|
|
591
|
+
children: /*#__PURE__*/_jsx("pre", {
|
|
592
|
+
children: JSON.stringify(values, null, 2)
|
|
593
|
+
})
|
|
594
|
+
})]
|
|
595
|
+
});
|
|
596
|
+
}
|
|
597
|
+
});
|
|
598
|
+
}
|
|
599
|
+
};
|
|
600
|
+
export var ErrorLoadingOptionsWithCustomErrorText = {
|
|
601
|
+
render: function render() {
|
|
602
|
+
return /*#__PURE__*/_jsx(FinalForm, {
|
|
603
|
+
initialValues: {
|
|
604
|
+
department: allOptions[0]
|
|
605
|
+
},
|
|
606
|
+
mode: "edit",
|
|
607
|
+
onSubmit: function onSubmit() {
|
|
608
|
+
// not handled
|
|
609
|
+
},
|
|
610
|
+
subscription: {
|
|
611
|
+
values: true
|
|
612
|
+
},
|
|
613
|
+
children: function children(_ref15) {
|
|
614
|
+
var values = _ref15.values;
|
|
615
|
+
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
616
|
+
children: [/*#__PURE__*/_jsx(AsyncAutocompleteField, {
|
|
617
|
+
loadOptions: /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee9() {
|
|
618
|
+
return _regenerator().w(function (_context9) {
|
|
619
|
+
while (1) switch (_context9.n) {
|
|
620
|
+
case 0:
|
|
621
|
+
_context9.n = 1;
|
|
622
|
+
return new Promise(function (resolve) {
|
|
623
|
+
return setTimeout(resolve, 500);
|
|
624
|
+
});
|
|
625
|
+
case 1:
|
|
626
|
+
throw Error("Error loading options");
|
|
627
|
+
case 2:
|
|
628
|
+
return _context9.a(2);
|
|
629
|
+
}
|
|
630
|
+
}, _callee9);
|
|
631
|
+
})),
|
|
632
|
+
name: "department",
|
|
633
|
+
label: "Department",
|
|
634
|
+
fullWidth: true,
|
|
635
|
+
variant: "horizontal",
|
|
636
|
+
getOptionLabel: function getOptionLabel(option) {
|
|
637
|
+
return option.label;
|
|
638
|
+
},
|
|
639
|
+
errorText: /*#__PURE__*/_jsxs("div", {
|
|
640
|
+
style: {
|
|
641
|
+
display: "flex",
|
|
642
|
+
alignItems: "center",
|
|
643
|
+
gap: "8px",
|
|
644
|
+
color: "black"
|
|
645
|
+
},
|
|
646
|
+
children: [/*#__PURE__*/_jsx(WarningSolid, {
|
|
647
|
+
color: "error"
|
|
648
|
+
}), "Error loading options"]
|
|
649
|
+
})
|
|
650
|
+
}), /*#__PURE__*/_jsx(Alert, {
|
|
651
|
+
title: "FormState",
|
|
652
|
+
children: /*#__PURE__*/_jsx("pre", {
|
|
653
|
+
children: JSON.stringify(values, null, 2)
|
|
654
|
+
})
|
|
655
|
+
})]
|
|
656
|
+
});
|
|
657
|
+
}
|
|
658
|
+
});
|
|
659
|
+
}
|
|
660
|
+
};
|