@rjsf/chakra-ui 5.24.10 → 6.0.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (147) hide show
  1. package/dist/chakra-ui.esm.js +664 -700
  2. package/dist/chakra-ui.esm.js.map +4 -4
  3. package/dist/chakra-ui.umd.js +488 -579
  4. package/dist/index.js +670 -708
  5. package/dist/index.js.map +4 -4
  6. package/lib/AddButton/AddButton.js +3 -3
  7. package/lib/AddButton/AddButton.js.map +1 -1
  8. package/lib/AltDateWidget/AltDateWidget.js.map +1 -1
  9. package/lib/ArrayFieldItemTemplate/ArrayFieldItemTemplate.d.ts +2 -2
  10. package/lib/ArrayFieldItemTemplate/ArrayFieldItemTemplate.js +5 -8
  11. package/lib/ArrayFieldItemTemplate/ArrayFieldItemTemplate.js.map +1 -1
  12. package/lib/ArrayFieldTemplate/ArrayFieldTemplate.js +2 -2
  13. package/lib/ArrayFieldTemplate/ArrayFieldTemplate.js.map +1 -1
  14. package/lib/BaseInputTemplate/BaseInputTemplate.js +4 -5
  15. package/lib/BaseInputTemplate/BaseInputTemplate.js.map +1 -1
  16. package/lib/ChakraFrameProvider.js +3 -4
  17. package/lib/ChakraFrameProvider.js.map +1 -1
  18. package/lib/CheckboxWidget/CheckboxWidget.js +5 -5
  19. package/lib/CheckboxWidget/CheckboxWidget.js.map +1 -1
  20. package/lib/CheckboxesWidget/CheckboxesWidget.js +10 -13
  21. package/lib/CheckboxesWidget/CheckboxesWidget.js.map +1 -1
  22. package/lib/DescriptionField/DescriptionField.js.map +1 -1
  23. package/lib/ErrorList/ErrorList.js +4 -3
  24. package/lib/ErrorList/ErrorList.js.map +1 -1
  25. package/lib/FieldErrorTemplate/FieldErrorTemplate.js +3 -3
  26. package/lib/FieldErrorTemplate/FieldErrorTemplate.js.map +1 -1
  27. package/lib/FieldHelpTemplate/FieldHelpTemplate.js +2 -2
  28. package/lib/FieldHelpTemplate/FieldHelpTemplate.js.map +1 -1
  29. package/lib/FieldTemplate/FieldTemplate.js +2 -2
  30. package/lib/FieldTemplate/FieldTemplate.js.map +1 -1
  31. package/lib/GridTemplate/GridTemplate.d.ts +7 -0
  32. package/lib/GridTemplate/GridTemplate.js +15 -0
  33. package/lib/GridTemplate/GridTemplate.js.map +1 -0
  34. package/lib/GridTemplate/index.d.ts +2 -0
  35. package/lib/GridTemplate/index.js +3 -0
  36. package/lib/GridTemplate/index.js.map +1 -0
  37. package/lib/IconButton/ChakraIconButton.js +1 -1
  38. package/lib/IconButton/ChakraIconButton.js.map +1 -1
  39. package/lib/IconButton/IconButton.js +1 -1
  40. package/lib/IconButton/IconButton.js.map +1 -1
  41. package/lib/ObjectFieldTemplate/ObjectFieldTemplate.js +2 -2
  42. package/lib/ObjectFieldTemplate/ObjectFieldTemplate.js.map +1 -1
  43. package/lib/RadioWidget/RadioWidget.d.ts +1 -1
  44. package/lib/RadioWidget/RadioWidget.js +11 -11
  45. package/lib/RadioWidget/RadioWidget.js.map +1 -1
  46. package/lib/RangeWidget/RangeWidget.d.ts +1 -1
  47. package/lib/RangeWidget/RangeWidget.js +6 -8
  48. package/lib/RangeWidget/RangeWidget.js.map +1 -1
  49. package/lib/SelectNativeWidget/NativeSelectWidget.d.ts +12 -0
  50. package/lib/SelectNativeWidget/NativeSelectWidget.js +60 -0
  51. package/lib/SelectNativeWidget/NativeSelectWidget.js.map +1 -0
  52. package/lib/SelectNativeWidget/index.d.ts +2 -0
  53. package/lib/SelectNativeWidget/index.js +3 -0
  54. package/lib/SelectNativeWidget/index.js.map +1 -0
  55. package/lib/SelectWidget/SelectWidget.js +30 -23
  56. package/lib/SelectWidget/SelectWidget.js.map +1 -1
  57. package/lib/SubmitButton/SubmitButton.js.map +1 -1
  58. package/lib/Templates/Templates.js +2 -0
  59. package/lib/Templates/Templates.js.map +1 -1
  60. package/lib/TextareaWidget/TextareaWidget.d.ts +1 -1
  61. package/lib/TextareaWidget/TextareaWidget.js +5 -6
  62. package/lib/TextareaWidget/TextareaWidget.js.map +1 -1
  63. package/lib/TitleField/TitleField.js +2 -2
  64. package/lib/TitleField/TitleField.js.map +1 -1
  65. package/lib/UpDownWidget/UpDownWidget.js +6 -7
  66. package/lib/UpDownWidget/UpDownWidget.js.map +1 -1
  67. package/lib/Widgets/Widgets.js +2 -0
  68. package/lib/Widgets/Widgets.js.map +1 -1
  69. package/lib/WrapIfAdditionalTemplate/WrapIfAdditionalTemplate.js +4 -3
  70. package/lib/WrapIfAdditionalTemplate/WrapIfAdditionalTemplate.js.map +1 -1
  71. package/lib/components/ui/alert.d.ts +24 -0
  72. package/lib/components/ui/alert.js +9 -0
  73. package/lib/components/ui/alert.js.map +1 -0
  74. package/lib/components/ui/checkbox.d.ts +17 -0
  75. package/lib/components/ui/checkbox.js +17 -0
  76. package/lib/components/ui/checkbox.js.map +1 -0
  77. package/lib/components/ui/close-button.d.ts +10 -0
  78. package/lib/components/ui/close-button.js +16 -0
  79. package/lib/components/ui/close-button.js.map +1 -0
  80. package/lib/components/ui/field.d.ts +20 -0
  81. package/lib/components/ui/field.js +19 -0
  82. package/lib/components/ui/field.js.map +1 -0
  83. package/lib/components/ui/number-input.d.ts +10 -0
  84. package/lib/components/ui/number-input.js +20 -0
  85. package/lib/components/ui/number-input.js.map +1 -0
  86. package/lib/components/ui/radio.d.ts +16 -0
  87. package/lib/components/ui/radio.js +17 -0
  88. package/lib/components/ui/radio.js.map +1 -0
  89. package/lib/components/ui/select.d.ts +73 -0
  90. package/lib/components/ui/select.js +99 -0
  91. package/lib/components/ui/select.js.map +1 -0
  92. package/lib/components/ui/slider.d.ts +18 -0
  93. package/lib/components/ui/slider.js +55 -0
  94. package/lib/components/ui/slider.js.map +1 -0
  95. package/lib/tsconfig.tsbuildinfo +1 -1
  96. package/lib/utils.d.ts +3 -6
  97. package/lib/utils.js +6 -7
  98. package/lib/utils.js.map +1 -1
  99. package/package.json +52 -47
  100. package/src/AddButton/AddButton.tsx +3 -2
  101. package/src/AltDateTimeWidget/AltDateTimeWidget.tsx +1 -1
  102. package/src/AltDateWidget/AltDateWidget.tsx +3 -3
  103. package/src/ArrayFieldItemTemplate/ArrayFieldItemTemplate.tsx +18 -60
  104. package/src/ArrayFieldTemplate/ArrayFieldTemplate.tsx +9 -7
  105. package/src/BaseInputTemplate/BaseInputTemplate.tsx +11 -18
  106. package/src/ChakraFrameProvider.tsx +3 -4
  107. package/src/CheckboxWidget/CheckboxWidget.tsx +13 -12
  108. package/src/CheckboxesWidget/CheckboxesWidget.tsx +14 -29
  109. package/src/DescriptionField/DescriptionField.tsx +1 -1
  110. package/src/ErrorList/ErrorList.tsx +16 -7
  111. package/src/FieldErrorTemplate/FieldErrorTemplate.tsx +5 -5
  112. package/src/FieldHelpTemplate/FieldHelpTemplate.tsx +3 -3
  113. package/src/FieldTemplate/FieldTemplate.tsx +8 -8
  114. package/src/Form/Form.tsx +1 -1
  115. package/src/GridTemplate/GridTemplate.tsx +15 -0
  116. package/src/GridTemplate/index.ts +2 -0
  117. package/src/IconButton/ChakraIconButton.tsx +7 -3
  118. package/src/IconButton/IconButton.tsx +5 -5
  119. package/src/ObjectFieldTemplate/ObjectFieldTemplate.tsx +6 -4
  120. package/src/RadioWidget/RadioWidget.tsx +15 -14
  121. package/src/RangeWidget/RangeWidget.tsx +13 -20
  122. package/src/SelectNativeWidget/NativeSelectWidget.tsx +134 -0
  123. package/src/SelectNativeWidget/index.ts +2 -0
  124. package/src/SelectWidget/SelectWidget.tsx +74 -46
  125. package/src/SubmitButton/SubmitButton.tsx +1 -1
  126. package/src/Templates/Templates.ts +3 -1
  127. package/src/TextareaWidget/TextareaWidget.tsx +11 -14
  128. package/src/Theme/Theme.tsx +1 -1
  129. package/src/TitleField/TitleField.tsx +2 -2
  130. package/src/UpDownWidget/UpDownWidget.tsx +21 -34
  131. package/src/Widgets/Widgets.ts +3 -1
  132. package/src/WrapIfAdditionalTemplate/WrapIfAdditionalTemplate.tsx +9 -7
  133. package/src/components/ui/alert.tsx +47 -0
  134. package/src/components/ui/checkbox.tsx +28 -0
  135. package/src/components/ui/close-button.tsx +21 -0
  136. package/src/components/ui/field.tsx +37 -0
  137. package/src/components/ui/number-input.tsx +31 -0
  138. package/src/components/ui/radio.tsx +28 -0
  139. package/src/components/ui/select.tsx +171 -0
  140. package/src/components/ui/slider.tsx +100 -0
  141. package/src/tsconfig.json +3 -4
  142. package/src/utils.ts +8 -12
  143. package/LICENSE.md +0 -201
  144. package/lib/CssReset.d.ts +0 -23
  145. package/lib/CssReset.js +0 -266
  146. package/lib/CssReset.js.map +0 -1
  147. package/src/CssReset.tsx +0 -270
package/lib/utils.d.ts CHANGED
@@ -1,13 +1,10 @@
1
- import { ChakraProps } from '@chakra-ui/react';
1
+ import { Field as ChakraField } from '@chakra-ui/react';
2
2
  import { UiSchema } from '@rjsf/utils';
3
3
  export interface ChakraUiSchema extends Omit<UiSchema, 'ui:options'> {
4
4
  'ui:options'?: ChakraUiOptions;
5
5
  }
6
6
  type ChakraUiOptions = UiSchema['ui:options'] & {
7
- chakra?: ChakraProps;
7
+ chakra?: ChakraField.RootProps;
8
8
  };
9
- interface GetChakraProps {
10
- uiSchema?: ChakraUiSchema;
11
- }
12
- export declare function getChakra({ uiSchema }: GetChakraProps): ChakraProps;
9
+ export declare function getChakra(uiSchema?: ChakraUiSchema): ChakraField.RootProps;
13
10
  export {};
package/lib/utils.js CHANGED
@@ -1,15 +1,14 @@
1
- import { shouldForwardProp } from '@chakra-ui/react';
2
- export function getChakra({ uiSchema = {} }) {
1
+ import { defaultSystem } from '@chakra-ui/react';
2
+ import shouldForwardProp from '@emotion/is-prop-valid';
3
+ const { isValidProperty } = defaultSystem;
4
+ export function getChakra(uiSchema = {}) {
3
5
  const chakraProps = (uiSchema['ui:options'] && uiSchema['ui:options'].chakra) || {};
4
6
  Object.keys(chakraProps).forEach((key) => {
5
7
  /**
6
8
  * Leveraging `shouldForwardProp` to remove props
7
- *
8
- * This is a utility function that's used in `@chakra-ui/react`'s factory function.
9
- * Normally, it prevents ChakraProps from being passed to the DOM.
10
- * In this case we just want to delete the unknown props. So we flip the boolean.
9
+ * https://chakra-ui.com/docs/styling/chakra-factory#forwarding-props
11
10
  */
12
- if (shouldForwardProp(key)) {
11
+ if (!isValidProperty(key) || shouldForwardProp(key)) {
13
12
  delete chakraProps[key];
14
13
  }
15
14
  });
package/lib/utils.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAalE,MAAM,UAAU,SAAS,CAAC,EAAE,QAAQ,GAAG,EAAE,EAAkB;IACzD,MAAM,WAAW,GAAG,CAAC,QAAQ,CAAC,YAAY,CAAC,IAAI,QAAQ,CAAC,YAAY,CAAC,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;IAEpF,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;QACvC;;;;;;WAMG;QACH,IAAI,iBAAiB,CAAC,GAAG,CAAC,EAAE;YAC1B,OAAQ,WAAmB,CAAC,GAAG,CAAC,CAAC;SAClC;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,WAAW,CAAC;AACrB,CAAC"}
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwB,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEvE,OAAO,iBAAiB,MAAM,wBAAwB,CAAC;AAEvD,MAAM,EAAE,eAAe,EAAE,GAAG,aAAa,CAAC;AAQ1C,MAAM,UAAU,SAAS,CAAC,WAA2B,EAAE;IACrD,MAAM,WAAW,GAAG,CAAC,QAAQ,CAAC,YAAY,CAAC,IAAI,QAAQ,CAAC,YAAY,CAAC,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;IAEpF,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;QACvC;;;WAGG;QACH,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,IAAI,iBAAiB,CAAC,GAAG,CAAC,EAAE,CAAC;YACpD,OAAQ,WAAmB,CAAC,GAAG,CAAC,CAAC;QACnC,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,WAAW,CAAC;AACrB,CAAC"}
package/package.json CHANGED
@@ -1,10 +1,38 @@
1
1
  {
2
2
  "name": "@rjsf/chakra-ui",
3
- "version": "5.24.10",
3
+ "version": "6.0.0-beta.1",
4
4
  "description": "Chakra UI theme, fields, and widgets for react-jsonschema-form",
5
5
  "main": "dist/index.js",
6
6
  "module": "lib/index.js",
7
7
  "typings": "lib/index.d.ts",
8
+ "type": "module",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./lib/index.d.ts",
12
+ "require": "./dist/index.js",
13
+ "import": "./lib/index.js"
14
+ },
15
+ "./lib": {
16
+ "types": "./lib/index.d.ts",
17
+ "require": "./dist/index.js",
18
+ "import": "./lib/index.js"
19
+ },
20
+ "./lib/*.js": {
21
+ "types": "./lib/*.d.ts",
22
+ "require": "./dist/*.js",
23
+ "import": "./lib/*.js"
24
+ },
25
+ "./dist": {
26
+ "types": "./lib/index.d.ts",
27
+ "require": "./dist/index.js",
28
+ "import": "./lib/index.js"
29
+ },
30
+ "./dist/*.js": {
31
+ "types": "./lib/*.d.ts",
32
+ "require": "./dist/*.js",
33
+ "import": "./lib/*.js"
34
+ }
35
+ },
8
36
  "files": [
9
37
  "dist",
10
38
  "lib",
@@ -22,7 +50,8 @@
22
50
  "precommit": "lint-staged",
23
51
  "test": "jest",
24
52
  "test:update": "jest --u",
25
- "test:watch": "jest --watch"
53
+ "test:watch": "jest --watch",
54
+ "type-check": "tsc --noEmit"
26
55
  },
27
56
  "lint-staged": {
28
57
  "{src,test}/**/*.ts?(x)": [
@@ -31,17 +60,14 @@
31
60
  },
32
61
  "engineStrict": false,
33
62
  "engines": {
34
- "node": ">=14"
63
+ "node": ">=20"
35
64
  },
36
65
  "peerDependencies": {
37
- "@chakra-ui/icons": ">=1.1.1",
38
- "@chakra-ui/react": ">=1.7.3 <3.0.0",
39
- "@chakra-ui/system": ">=1.12.1",
40
- "@rjsf/core": "^5.24.x",
41
- "@rjsf/utils": "^5.24.x",
42
- "chakra-react-select": ">=3.3.8 <6.0.0",
43
- "framer-motion": ">=5.6.0",
44
- "react": "^16.14.0 || >=17"
66
+ "@chakra-ui/react": ">=3.16.1",
67
+ "@rjsf/core": "^6.x",
68
+ "@rjsf/utils": "^6.x",
69
+ "chakra-react-select": ">=6",
70
+ "react": ">=18"
45
71
  },
46
72
  "publishConfig": {
47
73
  "access": "public"
@@ -55,43 +81,22 @@
55
81
  ],
56
82
  "license": "Apache-2.0",
57
83
  "devDependencies": {
58
- "@babel/core": "^7.23.9",
59
- "@babel/plugin-proposal-class-properties": "^7.18.6",
60
- "@babel/plugin-proposal-optional-chaining": "^7.21.0",
61
- "@babel/preset-env": "^7.23.9",
62
- "@babel/preset-react": "^7.23.3",
63
- "@babel/preset-typescript": "^7.23.3",
64
- "@chakra-ui/icons": "^1.1.7",
65
- "@chakra-ui/react": "^1.8.9",
66
- "@chakra-ui/system": "^1.12.1",
67
- "@emotion/eslint-plugin": "^11.11.0",
68
- "@emotion/jest": "^11.11.0",
69
- "@emotion/react": "^11.11.3",
70
- "@emotion/styled": "^11.11.0",
71
- "@rjsf/core": "^5.24.10",
72
- "@rjsf/snapshot-tests": "^5.24.10",
73
- "@rjsf/utils": "^5.24.10",
74
- "@rjsf/validator-ajv8": "^5.24.10",
75
- "@types/jest": "^29.5.12",
76
- "@types/react": "^18.2.58",
77
- "@types/react-dom": "^18.2.19",
78
- "@types/react-test-renderer": "^18.0.7",
79
- "babel-jest": "^29.7.0",
80
- "chakra-react-select": "^3.3.9",
84
+ "@chakra-ui/cli": "^3.16.1",
85
+ "@chakra-ui/react": "^3.16.1",
86
+ "@emotion/eslint-plugin": "^11.12.0",
87
+ "@emotion/jest": "^11.13.0",
88
+ "@emotion/react": "^11.14.0",
89
+ "@emotion/styled": "^11.14.0",
90
+ "@rjsf/core": "^6.0.0-beta.1",
91
+ "@rjsf/snapshot-tests": "^6.0.0-beta.1",
92
+ "@rjsf/utils": "^6.0.0-beta.1",
93
+ "@rjsf/validator-ajv8": "^6.0.0-beta.1",
94
+ "chakra-react-select": "6.1.0",
81
95
  "eslint": "^8.56.0",
82
- "framer-motion": "^5.6.0",
83
- "jest": "^29.7.0",
84
- "jest-environment-jsdom": "^29.7.0",
85
- "jest-watch-typeahead": "^2.2.2",
86
- "react": "^18.2.0",
87
- "react-dom": "^18.2.0",
88
- "react-test-renderer": "^18.2.0",
89
- "rimraf": "^5.0.5",
90
- "rollup": "^3.29.4",
91
- "typescript": "^4.9.5"
96
+ "lucide-react": "^0.488.0"
92
97
  },
93
98
  "dependencies": {
94
- "react-select": "^5.8.0"
95
- },
96
- "gitHead": "ad33d7c324cb040d0f34da30a17caea0251f1e3a"
99
+ "react-icons": "^5.4.0",
100
+ "react-select": "^5.10.1"
101
+ }
97
102
  }
@@ -1,6 +1,6 @@
1
1
  import { FormContextType, IconButtonProps, RJSFSchema, StrictRJSFSchema, TranslatableString } from '@rjsf/utils';
2
2
  import { Button } from '@chakra-ui/react';
3
- import { AddIcon } from '@chakra-ui/icons';
3
+ import { PlusIcon } from 'lucide-react';
4
4
 
5
5
  export default function AddButton<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>({
6
6
  uiSchema,
@@ -9,7 +9,8 @@ export default function AddButton<T = any, S extends StrictRJSFSchema = RJSFSche
9
9
  }: IconButtonProps<T, S, F>) {
10
10
  const { translateString } = registry;
11
11
  return (
12
- <Button leftIcon={<AddIcon />} {...props}>
12
+ <Button {...props}>
13
+ <PlusIcon />
13
14
  {translateString(TranslatableString.AddItemButton)}
14
15
  </Button>
15
16
  );
@@ -2,7 +2,7 @@ import _AltDateWidget from '../AltDateWidget';
2
2
  import { FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps } from '@rjsf/utils';
3
3
 
4
4
  function AltDateTimeWidget<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
5
- props: WidgetProps<T, S, F>
5
+ props: WidgetProps<T, S, F>,
6
6
  ) {
7
7
  const { AltDateWidget } = props.registry.widgets;
8
8
  return <AltDateWidget {...props} showTime />;
@@ -16,7 +16,7 @@ import {
16
16
  import { Box, Button } from '@chakra-ui/react';
17
17
 
18
18
  function DateElement<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
19
- props: WidgetProps<T, S, F>
19
+ props: WidgetProps<T, S, F>,
20
20
  ) {
21
21
  const { SelectWidget } = props.registry.widgets;
22
22
  const value = props.value ? props.value : undefined;
@@ -46,7 +46,7 @@ const readyForChange = (state: AltDateStateType) => {
46
46
  };
47
47
 
48
48
  function AltDateWidget<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
49
- props: WidgetProps<T, S, F>
49
+ props: WidgetProps<T, S, F>,
50
50
  ) {
51
51
  const { autofocus, disabled, id, onBlur, onChange, onFocus, options, readonly, registry, showTime, value } = props;
52
52
  const { translateString } = registry;
@@ -92,7 +92,7 @@ function AltDateWidget<T = any, S extends StrictRJSFSchema = RJSFSchema, F exten
92
92
  state,
93
93
  showTime,
94
94
  options.yearsRange as [number, number] | undefined,
95
- options.format as DateElementFormat | undefined
95
+ options.format as DateElementFormat | undefined,
96
96
  ).map((elemProps: any, i) => {
97
97
  const elemId = id + '_' + elemProps.type;
98
98
  return (
@@ -1,75 +1,33 @@
1
- import { useMemo } from 'react';
2
1
  import { Box, ButtonGroup, HStack } from '@chakra-ui/react';
3
- import { ArrayFieldTemplateItemType, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
2
+ import {
3
+ ArrayFieldItemTemplateType,
4
+ FormContextType,
5
+ getTemplate,
6
+ getUiOptions,
7
+ RJSFSchema,
8
+ StrictRJSFSchema,
9
+ } from '@rjsf/utils';
4
10
 
5
11
  export default function ArrayFieldItemTemplate<
6
12
  T = any,
7
13
  S extends StrictRJSFSchema = RJSFSchema,
8
- F extends FormContextType = any
9
- >(props: ArrayFieldTemplateItemType<T, S, F>) {
10
- const {
11
- children,
12
- disabled,
13
- hasToolbar,
14
- hasCopy,
15
- hasMoveDown,
16
- hasMoveUp,
17
- hasRemove,
18
- index,
19
- onCopyIndexClick,
20
- onDropIndexClick,
21
- onReorderClick,
22
- readonly,
23
- uiSchema,
14
+ F extends FormContextType = any,
15
+ >(props: ArrayFieldItemTemplateType<T, S, F>) {
16
+ const { children, buttonsProps, hasToolbar, uiSchema, registry } = props;
17
+ const uiOptions = getUiOptions<T, S, F>(uiSchema);
18
+ const ArrayFieldItemButtonsTemplate = getTemplate<'ArrayFieldItemButtonsTemplate', T, S, F>(
19
+ 'ArrayFieldItemButtonsTemplate',
24
20
  registry,
25
- } = props;
26
- const { CopyButton, MoveDownButton, MoveUpButton, RemoveButton } = registry.templates.ButtonTemplates;
27
- const onCopyClick = useMemo(() => onCopyIndexClick(index), [index, onCopyIndexClick]);
28
-
29
- const onRemoveClick = useMemo(() => onDropIndexClick(index), [index, onDropIndexClick]);
30
-
31
- const onArrowUpClick = useMemo(() => onReorderClick(index, index - 1), [index, onReorderClick]);
32
-
33
- const onArrowDownClick = useMemo(() => onReorderClick(index, index + 1), [index, onReorderClick]);
21
+ uiOptions,
22
+ );
34
23
 
35
24
  return (
36
25
  <HStack alignItems={'flex-end'} py={1}>
37
26
  <Box w='100%'>{children}</Box>
38
27
  {hasToolbar && (
39
28
  <Box>
40
- <ButtonGroup isAttached mb={1}>
41
- {(hasMoveUp || hasMoveDown) && (
42
- <MoveUpButton
43
- disabled={disabled || readonly || !hasMoveUp}
44
- onClick={onArrowUpClick}
45
- uiSchema={uiSchema}
46
- registry={registry}
47
- />
48
- )}
49
- {(hasMoveUp || hasMoveDown) && (
50
- <MoveDownButton
51
- disabled={disabled || readonly || !hasMoveDown}
52
- onClick={onArrowDownClick}
53
- uiSchema={uiSchema}
54
- registry={registry}
55
- />
56
- )}
57
- {hasCopy && (
58
- <CopyButton
59
- disabled={disabled || readonly}
60
- onClick={onCopyClick}
61
- uiSchema={uiSchema}
62
- registry={registry}
63
- />
64
- )}
65
- {hasRemove && (
66
- <RemoveButton
67
- disabled={disabled || readonly}
68
- onClick={onRemoveClick}
69
- uiSchema={uiSchema}
70
- registry={registry}
71
- />
72
- )}
29
+ <ButtonGroup attached mb={1}>
30
+ <ArrayFieldItemButtonsTemplate {...buttonsProps} />
73
31
  </ButtonGroup>
74
32
  </Box>
75
33
  )}
@@ -2,17 +2,18 @@ import { Box, Grid, GridItem } from '@chakra-ui/react';
2
2
  import {
3
3
  getTemplate,
4
4
  getUiOptions,
5
- ArrayFieldTemplateItemType,
5
+ ArrayFieldItemTemplateType,
6
6
  ArrayFieldTemplateProps,
7
7
  StrictRJSFSchema,
8
8
  RJSFSchema,
9
9
  FormContextType,
10
+ buttonId,
10
11
  } from '@rjsf/utils';
11
12
 
12
13
  export default function ArrayFieldTemplate<
13
14
  T = any,
14
15
  S extends StrictRJSFSchema = RJSFSchema,
15
- F extends FormContextType = any
16
+ F extends FormContextType = any,
16
17
  >(props: ArrayFieldTemplateProps<T, S, F>) {
17
18
  const { canAdd, disabled, idSchema, uiSchema, items, onAddClick, readonly, registry, required, schema, title } =
18
19
  props;
@@ -20,17 +21,17 @@ export default function ArrayFieldTemplate<
20
21
  const ArrayFieldDescriptionTemplate = getTemplate<'ArrayFieldDescriptionTemplate', T, S, F>(
21
22
  'ArrayFieldDescriptionTemplate',
22
23
  registry,
23
- uiOptions
24
+ uiOptions,
24
25
  );
25
26
  const ArrayFieldItemTemplate = getTemplate<'ArrayFieldItemTemplate', T, S, F>(
26
27
  'ArrayFieldItemTemplate',
27
28
  registry,
28
- uiOptions
29
+ uiOptions,
29
30
  );
30
31
  const ArrayFieldTitleTemplate = getTemplate<'ArrayFieldTitleTemplate', T, S, F>(
31
32
  'ArrayFieldTitleTemplate',
32
33
  registry,
33
- uiOptions
34
+ uiOptions,
34
35
  );
35
36
  // Button templates are not overridden in the uiSchema
36
37
  const {
@@ -56,7 +57,7 @@ export default function ArrayFieldTemplate<
56
57
  <Grid key={`array-item-list-${idSchema.$id}`}>
57
58
  <GridItem>
58
59
  {items.length > 0 &&
59
- items.map(({ key, ...itemProps }: ArrayFieldTemplateItemType<T, S, F>) => (
60
+ items.map(({ key, ...itemProps }: ArrayFieldItemTemplateType<T, S, F>) => (
60
61
  <ArrayFieldItemTemplate key={key} {...itemProps} />
61
62
  ))}
62
63
  </GridItem>
@@ -64,7 +65,8 @@ export default function ArrayFieldTemplate<
64
65
  <GridItem justifySelf={'flex-end'}>
65
66
  <Box mt={2}>
66
67
  <AddButton
67
- className='array-item-add'
68
+ id={buttonId<T>(idSchema, 'add')}
69
+ className='rjsf-array-item-add'
68
70
  onClick={onAddClick}
69
71
  disabled={disabled || readonly}
70
72
  uiSchema={uiSchema}
@@ -1,5 +1,5 @@
1
1
  import { ChangeEvent, FocusEvent } from 'react';
2
- import { FormControl, FormLabel, Input } from '@chakra-ui/react';
2
+ import { Input } from '@chakra-ui/react';
3
3
  import {
4
4
  ariaDescribedByIds,
5
5
  BaseInputTemplateProps,
@@ -10,12 +10,13 @@ import {
10
10
  RJSFSchema,
11
11
  StrictRJSFSchema,
12
12
  } from '@rjsf/utils';
13
- import { getChakra } from '../utils';
13
+
14
+ import { Field } from '../components/ui/field';
14
15
 
15
16
  export default function BaseInputTemplate<
16
17
  T = any,
17
18
  S extends StrictRJSFSchema = RJSFSchema,
18
- F extends FormContextType = any
19
+ F extends FormContextType = any,
19
20
  >(props: BaseInputTemplateProps<T, S, F>) {
20
21
  const {
21
22
  id,
@@ -24,7 +25,6 @@ export default function BaseInputTemplate<
24
25
  label,
25
26
  hideLabel,
26
27
  schema,
27
- uiSchema,
28
28
  onChange,
29
29
  onChangeOverride,
30
30
  onBlur,
@@ -38,7 +38,6 @@ export default function BaseInputTemplate<
38
38
  disabled,
39
39
  } = props;
40
40
  const inputProps = getInputProps<T, S, F>(schema, type, options);
41
- const chakraProps = getChakra({ uiSchema });
42
41
 
43
42
  const _onChange = ({ target: { value } }: ChangeEvent<HTMLInputElement>) =>
44
43
  onChange(value === '' ? options.emptyValue : value);
@@ -46,20 +45,14 @@ export default function BaseInputTemplate<
46
45
  const _onFocus = ({ target }: FocusEvent<HTMLInputElement>) => onFocus(id, target && target.value);
47
46
 
48
47
  return (
49
- <FormControl
48
+ <Field
50
49
  mb={1}
51
- {...chakraProps}
52
- isDisabled={disabled || readonly}
53
- isRequired={required}
54
- isReadOnly={readonly}
55
- isInvalid={rawErrors && rawErrors.length > 0}
50
+ disabled={disabled || readonly}
51
+ required={required}
52
+ readOnly={readonly}
53
+ invalid={rawErrors && rawErrors.length > 0}
54
+ label={labelValue(label, hideLabel || !label)}
56
55
  >
57
- {labelValue(
58
- <FormLabel htmlFor={id} id={`${id}-label`}>
59
- {label}
60
- </FormLabel>,
61
- hideLabel || !label
62
- )}
63
56
  <Input
64
57
  id={id}
65
58
  name={id}
@@ -82,6 +75,6 @@ export default function BaseInputTemplate<
82
75
  })}
83
76
  </datalist>
84
77
  ) : null}
85
- </FormControl>
78
+ </Field>
86
79
  );
87
80
  }
@@ -1,8 +1,7 @@
1
1
  import { CacheProvider } from '@emotion/react';
2
2
  import createCache from '@emotion/cache';
3
3
  import weakMemoize from '@emotion/weak-memoize';
4
- import { ChakraProvider } from '@chakra-ui/react';
5
- import CSSReset from './CssReset';
4
+ import { ChakraProvider, defaultSystem } from '@chakra-ui/react';
6
5
 
7
6
  /**
8
7
  * __createChakraFrameProvider is used to ensure that <Global> emotion components
@@ -30,8 +29,8 @@ export const __createChakraFrameProvider =
30
29
  return (
31
30
  <div style={{ margin: 2 }}>
32
31
  <CacheProvider value={memoizedCreateCacheWithContainer(document.head)}>
33
- <ChakraProvider resetCSS={false}>
34
- <CSSReset />
32
+ <ChakraProvider value={defaultSystem}>
33
+ {/* <CSSReset /> TODO: figrue out styling issues */}
35
34
  {props.children}
36
35
  </ChakraProvider>
37
36
  </CacheProvider>
@@ -1,5 +1,5 @@
1
- import { ChangeEvent, FocusEvent } from 'react';
2
- import { Checkbox, FormControl, Text } from '@chakra-ui/react';
1
+ import { FocusEvent } from 'react';
2
+ import { CheckboxCheckedChangeDetails, Text } from '@chakra-ui/react';
3
3
  import {
4
4
  ariaDescribedByIds,
5
5
  descriptionId,
@@ -11,12 +11,14 @@ import {
11
11
  RJSFSchema,
12
12
  FormContextType,
13
13
  } from '@rjsf/utils';
14
- import { getChakra } from '../utils';
14
+
15
+ import { Field } from '../components/ui/field';
16
+ import { Checkbox } from '../components/ui/checkbox';
15
17
 
16
18
  export default function CheckboxWidget<
17
19
  T = any,
18
20
  S extends StrictRJSFSchema = RJSFSchema,
19
- F extends FormContextType = any
21
+ F extends FormContextType = any,
20
22
  >(props: WidgetProps<T, S, F>) {
21
23
  const {
22
24
  id,
@@ -33,7 +35,6 @@ export default function CheckboxWidget<
33
35
  uiSchema,
34
36
  schema,
35
37
  } = props;
36
- const chakraProps = getChakra({ uiSchema });
37
38
  // Because an unchecked checkbox will cause html5 validation to fail, only add
38
39
  // the "required" attribute if the field value must be "true", due to the
39
40
  // "const" or "enum" keywords
@@ -41,16 +42,16 @@ export default function CheckboxWidget<
41
42
  const DescriptionFieldTemplate = getTemplate<'DescriptionFieldTemplate', T, S, F>(
42
43
  'DescriptionFieldTemplate',
43
44
  registry,
44
- options
45
+ options,
45
46
  );
46
47
  const description = options.description || schema.description;
47
48
 
48
- const _onChange = ({ target: { checked } }: ChangeEvent<HTMLInputElement>) => onChange(checked);
49
+ const _onChange = ({ checked }: CheckboxCheckedChangeDetails) => onChange(checked);
49
50
  const _onBlur = ({ target }: FocusEvent<HTMLInputElement | any>) => onBlur(id, target && target.value);
50
51
  const _onFocus = ({ target }: FocusEvent<HTMLInputElement | any>) => onFocus(id, target && target.value);
51
52
 
52
53
  return (
53
- <FormControl mb={1} {...chakraProps} isRequired={required}>
54
+ <Field mb={1} required={required}>
54
55
  {!hideLabel && !!description && (
55
56
  <DescriptionFieldTemplate
56
57
  id={descriptionId<T>(id)}
@@ -63,15 +64,15 @@ export default function CheckboxWidget<
63
64
  <Checkbox
64
65
  id={id}
65
66
  name={id}
66
- isChecked={typeof value === 'undefined' ? false : value}
67
- isDisabled={disabled || readonly}
68
- onChange={_onChange}
67
+ checked={typeof value === 'undefined' ? false : value}
68
+ disabled={disabled || readonly}
69
+ onCheckedChange={_onChange}
69
70
  onBlur={_onBlur}
70
71
  onFocus={_onFocus}
71
72
  aria-describedby={ariaDescribedByIds<T>(id)}
72
73
  >
73
74
  {labelValue(<Text>{label}</Text>, hideLabel || !label)}
74
75
  </Checkbox>
75
- </FormControl>
76
+ </Field>
76
77
  );
77
78
  }
@@ -1,23 +1,23 @@
1
- import { FocusEvent } from 'react';
2
- import { CheckboxGroup, Checkbox, FormLabel, FormControl, Text, Stack } from '@chakra-ui/react';
1
+ import { CheckboxGroup, FieldsetRoot, Stack, Text } from '@chakra-ui/react';
3
2
  import {
4
3
  ariaDescribedByIds,
5
4
  enumOptionsIndexForValue,
6
- enumOptionsIsSelected,
7
5
  enumOptionsValueForIndex,
6
+ FormContextType,
8
7
  labelValue,
9
8
  optionId,
10
- FormContextType,
11
9
  RJSFSchema,
12
10
  StrictRJSFSchema,
13
11
  WidgetProps,
14
12
  } from '@rjsf/utils';
15
- import { getChakra } from '../utils';
13
+ import { FocusEvent } from 'react';
14
+
15
+ import { Checkbox } from '../components/ui/checkbox';
16
16
 
17
17
  export default function CheckboxesWidget<
18
18
  T = any,
19
19
  S extends StrictRJSFSchema = RJSFSchema,
20
- F extends FormContextType = any
20
+ F extends FormContextType = any,
21
21
  >(props: WidgetProps<T, S, F>) {
22
22
  const {
23
23
  id,
@@ -31,12 +31,9 @@ export default function CheckboxesWidget<
31
31
  required,
32
32
  label,
33
33
  hideLabel,
34
- uiSchema,
35
34
  rawErrors = [],
36
35
  } = props;
37
36
  const { enumOptions, enumDisabled, emptyValue } = options;
38
- const chakraProps = getChakra({ uiSchema });
39
- const checkboxesValues = Array.isArray(value) ? value : [value];
40
37
 
41
38
  const _onBlur = ({ target }: FocusEvent<HTMLInputElement | any>) =>
42
39
  onBlur(id, enumOptionsValueForIndex<S>(target && target.value, enumOptions, emptyValue));
@@ -47,29 +44,18 @@ export default function CheckboxesWidget<
47
44
  const selectedIndexes = enumOptionsIndexForValue<S>(value, enumOptions, true) as string[];
48
45
 
49
46
  return (
50
- <FormControl
51
- mb={1}
52
- {...chakraProps}
53
- isDisabled={disabled || readonly}
54
- isRequired={required}
55
- isReadOnly={readonly}
56
- isInvalid={rawErrors && rawErrors.length > 0}
57
- >
58
- {labelValue(
59
- <FormLabel htmlFor={id} id={`${id}-label`}>
60
- {label}
61
- </FormLabel>,
62
- hideLabel || !label
63
- )}
47
+ <FieldsetRoot mb={1} disabled={disabled || readonly} invalid={rawErrors && rawErrors.length > 0}>
64
48
  <CheckboxGroup
65
- onChange={(option) => onChange(enumOptionsValueForIndex<S>(option, enumOptions, emptyValue))}
66
- defaultValue={selectedIndexes}
49
+ onValueChange={(option) => onChange(enumOptionsValueForIndex<S>(option, enumOptions, emptyValue))}
50
+ value={selectedIndexes}
67
51
  aria-describedby={ariaDescribedByIds<T>(id)}
52
+ readOnly={readonly}
53
+ required={required}
54
+ label={labelValue(label, hideLabel || !label)}
68
55
  >
69
56
  <Stack direction={row ? 'row' : 'column'}>
70
57
  {Array.isArray(enumOptions) &&
71
58
  enumOptions.map((option, index) => {
72
- const checked = enumOptionsIsSelected<S>(option.value, checkboxesValues);
73
59
  const itemDisabled = Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) !== -1;
74
60
  return (
75
61
  <Checkbox
@@ -77,8 +63,7 @@ export default function CheckboxesWidget<
77
63
  id={optionId(id, index)}
78
64
  name={id}
79
65
  value={String(index)}
80
- isChecked={checked}
81
- isDisabled={disabled || itemDisabled || readonly}
66
+ disabled={disabled || itemDisabled || readonly}
82
67
  onBlur={_onBlur}
83
68
  onFocus={_onFocus}
84
69
  >
@@ -88,6 +73,6 @@ export default function CheckboxesWidget<
88
73
  })}
89
74
  </Stack>
90
75
  </CheckboxGroup>
91
- </FormControl>
76
+ </FieldsetRoot>
92
77
  );
93
78
  }
@@ -4,7 +4,7 @@ import { Text } from '@chakra-ui/react';
4
4
  export default function DescriptionField<
5
5
  T = any,
6
6
  S extends StrictRJSFSchema = RJSFSchema,
7
- F extends FormContextType = any
7
+ F extends FormContextType = any,
8
8
  >({ description, id }: DescriptionFieldProps<T, S, F>) {
9
9
  if (!description) {
10
10
  return null;