@rjsf/antd 5.11.2 → 5.12.1
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/antd.esm.js +891 -1117
- package/dist/antd.esm.js.map +7 -1
- package/dist/antd.umd.js +1184 -0
- package/dist/index.js +1347 -5
- package/dist/index.js.map +7 -0
- package/lib/components/DatePicker/index.d.ts +48 -0
- package/lib/components/DatePicker/index.js +5 -0
- package/lib/components/DatePicker/index.js.map +1 -0
- package/lib/index.d.ts +11 -0
- package/lib/index.js +17 -0
- package/lib/index.js.map +1 -0
- package/lib/templates/ArrayFieldItemTemplate/index.d.ts +7 -0
- package/lib/templates/ArrayFieldItemTemplate/index.js +21 -0
- package/lib/templates/ArrayFieldItemTemplate/index.js.map +1 -0
- package/lib/templates/ArrayFieldTemplate/index.d.ts +7 -0
- package/lib/templates/ArrayFieldTemplate/index.js +38 -0
- package/lib/templates/ArrayFieldTemplate/index.js.map +1 -0
- package/lib/templates/BaseInputTemplate/index.d.ts +9 -0
- package/lib/templates/BaseInputTemplate/index.js +31 -0
- package/lib/templates/BaseInputTemplate/index.js.map +1 -0
- package/lib/templates/DescriptionField/index.d.ts +7 -0
- package/lib/templates/DescriptionField/index.js +13 -0
- package/lib/templates/DescriptionField/index.js.map +1 -0
- package/lib/templates/ErrorList/index.d.ts +7 -0
- package/lib/templates/ErrorList/index.js +16 -0
- package/lib/templates/ErrorList/index.js.map +1 -0
- package/lib/templates/FieldErrorTemplate/index.d.ts +7 -0
- package/lib/templates/FieldErrorTemplate/index.js +15 -0
- package/lib/templates/FieldErrorTemplate/index.js.map +1 -0
- package/lib/templates/FieldTemplate/index.d.ts +8 -0
- package/lib/templates/FieldTemplate/index.js +34 -0
- package/lib/templates/FieldTemplate/index.js.map +1 -0
- package/lib/templates/IconButton/index.d.ts +10 -0
- package/lib/templates/IconButton/index.js +36 -0
- package/lib/templates/IconButton/index.js.map +1 -0
- package/lib/templates/ObjectFieldTemplate/index.d.ts +9 -0
- package/lib/templates/ObjectFieldTemplate/index.js +71 -0
- package/lib/templates/ObjectFieldTemplate/index.js.map +1 -0
- package/lib/templates/SubmitButton/index.d.ts +5 -0
- package/lib/templates/SubmitButton/index.js +13 -0
- package/lib/templates/SubmitButton/index.js.map +1 -0
- package/lib/templates/TitleField/index.d.ts +7 -0
- package/lib/templates/TitleField/index.js +34 -0
- package/lib/templates/TitleField/index.js.map +1 -0
- package/lib/templates/WrapIfAdditionalTemplate/index.d.ts +8 -0
- package/lib/templates/WrapIfAdditionalTemplate/index.js +34 -0
- package/lib/templates/WrapIfAdditionalTemplate/index.js.map +1 -0
- package/lib/templates/index.d.ts +4 -0
- package/lib/templates/index.js +36 -0
- package/lib/templates/index.js.map +1 -0
- package/lib/widgets/AltDateTimeWidget/index.d.ts +15 -0
- package/lib/widgets/AltDateTimeWidget/index.js +8 -0
- package/lib/widgets/AltDateTimeWidget/index.js.map +1 -0
- package/lib/widgets/AltDateWidget/index.d.ts +15 -0
- package/lib/widgets/AltDateWidget/index.js +89 -0
- package/lib/widgets/AltDateWidget/index.js.map +1 -0
- package/lib/widgets/CheckboxWidget/index.d.ts +8 -0
- package/lib/widgets/CheckboxWidget/index.js +23 -0
- package/lib/widgets/CheckboxWidget/index.js.map +1 -0
- package/lib/widgets/CheckboxesWidget/index.d.ts +8 -0
- package/lib/widgets/CheckboxesWidget/index.js +26 -0
- package/lib/widgets/CheckboxesWidget/index.js.map +1 -0
- package/lib/widgets/DateTimeWidget/index.d.ts +8 -0
- package/lib/widgets/DateTimeWidget/index.js +22 -0
- package/lib/widgets/DateTimeWidget/index.js.map +1 -0
- package/lib/widgets/DateWidget/index.d.ts +8 -0
- package/lib/widgets/DateWidget/index.js +22 -0
- package/lib/widgets/DateWidget/index.js.map +1 -0
- package/lib/widgets/PasswordWidget/index.d.ts +7 -0
- package/lib/widgets/PasswordWidget/index.js +17 -0
- package/lib/widgets/PasswordWidget/index.js.map +1 -0
- package/lib/widgets/RadioWidget/index.d.ts +8 -0
- package/lib/widgets/RadioWidget/index.js +19 -0
- package/lib/widgets/RadioWidget/index.js.map +1 -0
- package/lib/widgets/RangeWidget/index.d.ts +8 -0
- package/lib/widgets/RangeWidget/index.js +26 -0
- package/lib/widgets/RangeWidget/index.js.map +1 -0
- package/lib/widgets/SelectWidget/index.d.ts +8 -0
- package/lib/widgets/SelectWidget/index.js +36 -0
- package/lib/widgets/SelectWidget/index.js.map +1 -0
- package/lib/widgets/TextareaWidget/index.d.ts +7 -0
- package/lib/widgets/TextareaWidget/index.js +23 -0
- package/lib/widgets/TextareaWidget/index.js.map +1 -0
- package/lib/widgets/index.d.ts +4 -0
- package/lib/widgets/index.js +28 -0
- package/lib/widgets/index.js.map +1 -0
- package/package.json +24 -16
- package/src/components/DatePicker/index.ts +6 -0
- package/src/index.less +38 -0
- package/src/index.ts +33 -0
- package/src/templates/ArrayFieldItemTemplate/index.tsx +90 -0
- package/src/templates/ArrayFieldTemplate/index.tsx +132 -0
- package/src/templates/BaseInputTemplate/index.tsx +105 -0
- package/src/templates/DescriptionField/index.tsx +17 -0
- package/src/templates/ErrorList/index.tsx +37 -0
- package/src/templates/FieldErrorTemplate/index.tsx +25 -0
- package/src/templates/FieldTemplate/index.tsx +114 -0
- package/src/templates/IconButton/index.tsx +94 -0
- package/src/templates/ObjectFieldTemplate/index.tsx +175 -0
- package/src/templates/SubmitButton/index.tsx +20 -0
- package/src/templates/TitleField/index.tsx +57 -0
- package/src/templates/WrapIfAdditionalTemplate/index.tsx +124 -0
- package/src/templates/index.ts +43 -0
- package/src/widgets/AltDateTimeWidget/index.tsx +17 -0
- package/src/widgets/AltDateWidget/index.tsx +197 -0
- package/src/widgets/CheckboxWidget/index.tsx +52 -0
- package/src/widgets/CheckboxesWidget/index.tsx +75 -0
- package/src/widgets/DateTimeWidget/index.tsx +54 -0
- package/src/widgets/DateWidget/index.tsx +52 -0
- package/src/widgets/PasswordWidget/index.tsx +46 -0
- package/src/widgets/RadioWidget/index.tsx +73 -0
- package/src/widgets/RangeWidget/index.tsx +69 -0
- package/src/widgets/SelectWidget/index.tsx +97 -0
- package/src/widgets/TextareaWidget/index.tsx +67 -0
- package/src/widgets/index.ts +35 -0
- package/dist/antd.cjs.development.js +0 -1643
- package/dist/antd.cjs.development.js.map +0 -1
- package/dist/antd.cjs.production.min.js +0 -2
- package/dist/antd.cjs.production.min.js.map +0 -1
- package/dist/antd.umd.development.js +0 -1617
- package/dist/antd.umd.development.js.map +0 -1
- package/dist/antd.umd.production.min.js +0 -2
- package/dist/antd.umd.production.min.js.map +0 -1
- package/dist/index.d.ts +0 -16
package/dist/index.js
CHANGED
|
@@ -1,8 +1,1350 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
1
29
|
|
|
2
|
-
|
|
30
|
+
// src/index.ts
|
|
31
|
+
var src_exports = {};
|
|
32
|
+
__export(src_exports, {
|
|
33
|
+
Form: () => Form3,
|
|
34
|
+
Templates: () => templates_default,
|
|
35
|
+
Theme: () => Theme,
|
|
36
|
+
Widgets: () => widgets_default,
|
|
37
|
+
default: () => src_default,
|
|
38
|
+
generateForm: () => generateForm,
|
|
39
|
+
generateTemplates: () => generateTemplates,
|
|
40
|
+
generateTheme: () => generateTheme,
|
|
41
|
+
generateWidgets: () => generateWidgets
|
|
42
|
+
});
|
|
43
|
+
module.exports = __toCommonJS(src_exports);
|
|
44
|
+
var import_core = require("@rjsf/core");
|
|
3
45
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
46
|
+
// src/templates/ArrayFieldItemTemplate/index.tsx
|
|
47
|
+
var import_button = __toESM(require("antd/lib/button"));
|
|
48
|
+
var import_col = __toESM(require("antd/lib/col"));
|
|
49
|
+
var import_row = __toESM(require("antd/lib/row"));
|
|
50
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
51
|
+
var BTN_GRP_STYLE = {
|
|
52
|
+
width: "100%"
|
|
53
|
+
};
|
|
54
|
+
var BTN_STYLE = {
|
|
55
|
+
width: "calc(100% / 4)"
|
|
56
|
+
};
|
|
57
|
+
function ArrayFieldItemTemplate(props) {
|
|
58
|
+
const {
|
|
59
|
+
children,
|
|
60
|
+
disabled,
|
|
61
|
+
hasCopy,
|
|
62
|
+
hasMoveDown,
|
|
63
|
+
hasMoveUp,
|
|
64
|
+
hasRemove,
|
|
65
|
+
hasToolbar,
|
|
66
|
+
index,
|
|
67
|
+
onCopyIndexClick,
|
|
68
|
+
onDropIndexClick,
|
|
69
|
+
onReorderClick,
|
|
70
|
+
readonly,
|
|
71
|
+
registry,
|
|
72
|
+
uiSchema
|
|
73
|
+
} = props;
|
|
74
|
+
const { CopyButton: CopyButton2, MoveDownButton: MoveDownButton2, MoveUpButton: MoveUpButton2, RemoveButton: RemoveButton2 } = registry.templates.ButtonTemplates;
|
|
75
|
+
const { rowGutter = 24, toolbarAlign = "top" } = registry.formContext;
|
|
76
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_row.default, { align: toolbarAlign, gutter: rowGutter, children: [
|
|
77
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_col.default, { flex: "1", children }),
|
|
78
|
+
hasToolbar && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_col.default, { flex: "192px", children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_button.default.Group, { style: BTN_GRP_STYLE, children: [
|
|
79
|
+
(hasMoveUp || hasMoveDown) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
80
|
+
MoveUpButton2,
|
|
81
|
+
{
|
|
82
|
+
disabled: disabled || readonly || !hasMoveUp,
|
|
83
|
+
onClick: onReorderClick(index, index - 1),
|
|
84
|
+
style: BTN_STYLE,
|
|
85
|
+
uiSchema,
|
|
86
|
+
registry
|
|
87
|
+
}
|
|
88
|
+
),
|
|
89
|
+
(hasMoveUp || hasMoveDown) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
90
|
+
MoveDownButton2,
|
|
91
|
+
{
|
|
92
|
+
disabled: disabled || readonly || !hasMoveDown,
|
|
93
|
+
onClick: onReorderClick(index, index + 1),
|
|
94
|
+
style: BTN_STYLE,
|
|
95
|
+
uiSchema,
|
|
96
|
+
registry
|
|
97
|
+
}
|
|
98
|
+
),
|
|
99
|
+
hasCopy && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
100
|
+
CopyButton2,
|
|
101
|
+
{
|
|
102
|
+
disabled: disabled || readonly,
|
|
103
|
+
onClick: onCopyIndexClick(index),
|
|
104
|
+
style: BTN_STYLE,
|
|
105
|
+
uiSchema,
|
|
106
|
+
registry
|
|
107
|
+
}
|
|
108
|
+
),
|
|
109
|
+
hasRemove && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
110
|
+
RemoveButton2,
|
|
111
|
+
{
|
|
112
|
+
disabled: disabled || readonly,
|
|
113
|
+
onClick: onDropIndexClick(index),
|
|
114
|
+
style: BTN_STYLE,
|
|
115
|
+
uiSchema,
|
|
116
|
+
registry
|
|
117
|
+
}
|
|
118
|
+
)
|
|
119
|
+
] }) })
|
|
120
|
+
] }, `array-item-${index}`);
|
|
8
121
|
}
|
|
122
|
+
|
|
123
|
+
// src/templates/ArrayFieldTemplate/index.tsx
|
|
124
|
+
var import_utils = require("@rjsf/utils");
|
|
125
|
+
var import_classnames = __toESM(require("classnames"));
|
|
126
|
+
var import_col2 = __toESM(require("antd/lib/col"));
|
|
127
|
+
var import_row2 = __toESM(require("antd/lib/row"));
|
|
128
|
+
var import_context = require("antd/lib/config-provider/context");
|
|
129
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
130
|
+
var DESCRIPTION_COL_STYLE = {
|
|
131
|
+
paddingBottom: "8px"
|
|
132
|
+
};
|
|
133
|
+
function ArrayFieldTemplate(props) {
|
|
134
|
+
const {
|
|
135
|
+
canAdd,
|
|
136
|
+
className,
|
|
137
|
+
disabled,
|
|
138
|
+
formContext,
|
|
139
|
+
idSchema,
|
|
140
|
+
items,
|
|
141
|
+
onAddClick,
|
|
142
|
+
readonly,
|
|
143
|
+
registry,
|
|
144
|
+
required,
|
|
145
|
+
schema,
|
|
146
|
+
title,
|
|
147
|
+
uiSchema
|
|
148
|
+
} = props;
|
|
149
|
+
const uiOptions = (0, import_utils.getUiOptions)(uiSchema);
|
|
150
|
+
const ArrayFieldDescriptionTemplate = (0, import_utils.getTemplate)(
|
|
151
|
+
"ArrayFieldDescriptionTemplate",
|
|
152
|
+
registry,
|
|
153
|
+
uiOptions
|
|
154
|
+
);
|
|
155
|
+
const ArrayFieldItemTemplate2 = (0, import_utils.getTemplate)(
|
|
156
|
+
"ArrayFieldItemTemplate",
|
|
157
|
+
registry,
|
|
158
|
+
uiOptions
|
|
159
|
+
);
|
|
160
|
+
const ArrayFieldTitleTemplate = (0, import_utils.getTemplate)(
|
|
161
|
+
"ArrayFieldTitleTemplate",
|
|
162
|
+
registry,
|
|
163
|
+
uiOptions
|
|
164
|
+
);
|
|
165
|
+
const {
|
|
166
|
+
ButtonTemplates: { AddButton: AddButton2 }
|
|
167
|
+
} = registry.templates;
|
|
168
|
+
const { labelAlign = "right", rowGutter = 24 } = formContext;
|
|
169
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_context.ConfigConsumer, { children: (configProps) => {
|
|
170
|
+
const { getPrefixCls } = configProps;
|
|
171
|
+
const prefixCls = getPrefixCls("form");
|
|
172
|
+
const labelClsBasic = `${prefixCls}-item-label`;
|
|
173
|
+
const labelColClassName = (0, import_classnames.default)(
|
|
174
|
+
labelClsBasic,
|
|
175
|
+
labelAlign === "left" && `${labelClsBasic}-left`
|
|
176
|
+
// labelCol.className,
|
|
177
|
+
);
|
|
178
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("fieldset", { className, id: idSchema.$id, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_row2.default, { gutter: rowGutter, children: [
|
|
179
|
+
(uiOptions.title || title) && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_col2.default, { className: labelColClassName, span: 24, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
180
|
+
ArrayFieldTitleTemplate,
|
|
181
|
+
{
|
|
182
|
+
idSchema,
|
|
183
|
+
required,
|
|
184
|
+
title: uiOptions.title || title,
|
|
185
|
+
schema,
|
|
186
|
+
uiSchema,
|
|
187
|
+
registry
|
|
188
|
+
}
|
|
189
|
+
) }),
|
|
190
|
+
(uiOptions.description || schema.description) && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_col2.default, { span: 24, style: DESCRIPTION_COL_STYLE, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
191
|
+
ArrayFieldDescriptionTemplate,
|
|
192
|
+
{
|
|
193
|
+
description: uiOptions.description || schema.description,
|
|
194
|
+
idSchema,
|
|
195
|
+
schema,
|
|
196
|
+
uiSchema,
|
|
197
|
+
registry
|
|
198
|
+
}
|
|
199
|
+
) }),
|
|
200
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_col2.default, { className: "row array-item-list", span: 24, children: items && items.map(({ key, ...itemProps }) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(ArrayFieldItemTemplate2, { ...itemProps }, key)) }),
|
|
201
|
+
canAdd && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_col2.default, { span: 24, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_row2.default, { gutter: rowGutter, justify: "end", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_col2.default, { flex: "192px", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
202
|
+
AddButton2,
|
|
203
|
+
{
|
|
204
|
+
className: "array-item-add",
|
|
205
|
+
disabled: disabled || readonly,
|
|
206
|
+
onClick: onAddClick,
|
|
207
|
+
uiSchema,
|
|
208
|
+
registry
|
|
209
|
+
}
|
|
210
|
+
) }) }) })
|
|
211
|
+
] }) });
|
|
212
|
+
} });
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
// src/templates/BaseInputTemplate/index.tsx
|
|
216
|
+
var import_input = __toESM(require("antd/lib/input"));
|
|
217
|
+
var import_input_number = __toESM(require("antd/lib/input-number"));
|
|
218
|
+
var import_utils2 = require("@rjsf/utils");
|
|
219
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
220
|
+
var INPUT_STYLE = {
|
|
221
|
+
width: "100%"
|
|
222
|
+
};
|
|
223
|
+
function BaseInputTemplate(props) {
|
|
224
|
+
const {
|
|
225
|
+
disabled,
|
|
226
|
+
formContext,
|
|
227
|
+
id,
|
|
228
|
+
onBlur,
|
|
229
|
+
onChange,
|
|
230
|
+
onChangeOverride,
|
|
231
|
+
onFocus,
|
|
232
|
+
options,
|
|
233
|
+
placeholder,
|
|
234
|
+
readonly,
|
|
235
|
+
schema,
|
|
236
|
+
value,
|
|
237
|
+
type
|
|
238
|
+
} = props;
|
|
239
|
+
const inputProps = (0, import_utils2.getInputProps)(schema, type, options, false);
|
|
240
|
+
const { readonlyAsDisabled = true } = formContext;
|
|
241
|
+
const handleNumberChange = (nextValue) => onChange(nextValue);
|
|
242
|
+
const handleTextChange = onChangeOverride ? onChangeOverride : ({ target }) => onChange(target.value === "" ? options.emptyValue : target.value);
|
|
243
|
+
const handleBlur = ({ target }) => onBlur(id, target.value);
|
|
244
|
+
const handleFocus = ({ target }) => onFocus(id, target.value);
|
|
245
|
+
const input = inputProps.type === "number" || inputProps.type === "integer" ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
246
|
+
import_input_number.default,
|
|
247
|
+
{
|
|
248
|
+
disabled: disabled || readonlyAsDisabled && readonly,
|
|
249
|
+
id,
|
|
250
|
+
name: id,
|
|
251
|
+
onBlur: !readonly ? handleBlur : void 0,
|
|
252
|
+
onChange: !readonly ? handleNumberChange : void 0,
|
|
253
|
+
onFocus: !readonly ? handleFocus : void 0,
|
|
254
|
+
placeholder,
|
|
255
|
+
style: INPUT_STYLE,
|
|
256
|
+
list: schema.examples ? (0, import_utils2.examplesId)(id) : void 0,
|
|
257
|
+
...inputProps,
|
|
258
|
+
value,
|
|
259
|
+
"aria-describedby": (0, import_utils2.ariaDescribedByIds)(id, !!schema.examples)
|
|
260
|
+
}
|
|
261
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
262
|
+
import_input.default,
|
|
263
|
+
{
|
|
264
|
+
disabled: disabled || readonlyAsDisabled && readonly,
|
|
265
|
+
id,
|
|
266
|
+
name: id,
|
|
267
|
+
onBlur: !readonly ? handleBlur : void 0,
|
|
268
|
+
onChange: !readonly ? handleTextChange : void 0,
|
|
269
|
+
onFocus: !readonly ? handleFocus : void 0,
|
|
270
|
+
placeholder,
|
|
271
|
+
style: INPUT_STYLE,
|
|
272
|
+
list: schema.examples ? (0, import_utils2.examplesId)(id) : void 0,
|
|
273
|
+
...inputProps,
|
|
274
|
+
value,
|
|
275
|
+
"aria-describedby": (0, import_utils2.ariaDescribedByIds)(id, !!schema.examples)
|
|
276
|
+
}
|
|
277
|
+
);
|
|
278
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
|
|
279
|
+
input,
|
|
280
|
+
Array.isArray(schema.examples) && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("datalist", { id: (0, import_utils2.examplesId)(id), children: schema.examples.concat(schema.default && !schema.examples.includes(schema.default) ? [schema.default] : []).map((example) => {
|
|
281
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("option", { value: example }, example);
|
|
282
|
+
}) })
|
|
283
|
+
] });
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
// src/templates/DescriptionField/index.tsx
|
|
287
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
288
|
+
function DescriptionField(props) {
|
|
289
|
+
const { id, description } = props;
|
|
290
|
+
if (!description) {
|
|
291
|
+
return null;
|
|
292
|
+
}
|
|
293
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { id, children: description });
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
// src/templates/ErrorList/index.tsx
|
|
297
|
+
var import_alert = __toESM(require("antd/lib/alert"));
|
|
298
|
+
var import_list = __toESM(require("antd/lib/list"));
|
|
299
|
+
var import_space = __toESM(require("antd/lib/space"));
|
|
300
|
+
var import_ExclamationCircleOutlined = __toESM(require("@ant-design/icons/ExclamationCircleOutlined"));
|
|
301
|
+
var import_utils3 = require("@rjsf/utils");
|
|
302
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
303
|
+
function ErrorList({
|
|
304
|
+
errors,
|
|
305
|
+
registry
|
|
306
|
+
}) {
|
|
307
|
+
const { translateString } = registry;
|
|
308
|
+
const renderErrors = () => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_list.default, { className: "list-group", size: "small", children: errors.map((error, index) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_list.default.Item, { children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_space.default, { children: [
|
|
309
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_ExclamationCircleOutlined.default, {}),
|
|
310
|
+
error.stack
|
|
311
|
+
] }) }, index)) });
|
|
312
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
313
|
+
import_alert.default,
|
|
314
|
+
{
|
|
315
|
+
className: "panel panel-danger errors",
|
|
316
|
+
description: renderErrors(),
|
|
317
|
+
message: translateString(import_utils3.TranslatableString.ErrorsLabel),
|
|
318
|
+
type: "error"
|
|
319
|
+
}
|
|
320
|
+
);
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
// src/templates/IconButton/index.tsx
|
|
324
|
+
var import_button2 = __toESM(require("antd/lib/button"));
|
|
325
|
+
var import_ArrowDownOutlined = __toESM(require("@ant-design/icons/ArrowDownOutlined"));
|
|
326
|
+
var import_ArrowUpOutlined = __toESM(require("@ant-design/icons/ArrowUpOutlined"));
|
|
327
|
+
var import_CopyOutlined = __toESM(require("@ant-design/icons/CopyOutlined"));
|
|
328
|
+
var import_DeleteOutlined = __toESM(require("@ant-design/icons/DeleteOutlined"));
|
|
329
|
+
var import_PlusCircleOutlined = __toESM(require("@ant-design/icons/PlusCircleOutlined"));
|
|
330
|
+
var import_utils4 = require("@rjsf/utils");
|
|
331
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
332
|
+
function IconButton(props) {
|
|
333
|
+
const { iconType = "default", icon, uiSchema, registry, ...otherProps } = props;
|
|
334
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_button2.default, { type: iconType, icon, ...otherProps });
|
|
335
|
+
}
|
|
336
|
+
function AddButton(props) {
|
|
337
|
+
const {
|
|
338
|
+
registry: { translateString }
|
|
339
|
+
} = props;
|
|
340
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
341
|
+
IconButton,
|
|
342
|
+
{
|
|
343
|
+
title: translateString(import_utils4.TranslatableString.AddItemButton),
|
|
344
|
+
...props,
|
|
345
|
+
block: true,
|
|
346
|
+
iconType: "primary",
|
|
347
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_PlusCircleOutlined.default, {})
|
|
348
|
+
}
|
|
349
|
+
);
|
|
350
|
+
}
|
|
351
|
+
function CopyButton(props) {
|
|
352
|
+
const {
|
|
353
|
+
registry: { translateString }
|
|
354
|
+
} = props;
|
|
355
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(IconButton, { title: translateString(import_utils4.TranslatableString.CopyButton), ...props, icon: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_CopyOutlined.default, {}) });
|
|
356
|
+
}
|
|
357
|
+
function MoveDownButton(props) {
|
|
358
|
+
const {
|
|
359
|
+
registry: { translateString }
|
|
360
|
+
} = props;
|
|
361
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(IconButton, { title: translateString(import_utils4.TranslatableString.MoveDownButton), ...props, icon: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_ArrowDownOutlined.default, {}) });
|
|
362
|
+
}
|
|
363
|
+
function MoveUpButton(props) {
|
|
364
|
+
const {
|
|
365
|
+
registry: { translateString }
|
|
366
|
+
} = props;
|
|
367
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(IconButton, { title: translateString(import_utils4.TranslatableString.MoveUpButton), ...props, icon: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_ArrowUpOutlined.default, {}) });
|
|
368
|
+
}
|
|
369
|
+
function RemoveButton(props) {
|
|
370
|
+
const options = (0, import_utils4.getUiOptions)(props.uiSchema);
|
|
371
|
+
const {
|
|
372
|
+
registry: { translateString }
|
|
373
|
+
} = props;
|
|
374
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
375
|
+
IconButton,
|
|
376
|
+
{
|
|
377
|
+
title: translateString(import_utils4.TranslatableString.RemoveButton),
|
|
378
|
+
...props,
|
|
379
|
+
danger: true,
|
|
380
|
+
block: !!options.block,
|
|
381
|
+
iconType: "primary",
|
|
382
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_DeleteOutlined.default, {})
|
|
383
|
+
}
|
|
384
|
+
);
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
// src/templates/FieldErrorTemplate/index.tsx
|
|
388
|
+
var import_utils5 = require("@rjsf/utils");
|
|
389
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
390
|
+
function FieldErrorTemplate(props) {
|
|
391
|
+
const { errors = [], idSchema } = props;
|
|
392
|
+
if (errors.length === 0) {
|
|
393
|
+
return null;
|
|
394
|
+
}
|
|
395
|
+
const id = (0, import_utils5.errorId)(idSchema);
|
|
396
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { id, children: errors.map((error) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { children: error }, `field-${id}-error-${error}`)) });
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
// src/templates/FieldTemplate/index.tsx
|
|
400
|
+
var import_form = __toESM(require("antd/lib/form"));
|
|
401
|
+
var import_utils6 = require("@rjsf/utils");
|
|
402
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
403
|
+
var VERTICAL_LABEL_COL = { span: 24 };
|
|
404
|
+
var VERTICAL_WRAPPER_COL = { span: 24 };
|
|
405
|
+
function FieldTemplate(props) {
|
|
406
|
+
const {
|
|
407
|
+
children,
|
|
408
|
+
classNames: classNames4,
|
|
409
|
+
style,
|
|
410
|
+
description,
|
|
411
|
+
disabled,
|
|
412
|
+
displayLabel,
|
|
413
|
+
errors,
|
|
414
|
+
formContext,
|
|
415
|
+
help,
|
|
416
|
+
hidden,
|
|
417
|
+
id,
|
|
418
|
+
label,
|
|
419
|
+
onDropPropertyClick,
|
|
420
|
+
onKeyChange,
|
|
421
|
+
rawErrors,
|
|
422
|
+
rawDescription,
|
|
423
|
+
rawHelp,
|
|
424
|
+
readonly,
|
|
425
|
+
registry,
|
|
426
|
+
required,
|
|
427
|
+
schema,
|
|
428
|
+
uiSchema
|
|
429
|
+
} = props;
|
|
430
|
+
const {
|
|
431
|
+
colon,
|
|
432
|
+
labelCol = VERTICAL_LABEL_COL,
|
|
433
|
+
wrapperCol = VERTICAL_WRAPPER_COL,
|
|
434
|
+
wrapperStyle,
|
|
435
|
+
descriptionLocation = "below"
|
|
436
|
+
} = formContext;
|
|
437
|
+
const uiOptions = (0, import_utils6.getUiOptions)(uiSchema);
|
|
438
|
+
const WrapIfAdditionalTemplate2 = (0, import_utils6.getTemplate)(
|
|
439
|
+
"WrapIfAdditionalTemplate",
|
|
440
|
+
registry,
|
|
441
|
+
uiOptions
|
|
442
|
+
);
|
|
443
|
+
if (hidden) {
|
|
444
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "field-hidden", children });
|
|
445
|
+
}
|
|
446
|
+
const descriptionNode = rawDescription ? description : void 0;
|
|
447
|
+
const descriptionProps = {};
|
|
448
|
+
switch (descriptionLocation) {
|
|
449
|
+
case "tooltip":
|
|
450
|
+
descriptionProps.tooltip = descriptionNode;
|
|
451
|
+
break;
|
|
452
|
+
case "below":
|
|
453
|
+
default:
|
|
454
|
+
descriptionProps.extra = descriptionNode;
|
|
455
|
+
break;
|
|
456
|
+
}
|
|
457
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
458
|
+
WrapIfAdditionalTemplate2,
|
|
459
|
+
{
|
|
460
|
+
classNames: classNames4,
|
|
461
|
+
style,
|
|
462
|
+
disabled,
|
|
463
|
+
id,
|
|
464
|
+
label,
|
|
465
|
+
onDropPropertyClick,
|
|
466
|
+
onKeyChange,
|
|
467
|
+
readonly,
|
|
468
|
+
required,
|
|
469
|
+
schema,
|
|
470
|
+
uiSchema,
|
|
471
|
+
registry,
|
|
472
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
473
|
+
import_form.default.Item,
|
|
474
|
+
{
|
|
475
|
+
colon,
|
|
476
|
+
hasFeedback: schema.type !== "array" && schema.type !== "object",
|
|
477
|
+
help: !!rawHelp && help || (rawErrors?.length ? errors : void 0),
|
|
478
|
+
htmlFor: id,
|
|
479
|
+
label: displayLabel && label,
|
|
480
|
+
labelCol,
|
|
481
|
+
required,
|
|
482
|
+
style: wrapperStyle,
|
|
483
|
+
validateStatus: rawErrors?.length ? "error" : void 0,
|
|
484
|
+
wrapperCol,
|
|
485
|
+
...descriptionProps,
|
|
486
|
+
children
|
|
487
|
+
}
|
|
488
|
+
)
|
|
489
|
+
}
|
|
490
|
+
);
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
// src/templates/ObjectFieldTemplate/index.tsx
|
|
494
|
+
var import_classnames2 = __toESM(require("classnames"));
|
|
495
|
+
var import_isObject = __toESM(require("lodash/isObject"));
|
|
496
|
+
var import_isNumber = __toESM(require("lodash/isNumber"));
|
|
497
|
+
var import_isString = __toESM(require("lodash/isString"));
|
|
498
|
+
var import_utils7 = require("@rjsf/utils");
|
|
499
|
+
var import_col3 = __toESM(require("antd/lib/col"));
|
|
500
|
+
var import_row3 = __toESM(require("antd/lib/row"));
|
|
501
|
+
var import_context2 = require("antd/lib/config-provider/context");
|
|
502
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
503
|
+
var DESCRIPTION_COL_STYLE2 = {
|
|
504
|
+
paddingBottom: "8px"
|
|
505
|
+
};
|
|
506
|
+
function ObjectFieldTemplate(props) {
|
|
507
|
+
const {
|
|
508
|
+
description,
|
|
509
|
+
disabled,
|
|
510
|
+
formContext,
|
|
511
|
+
formData,
|
|
512
|
+
idSchema,
|
|
513
|
+
onAddClick,
|
|
514
|
+
properties,
|
|
515
|
+
readonly,
|
|
516
|
+
required,
|
|
517
|
+
registry,
|
|
518
|
+
schema,
|
|
519
|
+
title,
|
|
520
|
+
uiSchema
|
|
521
|
+
} = props;
|
|
522
|
+
const uiOptions = (0, import_utils7.getUiOptions)(uiSchema);
|
|
523
|
+
const TitleFieldTemplate = (0, import_utils7.getTemplate)("TitleFieldTemplate", registry, uiOptions);
|
|
524
|
+
const DescriptionFieldTemplate = (0, import_utils7.getTemplate)(
|
|
525
|
+
"DescriptionFieldTemplate",
|
|
526
|
+
registry,
|
|
527
|
+
uiOptions
|
|
528
|
+
);
|
|
529
|
+
const {
|
|
530
|
+
ButtonTemplates: { AddButton: AddButton2 }
|
|
531
|
+
} = registry.templates;
|
|
532
|
+
const { colSpan = 24, labelAlign = "right", rowGutter = 24 } = formContext;
|
|
533
|
+
const findSchema = (element) => element.content.props.schema;
|
|
534
|
+
const findSchemaType = (element) => findSchema(element).type;
|
|
535
|
+
const findUiSchema = (element) => element.content.props.uiSchema;
|
|
536
|
+
const findUiSchemaField = (element) => (0, import_utils7.getUiOptions)(findUiSchema(element)).field;
|
|
537
|
+
const findUiSchemaWidget = (element) => (0, import_utils7.getUiOptions)(findUiSchema(element)).widget;
|
|
538
|
+
const calculateColSpan = (element) => {
|
|
539
|
+
const type = findSchemaType(element);
|
|
540
|
+
const field = findUiSchemaField(element);
|
|
541
|
+
const widget = findUiSchemaWidget(element);
|
|
542
|
+
const defaultColSpan = properties.length < 2 || // Single or no field in object.
|
|
543
|
+
type === "object" || type === "array" || widget === "textarea" ? 24 : 12;
|
|
544
|
+
if ((0, import_isObject.default)(colSpan)) {
|
|
545
|
+
const colSpanObj = colSpan;
|
|
546
|
+
if ((0, import_isString.default)(widget)) {
|
|
547
|
+
return colSpanObj[widget];
|
|
548
|
+
}
|
|
549
|
+
if ((0, import_isString.default)(field)) {
|
|
550
|
+
return colSpanObj[field];
|
|
551
|
+
}
|
|
552
|
+
if ((0, import_isString.default)(type)) {
|
|
553
|
+
return colSpanObj[type];
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
if ((0, import_isNumber.default)(colSpan)) {
|
|
557
|
+
return colSpan;
|
|
558
|
+
}
|
|
559
|
+
return defaultColSpan;
|
|
560
|
+
};
|
|
561
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_context2.ConfigConsumer, { children: (configProps) => {
|
|
562
|
+
const { getPrefixCls } = configProps;
|
|
563
|
+
const prefixCls = getPrefixCls("form");
|
|
564
|
+
const labelClsBasic = `${prefixCls}-item-label`;
|
|
565
|
+
const labelColClassName = (0, import_classnames2.default)(
|
|
566
|
+
labelClsBasic,
|
|
567
|
+
labelAlign === "left" && `${labelClsBasic}-left`
|
|
568
|
+
// labelCol.className,
|
|
569
|
+
);
|
|
570
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("fieldset", { id: idSchema.$id, children: [
|
|
571
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_row3.default, { gutter: rowGutter, children: [
|
|
572
|
+
title && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_col3.default, { className: labelColClassName, span: 24, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
573
|
+
TitleFieldTemplate,
|
|
574
|
+
{
|
|
575
|
+
id: (0, import_utils7.titleId)(idSchema),
|
|
576
|
+
title,
|
|
577
|
+
required,
|
|
578
|
+
schema,
|
|
579
|
+
uiSchema,
|
|
580
|
+
registry
|
|
581
|
+
}
|
|
582
|
+
) }),
|
|
583
|
+
description && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_col3.default, { span: 24, style: DESCRIPTION_COL_STYLE2, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
584
|
+
DescriptionFieldTemplate,
|
|
585
|
+
{
|
|
586
|
+
id: (0, import_utils7.descriptionId)(idSchema),
|
|
587
|
+
description,
|
|
588
|
+
schema,
|
|
589
|
+
uiSchema,
|
|
590
|
+
registry
|
|
591
|
+
}
|
|
592
|
+
) }),
|
|
593
|
+
properties.filter((e) => !e.hidden).map((element) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_col3.default, { span: calculateColSpan(element), children: element.content }, element.name))
|
|
594
|
+
] }),
|
|
595
|
+
(0, import_utils7.canExpand)(schema, uiSchema, formData) && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_col3.default, { span: 24, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_row3.default, { gutter: rowGutter, justify: "end", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_col3.default, { flex: "192px", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
596
|
+
AddButton2,
|
|
597
|
+
{
|
|
598
|
+
className: "object-property-expand",
|
|
599
|
+
disabled: disabled || readonly,
|
|
600
|
+
onClick: onAddClick(schema),
|
|
601
|
+
uiSchema,
|
|
602
|
+
registry
|
|
603
|
+
}
|
|
604
|
+
) }) }) })
|
|
605
|
+
] });
|
|
606
|
+
} });
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
// src/templates/SubmitButton/index.tsx
|
|
610
|
+
var import_button3 = __toESM(require("antd/lib/button"));
|
|
611
|
+
var import_utils8 = require("@rjsf/utils");
|
|
612
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
613
|
+
function SubmitButton({ uiSchema }) {
|
|
614
|
+
const { submitText, norender, props: submitButtonProps } = (0, import_utils8.getSubmitButtonOptions)(uiSchema);
|
|
615
|
+
if (norender) {
|
|
616
|
+
return null;
|
|
617
|
+
}
|
|
618
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_button3.default, { type: "submit", ...submitButtonProps, htmlType: "submit", children: submitText });
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
// src/templates/TitleField/index.tsx
|
|
622
|
+
var import_classnames3 = __toESM(require("classnames"));
|
|
623
|
+
var import_context3 = require("antd/lib/config-provider/context");
|
|
624
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
625
|
+
function TitleField({
|
|
626
|
+
id,
|
|
627
|
+
required,
|
|
628
|
+
registry,
|
|
629
|
+
title
|
|
630
|
+
}) {
|
|
631
|
+
const { formContext } = registry;
|
|
632
|
+
const { colon = true } = formContext;
|
|
633
|
+
let labelChildren = title;
|
|
634
|
+
if (colon && typeof title === "string" && title.trim() !== "") {
|
|
635
|
+
labelChildren = title.replace(/[::]\s*$/, "");
|
|
636
|
+
}
|
|
637
|
+
const handleLabelClick = () => {
|
|
638
|
+
if (!id) {
|
|
639
|
+
return;
|
|
640
|
+
}
|
|
641
|
+
const control = document.querySelector(`[id="${id}"]`);
|
|
642
|
+
if (control && control.focus) {
|
|
643
|
+
control.focus();
|
|
644
|
+
}
|
|
645
|
+
};
|
|
646
|
+
return title ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_context3.ConfigConsumer, { children: (configProps) => {
|
|
647
|
+
const { getPrefixCls } = configProps;
|
|
648
|
+
const prefixCls = getPrefixCls("form");
|
|
649
|
+
const labelClassName = (0, import_classnames3.default)({
|
|
650
|
+
[`${prefixCls}-item-required`]: required,
|
|
651
|
+
[`${prefixCls}-item-no-colon`]: !colon
|
|
652
|
+
});
|
|
653
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
654
|
+
"label",
|
|
655
|
+
{
|
|
656
|
+
className: labelClassName,
|
|
657
|
+
htmlFor: id,
|
|
658
|
+
onClick: handleLabelClick,
|
|
659
|
+
title: typeof title === "string" ? title : "",
|
|
660
|
+
children: labelChildren
|
|
661
|
+
}
|
|
662
|
+
);
|
|
663
|
+
} }) : null;
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
// src/templates/WrapIfAdditionalTemplate/index.tsx
|
|
667
|
+
var import_col4 = __toESM(require("antd/lib/col"));
|
|
668
|
+
var import_form2 = __toESM(require("antd/lib/form"));
|
|
669
|
+
var import_input2 = __toESM(require("antd/lib/input"));
|
|
670
|
+
var import_row4 = __toESM(require("antd/lib/row"));
|
|
671
|
+
var import_utils9 = require("@rjsf/utils");
|
|
672
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
673
|
+
var VERTICAL_LABEL_COL2 = { span: 24 };
|
|
674
|
+
var VERTICAL_WRAPPER_COL2 = { span: 24 };
|
|
675
|
+
var INPUT_STYLE2 = {
|
|
676
|
+
width: "100%"
|
|
677
|
+
};
|
|
678
|
+
function WrapIfAdditionalTemplate(props) {
|
|
679
|
+
const {
|
|
680
|
+
children,
|
|
681
|
+
classNames: classNames4,
|
|
682
|
+
style,
|
|
683
|
+
disabled,
|
|
684
|
+
id,
|
|
685
|
+
label,
|
|
686
|
+
onDropPropertyClick,
|
|
687
|
+
onKeyChange,
|
|
688
|
+
readonly,
|
|
689
|
+
required,
|
|
690
|
+
registry,
|
|
691
|
+
schema,
|
|
692
|
+
uiSchema
|
|
693
|
+
} = props;
|
|
694
|
+
const {
|
|
695
|
+
colon,
|
|
696
|
+
labelCol = VERTICAL_LABEL_COL2,
|
|
697
|
+
readonlyAsDisabled = true,
|
|
698
|
+
rowGutter = 24,
|
|
699
|
+
toolbarAlign = "top",
|
|
700
|
+
wrapperCol = VERTICAL_WRAPPER_COL2,
|
|
701
|
+
wrapperStyle
|
|
702
|
+
} = registry.formContext;
|
|
703
|
+
const { templates, translateString } = registry;
|
|
704
|
+
const { RemoveButton: RemoveButton2 } = templates.ButtonTemplates;
|
|
705
|
+
const keyLabel = translateString(import_utils9.TranslatableString.KeyLabel, [label]);
|
|
706
|
+
const additional = import_utils9.ADDITIONAL_PROPERTY_FLAG in schema;
|
|
707
|
+
if (!additional) {
|
|
708
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: classNames4, style, children });
|
|
709
|
+
}
|
|
710
|
+
const handleBlur = ({ target }) => onKeyChange(target.value);
|
|
711
|
+
const uiOptions = uiSchema ? uiSchema[import_utils9.UI_OPTIONS_KEY] : {};
|
|
712
|
+
const buttonUiOptions = {
|
|
713
|
+
...uiSchema,
|
|
714
|
+
[import_utils9.UI_OPTIONS_KEY]: { ...uiOptions, block: true }
|
|
715
|
+
};
|
|
716
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: classNames4, style, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_row4.default, { align: toolbarAlign, gutter: rowGutter, children: [
|
|
717
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_col4.default, { className: "form-additional", flex: "1", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "form-group", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
718
|
+
import_form2.default.Item,
|
|
719
|
+
{
|
|
720
|
+
colon,
|
|
721
|
+
className: "form-group",
|
|
722
|
+
hasFeedback: true,
|
|
723
|
+
htmlFor: `${id}-key`,
|
|
724
|
+
label: keyLabel,
|
|
725
|
+
labelCol,
|
|
726
|
+
required,
|
|
727
|
+
style: wrapperStyle,
|
|
728
|
+
wrapperCol,
|
|
729
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
730
|
+
import_input2.default,
|
|
731
|
+
{
|
|
732
|
+
className: "form-control",
|
|
733
|
+
defaultValue: label,
|
|
734
|
+
disabled: disabled || readonlyAsDisabled && readonly,
|
|
735
|
+
id: `${id}-key`,
|
|
736
|
+
name: `${id}-key`,
|
|
737
|
+
onBlur: !readonly ? handleBlur : void 0,
|
|
738
|
+
style: INPUT_STYLE2,
|
|
739
|
+
type: "text"
|
|
740
|
+
}
|
|
741
|
+
)
|
|
742
|
+
}
|
|
743
|
+
) }) }),
|
|
744
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_col4.default, { className: "form-additional", flex: "1", children }),
|
|
745
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_col4.default, { flex: "192px", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
746
|
+
RemoveButton2,
|
|
747
|
+
{
|
|
748
|
+
className: "array-item-remove",
|
|
749
|
+
disabled: disabled || readonly,
|
|
750
|
+
onClick: onDropPropertyClick(label),
|
|
751
|
+
uiSchema: buttonUiOptions,
|
|
752
|
+
registry
|
|
753
|
+
}
|
|
754
|
+
) })
|
|
755
|
+
] }) });
|
|
756
|
+
}
|
|
757
|
+
|
|
758
|
+
// src/templates/index.ts
|
|
759
|
+
function generateTemplates() {
|
|
760
|
+
return {
|
|
761
|
+
ArrayFieldItemTemplate,
|
|
762
|
+
ArrayFieldTemplate,
|
|
763
|
+
BaseInputTemplate,
|
|
764
|
+
ButtonTemplates: {
|
|
765
|
+
AddButton,
|
|
766
|
+
CopyButton,
|
|
767
|
+
MoveDownButton,
|
|
768
|
+
MoveUpButton,
|
|
769
|
+
RemoveButton,
|
|
770
|
+
SubmitButton
|
|
771
|
+
},
|
|
772
|
+
DescriptionFieldTemplate: DescriptionField,
|
|
773
|
+
ErrorListTemplate: ErrorList,
|
|
774
|
+
FieldErrorTemplate,
|
|
775
|
+
FieldTemplate,
|
|
776
|
+
ObjectFieldTemplate,
|
|
777
|
+
TitleFieldTemplate: TitleField,
|
|
778
|
+
WrapIfAdditionalTemplate
|
|
779
|
+
};
|
|
780
|
+
}
|
|
781
|
+
var templates_default = generateTemplates();
|
|
782
|
+
|
|
783
|
+
// src/widgets/AltDateWidget/index.tsx
|
|
784
|
+
var import_react = require("react");
|
|
785
|
+
var import_button4 = __toESM(require("antd/lib/button"));
|
|
786
|
+
var import_col5 = __toESM(require("antd/lib/col"));
|
|
787
|
+
var import_row5 = __toESM(require("antd/lib/row"));
|
|
788
|
+
var import_utils10 = require("@rjsf/utils");
|
|
789
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
790
|
+
var rangeOptions = (start, stop) => {
|
|
791
|
+
const options = [];
|
|
792
|
+
for (let i = start; i <= stop; i++) {
|
|
793
|
+
options.push({ value: i, label: (0, import_utils10.pad)(i, 2) });
|
|
794
|
+
}
|
|
795
|
+
return options;
|
|
796
|
+
};
|
|
797
|
+
var readyForChange = (state) => {
|
|
798
|
+
return Object.values(state).every((value) => value !== -1);
|
|
799
|
+
};
|
|
800
|
+
function dateElementProps(state, time, yearsRange = [1900, (/* @__PURE__ */ new Date()).getFullYear() + 2]) {
|
|
801
|
+
const { year, month, day, hour, minute, second } = state;
|
|
802
|
+
const data = [
|
|
803
|
+
{
|
|
804
|
+
type: "year",
|
|
805
|
+
range: yearsRange,
|
|
806
|
+
value: year
|
|
807
|
+
},
|
|
808
|
+
{ type: "month", range: [1, 12], value: month },
|
|
809
|
+
{ type: "day", range: [1, 31], value: day }
|
|
810
|
+
];
|
|
811
|
+
if (time) {
|
|
812
|
+
data.push(
|
|
813
|
+
{ type: "hour", range: [0, 23], value: hour || -1 },
|
|
814
|
+
{ type: "minute", range: [0, 59], value: minute || -1 },
|
|
815
|
+
{ type: "second", range: [0, 59], value: second || -1 }
|
|
816
|
+
);
|
|
817
|
+
}
|
|
818
|
+
return data;
|
|
819
|
+
}
|
|
820
|
+
function AltDateWidget(props) {
|
|
821
|
+
const {
|
|
822
|
+
autofocus,
|
|
823
|
+
disabled,
|
|
824
|
+
formContext,
|
|
825
|
+
id,
|
|
826
|
+
onBlur,
|
|
827
|
+
onChange,
|
|
828
|
+
onFocus,
|
|
829
|
+
options,
|
|
830
|
+
readonly,
|
|
831
|
+
registry,
|
|
832
|
+
showTime,
|
|
833
|
+
value
|
|
834
|
+
} = props;
|
|
835
|
+
const { translateString, widgets } = registry;
|
|
836
|
+
const { SelectWidget: SelectWidget2 } = widgets;
|
|
837
|
+
const { rowGutter = 24 } = formContext;
|
|
838
|
+
const [state, setState] = (0, import_react.useState)((0, import_utils10.parseDateString)(value, showTime));
|
|
839
|
+
(0, import_react.useEffect)(() => {
|
|
840
|
+
setState((0, import_utils10.parseDateString)(value, showTime));
|
|
841
|
+
}, [showTime, value]);
|
|
842
|
+
const handleChange = (property, nextValue) => {
|
|
843
|
+
const nextState = {
|
|
844
|
+
...state,
|
|
845
|
+
[property]: typeof nextValue === "undefined" ? -1 : nextValue
|
|
846
|
+
};
|
|
847
|
+
if (readyForChange(nextState)) {
|
|
848
|
+
onChange((0, import_utils10.toDateString)(nextState, showTime));
|
|
849
|
+
} else {
|
|
850
|
+
setState(nextState);
|
|
851
|
+
}
|
|
852
|
+
};
|
|
853
|
+
const handleNow = (event) => {
|
|
854
|
+
event.preventDefault();
|
|
855
|
+
if (disabled || readonly) {
|
|
856
|
+
return;
|
|
857
|
+
}
|
|
858
|
+
const nextState = (0, import_utils10.parseDateString)((/* @__PURE__ */ new Date()).toJSON(), showTime);
|
|
859
|
+
onChange((0, import_utils10.toDateString)(nextState, showTime));
|
|
860
|
+
};
|
|
861
|
+
const handleClear = (event) => {
|
|
862
|
+
event.preventDefault();
|
|
863
|
+
if (disabled || readonly) {
|
|
864
|
+
return;
|
|
865
|
+
}
|
|
866
|
+
onChange(void 0);
|
|
867
|
+
};
|
|
868
|
+
const renderDateElement = (elemProps) => /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
869
|
+
SelectWidget2,
|
|
870
|
+
{
|
|
871
|
+
autofocus: elemProps.autofocus,
|
|
872
|
+
className: "form-control",
|
|
873
|
+
disabled: elemProps.disabled,
|
|
874
|
+
id: elemProps.id,
|
|
875
|
+
name: elemProps.name,
|
|
876
|
+
onBlur: elemProps.onBlur,
|
|
877
|
+
onChange: (elemValue) => elemProps.select(elemProps.type, elemValue),
|
|
878
|
+
onFocus: elemProps.onFocus,
|
|
879
|
+
options: {
|
|
880
|
+
enumOptions: rangeOptions(elemProps.range[0], elemProps.range[1])
|
|
881
|
+
},
|
|
882
|
+
placeholder: elemProps.type,
|
|
883
|
+
readonly: elemProps.readonly,
|
|
884
|
+
schema: { type: "integer" },
|
|
885
|
+
value: elemProps.value,
|
|
886
|
+
registry,
|
|
887
|
+
label: "",
|
|
888
|
+
"aria-describedby": (0, import_utils10.ariaDescribedByIds)(id)
|
|
889
|
+
}
|
|
890
|
+
);
|
|
891
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_row5.default, { gutter: [Math.floor(rowGutter / 2), Math.floor(rowGutter / 2)], children: [
|
|
892
|
+
dateElementProps(state, showTime, options.yearsRange).map((elemProps, i) => {
|
|
893
|
+
const elemId = id + "_" + elemProps.type;
|
|
894
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_col5.default, { flex: "88px", children: renderDateElement({
|
|
895
|
+
...elemProps,
|
|
896
|
+
autofocus: autofocus && i === 0,
|
|
897
|
+
disabled,
|
|
898
|
+
id: elemId,
|
|
899
|
+
name: id,
|
|
900
|
+
onBlur,
|
|
901
|
+
onFocus,
|
|
902
|
+
readonly,
|
|
903
|
+
registry,
|
|
904
|
+
select: handleChange,
|
|
905
|
+
// NOTE: antd components accept -1 rather than issue a warning
|
|
906
|
+
// like material-ui, so we need to convert -1 to undefined here.
|
|
907
|
+
value: elemProps.value < 0 ? void 0 : elemProps.value
|
|
908
|
+
}) }, elemId);
|
|
909
|
+
}),
|
|
910
|
+
!options.hideNowButton && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_col5.default, { flex: "88px", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_button4.default, { block: true, className: "btn-now", onClick: handleNow, type: "primary", children: translateString(import_utils10.TranslatableString.NowLabel) }) }),
|
|
911
|
+
!options.hideClearButton && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_col5.default, { flex: "88px", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_button4.default, { block: true, className: "btn-clear", danger: true, onClick: handleClear, type: "primary", children: translateString(import_utils10.TranslatableString.ClearLabel) }) })
|
|
912
|
+
] });
|
|
913
|
+
}
|
|
914
|
+
AltDateWidget.defaultProps = {
|
|
915
|
+
autofocus: false,
|
|
916
|
+
disabled: false,
|
|
917
|
+
options: {
|
|
918
|
+
yearsRange: [1900, (/* @__PURE__ */ new Date()).getFullYear() + 2]
|
|
919
|
+
},
|
|
920
|
+
readonly: false,
|
|
921
|
+
showTime: false
|
|
922
|
+
};
|
|
923
|
+
|
|
924
|
+
// src/widgets/AltDateTimeWidget/index.tsx
|
|
925
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
926
|
+
function AltDateTimeWidget(props) {
|
|
927
|
+
const { AltDateWidget: AltDateWidget2 } = props.registry.widgets;
|
|
928
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(AltDateWidget2, { showTime: true, ...props });
|
|
929
|
+
}
|
|
930
|
+
AltDateTimeWidget.defaultProps = {
|
|
931
|
+
...AltDateWidget.defaultProps,
|
|
932
|
+
showTime: true
|
|
933
|
+
};
|
|
934
|
+
|
|
935
|
+
// src/widgets/CheckboxesWidget/index.tsx
|
|
936
|
+
var import_checkbox = __toESM(require("antd/lib/checkbox"));
|
|
937
|
+
var import_utils11 = require("@rjsf/utils");
|
|
938
|
+
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
939
|
+
function CheckboxesWidget({ autofocus, disabled, formContext, id, onBlur, onChange, onFocus, options, readonly, value }) {
|
|
940
|
+
const { readonlyAsDisabled = true } = formContext;
|
|
941
|
+
const { enumOptions, enumDisabled, inline, emptyValue } = options;
|
|
942
|
+
const handleChange = (nextValue) => onChange((0, import_utils11.enumOptionsValueForIndex)(nextValue, enumOptions, emptyValue));
|
|
943
|
+
const handleBlur = ({ target }) => onBlur(id, (0, import_utils11.enumOptionsValueForIndex)(target.value, enumOptions, emptyValue));
|
|
944
|
+
const handleFocus = ({ target }) => onFocus(id, (0, import_utils11.enumOptionsValueForIndex)(target.value, enumOptions, emptyValue));
|
|
945
|
+
const extraProps = {
|
|
946
|
+
id,
|
|
947
|
+
onBlur: !readonly ? handleBlur : void 0,
|
|
948
|
+
onFocus: !readonly ? handleFocus : void 0
|
|
949
|
+
};
|
|
950
|
+
const selectedIndexes = (0, import_utils11.enumOptionsIndexForValue)(value, enumOptions, true);
|
|
951
|
+
return Array.isArray(enumOptions) && enumOptions.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_jsx_runtime15.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
952
|
+
import_checkbox.default.Group,
|
|
953
|
+
{
|
|
954
|
+
disabled: disabled || readonlyAsDisabled && readonly,
|
|
955
|
+
name: id,
|
|
956
|
+
onChange: !readonly ? handleChange : void 0,
|
|
957
|
+
value: selectedIndexes,
|
|
958
|
+
...extraProps,
|
|
959
|
+
"aria-describedby": (0, import_utils11.ariaDescribedByIds)(id),
|
|
960
|
+
children: Array.isArray(enumOptions) && enumOptions.map((option, i) => /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("span", { children: [
|
|
961
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
962
|
+
import_checkbox.default,
|
|
963
|
+
{
|
|
964
|
+
id: (0, import_utils11.optionId)(id, i),
|
|
965
|
+
name: id,
|
|
966
|
+
autoFocus: i === 0 ? autofocus : false,
|
|
967
|
+
disabled: Array.isArray(enumDisabled) && enumDisabled.indexOf(value) !== -1,
|
|
968
|
+
value: String(i),
|
|
969
|
+
children: option.label
|
|
970
|
+
}
|
|
971
|
+
),
|
|
972
|
+
!inline && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("br", {})
|
|
973
|
+
] }, i))
|
|
974
|
+
}
|
|
975
|
+
) }) : null;
|
|
976
|
+
}
|
|
977
|
+
|
|
978
|
+
// src/widgets/CheckboxWidget/index.tsx
|
|
979
|
+
var import_checkbox2 = __toESM(require("antd/lib/checkbox"));
|
|
980
|
+
var import_utils12 = require("@rjsf/utils");
|
|
981
|
+
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
982
|
+
function CheckboxWidget(props) {
|
|
983
|
+
const { autofocus, disabled, formContext, id, label, hideLabel, onBlur, onChange, onFocus, readonly, value } = props;
|
|
984
|
+
const { readonlyAsDisabled = true } = formContext;
|
|
985
|
+
const handleChange = ({ target }) => onChange(target.checked);
|
|
986
|
+
const handleBlur = ({ target }) => onBlur(id, target.checked);
|
|
987
|
+
const handleFocus = ({ target }) => onFocus(id, target.checked);
|
|
988
|
+
const extraProps = {
|
|
989
|
+
onBlur: !readonly ? handleBlur : void 0,
|
|
990
|
+
onFocus: !readonly ? handleFocus : void 0
|
|
991
|
+
};
|
|
992
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
993
|
+
import_checkbox2.default,
|
|
994
|
+
{
|
|
995
|
+
autoFocus: autofocus,
|
|
996
|
+
checked: typeof value === "undefined" ? false : value,
|
|
997
|
+
disabled: disabled || readonlyAsDisabled && readonly,
|
|
998
|
+
id,
|
|
999
|
+
name: id,
|
|
1000
|
+
onChange: !readonly ? handleChange : void 0,
|
|
1001
|
+
...extraProps,
|
|
1002
|
+
"aria-describedby": (0, import_utils12.ariaDescribedByIds)(id),
|
|
1003
|
+
children: (0, import_utils12.labelValue)(label, hideLabel, "")
|
|
1004
|
+
}
|
|
1005
|
+
);
|
|
1006
|
+
}
|
|
1007
|
+
|
|
1008
|
+
// src/widgets/DateTimeWidget/index.tsx
|
|
1009
|
+
var import_dayjs2 = __toESM(require("dayjs"));
|
|
1010
|
+
var import_utils13 = require("@rjsf/utils");
|
|
1011
|
+
|
|
1012
|
+
// src/components/DatePicker/index.ts
|
|
1013
|
+
var import_dayjs = __toESM(require("rc-picker/lib/generate/dayjs"));
|
|
1014
|
+
var import_generatePicker = __toESM(require("antd/lib/date-picker/generatePicker"));
|
|
1015
|
+
var DatePicker = (0, import_generatePicker.default)(import_dayjs.default);
|
|
1016
|
+
var DatePicker_default = DatePicker;
|
|
1017
|
+
|
|
1018
|
+
// src/widgets/DateTimeWidget/index.tsx
|
|
1019
|
+
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
1020
|
+
var DATE_PICKER_STYLE = {
|
|
1021
|
+
width: "100%"
|
|
1022
|
+
};
|
|
1023
|
+
function DateTimeWidget(props) {
|
|
1024
|
+
const { disabled, formContext, id, onBlur, onChange, onFocus, placeholder, readonly, value } = props;
|
|
1025
|
+
const { readonlyAsDisabled = true } = formContext;
|
|
1026
|
+
const handleChange = (nextValue) => onChange(nextValue && nextValue.toISOString());
|
|
1027
|
+
const handleBlur = () => onBlur(id, value);
|
|
1028
|
+
const handleFocus = () => onFocus(id, value);
|
|
1029
|
+
const getPopupContainer = (node) => node.parentNode;
|
|
1030
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
1031
|
+
DatePicker_default,
|
|
1032
|
+
{
|
|
1033
|
+
disabled: disabled || readonlyAsDisabled && readonly,
|
|
1034
|
+
getPopupContainer,
|
|
1035
|
+
id,
|
|
1036
|
+
name: id,
|
|
1037
|
+
onBlur: !readonly ? handleBlur : void 0,
|
|
1038
|
+
onChange: !readonly ? handleChange : void 0,
|
|
1039
|
+
onFocus: !readonly ? handleFocus : void 0,
|
|
1040
|
+
placeholder,
|
|
1041
|
+
showTime: true,
|
|
1042
|
+
style: DATE_PICKER_STYLE,
|
|
1043
|
+
value: value && (0, import_dayjs2.default)(value),
|
|
1044
|
+
"aria-describedby": (0, import_utils13.ariaDescribedByIds)(id)
|
|
1045
|
+
}
|
|
1046
|
+
);
|
|
1047
|
+
}
|
|
1048
|
+
|
|
1049
|
+
// src/widgets/DateWidget/index.tsx
|
|
1050
|
+
var import_dayjs3 = __toESM(require("dayjs"));
|
|
1051
|
+
var import_utils14 = require("@rjsf/utils");
|
|
1052
|
+
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
1053
|
+
var DATE_PICKER_STYLE2 = {
|
|
1054
|
+
width: "100%"
|
|
1055
|
+
};
|
|
1056
|
+
function DateWidget(props) {
|
|
1057
|
+
const { disabled, formContext, id, onBlur, onChange, onFocus, placeholder, readonly, value } = props;
|
|
1058
|
+
const { readonlyAsDisabled = true } = formContext;
|
|
1059
|
+
const handleChange = (nextValue) => onChange(nextValue && nextValue.format("YYYY-MM-DD"));
|
|
1060
|
+
const handleBlur = () => onBlur(id, value);
|
|
1061
|
+
const handleFocus = () => onFocus(id, value);
|
|
1062
|
+
const getPopupContainer = (node) => node.parentNode;
|
|
1063
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
1064
|
+
DatePicker_default,
|
|
1065
|
+
{
|
|
1066
|
+
disabled: disabled || readonlyAsDisabled && readonly,
|
|
1067
|
+
getPopupContainer,
|
|
1068
|
+
id,
|
|
1069
|
+
name: id,
|
|
1070
|
+
onBlur: !readonly ? handleBlur : void 0,
|
|
1071
|
+
onChange: !readonly ? handleChange : void 0,
|
|
1072
|
+
onFocus: !readonly ? handleFocus : void 0,
|
|
1073
|
+
placeholder,
|
|
1074
|
+
showTime: false,
|
|
1075
|
+
style: DATE_PICKER_STYLE2,
|
|
1076
|
+
value: value && (0, import_dayjs3.default)(value),
|
|
1077
|
+
"aria-describedby": (0, import_utils14.ariaDescribedByIds)(id)
|
|
1078
|
+
}
|
|
1079
|
+
);
|
|
1080
|
+
}
|
|
1081
|
+
|
|
1082
|
+
// src/widgets/PasswordWidget/index.tsx
|
|
1083
|
+
var import_input3 = __toESM(require("antd/lib/input"));
|
|
1084
|
+
var import_utils15 = require("@rjsf/utils");
|
|
1085
|
+
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
1086
|
+
function PasswordWidget(props) {
|
|
1087
|
+
const { disabled, formContext, id, onBlur, onChange, onFocus, options, placeholder, readonly, value } = props;
|
|
1088
|
+
const { readonlyAsDisabled = true } = formContext;
|
|
1089
|
+
const emptyValue = options.emptyValue || "";
|
|
1090
|
+
const handleChange = ({ target }) => onChange(target.value === "" ? emptyValue : target.value);
|
|
1091
|
+
const handleBlur = ({ target }) => onBlur(id, target.value);
|
|
1092
|
+
const handleFocus = ({ target }) => onFocus(id, target.value);
|
|
1093
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
1094
|
+
import_input3.default.Password,
|
|
1095
|
+
{
|
|
1096
|
+
disabled: disabled || readonlyAsDisabled && readonly,
|
|
1097
|
+
id,
|
|
1098
|
+
name: id,
|
|
1099
|
+
onBlur: !readonly ? handleBlur : void 0,
|
|
1100
|
+
onChange: !readonly ? handleChange : void 0,
|
|
1101
|
+
onFocus: !readonly ? handleFocus : void 0,
|
|
1102
|
+
placeholder,
|
|
1103
|
+
value: value || "",
|
|
1104
|
+
"aria-describedby": (0, import_utils15.ariaDescribedByIds)(id)
|
|
1105
|
+
}
|
|
1106
|
+
);
|
|
1107
|
+
}
|
|
1108
|
+
|
|
1109
|
+
// src/widgets/RadioWidget/index.tsx
|
|
1110
|
+
var import_radio = __toESM(require("antd/lib/radio"));
|
|
1111
|
+
var import_utils16 = require("@rjsf/utils");
|
|
1112
|
+
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
1113
|
+
function RadioWidget({
|
|
1114
|
+
autofocus,
|
|
1115
|
+
disabled,
|
|
1116
|
+
formContext,
|
|
1117
|
+
id,
|
|
1118
|
+
onBlur,
|
|
1119
|
+
onChange,
|
|
1120
|
+
onFocus,
|
|
1121
|
+
options,
|
|
1122
|
+
readonly,
|
|
1123
|
+
value
|
|
1124
|
+
}) {
|
|
1125
|
+
const { readonlyAsDisabled = true } = formContext;
|
|
1126
|
+
const { enumOptions, enumDisabled, emptyValue } = options;
|
|
1127
|
+
const handleChange = ({ target: { value: nextValue } }) => onChange((0, import_utils16.enumOptionsValueForIndex)(nextValue, enumOptions, emptyValue));
|
|
1128
|
+
const handleBlur = ({ target }) => onBlur(id, (0, import_utils16.enumOptionsValueForIndex)(target.value, enumOptions, emptyValue));
|
|
1129
|
+
const handleFocus = ({ target }) => onFocus(id, (0, import_utils16.enumOptionsValueForIndex)(target.value, enumOptions, emptyValue));
|
|
1130
|
+
const selectedIndexes = (0, import_utils16.enumOptionsIndexForValue)(value, enumOptions);
|
|
1131
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
1132
|
+
import_radio.default.Group,
|
|
1133
|
+
{
|
|
1134
|
+
disabled: disabled || readonlyAsDisabled && readonly,
|
|
1135
|
+
id,
|
|
1136
|
+
name: id,
|
|
1137
|
+
onChange: !readonly ? handleChange : void 0,
|
|
1138
|
+
onBlur: !readonly ? handleBlur : void 0,
|
|
1139
|
+
onFocus: !readonly ? handleFocus : void 0,
|
|
1140
|
+
value: selectedIndexes,
|
|
1141
|
+
"aria-describedby": (0, import_utils16.ariaDescribedByIds)(id),
|
|
1142
|
+
children: Array.isArray(enumOptions) && enumOptions.map((option, i) => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
1143
|
+
import_radio.default,
|
|
1144
|
+
{
|
|
1145
|
+
id: (0, import_utils16.optionId)(id, i),
|
|
1146
|
+
name: id,
|
|
1147
|
+
autoFocus: i === 0 ? autofocus : false,
|
|
1148
|
+
disabled: Array.isArray(enumDisabled) && enumDisabled.indexOf(value) !== -1,
|
|
1149
|
+
value: String(i),
|
|
1150
|
+
children: option.label
|
|
1151
|
+
},
|
|
1152
|
+
i
|
|
1153
|
+
))
|
|
1154
|
+
}
|
|
1155
|
+
);
|
|
1156
|
+
}
|
|
1157
|
+
|
|
1158
|
+
// src/widgets/RangeWidget/index.tsx
|
|
1159
|
+
var import_slider = __toESM(require("antd/lib/slider"));
|
|
1160
|
+
var import_utils17 = require("@rjsf/utils");
|
|
1161
|
+
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
1162
|
+
function RangeWidget(props) {
|
|
1163
|
+
const {
|
|
1164
|
+
autofocus,
|
|
1165
|
+
disabled,
|
|
1166
|
+
formContext,
|
|
1167
|
+
id,
|
|
1168
|
+
onBlur,
|
|
1169
|
+
onChange,
|
|
1170
|
+
onFocus,
|
|
1171
|
+
options,
|
|
1172
|
+
placeholder,
|
|
1173
|
+
readonly,
|
|
1174
|
+
schema,
|
|
1175
|
+
value
|
|
1176
|
+
} = props;
|
|
1177
|
+
const { readonlyAsDisabled = true } = formContext;
|
|
1178
|
+
const { min, max, step } = (0, import_utils17.rangeSpec)(schema);
|
|
1179
|
+
const emptyValue = options.emptyValue || "";
|
|
1180
|
+
const handleChange = (nextValue) => onChange(nextValue === "" ? emptyValue : nextValue);
|
|
1181
|
+
const handleBlur = () => onBlur(id, value);
|
|
1182
|
+
const handleFocus = () => onFocus(id, value);
|
|
1183
|
+
const extraProps = {
|
|
1184
|
+
placeholder,
|
|
1185
|
+
onBlur: !readonly ? handleBlur : void 0,
|
|
1186
|
+
onFocus: !readonly ? handleFocus : void 0
|
|
1187
|
+
};
|
|
1188
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
1189
|
+
import_slider.default,
|
|
1190
|
+
{
|
|
1191
|
+
autoFocus: autofocus,
|
|
1192
|
+
disabled: disabled || readonlyAsDisabled && readonly,
|
|
1193
|
+
id,
|
|
1194
|
+
max,
|
|
1195
|
+
min,
|
|
1196
|
+
onChange: !readonly ? handleChange : void 0,
|
|
1197
|
+
range: false,
|
|
1198
|
+
step,
|
|
1199
|
+
value,
|
|
1200
|
+
...extraProps,
|
|
1201
|
+
"aria-describedby": (0, import_utils17.ariaDescribedByIds)(id)
|
|
1202
|
+
}
|
|
1203
|
+
);
|
|
1204
|
+
}
|
|
1205
|
+
|
|
1206
|
+
// src/widgets/SelectWidget/index.tsx
|
|
1207
|
+
var import_select = __toESM(require("antd/lib/select"));
|
|
1208
|
+
var import_utils18 = require("@rjsf/utils");
|
|
1209
|
+
var import_isString2 = __toESM(require("lodash/isString"));
|
|
1210
|
+
var import_jsx_runtime22 = require("react/jsx-runtime");
|
|
1211
|
+
var SELECT_STYLE = {
|
|
1212
|
+
width: "100%"
|
|
1213
|
+
};
|
|
1214
|
+
function SelectWidget({
|
|
1215
|
+
autofocus,
|
|
1216
|
+
disabled,
|
|
1217
|
+
formContext = {},
|
|
1218
|
+
id,
|
|
1219
|
+
multiple,
|
|
1220
|
+
onBlur,
|
|
1221
|
+
onChange,
|
|
1222
|
+
onFocus,
|
|
1223
|
+
options,
|
|
1224
|
+
placeholder,
|
|
1225
|
+
readonly,
|
|
1226
|
+
value
|
|
1227
|
+
}) {
|
|
1228
|
+
const { readonlyAsDisabled = true } = formContext;
|
|
1229
|
+
const { enumOptions, enumDisabled, emptyValue } = options;
|
|
1230
|
+
const handleChange = (nextValue) => onChange((0, import_utils18.enumOptionsValueForIndex)(nextValue, enumOptions, emptyValue));
|
|
1231
|
+
const handleBlur = () => onBlur(id, (0, import_utils18.enumOptionsValueForIndex)(value, enumOptions, emptyValue));
|
|
1232
|
+
const handleFocus = () => onFocus(id, (0, import_utils18.enumOptionsValueForIndex)(value, enumOptions, emptyValue));
|
|
1233
|
+
const filterOption = (input, option) => {
|
|
1234
|
+
if (option && (0, import_isString2.default)(option.label)) {
|
|
1235
|
+
return option.label.toLowerCase().indexOf(input.toLowerCase()) >= 0;
|
|
1236
|
+
}
|
|
1237
|
+
return false;
|
|
1238
|
+
};
|
|
1239
|
+
const getPopupContainer = (node) => node.parentNode;
|
|
1240
|
+
const selectedIndexes = (0, import_utils18.enumOptionsIndexForValue)(value, enumOptions, multiple);
|
|
1241
|
+
const extraProps = {
|
|
1242
|
+
name: id
|
|
1243
|
+
};
|
|
1244
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
1245
|
+
import_select.default,
|
|
1246
|
+
{
|
|
1247
|
+
autoFocus: autofocus,
|
|
1248
|
+
disabled: disabled || readonlyAsDisabled && readonly,
|
|
1249
|
+
getPopupContainer,
|
|
1250
|
+
id,
|
|
1251
|
+
mode: multiple ? "multiple" : void 0,
|
|
1252
|
+
onBlur: !readonly ? handleBlur : void 0,
|
|
1253
|
+
onChange: !readonly ? handleChange : void 0,
|
|
1254
|
+
onFocus: !readonly ? handleFocus : void 0,
|
|
1255
|
+
placeholder,
|
|
1256
|
+
style: SELECT_STYLE,
|
|
1257
|
+
value: selectedIndexes,
|
|
1258
|
+
...extraProps,
|
|
1259
|
+
filterOption,
|
|
1260
|
+
"aria-describedby": (0, import_utils18.ariaDescribedByIds)(id),
|
|
1261
|
+
children: Array.isArray(enumOptions) && enumOptions.map(({ value: optionValue, label: optionLabel }, index) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
1262
|
+
import_select.default.Option,
|
|
1263
|
+
{
|
|
1264
|
+
disabled: Array.isArray(enumDisabled) && enumDisabled.indexOf(optionValue) !== -1,
|
|
1265
|
+
value: String(index),
|
|
1266
|
+
children: optionLabel
|
|
1267
|
+
},
|
|
1268
|
+
String(index)
|
|
1269
|
+
))
|
|
1270
|
+
}
|
|
1271
|
+
);
|
|
1272
|
+
}
|
|
1273
|
+
|
|
1274
|
+
// src/widgets/TextareaWidget/index.tsx
|
|
1275
|
+
var import_input4 = __toESM(require("antd/lib/input"));
|
|
1276
|
+
var import_utils19 = require("@rjsf/utils");
|
|
1277
|
+
var import_jsx_runtime23 = require("react/jsx-runtime");
|
|
1278
|
+
var INPUT_STYLE3 = {
|
|
1279
|
+
width: "100%"
|
|
1280
|
+
};
|
|
1281
|
+
function TextareaWidget({
|
|
1282
|
+
disabled,
|
|
1283
|
+
formContext,
|
|
1284
|
+
id,
|
|
1285
|
+
onBlur,
|
|
1286
|
+
onChange,
|
|
1287
|
+
onFocus,
|
|
1288
|
+
options,
|
|
1289
|
+
placeholder,
|
|
1290
|
+
readonly,
|
|
1291
|
+
value
|
|
1292
|
+
}) {
|
|
1293
|
+
const { readonlyAsDisabled = true } = formContext;
|
|
1294
|
+
const handleChange = ({ target }) => onChange(target.value === "" ? options.emptyValue : target.value);
|
|
1295
|
+
const handleBlur = ({ target }) => onBlur(id, target.value);
|
|
1296
|
+
const handleFocus = ({ target }) => onFocus(id, target.value);
|
|
1297
|
+
const extraProps = {
|
|
1298
|
+
type: "textarea"
|
|
1299
|
+
};
|
|
1300
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
1301
|
+
import_input4.default.TextArea,
|
|
1302
|
+
{
|
|
1303
|
+
disabled: disabled || readonlyAsDisabled && readonly,
|
|
1304
|
+
id,
|
|
1305
|
+
name: id,
|
|
1306
|
+
onBlur: !readonly ? handleBlur : void 0,
|
|
1307
|
+
onChange: !readonly ? handleChange : void 0,
|
|
1308
|
+
onFocus: !readonly ? handleFocus : void 0,
|
|
1309
|
+
placeholder,
|
|
1310
|
+
rows: options.rows || 4,
|
|
1311
|
+
style: INPUT_STYLE3,
|
|
1312
|
+
value,
|
|
1313
|
+
...extraProps,
|
|
1314
|
+
"aria-describedby": (0, import_utils19.ariaDescribedByIds)(id)
|
|
1315
|
+
}
|
|
1316
|
+
);
|
|
1317
|
+
}
|
|
1318
|
+
|
|
1319
|
+
// src/widgets/index.ts
|
|
1320
|
+
function generateWidgets() {
|
|
1321
|
+
return {
|
|
1322
|
+
AltDateTimeWidget,
|
|
1323
|
+
AltDateWidget,
|
|
1324
|
+
CheckboxesWidget,
|
|
1325
|
+
CheckboxWidget,
|
|
1326
|
+
DateTimeWidget,
|
|
1327
|
+
DateWidget,
|
|
1328
|
+
PasswordWidget,
|
|
1329
|
+
RadioWidget,
|
|
1330
|
+
RangeWidget,
|
|
1331
|
+
SelectWidget,
|
|
1332
|
+
TextareaWidget
|
|
1333
|
+
};
|
|
1334
|
+
}
|
|
1335
|
+
var widgets_default = generateWidgets();
|
|
1336
|
+
|
|
1337
|
+
// src/index.ts
|
|
1338
|
+
function generateTheme() {
|
|
1339
|
+
return {
|
|
1340
|
+
templates: generateTemplates(),
|
|
1341
|
+
widgets: generateWidgets()
|
|
1342
|
+
};
|
|
1343
|
+
}
|
|
1344
|
+
var Theme = generateTheme();
|
|
1345
|
+
function generateForm() {
|
|
1346
|
+
return (0, import_core.withTheme)(generateTheme());
|
|
1347
|
+
}
|
|
1348
|
+
var Form3 = generateForm();
|
|
1349
|
+
var src_default = Form3;
|
|
1350
|
+
//# sourceMappingURL=index.js.map
|