@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
@@ -1,5 +1,6 @@
1
- import { ChangeEvent, FocusEvent } from 'react';
1
+ import type { ChangeEvent, FocusEvent } from 'react';
2
2
  import { Stack } from '@chakra-ui/react';
3
+ import type { FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps } from '@rjsf/utils';
3
4
  import {
4
5
  ariaDescribedByIds,
5
6
  enumOptionSelectedValue,
@@ -8,10 +9,6 @@ import {
8
9
  getOptionValueFormat,
9
10
  labelValue,
10
11
  optionId,
11
- FormContextType,
12
- RJSFSchema,
13
- StrictRJSFSchema,
14
- WidgetProps,
15
12
  } from '@rjsf/utils';
16
13
 
17
14
  import { Field } from '../components/ui/field';
@@ -36,12 +33,12 @@ export default function RadioWidget<T = any, S extends StrictRJSFSchema = RJSFSc
36
33
  const { enumOptions, enumDisabled, emptyValue } = options;
37
34
  const optionValueFormat = getOptionValueFormat(options);
38
35
 
39
- const _onChange = ({ target: { value } }: ChangeEvent<HTMLInputElement>) =>
40
- onChange(enumOptionValueDecoder<S>(value, enumOptions, optionValueFormat, emptyValue));
41
- const _onBlur = ({ target: { value } }: FocusEvent<HTMLInputElement>) =>
42
- onBlur(id, enumOptionValueDecoder<S>(value, enumOptions, optionValueFormat, emptyValue));
43
- const _onFocus = ({ target: { value } }: FocusEvent<HTMLInputElement>) =>
44
- onFocus(id, enumOptionValueDecoder<S>(value, enumOptions, optionValueFormat, emptyValue));
36
+ const handleChange = ({ target: { value: enumValue } }: ChangeEvent<HTMLInputElement>) =>
37
+ onChange(enumOptionValueDecoder<S>(enumValue, enumOptions, optionValueFormat, emptyValue));
38
+ const handleBlur = ({ target: { value: enumValue } }: FocusEvent<HTMLInputElement>) =>
39
+ onBlur(id, enumOptionValueDecoder<S>(enumValue, enumOptions, optionValueFormat, emptyValue));
40
+ const handleFocus = ({ target: { value: enumValue } }: FocusEvent<HTMLInputElement>) =>
41
+ onFocus(id, enumOptionValueDecoder<S>(enumValue, enumOptions, optionValueFormat, emptyValue));
45
42
 
46
43
  const row = options ? options.inline : false;
47
44
  const selectValue = enumOptionSelectedValue<S>(value, enumOptions, false, optionValueFormat, null);
@@ -58,9 +55,9 @@ export default function RadioWidget<T = any, S extends StrictRJSFSchema = RJSFSc
58
55
  {...chakraProps}
59
56
  >
60
57
  <RadioGroup
61
- onChange={_onChange}
62
- onBlur={_onBlur}
63
- onFocus={_onFocus}
58
+ onChange={handleChange}
59
+ onBlur={handleBlur}
60
+ onFocus={handleFocus}
64
61
  value={selectValue}
65
62
  name={htmlName || id}
66
63
  aria-describedby={ariaDescribedByIds(id)}
@@ -68,12 +65,12 @@ export default function RadioWidget<T = any, S extends StrictRJSFSchema = RJSFSc
68
65
  <Stack direction={row ? 'row' : 'column'}>
69
66
  {Array.isArray(enumOptions) &&
70
67
  enumOptions.map((option, index) => {
71
- const itemDisabled = Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) !== -1;
68
+ const itemDisabled = Array.isArray(enumDisabled) && enumDisabled.includes(option.value);
72
69
 
73
70
  return (
74
71
  <Radio
75
72
  value={enumOptionValueEncoder(option.value, index, optionValueFormat)}
76
- key={index}
73
+ key={String(option.value)}
77
74
  id={optionId(id, index)}
78
75
  disabled={disabled || itemDisabled || readonly}
79
76
  >
@@ -1,14 +1,7 @@
1
- import { FocusEvent } from 'react';
2
- import { SliderValueChangeDetails } from '@chakra-ui/react';
3
- import {
4
- ariaDescribedByIds,
5
- FormContextType,
6
- labelValue,
7
- rangeSpec,
8
- RJSFSchema,
9
- StrictRJSFSchema,
10
- WidgetProps,
11
- } from '@rjsf/utils';
1
+ import type { FocusEvent } from 'react';
2
+ import type { SliderValueChangeDetails } from '@chakra-ui/react';
3
+ import type { FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps } from '@rjsf/utils';
4
+ import { ariaDescribedByIds, labelValue, rangeSpec } from '@rjsf/utils';
12
5
 
13
6
  import { Field } from '../components/ui/field';
14
7
  import { Slider } from '../components/ui/slider';
@@ -28,10 +21,10 @@ export default function RangeWidget<T = any, S extends StrictRJSFSchema = RJSFSc
28
21
  id,
29
22
  uiSchema,
30
23
  }: WidgetProps<T, S, F>) {
31
- const _onChange = ({ value }: SliderValueChangeDetails) =>
32
- onChange(value === undefined ? options.emptyValue : value[0]);
33
- const _onBlur = ({ target }: FocusEvent<HTMLInputElement>) => onBlur(id, target && target.value);
34
- const _onFocus = ({ target }: FocusEvent<HTMLInputElement>) => onFocus(id, target && target.value);
24
+ const handleChange = ({ value: newValue }: SliderValueChangeDetails) =>
25
+ onChange(newValue === undefined ? options.emptyValue : newValue[0]);
26
+ const handleBlur = ({ target }: FocusEvent<HTMLInputElement>) => onBlur(id, target && target.value);
27
+ const handleFocus = ({ target }: FocusEvent<HTMLInputElement>) => onFocus(id, target && target.value);
35
28
 
36
29
  const chakraProps = getChakra({ uiSchema });
37
30
 
@@ -43,9 +36,9 @@ export default function RangeWidget<T = any, S extends StrictRJSFSchema = RJSFSc
43
36
  name={id}
44
37
  disabled={disabled || readonly}
45
38
  value={[value]}
46
- onValueChange={_onChange}
47
- onBlur={_onBlur}
48
- onFocus={_onFocus}
39
+ onValueChange={handleChange}
40
+ onBlur={handleBlur}
41
+ onFocus={handleFocus}
49
42
  aria-describedby={ariaDescribedByIds(id)}
50
43
  />
51
44
  </Field>
@@ -1,19 +1,17 @@
1
- import { FocusEvent, useMemo, useRef } from 'react';
2
- import { createListCollection, SelectValueChangeDetails, Select as ChakraSelect } from '@chakra-ui/react';
1
+ import type { FocusEvent } from 'react';
2
+ import { useMemo, useRef } from 'react';
3
+ import type { SelectValueChangeDetails } from '@chakra-ui/react';
4
+ import { createListCollection, Select as ChakraSelect } from '@chakra-ui/react';
5
+ import type { EnumOptionsType, FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps } from '@rjsf/utils';
3
6
  import {
4
7
  ariaDescribedByIds,
5
- EnumOptionsType,
6
8
  enumOptionSelectedValue,
7
9
  enumOptionValueDecoder,
8
10
  enumOptionValueEncoder,
9
11
  getOptionValueFormat,
10
12
  labelValue,
11
- FormContextType,
12
- RJSFSchema,
13
- StrictRJSFSchema,
14
- WidgetProps,
15
13
  } from '@rjsf/utils';
16
- import { OptionsOrGroups } from 'chakra-react-select';
14
+ import type { OptionsOrGroups } from 'chakra-react-select';
17
15
 
18
16
  import { Field } from '../components/ui/field';
19
17
  import { SelectRoot, SelectTrigger, SelectValueText } from '../components/ui/select';
@@ -45,41 +43,40 @@ export default function SelectWidget<T = any, S extends StrictRJSFSchema = RJSFS
45
43
  const { enumOptions, enumDisabled, emptyValue } = options;
46
44
  const optionValueFormat = getOptionValueFormat(options);
47
45
 
48
- const _onMultiChange = ({ value }: SelectValueChangeDetails) => {
49
- return onChange(enumOptionValueDecoder<S>(value, enumOptions, optionValueFormat, emptyValue));
50
- };
46
+ const handleMultiChange = ({ value: newValue }: SelectValueChangeDetails) =>
47
+ onChange(enumOptionValueDecoder<S>(newValue, enumOptions, optionValueFormat, emptyValue));
51
48
 
52
- const _onSingleChange = ({ value }: SelectValueChangeDetails) => {
53
- const selected = enumOptionValueDecoder<S>(value, enumOptions, optionValueFormat, emptyValue);
49
+ const handleSingleChange = ({ value: newValue }: SelectValueChangeDetails) => {
50
+ const selected = enumOptionValueDecoder<S>(newValue, enumOptions, optionValueFormat, emptyValue);
54
51
  return onChange(Array.isArray(selected) && selected.length === 1 ? selected[0] : selected);
55
52
  };
56
53
 
57
- const _onBlur = ({ target }: FocusEvent<HTMLInputElement>) =>
54
+ const handleBlur = ({ target }: FocusEvent<HTMLInputElement>) =>
58
55
  onBlur(id, enumOptionValueDecoder<S>(target && target.value, enumOptions, optionValueFormat, emptyValue));
59
56
 
60
- const _onFocus = ({ target }: FocusEvent<HTMLInputElement>) =>
57
+ const handleFocus = ({ target }: FocusEvent<HTMLInputElement>) =>
61
58
  onFocus(id, enumOptionValueDecoder<S>(target && target.value, enumOptions, optionValueFormat, emptyValue));
62
59
 
63
60
  const showPlaceholderOption = !multiple && schema.default === undefined;
64
61
  const displayEnumOptions = useMemo((): OptionsOrGroups<any, any> => {
65
- let displayEnumOptions: OptionsOrGroups<any, any> = [];
62
+ let computedOptions: OptionsOrGroups<any, any> = [];
66
63
  if (Array.isArray(enumOptions)) {
67
- displayEnumOptions = enumOptions.map((option: EnumOptionsType<S>, index: number) => {
68
- const { value, label } = option;
64
+ computedOptions = enumOptions.map((option: EnumOptionsType<S>, index: number) => {
65
+ const { value: enumValue, label: enumLabel } = option;
69
66
  return {
70
- label,
71
- value: enumOptionValueEncoder(value, index, optionValueFormat),
72
- disabled: Array.isArray(enumDisabled) && enumDisabled.indexOf(value) !== -1,
67
+ label: enumLabel,
68
+ value: enumOptionValueEncoder(enumValue, index, optionValueFormat),
69
+ disabled: Array.isArray(enumDisabled) && enumDisabled.includes(enumValue),
73
70
  };
74
71
  });
75
72
  if (showPlaceholderOption) {
76
- (displayEnumOptions as any[]).unshift({ value: '', label: placeholder || '' });
73
+ (computedOptions as any[]).unshift({ value: '', label: placeholder || '' });
77
74
  }
78
75
  }
79
- return displayEnumOptions;
76
+ return computedOptions;
80
77
  }, [enumDisabled, enumOptions, placeholder, showPlaceholderOption, optionValueFormat]);
81
78
 
82
- const isMultiple = typeof multiple !== 'undefined' && multiple !== false && Boolean(enumOptions);
79
+ const isMultiple = typeof multiple !== 'undefined' && multiple && Boolean(enumOptions);
83
80
 
84
81
  // Chakra's SelectRoot always expects a string array, so flatten the helper's
85
82
  // single/multiple return shape and strip the empty-single case.
@@ -114,9 +111,9 @@ export default function SelectWidget<T = any, S extends StrictRJSFSchema = RJSFS
114
111
  name={htmlName || id}
115
112
  multiple={isMultiple}
116
113
  closeOnSelect={!isMultiple}
117
- onBlur={_onBlur}
118
- onValueChange={isMultiple ? _onMultiChange : _onSingleChange}
119
- onFocus={_onFocus}
114
+ onBlur={handleBlur}
115
+ onValueChange={isMultiple ? handleMultiChange : handleSingleChange}
116
+ onFocus={handleFocus}
120
117
  autoFocus={autofocus}
121
118
  value={formValue}
122
119
  aria-describedby={ariaDescribedByIds(id)}
@@ -1,5 +1,6 @@
1
1
  import { Box, Button } from '@chakra-ui/react';
2
- import { FormContextType, getSubmitButtonOptions, RJSFSchema, StrictRJSFSchema, SubmitButtonProps } from '@rjsf/utils';
2
+ import type { FormContextType, RJSFSchema, StrictRJSFSchema, SubmitButtonProps } from '@rjsf/utils';
3
+ import { getSubmitButtonOptions } from '@rjsf/utils';
3
4
 
4
5
  export default function SubmitButton<
5
6
  T = any,
@@ -1,4 +1,4 @@
1
- import { FormContextType, RJSFSchema, StrictRJSFSchema, TemplatesType } from '@rjsf/utils';
1
+ import type { FormContextType, RJSFSchema, StrictRJSFSchema, TemplatesType } from '@rjsf/utils';
2
2
 
3
3
  import AddButton from '../AddButton';
4
4
  import ArrayFieldItemTemplate from '../ArrayFieldItemTemplate';
@@ -1,13 +1,7 @@
1
- import { ChangeEvent, FocusEvent } from 'react';
1
+ import type { ChangeEvent, FocusEvent } from 'react';
2
2
  import { Textarea } from '@chakra-ui/react';
3
- import {
4
- ariaDescribedByIds,
5
- labelValue,
6
- FormContextType,
7
- RJSFSchema,
8
- StrictRJSFSchema,
9
- WidgetProps,
10
- } from '@rjsf/utils';
3
+ import type { FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps } from '@rjsf/utils';
4
+ import { ariaDescribedByIds, labelValue } from '@rjsf/utils';
11
5
 
12
6
  import { Field } from '../components/ui/field';
13
7
  import { getChakra } from '../utils';
@@ -34,10 +28,10 @@ export default function TextareaWidget<
34
28
  rawErrors,
35
29
  uiSchema,
36
30
  }: WidgetProps<T, S, F>) {
37
- const _onChange = ({ target: { value } }: ChangeEvent<HTMLTextAreaElement>) =>
38
- onChange(value === '' ? options.emptyValue : value);
39
- const _onBlur = ({ target }: FocusEvent<HTMLTextAreaElement>) => onBlur(id, target && target.value);
40
- const _onFocus = ({ target }: FocusEvent<HTMLTextAreaElement>) => onFocus(id, target && target.value);
31
+ const handleChange = ({ target: { value: newValue } }: ChangeEvent<HTMLTextAreaElement>) =>
32
+ onChange(newValue === '' ? options.emptyValue : newValue);
33
+ const handleBlur = ({ target }: FocusEvent<HTMLTextAreaElement>) => onBlur(id, target && target.value);
34
+ const handleFocus = ({ target }: FocusEvent<HTMLTextAreaElement>) => onFocus(id, target && target.value);
41
35
 
42
36
  const chakraProps = getChakra({ uiSchema });
43
37
 
@@ -57,9 +51,9 @@ export default function TextareaWidget<
57
51
  value={value ?? ''}
58
52
  placeholder={placeholder}
59
53
  autoFocus={autofocus}
60
- onChange={_onChange}
61
- onBlur={_onBlur}
62
- onFocus={_onFocus}
54
+ onChange={handleChange}
55
+ onBlur={handleBlur}
56
+ onFocus={handleFocus}
63
57
  rows={options.rows}
64
58
  aria-describedby={ariaDescribedByIds(id)}
65
59
  />
@@ -1,5 +1,5 @@
1
- import { ThemeProps } from '@rjsf/core';
2
- import { FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
1
+ import type { ThemeProps } from '@rjsf/core';
2
+ import type { FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
3
3
 
4
4
  import { generateTemplates } from '../Templates';
5
5
  import { generateWidgets } from '../Widgets';
@@ -1,5 +1,5 @@
1
1
  import { Box, Flex, Heading, Separator, Spacer } from '@chakra-ui/react';
2
- import { FormContextType, RJSFSchema, StrictRJSFSchema, TitleFieldProps } from '@rjsf/utils';
2
+ import type { FormContextType, RJSFSchema, StrictRJSFSchema, TitleFieldProps } from '@rjsf/utils';
3
3
 
4
4
  export default function TitleField<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>({
5
5
  id,
@@ -1,13 +1,7 @@
1
- import { FocusEvent } from 'react';
2
- import { NumberInputValueChangeDetails } from '@chakra-ui/react';
3
- import {
4
- ariaDescribedByIds,
5
- labelValue,
6
- FormContextType,
7
- RJSFSchema,
8
- StrictRJSFSchema,
9
- WidgetProps,
10
- } from '@rjsf/utils';
1
+ import type { FocusEvent } from 'react';
2
+ import type { NumberInputValueChangeDetails } from '@chakra-ui/react';
3
+ import type { FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps } from '@rjsf/utils';
4
+ import { ariaDescribedByIds, labelValue } from '@rjsf/utils';
11
5
 
12
6
  import { Field } from '../components/ui/field';
13
7
  import { NumberInputRoot } from '../components/ui/number-input';
@@ -18,9 +12,9 @@ export default function UpDownWidget<T = any, S extends StrictRJSFSchema = RJSFS
18
12
  ) {
19
13
  const { id, readonly, disabled, label, hideLabel, value, onChange, onBlur, onFocus, rawErrors, required } = props;
20
14
 
21
- const _onChange = ({ value }: NumberInputValueChangeDetails) => onChange(value);
22
- const _onBlur = ({ target }: FocusEvent<HTMLInputElement | any>) => onBlur(id, target && target.value);
23
- const _onFocus = ({ target }: FocusEvent<HTMLInputElement | any>) => onFocus(id, target && target.value);
15
+ const handleChange = ({ value: newValue }: NumberInputValueChangeDetails) => onChange(newValue);
16
+ const handleBlur = ({ target }: FocusEvent<HTMLInputElement | any>) => onBlur(id, target && target.value);
17
+ const handleFocus = ({ target }: FocusEvent<HTMLInputElement | any>) => onFocus(id, target && target.value);
24
18
 
25
19
  const chakraProps = getChakra({ uiSchema: props.uiSchema });
26
20
 
@@ -36,9 +30,9 @@ export default function UpDownWidget<T = any, S extends StrictRJSFSchema = RJSFS
36
30
  >
37
31
  <NumberInputRoot
38
32
  value={value}
39
- onValueChange={_onChange}
40
- onBlur={_onBlur}
41
- onFocus={_onFocus}
33
+ onValueChange={handleChange}
34
+ onBlur={handleBlur}
35
+ onFocus={handleFocus}
42
36
  aria-describedby={ariaDescribedByIds(id)}
43
37
  id={id}
44
38
  name={id}
@@ -1,4 +1,4 @@
1
- import { FormContextType, RegistryWidgetsType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
1
+ import type { FormContextType, RegistryWidgetsType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
2
2
 
3
3
  import AltDateTimeWidget from '../AltDateTimeWidget/AltDateTimeWidget';
4
4
  import AltDateWidget from '../AltDateWidget/AltDateWidget';
@@ -1,13 +1,6 @@
1
1
  import { Grid, GridItem, Input } from '@chakra-ui/react';
2
- import {
3
- ADDITIONAL_PROPERTY_FLAG,
4
- buttonId,
5
- FormContextType,
6
- RJSFSchema,
7
- StrictRJSFSchema,
8
- TranslatableString,
9
- WrapIfAdditionalTemplateProps,
10
- } from '@rjsf/utils';
2
+ import type { FormContextType, RJSFSchema, StrictRJSFSchema, WrapIfAdditionalTemplateProps } from '@rjsf/utils';
3
+ import { ADDITIONAL_PROPERTY_FLAG, buttonId, TranslatableString } from '@rjsf/utils';
11
4
 
12
5
  import { Field } from '../components/ui/field';
13
6
 
@@ -1,4 +1,5 @@
1
- import { forwardRef, ReactNode } from 'react';
1
+ import type { ReactNode } from 'react';
2
+ import { forwardRef } from 'react';
2
3
  import { Alert as ChakraAlert } from '@chakra-ui/react';
3
4
 
4
5
  import { CloseButton } from './close-button';
@@ -23,7 +24,7 @@ export interface AlertProps extends Omit<ChakraAlert.RootProps, 'title'> {
23
24
  onClose?: () => void;
24
25
  }
25
26
 
26
- export const Alert = forwardRef<HTMLDivElement, AlertProps>(function Alert(props, ref) {
27
+ export const Alert = forwardRef<HTMLDivElement, AlertProps>((props, ref) => {
27
28
  const { title, children, closable, onClose, startElement, endElement, ...rest } = props;
28
29
  return (
29
30
  <ChakraAlert.Root ref={ref} {...rest}>
@@ -1,4 +1,5 @@
1
- import { forwardRef, InputHTMLAttributes, ReactNode, Ref } from 'react';
1
+ import type { InputHTMLAttributes, ReactNode, Ref } from 'react';
2
+ import { forwardRef } from 'react';
2
3
  import { Checkbox as ChakraCheckbox } from '@chakra-ui/react';
3
4
 
4
5
  export interface CheckboxProps extends ChakraCheckbox.RootProps {
@@ -16,7 +17,7 @@ export interface CheckboxProps extends ChakraCheckbox.RootProps {
16
17
  * @param {Ref<HTMLLabelElement>} [props.rootRef] - Ref for the root element of the checkbox.
17
18
  * @returns {JSX.Element} The rendered checkbox component.
18
19
  */
19
- export const Checkbox = forwardRef<HTMLInputElement, CheckboxProps>(function Checkbox(props, ref) {
20
+ export const Checkbox = forwardRef<HTMLInputElement, CheckboxProps>((props, ref) => {
20
21
  const { icon, children, inputProps, rootRef, ...rest } = props;
21
22
  return (
22
23
  <ChakraCheckbox.Root ref={rootRef} {...rest}>
@@ -12,10 +12,8 @@ export type CloseButtonProps = ButtonProps;
12
12
  * @param {ReactNode} [props.children] - The content to display inside the button.
13
13
  * @returns {JSX.Element} The rendered close button component.
14
14
  */
15
- export const CloseButton = forwardRef<HTMLButtonElement, CloseButtonProps>(function CloseButton(props, ref) {
16
- return (
17
- <ChakraIconButton variant='ghost' aria-label='Close' ref={ref} {...props}>
18
- {props.children ?? <LuX />}
19
- </ChakraIconButton>
20
- );
21
- });
15
+ export const CloseButton = forwardRef<HTMLButtonElement, CloseButtonProps>((props, ref) => (
16
+ <ChakraIconButton variant='ghost' aria-label='Close' ref={ref} {...props}>
17
+ {props.children ?? <LuX />}
18
+ </ChakraIconButton>
19
+ ));
@@ -1,4 +1,5 @@
1
- import { forwardRef, ReactNode } from 'react';
1
+ import type { ReactNode } from 'react';
2
+ import { forwardRef } from 'react';
2
3
  import { Field as ChakraField } from '@chakra-ui/react';
3
4
 
4
5
  export interface FieldProps extends Omit<ChakraField.RootProps, 'label'> {
@@ -19,7 +20,7 @@ export interface FieldProps extends Omit<ChakraField.RootProps, 'label'> {
19
20
  * @param {ReactNode} [props.optionalText] - Text to indicate that the field is optional.
20
21
  * @returns {JSX.Element} The rendered field component.
21
22
  */
22
- export const Field = forwardRef<HTMLDivElement, FieldProps>(function Field(props, ref) {
23
+ export const Field = forwardRef<HTMLDivElement, FieldProps>((props, ref) => {
23
24
  const { label, children, helperText, errorText, optionalText, ...rest } = props;
24
25
  return (
25
26
  <ChakraField.Root ref={ref} {...rest}>
@@ -10,7 +10,7 @@ export type NumberInputProps = ChakraNumberInput.RootProps;
10
10
  * @param {ReactNode} [props.children] - The content to display inside the number input.
11
11
  * @returns {JSX.Element} The rendered number input component.
12
12
  */
13
- export const NumberInputRoot = forwardRef<HTMLDivElement, NumberInputProps>(function NumberInput(props, ref) {
13
+ export const NumberInputRoot = forwardRef<HTMLDivElement, NumberInputProps>((props, ref) => {
14
14
  const inputRef = useRef<HTMLInputElement>(null);
15
15
 
16
16
  useEffect(() => {
@@ -1,4 +1,5 @@
1
- import { forwardRef, InputHTMLAttributes, Ref } from 'react';
1
+ import type { InputHTMLAttributes, Ref } from 'react';
2
+ import { forwardRef } from 'react';
2
3
  import { RadioGroup as ChakraRadioGroup } from '@chakra-ui/react';
3
4
 
4
5
  export interface RadioProps extends ChakraRadioGroup.ItemProps {
@@ -14,7 +15,7 @@ export interface RadioProps extends ChakraRadioGroup.ItemProps {
14
15
  * @param {Ref<HTMLDivElement>} [props.rootRef] - Ref for the root element of the radio.
15
16
  * @returns {JSX.Element} The rendered radio component.
16
17
  */
17
- export const Radio = forwardRef<HTMLInputElement, RadioProps>(function Radio(props, ref) {
18
+ export const Radio = forwardRef<HTMLInputElement, RadioProps>((props, ref) => {
18
19
  const { children, inputProps, rootRef, ...rest } = props;
19
20
  return (
20
21
  <ChakraRadioGroup.Item ref={rootRef} {...rest}>
@@ -1,9 +1,22 @@
1
- import { forwardRef, RefObject } from 'react';
1
+ import type { RefObject } from 'react';
2
+ import { forwardRef } from 'react';
2
3
  import type { CollectionItem } from '@chakra-ui/react';
3
4
  import { Select as ChakraSelect, Portal } from '@chakra-ui/react';
4
5
 
5
6
  import { CloseButton } from './close-button';
6
7
 
8
+ /**
9
+ * SelectClearTrigger component that renders a clear button for the select component.
10
+ *
11
+ * @param props - The properties for the clear trigger component.
12
+ * @returns - The rendered select clear trigger component.
13
+ */
14
+ const SelectClearTrigger = forwardRef<HTMLButtonElement, ChakraSelect.ClearTriggerProps>((props, ref) => (
15
+ <ChakraSelect.ClearTrigger asChild {...props} ref={ref}>
16
+ <CloseButton size='xs' variant='plain' focusVisibleRing='inside' focusRingWidth='2px' pointerEvents='auto' />
17
+ </ChakraSelect.ClearTrigger>
18
+ ));
19
+
7
20
  interface SelectTriggerProps extends ChakraSelect.ControlProps {
8
21
  clearable?: boolean;
9
22
  }
@@ -16,7 +29,7 @@ interface SelectTriggerProps extends ChakraSelect.ControlProps {
16
29
  * @param {ReactNode} [props.children] - The content to display inside the trigger.
17
30
  * @returns {JSX.Element} The rendered select trigger component.
18
31
  */
19
- export const SelectTrigger = forwardRef<HTMLButtonElement, SelectTriggerProps>(function SelectTrigger(props, ref) {
32
+ export const SelectTrigger = forwardRef<HTMLButtonElement, SelectTriggerProps>((props, ref) => {
20
33
  const { children, clearable, ...rest } = props;
21
34
  return (
22
35
  <ChakraSelect.Control {...rest}>
@@ -29,22 +42,6 @@ export const SelectTrigger = forwardRef<HTMLButtonElement, SelectTriggerProps>(f
29
42
  );
30
43
  });
31
44
 
32
- /**
33
- * SelectClearTrigger component that renders a clear button for the select component.
34
- *
35
- * @param {ChakraSelect.ClearTriggerProps} props - The properties for the clear trigger component.
36
- * @returns {JSX.Element} The rendered select clear trigger component.
37
- */
38
- const SelectClearTrigger = forwardRef<HTMLButtonElement, ChakraSelect.ClearTriggerProps>(
39
- function SelectClearTrigger(props, ref) {
40
- return (
41
- <ChakraSelect.ClearTrigger asChild {...props} ref={ref}>
42
- <CloseButton size='xs' variant='plain' focusVisibleRing='inside' focusRingWidth='2px' pointerEvents='auto' />
43
- </ChakraSelect.ClearTrigger>
44
- );
45
- },
46
- );
47
-
48
45
  interface SelectContentProps extends ChakraSelect.ContentProps {
49
46
  portalled?: boolean;
50
47
  portalRef?: RefObject<HTMLElement>;
@@ -58,7 +55,7 @@ interface SelectContentProps extends ChakraSelect.ContentProps {
58
55
  * @param {RefObject<HTMLElement>} [props.portalRef] - The ref for the portal container.
59
56
  * @returns {JSX.Element} The rendered select content component.
60
57
  */
61
- export const SelectContent = forwardRef<HTMLDivElement, SelectContentProps>(function SelectContent(props, ref) {
58
+ export const SelectContent = forwardRef<HTMLDivElement, SelectContentProps>((props, ref) => {
62
59
  const { portalled = true, portalRef, ...rest } = props;
63
60
  return (
64
61
  <Portal disabled={!portalled} container={portalRef}>
@@ -77,7 +74,7 @@ export const SelectContent = forwardRef<HTMLDivElement, SelectContentProps>(func
77
74
  * @param {ReactNode} [props.children] - The content to display inside the item.
78
75
  * @returns {JSX.Element} The rendered select item component.
79
76
  */
80
- export const SelectItem = forwardRef<HTMLDivElement, ChakraSelect.ItemProps>(function SelectItem(props, ref) {
77
+ export const SelectItem = forwardRef<HTMLDivElement, ChakraSelect.ItemProps>((props, ref) => {
81
78
  const { item, children, ...rest } = props;
82
79
  return (
83
80
  <ChakraSelect.Item key={item.value} item={item} {...rest} ref={ref}>
@@ -99,7 +96,7 @@ interface SelectValueTextProps extends Omit<ChakraSelect.ValueTextProps, 'childr
99
96
  * @param {ReactNode} [props.placeholder] - The placeholder text to display when no items are selected.
100
97
  * @returns {JSX.Element} The rendered select value text component.
101
98
  */
102
- export const SelectValueText = forwardRef<HTMLSpanElement, SelectValueTextProps>(function SelectValueText(props, ref) {
99
+ export const SelectValueText = forwardRef<HTMLSpanElement, SelectValueTextProps>((props, ref) => {
103
100
  const { children, ...rest } = props;
104
101
  return (
105
102
  <ChakraSelect.ValueText {...rest} ref={ref}>
@@ -130,20 +127,18 @@ export const SelectValueText = forwardRef<HTMLSpanElement, SelectValueTextProps>
130
127
  * @param {ReactNode} [props.children] - The content to display inside the select root.
131
128
  * @returns {JSX.Element} The rendered select root component.
132
129
  */
133
- export const SelectRoot = forwardRef<HTMLDivElement, ChakraSelect.RootProps>(function SelectRoot(props, ref) {
134
- return (
135
- <ChakraSelect.Root {...props} ref={ref} positioning={{ sameWidth: true, ...props.positioning }}>
136
- {props.asChild ? (
137
- props.children
138
- ) : (
139
- <>
140
- <ChakraSelect.HiddenSelect />
141
- {props.children}
142
- </>
143
- )}
144
- </ChakraSelect.Root>
145
- );
146
- }) as ChakraSelect.RootComponent;
130
+ export const SelectRoot = forwardRef<HTMLDivElement, ChakraSelect.RootProps>((props, ref) => (
131
+ <ChakraSelect.Root {...props} ref={ref} positioning={{ sameWidth: true, ...props.positioning }}>
132
+ {props.asChild ? (
133
+ props.children
134
+ ) : (
135
+ <>
136
+ <ChakraSelect.HiddenSelect />
137
+ {props.children}
138
+ </>
139
+ )}
140
+ </ChakraSelect.Root>
141
+ )) as ChakraSelect.RootComponent;
147
142
 
148
143
  interface SelectItemGroupProps extends ChakraSelect.ItemGroupProps {
149
144
  label: React.ReactNode;
@@ -157,7 +152,7 @@ interface SelectItemGroupProps extends ChakraSelect.ItemGroupProps {
157
152
  * @param {ReactNode} [props.children] - The content to display inside the item group.
158
153
  * @returns {JSX.Element} The rendered select item group component.
159
154
  */
160
- export const SelectItemGroup = forwardRef<HTMLDivElement, SelectItemGroupProps>(function SelectItemGroup(props, ref) {
155
+ export const SelectItemGroup = forwardRef<HTMLDivElement, SelectItemGroupProps>((props, ref) => {
161
156
  const { children, label, ...rest } = props;
162
157
  return (
163
158
  <ChakraSelect.ItemGroup {...rest} ref={ref}>