@rjsf/semantic-ui 6.6.1 → 6.7.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/LICENSE.md +201 -0
- package/dist/index.cjs +268 -241
- package/dist/index.cjs.map +4 -4
- package/dist/semantic-ui.esm.js +209 -218
- package/dist/semantic-ui.esm.js.map +4 -4
- package/dist/semantic-ui.umd.js +117 -96
- package/lib/AddButton/AddButton.d.ts +3 -3
- package/lib/AddButton/AddButton.js.map +1 -1
- package/lib/ArrayFieldItemTemplate/ArrayFieldItemTemplate.d.ts +2 -2
- package/lib/ArrayFieldItemTemplate/ArrayFieldItemTemplate.js +1 -1
- package/lib/ArrayFieldItemTemplate/ArrayFieldItemTemplate.js.map +1 -1
- package/lib/ArrayFieldTemplate/ArrayFieldTemplate.d.ts +2 -2
- package/lib/ArrayFieldTemplate/ArrayFieldTemplate.js +1 -1
- package/lib/ArrayFieldTemplate/ArrayFieldTemplate.js.map +1 -1
- package/lib/BaseInputTemplate/BaseInputTemplate.d.ts +2 -2
- package/lib/BaseInputTemplate/BaseInputTemplate.js +6 -6
- package/lib/BaseInputTemplate/BaseInputTemplate.js.map +1 -1
- package/lib/CheckboxWidget/CheckboxWidget.d.ts +2 -2
- package/lib/CheckboxWidget/CheckboxWidget.js +7 -7
- package/lib/CheckboxWidget/CheckboxWidget.js.map +1 -1
- package/lib/CheckboxesWidget/CheckboxesWidget.d.ts +2 -2
- package/lib/CheckboxesWidget/CheckboxesWidget.js +6 -6
- package/lib/CheckboxesWidget/CheckboxesWidget.js.map +1 -1
- package/lib/CyclicSchemaExpandTemplate/CyclicSchemaExpandTemplate.d.ts +6 -0
- package/lib/CyclicSchemaExpandTemplate/CyclicSchemaExpandTemplate.js +14 -0
- package/lib/CyclicSchemaExpandTemplate/CyclicSchemaExpandTemplate.js.map +1 -0
- package/lib/CyclicSchemaExpandTemplate/index.d.ts +2 -0
- package/lib/CyclicSchemaExpandTemplate/index.js +3 -0
- package/lib/CyclicSchemaExpandTemplate/index.js.map +1 -0
- package/lib/DescriptionField/DescriptionField.d.ts +2 -2
- package/lib/ErrorList/ErrorList.d.ts +2 -2
- package/lib/ErrorList/ErrorList.js.map +1 -1
- package/lib/FieldErrorTemplate/FieldErrorTemplate.d.ts +2 -2
- package/lib/FieldErrorTemplate/FieldErrorTemplate.js.map +1 -1
- package/lib/FieldHelpTemplate/FieldHelpTemplate.d.ts +2 -2
- package/lib/FieldHelpTemplate/FieldHelpTemplate.js.map +1 -1
- package/lib/FieldTemplate/FieldTemplate.d.ts +2 -2
- package/lib/FieldTemplate/FieldTemplate.js +1 -1
- package/lib/FieldTemplate/FieldTemplate.js.map +1 -1
- package/lib/GridTemplate/GridTemplate.d.ts +2 -2
- package/lib/IconButton/IconButton.d.ts +15 -8
- package/lib/IconButton/IconButton.js +14 -6
- package/lib/IconButton/IconButton.js.map +1 -1
- package/lib/MultiSchemaFieldTemplate/MultiSchemaFieldTemplate.d.ts +2 -2
- package/lib/ObjectFieldTemplate/ObjectFieldTemplate.d.ts +2 -2
- package/lib/ObjectFieldTemplate/ObjectFieldTemplate.js +1 -1
- package/lib/ObjectFieldTemplate/ObjectFieldTemplate.js.map +1 -1
- package/lib/OptionalDataControlsTemplate/OptionalDataControlsTemplate.d.ts +2 -2
- package/lib/OptionalDataControlsTemplate/OptionalDataControlsTemplate.js +1 -1
- package/lib/OptionalDataControlsTemplate/OptionalDataControlsTemplate.js.map +1 -1
- package/lib/RadioWidget/RadioWidget.d.ts +2 -2
- package/lib/RadioWidget/RadioWidget.js +5 -7
- package/lib/RadioWidget/RadioWidget.js.map +1 -1
- package/lib/RangeWidget/RangeWidget.d.ts +2 -2
- package/lib/RangeWidget/RangeWidget.js +5 -5
- package/lib/RangeWidget/RangeWidget.js.map +1 -1
- package/lib/SelectWidget/SelectWidget.d.ts +2 -2
- package/lib/SelectWidget/SelectWidget.js +8 -8
- package/lib/SelectWidget/SelectWidget.js.map +1 -1
- package/lib/SemanticUIForm/SemanticUIForm.d.ts +3 -3
- package/lib/SemanticUIForm/SemanticUIForm.js.map +1 -1
- package/lib/SubmitButton/SubmitButton.d.ts +2 -2
- package/lib/SubmitButton/SubmitButton.js.map +1 -1
- package/lib/Templates/Templates.d.ts +1 -1
- package/lib/Templates/Templates.js +2 -0
- package/lib/Templates/Templates.js.map +1 -1
- package/lib/TextareaWidget/TextareaWidget.d.ts +2 -2
- package/lib/TextareaWidget/TextareaWidget.js +6 -6
- package/lib/TextareaWidget/TextareaWidget.js.map +1 -1
- package/lib/Theme/Theme.d.ts +2 -2
- package/lib/TitleField/TitleField.d.ts +2 -2
- package/lib/Widgets/Widgets.d.ts +1 -1
- package/lib/WrapIfAdditionalTemplate/WrapIfAdditionalTemplate.d.ts +2 -2
- package/lib/WrapIfAdditionalTemplate/WrapIfAdditionalTemplate.js +2 -2
- package/lib/WrapIfAdditionalTemplate/WrapIfAdditionalTemplate.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/util.d.ts +7 -7
- package/lib/util.js +13 -6
- package/lib/util.js.map +1 -1
- package/package.json +25 -23
- package/src/AddButton/AddButton.tsx +5 -3
- package/src/ArrayFieldItemTemplate/ArrayFieldItemTemplate.tsx +2 -8
- package/src/ArrayFieldTemplate/ArrayFieldTemplate.tsx +2 -10
- package/src/BaseInputTemplate/BaseInputTemplate.tsx +13 -20
- package/src/CheckboxWidget/CheckboxWidget.tsx +13 -21
- package/src/CheckboxesWidget/CheckboxesWidget.tsx +11 -14
- package/src/CyclicSchemaExpandTemplate/CyclicSchemaExpandTemplate.tsx +25 -0
- package/src/CyclicSchemaExpandTemplate/index.ts +2 -0
- package/src/DescriptionField/DescriptionField.tsx +1 -1
- package/src/ErrorList/ErrorList.tsx +3 -1
- package/src/FieldErrorTemplate/FieldErrorTemplate.tsx +2 -1
- package/src/FieldHelpTemplate/FieldHelpTemplate.tsx +2 -1
- package/src/FieldTemplate/FieldTemplate.tsx +2 -8
- package/src/GridTemplate/GridTemplate.tsx +1 -1
- package/src/IconButton/IconButton.tsx +18 -8
- package/src/MultiSchemaFieldTemplate/MultiSchemaFieldTemplate.tsx +1 -1
- package/src/ObjectFieldTemplate/ObjectFieldTemplate.tsx +2 -12
- package/src/OptionalDataControlsTemplate/OptionalDataControlsTemplate.tsx +3 -2
- package/src/RadioWidget/RadioWidget.tsx +13 -16
- package/src/RangeWidget/RangeWidget.tsx +11 -10
- package/src/SelectWidget/SelectWidget.tsx +45 -37
- package/src/SemanticUIForm/SemanticUIForm.ts +4 -3
- package/src/SubmitButton/SubmitButton.tsx +2 -1
- package/src/Templates/Templates.ts +3 -1
- package/src/TextareaWidget/TextareaWidget.tsx +11 -17
- package/src/Theme/Theme.ts +2 -2
- package/src/TitleField/TitleField.tsx +1 -1
- package/src/Widgets/Widgets.tsx +1 -1
- package/src/WrapIfAdditionalTemplate/WrapIfAdditionalTemplate.tsx +6 -13
- package/src/util.tsx +20 -21
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { FormEvent } from 'react';
|
|
1
|
+
import type { FormEvent } from 'react';
|
|
2
|
+
import type { FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps } from '@rjsf/utils';
|
|
2
3
|
import {
|
|
3
4
|
ariaDescribedByIds,
|
|
4
5
|
enumOptionValueDecoder,
|
|
@@ -6,12 +7,9 @@ import {
|
|
|
6
7
|
enumOptionsIsSelected,
|
|
7
8
|
getOptionValueFormat,
|
|
8
9
|
optionId,
|
|
9
|
-
FormContextType,
|
|
10
|
-
RJSFSchema,
|
|
11
|
-
StrictRJSFSchema,
|
|
12
|
-
WidgetProps,
|
|
13
10
|
} from '@rjsf/utils';
|
|
14
|
-
import { CheckboxProps
|
|
11
|
+
import type { CheckboxProps } from 'semantic-ui-react';
|
|
12
|
+
import { Form, Radio } from 'semantic-ui-react';
|
|
15
13
|
|
|
16
14
|
import { getSemanticProps } from '../util';
|
|
17
15
|
|
|
@@ -45,19 +43,18 @@ export default function RadioWidget<T = any, S extends StrictRJSFSchema = RJSFSc
|
|
|
45
43
|
options,
|
|
46
44
|
uiSchema,
|
|
47
45
|
});
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
};
|
|
46
|
+
const handleChange = (_: FormEvent<HTMLInputElement>, { value: eventValue }: CheckboxProps) =>
|
|
47
|
+
onChange(enumOptionValueDecoder<S>(String(eventValue!), enumOptions, optionValueFormat, emptyValue));
|
|
51
48
|
|
|
52
|
-
const
|
|
53
|
-
const
|
|
49
|
+
const handleBlur = () => onBlur(id, value);
|
|
50
|
+
const handleFocus = () => onFocus(id, value);
|
|
54
51
|
const inlineOption = options.inline ? { inline: true } : { grouped: true };
|
|
55
52
|
return (
|
|
56
53
|
<Form.Group {...inlineOption}>
|
|
57
54
|
{Array.isArray(enumOptions) &&
|
|
58
55
|
enumOptions.map((option, index) => {
|
|
59
56
|
const checked = enumOptionsIsSelected<S>(option.value, value);
|
|
60
|
-
const itemDisabled = Array.isArray(enumDisabled) && enumDisabled.
|
|
57
|
+
const itemDisabled = Array.isArray(enumDisabled) && enumDisabled.includes(option.value);
|
|
61
58
|
return (
|
|
62
59
|
<Form.Field
|
|
63
60
|
required={required}
|
|
@@ -65,13 +62,13 @@ export default function RadioWidget<T = any, S extends StrictRJSFSchema = RJSFSc
|
|
|
65
62
|
id={optionId(id, index)}
|
|
66
63
|
name={htmlName || id}
|
|
67
64
|
{...semanticProps}
|
|
68
|
-
onFocus={
|
|
69
|
-
onBlur={
|
|
70
|
-
onChange={
|
|
65
|
+
onFocus={handleFocus}
|
|
66
|
+
onBlur={handleBlur}
|
|
67
|
+
onChange={handleChange}
|
|
71
68
|
label={option.label}
|
|
72
69
|
value={enumOptionValueEncoder(option.value, index, optionValueFormat)}
|
|
73
70
|
error={rawErrors.length > 0}
|
|
74
|
-
key={
|
|
71
|
+
key={String(option.value)}
|
|
75
72
|
checked={checked}
|
|
76
73
|
disabled={disabled || itemDisabled || readonly}
|
|
77
74
|
aria-describedby={ariaDescribedByIds(id)}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { ChangeEvent } from 'react';
|
|
2
|
-
import {
|
|
1
|
+
import type { ChangeEvent } from 'react';
|
|
2
|
+
import type { FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps } from '@rjsf/utils';
|
|
3
|
+
import { ariaDescribedByIds, rangeSpec } from '@rjsf/utils';
|
|
3
4
|
import { Input } from 'semantic-ui-react';
|
|
4
5
|
|
|
5
6
|
import { getSemanticProps } from '../util';
|
|
@@ -36,11 +37,11 @@ export default function RangeWidget<T = any, S extends StrictRJSFSchema = RJSFSc
|
|
|
36
37
|
},
|
|
37
38
|
});
|
|
38
39
|
|
|
39
|
-
//
|
|
40
|
-
const
|
|
41
|
-
onChange
|
|
42
|
-
const
|
|
43
|
-
const
|
|
40
|
+
// oxlint-disable-next-line no-shadow
|
|
41
|
+
const handleChange = ({ target: { value } }: ChangeEvent<HTMLInputElement>) =>
|
|
42
|
+
onChange?.(value === '' ? options.emptyValue : value);
|
|
43
|
+
const handleBlur = () => onBlur?.(id, value);
|
|
44
|
+
const handleFocus = () => onFocus?.(id, value);
|
|
44
45
|
|
|
45
46
|
return (
|
|
46
47
|
<>
|
|
@@ -55,9 +56,9 @@ export default function RangeWidget<T = any, S extends StrictRJSFSchema = RJSFSc
|
|
|
55
56
|
{...semanticProps}
|
|
56
57
|
value={value || ''}
|
|
57
58
|
error={rawErrors.length > 0}
|
|
58
|
-
onChange={
|
|
59
|
-
onBlur={
|
|
60
|
-
onFocus={
|
|
59
|
+
onChange={handleChange}
|
|
60
|
+
onBlur={handleBlur}
|
|
61
|
+
onFocus={handleFocus}
|
|
61
62
|
aria-describedby={ariaDescribedByIds(id)}
|
|
62
63
|
/>
|
|
63
64
|
<span>{value}</span>
|
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
import { FocusEvent, SyntheticEvent } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
ariaDescribedByIds,
|
|
4
|
-
enumOptionSelectedValue,
|
|
5
|
-
enumOptionValueDecoder,
|
|
6
|
-
enumOptionValueEncoder,
|
|
7
|
-
getOptionValueFormat,
|
|
8
|
-
labelValue,
|
|
1
|
+
import type { FocusEvent, SyntheticEvent } from 'react';
|
|
2
|
+
import type {
|
|
9
3
|
EnumOptionsType,
|
|
10
4
|
FormContextType,
|
|
11
5
|
OptionValueFormat,
|
|
@@ -14,8 +8,19 @@ import {
|
|
|
14
8
|
WidgetProps,
|
|
15
9
|
UIOptionsType,
|
|
16
10
|
} from '@rjsf/utils';
|
|
11
|
+
import {
|
|
12
|
+
ariaDescribedByIds,
|
|
13
|
+
enumOptionSelectedValue,
|
|
14
|
+
enumOptionValueDecoder,
|
|
15
|
+
enumOptionValueEncoder,
|
|
16
|
+
getOptionValueFormat,
|
|
17
|
+
labelValue,
|
|
18
|
+
logUnsupportedDefaultForEnum,
|
|
19
|
+
SelectedOptionDescription,
|
|
20
|
+
} from '@rjsf/utils';
|
|
17
21
|
import map from 'lodash/map';
|
|
18
|
-
import {
|
|
22
|
+
import type { DropdownProps, DropdownItemProps } from 'semantic-ui-react';
|
|
23
|
+
import { Form } from 'semantic-ui-react';
|
|
19
24
|
|
|
20
25
|
import { getSemanticProps } from '../util';
|
|
21
26
|
|
|
@@ -36,7 +41,7 @@ function createDefaultValueOptionsForDropDown<S extends StrictRJSFSchema = RJSFS
|
|
|
36
41
|
) {
|
|
37
42
|
const disabledOptions = enumDisabled || [];
|
|
38
43
|
const options: DropdownItemProps[] = map(enumOptions, ({ label, value }, index) => ({
|
|
39
|
-
disabled: disabledOptions.
|
|
44
|
+
disabled: disabledOptions.includes(value),
|
|
40
45
|
key: label,
|
|
41
46
|
text: label,
|
|
42
47
|
value: enumOptionValueEncoder(value, index, format),
|
|
@@ -92,6 +97,7 @@ export default function SelectWidget<T = any, S extends StrictRJSFSchema = RJSFS
|
|
|
92
97
|
const emptyValue = multiple ? [] : '';
|
|
93
98
|
const optionValueFormat = getOptionValueFormat(options);
|
|
94
99
|
const showPlaceholderOption = !multiple && schema.default === undefined;
|
|
100
|
+
logUnsupportedDefaultForEnum<S>(id, schema, enumOptions, multiple);
|
|
95
101
|
const dropdownOptions = createDefaultValueOptionsForDropDown<S>(
|
|
96
102
|
enumOptions,
|
|
97
103
|
enumDisabled,
|
|
@@ -99,33 +105,35 @@ export default function SelectWidget<T = any, S extends StrictRJSFSchema = RJSFS
|
|
|
99
105
|
placeholder,
|
|
100
106
|
optionValueFormat,
|
|
101
107
|
);
|
|
102
|
-
const
|
|
103
|
-
onChange(enumOptionValueDecoder<S>(
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
onFocus(id, enumOptionValueDecoder<S>(target && target.value, enumOptions, optionValueFormat, optEmptyVal));
|
|
108
|
+
const handleChange = (_: SyntheticEvent<HTMLElement>, { value: enumValue }: DropdownProps) =>
|
|
109
|
+
onChange(enumOptionValueDecoder<S>(enumValue as string[], enumOptions, optionValueFormat, optEmptyVal));
|
|
110
|
+
const handleBlur = (_: FocusEvent<HTMLElement>, { target }: DropdownProps) =>
|
|
111
|
+
onBlur(id, enumOptionValueDecoder<S>(target?.value, enumOptions, optionValueFormat, optEmptyVal));
|
|
112
|
+
const handleFocus = (_: FocusEvent<HTMLElement>, { target }: DropdownProps) =>
|
|
113
|
+
onFocus(id, enumOptionValueDecoder<S>(target?.value, enumOptions, optionValueFormat, optEmptyVal));
|
|
109
114
|
return (
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
115
|
+
<>
|
|
116
|
+
<Form.Dropdown
|
|
117
|
+
key={id}
|
|
118
|
+
id={id}
|
|
119
|
+
name={htmlName || id}
|
|
120
|
+
label={labelValue(label || undefined, hideLabel, false)}
|
|
121
|
+
multiple={typeof multiple === 'undefined' ? false : multiple}
|
|
122
|
+
value={enumOptionSelectedValue<S>(value, enumOptions, !!multiple, optionValueFormat, emptyValue)}
|
|
123
|
+
error={rawErrors.length > 0}
|
|
124
|
+
disabled={disabled}
|
|
125
|
+
placeholder={placeholder}
|
|
126
|
+
{...semanticProps}
|
|
127
|
+
required={required}
|
|
128
|
+
autoFocus={autofocus}
|
|
129
|
+
readOnly={readonly}
|
|
130
|
+
options={dropdownOptions}
|
|
131
|
+
onChange={handleChange}
|
|
132
|
+
onBlur={handleBlur}
|
|
133
|
+
onFocus={handleFocus}
|
|
134
|
+
aria-describedby={ariaDescribedByIds(id)}
|
|
135
|
+
/>
|
|
136
|
+
<SelectedOptionDescription {...props} />
|
|
137
|
+
</>
|
|
130
138
|
);
|
|
131
139
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { ComponentType } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import type { ComponentType } from 'react';
|
|
2
|
+
import type { FormProps } from '@rjsf/core';
|
|
3
|
+
import { withTheme } from '@rjsf/core';
|
|
4
|
+
import type { FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
4
5
|
|
|
5
6
|
import { generateTheme } from '../Theme';
|
|
6
7
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { FormContextType, RJSFSchema, StrictRJSFSchema, SubmitButtonProps } from '@rjsf/utils';
|
|
2
|
+
import { getSubmitButtonOptions } from '@rjsf/utils';
|
|
2
3
|
import { Button } from 'semantic-ui-react';
|
|
3
4
|
|
|
4
5
|
/** The `SubmitButton` renders a button that represent the `Submit` action on a form
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { FormContextType, RJSFSchema, StrictRJSFSchema, TemplatesType } from '@rjsf/utils';
|
|
1
|
+
import type { FormContextType, RJSFSchema, StrictRJSFSchema, TemplatesType } from '@rjsf/utils';
|
|
2
2
|
|
|
3
3
|
import AddButton from '../AddButton';
|
|
4
4
|
import ArrayFieldItemTemplate from '../ArrayFieldItemTemplate';
|
|
5
5
|
import ArrayFieldTemplate from '../ArrayFieldTemplate';
|
|
6
6
|
import BaseInputTemplate from '../BaseInputTemplate';
|
|
7
|
+
import CyclicSchemaExpandTemplate from '../CyclicSchemaExpandTemplate';
|
|
7
8
|
import DescriptionField from '../DescriptionField';
|
|
8
9
|
import ErrorList from '../ErrorList';
|
|
9
10
|
import FieldErrorTemplate from '../FieldErrorTemplate';
|
|
@@ -27,6 +28,7 @@ export function generateTemplates<
|
|
|
27
28
|
ArrayFieldItemTemplate,
|
|
28
29
|
ArrayFieldTemplate,
|
|
29
30
|
BaseInputTemplate,
|
|
31
|
+
CyclicSchemaExpandTemplate,
|
|
30
32
|
ButtonTemplates: {
|
|
31
33
|
AddButton,
|
|
32
34
|
CopyButton,
|
|
@@ -1,12 +1,6 @@
|
|
|
1
|
-
import { ChangeEvent } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
labelValue,
|
|
5
|
-
FormContextType,
|
|
6
|
-
RJSFSchema,
|
|
7
|
-
StrictRJSFSchema,
|
|
8
|
-
WidgetProps,
|
|
9
|
-
} from '@rjsf/utils';
|
|
1
|
+
import type { ChangeEvent } from 'react';
|
|
2
|
+
import type { FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps } from '@rjsf/utils';
|
|
3
|
+
import { ariaDescribedByIds, labelValue } from '@rjsf/utils';
|
|
10
4
|
import { Form } from 'semantic-ui-react';
|
|
11
5
|
|
|
12
6
|
import { getSemanticProps } from '../util';
|
|
@@ -43,11 +37,11 @@ export default function TextareaWidget<
|
|
|
43
37
|
options,
|
|
44
38
|
defaultSchemaProps: { inverted: 'false' },
|
|
45
39
|
});
|
|
46
|
-
//
|
|
47
|
-
const
|
|
48
|
-
onChange
|
|
49
|
-
const
|
|
50
|
-
const
|
|
40
|
+
// oxlint-disable-next-line no-shadow
|
|
41
|
+
const handleChange = ({ target: { value } }: ChangeEvent<HTMLTextAreaElement>) =>
|
|
42
|
+
onChange?.(value === '' ? options.emptyValue : value);
|
|
43
|
+
const handleBlur = () => onBlur?.(id, value);
|
|
44
|
+
const handleFocus = () => onFocus?.(id, value);
|
|
51
45
|
return (
|
|
52
46
|
<Form.TextArea
|
|
53
47
|
id={id}
|
|
@@ -62,9 +56,9 @@ export default function TextareaWidget<
|
|
|
62
56
|
value={value || ''}
|
|
63
57
|
error={rawErrors.length > 0}
|
|
64
58
|
rows={options.rows || 5}
|
|
65
|
-
onChange={
|
|
66
|
-
onBlur={
|
|
67
|
-
onFocus={
|
|
59
|
+
onChange={handleChange}
|
|
60
|
+
onBlur={handleBlur}
|
|
61
|
+
onFocus={handleFocus}
|
|
68
62
|
aria-describedby={ariaDescribedByIds(id)}
|
|
69
63
|
/>
|
|
70
64
|
);
|
package/src/Theme/Theme.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ThemeProps } from '@rjsf/core';
|
|
2
|
-
import { FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
1
|
+
import type { ThemeProps } from '@rjsf/core';
|
|
2
|
+
import type { FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
3
3
|
import { Form as SuiForm } from 'semantic-ui-react';
|
|
4
4
|
|
|
5
5
|
import { generateTemplates } from '../Templates';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FormContextType, TitleFieldProps, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
1
|
+
import type { FormContextType, TitleFieldProps, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
2
2
|
import { Grid, Header } from 'semantic-ui-react';
|
|
3
3
|
|
|
4
4
|
import { getSemanticProps } from '../util';
|
package/src/Widgets/Widgets.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FormContextType, RegistryWidgetsType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
1
|
+
import type { FormContextType, RegistryWidgetsType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
2
2
|
|
|
3
3
|
import CheckboxesWidget from '../CheckboxesWidget/CheckboxesWidget';
|
|
4
4
|
import CheckboxWidget from '../CheckboxWidget/CheckboxWidget';
|
|
@@ -1,12 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
buttonId,
|
|
4
|
-
FormContextType,
|
|
5
|
-
RJSFSchema,
|
|
6
|
-
StrictRJSFSchema,
|
|
7
|
-
TranslatableString,
|
|
8
|
-
WrapIfAdditionalTemplateProps,
|
|
9
|
-
} from '@rjsf/utils';
|
|
1
|
+
import type { FormContextType, RJSFSchema, StrictRJSFSchema, WrapIfAdditionalTemplateProps } from '@rjsf/utils';
|
|
2
|
+
import { ADDITIONAL_PROPERTY_FLAG, buttonId, TranslatableString } from '@rjsf/utils';
|
|
10
3
|
import { Form, Grid } from 'semantic-ui-react';
|
|
11
4
|
|
|
12
5
|
/** The `WrapIfAdditional` component is used by the `FieldTemplate` to rename, or remove properties that are
|
|
@@ -64,17 +57,17 @@ export default function WrapIfAdditionalTemplate<
|
|
|
64
57
|
className='form-group'
|
|
65
58
|
hasFeedback
|
|
66
59
|
fluid
|
|
67
|
-
htmlFor={
|
|
60
|
+
htmlFor={id}
|
|
68
61
|
label={displayLabel ? keyLabel : undefined}
|
|
69
62
|
required={required}
|
|
70
63
|
defaultValue={label}
|
|
71
64
|
disabled={disabled || (readonlyAsDisabled && readonly)}
|
|
72
|
-
id={
|
|
73
|
-
name={
|
|
65
|
+
id={id}
|
|
66
|
+
name={id}
|
|
74
67
|
onBlur={!readonly ? onKeyRenameBlur : undefined}
|
|
75
68
|
style={wrapperStyle}
|
|
76
69
|
type='text'
|
|
77
|
-
|
|
70
|
+
/>
|
|
78
71
|
</Form.Group>
|
|
79
72
|
</Grid.Column>
|
|
80
73
|
<Grid.Column width={7} className='form-additional' verticalAlign='middle'>
|
package/src/util.tsx
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
import { ElementType } from 'react';
|
|
2
|
-
import {
|
|
1
|
+
import type { ElementType } from 'react';
|
|
2
|
+
import type {
|
|
3
3
|
UiSchema,
|
|
4
4
|
GenericObjectType,
|
|
5
|
-
getUiOptions,
|
|
6
5
|
FormContextType,
|
|
7
6
|
RJSFSchema,
|
|
8
7
|
StrictRJSFSchema,
|
|
9
8
|
UIOptionsType,
|
|
10
9
|
} from '@rjsf/utils';
|
|
10
|
+
import { getUiOptions } from '@rjsf/utils';
|
|
11
11
|
|
|
12
|
-
export
|
|
12
|
+
export interface SemanticPropsTypes<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> {
|
|
13
13
|
formContext?: F;
|
|
14
14
|
uiSchema?: UiSchema<T, S, F>;
|
|
15
15
|
options?: UIOptionsType<T, S, F>;
|
|
16
16
|
defaultSchemaProps?: GenericObjectType;
|
|
17
17
|
defaultContextProps?: GenericObjectType;
|
|
18
|
-
}
|
|
18
|
+
}
|
|
19
19
|
|
|
20
|
-
export
|
|
20
|
+
export interface SemanticErrorPropsType<
|
|
21
21
|
T = any,
|
|
22
22
|
S extends StrictRJSFSchema = RJSFSchema,
|
|
23
23
|
F extends FormContextType = any,
|
|
24
|
-
>
|
|
24
|
+
> {
|
|
25
25
|
formContext?: F;
|
|
26
26
|
uiSchema?: UiSchema<T, S, F>;
|
|
27
27
|
options?: UIOptionsType<T, S, F>;
|
|
28
28
|
defaultProps?: GenericObjectType;
|
|
29
|
-
}
|
|
29
|
+
}
|
|
30
30
|
|
|
31
31
|
export type WrapProps = GenericObjectType & {
|
|
32
32
|
wrap: boolean;
|
|
@@ -55,14 +55,13 @@ export function getSemanticProps<T = any, S extends StrictRJSFSchema = RJSFSchem
|
|
|
55
55
|
const schemaProps = getUiOptions<T, S, F>(uiSchema).semantic;
|
|
56
56
|
const optionProps = options.semantic;
|
|
57
57
|
// formContext props should overide other props
|
|
58
|
-
return
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
);
|
|
58
|
+
return {
|
|
59
|
+
...defaultSchemaProps,
|
|
60
|
+
...defaultContextProps,
|
|
61
|
+
...schemaProps,
|
|
62
|
+
...optionProps,
|
|
63
|
+
...formContextProps,
|
|
64
|
+
};
|
|
66
65
|
}
|
|
67
66
|
|
|
68
67
|
/**
|
|
@@ -84,12 +83,12 @@ export function getSemanticErrorProps<
|
|
|
84
83
|
options = {},
|
|
85
84
|
defaultProps = { size: 'small', pointing: 'above' },
|
|
86
85
|
}: SemanticErrorPropsType<T, S, F>) {
|
|
87
|
-
const formContextProps = formContext.semantic
|
|
86
|
+
const formContextProps = formContext.semantic?.errorOptions;
|
|
88
87
|
const semanticOptions: GenericObjectType = getUiOptions<T, S, F>(uiSchema).semantic as GenericObjectType;
|
|
89
|
-
const schemaProps = semanticOptions
|
|
90
|
-
const optionProps =
|
|
88
|
+
const schemaProps = semanticOptions?.errorOptions;
|
|
89
|
+
const optionProps = (options.semantic as GenericObjectType)?.errorOptions;
|
|
91
90
|
|
|
92
|
-
return
|
|
91
|
+
return { ...defaultProps, ...schemaProps, ...optionProps, ...formContextProps };
|
|
93
92
|
}
|
|
94
93
|
|
|
95
94
|
/**
|
|
@@ -101,7 +100,7 @@ export function getSemanticErrorProps<
|
|
|
101
100
|
* @param {Array} omit
|
|
102
101
|
* @returns {string}
|
|
103
102
|
*/
|
|
104
|
-
export function cleanClassNames(classNameArr:
|
|
103
|
+
export function cleanClassNames(classNameArr: (string | undefined)[], omit: string[] = []) {
|
|
105
104
|
// Split each arg on whitespace, and add it to an array. Skip false-y args
|
|
106
105
|
// like "" and undefined.
|
|
107
106
|
const classList = classNameArr
|