@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.
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
@@ -0,0 +1,90 @@
1
+ import { ChangeEvent } from 'react';
2
+ import { Form } from 'semantic-ui-react';
3
+ import { getSemanticProps } from '../util';
4
+ import {
5
+ ariaDescribedByIds,
6
+ BaseInputTemplateProps,
7
+ examplesId,
8
+ getInputProps,
9
+ labelValue,
10
+ FormContextType,
11
+ RJSFSchema,
12
+ StrictRJSFSchema,
13
+ } from '@rjsf/utils';
14
+
15
+ /** The `BaseInputTemplate` is the template to use to render the basic `<input>` component for the `core` theme.
16
+ * It is used as the template for rendering many of the <input> based widgets that differ by `type` and callbacks only.
17
+ * It can be customized/overridden for other themes or individual implementations as needed.
18
+ *
19
+ * @param props - The `WidgetProps` for this template
20
+ */
21
+ export default function BaseInputTemplate<
22
+ T = any,
23
+ S extends StrictRJSFSchema = RJSFSchema,
24
+ F extends FormContextType = any
25
+ >(props: BaseInputTemplateProps<T, S, F>) {
26
+ const {
27
+ id,
28
+ placeholder,
29
+ label,
30
+ hideLabel,
31
+ value,
32
+ required,
33
+ readonly,
34
+ disabled,
35
+ onChange,
36
+ onChangeOverride,
37
+ onBlur,
38
+ onFocus,
39
+ autofocus,
40
+ options,
41
+ schema,
42
+ uiSchema,
43
+ formContext,
44
+ type,
45
+ rawErrors = [],
46
+ } = props;
47
+ const inputProps = getInputProps<T, S, F>(schema, type, options);
48
+ const semanticProps = getSemanticProps<T, S, F>({
49
+ uiSchema,
50
+ formContext,
51
+ options,
52
+ });
53
+ const _onChange = ({ target: { value } }: ChangeEvent<HTMLInputElement>) =>
54
+ onChange(value === '' ? options.emptyValue : value);
55
+ const _onBlur = () => onBlur && onBlur(id, value);
56
+ const _onFocus = () => onFocus && onFocus(id, value);
57
+
58
+ return (
59
+ <>
60
+ <Form.Input
61
+ key={id}
62
+ id={id}
63
+ name={id}
64
+ placeholder={placeholder}
65
+ {...inputProps}
66
+ label={labelValue(label || undefined, hideLabel, false)}
67
+ required={required}
68
+ autoFocus={autofocus}
69
+ disabled={disabled || readonly}
70
+ list={schema.examples ? examplesId<T>(id) : undefined}
71
+ {...semanticProps}
72
+ value={value || value === 0 ? value : ''}
73
+ error={rawErrors.length > 0}
74
+ onChange={onChangeOverride || _onChange}
75
+ onBlur={_onBlur}
76
+ onFocus={_onFocus}
77
+ aria-describedby={ariaDescribedByIds<T>(id, !!schema.examples)}
78
+ />
79
+ {Array.isArray(schema.examples) && (
80
+ <datalist id={examplesId<T>(id)}>
81
+ {(schema.examples as string[])
82
+ .concat(schema.default && !schema.examples.includes(schema.default) ? ([schema.default] as string[]) : [])
83
+ .map((example) => {
84
+ return <option key={example} value={example} />;
85
+ })}
86
+ </datalist>
87
+ )}
88
+ </>
89
+ );
90
+ }
@@ -0,0 +1,2 @@
1
+ export { default } from './BaseInputTemplate';
2
+ export * from './BaseInputTemplate';
@@ -0,0 +1,95 @@
1
+ import { FormEvent } from 'react';
2
+ import {
3
+ ariaDescribedByIds,
4
+ descriptionId,
5
+ getTemplate,
6
+ labelValue,
7
+ schemaRequiresTrueValue,
8
+ FormContextType,
9
+ RJSFSchema,
10
+ StrictRJSFSchema,
11
+ WidgetProps,
12
+ } from '@rjsf/utils';
13
+ import { Form, CheckboxProps } from 'semantic-ui-react';
14
+ import { getSemanticProps } from '../util';
15
+
16
+ /** The `CheckBoxWidget` is a widget for rendering boolean properties.
17
+ * It is typically used to represent a boolean.
18
+ *
19
+ * @param props - The `WidgetProps` for this component
20
+ */
21
+ export default function CheckboxWidget<
22
+ T = any,
23
+ S extends StrictRJSFSchema = RJSFSchema,
24
+ F extends FormContextType = any
25
+ >(props: WidgetProps<T, S, F>) {
26
+ const {
27
+ id,
28
+ value,
29
+ disabled,
30
+ readonly,
31
+ label = '',
32
+ hideLabel,
33
+ autofocus,
34
+ onChange,
35
+ onBlur,
36
+ options,
37
+ onFocus,
38
+ formContext,
39
+ schema,
40
+ uiSchema,
41
+ rawErrors = [],
42
+ registry,
43
+ } = props;
44
+ const semanticProps = getSemanticProps<T, S, F>({
45
+ options,
46
+ formContext,
47
+ uiSchema,
48
+ defaultSchemaProps: {
49
+ inverted: 'false',
50
+ },
51
+ });
52
+ const DescriptionFieldTemplate = getTemplate<'DescriptionFieldTemplate', T, S, F>(
53
+ 'DescriptionFieldTemplate',
54
+ registry,
55
+ options
56
+ );
57
+ // Because an unchecked checkbox will cause html5 validation to fail, only add
58
+ // the "required" attribute if the field value must be "true", due to the
59
+ // "const" or "enum" keywords
60
+ const required = schemaRequiresTrueValue<S>(schema);
61
+ const _onChange = (_: FormEvent<HTMLInputElement>, data: CheckboxProps) => onChange && onChange(data.checked);
62
+ const _onBlur = () => onBlur && onBlur(id, value);
63
+ const _onFocus = () => onFocus && onFocus(id, value);
64
+ const checked = value == 'true' || value == true;
65
+ const description = options.description ?? schema.description;
66
+
67
+ return (
68
+ <>
69
+ {!hideLabel && !!description && (
70
+ <DescriptionFieldTemplate
71
+ id={descriptionId<T>(id)}
72
+ description={description}
73
+ schema={schema}
74
+ uiSchema={uiSchema}
75
+ registry={registry}
76
+ />
77
+ )}
78
+ <Form.Checkbox
79
+ id={id}
80
+ name={id}
81
+ disabled={disabled || readonly}
82
+ autoFocus={autofocus}
83
+ {...semanticProps}
84
+ checked={typeof value === 'undefined' ? false : checked}
85
+ error={rawErrors.length > 0}
86
+ onChange={_onChange}
87
+ onBlur={_onBlur}
88
+ onFocus={_onFocus}
89
+ required={required}
90
+ label={labelValue(label, hideLabel, false)}
91
+ aria-describedby={ariaDescribedByIds<T>(id)}
92
+ />
93
+ </>
94
+ );
95
+ }
@@ -0,0 +1,2 @@
1
+ export { default } from './CheckboxWidget';
2
+ export * from './CheckboxWidget';
@@ -0,0 +1,102 @@
1
+ import { ChangeEvent } from 'react';
2
+ import { Form } from 'semantic-ui-react';
3
+ import {
4
+ ariaDescribedByIds,
5
+ enumOptionsDeselectValue,
6
+ enumOptionsIsSelected,
7
+ enumOptionsSelectValue,
8
+ getTemplate,
9
+ optionId,
10
+ titleId,
11
+ FormContextType,
12
+ RJSFSchema,
13
+ StrictRJSFSchema,
14
+ WidgetProps,
15
+ } from '@rjsf/utils';
16
+ import { getSemanticProps } from '../util';
17
+
18
+ /** The `CheckboxesWidget` is a widget for rendering checkbox groups.
19
+ * It is typically used to represent an array of enums.
20
+ *
21
+ * @param props - The `WidgetProps` for this component
22
+ */
23
+ export default function CheckboxesWidget<
24
+ T = any,
25
+ S extends StrictRJSFSchema = RJSFSchema,
26
+ F extends FormContextType = any
27
+ >(props: WidgetProps<T, S, F>) {
28
+ const {
29
+ id,
30
+ disabled,
31
+ options,
32
+ value,
33
+ autofocus,
34
+ readonly,
35
+ label,
36
+ hideLabel,
37
+ onChange,
38
+ onBlur,
39
+ onFocus,
40
+ formContext,
41
+ schema,
42
+ uiSchema,
43
+ rawErrors = [],
44
+ registry,
45
+ } = props;
46
+ const TitleFieldTemplate = getTemplate<'TitleFieldTemplate', T, S, F>('TitleFieldTemplate', registry, options);
47
+ const { enumOptions, enumDisabled, inline } = options;
48
+ const checkboxesValues = Array.isArray(value) ? value : [value];
49
+ const semanticProps = getSemanticProps<T, S, F>({
50
+ options,
51
+ formContext,
52
+ uiSchema,
53
+ defaultSchemaProps: {
54
+ inverted: 'false',
55
+ },
56
+ });
57
+ const _onChange =
58
+ (index: number) =>
59
+ ({ target: { checked } }: ChangeEvent<HTMLInputElement>) => {
60
+ // eslint-disable-next-line no-shadow
61
+ if (checked) {
62
+ onChange(enumOptionsSelectValue<S>(index, checkboxesValues, enumOptions));
63
+ } else {
64
+ onChange(enumOptionsDeselectValue<S>(index, checkboxesValues, enumOptions));
65
+ }
66
+ };
67
+
68
+ const _onBlur = () => onBlur(id, value);
69
+ const _onFocus = () => onFocus(id, value);
70
+ const inlineOption = inline ? { inline: true } : { grouped: true };
71
+ return (
72
+ <>
73
+ {!hideLabel && !!label && (
74
+ <TitleFieldTemplate id={titleId<T>(id)} title={label} schema={schema} uiSchema={uiSchema} registry={registry} />
75
+ )}
76
+ <Form.Group id={id} name={id} {...inlineOption}>
77
+ {Array.isArray(enumOptions) &&
78
+ enumOptions.map((option, index) => {
79
+ const checked = enumOptionsIsSelected<S>(option.value, checkboxesValues);
80
+ const itemDisabled = Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) !== -1;
81
+ return (
82
+ <Form.Checkbox
83
+ id={optionId(id, index)}
84
+ name={id}
85
+ key={index}
86
+ label={option.label}
87
+ {...semanticProps}
88
+ checked={checked}
89
+ error={rawErrors.length > 0}
90
+ disabled={disabled || itemDisabled || readonly}
91
+ autoFocus={autofocus && index === 0}
92
+ onChange={_onChange(index)}
93
+ onBlur={_onBlur}
94
+ onFocus={_onFocus}
95
+ aria-describedby={ariaDescribedByIds<T>(id)}
96
+ />
97
+ );
98
+ })}
99
+ </Form.Group>
100
+ </>
101
+ );
102
+ }
@@ -0,0 +1,2 @@
1
+ export { default } from './CheckboxesWidget';
2
+ export * from './CheckboxesWidget';
@@ -0,0 +1,21 @@
1
+ import { DescriptionFieldProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
2
+
3
+ /** The `DescriptionField` is the template to use to render the description of a field
4
+ *
5
+ * @param props - The `DescriptionFieldProps` for this component
6
+ */
7
+ export default function DescriptionField<
8
+ T = any,
9
+ S extends StrictRJSFSchema = RJSFSchema,
10
+ F extends FormContextType = any
11
+ >(props: DescriptionFieldProps<T, S, F>) {
12
+ const { id, description } = props;
13
+ if (!description) {
14
+ return null;
15
+ }
16
+ return (
17
+ <p id={id} className='sui-description'>
18
+ {description}
19
+ </p>
20
+ );
21
+ }
@@ -0,0 +1,2 @@
1
+ export { default } from './DescriptionField';
2
+ export * from './DescriptionField';
@@ -0,0 +1,23 @@
1
+ import { Message } from 'semantic-ui-react';
2
+ import { ErrorListProps, FormContextType, RJSFSchema, StrictRJSFSchema, TranslatableString } from '@rjsf/utils';
3
+
4
+ /** The `ErrorList` component is the template that renders the all the errors associated with the fields in the `Form`
5
+ *
6
+ * @param props - The `ErrorListProps` for this component
7
+ */
8
+ export default function ErrorList<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>({
9
+ errors,
10
+ registry,
11
+ }: ErrorListProps<T, S, F>) {
12
+ const { translateString } = registry;
13
+ return (
14
+ <Message negative>
15
+ <Message.Header>{translateString(TranslatableString.ErrorsLabel)}</Message.Header>
16
+ <Message.List>
17
+ {errors.map((error, index) => (
18
+ <Message.Item key={`error-${index}`}>{error.stack}</Message.Item>
19
+ ))}
20
+ </Message.List>
21
+ </Message>
22
+ );
23
+ }
@@ -0,0 +1,2 @@
1
+ export { default } from './ErrorList';
2
+ export * from './ErrorList';
@@ -0,0 +1,43 @@
1
+ import { errorId, FieldErrorProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
2
+ import { nanoid } from 'nanoid';
3
+ import { Label, List } from 'semantic-ui-react';
4
+
5
+ import { getSemanticErrorProps } from '../util';
6
+
7
+ const DEFAULT_OPTIONS = {
8
+ options: {
9
+ pointing: 'above',
10
+ size: 'small',
11
+ },
12
+ };
13
+
14
+ /** The `FieldErrorTemplate` component renders the errors local to the particular field
15
+ *
16
+ * @param props - The `FieldErrorProps` for the errors being rendered
17
+ */
18
+ export default function FieldErrorTemplate<
19
+ T = any,
20
+ S extends StrictRJSFSchema = RJSFSchema,
21
+ F extends FormContextType = any
22
+ >({ errors, idSchema, uiSchema, registry }: FieldErrorProps<T, S, F>) {
23
+ const { formContext } = registry;
24
+ const options = getSemanticErrorProps<T, S, F>({
25
+ formContext,
26
+ uiSchema,
27
+ defaultProps: DEFAULT_OPTIONS,
28
+ });
29
+ const { pointing, size } = options;
30
+ if (errors && errors.length > 0) {
31
+ const id = errorId<T>(idSchema);
32
+ return (
33
+ <Label id={id} color='red' pointing={pointing || 'above'} size={size || 'small'} basic>
34
+ <List bulleted>
35
+ {errors.map((error) => (
36
+ <List.Item key={nanoid()}>{error}</List.Item>
37
+ ))}
38
+ </List>
39
+ </Label>
40
+ );
41
+ }
42
+ return null;
43
+ }
@@ -0,0 +1,2 @@
1
+ export { default } from './FieldErrorTemplate';
2
+ export * from './FieldErrorTemplate';
@@ -0,0 +1,19 @@
1
+ import { Message } from 'semantic-ui-react';
2
+ import { FieldHelpProps, FormContextType, RJSFSchema, StrictRJSFSchema, helpId } from '@rjsf/utils';
3
+
4
+ /** The `FieldHelpTemplate` component renders any help desired for a field
5
+ *
6
+ * @param props - The `FieldHelpProps` to be rendered
7
+ */
8
+ export default function FieldHelpTemplate<
9
+ T = any,
10
+ S extends StrictRJSFSchema = RJSFSchema,
11
+ F extends FormContextType = any
12
+ >(props: FieldHelpProps<T, S, F>) {
13
+ const { idSchema, help } = props;
14
+ if (help) {
15
+ const id = helpId<T>(idSchema);
16
+ return <Message size='mini' info id={id} content={help} />;
17
+ }
18
+ return null;
19
+ }
@@ -0,0 +1,2 @@
1
+ export { default } from './FieldHelpTemplate';
2
+ export * from './FieldHelpTemplate';
@@ -0,0 +1,77 @@
1
+ import {
2
+ FieldTemplateProps,
3
+ FormContextType,
4
+ RJSFSchema,
5
+ StrictRJSFSchema,
6
+ getTemplate,
7
+ getUiOptions,
8
+ } from '@rjsf/utils';
9
+ import { Form } from 'semantic-ui-react';
10
+ import { getSemanticProps, MaybeWrap } from '../util';
11
+
12
+ /** The `FieldTemplate` component is the template used by `SchemaField` to render any field. It renders the field
13
+ * content, (label, description, children, errors and help) inside of a `WrapIfAdditional` component.
14
+ *
15
+ * @param props - The `FieldTemplateProps` for this component
16
+ */
17
+ export default function FieldTemplate<
18
+ T = any,
19
+ S extends StrictRJSFSchema = RJSFSchema,
20
+ F extends FormContextType = any
21
+ >(props: FieldTemplateProps<T, S, F>) {
22
+ const {
23
+ id,
24
+ children,
25
+ classNames,
26
+ style,
27
+ displayLabel,
28
+ label,
29
+ errors,
30
+ help,
31
+ hidden,
32
+ description,
33
+ rawDescription,
34
+ registry,
35
+ schema,
36
+ uiSchema,
37
+ ...otherProps
38
+ } = props;
39
+ const semanticProps = getSemanticProps<T, S, F>(otherProps);
40
+ const { wrapLabel, wrapContent } = semanticProps;
41
+ const uiOptions = getUiOptions<T, S, F>(uiSchema);
42
+ const WrapIfAdditionalTemplate = getTemplate<'WrapIfAdditionalTemplate', T, S, F>(
43
+ 'WrapIfAdditionalTemplate',
44
+ registry,
45
+ uiOptions
46
+ );
47
+
48
+ if (hidden) {
49
+ return <div style={{ display: 'none' }}>{children}</div>;
50
+ }
51
+
52
+ return (
53
+ <WrapIfAdditionalTemplate
54
+ classNames={classNames}
55
+ style={style}
56
+ id={id}
57
+ label={label}
58
+ registry={registry}
59
+ schema={schema}
60
+ uiSchema={uiSchema}
61
+ {...otherProps}
62
+ >
63
+ <Form.Group key={id} widths='equal' grouped>
64
+ <MaybeWrap wrap={wrapContent} className='sui-field-content'>
65
+ {children}
66
+ {displayLabel && rawDescription && (
67
+ <MaybeWrap wrap={wrapLabel} className='sui-field-label'>
68
+ {description}
69
+ </MaybeWrap>
70
+ )}
71
+ {help}
72
+ {errors}
73
+ </MaybeWrap>
74
+ </Form.Group>
75
+ </WrapIfAdditionalTemplate>
76
+ );
77
+ }
@@ -0,0 +1,2 @@
1
+ export { default } from './FieldTemplate';
2
+ export * from './FieldTemplate';
@@ -0,0 +1,55 @@
1
+ import { Button, ButtonProps } from 'semantic-ui-react';
2
+ import { FormContextType, IconButtonProps, RJSFSchema, StrictRJSFSchema, TranslatableString } from '@rjsf/utils';
3
+
4
+ function IconButton<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
5
+ props: IconButtonProps<T, S, F>
6
+ ) {
7
+ const { icon, iconType, color, className, uiSchema, registry, ...otherProps } = props;
8
+ return (
9
+ <Button
10
+ icon={icon}
11
+ size={iconType as ButtonProps['size']}
12
+ color={color as ButtonProps['color']}
13
+ className={className}
14
+ {...otherProps}
15
+ />
16
+ );
17
+ }
18
+
19
+ export default IconButton;
20
+
21
+ export function CopyButton<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
22
+ props: IconButtonProps<T, S, F>
23
+ ) {
24
+ const {
25
+ registry: { translateString },
26
+ } = props;
27
+ return <IconButton title={translateString(TranslatableString.CopyButton)} {...props} icon='copy' />;
28
+ }
29
+
30
+ export function MoveDownButton<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
31
+ props: IconButtonProps<T, S, F>
32
+ ) {
33
+ const {
34
+ registry: { translateString },
35
+ } = props;
36
+ return <IconButton title={translateString(TranslatableString.MoveDownButton)} {...props} icon='angle down' />;
37
+ }
38
+
39
+ export function MoveUpButton<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
40
+ props: IconButtonProps<T, S, F>
41
+ ) {
42
+ const {
43
+ registry: { translateString },
44
+ } = props;
45
+ return <IconButton title={translateString(TranslatableString.MoveUpButton)} {...props} icon='angle up' />;
46
+ }
47
+
48
+ export function RemoveButton<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
49
+ props: IconButtonProps<T, S, F>
50
+ ) {
51
+ const {
52
+ registry: { translateString },
53
+ } = props;
54
+ return <IconButton title={translateString(TranslatableString.RemoveButton)} {...props} icon='trash' />;
55
+ }
@@ -0,0 +1,2 @@
1
+ export { default } from './IconButton';
2
+ export * from './IconButton';
@@ -0,0 +1,94 @@
1
+ import { Grid } from 'semantic-ui-react';
2
+ import {
3
+ FormContextType,
4
+ ObjectFieldTemplateProps,
5
+ RJSFSchema,
6
+ StrictRJSFSchema,
7
+ canExpand,
8
+ descriptionId,
9
+ getTemplate,
10
+ getUiOptions,
11
+ titleId,
12
+ } from '@rjsf/utils';
13
+
14
+ /** The `ObjectFieldTemplate` is the template to use to render all the inner properties of an object along with the
15
+ * title and description if available. If the object is expandable, then an `AddButton` is also rendered after all
16
+ * the properties.
17
+ *
18
+ * @param props - The `ObjectFieldTemplateProps` for this component
19
+ */
20
+ export default function ObjectFieldTemplate<
21
+ T = any,
22
+ S extends StrictRJSFSchema = RJSFSchema,
23
+ F extends FormContextType = any
24
+ >(props: ObjectFieldTemplateProps<T, S, F>) {
25
+ const {
26
+ description,
27
+ onAddClick,
28
+ title,
29
+ properties,
30
+ disabled,
31
+ readonly,
32
+ required,
33
+ uiSchema,
34
+ schema,
35
+ formData,
36
+ idSchema,
37
+ registry,
38
+ } = props;
39
+ const uiOptions = getUiOptions<T, S, F>(uiSchema);
40
+ const TitleFieldTemplate = getTemplate<'TitleFieldTemplate', T, S, F>('TitleFieldTemplate', registry, uiOptions);
41
+ const DescriptionFieldTemplate = getTemplate<'DescriptionFieldTemplate', T, S, F>(
42
+ 'DescriptionFieldTemplate',
43
+ registry,
44
+ uiOptions
45
+ );
46
+ // Button templates are not overridden in the uiSchema
47
+ const {
48
+ ButtonTemplates: { AddButton },
49
+ } = registry.templates;
50
+ return (
51
+ <>
52
+ {title && (
53
+ <TitleFieldTemplate
54
+ id={titleId<T>(idSchema)}
55
+ title={title}
56
+ required={required}
57
+ schema={schema}
58
+ uiSchema={uiSchema}
59
+ registry={registry}
60
+ />
61
+ )}
62
+ {description && (
63
+ <DescriptionFieldTemplate
64
+ id={descriptionId<T>(idSchema)}
65
+ description={description}
66
+ schema={schema}
67
+ uiSchema={uiSchema}
68
+ registry={registry}
69
+ />
70
+ )}
71
+ {properties.map((prop) => prop.content)}
72
+ {canExpand<T, S, F>(schema, uiSchema, formData) && (
73
+ <Grid.Column width={16} verticalAlign='middle'>
74
+ <Grid.Row>
75
+ <div
76
+ style={{
77
+ marginTop: '1rem',
78
+ position: 'relative',
79
+ textAlign: 'right',
80
+ }}
81
+ >
82
+ <AddButton
83
+ onClick={onAddClick(schema)}
84
+ disabled={disabled || readonly}
85
+ uiSchema={uiSchema}
86
+ registry={registry}
87
+ />
88
+ </div>
89
+ </Grid.Row>
90
+ </Grid.Column>
91
+ )}
92
+ </>
93
+ );
94
+ }
@@ -0,0 +1,2 @@
1
+ export { default } from './ObjectFieldTemplate';
2
+ export * from './ObjectFieldTemplate';