@rjsf/semantic-ui 6.6.0 → 6.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +82 -74
- package/dist/index.cjs.map +3 -3
- package/dist/semantic-ui.esm.js +89 -119
- package/dist/semantic-ui.esm.js.map +3 -3
- package/dist/semantic-ui.umd.js +79 -72
- package/lib/AddButton/AddButton.d.ts +2 -2
- package/lib/AddButton/AddButton.js.map +1 -1
- package/lib/ArrayFieldItemTemplate/ArrayFieldItemTemplate.d.ts +1 -1
- package/lib/ArrayFieldItemTemplate/ArrayFieldItemTemplate.js +1 -1
- package/lib/ArrayFieldItemTemplate/ArrayFieldItemTemplate.js.map +1 -1
- package/lib/ArrayFieldTemplate/ArrayFieldTemplate.d.ts +1 -1
- package/lib/ArrayFieldTemplate/ArrayFieldTemplate.js +1 -1
- package/lib/ArrayFieldTemplate/ArrayFieldTemplate.js.map +1 -1
- package/lib/BaseInputTemplate/BaseInputTemplate.d.ts +1 -1
- package/lib/BaseInputTemplate/BaseInputTemplate.js +6 -6
- package/lib/BaseInputTemplate/BaseInputTemplate.js.map +1 -1
- package/lib/CheckboxWidget/CheckboxWidget.d.ts +1 -1
- package/lib/CheckboxWidget/CheckboxWidget.js +6 -6
- package/lib/CheckboxWidget/CheckboxWidget.js.map +1 -1
- package/lib/CheckboxesWidget/CheckboxesWidget.d.ts +1 -1
- package/lib/CheckboxesWidget/CheckboxesWidget.js +6 -6
- package/lib/CheckboxesWidget/CheckboxesWidget.js.map +1 -1
- package/lib/DescriptionField/DescriptionField.d.ts +1 -1
- package/lib/ErrorList/ErrorList.d.ts +1 -1
- package/lib/ErrorList/ErrorList.js.map +1 -1
- package/lib/FieldErrorTemplate/FieldErrorTemplate.d.ts +1 -1
- package/lib/FieldErrorTemplate/FieldErrorTemplate.js.map +1 -1
- package/lib/FieldHelpTemplate/FieldHelpTemplate.d.ts +1 -1
- package/lib/FieldHelpTemplate/FieldHelpTemplate.js.map +1 -1
- package/lib/FieldTemplate/FieldTemplate.d.ts +1 -1
- package/lib/FieldTemplate/FieldTemplate.js +1 -1
- package/lib/FieldTemplate/FieldTemplate.js.map +1 -1
- package/lib/GridTemplate/GridTemplate.d.ts +1 -1
- 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 +1 -1
- package/lib/ObjectFieldTemplate/ObjectFieldTemplate.d.ts +1 -1
- package/lib/ObjectFieldTemplate/ObjectFieldTemplate.js +1 -1
- package/lib/ObjectFieldTemplate/ObjectFieldTemplate.js.map +1 -1
- package/lib/OptionalDataControlsTemplate/OptionalDataControlsTemplate.d.ts +1 -1
- package/lib/OptionalDataControlsTemplate/OptionalDataControlsTemplate.js +1 -1
- package/lib/OptionalDataControlsTemplate/OptionalDataControlsTemplate.js.map +1 -1
- package/lib/RadioWidget/RadioWidget.d.ts +1 -1
- package/lib/RadioWidget/RadioWidget.js +5 -7
- package/lib/RadioWidget/RadioWidget.js.map +1 -1
- package/lib/RangeWidget/RangeWidget.d.ts +1 -1
- package/lib/RangeWidget/RangeWidget.js +5 -5
- package/lib/RangeWidget/RangeWidget.js.map +1 -1
- package/lib/SelectWidget/SelectWidget.d.ts +1 -1
- package/lib/SelectWidget/SelectWidget.js +5 -6
- 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 +1 -1
- package/lib/SubmitButton/SubmitButton.js.map +1 -1
- package/lib/Templates/Templates.d.ts +1 -1
- package/lib/TextareaWidget/TextareaWidget.d.ts +1 -1
- 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 +1 -1
- package/lib/Widgets/Widgets.d.ts +1 -1
- package/lib/WrapIfAdditionalTemplate/WrapIfAdditionalTemplate.d.ts +1 -1
- 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 +9 -3
- package/lib/util.js.map +1 -1
- package/package.json +8 -8
- 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 +12 -20
- package/src/CheckboxesWidget/CheckboxesWidget.tsx +11 -14
- 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 +10 -9
- package/src/SelectWidget/SelectWidget.tsx +20 -18
- package/src/SemanticUIForm/SemanticUIForm.ts +4 -3
- package/src/SubmitButton/SubmitButton.tsx +2 -1
- package/src/Templates/Templates.ts +1 -1
- package/src/TextareaWidget/TextareaWidget.tsx +10 -16
- 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 +17 -18
package/lib/util.d.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { ElementType } from 'react';
|
|
2
|
-
import { UiSchema, GenericObjectType, FormContextType, RJSFSchema, StrictRJSFSchema, UIOptionsType } from '@rjsf/utils';
|
|
3
|
-
export
|
|
1
|
+
import type { ElementType } from 'react';
|
|
2
|
+
import type { UiSchema, GenericObjectType, FormContextType, RJSFSchema, StrictRJSFSchema, UIOptionsType } from '@rjsf/utils';
|
|
3
|
+
export interface SemanticPropsTypes<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> {
|
|
4
4
|
formContext?: F;
|
|
5
5
|
uiSchema?: UiSchema<T, S, F>;
|
|
6
6
|
options?: UIOptionsType<T, S, F>;
|
|
7
7
|
defaultSchemaProps?: GenericObjectType;
|
|
8
8
|
defaultContextProps?: GenericObjectType;
|
|
9
|
-
}
|
|
10
|
-
export
|
|
9
|
+
}
|
|
10
|
+
export interface SemanticErrorPropsType<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> {
|
|
11
11
|
formContext?: F;
|
|
12
12
|
uiSchema?: UiSchema<T, S, F>;
|
|
13
13
|
options?: UIOptionsType<T, S, F>;
|
|
14
14
|
defaultProps?: GenericObjectType;
|
|
15
|
-
}
|
|
15
|
+
}
|
|
16
16
|
export type WrapProps = GenericObjectType & {
|
|
17
17
|
wrap: boolean;
|
|
18
18
|
component?: ElementType;
|
|
@@ -48,7 +48,7 @@ export declare function getSemanticErrorProps<T = any, S extends StrictRJSFSchem
|
|
|
48
48
|
* @param {Array} omit
|
|
49
49
|
* @returns {string}
|
|
50
50
|
*/
|
|
51
|
-
export declare function cleanClassNames(classNameArr:
|
|
51
|
+
export declare function cleanClassNames(classNameArr: (string | undefined)[], omit?: string[]): string;
|
|
52
52
|
/**
|
|
53
53
|
*
|
|
54
54
|
* @param {boolean} wrap
|
package/lib/util.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { getUiOptions
|
|
2
|
+
import { getUiOptions } from '@rjsf/utils';
|
|
3
3
|
/**
|
|
4
4
|
* Extract props meant for semantic UI components from props that are
|
|
5
5
|
* passed to Widgets, Templates and Fields.
|
|
@@ -16,7 +16,13 @@ export function getSemanticProps({ formContext = {}, uiSchema = {}, options = {}
|
|
|
16
16
|
const schemaProps = getUiOptions(uiSchema).semantic;
|
|
17
17
|
const optionProps = options.semantic;
|
|
18
18
|
// formContext props should overide other props
|
|
19
|
-
return
|
|
19
|
+
return {
|
|
20
|
+
...defaultSchemaProps,
|
|
21
|
+
...defaultContextProps,
|
|
22
|
+
...schemaProps,
|
|
23
|
+
...optionProps,
|
|
24
|
+
...formContextProps,
|
|
25
|
+
};
|
|
20
26
|
}
|
|
21
27
|
/**
|
|
22
28
|
* Extract error props meant for semantic UI components from props that are
|
|
@@ -32,7 +38,7 @@ export function getSemanticErrorProps({ formContext = {}, uiSchema = {}, options
|
|
|
32
38
|
const semanticOptions = getUiOptions(uiSchema).semantic;
|
|
33
39
|
const schemaProps = semanticOptions && semanticOptions.errorOptions;
|
|
34
40
|
const optionProps = options.semantic && options.semantic.errorOptions;
|
|
35
|
-
return
|
|
41
|
+
return { ...defaultProps, ...schemaProps, ...optionProps, ...formContextProps };
|
|
36
42
|
}
|
|
37
43
|
/**
|
|
38
44
|
* Combine multiple strings containing class names into a single string,
|
package/lib/util.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.js","sourceRoot":"","sources":["../src/util.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"util.js","sourceRoot":"","sources":["../src/util.tsx"],"names":[],"mappings":";AASA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AA0B3C;;;;;;;;;;GAUG;AACH,MAAM,UAAU,gBAAgB,CAAoF,EAClH,WAAW,GAAG,EAAO,EACrB,QAAQ,GAAG,EAAE,EACb,OAAO,GAAG,EAAE,EACZ,kBAAkB,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,EACrD,mBAAmB,GAAG,EAAE,GACI;IAC5B,MAAM,gBAAgB,GAAG,WAAW,CAAC,QAAQ,CAAC;IAC9C,MAAM,WAAW,GAAG,YAAY,CAAU,QAAQ,CAAC,CAAC,QAAQ,CAAC;IAC7D,MAAM,WAAW,GAAG,OAAO,CAAC,QAAQ,CAAC;IACrC,+CAA+C;IAC/C,OAAO;QACL,GAAG,kBAAkB;QACrB,GAAG,mBAAmB;QACtB,GAAG,WAAW;QACd,GAAG,WAAW;QACd,GAAG,gBAAgB;KACpB,CAAC;AACJ,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,qBAAqB,CAInC,EACA,WAAW,GAAG,EAAO,EACrB,QAAQ,GAAG,EAAE,EACb,OAAO,GAAG,EAAE,EACZ,YAAY,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,GACnB;IAChC,MAAM,gBAAgB,GAAG,WAAW,CAAC,QAAQ,IAAI,WAAW,CAAC,QAAQ,CAAC,YAAY,CAAC;IACnF,MAAM,eAAe,GAAsB,YAAY,CAAU,QAAQ,CAAC,CAAC,QAA6B,CAAC;IACzG,MAAM,WAAW,GAAG,eAAe,IAAI,eAAe,CAAC,YAAY,CAAC;IACpE,MAAM,WAAW,GAAG,OAAO,CAAC,QAAQ,IAAK,OAAO,CAAC,QAA8B,CAAC,YAAY,CAAC;IAE7F,OAAO,EAAE,GAAG,YAAY,EAAE,GAAG,WAAW,EAAE,GAAG,WAAW,EAAE,GAAG,gBAAgB,EAAE,CAAC;AAClF,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,eAAe,CAAC,YAAoC,EAAE,OAAiB,EAAE;IACvF,0EAA0E;IAC1E,yBAAyB;IACzB,MAAM,SAAS,GAAG,YAAY;SAC3B,MAAM,CAAC,OAAO,CAAC;SACf,MAAM,CAAW,CAAC,QAAQ,EAAE,OAAO,EAAE,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,OAAQ,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IAE9F,oEAAoE;IACpE,6BAA6B;IAC7B,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC9E,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,SAAS,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS,GAAG,KAAK,EAAE,GAAG,KAAK,EAAa;IACnF,OAAO,IAAI,CAAC,CAAC,CAAC,KAAC,SAAS,OAAK,KAAK,GAAI,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC;AAC1D,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rjsf/semantic-ui",
|
|
3
|
-
"version": "6.6.
|
|
3
|
+
"version": "6.6.2",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"module": "lib/index.js",
|
|
6
6
|
"typings": "lib/index.d.ts",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"lint": "oxlint src test",
|
|
54
54
|
"precommit": "lint-staged",
|
|
55
55
|
"test": "vitest run",
|
|
56
|
-
"test:update": "vitest run --update
|
|
56
|
+
"test:update": "vitest run --update"
|
|
57
57
|
},
|
|
58
58
|
"lint-staged": {
|
|
59
59
|
"{src,test}/**/*.ts(x)": [
|
|
@@ -62,16 +62,16 @@
|
|
|
62
62
|
]
|
|
63
63
|
},
|
|
64
64
|
"peerDependencies": {
|
|
65
|
-
"@rjsf/core": "^6.
|
|
66
|
-
"@rjsf/utils": "^6.
|
|
65
|
+
"@rjsf/core": "^6.6.x",
|
|
66
|
+
"@rjsf/utils": "^6.6.x",
|
|
67
67
|
"react": ">=18",
|
|
68
68
|
"semantic-ui-react": "^2.1.3"
|
|
69
69
|
},
|
|
70
70
|
"devDependencies": {
|
|
71
|
-
"@rjsf/core": "6.6.
|
|
72
|
-
"@rjsf/snapshot-tests": "6.6.
|
|
73
|
-
"@rjsf/utils": "6.6.
|
|
74
|
-
"@rjsf/validator-ajv8": "6.6.
|
|
71
|
+
"@rjsf/core": "6.6.2",
|
|
72
|
+
"@rjsf/snapshot-tests": "6.6.2",
|
|
73
|
+
"@rjsf/utils": "6.6.2",
|
|
74
|
+
"@rjsf/validator-ajv8": "6.6.2",
|
|
75
75
|
"atob": "^2.1.2",
|
|
76
76
|
"semantic-ui-react": "^2.1.5"
|
|
77
77
|
},
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { FormContextType, RJSFSchema, StrictRJSFSchema
|
|
2
|
-
import {
|
|
1
|
+
import type { FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
2
|
+
import { TranslatableString } from '@rjsf/utils';
|
|
3
|
+
import type { ButtonProps } from 'semantic-ui-react';
|
|
4
|
+
import { Button, Icon } from 'semantic-ui-react';
|
|
3
5
|
|
|
4
|
-
import { SemanticIconButtonProps } from '../IconButton';
|
|
6
|
+
import type { SemanticIconButtonProps } from '../IconButton';
|
|
5
7
|
|
|
6
8
|
/** The `AddButton` renders a button that represent the `Add` action on a form
|
|
7
9
|
*/
|
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
FormContextType,
|
|
4
|
-
RJSFSchema,
|
|
5
|
-
StrictRJSFSchema,
|
|
6
|
-
getUiOptions,
|
|
7
|
-
getTemplate,
|
|
8
|
-
} from '@rjsf/utils';
|
|
1
|
+
import type { ArrayFieldItemTemplateProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
2
|
+
import { getUiOptions, getTemplate } from '@rjsf/utils';
|
|
9
3
|
import { Button, Grid, Segment } from 'semantic-ui-react';
|
|
10
4
|
|
|
11
5
|
import { getSemanticProps, MaybeWrap } from '../util';
|
|
@@ -1,13 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
getUiOptions,
|
|
4
|
-
isFixedItems,
|
|
5
|
-
ArrayFieldTemplateProps,
|
|
6
|
-
FormContextType,
|
|
7
|
-
RJSFSchema,
|
|
8
|
-
StrictRJSFSchema,
|
|
9
|
-
buttonId,
|
|
10
|
-
} from '@rjsf/utils';
|
|
1
|
+
import type { ArrayFieldTemplateProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
2
|
+
import { getTemplate, getUiOptions, isFixedItems, buttonId } from '@rjsf/utils';
|
|
11
3
|
|
|
12
4
|
import { cleanClassNames } from '../util';
|
|
13
5
|
|
|
@@ -1,15 +1,8 @@
|
|
|
1
|
-
import { ChangeEvent, MouseEvent
|
|
1
|
+
import type { ChangeEvent, MouseEvent } from 'react';
|
|
2
|
+
import { useCallback } from 'react';
|
|
2
3
|
import { SchemaExamples } from '@rjsf/core';
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
BaseInputTemplateProps,
|
|
6
|
-
examplesId,
|
|
7
|
-
getInputProps,
|
|
8
|
-
labelValue,
|
|
9
|
-
FormContextType,
|
|
10
|
-
RJSFSchema,
|
|
11
|
-
StrictRJSFSchema,
|
|
12
|
-
} from '@rjsf/utils';
|
|
4
|
+
import type { BaseInputTemplateProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
5
|
+
import { ariaDescribedByIds, examplesId, getInputProps, labelValue } from '@rjsf/utils';
|
|
13
6
|
import { Form } from 'semantic-ui-react';
|
|
14
7
|
|
|
15
8
|
import { getSemanticProps } from '../util';
|
|
@@ -54,11 +47,11 @@ export default function BaseInputTemplate<
|
|
|
54
47
|
formContext: registry.formContext,
|
|
55
48
|
options,
|
|
56
49
|
});
|
|
57
|
-
const
|
|
58
|
-
onChange(
|
|
59
|
-
const
|
|
60
|
-
const
|
|
61
|
-
const
|
|
50
|
+
const handleChange = ({ target: { value: newValue } }: ChangeEvent<HTMLInputElement>) =>
|
|
51
|
+
onChange(newValue === '' ? options.emptyValue : newValue);
|
|
52
|
+
const handleBlur = () => onBlur && onBlur(id, value);
|
|
53
|
+
const handleFocus = () => onFocus && onFocus(id, value);
|
|
54
|
+
const handleClear = useCallback(
|
|
62
55
|
(e: MouseEvent) => {
|
|
63
56
|
e.preventDefault();
|
|
64
57
|
e.stopPropagation();
|
|
@@ -83,13 +76,13 @@ export default function BaseInputTemplate<
|
|
|
83
76
|
{...semanticProps}
|
|
84
77
|
value={value || value === 0 ? value : ''}
|
|
85
78
|
error={rawErrors.length > 0}
|
|
86
|
-
onChange={onChangeOverride ||
|
|
87
|
-
onBlur={
|
|
88
|
-
onFocus={
|
|
79
|
+
onChange={onChangeOverride || handleChange}
|
|
80
|
+
onBlur={handleBlur}
|
|
81
|
+
onFocus={handleFocus}
|
|
89
82
|
aria-describedby={ariaDescribedByIds(id, !!schema.examples)}
|
|
90
83
|
/>
|
|
91
84
|
{options.allowClearTextInputs && !readonly && !disabled && value && (
|
|
92
|
-
<ClearButton registry={registry} onClick={
|
|
85
|
+
<ClearButton registry={registry} onClick={handleClear} />
|
|
93
86
|
)}
|
|
94
87
|
<SchemaExamples id={id} schema={schema} />
|
|
95
88
|
</>
|
|
@@ -1,16 +1,8 @@
|
|
|
1
|
-
import { FormEvent } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
labelValue,
|
|
7
|
-
schemaRequiresTrueValue,
|
|
8
|
-
FormContextType,
|
|
9
|
-
RJSFSchema,
|
|
10
|
-
StrictRJSFSchema,
|
|
11
|
-
WidgetProps,
|
|
12
|
-
} from '@rjsf/utils';
|
|
13
|
-
import { Form, CheckboxProps } from 'semantic-ui-react';
|
|
1
|
+
import type { FormEvent } from 'react';
|
|
2
|
+
import type { FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps } from '@rjsf/utils';
|
|
3
|
+
import { ariaDescribedByIds, descriptionId, getTemplate, labelValue, schemaRequiresTrueValue } from '@rjsf/utils';
|
|
4
|
+
import type { CheckboxProps } from 'semantic-ui-react';
|
|
5
|
+
import { Form } from 'semantic-ui-react';
|
|
14
6
|
|
|
15
7
|
import { getSemanticProps } from '../util';
|
|
16
8
|
|
|
@@ -59,10 +51,10 @@ export default function CheckboxWidget<
|
|
|
59
51
|
// the "required" attribute if the field value must be "true", due to the
|
|
60
52
|
// "const" or "enum" keywords
|
|
61
53
|
const required = schemaRequiresTrueValue<S>(schema);
|
|
62
|
-
const checked = value
|
|
63
|
-
const
|
|
64
|
-
const
|
|
65
|
-
const
|
|
54
|
+
const checked = value === 'true' || value === true;
|
|
55
|
+
const handleChange = (_: FormEvent<HTMLInputElement>, data: CheckboxProps) => onChange && onChange(data.checked);
|
|
56
|
+
const handleBlur: React.FocusEventHandler<HTMLInputElement> = () => onBlur && onBlur(id, value);
|
|
57
|
+
const handleFocus: React.FocusEventHandler<HTMLInputElement> = () => onFocus && onFocus(id, value);
|
|
66
58
|
const description = options.description ?? schema.description;
|
|
67
59
|
|
|
68
60
|
return (
|
|
@@ -84,9 +76,9 @@ export default function CheckboxWidget<
|
|
|
84
76
|
{...semanticProps}
|
|
85
77
|
checked={typeof value === 'undefined' ? false : checked}
|
|
86
78
|
error={rawErrors.length > 0}
|
|
87
|
-
onChange={
|
|
88
|
-
onBlur={
|
|
89
|
-
onFocus={
|
|
79
|
+
onChange={handleChange}
|
|
80
|
+
onBlur={handleBlur}
|
|
81
|
+
onFocus={handleFocus}
|
|
90
82
|
required={required}
|
|
91
83
|
label={labelValue(label, hideLabel, false)}
|
|
92
84
|
aria-describedby={ariaDescribedByIds(id)}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { ChangeEvent } from 'react';
|
|
1
|
+
import type { ChangeEvent } from 'react';
|
|
2
|
+
import type { FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps } from '@rjsf/utils';
|
|
2
3
|
import {
|
|
3
4
|
ariaDescribedByIds,
|
|
4
5
|
enumOptionsDeselectValue,
|
|
@@ -7,10 +8,6 @@ import {
|
|
|
7
8
|
getTemplate,
|
|
8
9
|
optionId,
|
|
9
10
|
titleId,
|
|
10
|
-
FormContextType,
|
|
11
|
-
RJSFSchema,
|
|
12
|
-
StrictRJSFSchema,
|
|
13
|
-
WidgetProps,
|
|
14
11
|
} from '@rjsf/utils';
|
|
15
12
|
import { Form } from 'semantic-ui-react';
|
|
16
13
|
|
|
@@ -55,10 +52,10 @@ export default function CheckboxesWidget<
|
|
|
55
52
|
inverted: 'false',
|
|
56
53
|
},
|
|
57
54
|
});
|
|
58
|
-
const
|
|
55
|
+
const handleChange =
|
|
59
56
|
(index: number) =>
|
|
60
57
|
({ target: { checked } }: ChangeEvent<HTMLInputElement>) => {
|
|
61
|
-
//
|
|
58
|
+
// oxlint-disable-next-line no-shadow
|
|
62
59
|
if (checked) {
|
|
63
60
|
onChange(enumOptionsSelectValue<S>(index, checkboxesValues, enumOptions));
|
|
64
61
|
} else {
|
|
@@ -66,8 +63,8 @@ export default function CheckboxesWidget<
|
|
|
66
63
|
}
|
|
67
64
|
};
|
|
68
65
|
|
|
69
|
-
const
|
|
70
|
-
const
|
|
66
|
+
const handleBlur = () => onBlur(id, value);
|
|
67
|
+
const handleFocus = () => onFocus(id, value);
|
|
71
68
|
const inlineOption = inline ? { inline: true } : { grouped: true };
|
|
72
69
|
return (
|
|
73
70
|
<>
|
|
@@ -78,21 +75,21 @@ export default function CheckboxesWidget<
|
|
|
78
75
|
{Array.isArray(enumOptions) &&
|
|
79
76
|
enumOptions.map((option, index) => {
|
|
80
77
|
const checked = enumOptionsIsSelected<S>(option.value, checkboxesValues);
|
|
81
|
-
const itemDisabled = Array.isArray(enumDisabled) && enumDisabled.
|
|
78
|
+
const itemDisabled = Array.isArray(enumDisabled) && enumDisabled.includes(option.value);
|
|
82
79
|
return (
|
|
83
80
|
<Form.Checkbox
|
|
84
81
|
id={optionId(id, index)}
|
|
85
82
|
name={htmlName || id}
|
|
86
|
-
key={
|
|
83
|
+
key={String(option.value)}
|
|
87
84
|
label={option.label}
|
|
88
85
|
{...semanticProps}
|
|
89
86
|
checked={checked}
|
|
90
87
|
error={rawErrors.length > 0}
|
|
91
88
|
disabled={disabled || itemDisabled || readonly}
|
|
92
89
|
autoFocus={autofocus && index === 0}
|
|
93
|
-
onChange={
|
|
94
|
-
onBlur={
|
|
95
|
-
onFocus={
|
|
90
|
+
onChange={handleChange(index)}
|
|
91
|
+
onBlur={handleBlur}
|
|
92
|
+
onFocus={handleFocus}
|
|
96
93
|
aria-describedby={ariaDescribedByIds(id)}
|
|
97
94
|
/>
|
|
98
95
|
);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { RichDescription } from '@rjsf/core';
|
|
2
|
-
import { DescriptionFieldProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
2
|
+
import type { DescriptionFieldProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
3
3
|
|
|
4
4
|
/** The `DescriptionField` is the template to use to render the description of a field
|
|
5
5
|
*
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { ErrorListProps, FormContextType, RJSFSchema, StrictRJSFSchema
|
|
1
|
+
import type { ErrorListProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
2
|
+
import { TranslatableString } from '@rjsf/utils';
|
|
2
3
|
import { Message } from 'semantic-ui-react';
|
|
3
4
|
|
|
4
5
|
/** The `ErrorList` component is the template that renders the all the errors associated with the fields in the `Form`
|
|
@@ -15,6 +16,7 @@ export default function ErrorList<T = any, S extends StrictRJSFSchema = RJSFSche
|
|
|
15
16
|
<Message.Header>{translateString(TranslatableString.ErrorsLabel)}</Message.Header>
|
|
16
17
|
<Message.List>
|
|
17
18
|
{errors.map((error, index) => (
|
|
19
|
+
// oxlint-disable-next-line react/no-array-index-key
|
|
18
20
|
<Message.Item key={`error-${index}`}>{error.stack}</Message.Item>
|
|
19
21
|
))}
|
|
20
22
|
</Message.List>
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { FieldErrorProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
2
|
+
import { errorId } from '@rjsf/utils';
|
|
2
3
|
import uniqueId from 'lodash/uniqueId';
|
|
3
4
|
import { Label, List } from 'semantic-ui-react';
|
|
4
5
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { RichHelp } from '@rjsf/core';
|
|
2
|
-
import { FieldHelpProps, FormContextType, RJSFSchema, StrictRJSFSchema
|
|
2
|
+
import type { FieldHelpProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
3
|
+
import { helpId } from '@rjsf/utils';
|
|
3
4
|
import { Message } from 'semantic-ui-react';
|
|
4
5
|
|
|
5
6
|
/** The `FieldHelpTemplate` component renders any help desired for a field
|
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
FormContextType,
|
|
4
|
-
RJSFSchema,
|
|
5
|
-
StrictRJSFSchema,
|
|
6
|
-
getTemplate,
|
|
7
|
-
getUiOptions,
|
|
8
|
-
} from '@rjsf/utils';
|
|
1
|
+
import type { FieldTemplateProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
2
|
+
import { getTemplate, getUiOptions } from '@rjsf/utils';
|
|
9
3
|
import { Form } from 'semantic-ui-react';
|
|
10
4
|
|
|
11
5
|
import { getSemanticProps, MaybeWrap } from '../util';
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { memo } from 'react';
|
|
2
|
+
import type { FormContextType, IconButtonProps, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
3
|
+
import { TranslatableString } from '@rjsf/utils';
|
|
4
|
+
import type { ButtonProps } from 'semantic-ui-react';
|
|
5
|
+
import { Button } from 'semantic-ui-react';
|
|
3
6
|
|
|
4
7
|
export type SemanticIconButtonProps<
|
|
5
8
|
T = any,
|
|
@@ -7,7 +10,7 @@ export type SemanticIconButtonProps<
|
|
|
7
10
|
F extends FormContextType = any,
|
|
8
11
|
> = IconButtonProps<T, S, F> & Omit<ButtonProps, 'onChange'>;
|
|
9
12
|
|
|
10
|
-
|
|
13
|
+
function IconButtonFn<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
|
|
11
14
|
props: SemanticIconButtonProps<T, S, F>,
|
|
12
15
|
) {
|
|
13
16
|
const { icon, iconType, color, className, uiSchema, registry, ...otherProps } = props;
|
|
@@ -21,8 +24,10 @@ export default function IconButton<T = any, S extends StrictRJSFSchema = RJSFSch
|
|
|
21
24
|
/>
|
|
22
25
|
);
|
|
23
26
|
}
|
|
27
|
+
const IconButton = memo(IconButtonFn) as typeof IconButtonFn;
|
|
28
|
+
export default IconButton;
|
|
24
29
|
|
|
25
|
-
|
|
30
|
+
function CopyButtonFn<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
|
|
26
31
|
props: SemanticIconButtonProps<T, S, F>,
|
|
27
32
|
) {
|
|
28
33
|
const {
|
|
@@ -30,8 +35,9 @@ export function CopyButton<T = any, S extends StrictRJSFSchema = RJSFSchema, F e
|
|
|
30
35
|
} = props;
|
|
31
36
|
return <IconButton title={translateString(TranslatableString.CopyButton)} {...props} icon='copy' />;
|
|
32
37
|
}
|
|
38
|
+
export const CopyButton = memo(CopyButtonFn) as typeof CopyButtonFn;
|
|
33
39
|
|
|
34
|
-
|
|
40
|
+
function MoveDownButtonFn<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
|
|
35
41
|
props: SemanticIconButtonProps<T, S, F>,
|
|
36
42
|
) {
|
|
37
43
|
const {
|
|
@@ -39,8 +45,9 @@ export function MoveDownButton<T = any, S extends StrictRJSFSchema = RJSFSchema,
|
|
|
39
45
|
} = props;
|
|
40
46
|
return <IconButton title={translateString(TranslatableString.MoveDownButton)} {...props} icon='angle down' />;
|
|
41
47
|
}
|
|
48
|
+
export const MoveDownButton = memo(MoveDownButtonFn) as typeof MoveDownButtonFn;
|
|
42
49
|
|
|
43
|
-
|
|
50
|
+
function MoveUpButtonFn<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
|
|
44
51
|
props: SemanticIconButtonProps<T, S, F>,
|
|
45
52
|
) {
|
|
46
53
|
const {
|
|
@@ -48,8 +55,9 @@ export function MoveUpButton<T = any, S extends StrictRJSFSchema = RJSFSchema, F
|
|
|
48
55
|
} = props;
|
|
49
56
|
return <IconButton title={translateString(TranslatableString.MoveUpButton)} {...props} icon='angle up' />;
|
|
50
57
|
}
|
|
58
|
+
export const MoveUpButton = memo(MoveUpButtonFn) as typeof MoveUpButtonFn;
|
|
51
59
|
|
|
52
|
-
|
|
60
|
+
function RemoveButtonFn<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
|
|
53
61
|
props: SemanticIconButtonProps<T, S, F>,
|
|
54
62
|
) {
|
|
55
63
|
const {
|
|
@@ -57,8 +65,9 @@ export function RemoveButton<T = any, S extends StrictRJSFSchema = RJSFSchema, F
|
|
|
57
65
|
} = props;
|
|
58
66
|
return <IconButton title={translateString(TranslatableString.RemoveButton)} {...props} icon='trash' />;
|
|
59
67
|
}
|
|
68
|
+
export const RemoveButton = memo(RemoveButtonFn) as typeof RemoveButtonFn;
|
|
60
69
|
|
|
61
|
-
|
|
70
|
+
function ClearButtonFn<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
|
|
62
71
|
props: SemanticIconButtonProps<T, S, F>,
|
|
63
72
|
) {
|
|
64
73
|
const {
|
|
@@ -66,3 +75,4 @@ export function ClearButton<T = any, S extends StrictRJSFSchema = RJSFSchema, F
|
|
|
66
75
|
} = props;
|
|
67
76
|
return <IconButton title={translateString(TranslatableString.ClearButton)} {...props} icon='close' />;
|
|
68
77
|
}
|
|
78
|
+
export const ClearButton = memo(ClearButtonFn) as typeof ClearButtonFn;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FormContextType, MultiSchemaFieldTemplateProps, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
1
|
+
import type { FormContextType, MultiSchemaFieldTemplateProps, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
2
2
|
|
|
3
3
|
export default function MultiSchemaFieldTemplate<
|
|
4
4
|
T = any,
|
|
@@ -1,15 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
ObjectFieldTemplateProps,
|
|
4
|
-
RJSFSchema,
|
|
5
|
-
StrictRJSFSchema,
|
|
6
|
-
canExpand,
|
|
7
|
-
descriptionId,
|
|
8
|
-
getTemplate,
|
|
9
|
-
getUiOptions,
|
|
10
|
-
titleId,
|
|
11
|
-
buttonId,
|
|
12
|
-
} from '@rjsf/utils';
|
|
1
|
+
import type { FormContextType, ObjectFieldTemplateProps, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
2
|
+
import { canExpand, descriptionId, getTemplate, getUiOptions, titleId, buttonId } from '@rjsf/utils';
|
|
13
3
|
import { Grid } from 'semantic-ui-react';
|
|
14
4
|
|
|
15
5
|
/** The `ObjectFieldTemplate` is the template to use to render all the inner properties of an object along with the
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FormContextType, OptionalDataControlsTemplateProps, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
1
|
+
import type { FormContextType, OptionalDataControlsTemplateProps, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
2
2
|
|
|
3
3
|
import AddButton from '../AddButton';
|
|
4
4
|
import { RemoveButton } from '../IconButton';
|
|
@@ -28,7 +28,8 @@ export default function OptionalDataControlsTemplate<
|
|
|
28
28
|
size='mini'
|
|
29
29
|
/>
|
|
30
30
|
);
|
|
31
|
-
}
|
|
31
|
+
}
|
|
32
|
+
if (onRemoveClick) {
|
|
32
33
|
return (
|
|
33
34
|
<RemoveButton
|
|
34
35
|
id={id}
|
|
@@ -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
|
|
40
|
+
// oxlint-disable-next-line no-shadow
|
|
41
|
+
const handleChange = ({ target: { value } }: ChangeEvent<HTMLInputElement>) =>
|
|
41
42
|
onChange && onChange(value === '' ? options.emptyValue : value);
|
|
42
|
-
const
|
|
43
|
-
const
|
|
43
|
+
const handleBlur = () => onBlur && onBlur(id, value);
|
|
44
|
+
const handleFocus = () => onFocus && 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>
|