@rjsf/chakra-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.
Files changed (149) hide show
  1. package/dist/chakra-ui.esm.js +147 -189
  2. package/dist/chakra-ui.esm.js.map +3 -3
  3. package/dist/chakra-ui.umd.js +135 -133
  4. package/dist/index.cjs +237 -234
  5. package/dist/index.cjs.map +3 -3
  6. package/lib/AddButton/AddButton.d.ts +1 -1
  7. package/lib/AddButton/AddButton.js.map +1 -1
  8. package/lib/AltDateTimeWidget/AltDateTimeWidget.d.ts +1 -1
  9. package/lib/AltDateWidget/AltDateWidget.d.ts +1 -1
  10. package/lib/AltDateWidget/AltDateWidget.js +1 -1
  11. package/lib/AltDateWidget/AltDateWidget.js.map +1 -1
  12. package/lib/ArrayFieldItemTemplate/ArrayFieldItemTemplate.d.ts +1 -1
  13. package/lib/ArrayFieldItemTemplate/ArrayFieldItemTemplate.js +1 -1
  14. package/lib/ArrayFieldItemTemplate/ArrayFieldItemTemplate.js.map +1 -1
  15. package/lib/ArrayFieldTemplate/ArrayFieldTemplate.d.ts +1 -1
  16. package/lib/ArrayFieldTemplate/ArrayFieldTemplate.js +1 -1
  17. package/lib/ArrayFieldTemplate/ArrayFieldTemplate.js.map +1 -1
  18. package/lib/BaseInputTemplate/BaseInputTemplate.d.ts +1 -1
  19. package/lib/BaseInputTemplate/BaseInputTemplate.js +5 -5
  20. package/lib/BaseInputTemplate/BaseInputTemplate.js.map +1 -1
  21. package/lib/ChakraFrameProvider.js +1 -3
  22. package/lib/ChakraFrameProvider.js.map +1 -1
  23. package/lib/CheckboxWidget/CheckboxWidget.d.ts +1 -1
  24. package/lib/CheckboxWidget/CheckboxWidget.js +4 -4
  25. package/lib/CheckboxWidget/CheckboxWidget.js.map +1 -1
  26. package/lib/CheckboxesWidget/CheckboxesWidget.d.ts +1 -1
  27. package/lib/CheckboxesWidget/CheckboxesWidget.js +4 -4
  28. package/lib/CheckboxesWidget/CheckboxesWidget.js.map +1 -1
  29. package/lib/DescriptionField/DescriptionField.d.ts +1 -1
  30. package/lib/ErrorList/ErrorList.d.ts +1 -1
  31. package/lib/ErrorList/ErrorList.js.map +1 -1
  32. package/lib/FieldErrorTemplate/FieldErrorTemplate.d.ts +1 -1
  33. package/lib/FieldErrorTemplate/FieldErrorTemplate.js +1 -3
  34. package/lib/FieldErrorTemplate/FieldErrorTemplate.js.map +1 -1
  35. package/lib/FieldHelpTemplate/FieldHelpTemplate.d.ts +1 -1
  36. package/lib/FieldHelpTemplate/FieldHelpTemplate.js.map +1 -1
  37. package/lib/FieldTemplate/FieldTemplate.d.ts +1 -1
  38. package/lib/FieldTemplate/FieldTemplate.js +1 -1
  39. package/lib/FieldTemplate/FieldTemplate.js.map +1 -1
  40. package/lib/Form/Form.d.ts +3 -3
  41. package/lib/Form/Form.js.map +1 -1
  42. package/lib/GridTemplate/GridTemplate.d.ts +1 -1
  43. package/lib/IconButton/ChakraIconButton.d.ts +2 -2
  44. package/lib/IconButton/ChakraIconButton.js.map +1 -1
  45. package/lib/IconButton/IconButton.d.ts +13 -7
  46. package/lib/IconButton/IconButton.js +11 -5
  47. package/lib/IconButton/IconButton.js.map +1 -1
  48. package/lib/MultiSchemaFieldTemplate/MultiSchemaFieldTemplate.d.ts +1 -1
  49. package/lib/NativeSelectWidget/NativeSelectWidget.d.ts +1 -1
  50. package/lib/NativeSelectWidget/NativeSelectWidget.js +13 -15
  51. package/lib/NativeSelectWidget/NativeSelectWidget.js.map +1 -1
  52. package/lib/ObjectFieldTemplate/ObjectFieldTemplate.d.ts +1 -1
  53. package/lib/ObjectFieldTemplate/ObjectFieldTemplate.js +2 -2
  54. package/lib/ObjectFieldTemplate/ObjectFieldTemplate.js.map +1 -1
  55. package/lib/OptionalDataControlsTemplate/OptionalDataControlsTemplate.d.ts +1 -1
  56. package/lib/OptionalDataControlsTemplate/OptionalDataControlsTemplate.js +1 -1
  57. package/lib/OptionalDataControlsTemplate/OptionalDataControlsTemplate.js.map +1 -1
  58. package/lib/RadioWidget/RadioWidget.d.ts +1 -1
  59. package/lib/RadioWidget/RadioWidget.js +6 -6
  60. package/lib/RadioWidget/RadioWidget.js.map +1 -1
  61. package/lib/RangeWidget/RangeWidget.d.ts +1 -1
  62. package/lib/RangeWidget/RangeWidget.js +5 -5
  63. package/lib/RangeWidget/RangeWidget.js.map +1 -1
  64. package/lib/SelectWidget/SelectWidget.d.ts +1 -1
  65. package/lib/SelectWidget/SelectWidget.js +15 -17
  66. package/lib/SelectWidget/SelectWidget.js.map +1 -1
  67. package/lib/SubmitButton/SubmitButton.d.ts +1 -1
  68. package/lib/SubmitButton/SubmitButton.js.map +1 -1
  69. package/lib/Templates/Templates.d.ts +1 -1
  70. package/lib/TextareaWidget/TextareaWidget.d.ts +1 -1
  71. package/lib/TextareaWidget/TextareaWidget.js +5 -5
  72. package/lib/TextareaWidget/TextareaWidget.js.map +1 -1
  73. package/lib/Theme/Theme.d.ts +2 -2
  74. package/lib/TitleField/TitleField.d.ts +1 -1
  75. package/lib/UpDownWidget/UpDownWidget.d.ts +1 -1
  76. package/lib/UpDownWidget/UpDownWidget.js +5 -5
  77. package/lib/UpDownWidget/UpDownWidget.js.map +1 -1
  78. package/lib/Widgets/Widgets.d.ts +1 -1
  79. package/lib/WrapIfAdditionalTemplate/WrapIfAdditionalTemplate.d.ts +1 -1
  80. package/lib/WrapIfAdditionalTemplate/WrapIfAdditionalTemplate.js +1 -1
  81. package/lib/WrapIfAdditionalTemplate/WrapIfAdditionalTemplate.js.map +1 -1
  82. package/lib/components/ui/alert.d.ts +1 -1
  83. package/lib/components/ui/alert.js +1 -1
  84. package/lib/components/ui/alert.js.map +1 -1
  85. package/lib/components/ui/checkbox.d.ts +1 -1
  86. package/lib/components/ui/checkbox.js +1 -1
  87. package/lib/components/ui/checkbox.js.map +1 -1
  88. package/lib/components/ui/close-button.js +1 -1
  89. package/lib/components/ui/close-button.js.map +1 -1
  90. package/lib/components/ui/field.d.ts +1 -1
  91. package/lib/components/ui/field.js +1 -1
  92. package/lib/components/ui/field.js.map +1 -1
  93. package/lib/components/ui/number-input.js +1 -1
  94. package/lib/components/ui/number-input.js.map +1 -1
  95. package/lib/components/ui/radio.d.ts +1 -1
  96. package/lib/components/ui/radio.js +1 -1
  97. package/lib/components/ui/radio.js.map +1 -1
  98. package/lib/components/ui/select.d.ts +1 -1
  99. package/lib/components/ui/select.js +13 -17
  100. package/lib/components/ui/select.js.map +1 -1
  101. package/lib/components/ui/slider.d.ts +2 -2
  102. package/lib/components/ui/slider.js +19 -19
  103. package/lib/components/ui/slider.js.map +1 -1
  104. package/lib/tsconfig.tsbuildinfo +1 -1
  105. package/lib/utils.d.ts +2 -2
  106. package/lib/utils.js.map +1 -1
  107. package/package.json +8 -9
  108. package/src/AddButton/AddButton.tsx +2 -1
  109. package/src/AltDateTimeWidget/AltDateTimeWidget.tsx +1 -1
  110. package/src/AltDateWidget/AltDateWidget.tsx +2 -10
  111. package/src/ArrayFieldItemTemplate/ArrayFieldItemTemplate.tsx +3 -9
  112. package/src/ArrayFieldTemplate/ArrayFieldTemplate.tsx +2 -9
  113. package/src/BaseInputTemplate/BaseInputTemplate.tsx +11 -18
  114. package/src/ChakraFrameProvider.tsx +7 -9
  115. package/src/CheckboxWidget/CheckboxWidget.tsx +10 -12
  116. package/src/CheckboxesWidget/CheckboxesWidget.tsx +8 -11
  117. package/src/DescriptionField/DescriptionField.tsx +1 -1
  118. package/src/ErrorList/ErrorList.tsx +3 -1
  119. package/src/FieldErrorTemplate/FieldErrorTemplate.tsx +8 -8
  120. package/src/FieldHelpTemplate/FieldHelpTemplate.tsx +2 -1
  121. package/src/FieldTemplate/FieldTemplate.tsx +2 -8
  122. package/src/Form/Form.tsx +4 -3
  123. package/src/GridTemplate/GridTemplate.tsx +1 -1
  124. package/src/IconButton/ChakraIconButton.tsx +9 -3
  125. package/src/IconButton/IconButton.tsx +15 -7
  126. package/src/MultiSchemaFieldTemplate/MultiSchemaFieldTemplate.tsx +1 -1
  127. package/src/NativeSelectWidget/NativeSelectWidget.tsx +20 -29
  128. package/src/ObjectFieldTemplate/ObjectFieldTemplate.tsx +4 -18
  129. package/src/OptionalDataControlsTemplate/OptionalDataControlsTemplate.tsx +3 -2
  130. package/src/RadioWidget/RadioWidget.tsx +13 -16
  131. package/src/RangeWidget/RangeWidget.tsx +11 -18
  132. package/src/SelectWidget/SelectWidget.tsx +24 -27
  133. package/src/SubmitButton/SubmitButton.tsx +2 -1
  134. package/src/Templates/Templates.ts +1 -1
  135. package/src/TextareaWidget/TextareaWidget.tsx +10 -16
  136. package/src/Theme/Theme.tsx +2 -2
  137. package/src/TitleField/TitleField.tsx +1 -1
  138. package/src/UpDownWidget/UpDownWidget.tsx +10 -16
  139. package/src/Widgets/Widgets.ts +1 -1
  140. package/src/WrapIfAdditionalTemplate/WrapIfAdditionalTemplate.tsx +2 -9
  141. package/src/components/ui/alert.tsx +3 -2
  142. package/src/components/ui/checkbox.tsx +3 -2
  143. package/src/components/ui/close-button.tsx +5 -7
  144. package/src/components/ui/field.tsx +3 -2
  145. package/src/components/ui/number-input.tsx +1 -1
  146. package/src/components/ui/radio.tsx +3 -2
  147. package/src/components/ui/select.tsx +31 -36
  148. package/src/components/ui/slider.tsx +37 -35
  149. package/src/utils.ts +3 -2
package/lib/utils.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { Field as ChakraField } from '@chakra-ui/react';
2
- import { UiSchema } from '@rjsf/utils';
1
+ import type { Field as ChakraField } from '@chakra-ui/react';
2
+ import type { UiSchema } from '@rjsf/utils';
3
3
  export interface ChakraUiSchema extends Omit<UiSchema, 'ui:options'> {
4
4
  'ui:options'?: ChakraUiOptions;
5
5
  }
package/lib/utils.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwB,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACvE,OAAO,iBAAiB,MAAM,wBAAwB,CAAC;AAGvD,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"}
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,iBAAiB,MAAM,wBAAwB,CAAC;AAGvD,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,6 +1,6 @@
1
1
  {
2
2
  "name": "@rjsf/chakra-ui",
3
- "version": "6.6.0",
3
+ "version": "6.6.2",
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",
@@ -49,7 +49,7 @@
49
49
  "lint": "oxlint src test",
50
50
  "precommit": "lint-staged",
51
51
  "test": "vitest run",
52
- "test:update": "vitest run --update-snapshots",
52
+ "test:update": "vitest run --update",
53
53
  "test:watch": "vitest",
54
54
  "type-check": "tsc --noEmit"
55
55
  },
@@ -65,8 +65,8 @@
65
65
  },
66
66
  "peerDependencies": {
67
67
  "@chakra-ui/react": ">=3.16.1",
68
- "@rjsf/core": "^6.5.x",
69
- "@rjsf/utils": "^6.5.x",
68
+ "@rjsf/core": "^6.6.x",
69
+ "@rjsf/utils": "^6.6.x",
70
70
  "chakra-react-select": ">=6",
71
71
  "react": ">=18"
72
72
  },
@@ -86,14 +86,13 @@
86
86
  },
87
87
  "license": "Apache-2.0",
88
88
  "devDependencies": {
89
- "@chakra-ui/cli": "^3.35.0",
90
89
  "@chakra-ui/react": "^3.35.0",
91
90
  "@emotion/jest": "^11.14.2",
92
91
  "@emotion/react": "^11.14.0",
93
- "@rjsf/core": "6.6.0",
94
- "@rjsf/snapshot-tests": "6.6.0",
95
- "@rjsf/utils": "6.6.0",
96
- "@rjsf/validator-ajv8": "6.6.0",
92
+ "@rjsf/core": "6.6.2",
93
+ "@rjsf/snapshot-tests": "6.6.2",
94
+ "@rjsf/utils": "6.6.2",
95
+ "@rjsf/validator-ajv8": "6.6.2",
97
96
  "chakra-react-select": "^6.1.3"
98
97
  },
99
98
  "dependencies": {
@@ -1,5 +1,6 @@
1
1
  import { Button } from '@chakra-ui/react';
2
- import { FormContextType, IconButtonProps, RJSFSchema, StrictRJSFSchema, TranslatableString } from '@rjsf/utils';
2
+ import type { FormContextType, IconButtonProps, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
3
+ import { TranslatableString } from '@rjsf/utils';
3
4
  import { PlusIcon } from 'lucide-react';
4
5
 
5
6
  export default function AddButton<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>({
@@ -1,4 +1,4 @@
1
- import { FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps } from '@rjsf/utils';
1
+ import type { FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps } from '@rjsf/utils';
2
2
 
3
3
  function AltDateTimeWidget<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>({
4
4
  time = true,
@@ -1,14 +1,6 @@
1
1
  import { Box, Button, FieldsetRoot } from '@chakra-ui/react';
2
- import {
3
- DateElement,
4
- DateElementProp,
5
- FormContextType,
6
- RJSFSchema,
7
- StrictRJSFSchema,
8
- TranslatableString,
9
- useAltDateWidgetProps,
10
- WidgetProps,
11
- } from '@rjsf/utils';
2
+ import type { DateElementProp, FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps } from '@rjsf/utils';
3
+ import { DateElement, TranslatableString, useAltDateWidgetProps } from '@rjsf/utils';
12
4
 
13
5
  import { getChakra } from '../utils';
14
6
 
@@ -1,12 +1,6 @@
1
1
  import { Box, ButtonGroup, HStack } from '@chakra-ui/react';
2
- import {
3
- ArrayFieldItemTemplateProps,
4
- FormContextType,
5
- getTemplate,
6
- getUiOptions,
7
- RJSFSchema,
8
- StrictRJSFSchema,
9
- } from '@rjsf/utils';
2
+ import type { ArrayFieldItemTemplateProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
3
+ import { getTemplate, getUiOptions } from '@rjsf/utils';
10
4
 
11
5
  export default function ArrayFieldItemTemplate<
12
6
  T = any,
@@ -22,7 +16,7 @@ export default function ArrayFieldItemTemplate<
22
16
  );
23
17
 
24
18
  return (
25
- <HStack alignItems={'flex-end'} py={1}>
19
+ <HStack alignItems='flex-end' py={1}>
26
20
  <Box w='100%'>{children}</Box>
27
21
  {hasToolbar && (
28
22
  <Box>
@@ -1,13 +1,6 @@
1
1
  import { Box, Grid, GridItem } from '@chakra-ui/react';
2
- import {
3
- getTemplate,
4
- getUiOptions,
5
- ArrayFieldTemplateProps,
6
- StrictRJSFSchema,
7
- RJSFSchema,
8
- FormContextType,
9
- buttonId,
10
- } from '@rjsf/utils';
2
+ import type { ArrayFieldTemplateProps, StrictRJSFSchema, RJSFSchema, FormContextType } from '@rjsf/utils';
3
+ import { getTemplate, getUiOptions, buttonId } from '@rjsf/utils';
11
4
 
12
5
  export default function ArrayFieldTemplate<
13
6
  T = any,
@@ -1,16 +1,9 @@
1
- import { ChangeEvent, FocusEvent, MouseEvent, useCallback } from 'react';
1
+ import type { ChangeEvent, FocusEvent, MouseEvent } from 'react';
2
+ import { useCallback } from 'react';
2
3
  import { Input } from '@chakra-ui/react';
3
4
  import { SchemaExamples } from '@rjsf/core';
4
- import {
5
- ariaDescribedByIds,
6
- BaseInputTemplateProps,
7
- examplesId,
8
- labelValue,
9
- FormContextType,
10
- getInputProps,
11
- RJSFSchema,
12
- StrictRJSFSchema,
13
- } from '@rjsf/utils';
5
+ import type { BaseInputTemplateProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
6
+ import { ariaDescribedByIds, examplesId, labelValue, getInputProps } from '@rjsf/utils';
14
7
 
15
8
  import { Field } from '../components/ui/field';
16
9
  import { getChakra } from '../utils';
@@ -45,10 +38,10 @@ export default function BaseInputTemplate<
45
38
  const inputProps = getInputProps<T, S, F>(schema, type, options);
46
39
  const { ClearButton } = registry.templates.ButtonTemplates;
47
40
 
48
- const _onChange = ({ target: { value } }: ChangeEvent<HTMLInputElement>) =>
49
- onChange(value === '' ? options.emptyValue : value);
50
- const _onBlur = ({ target }: FocusEvent<HTMLInputElement>) => onBlur(id, target && target.value);
51
- const _onFocus = ({ target }: FocusEvent<HTMLInputElement>) => onFocus(id, target && target.value);
41
+ const handleChange = ({ target: { value: newValue } }: ChangeEvent<HTMLInputElement>) =>
42
+ onChange(newValue === '' ? options.emptyValue : newValue);
43
+ const handleBlur = ({ target }: FocusEvent<HTMLInputElement>) => onBlur(id, target && target.value);
44
+ const handleFocus = ({ target }: FocusEvent<HTMLInputElement>) => onFocus(id, target && target.value);
52
45
  const onClear = useCallback(
53
46
  (e: MouseEvent) => {
54
47
  e.preventDefault();
@@ -74,9 +67,9 @@ export default function BaseInputTemplate<
74
67
  id={id}
75
68
  name={htmlName || id}
76
69
  value={value || value === 0 ? value : ''}
77
- onChange={onChangeOverride || _onChange}
78
- onBlur={_onBlur}
79
- onFocus={_onFocus}
70
+ onChange={onChangeOverride || handleChange}
71
+ onBlur={handleBlur}
72
+ onFocus={handleFocus}
80
73
  autoFocus={autofocus}
81
74
  placeholder={placeholder}
82
75
  {...inputProps}
@@ -25,12 +25,10 @@ const memoizedCreateCacheWithContainer = weakMemoize((container: HTMLElement) =>
25
25
 
26
26
  export const __createChakraFrameProvider =
27
27
  (props: any) =>
28
- ({ document }: any) => {
29
- return (
30
- <div style={{ margin: 2 }}>
31
- <CacheProvider value={memoizedCreateCacheWithContainer(document.head)}>
32
- <ChakraProvider value={defaultSystem}>{props.children}</ChakraProvider>
33
- </CacheProvider>
34
- </div>
35
- );
36
- };
28
+ ({ document }: any) => (
29
+ <div style={{ margin: 2 }}>
30
+ <CacheProvider value={memoizedCreateCacheWithContainer(document.head)}>
31
+ <ChakraProvider value={defaultSystem}>{props.children}</ChakraProvider>
32
+ </CacheProvider>
33
+ </div>
34
+ );
@@ -1,15 +1,13 @@
1
- import { FocusEvent } from 'react';
2
- import { CheckboxCheckedChangeDetails, Text } from '@chakra-ui/react';
1
+ import type { FocusEvent } from 'react';
2
+ import type { CheckboxCheckedChangeDetails } from '@chakra-ui/react';
3
+ import { Text } from '@chakra-ui/react';
4
+ import type { WidgetProps, StrictRJSFSchema, RJSFSchema, FormContextType } from '@rjsf/utils';
3
5
  import {
4
6
  ariaDescribedByIds,
5
7
  descriptionId,
6
8
  getTemplate,
7
9
  labelValue,
8
- WidgetProps,
9
10
  schemaRequiresTrueValue,
10
- StrictRJSFSchema,
11
- RJSFSchema,
12
- FormContextType,
13
11
  getUiOptions,
14
12
  } from '@rjsf/utils';
15
13
 
@@ -51,9 +49,9 @@ export default function CheckboxWidget<
51
49
  const isCheckbox = uiOptions.widget === 'checkbox';
52
50
  const description = isCheckbox ? undefined : (options.description ?? schema.description);
53
51
 
54
- const _onChange = ({ checked }: CheckboxCheckedChangeDetails) => onChange(checked);
55
- const _onBlur = ({ target }: FocusEvent<HTMLInputElement | any>) => onBlur(id, target && target.checked);
56
- const _onFocus = ({ target }: FocusEvent<HTMLInputElement | any>) => onFocus(id, target && target.checked);
52
+ const handleChange = ({ checked }: CheckboxCheckedChangeDetails) => onChange(checked);
53
+ const handleBlur = ({ target }: FocusEvent<HTMLInputElement | any>) => onBlur(id, target && target.checked);
54
+ const handleFocus = ({ target }: FocusEvent<HTMLInputElement | any>) => onFocus(id, target && target.checked);
57
55
 
58
56
  const chakraProps = getChakra({ uiSchema });
59
57
 
@@ -73,9 +71,9 @@ export default function CheckboxWidget<
73
71
  name={htmlName || id}
74
72
  checked={typeof value === 'undefined' ? false : value}
75
73
  disabled={disabled || readonly}
76
- onCheckedChange={_onChange}
77
- onBlur={_onBlur}
78
- onFocus={_onFocus}
74
+ onCheckedChange={handleChange}
75
+ onBlur={handleBlur}
76
+ onFocus={handleFocus}
79
77
  aria-describedby={ariaDescribedByIds(id)}
80
78
  >
81
79
  {labelValue(<Text>{label}</Text>, hideLabel || !label)}
@@ -1,16 +1,13 @@
1
- import { FocusEvent } from 'react';
1
+ import type { FocusEvent } from 'react';
2
2
  import { CheckboxGroup, FieldsetRoot, Stack, Text, FieldsetLegend } from '@chakra-ui/react';
3
+ import type { FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps } from '@rjsf/utils';
3
4
  import {
4
5
  ariaDescribedByIds,
5
6
  enumOptionSelectedValue,
6
7
  enumOptionValueDecoder,
7
8
  enumOptionValueEncoder,
8
9
  getOptionValueFormat,
9
- FormContextType,
10
10
  optionId,
11
- RJSFSchema,
12
- StrictRJSFSchema,
13
- WidgetProps,
14
11
  labelValue,
15
12
  } from '@rjsf/utils';
16
13
 
@@ -41,9 +38,9 @@ export default function CheckboxesWidget<
41
38
  const { enumOptions, enumDisabled, emptyValue } = options;
42
39
  const optionValueFormat = getOptionValueFormat(options);
43
40
 
44
- const _onBlur = ({ target }: FocusEvent<HTMLInputElement | any>) =>
41
+ const handleBlur = ({ target }: FocusEvent<HTMLInputElement | any>) =>
45
42
  onBlur(id, enumOptionValueDecoder<S>(target && target.value, enumOptions, optionValueFormat, emptyValue));
46
- const _onFocus = ({ target }: FocusEvent<HTMLInputElement | any>) =>
43
+ const handleFocus = ({ target }: FocusEvent<HTMLInputElement | any>) =>
47
44
  onFocus(id, enumOptionValueDecoder<S>(target && target.value, enumOptions, optionValueFormat, emptyValue));
48
45
 
49
46
  const row = options ? options.inline : false;
@@ -71,16 +68,16 @@ export default function CheckboxesWidget<
71
68
  <Stack direction={row ? 'row' : 'column'}>
72
69
  {Array.isArray(enumOptions) &&
73
70
  enumOptions.map((option, index) => {
74
- const itemDisabled = Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) !== -1;
71
+ const itemDisabled = Array.isArray(enumDisabled) && enumDisabled.includes(option.value);
75
72
  return (
76
73
  <Checkbox
77
- key={index}
74
+ key={String(option.value)}
78
75
  id={optionId(id, index)}
79
76
  name={htmlName || id}
80
77
  value={enumOptionValueEncoder(option.value, index, optionValueFormat)}
81
78
  disabled={disabled || itemDisabled || readonly}
82
- onBlur={_onBlur}
83
- onFocus={_onFocus}
79
+ onBlur={handleBlur}
80
+ onFocus={handleFocus}
84
81
  >
85
82
  {option.label && <Text>{option.label}</Text>}
86
83
  </Checkbox>
@@ -1,6 +1,6 @@
1
1
  import { Text } from '@chakra-ui/react';
2
2
  import { RichDescription } from '@rjsf/core';
3
- import { DescriptionFieldProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
3
+ import type { DescriptionFieldProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
4
4
 
5
5
  /** The `DescriptionField` is the template to use to render the description of a field
6
6
  *
@@ -1,5 +1,6 @@
1
1
  import { ListItem, ListRoot } from '@chakra-ui/react';
2
- import { ErrorListProps, FormContextType, RJSFSchema, StrictRJSFSchema, TranslatableString } from '@rjsf/utils';
2
+ import type { ErrorListProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
3
+ import { TranslatableString } from '@rjsf/utils';
3
4
 
4
5
  import { Alert } from '../components/ui/alert';
5
6
 
@@ -12,6 +13,7 @@ export default function ErrorList<T = any, S extends StrictRJSFSchema = RJSFSche
12
13
  <Alert status='error' title={translateString(TranslatableString.ErrorsLabel)} mb={3}>
13
14
  <ListRoot listStylePosition='inside'>
14
15
  {errors.map((error, i) => (
16
+ // oxlint-disable-next-line react/no-array-index-key
15
17
  <ListItem key={i}>{error.stack}</ListItem>
16
18
  ))}
17
19
  </ListRoot>
@@ -1,5 +1,6 @@
1
1
  import { Fieldset } from '@chakra-ui/react';
2
- import { errorId, FieldErrorProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
2
+ import type { FieldErrorProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
3
+ import { errorId } from '@rjsf/utils';
3
4
 
4
5
  /** The `FieldErrorTemplate` component renders the errors local to the particular field
5
6
  *
@@ -16,11 +17,10 @@ export default function FieldErrorTemplate<
16
17
  }
17
18
  const id = errorId(fieldPathId);
18
19
 
19
- return errors.map((error, i: number) => {
20
- return (
21
- <Fieldset.ErrorText mt={0} key={i} id={id}>
22
- {error}
23
- </Fieldset.ErrorText>
24
- );
25
- });
20
+ return errors.map((error, i: number) => (
21
+ // oxlint-disable-next-line react/no-array-index-key
22
+ <Fieldset.ErrorText mt={0} key={i} id={id}>
23
+ {error}
24
+ </Fieldset.ErrorText>
25
+ ));
26
26
  }
@@ -1,6 +1,7 @@
1
1
  import { Text } from '@chakra-ui/react';
2
2
  import { RichHelp } from '@rjsf/core';
3
- import { helpId, FieldHelpProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
3
+ import type { FieldHelpProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
4
+ import { helpId } from '@rjsf/utils';
4
5
 
5
6
  /** The `FieldHelpTemplate` component renders any help desired for a field
6
7
  *
@@ -1,12 +1,6 @@
1
1
  import { Fieldset } from '@chakra-ui/react';
2
- import {
3
- FieldTemplateProps,
4
- FormContextType,
5
- getTemplate,
6
- getUiOptions,
7
- RJSFSchema,
8
- StrictRJSFSchema,
9
- } from '@rjsf/utils';
2
+ import type { FieldTemplateProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
3
+ import { getTemplate, getUiOptions } from '@rjsf/utils';
10
4
 
11
5
  export default function FieldTemplate<
12
6
  T = any,
package/src/Form/Form.tsx CHANGED
@@ -1,6 +1,7 @@
1
- import { ComponentType } from 'react';
2
- import { withTheme, FormProps } from '@rjsf/core';
3
- import { FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
1
+ import type { ComponentType } from 'react';
2
+ import type { FormProps } from '@rjsf/core';
3
+ import { withTheme } from '@rjsf/core';
4
+ import type { FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
4
5
 
5
6
  import { generateTheme } from '../Theme';
6
7
 
@@ -1,5 +1,5 @@
1
1
  import { Grid, GridItem } from '@chakra-ui/react';
2
- import { GridTemplateProps } from '@rjsf/utils';
2
+ import type { GridTemplateProps } from '@rjsf/utils';
3
3
 
4
4
  /** Renders a `GridTemplate` for chakra-ui, which is expecting the column sizing information coming in via the
5
5
  * extra props provided by the caller, which are spread directly on the `Grid`/`GridItem`.
@@ -1,6 +1,12 @@
1
1
  import { memo } from 'react';
2
- import { IconButton, IconButtonProps } from '@chakra-ui/react';
3
- import { FormContextType, IconButtonProps as RJSFIconButtonProps, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
2
+ import type { IconButtonProps } from '@chakra-ui/react';
3
+ import { IconButton } from '@chakra-ui/react';
4
+ import type {
5
+ FormContextType,
6
+ IconButtonProps as RJSFIconButtonProps,
7
+ RJSFSchema,
8
+ StrictRJSFSchema,
9
+ } from '@rjsf/utils';
4
10
 
5
11
  export type ChakraIconButtonProps<
6
12
  T = any,
@@ -14,7 +20,7 @@ function ChakraIconButton<T = any, S extends StrictRJSFSchema = RJSFSchema, F ex
14
20
  const { icon, iconType, uiSchema, registry, ...otherProps } = props;
15
21
 
16
22
  return (
17
- <IconButton aria-label={props.title!} {...otherProps}>
23
+ <IconButton aria-label={props.title} {...otherProps}>
18
24
  {icon}
19
25
  </IconButton>
20
26
  );
@@ -1,9 +1,12 @@
1
- import { FormContextType, RJSFSchema, StrictRJSFSchema, TranslatableString } from '@rjsf/utils';
1
+ import { memo } from 'react';
2
+ import type { FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
3
+ import { TranslatableString } from '@rjsf/utils';
2
4
  import { ArrowUpIcon, ArrowDownIcon, CopyIcon, DeleteIcon, X } from 'lucide-react';
3
5
 
4
- import ChakraIconButton, { ChakraIconButtonProps } from './ChakraIconButton';
6
+ import type { ChakraIconButtonProps } from './ChakraIconButton';
7
+ import ChakraIconButton from './ChakraIconButton';
5
8
 
6
- export function CopyButton<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
9
+ function CopyButtonFn<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
7
10
  props: ChakraIconButtonProps<T, S, F>,
8
11
  ) {
9
12
  const {
@@ -13,8 +16,9 @@ export function CopyButton<T = any, S extends StrictRJSFSchema = RJSFSchema, F e
13
16
  <ChakraIconButton<T, S, F> title={translateString(TranslatableString.CopyButton)} {...props} icon={<CopyIcon />} />
14
17
  );
15
18
  }
19
+ export const CopyButton = memo(CopyButtonFn) as typeof CopyButtonFn;
16
20
 
17
- export function MoveDownButton<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
21
+ function MoveDownButtonFn<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
18
22
  props: ChakraIconButtonProps<T, S, F>,
19
23
  ) {
20
24
  const {
@@ -28,8 +32,9 @@ export function MoveDownButton<T = any, S extends StrictRJSFSchema = RJSFSchema,
28
32
  />
29
33
  );
30
34
  }
35
+ export const MoveDownButton = memo(MoveDownButtonFn) as typeof MoveDownButtonFn;
31
36
 
32
- export function MoveUpButton<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
37
+ function MoveUpButtonFn<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
33
38
  props: ChakraIconButtonProps<T, S, F>,
34
39
  ) {
35
40
  const {
@@ -43,8 +48,9 @@ export function MoveUpButton<T = any, S extends StrictRJSFSchema = RJSFSchema, F
43
48
  />
44
49
  );
45
50
  }
51
+ export const MoveUpButton = memo(MoveUpButtonFn) as typeof MoveUpButtonFn;
46
52
 
47
- export function RemoveButton<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
53
+ function RemoveButtonFn<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
48
54
  props: ChakraIconButtonProps<T, S, F>,
49
55
  ) {
50
56
  const {
@@ -58,8 +64,9 @@ export function RemoveButton<T = any, S extends StrictRJSFSchema = RJSFSchema, F
58
64
  />
59
65
  );
60
66
  }
67
+ export const RemoveButton = memo(RemoveButtonFn) as typeof RemoveButtonFn;
61
68
 
62
- export function ClearButton<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
69
+ function ClearButtonFn<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
63
70
  props: ChakraIconButtonProps<T, S, F>,
64
71
  ) {
65
72
  const {
@@ -67,3 +74,4 @@ export function ClearButton<T = any, S extends StrictRJSFSchema = RJSFSchema, F
67
74
  } = props;
68
75
  return <ChakraIconButton<T, S, F> title={translateString(TranslatableString.ClearButton)} {...props} icon={<X />} />;
69
76
  }
77
+ export const ClearButton = memo(ClearButtonFn) as typeof ClearButtonFn;
@@ -1,5 +1,5 @@
1
1
  import { Box, Card } from '@chakra-ui/react';
2
- import { FormContextType, MultiSchemaFieldTemplateProps, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
2
+ import type { FormContextType, MultiSchemaFieldTemplateProps, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
3
3
 
4
4
  export default function MultiSchemaFieldTemplate<
5
5
  T = any,
@@ -1,17 +1,9 @@
1
- import { ChangeEvent, FocusEvent, useMemo } from 'react';
1
+ import type { ChangeEvent, FocusEvent } from 'react';
2
+ import { useMemo } from 'react';
2
3
  import { createListCollection, NativeSelect } from '@chakra-ui/react';
3
- import {
4
- ariaDescribedByIds,
5
- EnumOptionsType,
6
- enumOptionsIndexForValue,
7
- enumOptionsValueForIndex,
8
- labelValue,
9
- FormContextType,
10
- RJSFSchema,
11
- StrictRJSFSchema,
12
- WidgetProps,
13
- } from '@rjsf/utils';
14
- import { OptionsOrGroups } from 'chakra-react-select';
4
+ import type { EnumOptionsType, FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps } from '@rjsf/utils';
5
+ import { ariaDescribedByIds, enumOptionsIndexForValue, enumOptionsValueForIndex, labelValue } from '@rjsf/utils';
6
+ import type { OptionsOrGroups } from 'chakra-react-select';
15
7
 
16
8
  import { Field } from '../components/ui/field';
17
9
  import { getChakra } from '../utils';
@@ -52,14 +44,13 @@ export default function NativeSelectWidget<
52
44
  } = props;
53
45
  const { enumOptions, enumDisabled, emptyValue } = options;
54
46
 
55
- const _onChange = ({ target }: ChangeEvent<HTMLSelectElement>) => {
56
- return onChange(enumOptionsValueForIndex<S>(target && target.value, enumOptions, emptyValue));
57
- };
47
+ const handleChange = ({ target }: ChangeEvent<HTMLSelectElement>) =>
48
+ onChange(enumOptionsValueForIndex<S>(target && target.value, enumOptions, emptyValue));
58
49
 
59
- const _onBlur = ({ target }: FocusEvent<HTMLSelectElement>) =>
50
+ const handleBlur = ({ target }: FocusEvent<HTMLSelectElement>) =>
60
51
  onBlur(id, enumOptionsValueForIndex<S>(target && target.value, enumOptions, emptyValue));
61
52
 
62
- const _onFocus = ({ target }: FocusEvent<HTMLSelectElement>) =>
53
+ const handleFocus = ({ target }: FocusEvent<HTMLSelectElement>) =>
63
54
  onFocus(id, enumOptionsValueForIndex<S>(target && target.value, enumOptions, emptyValue));
64
55
 
65
56
  const showPlaceholderOption = !multiple && schema.default === undefined;
@@ -67,20 +58,20 @@ export default function NativeSelectWidget<
67
58
  valueLabelMap: Record<string | number, string>;
68
59
  displayEnumOptions: OptionsOrGroups<any, any>;
69
60
  } => {
70
- const valueLabelMap: Record<string | number, string> = {};
71
- let displayEnumOptions: OptionsOrGroups<any, any> = [];
61
+ const computedValueLabelMap: Record<string | number, string> = {};
62
+ let computedOptions: OptionsOrGroups<any, any> = [];
72
63
  if (Array.isArray(enumOptions)) {
73
- displayEnumOptions = enumOptions.map((option: EnumOptionsType<S>, index: number) => {
74
- const { value, label } = option;
75
- valueLabelMap[index] = label || String(value);
64
+ computedOptions = enumOptions.map((option: EnumOptionsType<S>, index: number) => {
65
+ const { value: enumValue, label: enumLabel } = option;
66
+ computedValueLabelMap[index] = enumLabel || String(enumValue);
76
67
  return {
77
- label,
68
+ label: enumLabel,
78
69
  value: String(index),
79
- disabled: Array.isArray(enumDisabled) && enumDisabled.indexOf(value) !== -1,
70
+ disabled: Array.isArray(enumDisabled) && enumDisabled.includes(enumValue),
80
71
  };
81
72
  });
82
73
  }
83
- return { valueLabelMap: valueLabelMap, displayEnumOptions: displayEnumOptions };
74
+ return { valueLabelMap: computedValueLabelMap, displayEnumOptions: computedOptions };
84
75
  }, [enumDisabled, enumOptions]);
85
76
 
86
77
  const selectedIndex = enumOptionsIndexForValue<S>(value, enumOptions, false);
@@ -116,9 +107,9 @@ export default function NativeSelectWidget<
116
107
  <NativeSelect.Root>
117
108
  <NativeSelect.Field
118
109
  id={id}
119
- onBlur={_onBlur}
120
- onChange={_onChange}
121
- onFocus={_onFocus}
110
+ onBlur={handleBlur}
111
+ onChange={handleChange}
112
+ onFocus={handleFocus}
122
113
  autoFocus={autofocus}
123
114
  value={formValue}
124
115
  aria-describedby={ariaDescribedByIds(id)}
@@ -1,16 +1,6 @@
1
1
  import { Grid, GridItem } from '@chakra-ui/react';
2
- import {
3
- buttonId,
4
- canExpand,
5
- descriptionId,
6
- FormContextType,
7
- getTemplate,
8
- getUiOptions,
9
- ObjectFieldTemplateProps,
10
- RJSFSchema,
11
- StrictRJSFSchema,
12
- titleId,
13
- } from '@rjsf/utils';
2
+ import type { FormContextType, ObjectFieldTemplateProps, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
3
+ import { buttonId, canExpand, descriptionId, getTemplate, getUiOptions, titleId } from '@rjsf/utils';
14
4
 
15
5
  export default function ObjectFieldTemplate<
16
6
  T = any,
@@ -69,12 +59,8 @@ export default function ObjectFieldTemplate<
69
59
  )}
70
60
  <Grid gap={description ? 2 : 4} mb={4}>
71
61
  {!showOptionalDataControlInTitle ? <GridItem>{optionalDataControl}</GridItem> : undefined}
72
- {properties.map((element, index) =>
73
- element.hidden ? (
74
- element.content
75
- ) : (
76
- <GridItem key={`${fieldPathId.$id}-${element.name}-${index}`}>{element.content}</GridItem>
77
- ),
62
+ {properties.map((element) =>
63
+ element.hidden ? element.content : <GridItem key={element.name}>{element.content}</GridItem>,
78
64
  )}
79
65
  {canExpand<T, S, F>(schema, uiSchema, formData) && (
80
66
  <GridItem justifySelf='flex-end'>
@@ -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
  import { PlusIcon } from 'lucide-react';
3
3
 
4
4
  import ChakraIconButton, { RemoveButton } from '../IconButton';
@@ -30,7 +30,8 @@ export default function OptionalDataControlsTemplate<
30
30
  variant='subtle'
31
31
  />
32
32
  );
33
- } else if (onRemoveClick) {
33
+ }
34
+ if (onRemoveClick) {
34
35
  return (
35
36
  <RemoveButton
36
37
  id={id}