@rjsf/fluentui-rc 5.14.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.
- package/LICENSE.md +201 -0
- package/README.md +127 -0
- package/dist/core.umd.js +940 -0
- package/dist/index.esm.js +1091 -0
- package/dist/index.esm.js.map +7 -0
- package/dist/index.js +1063 -0
- package/dist/index.js.map +7 -0
- package/lib/AddButton/AddButton.d.ts +3 -0
- package/lib/AddButton/AddButton.js +11 -0
- package/lib/AddButton/AddButton.js.map +1 -0
- package/lib/AddButton/index.d.ts +2 -0
- package/lib/AddButton/index.js +3 -0
- package/lib/AddButton/index.js.map +1 -0
- package/lib/ArrayFieldItemTemplate/ArrayFieldItemTemplate.d.ts +7 -0
- package/lib/ArrayFieldItemTemplate/ArrayFieldItemTemplate.js +12 -0
- package/lib/ArrayFieldItemTemplate/ArrayFieldItemTemplate.js.map +1 -0
- package/lib/ArrayFieldItemTemplate/index.d.ts +2 -0
- package/lib/ArrayFieldItemTemplate/index.js +3 -0
- package/lib/ArrayFieldItemTemplate/index.js.map +1 -0
- package/lib/ArrayFieldTemplate/ArrayFieldTemplate.d.ts +7 -0
- package/lib/ArrayFieldTemplate/ArrayFieldTemplate.js +28 -0
- package/lib/ArrayFieldTemplate/ArrayFieldTemplate.js.map +1 -0
- package/lib/ArrayFieldTemplate/index.d.ts +2 -0
- package/lib/ArrayFieldTemplate/index.js +3 -0
- package/lib/ArrayFieldTemplate/index.js.map +1 -0
- package/lib/BaseInputTemplate/BaseInputTemplate.d.ts +9 -0
- package/lib/BaseInputTemplate/BaseInputTemplate.js +38 -0
- package/lib/BaseInputTemplate/BaseInputTemplate.js.map +1 -0
- package/lib/BaseInputTemplate/index.d.ts +2 -0
- package/lib/BaseInputTemplate/index.js +3 -0
- package/lib/BaseInputTemplate/index.js.map +1 -0
- package/lib/CheckboxWidget/CheckboxWidget.d.ts +8 -0
- package/lib/CheckboxWidget/CheckboxWidget.js +23 -0
- package/lib/CheckboxWidget/CheckboxWidget.js.map +1 -0
- package/lib/CheckboxWidget/index.d.ts +2 -0
- package/lib/CheckboxWidget/index.js +3 -0
- package/lib/CheckboxWidget/index.js.map +1 -0
- package/lib/CheckboxesWidget/CheckboxesWidget.d.ts +8 -0
- package/lib/CheckboxesWidget/CheckboxesWidget.js +30 -0
- package/lib/CheckboxesWidget/CheckboxesWidget.js.map +1 -0
- package/lib/CheckboxesWidget/index.d.ts +2 -0
- package/lib/CheckboxesWidget/index.js +3 -0
- package/lib/CheckboxesWidget/index.js.map +1 -0
- package/lib/DescriptionField/DescriptionField.d.ts +7 -0
- package/lib/DescriptionField/DescriptionField.js +21 -0
- package/lib/DescriptionField/DescriptionField.js.map +1 -0
- package/lib/DescriptionField/index.d.ts +2 -0
- package/lib/DescriptionField/index.js +3 -0
- package/lib/DescriptionField/index.js.map +1 -0
- package/lib/ErrorList/ErrorList.d.ts +7 -0
- package/lib/ErrorList/ErrorList.js +26 -0
- package/lib/ErrorList/ErrorList.js.map +1 -0
- package/lib/ErrorList/index.d.ts +2 -0
- package/lib/ErrorList/index.js +3 -0
- package/lib/ErrorList/index.js.map +1 -0
- package/lib/FieldErrorTemplate/FieldErrorTemplate.d.ts +7 -0
- package/lib/FieldErrorTemplate/FieldErrorTemplate.js +28 -0
- package/lib/FieldErrorTemplate/FieldErrorTemplate.js.map +1 -0
- package/lib/FieldErrorTemplate/index.d.ts +2 -0
- package/lib/FieldErrorTemplate/index.js +3 -0
- package/lib/FieldErrorTemplate/index.js.map +1 -0
- package/lib/FieldHelpTemplate/FieldHelpTemplate.d.ts +7 -0
- package/lib/FieldHelpTemplate/FieldHelpTemplate.js +16 -0
- package/lib/FieldHelpTemplate/FieldHelpTemplate.js.map +1 -0
- package/lib/FieldHelpTemplate/index.d.ts +2 -0
- package/lib/FieldHelpTemplate/index.js +3 -0
- package/lib/FieldHelpTemplate/index.js.map +1 -0
- package/lib/FieldTemplate/FieldTemplate.d.ts +8 -0
- package/lib/FieldTemplate/FieldTemplate.js +18 -0
- package/lib/FieldTemplate/FieldTemplate.js.map +1 -0
- package/lib/FieldTemplate/index.d.ts +2 -0
- package/lib/FieldTemplate/index.js +3 -0
- package/lib/FieldTemplate/index.js.map +1 -0
- package/lib/FluentForm/FluentForm.d.ts +6 -0
- package/lib/FluentForm/FluentForm.js +7 -0
- package/lib/FluentForm/FluentForm.js.map +1 -0
- package/lib/FluentForm/index.d.ts +2 -0
- package/lib/FluentForm/index.js +3 -0
- package/lib/FluentForm/index.js.map +1 -0
- package/lib/FluentUIRCFrameProvider.d.ts +2 -0
- package/lib/FluentUIRCFrameProvider.js +12 -0
- package/lib/FluentUIRCFrameProvider.js.map +1 -0
- package/lib/IconButton/IconButton.d.ts +7 -0
- package/lib/IconButton/IconButton.js +26 -0
- package/lib/IconButton/IconButton.js.map +1 -0
- package/lib/IconButton/index.d.ts +2 -0
- package/lib/IconButton/index.js +3 -0
- package/lib/IconButton/index.js.map +1 -0
- package/lib/ObjectFieldTemplate/ObjectFieldTemplate.d.ts +9 -0
- package/lib/ObjectFieldTemplate/ObjectFieldTemplate.js +22 -0
- package/lib/ObjectFieldTemplate/ObjectFieldTemplate.js.map +1 -0
- package/lib/ObjectFieldTemplate/index.d.ts +2 -0
- package/lib/ObjectFieldTemplate/index.js +3 -0
- package/lib/ObjectFieldTemplate/index.js.map +1 -0
- package/lib/RadioWidget/RadioWidget.d.ts +8 -0
- package/lib/RadioWidget/RadioWidget.js +22 -0
- package/lib/RadioWidget/RadioWidget.js.map +1 -0
- package/lib/RadioWidget/index.d.ts +2 -0
- package/lib/RadioWidget/index.js +3 -0
- package/lib/RadioWidget/index.js.map +1 -0
- package/lib/RangeWidget/RangeWidget.d.ts +8 -0
- package/lib/RangeWidget/RangeWidget.js +20 -0
- package/lib/RangeWidget/RangeWidget.js.map +1 -0
- package/lib/RangeWidget/index.d.ts +2 -0
- package/lib/RangeWidget/index.js +3 -0
- package/lib/RangeWidget/index.js.map +1 -0
- package/lib/SelectWidget/SelectWidget.d.ts +9 -0
- package/lib/SelectWidget/SelectWidget.js +41 -0
- package/lib/SelectWidget/SelectWidget.js.map +1 -0
- package/lib/SelectWidget/index.d.ts +2 -0
- package/lib/SelectWidget/index.js +3 -0
- package/lib/SelectWidget/index.js.map +1 -0
- package/lib/SubmitButton/SubmitButton.d.ts +3 -0
- package/lib/SubmitButton/SubmitButton.js +17 -0
- package/lib/SubmitButton/SubmitButton.js.map +1 -0
- package/lib/SubmitButton/index.d.ts +2 -0
- package/lib/SubmitButton/index.js +3 -0
- package/lib/SubmitButton/index.js.map +1 -0
- package/lib/Templates/Templates.d.ts +4 -0
- package/lib/Templates/Templates.js +39 -0
- package/lib/Templates/Templates.js.map +1 -0
- package/lib/Templates/index.d.ts +2 -0
- package/lib/Templates/index.js +3 -0
- package/lib/Templates/index.js.map +1 -0
- package/lib/TextareaWidget/TextareaWidget.d.ts +7 -0
- package/lib/TextareaWidget/TextareaWidget.js +27 -0
- package/lib/TextareaWidget/TextareaWidget.js.map +1 -0
- package/lib/TextareaWidget/index.d.ts +2 -0
- package/lib/TextareaWidget/index.js +3 -0
- package/lib/TextareaWidget/index.js.map +1 -0
- package/lib/Theme/Theme.d.ts +5 -0
- package/lib/Theme/Theme.js +10 -0
- package/lib/Theme/Theme.js.map +1 -0
- package/lib/Theme/index.d.ts +2 -0
- package/lib/Theme/index.js +3 -0
- package/lib/Theme/index.js.map +1 -0
- package/lib/TitleField/TitleField.d.ts +7 -0
- package/lib/TitleField/TitleField.js +17 -0
- package/lib/TitleField/TitleField.js.map +1 -0
- package/lib/TitleField/index.d.ts +2 -0
- package/lib/TitleField/index.js +3 -0
- package/lib/TitleField/index.js.map +1 -0
- package/lib/Widgets/Widgets.d.ts +4 -0
- package/lib/Widgets/Widgets.js +18 -0
- package/lib/Widgets/Widgets.js.map +1 -0
- package/lib/Widgets/index.d.ts +2 -0
- package/lib/Widgets/index.js +3 -0
- package/lib/Widgets/index.js.map +1 -0
- package/lib/WrapIfAdditionalTemplate/WrapIfAdditionalTemplate.d.ts +8 -0
- package/lib/WrapIfAdditionalTemplate/WrapIfAdditionalTemplate.js +40 -0
- package/lib/WrapIfAdditionalTemplate/WrapIfAdditionalTemplate.js.map +1 -0
- package/lib/WrapIfAdditionalTemplate/index.d.ts +2 -0
- package/lib/WrapIfAdditionalTemplate/index.js +3 -0
- package/lib/WrapIfAdditionalTemplate/index.js.map +1 -0
- package/lib/index.d.ts +7 -0
- package/lib/index.js +8 -0
- package/lib/index.js.map +1 -0
- package/lib/tsconfig.tsbuildinfo +1 -0
- package/package.json +98 -0
- package/src/AddButton/AddButton.tsx +12 -0
- package/src/AddButton/index.ts +2 -0
- package/src/ArrayFieldItemTemplate/ArrayFieldItemTemplate.tsx +72 -0
- package/src/ArrayFieldItemTemplate/index.ts +2 -0
- package/src/ArrayFieldTemplate/ArrayFieldTemplate.tsx +87 -0
- package/src/ArrayFieldTemplate/index.ts +2 -0
- package/src/BaseInputTemplate/BaseInputTemplate.tsx +99 -0
- package/src/BaseInputTemplate/index.ts +2 -0
- package/src/CheckboxWidget/CheckboxWidget.tsx +81 -0
- package/src/CheckboxWidget/index.ts +2 -0
- package/src/CheckboxesWidget/CheckboxesWidget.tsx +91 -0
- package/src/CheckboxesWidget/index.ts +2 -0
- package/src/DescriptionField/DescriptionField.tsx +31 -0
- package/src/DescriptionField/index.ts +2 -0
- package/src/ErrorList/ErrorList.tsx +40 -0
- package/src/ErrorList/index.ts +2 -0
- package/src/FieldErrorTemplate/FieldErrorTemplate.tsx +44 -0
- package/src/FieldErrorTemplate/index.ts +2 -0
- package/src/FieldHelpTemplate/FieldHelpTemplate.tsx +19 -0
- package/src/FieldHelpTemplate/index.ts +2 -0
- package/src/FieldTemplate/FieldTemplate.tsx +80 -0
- package/src/FieldTemplate/index.ts +2 -0
- package/src/FluentForm/FluentForm.ts +15 -0
- package/src/FluentForm/index.ts +2 -0
- package/src/FluentUIRCFrameProvider.tsx +21 -0
- package/src/IconButton/IconButton.tsx +73 -0
- package/src/IconButton/index.ts +2 -0
- package/src/ObjectFieldTemplate/ObjectFieldTemplate.tsx +97 -0
- package/src/ObjectFieldTemplate/index.ts +2 -0
- package/src/RadioWidget/RadioWidget.tsx +77 -0
- package/src/RadioWidget/index.ts +2 -0
- package/src/RangeWidget/RangeWidget.tsx +49 -0
- package/src/RangeWidget/index.ts +2 -0
- package/src/SelectWidget/SelectWidget.tsx +98 -0
- package/src/SelectWidget/index.ts +2 -0
- package/src/SubmitButton/SubmitButton.tsx +27 -0
- package/src/SubmitButton/index.ts +2 -0
- package/src/Templates/Templates.ts +45 -0
- package/src/Templates/index.ts +2 -0
- package/src/TextareaWidget/TextareaWidget.tsx +81 -0
- package/src/TextareaWidget/index.ts +2 -0
- package/src/Theme/Theme.ts +18 -0
- package/src/Theme/index.ts +2 -0
- package/src/TitleField/TitleField.tsx +28 -0
- package/src/TitleField/index.ts +2 -0
- package/src/Widgets/Widgets.ts +24 -0
- package/src/Widgets/index.ts +2 -0
- package/src/WrapIfAdditionalTemplate/WrapIfAdditionalTemplate.tsx +100 -0
- package/src/WrapIfAdditionalTemplate/index.ts +2 -0
- package/src/index.ts +9 -0
- package/src/tsconfig.json +24 -0
package/package.json
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@rjsf/fluentui-rc",
|
|
3
|
+
"version": "5.14.1",
|
|
4
|
+
"description": "FluentUI React Components theme, fields and widgets for react-jsonschema-form",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"build:ts": "tsc -b",
|
|
7
|
+
"build:cjs": "esbuild ./src/index.ts --bundle --outfile=dist/index.js --sourcemap --packages=external --format=cjs",
|
|
8
|
+
"build:esm": "esbuild ./src/index.ts --bundle --outfile=dist/index.esm.js --sourcemap --packages=external --format=esm",
|
|
9
|
+
"build:umd": "rollup dist/index.esm.js --format=umd --file=dist/core.umd.js --name=JSONSchemaForm",
|
|
10
|
+
"build": "npm run build:ts && npm run build:cjs && npm run build:esm && npm run build:umd",
|
|
11
|
+
"cs-check": "prettier -l \"{src,test,testSnap}/**/*.[jt]s?(x)\"",
|
|
12
|
+
"cs-format": "prettier \"{src,test,testSnap}/**/*.[jt]s?(x)\" --write",
|
|
13
|
+
"lint": "eslint src test",
|
|
14
|
+
"precommit": "lint-staged",
|
|
15
|
+
"publish-to-npm": "npm run build && npm publish",
|
|
16
|
+
"test": "jest",
|
|
17
|
+
"test:debug": "node --inspect-brk node_modules/.bin/jest",
|
|
18
|
+
"test:update": "jest --u",
|
|
19
|
+
"test:watch": "jest --watch",
|
|
20
|
+
"test-coverage": "jest --coverage"
|
|
21
|
+
},
|
|
22
|
+
"lint-staged": {
|
|
23
|
+
"{src,test}/**/*.[jt]s?(x)": [
|
|
24
|
+
"eslint --fix"
|
|
25
|
+
]
|
|
26
|
+
},
|
|
27
|
+
"main": "dist/index.js",
|
|
28
|
+
"module": "lib/index.js",
|
|
29
|
+
"typings": "lib/index.d.ts",
|
|
30
|
+
"files": [
|
|
31
|
+
"dist",
|
|
32
|
+
"lib",
|
|
33
|
+
"src"
|
|
34
|
+
],
|
|
35
|
+
"engineStrict": false,
|
|
36
|
+
"engines": {
|
|
37
|
+
"node": ">=14"
|
|
38
|
+
},
|
|
39
|
+
"peerDependencies": {
|
|
40
|
+
"@rjsf/utils": "^5.12.x",
|
|
41
|
+
"react": "^16.14.0 || >=17"
|
|
42
|
+
},
|
|
43
|
+
"dependencies": {
|
|
44
|
+
"@fluentui/react-components": "^9.35.0",
|
|
45
|
+
"@fluentui/react-icons": "^2.0.220",
|
|
46
|
+
"@fluentui/react-migration-v0-v9": "^9.0.42"
|
|
47
|
+
},
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"@babel/core": "^7.22.17",
|
|
50
|
+
"@babel/plugin-proposal-class-properties": "^7.18.6",
|
|
51
|
+
"@babel/plugin-proposal-optional-chaining": "^7.21.0",
|
|
52
|
+
"@babel/preset-env": "^7.22.15",
|
|
53
|
+
"@babel/preset-react": "^7.22.15",
|
|
54
|
+
"@babel/preset-typescript": "^7.22.15",
|
|
55
|
+
"@rjsf/core": "^5.14.1",
|
|
56
|
+
"@rjsf/snapshot-tests": "^5.14.1",
|
|
57
|
+
"@rjsf/utils": "^5.14.1",
|
|
58
|
+
"@rjsf/validator-ajv8": "^5.14.1",
|
|
59
|
+
"@types/jest": "^29.5.7",
|
|
60
|
+
"@types/react": "^17.0.65",
|
|
61
|
+
"@types/react-dom": "^17.0.20",
|
|
62
|
+
"@types/react-test-renderer": "^17.0.3",
|
|
63
|
+
"babel-jest": "^29.6.4",
|
|
64
|
+
"esbuild": "^0.18.20",
|
|
65
|
+
"eslint": "^8.48.0",
|
|
66
|
+
"jest": "^29.6.4",
|
|
67
|
+
"jest-environment-jsdom": "^29.6.4",
|
|
68
|
+
"react": "^17.0.2",
|
|
69
|
+
"react-dom": "^17.0.2",
|
|
70
|
+
"react-test-renderer": "^17.0.2",
|
|
71
|
+
"rimraf": "^5.0.1",
|
|
72
|
+
"rollup": "^3.29.0",
|
|
73
|
+
"typescript": "^4.9.5"
|
|
74
|
+
},
|
|
75
|
+
"directories": {
|
|
76
|
+
"test": "test"
|
|
77
|
+
},
|
|
78
|
+
"repository": {
|
|
79
|
+
"type": "git",
|
|
80
|
+
"url": "git+https://github.com/rjsf-team/react-jsonschema-form.git"
|
|
81
|
+
},
|
|
82
|
+
"author": "Marc Veens <veens.marc@gmail.com>",
|
|
83
|
+
"contributors": [],
|
|
84
|
+
"keywords": [
|
|
85
|
+
"react",
|
|
86
|
+
"form",
|
|
87
|
+
"json-schema",
|
|
88
|
+
"fluentui",
|
|
89
|
+
"fluentui-rc",
|
|
90
|
+
"rjsf-fluentui-rc"
|
|
91
|
+
],
|
|
92
|
+
"license": "Apache-2.0",
|
|
93
|
+
"homepage": "https://github.com/rjsf-team/react-jsonschema-form",
|
|
94
|
+
"publishConfig": {
|
|
95
|
+
"access": "public"
|
|
96
|
+
},
|
|
97
|
+
"gitHead": "7eb830fc26a09dcd62f2079c45c982537379c79c"
|
|
98
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { FormContextType, IconButtonProps, RJSFSchema, StrictRJSFSchema, TranslatableString } from '@rjsf/utils';
|
|
2
|
+
import { Button } from '@fluentui/react-components';
|
|
3
|
+
import { AddRegular } from '@fluentui/react-icons';
|
|
4
|
+
|
|
5
|
+
export default function AddButton<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>({
|
|
6
|
+
uiSchema,
|
|
7
|
+
registry,
|
|
8
|
+
...props
|
|
9
|
+
}: IconButtonProps<T, S, F>) {
|
|
10
|
+
const { translateString } = registry;
|
|
11
|
+
return <Button {...props} icon={<AddRegular />} title={translateString(TranslatableString.AddItemButton)} />;
|
|
12
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { ArrayFieldTemplateItemType, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
2
|
+
import { Flex } from '@fluentui/react-migration-v0-v9';
|
|
3
|
+
|
|
4
|
+
/** The `ArrayFieldItemTemplate` component is the template used to render an items of an array.
|
|
5
|
+
*
|
|
6
|
+
* @param props - The `ArrayFieldTemplateItemType` props for the component
|
|
7
|
+
*/
|
|
8
|
+
export default function ArrayFieldItemTemplate<
|
|
9
|
+
T = any,
|
|
10
|
+
S extends StrictRJSFSchema = RJSFSchema,
|
|
11
|
+
F extends FormContextType = any
|
|
12
|
+
>(props: ArrayFieldTemplateItemType<T, S, F>) {
|
|
13
|
+
const {
|
|
14
|
+
children,
|
|
15
|
+
disabled,
|
|
16
|
+
hasToolbar,
|
|
17
|
+
hasCopy,
|
|
18
|
+
hasMoveDown,
|
|
19
|
+
hasMoveUp,
|
|
20
|
+
hasRemove,
|
|
21
|
+
index,
|
|
22
|
+
onCopyIndexClick,
|
|
23
|
+
onDropIndexClick,
|
|
24
|
+
onReorderClick,
|
|
25
|
+
readonly,
|
|
26
|
+
uiSchema,
|
|
27
|
+
registry,
|
|
28
|
+
} = props;
|
|
29
|
+
const { CopyButton, MoveDownButton, MoveUpButton, RemoveButton } = registry.templates.ButtonTemplates;
|
|
30
|
+
|
|
31
|
+
return (
|
|
32
|
+
<Flex vAlign='end'>
|
|
33
|
+
<Flex>{children}</Flex>
|
|
34
|
+
{hasToolbar && (
|
|
35
|
+
<Flex style={{ marginLeft: '8px' }}>
|
|
36
|
+
{(hasMoveUp || hasMoveDown) && (
|
|
37
|
+
<MoveUpButton
|
|
38
|
+
disabled={disabled || readonly || !hasMoveUp}
|
|
39
|
+
onClick={onReorderClick(index, index - 1)}
|
|
40
|
+
uiSchema={uiSchema}
|
|
41
|
+
registry={registry}
|
|
42
|
+
/>
|
|
43
|
+
)}
|
|
44
|
+
{(hasMoveUp || hasMoveDown) && (
|
|
45
|
+
<MoveDownButton
|
|
46
|
+
disabled={disabled || readonly || !hasMoveDown}
|
|
47
|
+
onClick={onReorderClick(index, index + 1)}
|
|
48
|
+
uiSchema={uiSchema}
|
|
49
|
+
registry={registry}
|
|
50
|
+
/>
|
|
51
|
+
)}
|
|
52
|
+
{hasCopy && (
|
|
53
|
+
<CopyButton
|
|
54
|
+
disabled={disabled || readonly}
|
|
55
|
+
onClick={onCopyIndexClick(index)}
|
|
56
|
+
uiSchema={uiSchema}
|
|
57
|
+
registry={registry}
|
|
58
|
+
/>
|
|
59
|
+
)}
|
|
60
|
+
{hasRemove && (
|
|
61
|
+
<RemoveButton
|
|
62
|
+
disabled={disabled || readonly}
|
|
63
|
+
onClick={onDropIndexClick(index)}
|
|
64
|
+
uiSchema={uiSchema}
|
|
65
|
+
registry={registry}
|
|
66
|
+
/>
|
|
67
|
+
)}
|
|
68
|
+
</Flex>
|
|
69
|
+
)}
|
|
70
|
+
</Flex>
|
|
71
|
+
);
|
|
72
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { makeStyles, shorthands } from '@fluentui/react-components';
|
|
2
|
+
import { Flex } from '@fluentui/react-migration-v0-v9';
|
|
3
|
+
import {
|
|
4
|
+
getTemplate,
|
|
5
|
+
getUiOptions,
|
|
6
|
+
ArrayFieldTemplateProps,
|
|
7
|
+
ArrayFieldTemplateItemType,
|
|
8
|
+
FormContextType,
|
|
9
|
+
RJSFSchema,
|
|
10
|
+
StrictRJSFSchema,
|
|
11
|
+
} from '@rjsf/utils';
|
|
12
|
+
|
|
13
|
+
const useStyles = makeStyles({
|
|
14
|
+
arrayItemList: {
|
|
15
|
+
...shorthands.gap('12px'),
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
/** The `ArrayFieldTemplate` component is the template used to render all items in an array.
|
|
20
|
+
*
|
|
21
|
+
* @param props - The `ArrayFieldTemplateItemType` props for the component
|
|
22
|
+
*/
|
|
23
|
+
export default function ArrayFieldTemplate<
|
|
24
|
+
T = any,
|
|
25
|
+
S extends StrictRJSFSchema = RJSFSchema,
|
|
26
|
+
F extends FormContextType = any
|
|
27
|
+
>(props: ArrayFieldTemplateProps<T, S, F>) {
|
|
28
|
+
const { canAdd, disabled, idSchema, uiSchema, items, onAddClick, readonly, registry, required, schema, title } =
|
|
29
|
+
props;
|
|
30
|
+
const classes = useStyles();
|
|
31
|
+
const uiOptions = getUiOptions<T, S, F>(uiSchema);
|
|
32
|
+
const ArrayFieldDescriptionTemplate = getTemplate<'ArrayFieldDescriptionTemplate', T, S, F>(
|
|
33
|
+
'ArrayFieldDescriptionTemplate',
|
|
34
|
+
registry,
|
|
35
|
+
uiOptions
|
|
36
|
+
);
|
|
37
|
+
const ArrayFieldItemTemplate = getTemplate<'ArrayFieldItemTemplate', T, S, F>(
|
|
38
|
+
'ArrayFieldItemTemplate',
|
|
39
|
+
registry,
|
|
40
|
+
uiOptions
|
|
41
|
+
);
|
|
42
|
+
const ArrayFieldTitleTemplate = getTemplate<'ArrayFieldTitleTemplate', T, S, F>(
|
|
43
|
+
'ArrayFieldTitleTemplate',
|
|
44
|
+
registry,
|
|
45
|
+
uiOptions
|
|
46
|
+
);
|
|
47
|
+
// Button templates are not overridden in the uiSchema
|
|
48
|
+
const {
|
|
49
|
+
ButtonTemplates: { AddButton },
|
|
50
|
+
} = registry.templates;
|
|
51
|
+
return (
|
|
52
|
+
<>
|
|
53
|
+
<ArrayFieldTitleTemplate
|
|
54
|
+
idSchema={idSchema}
|
|
55
|
+
title={uiOptions.title || title}
|
|
56
|
+
schema={schema}
|
|
57
|
+
uiSchema={uiSchema}
|
|
58
|
+
required={required}
|
|
59
|
+
registry={registry}
|
|
60
|
+
/>
|
|
61
|
+
<ArrayFieldDescriptionTemplate
|
|
62
|
+
idSchema={idSchema}
|
|
63
|
+
description={uiOptions.description || schema.description}
|
|
64
|
+
schema={schema}
|
|
65
|
+
uiSchema={uiSchema}
|
|
66
|
+
registry={registry}
|
|
67
|
+
/>
|
|
68
|
+
<Flex column key={`array-item-list-${idSchema.$id}`} className={classes.arrayItemList}>
|
|
69
|
+
{items &&
|
|
70
|
+
items.map(({ key, ...itemProps }: ArrayFieldTemplateItemType<T, S, F>) => (
|
|
71
|
+
<ArrayFieldItemTemplate key={key} {...itemProps} />
|
|
72
|
+
))}
|
|
73
|
+
{canAdd && (
|
|
74
|
+
<Flex hAlign='end'>
|
|
75
|
+
<AddButton
|
|
76
|
+
className='array-item-add'
|
|
77
|
+
onClick={onAddClick}
|
|
78
|
+
disabled={disabled || readonly}
|
|
79
|
+
uiSchema={uiSchema}
|
|
80
|
+
registry={registry}
|
|
81
|
+
/>
|
|
82
|
+
</Flex>
|
|
83
|
+
)}
|
|
84
|
+
</Flex>
|
|
85
|
+
</>
|
|
86
|
+
);
|
|
87
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { ChangeEvent, FocusEvent } from 'react';
|
|
2
|
+
import { Input, InputProps, Label, makeStyles } from '@fluentui/react-components';
|
|
3
|
+
import {
|
|
4
|
+
ariaDescribedByIds,
|
|
5
|
+
BaseInputTemplateProps,
|
|
6
|
+
examplesId,
|
|
7
|
+
getInputProps,
|
|
8
|
+
FormContextType,
|
|
9
|
+
RJSFSchema,
|
|
10
|
+
StrictRJSFSchema,
|
|
11
|
+
labelValue,
|
|
12
|
+
} from '@rjsf/utils';
|
|
13
|
+
|
|
14
|
+
const useStyles = makeStyles({
|
|
15
|
+
input: {
|
|
16
|
+
width: '100%',
|
|
17
|
+
},
|
|
18
|
+
label: {
|
|
19
|
+
paddingTop: '2px',
|
|
20
|
+
paddingBottom: '2px',
|
|
21
|
+
marginBottom: '2px',
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
/** The `BaseInputTemplate` is the template to use to render the basic `<input>` component for the `core` theme.
|
|
26
|
+
* It is used as the template for rendering many of the <input> based widgets that differ by `type` and callbacks only.
|
|
27
|
+
* It can be customized/overridden for other themes or individual implementations as needed.
|
|
28
|
+
*
|
|
29
|
+
* @param props - The `WidgetProps` for this template
|
|
30
|
+
*/
|
|
31
|
+
export default function BaseInputTemplate<
|
|
32
|
+
T = any,
|
|
33
|
+
S extends StrictRJSFSchema = RJSFSchema,
|
|
34
|
+
F extends FormContextType = any
|
|
35
|
+
>(props: BaseInputTemplateProps<T, S, F>) {
|
|
36
|
+
const {
|
|
37
|
+
id,
|
|
38
|
+
placeholder,
|
|
39
|
+
required,
|
|
40
|
+
readonly,
|
|
41
|
+
disabled,
|
|
42
|
+
type,
|
|
43
|
+
value,
|
|
44
|
+
label,
|
|
45
|
+
hideLabel,
|
|
46
|
+
onChange,
|
|
47
|
+
onChangeOverride,
|
|
48
|
+
onBlur,
|
|
49
|
+
onFocus,
|
|
50
|
+
autofocus,
|
|
51
|
+
options,
|
|
52
|
+
schema,
|
|
53
|
+
} = props;
|
|
54
|
+
const classes = useStyles();
|
|
55
|
+
const inputProps = getInputProps<T, S, F>(schema, type, options);
|
|
56
|
+
// Now we need to pull out the step, min, max into an inner `inputProps` for material-ui
|
|
57
|
+
const _onChange = ({ target: { value } }: ChangeEvent<HTMLInputElement>) =>
|
|
58
|
+
onChange(value === '' ? options.emptyValue : value);
|
|
59
|
+
const _onBlur = ({ target: { value } }: FocusEvent<HTMLInputElement>) => onBlur(id, value);
|
|
60
|
+
const _onFocus = ({ target: { value } }: FocusEvent<HTMLInputElement>) => onFocus(id, value);
|
|
61
|
+
return (
|
|
62
|
+
<>
|
|
63
|
+
{labelValue(
|
|
64
|
+
<Label htmlFor={id} required={required} disabled={disabled} className={classes.label}>
|
|
65
|
+
{label}
|
|
66
|
+
</Label>,
|
|
67
|
+
hideLabel
|
|
68
|
+
)}
|
|
69
|
+
<Input
|
|
70
|
+
id={id}
|
|
71
|
+
name={id}
|
|
72
|
+
placeholder={placeholder}
|
|
73
|
+
autoFocus={autofocus}
|
|
74
|
+
required={required}
|
|
75
|
+
disabled={disabled || readonly}
|
|
76
|
+
{...(inputProps as InputProps)}
|
|
77
|
+
input={{
|
|
78
|
+
className: classes.input,
|
|
79
|
+
// Due to Fluent UI this does not work correctly
|
|
80
|
+
list: schema.examples ? examplesId<T>(id) : undefined,
|
|
81
|
+
}}
|
|
82
|
+
value={value || value === 0 ? value : ''}
|
|
83
|
+
onChange={onChangeOverride || _onChange}
|
|
84
|
+
onFocus={_onFocus}
|
|
85
|
+
onBlur={_onBlur}
|
|
86
|
+
aria-describedby={ariaDescribedByIds<T>(id, !!schema.examples)}
|
|
87
|
+
/>
|
|
88
|
+
{Array.isArray(schema.examples) && (
|
|
89
|
+
<datalist id={examplesId<T>(id)}>
|
|
90
|
+
{(schema.examples as string[])
|
|
91
|
+
.concat(schema.default && !schema.examples.includes(schema.default) ? ([schema.default] as string[]) : [])
|
|
92
|
+
.map((example: any) => {
|
|
93
|
+
return <option key={example} value={example} />;
|
|
94
|
+
})}
|
|
95
|
+
</datalist>
|
|
96
|
+
)}
|
|
97
|
+
</>
|
|
98
|
+
);
|
|
99
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { ChangeEvent, FocusEvent } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
ariaDescribedByIds,
|
|
4
|
+
descriptionId,
|
|
5
|
+
getTemplate,
|
|
6
|
+
schemaRequiresTrueValue,
|
|
7
|
+
FormContextType,
|
|
8
|
+
RJSFSchema,
|
|
9
|
+
StrictRJSFSchema,
|
|
10
|
+
WidgetProps,
|
|
11
|
+
} from '@rjsf/utils';
|
|
12
|
+
import { Checkbox } from '@fluentui/react-components';
|
|
13
|
+
|
|
14
|
+
/** The `CheckBoxWidget` is a widget for rendering boolean properties.
|
|
15
|
+
* It is typically used to represent a boolean.
|
|
16
|
+
*
|
|
17
|
+
* @param props - The `WidgetProps` for this component
|
|
18
|
+
*/
|
|
19
|
+
export default function CheckboxWidget<
|
|
20
|
+
T = any,
|
|
21
|
+
S extends StrictRJSFSchema = RJSFSchema,
|
|
22
|
+
F extends FormContextType = any
|
|
23
|
+
>(props: WidgetProps<T, S, F>) {
|
|
24
|
+
const {
|
|
25
|
+
schema,
|
|
26
|
+
id,
|
|
27
|
+
value,
|
|
28
|
+
disabled,
|
|
29
|
+
readonly,
|
|
30
|
+
label = '',
|
|
31
|
+
hideLabel,
|
|
32
|
+
autofocus,
|
|
33
|
+
onChange,
|
|
34
|
+
onBlur,
|
|
35
|
+
onFocus,
|
|
36
|
+
registry,
|
|
37
|
+
options,
|
|
38
|
+
uiSchema,
|
|
39
|
+
} = props;
|
|
40
|
+
const DescriptionFieldTemplate = getTemplate<'DescriptionFieldTemplate', T, S, F>(
|
|
41
|
+
'DescriptionFieldTemplate',
|
|
42
|
+
registry,
|
|
43
|
+
options
|
|
44
|
+
);
|
|
45
|
+
// Because an unchecked checkbox will cause html5 validation to fail, only add
|
|
46
|
+
// the "required" attribute if the field value must be "true", due to the
|
|
47
|
+
// "const" or "enum" keywords
|
|
48
|
+
const required = schemaRequiresTrueValue<S>(schema);
|
|
49
|
+
|
|
50
|
+
const _onChange = ({ target: { checked } }: ChangeEvent<HTMLInputElement>) => onChange(checked);
|
|
51
|
+
const _onBlur = ({ target: { value } }: FocusEvent<HTMLInputElement>) => onBlur(id, value);
|
|
52
|
+
const _onFocus = ({ target: { value } }: FocusEvent<HTMLInputElement>) => onFocus(id, value);
|
|
53
|
+
const description = options.description ?? schema.description;
|
|
54
|
+
|
|
55
|
+
return (
|
|
56
|
+
<>
|
|
57
|
+
{!hideLabel && !!description && (
|
|
58
|
+
<DescriptionFieldTemplate
|
|
59
|
+
id={descriptionId<T>(id)}
|
|
60
|
+
description={description}
|
|
61
|
+
schema={schema}
|
|
62
|
+
uiSchema={uiSchema}
|
|
63
|
+
registry={registry}
|
|
64
|
+
/>
|
|
65
|
+
)}
|
|
66
|
+
<Checkbox
|
|
67
|
+
id={id}
|
|
68
|
+
name={id}
|
|
69
|
+
label={label}
|
|
70
|
+
checked={typeof value === 'undefined' ? false : Boolean(value)}
|
|
71
|
+
required={required}
|
|
72
|
+
disabled={disabled || readonly}
|
|
73
|
+
autoFocus={autofocus}
|
|
74
|
+
onChange={_onChange}
|
|
75
|
+
onBlur={_onBlur}
|
|
76
|
+
onFocus={_onFocus}
|
|
77
|
+
aria-describedby={ariaDescribedByIds<T>(id)}
|
|
78
|
+
/>
|
|
79
|
+
</>
|
|
80
|
+
);
|
|
81
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { ChangeEvent, FocusEvent } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
ariaDescribedByIds,
|
|
4
|
+
enumOptionsDeselectValue,
|
|
5
|
+
enumOptionsIsSelected,
|
|
6
|
+
enumOptionsSelectValue,
|
|
7
|
+
enumOptionsValueForIndex,
|
|
8
|
+
labelValue,
|
|
9
|
+
optionId,
|
|
10
|
+
FormContextType,
|
|
11
|
+
WidgetProps,
|
|
12
|
+
RJSFSchema,
|
|
13
|
+
StrictRJSFSchema,
|
|
14
|
+
} from '@rjsf/utils';
|
|
15
|
+
import { Label, Checkbox } from '@fluentui/react-components';
|
|
16
|
+
import { Flex } from '@fluentui/react-migration-v0-v9';
|
|
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
|
+
>({
|
|
28
|
+
label,
|
|
29
|
+
hideLabel,
|
|
30
|
+
id,
|
|
31
|
+
disabled,
|
|
32
|
+
options,
|
|
33
|
+
value,
|
|
34
|
+
autofocus,
|
|
35
|
+
readonly,
|
|
36
|
+
required,
|
|
37
|
+
onChange,
|
|
38
|
+
onBlur,
|
|
39
|
+
onFocus,
|
|
40
|
+
}: WidgetProps<T, S, F>) {
|
|
41
|
+
const { enumOptions, enumDisabled, inline, emptyValue } = options;
|
|
42
|
+
const checkboxesValues = Array.isArray(value) ? value : [value];
|
|
43
|
+
|
|
44
|
+
const _onChange =
|
|
45
|
+
(index: number) =>
|
|
46
|
+
({ target: { checked } }: ChangeEvent<HTMLInputElement>) => {
|
|
47
|
+
if (checked) {
|
|
48
|
+
onChange(enumOptionsSelectValue<S>(index, checkboxesValues, enumOptions));
|
|
49
|
+
} else {
|
|
50
|
+
onChange(enumOptionsDeselectValue<S>(index, checkboxesValues, enumOptions));
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
const _onBlur = ({ target: { value } }: FocusEvent<HTMLInputElement>) =>
|
|
55
|
+
onBlur(id, enumOptionsValueForIndex<S>(value, enumOptions, emptyValue));
|
|
56
|
+
const _onFocus = ({ target: { value } }: FocusEvent<HTMLInputElement>) =>
|
|
57
|
+
onFocus(id, enumOptionsValueForIndex<S>(value, enumOptions, emptyValue));
|
|
58
|
+
|
|
59
|
+
return (
|
|
60
|
+
<>
|
|
61
|
+
{labelValue(
|
|
62
|
+
<Label required={required} htmlFor={id}>
|
|
63
|
+
{label || undefined}
|
|
64
|
+
</Label>,
|
|
65
|
+
hideLabel
|
|
66
|
+
)}
|
|
67
|
+
<Flex column={!inline}>
|
|
68
|
+
{Array.isArray(enumOptions) &&
|
|
69
|
+
enumOptions.map((option, index: number) => {
|
|
70
|
+
const checked = enumOptionsIsSelected<S>(option.value, checkboxesValues);
|
|
71
|
+
const itemDisabled = Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) !== -1;
|
|
72
|
+
return (
|
|
73
|
+
<Checkbox
|
|
74
|
+
key={index}
|
|
75
|
+
id={optionId(id, index)}
|
|
76
|
+
name={id}
|
|
77
|
+
label={option.label}
|
|
78
|
+
checked={checked}
|
|
79
|
+
disabled={disabled || itemDisabled || readonly}
|
|
80
|
+
autoFocus={autofocus && index === 0}
|
|
81
|
+
onChange={_onChange(index)}
|
|
82
|
+
onBlur={_onBlur}
|
|
83
|
+
onFocus={_onFocus}
|
|
84
|
+
aria-describedby={ariaDescribedByIds<T>(id)}
|
|
85
|
+
/>
|
|
86
|
+
);
|
|
87
|
+
})}
|
|
88
|
+
</Flex>
|
|
89
|
+
</>
|
|
90
|
+
);
|
|
91
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Text, makeStyles, tokens } from '@fluentui/react-components';
|
|
2
|
+
import { DescriptionFieldProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
3
|
+
|
|
4
|
+
const useStyles = makeStyles({
|
|
5
|
+
label: {
|
|
6
|
+
marginTop: tokens.spacingVerticalS,
|
|
7
|
+
marginBottom: tokens.spacingVerticalM,
|
|
8
|
+
},
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
/** The `DescriptionField` is the template to use to render the description of a field
|
|
12
|
+
*
|
|
13
|
+
* @param props - The `DescriptionFieldProps` for this component
|
|
14
|
+
*/
|
|
15
|
+
export default function DescriptionField<
|
|
16
|
+
T = any,
|
|
17
|
+
S extends StrictRJSFSchema = RJSFSchema,
|
|
18
|
+
F extends FormContextType = any
|
|
19
|
+
>(props: DescriptionFieldProps<T, S, F>) {
|
|
20
|
+
const { id, description } = props;
|
|
21
|
+
const classes = useStyles();
|
|
22
|
+
if (description) {
|
|
23
|
+
return (
|
|
24
|
+
<Text block id={id} className={classes.label}>
|
|
25
|
+
{description}
|
|
26
|
+
</Text>
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Card, Text, makeStyles, shorthands, tokens } from '@fluentui/react-components';
|
|
2
|
+
import { ErrorListProps, FormContextType, RJSFSchema, StrictRJSFSchema, TranslatableString } from '@rjsf/utils';
|
|
3
|
+
|
|
4
|
+
const useStyles = makeStyles({
|
|
5
|
+
errorCard: {
|
|
6
|
+
backgroundColor: tokens.colorStatusDangerBackground1,
|
|
7
|
+
marginBottom: tokens.spacingVerticalL,
|
|
8
|
+
'&::after': {
|
|
9
|
+
...shorthands.borderColor(tokens.colorStatusDangerBorder1),
|
|
10
|
+
},
|
|
11
|
+
},
|
|
12
|
+
errorTitle: {
|
|
13
|
+
marginTop: 0,
|
|
14
|
+
marginBottom: 0,
|
|
15
|
+
},
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
/** The `ErrorList` component is the template that renders the all the errors associated with the fields in the `Form`
|
|
19
|
+
*
|
|
20
|
+
* @param props - The `ErrorListProps` for this component
|
|
21
|
+
*/
|
|
22
|
+
export default function ErrorList<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>({
|
|
23
|
+
errors,
|
|
24
|
+
registry,
|
|
25
|
+
}: ErrorListProps<T, S, F>) {
|
|
26
|
+
const { translateString } = registry;
|
|
27
|
+
const classes = useStyles();
|
|
28
|
+
return (
|
|
29
|
+
<Card appearance='outline' className={classes.errorCard}>
|
|
30
|
+
<Text as='h6' size={400} className={classes.errorTitle}>
|
|
31
|
+
{translateString(TranslatableString.ErrorsLabel)}
|
|
32
|
+
</Text>
|
|
33
|
+
<ul>
|
|
34
|
+
{errors.map((error, i: number) => {
|
|
35
|
+
return <li key={i}>{error.stack}</li>;
|
|
36
|
+
})}
|
|
37
|
+
</ul>
|
|
38
|
+
</Card>
|
|
39
|
+
);
|
|
40
|
+
}
|