@rjsf/semantic-ui 5.11.2 → 5.12.0
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/index.js +1128 -5
- package/dist/index.js.map +7 -0
- package/dist/semantic-ui.esm.js +641 -809
- package/dist/semantic-ui.esm.js.map +7 -1
- package/dist/semantic-ui.umd.js +997 -0
- package/lib/AddButton/AddButton.d.ts +5 -0
- package/lib/AddButton/AddButton.js +12 -0
- package/lib/AddButton/AddButton.js.map +1 -0
- package/lib/AddButton/index.d.ts +2 -0
- package/lib/AddButton/index.js +3 -0
- package/lib/AddButton/index.js.map +1 -0
- package/lib/ArrayFieldItemTemplate/ArrayFieldItemTemplate.d.ts +7 -0
- package/lib/ArrayFieldItemTemplate/ArrayFieldItemTemplate.js +21 -0
- package/lib/ArrayFieldItemTemplate/ArrayFieldItemTemplate.js.map +1 -0
- package/lib/ArrayFieldItemTemplate/index.d.ts +2 -0
- package/lib/ArrayFieldItemTemplate/index.js +3 -0
- package/lib/ArrayFieldItemTemplate/index.js.map +1 -0
- package/lib/ArrayFieldTemplate/ArrayFieldTemplate.d.ts +7 -0
- package/lib/ArrayFieldTemplate/ArrayFieldTemplate.js +40 -0
- package/lib/ArrayFieldTemplate/ArrayFieldTemplate.js.map +1 -0
- package/lib/ArrayFieldTemplate/index.d.ts +2 -0
- package/lib/ArrayFieldTemplate/index.js +3 -0
- package/lib/ArrayFieldTemplate/index.js.map +1 -0
- package/lib/BaseInputTemplate/BaseInputTemplate.d.ts +9 -0
- package/lib/BaseInputTemplate/BaseInputTemplate.js +28 -0
- package/lib/BaseInputTemplate/BaseInputTemplate.js.map +1 -0
- package/lib/BaseInputTemplate/index.d.ts +2 -0
- package/lib/BaseInputTemplate/index.js +3 -0
- package/lib/BaseInputTemplate/index.js.map +1 -0
- package/lib/CheckboxWidget/CheckboxWidget.d.ts +8 -0
- package/lib/CheckboxWidget/CheckboxWidget.js +33 -0
- package/lib/CheckboxWidget/CheckboxWidget.js.map +1 -0
- package/lib/CheckboxWidget/index.d.ts +2 -0
- package/lib/CheckboxWidget/index.js +3 -0
- package/lib/CheckboxWidget/index.js.map +1 -0
- package/lib/CheckboxesWidget/CheckboxesWidget.d.ts +8 -0
- package/lib/CheckboxesWidget/CheckboxesWidget.js +42 -0
- package/lib/CheckboxesWidget/CheckboxesWidget.js.map +1 -0
- package/lib/CheckboxesWidget/index.d.ts +2 -0
- package/lib/CheckboxesWidget/index.js +3 -0
- package/lib/CheckboxesWidget/index.js.map +1 -0
- package/lib/DescriptionField/DescriptionField.d.ts +7 -0
- package/lib/DescriptionField/DescriptionField.js +13 -0
- package/lib/DescriptionField/DescriptionField.js.map +1 -0
- package/lib/DescriptionField/index.d.ts +2 -0
- package/lib/DescriptionField/index.js +3 -0
- package/lib/DescriptionField/index.js.map +1 -0
- package/lib/ErrorList/ErrorList.d.ts +7 -0
- package/lib/ErrorList/ErrorList.js +12 -0
- package/lib/ErrorList/ErrorList.js.map +1 -0
- package/lib/ErrorList/index.d.ts +2 -0
- package/lib/ErrorList/index.js +3 -0
- package/lib/ErrorList/index.js.map +1 -0
- package/lib/FieldErrorTemplate/FieldErrorTemplate.d.ts +7 -0
- package/lib/FieldErrorTemplate/FieldErrorTemplate.js +30 -0
- package/lib/FieldErrorTemplate/FieldErrorTemplate.js.map +1 -0
- package/lib/FieldErrorTemplate/index.d.ts +2 -0
- package/lib/FieldErrorTemplate/index.js +3 -0
- package/lib/FieldErrorTemplate/index.js.map +1 -0
- package/lib/FieldHelpTemplate/FieldHelpTemplate.d.ts +7 -0
- package/lib/FieldHelpTemplate/FieldHelpTemplate.js +16 -0
- package/lib/FieldHelpTemplate/FieldHelpTemplate.js.map +1 -0
- package/lib/FieldHelpTemplate/index.d.ts +2 -0
- package/lib/FieldHelpTemplate/index.js +3 -0
- package/lib/FieldHelpTemplate/index.js.map +1 -0
- package/lib/FieldTemplate/FieldTemplate.d.ts +8 -0
- package/lib/FieldTemplate/FieldTemplate.js +22 -0
- package/lib/FieldTemplate/FieldTemplate.js.map +1 -0
- package/lib/FieldTemplate/index.d.ts +2 -0
- package/lib/FieldTemplate/index.js +3 -0
- package/lib/FieldTemplate/index.js.map +1 -0
- package/lib/IconButton/IconButton.d.ts +8 -0
- package/lib/IconButton/IconButton.js +26 -0
- package/lib/IconButton/IconButton.js.map +1 -0
- package/lib/IconButton/index.d.ts +2 -0
- package/lib/IconButton/index.js +3 -0
- package/lib/IconButton/index.js.map +1 -0
- package/lib/ObjectFieldTemplate/ObjectFieldTemplate.d.ts +9 -0
- package/lib/ObjectFieldTemplate/ObjectFieldTemplate.js +23 -0
- package/lib/ObjectFieldTemplate/ObjectFieldTemplate.js.map +1 -0
- package/lib/ObjectFieldTemplate/index.d.ts +2 -0
- package/lib/ObjectFieldTemplate/index.js +3 -0
- package/lib/ObjectFieldTemplate/index.js.map +1 -0
- package/lib/RadioWidget/RadioWidget.d.ts +8 -0
- package/lib/RadioWidget/RadioWidget.js +32 -0
- package/lib/RadioWidget/RadioWidget.js.map +1 -0
- package/lib/RadioWidget/index.d.ts +2 -0
- package/lib/RadioWidget/index.js +3 -0
- package/lib/RadioWidget/index.js.map +1 -0
- package/lib/RangeWidget/RangeWidget.d.ts +8 -0
- package/lib/RangeWidget/RangeWidget.js +26 -0
- package/lib/RangeWidget/RangeWidget.js.map +1 -0
- package/lib/RangeWidget/index.d.ts +2 -0
- package/lib/RangeWidget/index.js +3 -0
- package/lib/RangeWidget/index.js.map +1 -0
- package/lib/SelectWidget/SelectWidget.d.ts +8 -0
- package/lib/SelectWidget/SelectWidget.js +51 -0
- package/lib/SelectWidget/SelectWidget.js.map +1 -0
- package/lib/SelectWidget/index.d.ts +2 -0
- package/lib/SelectWidget/index.js +3 -0
- package/lib/SelectWidget/index.js.map +1 -0
- package/lib/SemanticUIForm/SemanticUIForm.d.ts +6 -0
- package/lib/SemanticUIForm/SemanticUIForm.js +7 -0
- package/lib/SemanticUIForm/SemanticUIForm.js.map +1 -0
- package/lib/SemanticUIForm/index.d.ts +2 -0
- package/lib/SemanticUIForm/index.js +3 -0
- package/lib/SemanticUIForm/index.js.map +1 -0
- package/lib/SubmitButton/SubmitButton.d.ts +5 -0
- package/lib/SubmitButton/SubmitButton.js +13 -0
- package/lib/SubmitButton/SubmitButton.js.map +1 -0
- package/lib/SubmitButton/index.d.ts +2 -0
- package/lib/SubmitButton/index.js +3 -0
- package/lib/SubmitButton/index.js.map +1 -0
- package/lib/Templates/Templates.d.ts +4 -0
- package/lib/Templates/Templates.js +39 -0
- package/lib/Templates/Templates.js.map +1 -0
- package/lib/Templates/index.d.ts +2 -0
- package/lib/Templates/index.js +3 -0
- package/lib/Templates/index.js.map +1 -0
- package/lib/TextareaWidget/TextareaWidget.d.ts +7 -0
- package/lib/TextareaWidget/TextareaWidget.js +22 -0
- package/lib/TextareaWidget/TextareaWidget.js.map +1 -0
- package/lib/TextareaWidget/index.d.ts +2 -0
- package/lib/TextareaWidget/index.js +3 -0
- package/lib/TextareaWidget/index.js.map +1 -0
- package/lib/Theme/Theme.d.ts +5 -0
- package/lib/Theme/Theme.js +12 -0
- package/lib/Theme/Theme.js.map +1 -0
- package/lib/Theme/index.d.ts +2 -0
- package/lib/Theme/index.js +3 -0
- package/lib/Theme/index.js.map +1 -0
- package/lib/TitleField/TitleField.d.ts +7 -0
- package/lib/TitleField/TitleField.js +22 -0
- package/lib/TitleField/TitleField.js.map +1 -0
- package/lib/TitleField/index.d.ts +2 -0
- package/lib/TitleField/index.js +3 -0
- package/lib/TitleField/index.js.map +1 -0
- package/lib/Widgets/Widgets.d.ts +4 -0
- package/lib/Widgets/Widgets.js +18 -0
- package/lib/Widgets/Widgets.js.map +1 -0
- package/lib/Widgets/index.d.ts +2 -0
- package/lib/Widgets/index.js +3 -0
- package/lib/Widgets/index.js.map +1 -0
- package/lib/WrapIfAdditionalTemplate/WrapIfAdditionalTemplate.d.ts +8 -0
- package/lib/WrapIfAdditionalTemplate/WrapIfAdditionalTemplate.js +23 -0
- package/lib/WrapIfAdditionalTemplate/WrapIfAdditionalTemplate.js.map +1 -0
- package/lib/WrapIfAdditionalTemplate/index.d.ts +2 -0
- package/lib/WrapIfAdditionalTemplate/index.js +3 -0
- package/lib/WrapIfAdditionalTemplate/index.js.map +1 -0
- package/lib/index.d.ts +6 -0
- package/lib/index.js +7 -0
- package/lib/index.js.map +1 -0
- package/lib/util.d.ts +60 -0
- package/lib/util.js +69 -0
- package/lib/util.js.map +1 -0
- package/package.json +23 -15
- package/src/AddButton/AddButton.tsx +24 -0
- package/src/AddButton/index.ts +2 -0
- package/src/ArrayFieldItemTemplate/ArrayFieldItemTemplate.tsx +102 -0
- package/src/ArrayFieldItemTemplate/index.ts +2 -0
- package/src/ArrayFieldTemplate/ArrayFieldTemplate.tsx +114 -0
- package/src/ArrayFieldTemplate/index.ts +2 -0
- package/src/BaseInputTemplate/BaseInputTemplate.tsx +90 -0
- package/src/BaseInputTemplate/index.ts +2 -0
- package/src/CheckboxWidget/CheckboxWidget.tsx +95 -0
- package/src/CheckboxWidget/index.ts +2 -0
- package/src/CheckboxesWidget/CheckboxesWidget.tsx +102 -0
- package/src/CheckboxesWidget/index.ts +2 -0
- package/src/DescriptionField/DescriptionField.tsx +21 -0
- package/src/DescriptionField/index.ts +2 -0
- package/src/ErrorList/ErrorList.tsx +23 -0
- package/src/ErrorList/index.ts +2 -0
- package/src/FieldErrorTemplate/FieldErrorTemplate.tsx +43 -0
- package/src/FieldErrorTemplate/index.ts +2 -0
- package/src/FieldHelpTemplate/FieldHelpTemplate.tsx +19 -0
- package/src/FieldHelpTemplate/index.ts +2 -0
- package/src/FieldTemplate/FieldTemplate.tsx +77 -0
- package/src/FieldTemplate/index.ts +2 -0
- package/src/IconButton/IconButton.tsx +55 -0
- package/src/IconButton/index.ts +2 -0
- package/src/ObjectFieldTemplate/ObjectFieldTemplate.tsx +94 -0
- package/src/ObjectFieldTemplate/index.ts +2 -0
- package/src/RadioWidget/RadioWidget.tsx +78 -0
- package/src/RadioWidget/index.ts +2 -0
- package/src/RangeWidget/RangeWidget.tsx +65 -0
- package/src/RangeWidget/index.ts +2 -0
- package/src/SelectWidget/SelectWidget.tsx +111 -0
- package/src/SelectWidget/index.ts +2 -0
- package/src/SemanticUIForm/SemanticUIForm.ts +15 -0
- package/src/SemanticUIForm/index.ts +2 -0
- package/src/SubmitButton/SubmitButton.tsx +20 -0
- package/src/SubmitButton/index.ts +2 -0
- package/src/Templates/Templates.ts +46 -0
- package/src/Templates/index.ts +2 -0
- package/src/TextareaWidget/TextareaWidget.tsx +69 -0
- package/src/TextareaWidget/index.ts +2 -0
- package/src/Theme/Theme.ts +20 -0
- package/src/Theme/index.ts +2 -0
- package/src/TitleField/TitleField.tsx +32 -0
- package/src/TitleField/index.ts +2 -0
- package/src/Widgets/Widgets.tsx +25 -0
- package/src/Widgets/index.ts +2 -0
- package/src/WrapIfAdditionalTemplate/WrapIfAdditionalTemplate.tsx +95 -0
- package/src/WrapIfAdditionalTemplate/index.ts +2 -0
- package/src/index.ts +8 -0
- package/src/util.tsx +126 -0
- package/dist/index.d.ts +0 -17
- package/dist/semantic-ui.cjs.development.js +0 -1335
- package/dist/semantic-ui.cjs.development.js.map +0 -1
- package/dist/semantic-ui.cjs.production.min.js +0 -2
- package/dist/semantic-ui.cjs.production.min.js.map +0 -1
- package/dist/semantic-ui.umd.development.js +0 -1333
- package/dist/semantic-ui.umd.development.js.map +0 -1
- package/dist/semantic-ui.umd.production.min.js +0 -2
- package/dist/semantic-ui.umd.production.min.js.map +0 -1
|
@@ -1,1335 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var core = require('@rjsf/core');
|
|
6
|
-
var semanticUiReact = require('semantic-ui-react');
|
|
7
|
-
var jsxRuntime = require('react/jsx-runtime');
|
|
8
|
-
var utils = require('@rjsf/utils');
|
|
9
|
-
var nanoid = require('nanoid');
|
|
10
|
-
var react = require('react');
|
|
11
|
-
var map = require('lodash/map');
|
|
12
|
-
|
|
13
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
14
|
-
|
|
15
|
-
var map__default = /*#__PURE__*/_interopDefaultLegacy(map);
|
|
16
|
-
|
|
17
|
-
/** The `AddButton` renders a button that represent the `Add` action on a form
|
|
18
|
-
*/
|
|
19
|
-
function AddButton({
|
|
20
|
-
uiSchema,
|
|
21
|
-
registry,
|
|
22
|
-
color,
|
|
23
|
-
...props
|
|
24
|
-
}) {
|
|
25
|
-
const {
|
|
26
|
-
translateString
|
|
27
|
-
} = registry;
|
|
28
|
-
return jsxRuntime.jsx(semanticUiReact.Button, {
|
|
29
|
-
title: translateString(utils.TranslatableString.AddItemButton),
|
|
30
|
-
color: color,
|
|
31
|
-
...props,
|
|
32
|
-
icon: true,
|
|
33
|
-
size: 'tiny',
|
|
34
|
-
children: jsxRuntime.jsx(semanticUiReact.Icon, {
|
|
35
|
-
name: 'plus'
|
|
36
|
-
})
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Extract props meant for semantic UI components from props that are
|
|
42
|
-
* passed to Widgets, Templates and Fields.
|
|
43
|
-
* @param {Object} params
|
|
44
|
-
* @param {Object?} params.formContext
|
|
45
|
-
* @param {Object?} params.uiSchema
|
|
46
|
-
* @param {Object?} params.options
|
|
47
|
-
* @param {Object?} params.defaultSchemaProps
|
|
48
|
-
* @param {Object?} params.defaultContextProps
|
|
49
|
-
* @returns {any}
|
|
50
|
-
*/
|
|
51
|
-
function getSemanticProps({
|
|
52
|
-
formContext = {},
|
|
53
|
-
uiSchema = {},
|
|
54
|
-
options = {},
|
|
55
|
-
defaultSchemaProps = {
|
|
56
|
-
fluid: true,
|
|
57
|
-
inverted: false
|
|
58
|
-
},
|
|
59
|
-
defaultContextProps = {}
|
|
60
|
-
}) {
|
|
61
|
-
const formContextProps = formContext.semantic;
|
|
62
|
-
const schemaProps = utils.getUiOptions(uiSchema).semantic;
|
|
63
|
-
const optionProps = options.semantic;
|
|
64
|
-
// formContext props should overide other props
|
|
65
|
-
return Object.assign({}, {
|
|
66
|
-
...defaultSchemaProps
|
|
67
|
-
}, {
|
|
68
|
-
...defaultContextProps
|
|
69
|
-
}, schemaProps, optionProps, formContextProps);
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Extract error props meant for semantic UI components from props that are
|
|
73
|
-
* passed to Widgets, Templates and Fields.
|
|
74
|
-
* @param {Object} params
|
|
75
|
-
* @param {Object?} params.formContext
|
|
76
|
-
* @param {Object?} params.uiSchema
|
|
77
|
-
* @param {Object?} params.defaultProps
|
|
78
|
-
* @returns {any}
|
|
79
|
-
*/
|
|
80
|
-
function getSemanticErrorProps({
|
|
81
|
-
formContext = {},
|
|
82
|
-
uiSchema = {},
|
|
83
|
-
options = {},
|
|
84
|
-
defaultProps = {
|
|
85
|
-
size: 'small',
|
|
86
|
-
pointing: 'above'
|
|
87
|
-
}
|
|
88
|
-
}) {
|
|
89
|
-
const formContextProps = formContext.semantic && formContext.semantic.errorOptions;
|
|
90
|
-
const semanticOptions = utils.getUiOptions(uiSchema).semantic;
|
|
91
|
-
const schemaProps = semanticOptions && semanticOptions.errorOptions;
|
|
92
|
-
const optionProps = options.semantic && options.semantic.errorOptions;
|
|
93
|
-
return Object.assign({}, {
|
|
94
|
-
...defaultProps
|
|
95
|
-
}, schemaProps, optionProps, formContextProps);
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* Combine multiple strings containing class names into a single string,
|
|
99
|
-
* removing duplicates. E.g.
|
|
100
|
-
* cleanClassNames('bar', 'baz bar', 'x y ', undefined)
|
|
101
|
-
* // 'bar baz x y'
|
|
102
|
-
* @param {Array} classNameArr
|
|
103
|
-
* @param {Array} omit
|
|
104
|
-
* @returns {string}
|
|
105
|
-
*/
|
|
106
|
-
function cleanClassNames(classNameArr, omit = []) {
|
|
107
|
-
// Split each arg on whitespace, and add it to an array. Skip false-y args
|
|
108
|
-
// like "" and undefined.
|
|
109
|
-
const classList = classNameArr.filter(Boolean).reduce((previous, current) => previous.concat(current.trim().split(/\s+/)), []);
|
|
110
|
-
// Remove any class names from omit, and make the rest unique before
|
|
111
|
-
// returning them as a string
|
|
112
|
-
return [...new Set(classList.filter(cn => !omit.includes(cn)))].join(' ');
|
|
113
|
-
}
|
|
114
|
-
/**
|
|
115
|
-
*
|
|
116
|
-
* @param {boolean} wrap
|
|
117
|
-
* @param Component
|
|
118
|
-
* @param {Object} props
|
|
119
|
-
* @returns {*}
|
|
120
|
-
* @constructor
|
|
121
|
-
*/
|
|
122
|
-
function MaybeWrap({
|
|
123
|
-
wrap,
|
|
124
|
-
component: Component = 'div',
|
|
125
|
-
...props
|
|
126
|
-
}) {
|
|
127
|
-
return wrap ? jsxRuntime.jsx(Component, {
|
|
128
|
-
...props
|
|
129
|
-
}) : props.children;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
const gridStyle = vertical => ({
|
|
133
|
-
display: 'grid',
|
|
134
|
-
gridTemplateColumns: `1fr ${vertical ? 65 : 150}px`
|
|
135
|
-
});
|
|
136
|
-
/** The `ArrayFieldItemTemplate` component is the template used to render an items of an array.
|
|
137
|
-
*
|
|
138
|
-
* @param props - The `ArrayFieldTemplateItemType` props for the component
|
|
139
|
-
*/
|
|
140
|
-
function ArrayFieldItemTemplate(props) {
|
|
141
|
-
const {
|
|
142
|
-
children,
|
|
143
|
-
disabled,
|
|
144
|
-
hasToolbar,
|
|
145
|
-
hasCopy,
|
|
146
|
-
hasMoveDown,
|
|
147
|
-
hasMoveUp,
|
|
148
|
-
hasRemove,
|
|
149
|
-
index,
|
|
150
|
-
onCopyIndexClick,
|
|
151
|
-
onDropIndexClick,
|
|
152
|
-
onReorderClick,
|
|
153
|
-
readonly,
|
|
154
|
-
uiSchema,
|
|
155
|
-
registry
|
|
156
|
-
} = props;
|
|
157
|
-
const {
|
|
158
|
-
CopyButton,
|
|
159
|
-
MoveDownButton,
|
|
160
|
-
MoveUpButton,
|
|
161
|
-
RemoveButton
|
|
162
|
-
} = registry.templates.ButtonTemplates;
|
|
163
|
-
const uiOptions = utils.getUiOptions(uiSchema);
|
|
164
|
-
// Pull the semantic props out of the uiOptions that were put in via the ArrayFieldTemplate
|
|
165
|
-
const {
|
|
166
|
-
horizontalButtons = true,
|
|
167
|
-
wrapItem = false
|
|
168
|
-
} = uiOptions.semantic;
|
|
169
|
-
return jsxRuntime.jsx("div", {
|
|
170
|
-
className: 'array-item',
|
|
171
|
-
children: jsxRuntime.jsx(MaybeWrap, {
|
|
172
|
-
wrap: wrapItem,
|
|
173
|
-
component: semanticUiReact.Segment,
|
|
174
|
-
children: jsxRuntime.jsxs(semanticUiReact.Grid, {
|
|
175
|
-
style: {
|
|
176
|
-
...gridStyle(!horizontalButtons),
|
|
177
|
-
alignItems: 'center'
|
|
178
|
-
},
|
|
179
|
-
children: [jsxRuntime.jsx(semanticUiReact.Grid.Column, {
|
|
180
|
-
width: 16,
|
|
181
|
-
verticalAlign: 'middle',
|
|
182
|
-
children: children
|
|
183
|
-
}), hasToolbar && jsxRuntime.jsx(semanticUiReact.Grid.Column, {
|
|
184
|
-
children: (hasMoveUp || hasMoveDown || hasRemove) && jsxRuntime.jsxs(semanticUiReact.Button.Group, {
|
|
185
|
-
size: 'mini',
|
|
186
|
-
vertical: !horizontalButtons,
|
|
187
|
-
children: [(hasMoveUp || hasMoveDown) && jsxRuntime.jsx(MoveUpButton, {
|
|
188
|
-
className: 'array-item-move-up',
|
|
189
|
-
disabled: disabled || readonly || !hasMoveUp,
|
|
190
|
-
onClick: onReorderClick(index, index - 1),
|
|
191
|
-
uiSchema: uiSchema,
|
|
192
|
-
registry: registry
|
|
193
|
-
}), (hasMoveUp || hasMoveDown) && jsxRuntime.jsx(MoveDownButton, {
|
|
194
|
-
className: 'array-item-move-down',
|
|
195
|
-
disabled: disabled || readonly || !hasMoveDown,
|
|
196
|
-
onClick: onReorderClick(index, index + 1),
|
|
197
|
-
uiSchema: uiSchema,
|
|
198
|
-
registry: registry
|
|
199
|
-
}), hasCopy && jsxRuntime.jsx(CopyButton, {
|
|
200
|
-
className: 'array-item-copy',
|
|
201
|
-
disabled: disabled || readonly,
|
|
202
|
-
onClick: onCopyIndexClick(index),
|
|
203
|
-
uiSchema: uiSchema,
|
|
204
|
-
registry: registry
|
|
205
|
-
}), hasRemove && jsxRuntime.jsx(RemoveButton, {
|
|
206
|
-
className: 'array-item-remove',
|
|
207
|
-
disabled: disabled || readonly,
|
|
208
|
-
onClick: onDropIndexClick(index),
|
|
209
|
-
uiSchema: uiSchema,
|
|
210
|
-
registry: registry
|
|
211
|
-
})]
|
|
212
|
-
})
|
|
213
|
-
})]
|
|
214
|
-
})
|
|
215
|
-
})
|
|
216
|
-
});
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
/** The `ArrayFieldTemplate` component is the template used to render all items in an array.
|
|
220
|
-
*
|
|
221
|
-
* @param props - The `ArrayFieldTemplateItemType` props for the component
|
|
222
|
-
*/
|
|
223
|
-
function ArrayFieldTemplate(props) {
|
|
224
|
-
const {
|
|
225
|
-
uiSchema,
|
|
226
|
-
idSchema,
|
|
227
|
-
canAdd,
|
|
228
|
-
className,
|
|
229
|
-
// classNames, This is not part of the type, so it is likely never passed in
|
|
230
|
-
disabled,
|
|
231
|
-
formContext,
|
|
232
|
-
items,
|
|
233
|
-
onAddClick,
|
|
234
|
-
// options, This is not part of the type, so it is likely never passed in
|
|
235
|
-
readonly,
|
|
236
|
-
required,
|
|
237
|
-
schema,
|
|
238
|
-
title,
|
|
239
|
-
registry
|
|
240
|
-
} = props;
|
|
241
|
-
const semanticProps = getSemanticProps({
|
|
242
|
-
uiSchema,
|
|
243
|
-
formContext,
|
|
244
|
-
defaultSchemaProps: {
|
|
245
|
-
horizontalButtons: true,
|
|
246
|
-
wrapItem: false
|
|
247
|
-
}
|
|
248
|
-
});
|
|
249
|
-
const {
|
|
250
|
-
horizontalButtons,
|
|
251
|
-
wrapItem
|
|
252
|
-
} = semanticProps;
|
|
253
|
-
const semantic = {
|
|
254
|
-
horizontalButtons,
|
|
255
|
-
wrapItem
|
|
256
|
-
};
|
|
257
|
-
const uiOptions = utils.getUiOptions(uiSchema);
|
|
258
|
-
const ArrayFieldDescriptionTemplate = utils.getTemplate('ArrayFieldDescriptionTemplate', registry, uiOptions);
|
|
259
|
-
const ArrayFieldItemTemplate = utils.getTemplate('ArrayFieldItemTemplate', registry, uiOptions);
|
|
260
|
-
const ArrayFieldTitleTemplate = utils.getTemplate('ArrayFieldTitleTemplate', registry, uiOptions);
|
|
261
|
-
// Button templates are not overridden in the uiSchema
|
|
262
|
-
const {
|
|
263
|
-
ButtonTemplates: {
|
|
264
|
-
AddButton
|
|
265
|
-
}
|
|
266
|
-
} = registry.templates;
|
|
267
|
-
return jsxRuntime.jsxs("div", {
|
|
268
|
-
className: cleanClassNames([className, utils.isFixedItems(schema) ? '' : 'sortable-form-fields']),
|
|
269
|
-
children: [jsxRuntime.jsx(ArrayFieldTitleTemplate, {
|
|
270
|
-
idSchema: idSchema,
|
|
271
|
-
title: uiOptions.title || title,
|
|
272
|
-
schema: schema,
|
|
273
|
-
uiSchema: uiSchema,
|
|
274
|
-
required: required,
|
|
275
|
-
registry: registry
|
|
276
|
-
}), jsxRuntime.jsx(ArrayFieldDescriptionTemplate, {
|
|
277
|
-
idSchema: idSchema,
|
|
278
|
-
description: uiOptions.description || schema.description,
|
|
279
|
-
schema: schema,
|
|
280
|
-
uiSchema: uiSchema,
|
|
281
|
-
registry: registry
|
|
282
|
-
}), jsxRuntime.jsxs("div", {
|
|
283
|
-
children: [jsxRuntime.jsx("div", {
|
|
284
|
-
className: 'row array-item-list',
|
|
285
|
-
children: items && items.map(({
|
|
286
|
-
key,
|
|
287
|
-
uiSchema: itemUiSchema = {},
|
|
288
|
-
...props
|
|
289
|
-
}) => {
|
|
290
|
-
// Merge in the semantic props from the ArrayFieldTemplate into each of the items
|
|
291
|
-
const mergedUiSchema = {
|
|
292
|
-
...itemUiSchema,
|
|
293
|
-
[utils.UI_OPTIONS_KEY]: {
|
|
294
|
-
...itemUiSchema[utils.UI_OPTIONS_KEY],
|
|
295
|
-
semantic
|
|
296
|
-
}
|
|
297
|
-
};
|
|
298
|
-
return jsxRuntime.jsx(ArrayFieldItemTemplate, {
|
|
299
|
-
...props,
|
|
300
|
-
uiSchema: mergedUiSchema
|
|
301
|
-
}, key);
|
|
302
|
-
})
|
|
303
|
-
}), canAdd && jsxRuntime.jsx("div", {
|
|
304
|
-
style: {
|
|
305
|
-
marginTop: '1rem',
|
|
306
|
-
position: 'relative',
|
|
307
|
-
textAlign: 'right'
|
|
308
|
-
},
|
|
309
|
-
children: jsxRuntime.jsx(AddButton, {
|
|
310
|
-
onClick: onAddClick,
|
|
311
|
-
disabled: disabled || readonly,
|
|
312
|
-
uiSchema: uiSchema,
|
|
313
|
-
registry: registry
|
|
314
|
-
})
|
|
315
|
-
})]
|
|
316
|
-
}, `array-item-list-${idSchema.$id}`)]
|
|
317
|
-
});
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
/** The `BaseInputTemplate` is the template to use to render the basic `<input>` component for the `core` theme.
|
|
321
|
-
* It is used as the template for rendering many of the <input> based widgets that differ by `type` and callbacks only.
|
|
322
|
-
* It can be customized/overridden for other themes or individual implementations as needed.
|
|
323
|
-
*
|
|
324
|
-
* @param props - The `WidgetProps` for this template
|
|
325
|
-
*/
|
|
326
|
-
function BaseInputTemplate(props) {
|
|
327
|
-
const {
|
|
328
|
-
id,
|
|
329
|
-
placeholder,
|
|
330
|
-
label,
|
|
331
|
-
hideLabel,
|
|
332
|
-
value,
|
|
333
|
-
required,
|
|
334
|
-
readonly,
|
|
335
|
-
disabled,
|
|
336
|
-
onChange,
|
|
337
|
-
onChangeOverride,
|
|
338
|
-
onBlur,
|
|
339
|
-
onFocus,
|
|
340
|
-
autofocus,
|
|
341
|
-
options,
|
|
342
|
-
schema,
|
|
343
|
-
uiSchema,
|
|
344
|
-
formContext,
|
|
345
|
-
type,
|
|
346
|
-
rawErrors = []
|
|
347
|
-
} = props;
|
|
348
|
-
const inputProps = utils.getInputProps(schema, type, options);
|
|
349
|
-
const semanticProps = getSemanticProps({
|
|
350
|
-
uiSchema,
|
|
351
|
-
formContext,
|
|
352
|
-
options
|
|
353
|
-
});
|
|
354
|
-
const _onChange = ({
|
|
355
|
-
target: {
|
|
356
|
-
value
|
|
357
|
-
}
|
|
358
|
-
}) => onChange(value === '' ? options.emptyValue : value);
|
|
359
|
-
const _onBlur = () => onBlur && onBlur(id, value);
|
|
360
|
-
const _onFocus = () => onFocus && onFocus(id, value);
|
|
361
|
-
return jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
362
|
-
children: [jsxRuntime.jsx(semanticUiReact.Form.Input, {
|
|
363
|
-
id: id,
|
|
364
|
-
name: id,
|
|
365
|
-
placeholder: placeholder,
|
|
366
|
-
...inputProps,
|
|
367
|
-
label: utils.labelValue(label || undefined, hideLabel, false),
|
|
368
|
-
required: required,
|
|
369
|
-
autoFocus: autofocus,
|
|
370
|
-
disabled: disabled || readonly,
|
|
371
|
-
list: schema.examples ? utils.examplesId(id) : undefined,
|
|
372
|
-
...semanticProps,
|
|
373
|
-
value: value || value === 0 ? value : '',
|
|
374
|
-
error: rawErrors.length > 0,
|
|
375
|
-
onChange: onChangeOverride || _onChange,
|
|
376
|
-
onBlur: _onBlur,
|
|
377
|
-
onFocus: _onFocus,
|
|
378
|
-
"aria-describedby": utils.ariaDescribedByIds(id, !!schema.examples)
|
|
379
|
-
}, id), Array.isArray(schema.examples) && jsxRuntime.jsx("datalist", {
|
|
380
|
-
id: utils.examplesId(id),
|
|
381
|
-
children: schema.examples.concat(schema.default && !schema.examples.includes(schema.default) ? [schema.default] : []).map(example => {
|
|
382
|
-
return jsxRuntime.jsx("option", {
|
|
383
|
-
value: example
|
|
384
|
-
}, example);
|
|
385
|
-
})
|
|
386
|
-
})]
|
|
387
|
-
});
|
|
388
|
-
}
|
|
389
|
-
|
|
390
|
-
/** The `DescriptionField` is the template to use to render the description of a field
|
|
391
|
-
*
|
|
392
|
-
* @param props - The `DescriptionFieldProps` for this component
|
|
393
|
-
*/
|
|
394
|
-
function DescriptionField(props) {
|
|
395
|
-
const {
|
|
396
|
-
id,
|
|
397
|
-
description
|
|
398
|
-
} = props;
|
|
399
|
-
if (!description) {
|
|
400
|
-
return null;
|
|
401
|
-
}
|
|
402
|
-
return jsxRuntime.jsx("p", {
|
|
403
|
-
id: id,
|
|
404
|
-
className: 'sui-description',
|
|
405
|
-
children: description
|
|
406
|
-
});
|
|
407
|
-
}
|
|
408
|
-
|
|
409
|
-
/** The `ErrorList` component is the template that renders the all the errors associated with the fields in the `Form`
|
|
410
|
-
*
|
|
411
|
-
* @param props - The `ErrorListProps` for this component
|
|
412
|
-
*/
|
|
413
|
-
function ErrorList({
|
|
414
|
-
errors,
|
|
415
|
-
registry
|
|
416
|
-
}) {
|
|
417
|
-
const {
|
|
418
|
-
translateString
|
|
419
|
-
} = registry;
|
|
420
|
-
return jsxRuntime.jsxs(semanticUiReact.Message, {
|
|
421
|
-
negative: true,
|
|
422
|
-
children: [jsxRuntime.jsx(semanticUiReact.Message.Header, {
|
|
423
|
-
children: translateString(utils.TranslatableString.ErrorsLabel)
|
|
424
|
-
}), jsxRuntime.jsx(semanticUiReact.Message.List, {
|
|
425
|
-
children: errors.map((error, index) => jsxRuntime.jsx(semanticUiReact.Message.Item, {
|
|
426
|
-
children: error.stack
|
|
427
|
-
}, `error-${index}`))
|
|
428
|
-
})]
|
|
429
|
-
});
|
|
430
|
-
}
|
|
431
|
-
|
|
432
|
-
function IconButton(props) {
|
|
433
|
-
const {
|
|
434
|
-
icon,
|
|
435
|
-
iconType,
|
|
436
|
-
color,
|
|
437
|
-
className,
|
|
438
|
-
uiSchema,
|
|
439
|
-
registry,
|
|
440
|
-
...otherProps
|
|
441
|
-
} = props;
|
|
442
|
-
return jsxRuntime.jsx(semanticUiReact.Button, {
|
|
443
|
-
icon: icon,
|
|
444
|
-
size: iconType,
|
|
445
|
-
color: color,
|
|
446
|
-
className: className,
|
|
447
|
-
...otherProps
|
|
448
|
-
});
|
|
449
|
-
}
|
|
450
|
-
function CopyButton(props) {
|
|
451
|
-
const {
|
|
452
|
-
registry: {
|
|
453
|
-
translateString
|
|
454
|
-
}
|
|
455
|
-
} = props;
|
|
456
|
-
return jsxRuntime.jsx(IconButton, {
|
|
457
|
-
title: translateString(utils.TranslatableString.CopyButton),
|
|
458
|
-
...props,
|
|
459
|
-
icon: 'copy'
|
|
460
|
-
});
|
|
461
|
-
}
|
|
462
|
-
function MoveDownButton(props) {
|
|
463
|
-
const {
|
|
464
|
-
registry: {
|
|
465
|
-
translateString
|
|
466
|
-
}
|
|
467
|
-
} = props;
|
|
468
|
-
return jsxRuntime.jsx(IconButton, {
|
|
469
|
-
title: translateString(utils.TranslatableString.MoveDownButton),
|
|
470
|
-
...props,
|
|
471
|
-
icon: 'angle down'
|
|
472
|
-
});
|
|
473
|
-
}
|
|
474
|
-
function MoveUpButton(props) {
|
|
475
|
-
const {
|
|
476
|
-
registry: {
|
|
477
|
-
translateString
|
|
478
|
-
}
|
|
479
|
-
} = props;
|
|
480
|
-
return jsxRuntime.jsx(IconButton, {
|
|
481
|
-
title: translateString(utils.TranslatableString.MoveUpButton),
|
|
482
|
-
...props,
|
|
483
|
-
icon: 'angle up'
|
|
484
|
-
});
|
|
485
|
-
}
|
|
486
|
-
function RemoveButton(props) {
|
|
487
|
-
const {
|
|
488
|
-
registry: {
|
|
489
|
-
translateString
|
|
490
|
-
}
|
|
491
|
-
} = props;
|
|
492
|
-
return jsxRuntime.jsx(IconButton, {
|
|
493
|
-
title: translateString(utils.TranslatableString.RemoveButton),
|
|
494
|
-
...props,
|
|
495
|
-
icon: 'trash'
|
|
496
|
-
});
|
|
497
|
-
}
|
|
498
|
-
|
|
499
|
-
const DEFAULT_OPTIONS$1 = {
|
|
500
|
-
options: {
|
|
501
|
-
pointing: 'above',
|
|
502
|
-
size: 'small'
|
|
503
|
-
}
|
|
504
|
-
};
|
|
505
|
-
/** The `FieldErrorTemplate` component renders the errors local to the particular field
|
|
506
|
-
*
|
|
507
|
-
* @param props - The `FieldErrorProps` for the errors being rendered
|
|
508
|
-
*/
|
|
509
|
-
function FieldErrorTemplate({
|
|
510
|
-
errors,
|
|
511
|
-
idSchema,
|
|
512
|
-
uiSchema,
|
|
513
|
-
registry
|
|
514
|
-
}) {
|
|
515
|
-
const {
|
|
516
|
-
formContext
|
|
517
|
-
} = registry;
|
|
518
|
-
const options = getSemanticErrorProps({
|
|
519
|
-
formContext,
|
|
520
|
-
uiSchema,
|
|
521
|
-
defaultProps: DEFAULT_OPTIONS$1
|
|
522
|
-
});
|
|
523
|
-
const {
|
|
524
|
-
pointing,
|
|
525
|
-
size
|
|
526
|
-
} = options;
|
|
527
|
-
if (errors && errors.length > 0) {
|
|
528
|
-
const id = utils.errorId(idSchema);
|
|
529
|
-
return jsxRuntime.jsx(semanticUiReact.Label, {
|
|
530
|
-
id: id,
|
|
531
|
-
color: 'red',
|
|
532
|
-
pointing: pointing || 'above',
|
|
533
|
-
size: size || 'small',
|
|
534
|
-
basic: true,
|
|
535
|
-
children: jsxRuntime.jsx(semanticUiReact.List, {
|
|
536
|
-
bulleted: true,
|
|
537
|
-
children: errors.map(error => jsxRuntime.jsx(semanticUiReact.List.Item, {
|
|
538
|
-
children: error
|
|
539
|
-
}, nanoid.nanoid()))
|
|
540
|
-
})
|
|
541
|
-
});
|
|
542
|
-
}
|
|
543
|
-
return null;
|
|
544
|
-
}
|
|
545
|
-
|
|
546
|
-
/** The `FieldHelpTemplate` component renders any help desired for a field
|
|
547
|
-
*
|
|
548
|
-
* @param props - The `FieldHelpProps` to be rendered
|
|
549
|
-
*/
|
|
550
|
-
function FieldHelpTemplate(props) {
|
|
551
|
-
const {
|
|
552
|
-
idSchema,
|
|
553
|
-
help
|
|
554
|
-
} = props;
|
|
555
|
-
if (help) {
|
|
556
|
-
const id = utils.helpId(idSchema);
|
|
557
|
-
return jsxRuntime.jsx(semanticUiReact.Message, {
|
|
558
|
-
size: 'mini',
|
|
559
|
-
info: true,
|
|
560
|
-
id: id,
|
|
561
|
-
content: help
|
|
562
|
-
});
|
|
563
|
-
}
|
|
564
|
-
return null;
|
|
565
|
-
}
|
|
566
|
-
|
|
567
|
-
/** The `FieldTemplate` component is the template used by `SchemaField` to render any field. It renders the field
|
|
568
|
-
* content, (label, description, children, errors and help) inside of a `WrapIfAdditional` component.
|
|
569
|
-
*
|
|
570
|
-
* @param props - The `FieldTemplateProps` for this component
|
|
571
|
-
*/
|
|
572
|
-
function FieldTemplate(props) {
|
|
573
|
-
const {
|
|
574
|
-
id,
|
|
575
|
-
children,
|
|
576
|
-
classNames,
|
|
577
|
-
style,
|
|
578
|
-
displayLabel,
|
|
579
|
-
label,
|
|
580
|
-
errors,
|
|
581
|
-
help,
|
|
582
|
-
hidden,
|
|
583
|
-
description,
|
|
584
|
-
rawDescription,
|
|
585
|
-
registry,
|
|
586
|
-
schema,
|
|
587
|
-
uiSchema,
|
|
588
|
-
...otherProps
|
|
589
|
-
} = props;
|
|
590
|
-
const semanticProps = getSemanticProps(otherProps);
|
|
591
|
-
const {
|
|
592
|
-
wrapLabel,
|
|
593
|
-
wrapContent
|
|
594
|
-
} = semanticProps;
|
|
595
|
-
const uiOptions = utils.getUiOptions(uiSchema);
|
|
596
|
-
const WrapIfAdditionalTemplate = utils.getTemplate('WrapIfAdditionalTemplate', registry, uiOptions);
|
|
597
|
-
if (hidden) {
|
|
598
|
-
return jsxRuntime.jsx("div", {
|
|
599
|
-
style: {
|
|
600
|
-
display: 'none'
|
|
601
|
-
},
|
|
602
|
-
children: children
|
|
603
|
-
});
|
|
604
|
-
}
|
|
605
|
-
return jsxRuntime.jsx(WrapIfAdditionalTemplate, {
|
|
606
|
-
classNames: classNames,
|
|
607
|
-
style: style,
|
|
608
|
-
id: id,
|
|
609
|
-
label: label,
|
|
610
|
-
registry: registry,
|
|
611
|
-
schema: schema,
|
|
612
|
-
uiSchema: uiSchema,
|
|
613
|
-
...otherProps,
|
|
614
|
-
children: jsxRuntime.jsx(semanticUiReact.Form.Group, {
|
|
615
|
-
widths: 'equal',
|
|
616
|
-
grouped: true,
|
|
617
|
-
children: jsxRuntime.jsxs(MaybeWrap, {
|
|
618
|
-
wrap: wrapContent,
|
|
619
|
-
className: 'sui-field-content',
|
|
620
|
-
children: [children, displayLabel && rawDescription && jsxRuntime.jsx(MaybeWrap, {
|
|
621
|
-
wrap: wrapLabel,
|
|
622
|
-
className: 'sui-field-label',
|
|
623
|
-
children: description
|
|
624
|
-
}), help, errors]
|
|
625
|
-
})
|
|
626
|
-
}, id)
|
|
627
|
-
});
|
|
628
|
-
}
|
|
629
|
-
|
|
630
|
-
/** The `ObjectFieldTemplate` is the template to use to render all the inner properties of an object along with the
|
|
631
|
-
* title and description if available. If the object is expandable, then an `AddButton` is also rendered after all
|
|
632
|
-
* the properties.
|
|
633
|
-
*
|
|
634
|
-
* @param props - The `ObjectFieldTemplateProps` for this component
|
|
635
|
-
*/
|
|
636
|
-
function ObjectFieldTemplate(props) {
|
|
637
|
-
const {
|
|
638
|
-
description,
|
|
639
|
-
onAddClick,
|
|
640
|
-
title,
|
|
641
|
-
properties,
|
|
642
|
-
disabled,
|
|
643
|
-
readonly,
|
|
644
|
-
required,
|
|
645
|
-
uiSchema,
|
|
646
|
-
schema,
|
|
647
|
-
formData,
|
|
648
|
-
idSchema,
|
|
649
|
-
registry
|
|
650
|
-
} = props;
|
|
651
|
-
const uiOptions = utils.getUiOptions(uiSchema);
|
|
652
|
-
const TitleFieldTemplate = utils.getTemplate('TitleFieldTemplate', registry, uiOptions);
|
|
653
|
-
const DescriptionFieldTemplate = utils.getTemplate('DescriptionFieldTemplate', registry, uiOptions);
|
|
654
|
-
// Button templates are not overridden in the uiSchema
|
|
655
|
-
const {
|
|
656
|
-
ButtonTemplates: {
|
|
657
|
-
AddButton
|
|
658
|
-
}
|
|
659
|
-
} = registry.templates;
|
|
660
|
-
return jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
661
|
-
children: [title && jsxRuntime.jsx(TitleFieldTemplate, {
|
|
662
|
-
id: utils.titleId(idSchema),
|
|
663
|
-
title: title,
|
|
664
|
-
required: required,
|
|
665
|
-
schema: schema,
|
|
666
|
-
uiSchema: uiSchema,
|
|
667
|
-
registry: registry
|
|
668
|
-
}), description && jsxRuntime.jsx(DescriptionFieldTemplate, {
|
|
669
|
-
id: utils.descriptionId(idSchema),
|
|
670
|
-
description: description,
|
|
671
|
-
schema: schema,
|
|
672
|
-
uiSchema: uiSchema,
|
|
673
|
-
registry: registry
|
|
674
|
-
}), properties.map(prop => prop.content), utils.canExpand(schema, uiSchema, formData) && jsxRuntime.jsx(semanticUiReact.Grid.Column, {
|
|
675
|
-
width: 16,
|
|
676
|
-
verticalAlign: 'middle',
|
|
677
|
-
children: jsxRuntime.jsx(semanticUiReact.Grid.Row, {
|
|
678
|
-
children: jsxRuntime.jsx("div", {
|
|
679
|
-
style: {
|
|
680
|
-
marginTop: '1rem',
|
|
681
|
-
position: 'relative',
|
|
682
|
-
textAlign: 'right'
|
|
683
|
-
},
|
|
684
|
-
children: jsxRuntime.jsx(AddButton, {
|
|
685
|
-
onClick: onAddClick(schema),
|
|
686
|
-
disabled: disabled || readonly,
|
|
687
|
-
uiSchema: uiSchema,
|
|
688
|
-
registry: registry
|
|
689
|
-
})
|
|
690
|
-
})
|
|
691
|
-
})
|
|
692
|
-
})]
|
|
693
|
-
});
|
|
694
|
-
}
|
|
695
|
-
|
|
696
|
-
/** The `SubmitButton` renders a button that represent the `Submit` action on a form
|
|
697
|
-
*/
|
|
698
|
-
function SubmitButton({
|
|
699
|
-
uiSchema
|
|
700
|
-
}) {
|
|
701
|
-
const {
|
|
702
|
-
submitText,
|
|
703
|
-
norender,
|
|
704
|
-
props: submitButtonProps = {}
|
|
705
|
-
} = utils.getSubmitButtonOptions(uiSchema);
|
|
706
|
-
if (norender) {
|
|
707
|
-
return null;
|
|
708
|
-
}
|
|
709
|
-
return jsxRuntime.jsx(semanticUiReact.Button, {
|
|
710
|
-
type: 'submit',
|
|
711
|
-
primary: true,
|
|
712
|
-
...submitButtonProps,
|
|
713
|
-
children: submitText
|
|
714
|
-
});
|
|
715
|
-
}
|
|
716
|
-
|
|
717
|
-
const DEFAULT_OPTIONS = {
|
|
718
|
-
inverted: false,
|
|
719
|
-
dividing: true
|
|
720
|
-
};
|
|
721
|
-
/** The `TitleField` is the template to use to render the title of a field
|
|
722
|
-
*
|
|
723
|
-
* @param props - The `TitleFieldProps` for this component
|
|
724
|
-
*/
|
|
725
|
-
function TitleField({
|
|
726
|
-
id,
|
|
727
|
-
title,
|
|
728
|
-
uiSchema
|
|
729
|
-
}) {
|
|
730
|
-
const semanticProps = getSemanticProps({
|
|
731
|
-
uiSchema,
|
|
732
|
-
defaultSchemaProps: DEFAULT_OPTIONS
|
|
733
|
-
});
|
|
734
|
-
if (!title) {
|
|
735
|
-
return null;
|
|
736
|
-
}
|
|
737
|
-
return jsxRuntime.jsx(semanticUiReact.Header, {
|
|
738
|
-
id: id,
|
|
739
|
-
...semanticProps,
|
|
740
|
-
as: 'h5',
|
|
741
|
-
children: title
|
|
742
|
-
});
|
|
743
|
-
}
|
|
744
|
-
|
|
745
|
-
/** The `WrapIfAdditional` component is used by the `FieldTemplate` to rename, or remove properties that are
|
|
746
|
-
* part of an `additionalProperties` part of a schema.
|
|
747
|
-
*
|
|
748
|
-
* @param props - The `WrapIfAdditionalProps` for this component
|
|
749
|
-
*/
|
|
750
|
-
function WrapIfAdditionalTemplate(props) {
|
|
751
|
-
const {
|
|
752
|
-
children,
|
|
753
|
-
classNames,
|
|
754
|
-
style,
|
|
755
|
-
disabled,
|
|
756
|
-
id,
|
|
757
|
-
label,
|
|
758
|
-
onDropPropertyClick,
|
|
759
|
-
onKeyChange,
|
|
760
|
-
readonly,
|
|
761
|
-
required,
|
|
762
|
-
schema,
|
|
763
|
-
uiSchema,
|
|
764
|
-
registry
|
|
765
|
-
} = props;
|
|
766
|
-
const {
|
|
767
|
-
templates,
|
|
768
|
-
translateString
|
|
769
|
-
} = registry;
|
|
770
|
-
// Button templates are not overridden in the uiSchema
|
|
771
|
-
const {
|
|
772
|
-
RemoveButton
|
|
773
|
-
} = templates.ButtonTemplates;
|
|
774
|
-
const keyLabel = translateString(utils.TranslatableString.KeyLabel, [label]);
|
|
775
|
-
const {
|
|
776
|
-
readonlyAsDisabled = true,
|
|
777
|
-
wrapperStyle
|
|
778
|
-
} = registry.formContext;
|
|
779
|
-
const additional = (utils.ADDITIONAL_PROPERTY_FLAG in schema);
|
|
780
|
-
if (!additional) {
|
|
781
|
-
return jsxRuntime.jsx("div", {
|
|
782
|
-
className: classNames,
|
|
783
|
-
style: style,
|
|
784
|
-
children: children
|
|
785
|
-
});
|
|
786
|
-
}
|
|
787
|
-
const handleBlur = ({
|
|
788
|
-
target
|
|
789
|
-
}) => onKeyChange(target.value);
|
|
790
|
-
return jsxRuntime.jsx("div", {
|
|
791
|
-
className: classNames,
|
|
792
|
-
style: style,
|
|
793
|
-
children: jsxRuntime.jsx(semanticUiReact.Grid, {
|
|
794
|
-
columns: 'equal',
|
|
795
|
-
children: jsxRuntime.jsxs(semanticUiReact.Grid.Row, {
|
|
796
|
-
children: [jsxRuntime.jsx(semanticUiReact.Grid.Column, {
|
|
797
|
-
className: 'form-additional',
|
|
798
|
-
children: jsxRuntime.jsx(semanticUiReact.Form.Group, {
|
|
799
|
-
widths: 'equal',
|
|
800
|
-
grouped: true,
|
|
801
|
-
children: jsxRuntime.jsx(semanticUiReact.Form.Input, {
|
|
802
|
-
className: 'form-group',
|
|
803
|
-
hasFeedback: true,
|
|
804
|
-
fluid: true,
|
|
805
|
-
htmlFor: `${id}`,
|
|
806
|
-
label: keyLabel,
|
|
807
|
-
required: required,
|
|
808
|
-
defaultValue: label,
|
|
809
|
-
disabled: disabled || readonlyAsDisabled && readonly,
|
|
810
|
-
id: `${id}`,
|
|
811
|
-
name: `${id}`,
|
|
812
|
-
onBlur: !readonly ? handleBlur : undefined,
|
|
813
|
-
style: wrapperStyle,
|
|
814
|
-
type: 'text'
|
|
815
|
-
})
|
|
816
|
-
})
|
|
817
|
-
}), jsxRuntime.jsx(semanticUiReact.Grid.Column, {
|
|
818
|
-
className: 'form-additional',
|
|
819
|
-
verticalAlign: 'middle',
|
|
820
|
-
children: children
|
|
821
|
-
}), jsxRuntime.jsx(semanticUiReact.Grid.Column, {
|
|
822
|
-
children: jsxRuntime.jsx(RemoveButton, {
|
|
823
|
-
iconType: 'mini',
|
|
824
|
-
className: 'array-item-remove',
|
|
825
|
-
disabled: disabled || readonly,
|
|
826
|
-
onClick: onDropPropertyClick(label),
|
|
827
|
-
uiSchema: uiSchema,
|
|
828
|
-
registry: registry
|
|
829
|
-
})
|
|
830
|
-
})]
|
|
831
|
-
})
|
|
832
|
-
})
|
|
833
|
-
}, `${id}-key`);
|
|
834
|
-
}
|
|
835
|
-
|
|
836
|
-
function generateTemplates() {
|
|
837
|
-
return {
|
|
838
|
-
ArrayFieldItemTemplate,
|
|
839
|
-
ArrayFieldTemplate,
|
|
840
|
-
BaseInputTemplate,
|
|
841
|
-
ButtonTemplates: {
|
|
842
|
-
AddButton,
|
|
843
|
-
CopyButton,
|
|
844
|
-
MoveDownButton,
|
|
845
|
-
MoveUpButton,
|
|
846
|
-
RemoveButton,
|
|
847
|
-
SubmitButton
|
|
848
|
-
},
|
|
849
|
-
DescriptionFieldTemplate: DescriptionField,
|
|
850
|
-
ErrorListTemplate: ErrorList,
|
|
851
|
-
FieldErrorTemplate,
|
|
852
|
-
FieldHelpTemplate,
|
|
853
|
-
FieldTemplate,
|
|
854
|
-
ObjectFieldTemplate,
|
|
855
|
-
TitleFieldTemplate: TitleField,
|
|
856
|
-
WrapIfAdditionalTemplate
|
|
857
|
-
};
|
|
858
|
-
}
|
|
859
|
-
var Templates = /*#__PURE__*/generateTemplates();
|
|
860
|
-
|
|
861
|
-
/** The `CheckBoxWidget` is a widget for rendering boolean properties.
|
|
862
|
-
* It is typically used to represent a boolean.
|
|
863
|
-
*
|
|
864
|
-
* @param props - The `WidgetProps` for this component
|
|
865
|
-
*/
|
|
866
|
-
function CheckboxWidget(props) {
|
|
867
|
-
const {
|
|
868
|
-
id,
|
|
869
|
-
value,
|
|
870
|
-
disabled,
|
|
871
|
-
readonly,
|
|
872
|
-
label = '',
|
|
873
|
-
hideLabel,
|
|
874
|
-
autofocus,
|
|
875
|
-
onChange,
|
|
876
|
-
onBlur,
|
|
877
|
-
options,
|
|
878
|
-
onFocus,
|
|
879
|
-
formContext,
|
|
880
|
-
schema,
|
|
881
|
-
uiSchema,
|
|
882
|
-
rawErrors = [],
|
|
883
|
-
registry
|
|
884
|
-
} = props;
|
|
885
|
-
const semanticProps = getSemanticProps({
|
|
886
|
-
options,
|
|
887
|
-
formContext,
|
|
888
|
-
uiSchema,
|
|
889
|
-
defaultSchemaProps: {
|
|
890
|
-
inverted: 'false'
|
|
891
|
-
}
|
|
892
|
-
});
|
|
893
|
-
const DescriptionFieldTemplate = utils.getTemplate('DescriptionFieldTemplate', registry, options);
|
|
894
|
-
// Because an unchecked checkbox will cause html5 validation to fail, only add
|
|
895
|
-
// the "required" attribute if the field value must be "true", due to the
|
|
896
|
-
// "const" or "enum" keywords
|
|
897
|
-
const required = utils.schemaRequiresTrueValue(schema);
|
|
898
|
-
const _onChange = (_, data) => onChange && onChange(data.checked);
|
|
899
|
-
const _onBlur = () => onBlur && onBlur(id, value);
|
|
900
|
-
const _onFocus = () => onFocus && onFocus(id, value);
|
|
901
|
-
const checked = value == 'true' || value == true;
|
|
902
|
-
const description = options.description ?? schema.description;
|
|
903
|
-
return jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
904
|
-
children: [!hideLabel && !!description && jsxRuntime.jsx(DescriptionFieldTemplate, {
|
|
905
|
-
id: utils.descriptionId(id),
|
|
906
|
-
description: description,
|
|
907
|
-
schema: schema,
|
|
908
|
-
uiSchema: uiSchema,
|
|
909
|
-
registry: registry
|
|
910
|
-
}), jsxRuntime.jsx(semanticUiReact.Form.Checkbox, {
|
|
911
|
-
id: id,
|
|
912
|
-
name: id,
|
|
913
|
-
disabled: disabled || readonly,
|
|
914
|
-
autoFocus: autofocus,
|
|
915
|
-
...semanticProps,
|
|
916
|
-
checked: typeof value === 'undefined' ? false : checked,
|
|
917
|
-
error: rawErrors.length > 0,
|
|
918
|
-
onChange: _onChange,
|
|
919
|
-
onBlur: _onBlur,
|
|
920
|
-
onFocus: _onFocus,
|
|
921
|
-
required: required,
|
|
922
|
-
label: utils.labelValue(label, hideLabel, false),
|
|
923
|
-
"aria-describedby": utils.ariaDescribedByIds(id)
|
|
924
|
-
})]
|
|
925
|
-
});
|
|
926
|
-
}
|
|
927
|
-
|
|
928
|
-
/** The `CheckboxesWidget` is a widget for rendering checkbox groups.
|
|
929
|
-
* It is typically used to represent an array of enums.
|
|
930
|
-
*
|
|
931
|
-
* @param props - The `WidgetProps` for this component
|
|
932
|
-
*/
|
|
933
|
-
function CheckboxesWidget(props) {
|
|
934
|
-
const {
|
|
935
|
-
id,
|
|
936
|
-
disabled,
|
|
937
|
-
options,
|
|
938
|
-
value,
|
|
939
|
-
autofocus,
|
|
940
|
-
readonly,
|
|
941
|
-
label,
|
|
942
|
-
hideLabel,
|
|
943
|
-
onChange,
|
|
944
|
-
onBlur,
|
|
945
|
-
onFocus,
|
|
946
|
-
formContext,
|
|
947
|
-
schema,
|
|
948
|
-
uiSchema,
|
|
949
|
-
rawErrors = [],
|
|
950
|
-
registry
|
|
951
|
-
} = props;
|
|
952
|
-
const TitleFieldTemplate = utils.getTemplate('TitleFieldTemplate', registry, options);
|
|
953
|
-
const {
|
|
954
|
-
enumOptions,
|
|
955
|
-
enumDisabled,
|
|
956
|
-
inline
|
|
957
|
-
} = options;
|
|
958
|
-
const checkboxesValues = Array.isArray(value) ? value : [value];
|
|
959
|
-
const semanticProps = getSemanticProps({
|
|
960
|
-
options,
|
|
961
|
-
formContext,
|
|
962
|
-
uiSchema,
|
|
963
|
-
defaultSchemaProps: {
|
|
964
|
-
inverted: 'false'
|
|
965
|
-
}
|
|
966
|
-
});
|
|
967
|
-
const _onChange = index => ({
|
|
968
|
-
target: {
|
|
969
|
-
checked
|
|
970
|
-
}
|
|
971
|
-
}) => {
|
|
972
|
-
// eslint-disable-next-line no-shadow
|
|
973
|
-
if (checked) {
|
|
974
|
-
onChange(utils.enumOptionsSelectValue(index, checkboxesValues, enumOptions));
|
|
975
|
-
} else {
|
|
976
|
-
onChange(utils.enumOptionsDeselectValue(index, checkboxesValues, enumOptions));
|
|
977
|
-
}
|
|
978
|
-
};
|
|
979
|
-
const _onBlur = () => onBlur(id, value);
|
|
980
|
-
const _onFocus = () => onFocus(id, value);
|
|
981
|
-
const inlineOption = inline ? {
|
|
982
|
-
inline: true
|
|
983
|
-
} : {
|
|
984
|
-
grouped: true
|
|
985
|
-
};
|
|
986
|
-
return jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
987
|
-
children: [!hideLabel && !!label && jsxRuntime.jsx(TitleFieldTemplate, {
|
|
988
|
-
id: utils.titleId(id),
|
|
989
|
-
title: label,
|
|
990
|
-
schema: schema,
|
|
991
|
-
uiSchema: uiSchema,
|
|
992
|
-
registry: registry
|
|
993
|
-
}), jsxRuntime.jsx(semanticUiReact.Form.Group, {
|
|
994
|
-
id: id,
|
|
995
|
-
name: id,
|
|
996
|
-
...inlineOption,
|
|
997
|
-
children: Array.isArray(enumOptions) && enumOptions.map((option, index) => {
|
|
998
|
-
const checked = utils.enumOptionsIsSelected(option.value, checkboxesValues);
|
|
999
|
-
const itemDisabled = Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) !== -1;
|
|
1000
|
-
return jsxRuntime.jsx(semanticUiReact.Form.Checkbox, {
|
|
1001
|
-
id: utils.optionId(id, index),
|
|
1002
|
-
name: id,
|
|
1003
|
-
label: option.label,
|
|
1004
|
-
...semanticProps,
|
|
1005
|
-
checked: checked,
|
|
1006
|
-
error: rawErrors.length > 0,
|
|
1007
|
-
disabled: disabled || itemDisabled || readonly,
|
|
1008
|
-
autoFocus: autofocus && index === 0,
|
|
1009
|
-
onChange: _onChange(index),
|
|
1010
|
-
onBlur: _onBlur,
|
|
1011
|
-
onFocus: _onFocus,
|
|
1012
|
-
"aria-describedby": utils.ariaDescribedByIds(id)
|
|
1013
|
-
}, index);
|
|
1014
|
-
})
|
|
1015
|
-
})]
|
|
1016
|
-
});
|
|
1017
|
-
}
|
|
1018
|
-
|
|
1019
|
-
/** The `RadioWidget` is a widget for rendering a radio group.
|
|
1020
|
-
* It is typically used with a string property constrained with enum options.
|
|
1021
|
-
*
|
|
1022
|
-
* @param props - The `WidgetProps` for this component
|
|
1023
|
-
*/
|
|
1024
|
-
function RadioWidget(props) {
|
|
1025
|
-
const {
|
|
1026
|
-
id,
|
|
1027
|
-
value,
|
|
1028
|
-
required,
|
|
1029
|
-
disabled,
|
|
1030
|
-
readonly,
|
|
1031
|
-
onChange,
|
|
1032
|
-
onBlur,
|
|
1033
|
-
onFocus,
|
|
1034
|
-
options,
|
|
1035
|
-
formContext,
|
|
1036
|
-
uiSchema,
|
|
1037
|
-
rawErrors = []
|
|
1038
|
-
} = props;
|
|
1039
|
-
const {
|
|
1040
|
-
enumOptions,
|
|
1041
|
-
enumDisabled,
|
|
1042
|
-
emptyValue
|
|
1043
|
-
} = options;
|
|
1044
|
-
const semanticProps = getSemanticProps({
|
|
1045
|
-
formContext,
|
|
1046
|
-
options,
|
|
1047
|
-
uiSchema
|
|
1048
|
-
});
|
|
1049
|
-
const _onChange = (_, {
|
|
1050
|
-
value: eventValue
|
|
1051
|
-
}) => {
|
|
1052
|
-
return onChange(utils.enumOptionsValueForIndex(eventValue, enumOptions, emptyValue));
|
|
1053
|
-
};
|
|
1054
|
-
const _onBlur = () => onBlur(id, value);
|
|
1055
|
-
const _onFocus = () => onFocus(id, value);
|
|
1056
|
-
const inlineOption = options.inline ? {
|
|
1057
|
-
inline: true
|
|
1058
|
-
} : {
|
|
1059
|
-
grouped: true
|
|
1060
|
-
};
|
|
1061
|
-
return jsxRuntime.jsx(semanticUiReact.Form.Group, {
|
|
1062
|
-
...inlineOption,
|
|
1063
|
-
children: Array.isArray(enumOptions) && enumOptions.map((option, index) => {
|
|
1064
|
-
const checked = utils.enumOptionsIsSelected(option.value, value);
|
|
1065
|
-
const itemDisabled = Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) !== -1;
|
|
1066
|
-
return /*#__PURE__*/react.createElement(semanticUiReact.Form.Field, {
|
|
1067
|
-
required: required,
|
|
1068
|
-
control: semanticUiReact.Radio,
|
|
1069
|
-
id: utils.optionId(id, index),
|
|
1070
|
-
name: id,
|
|
1071
|
-
...semanticProps,
|
|
1072
|
-
onFocus: _onFocus,
|
|
1073
|
-
onBlur: _onBlur,
|
|
1074
|
-
onChange: _onChange,
|
|
1075
|
-
label: option.label,
|
|
1076
|
-
value: String(index),
|
|
1077
|
-
error: rawErrors.length > 0,
|
|
1078
|
-
key: index,
|
|
1079
|
-
checked: checked,
|
|
1080
|
-
disabled: disabled || itemDisabled || readonly,
|
|
1081
|
-
"aria-describedby": utils.ariaDescribedByIds(id)
|
|
1082
|
-
});
|
|
1083
|
-
})
|
|
1084
|
-
});
|
|
1085
|
-
}
|
|
1086
|
-
|
|
1087
|
-
/** The `RangeWidget` component uses the `BaseInputTemplate` changing the type to `range` and wrapping the result
|
|
1088
|
-
* in a div, with the value along side it.
|
|
1089
|
-
*
|
|
1090
|
-
* @param props - The `WidgetProps` for this component
|
|
1091
|
-
*/
|
|
1092
|
-
function RangeWidget(props) {
|
|
1093
|
-
const {
|
|
1094
|
-
id,
|
|
1095
|
-
value,
|
|
1096
|
-
required,
|
|
1097
|
-
readonly,
|
|
1098
|
-
disabled,
|
|
1099
|
-
onChange,
|
|
1100
|
-
onBlur,
|
|
1101
|
-
onFocus,
|
|
1102
|
-
options,
|
|
1103
|
-
schema,
|
|
1104
|
-
uiSchema,
|
|
1105
|
-
formContext,
|
|
1106
|
-
rawErrors = []
|
|
1107
|
-
} = props;
|
|
1108
|
-
const semanticProps = getSemanticProps({
|
|
1109
|
-
formContext,
|
|
1110
|
-
options,
|
|
1111
|
-
uiSchema,
|
|
1112
|
-
defaultSchemaProps: {
|
|
1113
|
-
fluid: true
|
|
1114
|
-
}
|
|
1115
|
-
});
|
|
1116
|
-
// eslint-disable-next-line no-shadow
|
|
1117
|
-
const _onChange = ({
|
|
1118
|
-
target: {
|
|
1119
|
-
value
|
|
1120
|
-
}
|
|
1121
|
-
}) => onChange && onChange(value === '' ? options.emptyValue : value);
|
|
1122
|
-
const _onBlur = () => onBlur && onBlur(id, value);
|
|
1123
|
-
const _onFocus = () => onFocus && onFocus(id, value);
|
|
1124
|
-
return jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
1125
|
-
children: [jsxRuntime.jsx(semanticUiReact.Input, {
|
|
1126
|
-
id: id,
|
|
1127
|
-
name: id,
|
|
1128
|
-
type: 'range',
|
|
1129
|
-
required: required,
|
|
1130
|
-
disabled: disabled || readonly,
|
|
1131
|
-
...utils.rangeSpec(schema),
|
|
1132
|
-
...semanticProps,
|
|
1133
|
-
value: value || '',
|
|
1134
|
-
error: rawErrors.length > 0,
|
|
1135
|
-
onChange: _onChange,
|
|
1136
|
-
onBlur: _onBlur,
|
|
1137
|
-
onFocus: _onFocus,
|
|
1138
|
-
"aria-describedby": utils.ariaDescribedByIds(id)
|
|
1139
|
-
}, id), jsxRuntime.jsx("span", {
|
|
1140
|
-
children: value
|
|
1141
|
-
})]
|
|
1142
|
-
});
|
|
1143
|
-
}
|
|
1144
|
-
|
|
1145
|
-
/**
|
|
1146
|
-
* Returns and creates an array format required for semantic drop down
|
|
1147
|
-
* @param {array} enumOptions- array of items for the dropdown
|
|
1148
|
-
* @param {array} enumDisabled - array of enum option values to disable
|
|
1149
|
-
* @returns {*}
|
|
1150
|
-
*/
|
|
1151
|
-
function createDefaultValueOptionsForDropDown(enumOptions, enumDisabled) {
|
|
1152
|
-
const disabledOptions = enumDisabled || [];
|
|
1153
|
-
const options = map__default["default"](enumOptions, ({
|
|
1154
|
-
label,
|
|
1155
|
-
value
|
|
1156
|
-
}, index) => ({
|
|
1157
|
-
disabled: disabledOptions.indexOf(value) !== -1,
|
|
1158
|
-
key: label,
|
|
1159
|
-
text: label,
|
|
1160
|
-
value: String(index)
|
|
1161
|
-
}));
|
|
1162
|
-
return options;
|
|
1163
|
-
}
|
|
1164
|
-
/** The `SelectWidget` is a widget for rendering dropdowns.
|
|
1165
|
-
* It is typically used with string properties constrained with enum options.
|
|
1166
|
-
*
|
|
1167
|
-
* @param props - The `WidgetProps` for this component
|
|
1168
|
-
*/
|
|
1169
|
-
function SelectWidget(props) {
|
|
1170
|
-
const {
|
|
1171
|
-
uiSchema,
|
|
1172
|
-
formContext,
|
|
1173
|
-
id,
|
|
1174
|
-
options,
|
|
1175
|
-
label,
|
|
1176
|
-
hideLabel,
|
|
1177
|
-
required,
|
|
1178
|
-
disabled,
|
|
1179
|
-
readonly,
|
|
1180
|
-
value,
|
|
1181
|
-
multiple,
|
|
1182
|
-
placeholder,
|
|
1183
|
-
autofocus,
|
|
1184
|
-
onChange,
|
|
1185
|
-
onBlur,
|
|
1186
|
-
onFocus,
|
|
1187
|
-
rawErrors = []
|
|
1188
|
-
} = props;
|
|
1189
|
-
const semanticProps = getSemanticProps({
|
|
1190
|
-
uiSchema,
|
|
1191
|
-
formContext,
|
|
1192
|
-
options,
|
|
1193
|
-
defaultSchemaProps: {
|
|
1194
|
-
inverted: 'false',
|
|
1195
|
-
selection: true,
|
|
1196
|
-
fluid: true,
|
|
1197
|
-
scrolling: true,
|
|
1198
|
-
upward: false
|
|
1199
|
-
}
|
|
1200
|
-
});
|
|
1201
|
-
const {
|
|
1202
|
-
enumDisabled,
|
|
1203
|
-
enumOptions,
|
|
1204
|
-
emptyValue: optEmptyVal
|
|
1205
|
-
} = options;
|
|
1206
|
-
const emptyValue = multiple ? [] : '';
|
|
1207
|
-
const dropdownOptions = createDefaultValueOptionsForDropDown(enumOptions, enumDisabled);
|
|
1208
|
-
const _onChange = (_, {
|
|
1209
|
-
value
|
|
1210
|
-
}) => onChange(utils.enumOptionsValueForIndex(value, enumOptions, optEmptyVal));
|
|
1211
|
-
// eslint-disable-next-line no-shadow
|
|
1212
|
-
const _onBlur = (_, {
|
|
1213
|
-
target: {
|
|
1214
|
-
value
|
|
1215
|
-
}
|
|
1216
|
-
}) => onBlur(id, utils.enumOptionsValueForIndex(value, enumOptions, optEmptyVal));
|
|
1217
|
-
const _onFocus = (_, {
|
|
1218
|
-
target: {
|
|
1219
|
-
value
|
|
1220
|
-
}
|
|
1221
|
-
}) => onFocus(id, utils.enumOptionsValueForIndex(value, enumOptions, optEmptyVal));
|
|
1222
|
-
const selectedIndexes = utils.enumOptionsIndexForValue(value, enumOptions, multiple);
|
|
1223
|
-
return jsxRuntime.jsx(semanticUiReact.Form.Dropdown, {
|
|
1224
|
-
id: id,
|
|
1225
|
-
name: id,
|
|
1226
|
-
label: utils.labelValue(label || undefined, hideLabel, false),
|
|
1227
|
-
multiple: typeof multiple === 'undefined' ? false : multiple,
|
|
1228
|
-
value: typeof value === 'undefined' ? emptyValue : selectedIndexes,
|
|
1229
|
-
error: rawErrors.length > 0,
|
|
1230
|
-
disabled: disabled,
|
|
1231
|
-
placeholder: placeholder,
|
|
1232
|
-
...semanticProps,
|
|
1233
|
-
required: required,
|
|
1234
|
-
autoFocus: autofocus,
|
|
1235
|
-
readOnly: readonly,
|
|
1236
|
-
options: dropdownOptions,
|
|
1237
|
-
onChange: _onChange,
|
|
1238
|
-
onBlur: _onBlur,
|
|
1239
|
-
onFocus: _onFocus,
|
|
1240
|
-
"aria-describedby": utils.ariaDescribedByIds(id)
|
|
1241
|
-
}, id);
|
|
1242
|
-
}
|
|
1243
|
-
|
|
1244
|
-
/** The `TextareaWidget` is a widget for rendering input fields as textarea.
|
|
1245
|
-
*
|
|
1246
|
-
* @param props - The `WidgetProps` for this component
|
|
1247
|
-
*/
|
|
1248
|
-
function TextareaWidget(props) {
|
|
1249
|
-
const {
|
|
1250
|
-
id,
|
|
1251
|
-
placeholder,
|
|
1252
|
-
value,
|
|
1253
|
-
required,
|
|
1254
|
-
disabled,
|
|
1255
|
-
autofocus,
|
|
1256
|
-
label,
|
|
1257
|
-
hideLabel,
|
|
1258
|
-
readonly,
|
|
1259
|
-
onBlur,
|
|
1260
|
-
onFocus,
|
|
1261
|
-
onChange,
|
|
1262
|
-
options,
|
|
1263
|
-
formContext,
|
|
1264
|
-
rawErrors = []
|
|
1265
|
-
} = props;
|
|
1266
|
-
const semanticProps = getSemanticProps({
|
|
1267
|
-
formContext,
|
|
1268
|
-
options,
|
|
1269
|
-
defaultSchemaProps: {
|
|
1270
|
-
inverted: 'false'
|
|
1271
|
-
}
|
|
1272
|
-
});
|
|
1273
|
-
// eslint-disable-next-line no-shadow
|
|
1274
|
-
const _onChange = ({
|
|
1275
|
-
target: {
|
|
1276
|
-
value
|
|
1277
|
-
}
|
|
1278
|
-
}) => onChange && onChange(value === '' ? options.emptyValue : value);
|
|
1279
|
-
const _onBlur = () => onBlur && onBlur(id, value);
|
|
1280
|
-
const _onFocus = () => onFocus && onFocus(id, value);
|
|
1281
|
-
return jsxRuntime.jsx(semanticUiReact.Form.TextArea, {
|
|
1282
|
-
id: id,
|
|
1283
|
-
name: id,
|
|
1284
|
-
label: utils.labelValue(label || undefined, hideLabel, false),
|
|
1285
|
-
placeholder: placeholder,
|
|
1286
|
-
autoFocus: autofocus,
|
|
1287
|
-
required: required,
|
|
1288
|
-
disabled: disabled || readonly,
|
|
1289
|
-
...semanticProps,
|
|
1290
|
-
value: value || '',
|
|
1291
|
-
error: rawErrors.length > 0,
|
|
1292
|
-
rows: options.rows || 5,
|
|
1293
|
-
onChange: _onChange,
|
|
1294
|
-
onBlur: _onBlur,
|
|
1295
|
-
onFocus: _onFocus,
|
|
1296
|
-
"aria-describedby": utils.ariaDescribedByIds(id)
|
|
1297
|
-
}, id);
|
|
1298
|
-
}
|
|
1299
|
-
|
|
1300
|
-
function generateWidgets() {
|
|
1301
|
-
return {
|
|
1302
|
-
CheckboxWidget,
|
|
1303
|
-
CheckboxesWidget,
|
|
1304
|
-
RadioWidget,
|
|
1305
|
-
RangeWidget,
|
|
1306
|
-
SelectWidget,
|
|
1307
|
-
TextareaWidget
|
|
1308
|
-
};
|
|
1309
|
-
}
|
|
1310
|
-
var Widgets = /*#__PURE__*/generateWidgets();
|
|
1311
|
-
|
|
1312
|
-
function generateTheme() {
|
|
1313
|
-
return {
|
|
1314
|
-
templates: generateTemplates(),
|
|
1315
|
-
widgets: generateWidgets(),
|
|
1316
|
-
_internalFormWrapper: semanticUiReact.Form
|
|
1317
|
-
};
|
|
1318
|
-
}
|
|
1319
|
-
var Theme = /*#__PURE__*/generateTheme();
|
|
1320
|
-
|
|
1321
|
-
function generateForm() {
|
|
1322
|
-
return core.withTheme(generateTheme());
|
|
1323
|
-
}
|
|
1324
|
-
var SemanticUIForm = /*#__PURE__*/generateForm();
|
|
1325
|
-
|
|
1326
|
-
exports.Form = SemanticUIForm;
|
|
1327
|
-
exports.Templates = Templates;
|
|
1328
|
-
exports.Theme = Theme;
|
|
1329
|
-
exports.Widgets = Widgets;
|
|
1330
|
-
exports["default"] = SemanticUIForm;
|
|
1331
|
-
exports.generateForm = generateForm;
|
|
1332
|
-
exports.generateTemplates = generateTemplates;
|
|
1333
|
-
exports.generateTheme = generateTheme;
|
|
1334
|
-
exports.generateWidgets = generateWidgets;
|
|
1335
|
-
//# sourceMappingURL=semantic-ui.cjs.development.js.map
|