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