@rjsf/shadcn 6.4.2 → 6.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rjsf/shadcn",
3
- "version": "6.4.2",
3
+ "version": "6.5.1",
4
4
  "main": "dist/index.js",
5
5
  "module": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
@@ -64,8 +64,8 @@
64
64
  ]
65
65
  },
66
66
  "peerDependencies": {
67
- "@rjsf/core": "^6.4.x",
68
- "@rjsf/utils": "^6.4.x",
67
+ "@rjsf/core": "^6.5.x",
68
+ "@rjsf/utils": "^6.5.x",
69
69
  "react": ">=18"
70
70
  },
71
71
  "engineStrict": false,
@@ -73,11 +73,11 @@
73
73
  "node": ">=20"
74
74
  },
75
75
  "devDependencies": {
76
- "@rjsf/core": "6.4.2",
77
- "@rjsf/snapshot-tests": "6.4.2",
78
- "@rjsf/utils": "6.4.2",
79
- "@rjsf/validator-ajv8": "6.4.2",
80
- "@tailwindcss/cli": "^4.1.18",
76
+ "@rjsf/core": "6.5.1",
77
+ "@rjsf/snapshot-tests": "6.5.1",
78
+ "@rjsf/utils": "6.5.1",
79
+ "@rjsf/validator-ajv8": "6.5.1",
80
+ "@tailwindcss/cli": "^4.2.2",
81
81
  "eslint": "^8.57.1",
82
82
  "jsdom": "^27.0.1",
83
83
  "tailwindcss": "^4.1.18"
@@ -97,10 +97,10 @@
97
97
  "class-variance-authority": "^0.7.1",
98
98
  "clsx": "^2.1.1",
99
99
  "cmdk": "^1.1.1",
100
- "lodash": "^4.17.23",
101
- "lodash-es": "^4.17.23",
100
+ "lodash": "^4.18.1",
101
+ "lodash-es": "^4.18.1",
102
102
  "lucide-react": "^0.548.0",
103
- "tailwind-merge": "^3.4.0",
103
+ "tailwind-merge": "^3.5.0",
104
104
  "tailwindcss-animate": "^1.0.7",
105
105
  "uuid": "^13.0.0"
106
106
  },
@@ -1,9 +1,10 @@
1
1
  import {
2
2
  ariaDescribedByIds,
3
+ enumOptionValueDecoder,
3
4
  enumOptionsDeselectValue,
4
5
  enumOptionsIsSelected,
5
6
  enumOptionsSelectValue,
6
- enumOptionsValueForIndex,
7
+ getOptionValueFormat,
7
8
  FormContextType,
8
9
  optionId,
9
10
  RJSFSchema,
@@ -40,12 +41,13 @@ export default function CheckboxesWidget<
40
41
  className,
41
42
  }: WidgetProps<T, S, F>) {
42
43
  const { enumOptions, enumDisabled, inline, emptyValue } = options;
44
+ const optionValueFormat = getOptionValueFormat(options);
43
45
  const checkboxesValues = Array.isArray(value) ? value : [value];
44
46
 
45
47
  const _onBlur = ({ target }: FocusEvent<HTMLButtonElement>) =>
46
- onBlur(id, enumOptionsValueForIndex<S>(target && (target as any).value, enumOptions, emptyValue));
48
+ onBlur(id, enumOptionValueDecoder<S>(target && (target as any).value, enumOptions, optionValueFormat, emptyValue));
47
49
  const _onFocus = ({ target }: FocusEvent<HTMLButtonElement>) =>
48
- onFocus(id, enumOptionsValueForIndex<S>(target && (target as any).value, enumOptions, emptyValue));
50
+ onFocus(id, enumOptionValueDecoder<S>(target && (target as any).value, enumOptions, optionValueFormat, emptyValue));
49
51
 
50
52
  return (
51
53
  <div className={cn({ 'flex flex-col gap-2': !inline, 'flex flex-row gap-4 flex-wrap': inline })}>
@@ -1,7 +1,9 @@
1
1
  import {
2
2
  ariaDescribedByIds,
3
+ enumOptionValueDecoder,
4
+ enumOptionValueEncoder,
3
5
  enumOptionsIsSelected,
4
- enumOptionsValueForIndex,
6
+ getOptionValueFormat,
5
7
  FormContextType,
6
8
  optionId,
7
9
  RJSFSchema,
@@ -32,12 +34,14 @@ export default function RadioWidget<T = any, S extends StrictRJSFSchema = RJSFSc
32
34
  className,
33
35
  }: WidgetProps<T, S, F>) {
34
36
  const { enumOptions, enumDisabled, emptyValue } = options;
37
+ const optionValueFormat = getOptionValueFormat(options);
35
38
 
36
- const _onChange = (value: string) => onChange(enumOptionsValueForIndex<S>(value, enumOptions, emptyValue));
39
+ const _onChange = (value: string) =>
40
+ onChange(enumOptionValueDecoder<S>(value, enumOptions, optionValueFormat, emptyValue));
37
41
  const _onBlur = ({ target }: FocusEvent<HTMLInputElement>) =>
38
- onBlur(id, enumOptionsValueForIndex<S>(target && target.value, enumOptions, emptyValue));
42
+ onBlur(id, enumOptionValueDecoder<S>(target && target.value, enumOptions, optionValueFormat, emptyValue));
39
43
  const _onFocus = ({ target }: FocusEvent<HTMLInputElement>) =>
40
- onFocus(id, enumOptionsValueForIndex<S>(target && target.value, enumOptions, emptyValue));
44
+ onFocus(id, enumOptionValueDecoder<S>(target && target.value, enumOptions, optionValueFormat, emptyValue));
41
45
 
42
46
  const inline = Boolean(options && options.inline);
43
47
 
@@ -64,7 +68,7 @@ export default function RadioWidget<T = any, S extends StrictRJSFSchema = RJSFSc
64
68
  <div className='flex items-center gap-2' key={optionId(id, index)}>
65
69
  <RadioGroupItem
66
70
  checked={checked}
67
- value={index.toString()}
71
+ value={enumOptionValueEncoder(option.value, index, optionValueFormat)}
68
72
  id={optionId(id, index)}
69
73
  disabled={itemDisabled}
70
74
  />
@@ -1,7 +1,9 @@
1
1
  import {
2
2
  ariaDescribedByIds,
3
- enumOptionsIndexForValue,
4
- enumOptionsValueForIndex,
3
+ enumOptionSelectedValue,
4
+ enumOptionValueDecoder,
5
+ enumOptionValueEncoder,
6
+ getOptionValueFormat,
5
7
  FormContextType,
6
8
  RJSFSchema,
7
9
  StrictRJSFSchema,
@@ -33,23 +35,23 @@ export default function SelectWidget<
33
35
  onChange,
34
36
  onBlur,
35
37
  onFocus,
36
- defaultValue,
37
38
  placeholder,
38
39
  rawErrors = [],
39
40
  className,
40
41
  }: WidgetProps<T, S, F>) {
41
42
  const { enumOptions, enumDisabled, emptyValue: optEmptyValue } = options;
43
+ const optionValueFormat = getOptionValueFormat(options);
42
44
 
43
45
  const _onFancyFocus = () => {
44
- onFocus(id, enumOptionsValueForIndex<S>(value, enumOptions, optEmptyValue));
46
+ onFocus(id, enumOptionValueDecoder<S>(value, enumOptions, optionValueFormat, optEmptyValue));
45
47
  };
46
48
 
47
49
  const _onFancyBlur = () => {
48
- onBlur(id, enumOptionsValueForIndex<S>(value, enumOptions, optEmptyValue));
50
+ onBlur(id, enumOptionValueDecoder<S>(value, enumOptions, optionValueFormat, optEmptyValue));
49
51
  };
50
52
 
51
53
  const items = (enumOptions as any)?.map(({ value, label }: any, index: number) => ({
52
- value: multiple ? value : index.toString(),
54
+ value: multiple ? value : enumOptionValueEncoder(value, index, optionValueFormat),
53
55
  label: label,
54
56
  index,
55
57
  disabled: Array.isArray(enumDisabled) && enumDisabled.includes(value),
@@ -62,9 +64,9 @@ export default function SelectWidget<
62
64
  {!multiple ? (
63
65
  <FancySelect
64
66
  items={items}
65
- selected={enumOptionsIndexForValue<S>(value ?? defaultValue, enumOptions, false) as unknown as string}
67
+ selected={enumOptionSelectedValue<S>(value, enumOptions, false, optionValueFormat, '') as string}
66
68
  onValueChange={(selectedValue) => {
67
- onChange(enumOptionsValueForIndex<S>(selectedValue, enumOptions, optEmptyValue));
69
+ onChange(enumOptionValueDecoder<S>(selectedValue, enumOptions, optionValueFormat, optEmptyValue));
68
70
  }}
69
71
  autoFocus={autofocus}
70
72
  disabled={disabled || readonly}
@@ -85,7 +87,7 @@ export default function SelectWidget<
85
87
  items={items}
86
88
  selected={value}
87
89
  onValueChange={(values) => {
88
- onChange(enumOptionsValueForIndex<S>(values, enumOptions, optEmptyValue));
90
+ onChange(enumOptionValueDecoder<S>(values.map(String), enumOptions, optionValueFormat, optEmptyValue));
89
91
  }}
90
92
  onFocus={_onFancyFocus}
91
93
  onBlur={_onFancyBlur}
@@ -67,6 +67,7 @@ export default function WrapIfAdditionalTemplate<
67
67
  )}
68
68
  <div className='pl-0.5'>
69
69
  <Input
70
+ key={label}
70
71
  required={required}
71
72
  defaultValue={label}
72
73
  disabled={disabled || readonly}