@rjsf/chakra-ui 4.2.0 → 4.2.3
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/AltDateTimeWidget/AltDateTimeWidget.d.ts +0 -1
- package/dist/AltDateWidget/AltDateWidget.d.ts +0 -1
- package/dist/ArrayFieldTemplate/ArrayFieldTemplate.d.ts +0 -1
- package/dist/ChakraFrameProvider.d.ts +0 -1
- package/dist/CheckboxWidget/CheckboxWidget.d.ts +0 -1
- package/dist/CheckboxesWidget/CheckboxesWidget.d.ts +0 -1
- package/dist/ColorWidget/ColorWidget.d.ts +0 -1
- package/dist/CssReset.d.ts +0 -1
- package/dist/DateTimeWidget/DateTimeWidget.d.ts +0 -1
- package/dist/DateWidget/DateWidget.d.ts +0 -1
- package/dist/DescriptionField/DescriptionField.d.ts +0 -1
- package/dist/EmailWidget/EmailWidget.d.ts +0 -1
- package/dist/ErrorList/ErrorList.d.ts +0 -1
- package/dist/FieldTemplate/FieldTemplate.d.ts +0 -1
- package/dist/Fields/Fields.d.ts +0 -1
- package/dist/ObjectFieldTemplate/ObjectFieldTemplate.d.ts +0 -1
- package/dist/PasswordWidget/PasswordWidget.d.ts +0 -1
- package/dist/RadioWidget/RadioWidget.d.ts +0 -1
- package/dist/RangeWidget/RangeWidget.d.ts +0 -1
- package/dist/SelectWidget/SelectWidget.d.ts +0 -1
- package/dist/SubmitButton/SubmitButton.d.ts +0 -1
- package/dist/TextWidget/TextWidget.d.ts +0 -1
- package/dist/TextareaWidget/TextareaWidget.d.ts +0 -1
- package/dist/TitleField/TitleField.d.ts +0 -1
- package/dist/URLWidget/URLWidget.d.ts +0 -1
- package/dist/UpDownWidget/UpDownWidget.d.ts +0 -1
- package/dist/Widgets/Widgets.d.ts +1 -1
- package/dist/chakra-ui.cjs.development.js +24 -1
- package/dist/chakra-ui.cjs.development.js.map +1 -1
- package/dist/chakra-ui.cjs.production.min.js +1 -1
- package/dist/chakra-ui.cjs.production.min.js.map +1 -1
- package/dist/chakra-ui.esm.js +24 -1
- package/dist/chakra-ui.esm.js.map +1 -1
- package/dist/chakra-ui.umd.development.js +1381 -0
- package/dist/chakra-ui.umd.development.js.map +1 -0
- package/dist/chakra-ui.umd.production.min.js +2 -0
- package/dist/chakra-ui.umd.production.min.js.map +1 -0
- package/package.json +5 -8
|
@@ -0,0 +1,1381 @@
|
|
|
1
|
+
(function (global, factory) {
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@rjsf/core'), require('react'), require('@chakra-ui/react'), require('@chakra-ui/icons'), require('chakra-react-select'), require('@emotion/react'), require('@emotion/cache'), require('@emotion/weak-memoize')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', '@rjsf/core', 'react', '@chakra-ui/react', '@chakra-ui/icons', 'chakra-react-select', '@emotion/react', '@emotion/cache', '@emotion/weak-memoize'], factory) :
|
|
4
|
+
(global = global || self, factory(global['@rjsf/chakra-ui'] = {}, global.core, global.React, global.react, global.icons, global.chakraReactSelect, global.react$1, global.createCache, global.weakMemoize));
|
|
5
|
+
}(this, (function (exports, core, React, react, icons, chakraReactSelect, react$1, createCache, weakMemoize) { 'use strict';
|
|
6
|
+
|
|
7
|
+
var React__default = 'default' in React ? React['default'] : React;
|
|
8
|
+
createCache = createCache && Object.prototype.hasOwnProperty.call(createCache, 'default') ? createCache['default'] : createCache;
|
|
9
|
+
weakMemoize = weakMemoize && Object.prototype.hasOwnProperty.call(weakMemoize, 'default') ? weakMemoize['default'] : weakMemoize;
|
|
10
|
+
|
|
11
|
+
function _extends() {
|
|
12
|
+
_extends = Object.assign || function (target) {
|
|
13
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
14
|
+
var source = arguments[i];
|
|
15
|
+
|
|
16
|
+
for (var key in source) {
|
|
17
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
18
|
+
target[key] = source[key];
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return target;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
return _extends.apply(this, arguments);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
30
|
+
if (source == null) return {};
|
|
31
|
+
var target = {};
|
|
32
|
+
var sourceKeys = Object.keys(source);
|
|
33
|
+
var key, i;
|
|
34
|
+
|
|
35
|
+
for (i = 0; i < sourceKeys.length; i++) {
|
|
36
|
+
key = sourceKeys[i];
|
|
37
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
38
|
+
target[key] = source[key];
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return target;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
var AddButton = function AddButton(props) {
|
|
45
|
+
return React__default.createElement(react.Button, Object.assign({
|
|
46
|
+
leftIcon: React__default.createElement(icons.AddIcon, null)
|
|
47
|
+
}, props), "Add Item");
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
var _excluded = ["icon"];
|
|
51
|
+
var mappings = {
|
|
52
|
+
remove: /*#__PURE__*/React__default.createElement(icons.DeleteIcon, null),
|
|
53
|
+
plus: /*#__PURE__*/React__default.createElement(icons.AddIcon, null),
|
|
54
|
+
"arrow-up": /*#__PURE__*/React__default.createElement(icons.ArrowUpIcon, null),
|
|
55
|
+
"arrow-down": /*#__PURE__*/React__default.createElement(icons.ArrowDownIcon, null)
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* props used in Template:
|
|
59
|
+
* icon, tabIndex, disabled, onClick
|
|
60
|
+
*/
|
|
61
|
+
|
|
62
|
+
var ChakraIconButton = /*#__PURE__*/React.memo(function (props) {
|
|
63
|
+
var icon = props.icon,
|
|
64
|
+
otherProps = _objectWithoutPropertiesLoose(props, _excluded);
|
|
65
|
+
|
|
66
|
+
return React__default.createElement(react.IconButton, Object.assign({}, otherProps, {
|
|
67
|
+
icon: mappings[icon],
|
|
68
|
+
"aria-label": icon
|
|
69
|
+
}));
|
|
70
|
+
});
|
|
71
|
+
ChakraIconButton.displayName = 'ChakraIconButton';
|
|
72
|
+
|
|
73
|
+
var _excluded$1 = ["key"],
|
|
74
|
+
_excluded2 = ["key"];
|
|
75
|
+
var isMultiSelect = core.utils.isMultiSelect,
|
|
76
|
+
getDefaultRegistry = core.utils.getDefaultRegistry;
|
|
77
|
+
|
|
78
|
+
var ArrayFieldTemplate = function ArrayFieldTemplate(props) {
|
|
79
|
+
var schema = props.schema,
|
|
80
|
+
_props$registry = props.registry,
|
|
81
|
+
registry = _props$registry === void 0 ? getDefaultRegistry() : _props$registry;
|
|
82
|
+
|
|
83
|
+
if (isMultiSelect(schema, registry.rootSchema)) {
|
|
84
|
+
return React__default.createElement(DefaultFixedArrayFieldTemplate, Object.assign({}, props));
|
|
85
|
+
} else {
|
|
86
|
+
return React__default.createElement(DefaultNormalArrayFieldTemplate, Object.assign({}, props));
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
var ArrayFieldTitle = function ArrayFieldTitle(_ref) {
|
|
91
|
+
var TitleField = _ref.TitleField,
|
|
92
|
+
idSchema = _ref.idSchema,
|
|
93
|
+
title = _ref.title,
|
|
94
|
+
required = _ref.required;
|
|
95
|
+
|
|
96
|
+
if (!title) {
|
|
97
|
+
return null;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
var id = idSchema.$id + "__title";
|
|
101
|
+
return React__default.createElement(TitleField, {
|
|
102
|
+
id: id,
|
|
103
|
+
title: title,
|
|
104
|
+
required: required
|
|
105
|
+
});
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
var ArrayFieldDescription = function ArrayFieldDescription(_ref2) {
|
|
109
|
+
var DescriptionField = _ref2.DescriptionField,
|
|
110
|
+
idSchema = _ref2.idSchema,
|
|
111
|
+
description = _ref2.description;
|
|
112
|
+
|
|
113
|
+
if (!description) {
|
|
114
|
+
return null;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
var id = idSchema.$id + "__description";
|
|
118
|
+
return React__default.createElement(DescriptionField, {
|
|
119
|
+
id: id,
|
|
120
|
+
description: description
|
|
121
|
+
});
|
|
122
|
+
}; // Used in the two templates
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
var DefaultArrayItem = function DefaultArrayItem(_ref3) {
|
|
126
|
+
var index = _ref3.index,
|
|
127
|
+
readonly = _ref3.readonly,
|
|
128
|
+
disabled = _ref3.disabled,
|
|
129
|
+
children = _ref3.children,
|
|
130
|
+
hasToolbar = _ref3.hasToolbar,
|
|
131
|
+
hasRemove = _ref3.hasRemove,
|
|
132
|
+
hasMoveUp = _ref3.hasMoveUp,
|
|
133
|
+
hasMoveDown = _ref3.hasMoveDown,
|
|
134
|
+
onReorderClick = _ref3.onReorderClick,
|
|
135
|
+
onDropIndexClick = _ref3.onDropIndexClick;
|
|
136
|
+
var onRemoveClick = React.useMemo(function () {
|
|
137
|
+
return onDropIndexClick(index);
|
|
138
|
+
}, [index, onDropIndexClick]);
|
|
139
|
+
var onArrowUpClick = React.useMemo(function () {
|
|
140
|
+
return onReorderClick(index, index - 1);
|
|
141
|
+
}, [index, onReorderClick]);
|
|
142
|
+
var onArrowDownClick = React.useMemo(function () {
|
|
143
|
+
return onReorderClick(index, index + 1);
|
|
144
|
+
}, [index, onReorderClick]);
|
|
145
|
+
return React__default.createElement(react.HStack, {
|
|
146
|
+
alignItems: "flex-end",
|
|
147
|
+
py: 1
|
|
148
|
+
}, React__default.createElement(react.Box, {
|
|
149
|
+
w: "100%"
|
|
150
|
+
}, children), hasToolbar && React__default.createElement(react.Box, null, React__default.createElement(react.ButtonGroup, {
|
|
151
|
+
isAttached: true,
|
|
152
|
+
mb: 1
|
|
153
|
+
}, (hasMoveUp || hasMoveDown) && React__default.createElement(ChakraIconButton, {
|
|
154
|
+
icon: "arrow-up",
|
|
155
|
+
tabIndex: -1,
|
|
156
|
+
disabled: disabled || readonly || !hasMoveUp,
|
|
157
|
+
onClick: onArrowUpClick
|
|
158
|
+
}), (hasMoveUp || hasMoveDown) && React__default.createElement(ChakraIconButton, {
|
|
159
|
+
icon: "arrow-down",
|
|
160
|
+
tabIndex: -1,
|
|
161
|
+
disabled: disabled || readonly || !hasMoveDown,
|
|
162
|
+
onClick: onArrowDownClick
|
|
163
|
+
}), hasRemove && React__default.createElement(ChakraIconButton, {
|
|
164
|
+
icon: "remove",
|
|
165
|
+
tabIndex: -1,
|
|
166
|
+
disabled: disabled || readonly,
|
|
167
|
+
onClick: onRemoveClick
|
|
168
|
+
}))));
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
var DefaultFixedArrayFieldTemplate = function DefaultFixedArrayFieldTemplate(props) {
|
|
172
|
+
return React__default.createElement("fieldset", {
|
|
173
|
+
className: props.className
|
|
174
|
+
}, React__default.createElement(ArrayFieldTitle, {
|
|
175
|
+
key: "array-field-title-" + props.idSchema.$id,
|
|
176
|
+
TitleField: props.TitleField,
|
|
177
|
+
idSchema: props.idSchema,
|
|
178
|
+
title: props.uiSchema["ui:title"] || props.title,
|
|
179
|
+
required: props.required
|
|
180
|
+
}), (props.uiSchema["ui:description"] || props.schema.description) && // Use DescriptionField if possible
|
|
181
|
+
React__default.createElement("div", {
|
|
182
|
+
className: "field-description",
|
|
183
|
+
key: "field-description-" + props.idSchema.$id
|
|
184
|
+
}, props.uiSchema["ui:description"] || props.schema.description), React__default.createElement("div", {
|
|
185
|
+
className: "row array-item-list",
|
|
186
|
+
key: "array-item-list-" + props.idSchema.$id
|
|
187
|
+
}, props.items && props.items.map(function (p) {
|
|
188
|
+
var key = p.key,
|
|
189
|
+
itemProps = _objectWithoutPropertiesLoose(p, _excluded$1);
|
|
190
|
+
|
|
191
|
+
return React__default.createElement(DefaultArrayItem, Object.assign({
|
|
192
|
+
key: key
|
|
193
|
+
}, itemProps));
|
|
194
|
+
})), props.canAdd && React__default.createElement(AddButton, {
|
|
195
|
+
justifySelf: "flex-end",
|
|
196
|
+
className: "array-item-add",
|
|
197
|
+
onClick: props.onAddClick,
|
|
198
|
+
disabled: props.disabled || props.readonly
|
|
199
|
+
}));
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
var DefaultNormalArrayFieldTemplate = function DefaultNormalArrayFieldTemplate(props) {
|
|
203
|
+
return React__default.createElement(react.Box, null, React__default.createElement(ArrayFieldTitle, {
|
|
204
|
+
key: "array-field-title-" + props.idSchema.$id,
|
|
205
|
+
TitleField: props.TitleField,
|
|
206
|
+
idSchema: props.idSchema,
|
|
207
|
+
title: props.uiSchema["ui:title"] || props.title,
|
|
208
|
+
required: props.required
|
|
209
|
+
}), (props.uiSchema["ui:description"] || props.schema.description) && React__default.createElement(ArrayFieldDescription, {
|
|
210
|
+
key: "array-field-description-" + props.idSchema.$id,
|
|
211
|
+
DescriptionField: props.DescriptionField,
|
|
212
|
+
idSchema: props.idSchema,
|
|
213
|
+
description: props.uiSchema["ui:description"] || props.schema.description
|
|
214
|
+
}), React__default.createElement(react.Grid, {
|
|
215
|
+
key: "array-item-list-" + props.idSchema.$id
|
|
216
|
+
}, React__default.createElement(react.GridItem, null, props.items.length > 0 && props.items.map(function (p) {
|
|
217
|
+
var key = p.key,
|
|
218
|
+
itemProps = _objectWithoutPropertiesLoose(p, _excluded2);
|
|
219
|
+
|
|
220
|
+
return React__default.createElement(DefaultArrayItem, Object.assign({
|
|
221
|
+
key: key
|
|
222
|
+
}, itemProps));
|
|
223
|
+
})), props.canAdd && React__default.createElement(react.GridItem, {
|
|
224
|
+
justifySelf: "flex-end"
|
|
225
|
+
}, React__default.createElement(react.Box, {
|
|
226
|
+
mt: 2
|
|
227
|
+
}, React__default.createElement(AddButton, {
|
|
228
|
+
className: "array-item-add",
|
|
229
|
+
onClick: props.onAddClick,
|
|
230
|
+
disabled: props.disabled || props.readonly
|
|
231
|
+
})))));
|
|
232
|
+
};
|
|
233
|
+
|
|
234
|
+
var ErrorList = function ErrorList(_ref) {
|
|
235
|
+
var errors = _ref.errors;
|
|
236
|
+
return React__default.createElement(react.Alert, {
|
|
237
|
+
flexDirection: "column",
|
|
238
|
+
alignItems: "flex-start",
|
|
239
|
+
gap: 3,
|
|
240
|
+
status: "error"
|
|
241
|
+
}, React__default.createElement(react.AlertTitle, null, "Errors"), React__default.createElement(react.List, null, errors.map(function (error, i) {
|
|
242
|
+
return React__default.createElement(react.ListItem, {
|
|
243
|
+
key: i
|
|
244
|
+
}, React__default.createElement(react.ListIcon, {
|
|
245
|
+
as: icons.WarningIcon,
|
|
246
|
+
color: "red.500"
|
|
247
|
+
}), error.stack);
|
|
248
|
+
})));
|
|
249
|
+
};
|
|
250
|
+
|
|
251
|
+
var TitleField = function TitleField(_ref) {
|
|
252
|
+
var title = _ref.title;
|
|
253
|
+
return React__default.createElement(react.Box, {
|
|
254
|
+
mt: 1,
|
|
255
|
+
mb: 4
|
|
256
|
+
}, React__default.createElement(react.Heading, {
|
|
257
|
+
as: "h5"
|
|
258
|
+
}, title), React__default.createElement(react.Divider, null));
|
|
259
|
+
};
|
|
260
|
+
|
|
261
|
+
var DescriptionField = function DescriptionField(_ref) {
|
|
262
|
+
var description = _ref.description,
|
|
263
|
+
id = _ref.id;
|
|
264
|
+
if (!description) return null;
|
|
265
|
+
|
|
266
|
+
if (typeof description === "string") {
|
|
267
|
+
return React__default.createElement(react.Text, {
|
|
268
|
+
id: id,
|
|
269
|
+
mt: 2,
|
|
270
|
+
mb: 4
|
|
271
|
+
}, description);
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
return React__default.createElement(React__default.Fragment, null, description);
|
|
275
|
+
};
|
|
276
|
+
|
|
277
|
+
var Fields = {
|
|
278
|
+
TitleField: TitleField,
|
|
279
|
+
DescriptionField: DescriptionField
|
|
280
|
+
};
|
|
281
|
+
|
|
282
|
+
var ADDITIONAL_PROPERTY_FLAG = core.utils.ADDITIONAL_PROPERTY_FLAG;
|
|
283
|
+
|
|
284
|
+
var WrapIfAdditional = function WrapIfAdditional(props) {
|
|
285
|
+
var children = props.children,
|
|
286
|
+
disabled = props.disabled,
|
|
287
|
+
id = props.id,
|
|
288
|
+
label = props.label,
|
|
289
|
+
onDropPropertyClick = props.onDropPropertyClick,
|
|
290
|
+
onKeyChange = props.onKeyChange,
|
|
291
|
+
readonly = props.readonly,
|
|
292
|
+
required = props.required,
|
|
293
|
+
schema = props.schema;
|
|
294
|
+
var additional = schema.hasOwnProperty(ADDITIONAL_PROPERTY_FLAG);
|
|
295
|
+
|
|
296
|
+
if (!additional) {
|
|
297
|
+
return React.createElement(React.Fragment, null, children);
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
var keyLabel = label + " Key";
|
|
301
|
+
|
|
302
|
+
var handleBlur = function handleBlur(_ref) {
|
|
303
|
+
var target = _ref.target;
|
|
304
|
+
return onKeyChange(target.value);
|
|
305
|
+
};
|
|
306
|
+
|
|
307
|
+
return React.createElement(react.Grid, {
|
|
308
|
+
key: id + "-key",
|
|
309
|
+
alignItems: "center",
|
|
310
|
+
gap: 2
|
|
311
|
+
}, React.createElement(react.GridItem, null, React.createElement(react.FormControl, {
|
|
312
|
+
isRequired: required
|
|
313
|
+
}, React.createElement(react.FormLabel, {
|
|
314
|
+
htmlFor: id + "-key"
|
|
315
|
+
}, keyLabel), React.createElement(react.Input, {
|
|
316
|
+
defaultValue: label,
|
|
317
|
+
disabled: disabled || readonly,
|
|
318
|
+
id: id + "-key",
|
|
319
|
+
name: id + "-key",
|
|
320
|
+
onBlur: !readonly ? handleBlur : undefined,
|
|
321
|
+
type: "text",
|
|
322
|
+
mb: 1
|
|
323
|
+
}))), React.createElement(react.GridItem, null, children), React.createElement(react.GridItem, null, React.createElement(ChakraIconButton, {
|
|
324
|
+
icon: "remove",
|
|
325
|
+
tabIndex: -1,
|
|
326
|
+
disabled: disabled || readonly,
|
|
327
|
+
onClick: onDropPropertyClick(label)
|
|
328
|
+
})));
|
|
329
|
+
};
|
|
330
|
+
|
|
331
|
+
var FieldTemplate = function FieldTemplate(props) {
|
|
332
|
+
var id = props.id,
|
|
333
|
+
children = props.children,
|
|
334
|
+
classNames = props.classNames,
|
|
335
|
+
disabled = props.disabled,
|
|
336
|
+
displayLabel = props.displayLabel,
|
|
337
|
+
hidden = props.hidden,
|
|
338
|
+
label = props.label,
|
|
339
|
+
onDropPropertyClick = props.onDropPropertyClick,
|
|
340
|
+
onKeyChange = props.onKeyChange,
|
|
341
|
+
readonly = props.readonly,
|
|
342
|
+
required = props.required,
|
|
343
|
+
_props$rawErrors = props.rawErrors,
|
|
344
|
+
rawErrors = _props$rawErrors === void 0 ? [] : _props$rawErrors,
|
|
345
|
+
rawHelp = props.rawHelp,
|
|
346
|
+
rawDescription = props.rawDescription,
|
|
347
|
+
schema = props.schema;
|
|
348
|
+
|
|
349
|
+
if (hidden) {
|
|
350
|
+
return React__default.createElement(React__default.Fragment, null, children);
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
return React__default.createElement(WrapIfAdditional, {
|
|
354
|
+
classNames: classNames,
|
|
355
|
+
disabled: disabled,
|
|
356
|
+
id: id,
|
|
357
|
+
label: label,
|
|
358
|
+
onDropPropertyClick: onDropPropertyClick,
|
|
359
|
+
onKeyChange: onKeyChange,
|
|
360
|
+
readonly: readonly,
|
|
361
|
+
required: required,
|
|
362
|
+
schema: schema
|
|
363
|
+
}, React__default.createElement(react.FormControl, {
|
|
364
|
+
isRequired: required,
|
|
365
|
+
isInvalid: rawErrors && rawErrors.length > 0
|
|
366
|
+
}, children, displayLabel && rawDescription ? React__default.createElement(react.Text, {
|
|
367
|
+
mt: 2
|
|
368
|
+
}, rawDescription) : null, rawErrors && rawErrors.length > 0 && React__default.createElement(react.List, null, rawErrors.map(function (error, i) {
|
|
369
|
+
return React__default.createElement(react.ListItem, {
|
|
370
|
+
key: i
|
|
371
|
+
}, React__default.createElement(react.FormErrorMessage, {
|
|
372
|
+
id: id
|
|
373
|
+
}, error));
|
|
374
|
+
})), rawHelp && React__default.createElement(react.FormHelperText, {
|
|
375
|
+
id: id
|
|
376
|
+
}, rawHelp)));
|
|
377
|
+
};
|
|
378
|
+
|
|
379
|
+
var canExpand = core.utils.canExpand;
|
|
380
|
+
|
|
381
|
+
var ObjectFieldTemplate = function ObjectFieldTemplate(props) {
|
|
382
|
+
var DescriptionField = props.DescriptionField,
|
|
383
|
+
description = props.description,
|
|
384
|
+
TitleField = props.TitleField,
|
|
385
|
+
title = props.title,
|
|
386
|
+
properties = props.properties,
|
|
387
|
+
required = props.required,
|
|
388
|
+
disabled = props.disabled,
|
|
389
|
+
readonly = props.readonly,
|
|
390
|
+
uiSchema = props.uiSchema,
|
|
391
|
+
idSchema = props.idSchema,
|
|
392
|
+
schema = props.schema,
|
|
393
|
+
formData = props.formData,
|
|
394
|
+
onAddClick = props.onAddClick;
|
|
395
|
+
return React.createElement(React.Fragment, null, (uiSchema["ui:title"] || title) && React.createElement(TitleField, {
|
|
396
|
+
id: idSchema.$id + "-title",
|
|
397
|
+
title: title,
|
|
398
|
+
required: required
|
|
399
|
+
}), description && React.createElement(DescriptionField, {
|
|
400
|
+
id: idSchema.$id + "-description",
|
|
401
|
+
description: description
|
|
402
|
+
}), React.createElement(react.Grid, {
|
|
403
|
+
gap: description ? 2 : 6,
|
|
404
|
+
mb: 4
|
|
405
|
+
}, properties.map(function (element, index) {
|
|
406
|
+
return element.hidden ? element.content : React.createElement(react.GridItem, {
|
|
407
|
+
key: idSchema.$id + "-" + element.name + "-" + index
|
|
408
|
+
}, element.content);
|
|
409
|
+
}), canExpand(schema, uiSchema, formData) && React.createElement(react.GridItem, {
|
|
410
|
+
justifySelf: "flex-end"
|
|
411
|
+
}, React.createElement(AddButton, {
|
|
412
|
+
className: "object-property-expand",
|
|
413
|
+
onClick: onAddClick(schema),
|
|
414
|
+
disabled: disabled || readonly
|
|
415
|
+
}))));
|
|
416
|
+
};
|
|
417
|
+
|
|
418
|
+
var pad = core.utils.pad,
|
|
419
|
+
parseDateString = core.utils.parseDateString,
|
|
420
|
+
toDateString = core.utils.toDateString;
|
|
421
|
+
|
|
422
|
+
var rangeOptions = function rangeOptions(start, stop) {
|
|
423
|
+
var options = [];
|
|
424
|
+
|
|
425
|
+
for (var i = start; i <= stop; i++) {
|
|
426
|
+
options.push({
|
|
427
|
+
value: i,
|
|
428
|
+
label: pad(i, 2)
|
|
429
|
+
});
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
return options;
|
|
433
|
+
};
|
|
434
|
+
|
|
435
|
+
var readyForChange = function readyForChange(state) {
|
|
436
|
+
return Object.keys(state).every(function (key) {
|
|
437
|
+
return typeof state[key] !== "undefined" && state[key] !== -1;
|
|
438
|
+
});
|
|
439
|
+
};
|
|
440
|
+
|
|
441
|
+
var AltDateWidget = function AltDateWidget(props) {
|
|
442
|
+
var autofocus = props.autofocus,
|
|
443
|
+
disabled = props.disabled,
|
|
444
|
+
id = props.id,
|
|
445
|
+
onBlur = props.onBlur,
|
|
446
|
+
onChange = props.onChange,
|
|
447
|
+
onFocus = props.onFocus,
|
|
448
|
+
options = props.options,
|
|
449
|
+
readonly = props.readonly,
|
|
450
|
+
registry = props.registry,
|
|
451
|
+
showTime = props.showTime,
|
|
452
|
+
value = props.value;
|
|
453
|
+
var SelectWidget = registry.widgets.SelectWidget;
|
|
454
|
+
|
|
455
|
+
var _useState = React.useState(parseDateString(value, showTime)),
|
|
456
|
+
state = _useState[0],
|
|
457
|
+
setState = _useState[1];
|
|
458
|
+
|
|
459
|
+
React.useEffect(function () {
|
|
460
|
+
setState(parseDateString(value, showTime));
|
|
461
|
+
}, [showTime, value]);
|
|
462
|
+
|
|
463
|
+
var handleChange = function handleChange(property, nextValue) {
|
|
464
|
+
var _extends2;
|
|
465
|
+
|
|
466
|
+
var nextState = _extends({}, state, (_extends2 = {}, _extends2[property] = typeof nextValue === "undefined" ? -1 : nextValue, _extends2));
|
|
467
|
+
|
|
468
|
+
if (readyForChange(nextState)) {
|
|
469
|
+
onChange(toDateString(nextState, showTime));
|
|
470
|
+
} else {
|
|
471
|
+
setState(nextState);
|
|
472
|
+
}
|
|
473
|
+
};
|
|
474
|
+
|
|
475
|
+
var handleNow = function handleNow(event) {
|
|
476
|
+
event.preventDefault();
|
|
477
|
+
|
|
478
|
+
if (disabled || readonly) {
|
|
479
|
+
return;
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
var nextState = parseDateString(new Date().toJSON(), showTime);
|
|
483
|
+
onChange(toDateString(nextState, showTime));
|
|
484
|
+
};
|
|
485
|
+
|
|
486
|
+
var handleClear = function handleClear(event) {
|
|
487
|
+
event.preventDefault();
|
|
488
|
+
|
|
489
|
+
if (disabled || readonly) {
|
|
490
|
+
return;
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
onChange(undefined);
|
|
494
|
+
};
|
|
495
|
+
|
|
496
|
+
var dateElementProps = function dateElementProps() {
|
|
497
|
+
var year = state.year,
|
|
498
|
+
month = state.month,
|
|
499
|
+
day = state.day,
|
|
500
|
+
hour = state.hour,
|
|
501
|
+
minute = state.minute,
|
|
502
|
+
second = state.second;
|
|
503
|
+
var data = [{
|
|
504
|
+
type: "year",
|
|
505
|
+
range: options.yearsRange,
|
|
506
|
+
value: year
|
|
507
|
+
}, {
|
|
508
|
+
type: "month",
|
|
509
|
+
range: [1, 12],
|
|
510
|
+
value: month
|
|
511
|
+
}, {
|
|
512
|
+
type: "day",
|
|
513
|
+
range: [1, 31],
|
|
514
|
+
value: day
|
|
515
|
+
}];
|
|
516
|
+
|
|
517
|
+
if (showTime) {
|
|
518
|
+
data.push({
|
|
519
|
+
type: "hour",
|
|
520
|
+
range: [0, 23],
|
|
521
|
+
value: hour
|
|
522
|
+
}, {
|
|
523
|
+
type: "minute",
|
|
524
|
+
range: [0, 59],
|
|
525
|
+
value: minute
|
|
526
|
+
}, {
|
|
527
|
+
type: "second",
|
|
528
|
+
range: [0, 59],
|
|
529
|
+
value: second
|
|
530
|
+
});
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
return data;
|
|
534
|
+
};
|
|
535
|
+
|
|
536
|
+
var renderDateElement = function renderDateElement(elemProps) {
|
|
537
|
+
var value = Boolean(elemProps.value) ? elemProps.value : undefined;
|
|
538
|
+
return React__default.createElement(SelectWidget, Object.assign({}, elemProps, {
|
|
539
|
+
label: undefined,
|
|
540
|
+
className: "form-control",
|
|
541
|
+
onChange: function onChange(elemValue) {
|
|
542
|
+
return elemProps.select(elemProps.type, elemValue);
|
|
543
|
+
},
|
|
544
|
+
options: {
|
|
545
|
+
enumOptions: rangeOptions(elemProps.range[0], elemProps.range[1])
|
|
546
|
+
},
|
|
547
|
+
placeholder: elemProps.type,
|
|
548
|
+
schema: {
|
|
549
|
+
type: "integer"
|
|
550
|
+
},
|
|
551
|
+
value: value
|
|
552
|
+
}));
|
|
553
|
+
};
|
|
554
|
+
|
|
555
|
+
return React__default.createElement(react.Box, null, React__default.createElement(react.Box, {
|
|
556
|
+
display: "flex",
|
|
557
|
+
flexWrap: "wrap",
|
|
558
|
+
alignItems: "center",
|
|
559
|
+
justify: "center"
|
|
560
|
+
}, dateElementProps().map(function (elemProps, i) {
|
|
561
|
+
var elemId = id + "_" + elemProps.type;
|
|
562
|
+
return React__default.createElement(react.Box, {
|
|
563
|
+
key: elemId,
|
|
564
|
+
mr: "2",
|
|
565
|
+
mb: "2"
|
|
566
|
+
}, renderDateElement(_extends({}, props, elemProps, {
|
|
567
|
+
autofocus: autofocus && i === 0,
|
|
568
|
+
disabled: disabled,
|
|
569
|
+
id: elemId,
|
|
570
|
+
onBlur: onBlur,
|
|
571
|
+
onFocus: onFocus,
|
|
572
|
+
readonly: readonly,
|
|
573
|
+
registry: registry,
|
|
574
|
+
select: handleChange,
|
|
575
|
+
value: elemProps.value < 0 ? "" : elemProps.value
|
|
576
|
+
})));
|
|
577
|
+
})), React__default.createElement(react.Box, {
|
|
578
|
+
display: "flex"
|
|
579
|
+
}, !options.hideNowButton && React__default.createElement(react.Button, {
|
|
580
|
+
onClick: function onClick(e) {
|
|
581
|
+
return handleNow(e);
|
|
582
|
+
},
|
|
583
|
+
mr: "2"
|
|
584
|
+
}, "Now"), !options.hideClearButton && React__default.createElement(react.Button, {
|
|
585
|
+
onClick: function onClick(e) {
|
|
586
|
+
return handleClear(e);
|
|
587
|
+
}
|
|
588
|
+
}, "Clear")));
|
|
589
|
+
};
|
|
590
|
+
|
|
591
|
+
AltDateWidget.defaultProps = {
|
|
592
|
+
autofocus: false,
|
|
593
|
+
disabled: false,
|
|
594
|
+
readonly: false,
|
|
595
|
+
showTime: false,
|
|
596
|
+
options: {
|
|
597
|
+
yearsRange: [1900, /*#__PURE__*/new Date().getFullYear() + 2]
|
|
598
|
+
}
|
|
599
|
+
};
|
|
600
|
+
|
|
601
|
+
var AltDateTimeWidget = function AltDateTimeWidget(props) {
|
|
602
|
+
var AltDateWidget = props.registry.widgets.AltDateWidget;
|
|
603
|
+
return React__default.createElement(AltDateWidget, Object.assign({}, props, {
|
|
604
|
+
showTime: true
|
|
605
|
+
}));
|
|
606
|
+
};
|
|
607
|
+
|
|
608
|
+
AltDateTimeWidget.defaultProps = /*#__PURE__*/_extends({}, AltDateWidget.defaultProps, {
|
|
609
|
+
showTime: true
|
|
610
|
+
});
|
|
611
|
+
|
|
612
|
+
function getChakra(_ref) {
|
|
613
|
+
var _ref$uiSchema = _ref.uiSchema,
|
|
614
|
+
uiSchema = _ref$uiSchema === void 0 ? {} : _ref$uiSchema;
|
|
615
|
+
var chakraProps = uiSchema["ui:options"] && uiSchema["ui:options"].chakra || {};
|
|
616
|
+
Object.keys(chakraProps).forEach(function (key) {
|
|
617
|
+
/**
|
|
618
|
+
* Leveraging `shouldForwardProp` to remove props
|
|
619
|
+
*
|
|
620
|
+
* This is a utility function that's used in `@chakra-ui/react`'s factory function.
|
|
621
|
+
* Normally, it prevents ChakraProps from being passed to the DOM.
|
|
622
|
+
* In this case we just want to delete the unknown props. So we flip the boolean.
|
|
623
|
+
*/
|
|
624
|
+
if (react.shouldForwardProp(key)) {
|
|
625
|
+
// @ts-ignore - How to type this?!... 😬
|
|
626
|
+
delete chakraProps[key];
|
|
627
|
+
}
|
|
628
|
+
});
|
|
629
|
+
return chakraProps;
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
var CheckboxWidget = function CheckboxWidget(props) {
|
|
633
|
+
var id = props.id,
|
|
634
|
+
value = props.value,
|
|
635
|
+
disabled = props.disabled,
|
|
636
|
+
readonly = props.readonly,
|
|
637
|
+
onChange = props.onChange,
|
|
638
|
+
onBlur = props.onBlur,
|
|
639
|
+
onFocus = props.onFocus,
|
|
640
|
+
required = props.required,
|
|
641
|
+
label = props.label,
|
|
642
|
+
uiSchema = props.uiSchema;
|
|
643
|
+
var chakraProps = getChakra({
|
|
644
|
+
uiSchema: uiSchema
|
|
645
|
+
});
|
|
646
|
+
|
|
647
|
+
var _onChange = function _onChange(_ref) {
|
|
648
|
+
var checked = _ref.target.checked;
|
|
649
|
+
return onChange(checked);
|
|
650
|
+
};
|
|
651
|
+
|
|
652
|
+
var _onBlur = function _onBlur(_ref2) {
|
|
653
|
+
var value = _ref2.target.value;
|
|
654
|
+
return onBlur(id, value);
|
|
655
|
+
};
|
|
656
|
+
|
|
657
|
+
var _onFocus = function _onFocus(_ref3) {
|
|
658
|
+
var value = _ref3.target.value;
|
|
659
|
+
return onFocus(id, value);
|
|
660
|
+
};
|
|
661
|
+
|
|
662
|
+
return React__default.createElement(react.FormControl, Object.assign({
|
|
663
|
+
mb: 1
|
|
664
|
+
}, chakraProps, {
|
|
665
|
+
isRequired: required
|
|
666
|
+
}), React__default.createElement(react.Checkbox, {
|
|
667
|
+
id: id,
|
|
668
|
+
name: id,
|
|
669
|
+
isChecked: typeof value === "undefined" ? false : value,
|
|
670
|
+
isDisabled: disabled || readonly,
|
|
671
|
+
onChange: _onChange,
|
|
672
|
+
onBlur: _onBlur,
|
|
673
|
+
onFocus: _onFocus
|
|
674
|
+
}, label && React__default.createElement(react.Text, null, label)));
|
|
675
|
+
};
|
|
676
|
+
|
|
677
|
+
// const at = all.indexOf(value);
|
|
678
|
+
// const updated = selected.slice(0, at).concat(value, selected.slice(at));
|
|
679
|
+
// // As inserting values at predefined index positions doesn't work with empty
|
|
680
|
+
// // arrays, we need to reorder the updated selection to match the initial order
|
|
681
|
+
// return updated.sort((a, b) => all.indexOf(a) > all.indexOf(b));
|
|
682
|
+
// };
|
|
683
|
+
// const deselectValue = (value, selected) => {
|
|
684
|
+
// return selected.filter((v) => v !== value);
|
|
685
|
+
// };
|
|
686
|
+
|
|
687
|
+
var CheckboxesWidget = function CheckboxesWidget(props) {
|
|
688
|
+
var id = props.id,
|
|
689
|
+
disabled = props.disabled,
|
|
690
|
+
options = props.options,
|
|
691
|
+
value = props.value,
|
|
692
|
+
readonly = props.readonly,
|
|
693
|
+
_onChange = props.onChange,
|
|
694
|
+
onBlur = props.onBlur,
|
|
695
|
+
onFocus = props.onFocus,
|
|
696
|
+
required = props.required,
|
|
697
|
+
label = props.label,
|
|
698
|
+
uiSchema = props.uiSchema,
|
|
699
|
+
_props$rawErrors = props.rawErrors,
|
|
700
|
+
rawErrors = _props$rawErrors === void 0 ? [] : _props$rawErrors,
|
|
701
|
+
schema = props.schema;
|
|
702
|
+
var enumOptions = options.enumOptions,
|
|
703
|
+
enumDisabled = options.enumDisabled;
|
|
704
|
+
var chakraProps = getChakra({
|
|
705
|
+
uiSchema: uiSchema
|
|
706
|
+
}); // const _onChange = option => ({ target: { checked } }) => {
|
|
707
|
+
// const all = enumOptions.map(({ value }) => value)
|
|
708
|
+
// if (checked) {
|
|
709
|
+
// onChange(selectValue(option.value, value, all))
|
|
710
|
+
// } else {
|
|
711
|
+
// onChange(deselectValue(option.value, value))
|
|
712
|
+
// }
|
|
713
|
+
// }
|
|
714
|
+
|
|
715
|
+
var _onBlur = function _onBlur(_ref) {
|
|
716
|
+
var value = _ref.target.value;
|
|
717
|
+
return onBlur(id, value);
|
|
718
|
+
};
|
|
719
|
+
|
|
720
|
+
var _onFocus = function _onFocus(_ref2) {
|
|
721
|
+
var value = _ref2.target.value;
|
|
722
|
+
return onFocus(id, value);
|
|
723
|
+
};
|
|
724
|
+
|
|
725
|
+
var row = options ? options.inline : false;
|
|
726
|
+
return React__default.createElement(react.FormControl, Object.assign({
|
|
727
|
+
mb: 1
|
|
728
|
+
}, chakraProps, {
|
|
729
|
+
isDisabled: disabled || readonly,
|
|
730
|
+
isRequired: required,
|
|
731
|
+
isReadOnly: readonly,
|
|
732
|
+
isInvalid: rawErrors && rawErrors.length > 0
|
|
733
|
+
}), React__default.createElement(react.FormLabel, {
|
|
734
|
+
htmlFor: id
|
|
735
|
+
}, label || schema.title), React__default.createElement(react.CheckboxGroup, {
|
|
736
|
+
onChange: function onChange(option) {
|
|
737
|
+
return _onChange(option);
|
|
738
|
+
},
|
|
739
|
+
defaultValue: value
|
|
740
|
+
}, React__default.createElement(react.Stack, {
|
|
741
|
+
direction: row ? "row" : "column"
|
|
742
|
+
}, enumOptions.map(function (option, index) {
|
|
743
|
+
var checked = value.indexOf(option.value) !== -1;
|
|
744
|
+
var itemDisabled = enumDisabled && enumDisabled.indexOf(option.value) !== -1;
|
|
745
|
+
return React__default.createElement(react.Checkbox, {
|
|
746
|
+
key: id + "_" + index,
|
|
747
|
+
id: id + "_" + index,
|
|
748
|
+
value: option.value,
|
|
749
|
+
isChecked: checked,
|
|
750
|
+
isDisabled: disabled || itemDisabled || readonly,
|
|
751
|
+
onBlur: _onBlur,
|
|
752
|
+
onFocus: _onFocus
|
|
753
|
+
}, option.label && React__default.createElement(react.Text, null, option.label));
|
|
754
|
+
}))));
|
|
755
|
+
};
|
|
756
|
+
|
|
757
|
+
var ColorWidget = function ColorWidget(props) {
|
|
758
|
+
var registry = props.registry;
|
|
759
|
+
var TextWidget = registry.widgets.TextWidget;
|
|
760
|
+
return React__default.createElement(TextWidget, Object.assign({
|
|
761
|
+
type: "color"
|
|
762
|
+
}, props));
|
|
763
|
+
};
|
|
764
|
+
|
|
765
|
+
var DateWidget = function DateWidget(props) {
|
|
766
|
+
var registry = props.registry;
|
|
767
|
+
var TextWidget = registry.widgets.TextWidget;
|
|
768
|
+
return React__default.createElement(TextWidget, Object.assign({}, props, {
|
|
769
|
+
type: "date"
|
|
770
|
+
}));
|
|
771
|
+
};
|
|
772
|
+
|
|
773
|
+
var localToUTC = core.utils.localToUTC,
|
|
774
|
+
utcToLocal = core.utils.utcToLocal;
|
|
775
|
+
|
|
776
|
+
var DateTimeWidget = function DateTimeWidget(props) {
|
|
777
|
+
var registry = props.registry;
|
|
778
|
+
var TextWidget = registry.widgets.TextWidget;
|
|
779
|
+
var value = utcToLocal(props.value);
|
|
780
|
+
|
|
781
|
+
var onChange = function onChange(value) {
|
|
782
|
+
props.onChange(localToUTC(value));
|
|
783
|
+
};
|
|
784
|
+
|
|
785
|
+
return React__default.createElement(TextWidget, Object.assign({
|
|
786
|
+
type: "datetime-local"
|
|
787
|
+
}, props, {
|
|
788
|
+
value: value,
|
|
789
|
+
onChange: onChange
|
|
790
|
+
}));
|
|
791
|
+
};
|
|
792
|
+
|
|
793
|
+
var EmailWidget = function EmailWidget(props) {
|
|
794
|
+
var registry = props.registry;
|
|
795
|
+
var TextWidget = registry.widgets.TextWidget;
|
|
796
|
+
return React__default.createElement(TextWidget, Object.assign({}, props, {
|
|
797
|
+
type: "email"
|
|
798
|
+
}));
|
|
799
|
+
};
|
|
800
|
+
|
|
801
|
+
var PasswordWidget = function PasswordWidget(props) {
|
|
802
|
+
var registry = props.registry;
|
|
803
|
+
var TextWidget = registry.widgets.TextWidget;
|
|
804
|
+
return React__default.createElement(TextWidget, Object.assign({
|
|
805
|
+
type: "password"
|
|
806
|
+
}, props));
|
|
807
|
+
};
|
|
808
|
+
|
|
809
|
+
var RadioWidget = function RadioWidget(_ref) {
|
|
810
|
+
var id = _ref.id,
|
|
811
|
+
schema = _ref.schema,
|
|
812
|
+
options = _ref.options,
|
|
813
|
+
value = _ref.value,
|
|
814
|
+
required = _ref.required,
|
|
815
|
+
disabled = _ref.disabled,
|
|
816
|
+
readonly = _ref.readonly,
|
|
817
|
+
label = _ref.label,
|
|
818
|
+
onChange = _ref.onChange,
|
|
819
|
+
onBlur = _ref.onBlur,
|
|
820
|
+
onFocus = _ref.onFocus,
|
|
821
|
+
uiSchema = _ref.uiSchema;
|
|
822
|
+
var enumOptions = options.enumOptions,
|
|
823
|
+
enumDisabled = options.enumDisabled;
|
|
824
|
+
var chakraProps = getChakra({
|
|
825
|
+
uiSchema: uiSchema
|
|
826
|
+
});
|
|
827
|
+
|
|
828
|
+
var _onBlur = function _onBlur(_ref2) {
|
|
829
|
+
var value = _ref2.target.value;
|
|
830
|
+
return onBlur(id, value);
|
|
831
|
+
};
|
|
832
|
+
|
|
833
|
+
var _onFocus = function _onFocus(_ref3) {
|
|
834
|
+
var value = _ref3.target.value;
|
|
835
|
+
return onFocus(id, value);
|
|
836
|
+
};
|
|
837
|
+
|
|
838
|
+
var row = options ? options.inline : false;
|
|
839
|
+
return React__default.createElement(react.FormControl, Object.assign({
|
|
840
|
+
mb: 1
|
|
841
|
+
}, chakraProps, {
|
|
842
|
+
isDisabled: disabled || readonly,
|
|
843
|
+
isRequired: required,
|
|
844
|
+
isReadOnly: readonly
|
|
845
|
+
}), React__default.createElement(react.FormLabel, {
|
|
846
|
+
htmlFor: id
|
|
847
|
+
}, label || schema.title), React__default.createElement(react.RadioGroup, {
|
|
848
|
+
onChange: onChange,
|
|
849
|
+
onBlur: _onBlur,
|
|
850
|
+
onFocus: _onFocus,
|
|
851
|
+
value: "" + value,
|
|
852
|
+
name: id
|
|
853
|
+
}, React__default.createElement(react.Stack, {
|
|
854
|
+
direction: row ? "row" : "column"
|
|
855
|
+
}, enumOptions.map(function (option, i) {
|
|
856
|
+
var itemDisabled = Boolean(enumDisabled && enumDisabled.indexOf(option.value) != -1);
|
|
857
|
+
return React__default.createElement(react.Radio, {
|
|
858
|
+
value: "" + option.value,
|
|
859
|
+
key: i,
|
|
860
|
+
disabled: disabled || itemDisabled || readonly
|
|
861
|
+
}, "" + option.label);
|
|
862
|
+
}))));
|
|
863
|
+
};
|
|
864
|
+
|
|
865
|
+
var rangeSpec = core.utils.rangeSpec,
|
|
866
|
+
getDisplayLabel = core.utils.getDisplayLabel;
|
|
867
|
+
|
|
868
|
+
var RangeWidget = function RangeWidget(_ref) {
|
|
869
|
+
var value = _ref.value,
|
|
870
|
+
readonly = _ref.readonly,
|
|
871
|
+
disabled = _ref.disabled,
|
|
872
|
+
onBlur = _ref.onBlur,
|
|
873
|
+
onFocus = _ref.onFocus,
|
|
874
|
+
options = _ref.options,
|
|
875
|
+
schema = _ref.schema,
|
|
876
|
+
uiSchema = _ref.uiSchema,
|
|
877
|
+
onChange = _ref.onChange,
|
|
878
|
+
label = _ref.label,
|
|
879
|
+
id = _ref.id;
|
|
880
|
+
var chakraProps = getChakra({
|
|
881
|
+
uiSchema: uiSchema
|
|
882
|
+
});
|
|
883
|
+
|
|
884
|
+
var sliderWidgetProps = _extends({
|
|
885
|
+
value: value,
|
|
886
|
+
label: label,
|
|
887
|
+
id: id
|
|
888
|
+
}, rangeSpec(schema));
|
|
889
|
+
|
|
890
|
+
var displayLabel = getDisplayLabel(schema, uiSchema) && (!!label || !!schema.title);
|
|
891
|
+
|
|
892
|
+
var _onChange = function _onChange(value) {
|
|
893
|
+
return onChange(value === undefined ? options.emptyValue : value);
|
|
894
|
+
};
|
|
895
|
+
|
|
896
|
+
var _onBlur = function _onBlur(_ref2) {
|
|
897
|
+
var value = _ref2.target.value;
|
|
898
|
+
return onBlur(id, value);
|
|
899
|
+
};
|
|
900
|
+
|
|
901
|
+
var _onFocus = function _onFocus(_ref3) {
|
|
902
|
+
var value = _ref3.target.value;
|
|
903
|
+
return onFocus(id, value);
|
|
904
|
+
};
|
|
905
|
+
|
|
906
|
+
return React__default.createElement(react.FormControl, Object.assign({
|
|
907
|
+
mb: 1
|
|
908
|
+
}, chakraProps), displayLabel ? React__default.createElement(react.FormLabel, {
|
|
909
|
+
htmlFor: id
|
|
910
|
+
}, label || schema.title) : null, React__default.createElement(react.Slider, Object.assign({}, sliderWidgetProps, {
|
|
911
|
+
id: id,
|
|
912
|
+
name: id,
|
|
913
|
+
isDisabled: disabled || readonly,
|
|
914
|
+
onChange: _onChange,
|
|
915
|
+
onBlur: _onBlur,
|
|
916
|
+
onFocus: _onFocus
|
|
917
|
+
}), React__default.createElement(react.SliderTrack, null, React__default.createElement(react.SliderFilledTrack, null)), React__default.createElement(react.SliderThumb, null)));
|
|
918
|
+
};
|
|
919
|
+
|
|
920
|
+
var asNumber = core.utils.asNumber,
|
|
921
|
+
guessType = core.utils.guessType;
|
|
922
|
+
var nums = /*#__PURE__*/new Set(["number", "integer"]);
|
|
923
|
+
/**
|
|
924
|
+
* This is a silly limitation in the DOM where option change event values are
|
|
925
|
+
* always retrieved as strings.
|
|
926
|
+
*/
|
|
927
|
+
|
|
928
|
+
var processValue = function processValue(schema, value) {
|
|
929
|
+
// "enum" is a reserved word, so only "type" and "items" can be destructured
|
|
930
|
+
var type = schema.type,
|
|
931
|
+
items = schema.items;
|
|
932
|
+
|
|
933
|
+
if (value === "") {
|
|
934
|
+
return undefined;
|
|
935
|
+
} else if (type === "array" && items && nums.has(items.type)) {
|
|
936
|
+
return value.map(asNumber);
|
|
937
|
+
} else if (type === "boolean") {
|
|
938
|
+
return value === "true";
|
|
939
|
+
} else if (type === "number") {
|
|
940
|
+
return asNumber(value);
|
|
941
|
+
} // If type is undefined, but an enum is present, try and infer the type from
|
|
942
|
+
// the enum values
|
|
943
|
+
|
|
944
|
+
|
|
945
|
+
if (schema["enum"]) {
|
|
946
|
+
if (schema["enum"].every(function (x) {
|
|
947
|
+
return guessType(x) === "number";
|
|
948
|
+
})) {
|
|
949
|
+
return asNumber(value);
|
|
950
|
+
} else if (schema["enum"].every(function (x) {
|
|
951
|
+
return guessType(x) === "boolean";
|
|
952
|
+
})) {
|
|
953
|
+
return value === "true";
|
|
954
|
+
}
|
|
955
|
+
}
|
|
956
|
+
|
|
957
|
+
return value;
|
|
958
|
+
};
|
|
959
|
+
|
|
960
|
+
var SelectWidget = function SelectWidget(props) {
|
|
961
|
+
var schema = props.schema,
|
|
962
|
+
id = props.id,
|
|
963
|
+
options = props.options,
|
|
964
|
+
label = props.label,
|
|
965
|
+
placeholder = props.placeholder,
|
|
966
|
+
multiple = props.multiple,
|
|
967
|
+
required = props.required,
|
|
968
|
+
disabled = props.disabled,
|
|
969
|
+
readonly = props.readonly,
|
|
970
|
+
value = props.value,
|
|
971
|
+
autofocus = props.autofocus,
|
|
972
|
+
onChange = props.onChange,
|
|
973
|
+
onBlur = props.onBlur,
|
|
974
|
+
onFocus = props.onFocus,
|
|
975
|
+
_props$rawErrors = props.rawErrors,
|
|
976
|
+
rawErrors = _props$rawErrors === void 0 ? [] : _props$rawErrors,
|
|
977
|
+
uiSchema = props.uiSchema;
|
|
978
|
+
var enumOptions = options.enumOptions,
|
|
979
|
+
enumDisabled = options.enumDisabled;
|
|
980
|
+
var chakraProps = getChakra({
|
|
981
|
+
uiSchema: uiSchema
|
|
982
|
+
}); // TODO: Default emptyValue should be string when multi select is implemented
|
|
983
|
+
// const emptyValue = multiple ? [] : "";
|
|
984
|
+
|
|
985
|
+
var emptyValue = "";
|
|
986
|
+
|
|
987
|
+
var _onMultiChange = function _onMultiChange(e) {
|
|
988
|
+
return onChange(processValue(schema, e.map(function (v) {
|
|
989
|
+
return v.value;
|
|
990
|
+
})));
|
|
991
|
+
};
|
|
992
|
+
|
|
993
|
+
var _onChange = function _onChange(_ref) {
|
|
994
|
+
var value = _ref.target.value;
|
|
995
|
+
return onChange(processValue(schema, value));
|
|
996
|
+
};
|
|
997
|
+
|
|
998
|
+
var _onBlur = function _onBlur(_ref2) {
|
|
999
|
+
var value = _ref2.target.value;
|
|
1000
|
+
return onBlur(id, processValue(schema, value));
|
|
1001
|
+
};
|
|
1002
|
+
|
|
1003
|
+
var _onFocus = function _onFocus(_ref3) {
|
|
1004
|
+
var value = _ref3.target.value;
|
|
1005
|
+
return onFocus(id, processValue(schema, value));
|
|
1006
|
+
};
|
|
1007
|
+
|
|
1008
|
+
return React__default.createElement(react.FormControl, Object.assign({
|
|
1009
|
+
mb: 1
|
|
1010
|
+
}, chakraProps, {
|
|
1011
|
+
isDisabled: disabled || readonly,
|
|
1012
|
+
isRequired: required,
|
|
1013
|
+
isReadOnly: readonly,
|
|
1014
|
+
isInvalid: rawErrors && rawErrors.length > 0
|
|
1015
|
+
}), (label || schema.title) && React__default.createElement(react.FormLabel, {
|
|
1016
|
+
htmlFor: typeof multiple !== "undefined" && enumOptions ? undefined : id
|
|
1017
|
+
}, label || schema.title), typeof multiple !== "undefined" && enumOptions ? React__default.createElement(chakraReactSelect.Select, {
|
|
1018
|
+
inputId: id,
|
|
1019
|
+
name: id,
|
|
1020
|
+
isMulti: true,
|
|
1021
|
+
options: enumOptions,
|
|
1022
|
+
placeholder: placeholder,
|
|
1023
|
+
closeMenuOnSelect: false,
|
|
1024
|
+
onChange: _onMultiChange,
|
|
1025
|
+
value: value.map(function (v) {
|
|
1026
|
+
return {
|
|
1027
|
+
label: v,
|
|
1028
|
+
value: v
|
|
1029
|
+
};
|
|
1030
|
+
})
|
|
1031
|
+
}) : React__default.createElement(react.Select, {
|
|
1032
|
+
id: id,
|
|
1033
|
+
name: id,
|
|
1034
|
+
placeholder: placeholder !== "" ? placeholder : " ",
|
|
1035
|
+
value: typeof value === "undefined" ? emptyValue : value.toString(),
|
|
1036
|
+
autoFocus: autofocus,
|
|
1037
|
+
onBlur: _onBlur,
|
|
1038
|
+
onChange: _onChange,
|
|
1039
|
+
onFocus: _onFocus
|
|
1040
|
+
}, enumOptions.map(function (_ref4, i) {
|
|
1041
|
+
var value = _ref4.value,
|
|
1042
|
+
label = _ref4.label;
|
|
1043
|
+
var disabled = enumDisabled && enumDisabled.indexOf(value) != -1;
|
|
1044
|
+
return React__default.createElement("option", {
|
|
1045
|
+
key: i,
|
|
1046
|
+
value: value,
|
|
1047
|
+
disabled: disabled
|
|
1048
|
+
}, label);
|
|
1049
|
+
})));
|
|
1050
|
+
};
|
|
1051
|
+
|
|
1052
|
+
var getDisplayLabel$1 = core.utils.getDisplayLabel;
|
|
1053
|
+
|
|
1054
|
+
var TextareaWidget = function TextareaWidget(_ref) {
|
|
1055
|
+
var id = _ref.id,
|
|
1056
|
+
placeholder = _ref.placeholder,
|
|
1057
|
+
value = _ref.value,
|
|
1058
|
+
label = _ref.label,
|
|
1059
|
+
disabled = _ref.disabled,
|
|
1060
|
+
autofocus = _ref.autofocus,
|
|
1061
|
+
readonly = _ref.readonly,
|
|
1062
|
+
onBlur = _ref.onBlur,
|
|
1063
|
+
onFocus = _ref.onFocus,
|
|
1064
|
+
onChange = _ref.onChange,
|
|
1065
|
+
options = _ref.options,
|
|
1066
|
+
schema = _ref.schema,
|
|
1067
|
+
uiSchema = _ref.uiSchema,
|
|
1068
|
+
required = _ref.required,
|
|
1069
|
+
rawErrors = _ref.rawErrors;
|
|
1070
|
+
var chakraProps = getChakra({
|
|
1071
|
+
uiSchema: uiSchema
|
|
1072
|
+
});
|
|
1073
|
+
var displayLabel = getDisplayLabel$1(schema, uiSchema) && (!!label || !!schema.title);
|
|
1074
|
+
|
|
1075
|
+
var _onChange = function _onChange(_ref2) {
|
|
1076
|
+
var value = _ref2.target.value;
|
|
1077
|
+
return onChange(value === "" ? options.emptyValue : value);
|
|
1078
|
+
};
|
|
1079
|
+
|
|
1080
|
+
var _onBlur = function _onBlur(_ref3) {
|
|
1081
|
+
var value = _ref3.target.value;
|
|
1082
|
+
return onBlur(id, value);
|
|
1083
|
+
};
|
|
1084
|
+
|
|
1085
|
+
var _onFocus = function _onFocus(_ref4) {
|
|
1086
|
+
var value = _ref4.target.value;
|
|
1087
|
+
return onFocus(id, value);
|
|
1088
|
+
};
|
|
1089
|
+
|
|
1090
|
+
return React__default.createElement(react.FormControl, Object.assign({
|
|
1091
|
+
mb: 1
|
|
1092
|
+
}, chakraProps, {
|
|
1093
|
+
isDisabled: disabled || readonly,
|
|
1094
|
+
isRequired: required,
|
|
1095
|
+
isReadOnly: readonly,
|
|
1096
|
+
isInvalid: rawErrors && rawErrors.length > 0
|
|
1097
|
+
}), displayLabel ? React__default.createElement(react.FormLabel, {
|
|
1098
|
+
htmlFor: id
|
|
1099
|
+
}, label || schema.title) : null, React__default.createElement(react.Textarea, {
|
|
1100
|
+
id: id,
|
|
1101
|
+
name: id,
|
|
1102
|
+
value: value != null ? value : "",
|
|
1103
|
+
placeholder: placeholder,
|
|
1104
|
+
autoFocus: autofocus,
|
|
1105
|
+
onChange: _onChange,
|
|
1106
|
+
onBlur: _onBlur,
|
|
1107
|
+
onFocus: _onFocus
|
|
1108
|
+
}));
|
|
1109
|
+
};
|
|
1110
|
+
|
|
1111
|
+
var getDisplayLabel$2 = core.utils.getDisplayLabel;
|
|
1112
|
+
|
|
1113
|
+
var TextWidget = function TextWidget(props) {
|
|
1114
|
+
var id = props.id,
|
|
1115
|
+
type = props.type,
|
|
1116
|
+
value = props.value,
|
|
1117
|
+
label = props.label,
|
|
1118
|
+
schema = props.schema,
|
|
1119
|
+
uiSchema = props.uiSchema,
|
|
1120
|
+
onChange = props.onChange,
|
|
1121
|
+
onBlur = props.onBlur,
|
|
1122
|
+
onFocus = props.onFocus,
|
|
1123
|
+
options = props.options,
|
|
1124
|
+
required = props.required,
|
|
1125
|
+
readonly = props.readonly,
|
|
1126
|
+
rawErrors = props.rawErrors,
|
|
1127
|
+
autofocus = props.autofocus,
|
|
1128
|
+
placeholder = props.placeholder,
|
|
1129
|
+
disabled = props.disabled;
|
|
1130
|
+
var chakraProps = getChakra({
|
|
1131
|
+
uiSchema: uiSchema
|
|
1132
|
+
});
|
|
1133
|
+
|
|
1134
|
+
var _onChange = function _onChange(_ref) {
|
|
1135
|
+
var value = _ref.target.value;
|
|
1136
|
+
return onChange(value === "" ? options.emptyValue : value);
|
|
1137
|
+
};
|
|
1138
|
+
|
|
1139
|
+
var _onBlur = function _onBlur(_ref2) {
|
|
1140
|
+
var value = _ref2.target.value;
|
|
1141
|
+
return onBlur(id, value);
|
|
1142
|
+
};
|
|
1143
|
+
|
|
1144
|
+
var _onFocus = function _onFocus(_ref3) {
|
|
1145
|
+
var value = _ref3.target.value;
|
|
1146
|
+
return onFocus(id, value);
|
|
1147
|
+
};
|
|
1148
|
+
|
|
1149
|
+
var displayLabel = getDisplayLabel$2(schema, uiSchema) && (!!label || !!schema.title);
|
|
1150
|
+
var inputType = (type || schema.type) === "string" ? "text" : "" + (type || schema.type);
|
|
1151
|
+
return React.createElement(react.FormControl, Object.assign({
|
|
1152
|
+
mb: 1
|
|
1153
|
+
}, chakraProps, {
|
|
1154
|
+
isDisabled: disabled || readonly,
|
|
1155
|
+
isRequired: required,
|
|
1156
|
+
isReadOnly: readonly,
|
|
1157
|
+
isInvalid: rawErrors && rawErrors.length > 0
|
|
1158
|
+
}), displayLabel ? React.createElement(react.FormLabel, {
|
|
1159
|
+
htmlFor: id,
|
|
1160
|
+
id: id + "-label"
|
|
1161
|
+
}, label || schema.title) : null, React.createElement(react.Input, {
|
|
1162
|
+
id: id,
|
|
1163
|
+
name: id,
|
|
1164
|
+
value: value || value === 0 ? value : "",
|
|
1165
|
+
onChange: _onChange,
|
|
1166
|
+
onBlur: _onBlur,
|
|
1167
|
+
onFocus: _onFocus,
|
|
1168
|
+
autoFocus: autofocus,
|
|
1169
|
+
placeholder: placeholder,
|
|
1170
|
+
type: inputType,
|
|
1171
|
+
list: schema.examples ? "examples_" + id : undefined
|
|
1172
|
+
}), schema.examples ? React.createElement("datalist", {
|
|
1173
|
+
id: "examples_" + id
|
|
1174
|
+
}, schema.examples.concat(schema["default"] ? [schema["default"]] : []).map(function (example) {
|
|
1175
|
+
return React.createElement("option", {
|
|
1176
|
+
key: example,
|
|
1177
|
+
value: example
|
|
1178
|
+
});
|
|
1179
|
+
})) : null);
|
|
1180
|
+
};
|
|
1181
|
+
|
|
1182
|
+
var getDisplayLabel$3 = core.utils.getDisplayLabel;
|
|
1183
|
+
|
|
1184
|
+
var UpDownWidget = function UpDownWidget(props) {
|
|
1185
|
+
var id = props.id,
|
|
1186
|
+
schema = props.schema,
|
|
1187
|
+
uiSchema = props.uiSchema,
|
|
1188
|
+
readonly = props.readonly,
|
|
1189
|
+
disabled = props.disabled,
|
|
1190
|
+
label = props.label,
|
|
1191
|
+
value = props.value,
|
|
1192
|
+
onChange = props.onChange,
|
|
1193
|
+
onBlur = props.onBlur,
|
|
1194
|
+
onFocus = props.onFocus,
|
|
1195
|
+
rawErrors = props.rawErrors,
|
|
1196
|
+
required = props.required;
|
|
1197
|
+
var displayLabel = getDisplayLabel$3(schema, uiSchema) && (!!label || !!schema.title);
|
|
1198
|
+
var chakraProps = getChakra({
|
|
1199
|
+
uiSchema: uiSchema
|
|
1200
|
+
});
|
|
1201
|
+
|
|
1202
|
+
var _onChange = function _onChange(value) {
|
|
1203
|
+
return onChange(value);
|
|
1204
|
+
};
|
|
1205
|
+
|
|
1206
|
+
var _onBlur = function _onBlur(_ref) {
|
|
1207
|
+
var value = _ref.target.value;
|
|
1208
|
+
return onBlur(id, value);
|
|
1209
|
+
};
|
|
1210
|
+
|
|
1211
|
+
var _onFocus = function _onFocus(_ref2) {
|
|
1212
|
+
var value = _ref2.target.value;
|
|
1213
|
+
return onFocus(id, value);
|
|
1214
|
+
};
|
|
1215
|
+
|
|
1216
|
+
return React__default.createElement(react.FormControl, Object.assign({
|
|
1217
|
+
mb: 1
|
|
1218
|
+
}, chakraProps, {
|
|
1219
|
+
isDisabled: disabled || readonly,
|
|
1220
|
+
isRequired: required,
|
|
1221
|
+
isReadOnly: readonly,
|
|
1222
|
+
isInvalid: rawErrors && rawErrors.length > 0
|
|
1223
|
+
}), displayLabel ? React__default.createElement(react.FormLabel, {
|
|
1224
|
+
htmlFor: id
|
|
1225
|
+
}, label || schema.title) : null, React__default.createElement(react.NumberInput, {
|
|
1226
|
+
value: value != null ? value : "",
|
|
1227
|
+
onChange: _onChange,
|
|
1228
|
+
onBlur: _onBlur,
|
|
1229
|
+
onFocus: _onFocus
|
|
1230
|
+
}, React__default.createElement(react.NumberInputField, {
|
|
1231
|
+
id: id,
|
|
1232
|
+
name: id
|
|
1233
|
+
}), React__default.createElement(react.NumberInputStepper, null, React__default.createElement(react.NumberIncrementStepper, null), React__default.createElement(react.NumberDecrementStepper, null))));
|
|
1234
|
+
};
|
|
1235
|
+
|
|
1236
|
+
var URLWidget = function URLWidget(props) {
|
|
1237
|
+
var registry = props.registry;
|
|
1238
|
+
var TextWidget = registry.widgets.TextWidget;
|
|
1239
|
+
return React__default.createElement(TextWidget, Object.assign({
|
|
1240
|
+
type: "url"
|
|
1241
|
+
}, props));
|
|
1242
|
+
};
|
|
1243
|
+
|
|
1244
|
+
var getSubmitButtonOptions = core.utils.getSubmitButtonOptions;
|
|
1245
|
+
|
|
1246
|
+
var SubmitButton = function SubmitButton(_ref) {
|
|
1247
|
+
var uiSchema = _ref.uiSchema;
|
|
1248
|
+
|
|
1249
|
+
var _getSubmitButtonOptio = getSubmitButtonOptions(uiSchema),
|
|
1250
|
+
submitText = _getSubmitButtonOptio.submitText,
|
|
1251
|
+
norender = _getSubmitButtonOptio.norender,
|
|
1252
|
+
submitButtonProps = _getSubmitButtonOptio.props;
|
|
1253
|
+
|
|
1254
|
+
if (norender) {
|
|
1255
|
+
return null;
|
|
1256
|
+
}
|
|
1257
|
+
|
|
1258
|
+
return React__default.createElement(react.Box, {
|
|
1259
|
+
marginTop: 3
|
|
1260
|
+
}, React__default.createElement(react.Button, Object.assign({
|
|
1261
|
+
type: "submit",
|
|
1262
|
+
variant: "solid"
|
|
1263
|
+
}, submitButtonProps), submitText));
|
|
1264
|
+
};
|
|
1265
|
+
|
|
1266
|
+
var widgets = {
|
|
1267
|
+
AltDateTimeWidget: AltDateTimeWidget,
|
|
1268
|
+
AltDateWidget: AltDateWidget,
|
|
1269
|
+
CheckboxWidget: CheckboxWidget,
|
|
1270
|
+
CheckboxesWidget: CheckboxesWidget,
|
|
1271
|
+
ColorWidget: ColorWidget,
|
|
1272
|
+
DateWidget: DateWidget,
|
|
1273
|
+
DateTimeWidget: DateTimeWidget,
|
|
1274
|
+
EmailWidget: EmailWidget,
|
|
1275
|
+
PasswordWidget: PasswordWidget,
|
|
1276
|
+
RadioWidget: RadioWidget,
|
|
1277
|
+
RangeWidget: RangeWidget,
|
|
1278
|
+
SelectWidget: SelectWidget,
|
|
1279
|
+
TextareaWidget: TextareaWidget,
|
|
1280
|
+
TextWidget: TextWidget,
|
|
1281
|
+
UpDownWidget: UpDownWidget,
|
|
1282
|
+
URLWidget: URLWidget,
|
|
1283
|
+
SubmitButton: SubmitButton
|
|
1284
|
+
};
|
|
1285
|
+
|
|
1286
|
+
var getDefaultRegistry$1 = core.utils.getDefaultRegistry;
|
|
1287
|
+
|
|
1288
|
+
var _getDefaultRegistry = /*#__PURE__*/getDefaultRegistry$1(),
|
|
1289
|
+
fields = _getDefaultRegistry.fields,
|
|
1290
|
+
widgets$1 = _getDefaultRegistry.widgets;
|
|
1291
|
+
|
|
1292
|
+
var Theme = {
|
|
1293
|
+
ArrayFieldTemplate: ArrayFieldTemplate,
|
|
1294
|
+
FieldTemplate: FieldTemplate,
|
|
1295
|
+
ObjectFieldTemplate: ObjectFieldTemplate,
|
|
1296
|
+
ErrorList: ErrorList,
|
|
1297
|
+
fields: /*#__PURE__*/_extends({}, fields, Fields),
|
|
1298
|
+
widgets: /*#__PURE__*/_extends({}, widgets$1, widgets)
|
|
1299
|
+
};
|
|
1300
|
+
|
|
1301
|
+
var Form = /*#__PURE__*/core.withTheme(Theme);
|
|
1302
|
+
|
|
1303
|
+
/**
|
|
1304
|
+
*
|
|
1305
|
+
* The reason we need this is for ChakraProvider styling in Playground.
|
|
1306
|
+
* The User Developer would be responsible for styling with ChakraProvider in their app.
|
|
1307
|
+
*
|
|
1308
|
+
* Exact duplicate of `@chakra-ui/react`'s `CSSReset` component. Except for the following:
|
|
1309
|
+
*
|
|
1310
|
+
```css
|
|
1311
|
+
input {
|
|
1312
|
+
border-width: revert;
|
|
1313
|
+
border-color: revert;
|
|
1314
|
+
border-style: revert;
|
|
1315
|
+
}
|
|
1316
|
+
.array-item > hr {
|
|
1317
|
+
margin-top: 16px;
|
|
1318
|
+
margin-bottom: 16px;
|
|
1319
|
+
}
|
|
1320
|
+
```
|
|
1321
|
+
|
|
1322
|
+
It is located at the bottom of the styles string.
|
|
1323
|
+
*/
|
|
1324
|
+
|
|
1325
|
+
var CSSReset = function CSSReset() {
|
|
1326
|
+
return React.createElement(react$1.Global, {
|
|
1327
|
+
styles: "\n html {\n line-height: 1.5;\n -webkit-text-size-adjust: 100%;\n font-family: system-ui, sans-serif;\n -webkit-font-smoothing: antialiased;\n text-rendering: optimizeLegibility;\n -moz-osx-font-smoothing: grayscale;\n touch-action: manipulation;\n }\n body {\n position: relative;\n min-height: 100%;\n font-feature-settings: 'kern';\n }\n *,\n *::before,\n *::after {\n border-width: 0;\n border-style: solid;\n box-sizing: border-box;\n }\n main {\n display: block;\n }\n hr {\n border-top-width: 1px;\n box-sizing: content-box;\n height: 0;\n overflow: visible;\n }\n pre,\n code,\n kbd,\n samp {\n font-family: SFMono-Regular, Menlo, Monaco, Consolas, monospace;\n font-size: 1em;\n }\n a {\n background-color: transparent;\n color: inherit;\n text-decoration: inherit;\n }\n abbr[title] {\n border-bottom: none;\n text-decoration: underline;\n -webkit-text-decoration: underline dotted;\n text-decoration: underline dotted;\n }\n b,\n strong {\n font-weight: bold;\n }\n small {\n font-size: 80%;\n }\n sub,\n sup {\n font-size: 75%;\n line-height: 0;\n position: relative;\n vertical-align: baseline;\n }\n sub {\n bottom: -0.25em;\n }\n sup {\n top: -0.5em;\n }\n img {\n border-style: none;\n }\n button,\n input,\n optgroup,\n select,\n textarea {\n font-family: inherit;\n font-size: 100%;\n line-height: 1.15;\n margin: 0;\n }\n button,\n input {\n overflow: visible;\n }\n button,\n select {\n text-transform: none;\n }\n button::-moz-focus-inner,\n [type=\"button\"]::-moz-focus-inner,\n [type=\"reset\"]::-moz-focus-inner,\n [type=\"submit\"]::-moz-focus-inner {\n border-style: none;\n padding: 0;\n }\n fieldset {\n padding: 0.35em 0.75em 0.625em;\n }\n legend {\n box-sizing: border-box;\n color: inherit;\n display: table;\n max-width: 100%;\n padding: 0;\n white-space: normal;\n }\n progress {\n vertical-align: baseline;\n }\n textarea {\n overflow: auto;\n }\n [type=\"checkbox\"],\n [type=\"radio\"] {\n box-sizing: border-box;\n padding: 0;\n }\n [type=\"number\"]::-webkit-inner-spin-button,\n [type=\"number\"]::-webkit-outer-spin-button {\n -webkit-appearance: none !important;\n }\n input[type=\"number\"] {\n -moz-appearance: textfield;\n }\n [type=\"search\"] {\n -webkit-appearance: textfield;\n outline-offset: -2px;\n }\n [type=\"search\"]::-webkit-search-decoration {\n -webkit-appearance: none !important;\n }\n ::-webkit-file-upload-button {\n -webkit-appearance: button;\n font: inherit;\n }\n details {\n display: block;\n }\n summary {\n display: list-item;\n }\n template {\n display: none;\n }\n [hidden] {\n display: none !important;\n }\n body,\n blockquote,\n dl,\n dd,\n h1,\n h2,\n h3,\n h4,\n h5,\n h6,\n hr,\n figure,\n p,\n pre {\n margin: 0;\n }\n button {\n background: transparent;\n padding: 0;\n }\n fieldset {\n margin: 0;\n padding: 0;\n }\n ol,\n ul {\n margin: 0;\n padding: 0;\n }\n textarea {\n resize: vertical;\n }\n button,\n [role=\"button\"] {\n cursor: pointer;\n }\n button::-moz-focus-inner {\n border: 0 !important;\n }\n table {\n border-collapse: collapse;\n }\n h1,\n h2,\n h3,\n h4,\n h5,\n h6 {\n font-size: inherit;\n font-weight: inherit;\n }\n button,\n input,\n optgroup,\n select,\n textarea {\n padding: 0;\n line-height: inherit;\n color: inherit;\n }\n img,\n svg,\n video,\n canvas,\n audio,\n iframe,\n embed,\n object {\n display: block;\n }\n img,\n video {\n max-width: 100%;\n height: auto;\n }\n [data-js-focus-visible] :focus:not([data-focus-visible-added]) {\n outline: none;\n box-shadow: none;\n }\n select::-ms-expand {\n display: none;\n }\n input {\n border-width: revert;\n border-color: revert;\n border-style: revert;\n }\n .array-item > hr {\n margin-top: 16px;\n margin-bottom: 16px;\n }\n "
|
|
1328
|
+
});
|
|
1329
|
+
};
|
|
1330
|
+
|
|
1331
|
+
/**
|
|
1332
|
+
* __createChakraFrameProvider is used to ensure that <Global> emotion components
|
|
1333
|
+
* can be rendered within an iframe without changing the styles of the parent page.
|
|
1334
|
+
* Required for using Chakra UI in the playground.
|
|
1335
|
+
*
|
|
1336
|
+
* We have to define ChakraFrameProvider in this library, as opposed to the playground,
|
|
1337
|
+
* in order to avoid conflicting versions of emotion, which breaks the styling.
|
|
1338
|
+
*
|
|
1339
|
+
* NOTE: This is an internal component only used by @rjsf/playground (no
|
|
1340
|
+
* backwards compatibility guarantees!)
|
|
1341
|
+
*
|
|
1342
|
+
* From: https://codesandbox.io/s/p98y9o7jz0?file=/src/frame-provider.js:0-650
|
|
1343
|
+
* Also see: https://github.com/emotion-js/emotion/issues/760#issuecomment-404353706
|
|
1344
|
+
*/
|
|
1345
|
+
|
|
1346
|
+
var memoizedCreateCacheWithContainer = /*#__PURE__*/weakMemoize(function (container) {
|
|
1347
|
+
var newCache = createCache({
|
|
1348
|
+
container: container,
|
|
1349
|
+
key: "rjsf"
|
|
1350
|
+
});
|
|
1351
|
+
return newCache;
|
|
1352
|
+
});
|
|
1353
|
+
var __createChakraFrameProvider = function __createChakraFrameProvider(props) {
|
|
1354
|
+
return function (_ref) {
|
|
1355
|
+
var document = _ref.document;
|
|
1356
|
+
return React.createElement("div", {
|
|
1357
|
+
style: {
|
|
1358
|
+
margin: 2
|
|
1359
|
+
}
|
|
1360
|
+
}, React.createElement(react$1.CacheProvider, {
|
|
1361
|
+
value: memoizedCreateCacheWithContainer(document.head)
|
|
1362
|
+
}, React.createElement(react.ChakraProvider, {
|
|
1363
|
+
resetCSS: false
|
|
1364
|
+
}, React.createElement(CSSReset, null), props.children)));
|
|
1365
|
+
};
|
|
1366
|
+
};
|
|
1367
|
+
|
|
1368
|
+
exports.ArrayFieldTemplate = ArrayFieldTemplate;
|
|
1369
|
+
exports.FieldTemplate = FieldTemplate;
|
|
1370
|
+
exports.Fields = Fields;
|
|
1371
|
+
exports.Form = Form;
|
|
1372
|
+
exports.ObjectFieldTemplate = ObjectFieldTemplate;
|
|
1373
|
+
exports.Theme = Theme;
|
|
1374
|
+
exports.Widgets = widgets;
|
|
1375
|
+
exports.__createChakraFrameProvider = __createChakraFrameProvider;
|
|
1376
|
+
exports.default = Form;
|
|
1377
|
+
|
|
1378
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
1379
|
+
|
|
1380
|
+
})));
|
|
1381
|
+
//# sourceMappingURL=chakra-ui.umd.development.js.map
|