@rjsf/shadcn 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 (134) hide show
  1. package/dist/index.cjs +117 -100
  2. package/dist/index.cjs.map +3 -3
  3. package/dist/rjsf-shadcn.esm.js +105 -124
  4. package/dist/rjsf-shadcn.esm.js.map +3 -3
  5. package/dist/rjsf-shadcn.umd.js +96 -80
  6. package/lib/AddButton/AddButton.d.ts +1 -1
  7. package/lib/AddButton/AddButton.js.map +1 -1
  8. package/lib/ArrayFieldItemTemplate/ArrayFieldItemTemplate.d.ts +1 -1
  9. package/lib/ArrayFieldItemTemplate/ArrayFieldItemTemplate.js +1 -1
  10. package/lib/ArrayFieldItemTemplate/ArrayFieldItemTemplate.js.map +1 -1
  11. package/lib/ArrayFieldTemplate/ArrayFieldTemplate.d.ts +1 -1
  12. package/lib/ArrayFieldTemplate/ArrayFieldTemplate.js +1 -1
  13. package/lib/ArrayFieldTemplate/ArrayFieldTemplate.js.map +1 -1
  14. package/lib/BaseInputTemplate/BaseInputTemplate.d.ts +1 -1
  15. package/lib/BaseInputTemplate/BaseInputTemplate.js +6 -6
  16. package/lib/BaseInputTemplate/BaseInputTemplate.js.map +1 -1
  17. package/lib/CheckboxWidget/CheckboxWidget.d.ts +1 -1
  18. package/lib/CheckboxWidget/CheckboxWidget.js +5 -5
  19. package/lib/CheckboxWidget/CheckboxWidget.js.map +1 -1
  20. package/lib/CheckboxesWidget/CheckboxesWidget.d.ts +1 -1
  21. package/lib/CheckboxesWidget/CheckboxesWidget.js +4 -4
  22. package/lib/CheckboxesWidget/CheckboxesWidget.js.map +1 -1
  23. package/lib/DescriptionField/DescriptionField.d.ts +1 -1
  24. package/lib/ErrorList/ErrorList.d.ts +1 -1
  25. package/lib/ErrorList/ErrorList.js +1 -3
  26. package/lib/ErrorList/ErrorList.js.map +1 -1
  27. package/lib/FieldErrorTemplate/FieldErrorTemplate.d.ts +1 -1
  28. package/lib/FieldErrorTemplate/FieldErrorTemplate.js +1 -3
  29. package/lib/FieldErrorTemplate/FieldErrorTemplate.js.map +1 -1
  30. package/lib/FieldHelpTemplate/FieldHelpTemplate.d.ts +1 -1
  31. package/lib/FieldHelpTemplate/FieldHelpTemplate.js.map +1 -1
  32. package/lib/FieldTemplate/FieldTemplate.d.ts +1 -1
  33. package/lib/FieldTemplate/FieldTemplate.js +1 -1
  34. package/lib/FieldTemplate/FieldTemplate.js.map +1 -1
  35. package/lib/Form/Form.d.ts +3 -3
  36. package/lib/Form/Form.js.map +1 -1
  37. package/lib/GridTemplate/GridTemplate.d.ts +1 -1
  38. package/lib/IconButton/IconButton.d.ts +15 -8
  39. package/lib/IconButton/IconButton.js +14 -6
  40. package/lib/IconButton/IconButton.js.map +1 -1
  41. package/lib/MultiSchemaFieldTemplate/MultiSchemaFieldTemplate.d.ts +1 -1
  42. package/lib/ObjectFieldTemplate/ObjectFieldTemplate.d.ts +1 -1
  43. package/lib/ObjectFieldTemplate/ObjectFieldTemplate.js +2 -2
  44. package/lib/ObjectFieldTemplate/ObjectFieldTemplate.js.map +1 -1
  45. package/lib/OptionalDataControlsTemplate/OptionalDataControlsTemplate.d.ts +1 -1
  46. package/lib/OptionalDataControlsTemplate/OptionalDataControlsTemplate.js +1 -1
  47. package/lib/OptionalDataControlsTemplate/OptionalDataControlsTemplate.js.map +1 -1
  48. package/lib/RadioWidget/RadioWidget.d.ts +1 -1
  49. package/lib/RadioWidget/RadioWidget.js +6 -6
  50. package/lib/RadioWidget/RadioWidget.js.map +1 -1
  51. package/lib/RangeWidget/RangeWidget.d.ts +2 -2
  52. package/lib/RangeWidget/RangeWidget.js +2 -2
  53. package/lib/RangeWidget/RangeWidget.js.map +1 -1
  54. package/lib/SelectWidget/SelectWidget.d.ts +1 -1
  55. package/lib/SelectWidget/SelectWidget.js +8 -8
  56. package/lib/SelectWidget/SelectWidget.js.map +1 -1
  57. package/lib/SubmitButton/SubmitButton.d.ts +1 -1
  58. package/lib/SubmitButton/SubmitButton.js.map +1 -1
  59. package/lib/Templates/Templates.d.ts +1 -1
  60. package/lib/TextareaWidget/TextareaWidget.d.ts +1 -1
  61. package/lib/TextareaWidget/TextareaWidget.js +4 -4
  62. package/lib/TextareaWidget/TextareaWidget.js.map +1 -1
  63. package/lib/Theme/Theme.d.ts +2 -2
  64. package/lib/TitleField/TitleField.d.ts +1 -1
  65. package/lib/TitleField/TitleField.js.map +1 -1
  66. package/lib/Widgets/Widgets.d.ts +1 -1
  67. package/lib/WrapIfAdditionalTemplate/WrapIfAdditionalTemplate.d.ts +1 -1
  68. package/lib/WrapIfAdditionalTemplate/WrapIfAdditionalTemplate.js +1 -1
  69. package/lib/WrapIfAdditionalTemplate/WrapIfAdditionalTemplate.js.map +1 -1
  70. package/lib/components/ui/alert.d.ts +1 -1
  71. package/lib/components/ui/badge.d.ts +1 -1
  72. package/lib/components/ui/button.d.ts +1 -1
  73. package/lib/components/ui/checkbox.d.ts +1 -1
  74. package/lib/components/ui/command.d.ts +1 -1
  75. package/lib/components/ui/command.js +1 -3
  76. package/lib/components/ui/command.js.map +1 -1
  77. package/lib/components/ui/dialog.d.ts +1 -1
  78. package/lib/components/ui/fancy-multi-select.d.ts +3 -3
  79. package/lib/components/ui/fancy-multi-select.js +2 -2
  80. package/lib/components/ui/fancy-multi-select.js.map +1 -1
  81. package/lib/components/ui/fancy-select.d.ts +3 -3
  82. package/lib/components/ui/fancy-select.js +1 -1
  83. package/lib/components/ui/fancy-select.js.map +1 -1
  84. package/lib/components/ui/input.d.ts +1 -1
  85. package/lib/components/ui/label.d.ts +1 -1
  86. package/lib/components/ui/radio-group.d.ts +1 -1
  87. package/lib/components/ui/separator.d.ts +1 -1
  88. package/lib/components/ui/slider.d.ts +1 -1
  89. package/lib/components/ui/slider.js +10 -2
  90. package/lib/components/ui/slider.js.map +1 -1
  91. package/lib/components/ui/textarea.d.ts +1 -1
  92. package/lib/tsconfig.tsbuildinfo +1 -1
  93. package/package.json +8 -9
  94. package/src/AddButton/AddButton.tsx +2 -1
  95. package/src/ArrayFieldItemTemplate/ArrayFieldItemTemplate.tsx +2 -8
  96. package/src/ArrayFieldTemplate/ArrayFieldTemplate.tsx +2 -9
  97. package/src/BaseInputTemplate/BaseInputTemplate.tsx +13 -19
  98. package/src/CheckboxWidget/CheckboxWidget.tsx +8 -17
  99. package/src/CheckboxesWidget/CheckboxesWidget.tsx +7 -10
  100. package/src/DescriptionField/DescriptionField.tsx +1 -1
  101. package/src/ErrorList/ErrorList.tsx +6 -4
  102. package/src/FieldErrorTemplate/FieldErrorTemplate.tsx +8 -8
  103. package/src/FieldHelpTemplate/FieldHelpTemplate.tsx +2 -1
  104. package/src/FieldTemplate/FieldTemplate.tsx +2 -8
  105. package/src/Form/Form.tsx +4 -3
  106. package/src/GridTemplate/GridTemplate.tsx +1 -1
  107. package/src/IconButton/IconButton.tsx +19 -9
  108. package/src/MultiSchemaFieldTemplate/MultiSchemaFieldTemplate.tsx +1 -1
  109. package/src/ObjectFieldTemplate/ObjectFieldTemplate.tsx +4 -14
  110. package/src/OptionalDataControlsTemplate/OptionalDataControlsTemplate.tsx +3 -2
  111. package/src/RadioWidget/RadioWidget.tsx +10 -13
  112. package/src/RangeWidget/RangeWidget.tsx +5 -4
  113. package/src/SelectWidget/SelectWidget.tsx +11 -14
  114. package/src/SubmitButton/SubmitButton.tsx +2 -1
  115. package/src/Templates/Templates.ts +1 -1
  116. package/src/TextareaWidget/TextareaWidget.tsx +10 -9
  117. package/src/Theme/Theme.tsx +2 -2
  118. package/src/TitleField/TitleField.tsx +2 -1
  119. package/src/Widgets/Widgets.ts +1 -1
  120. package/src/WrapIfAdditionalTemplate/WrapIfAdditionalTemplate.tsx +2 -9
  121. package/src/components/ui/alert.tsx +1 -1
  122. package/src/components/ui/badge.tsx +1 -1
  123. package/src/components/ui/button.tsx +1 -1
  124. package/src/components/ui/checkbox.tsx +1 -1
  125. package/src/components/ui/command.tsx +13 -14
  126. package/src/components/ui/dialog.tsx +1 -1
  127. package/src/components/ui/fancy-multi-select.tsx +5 -13
  128. package/src/components/ui/fancy-select.tsx +7 -3
  129. package/src/components/ui/input.tsx +1 -1
  130. package/src/components/ui/label.tsx +1 -1
  131. package/src/components/ui/radio-group.tsx +1 -1
  132. package/src/components/ui/separator.tsx +1 -1
  133. package/src/components/ui/slider.tsx +12 -6
  134. package/src/components/ui/textarea.tsx +1 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rjsf/shadcn",
3
- "version": "6.6.0",
3
+ "version": "6.6.2",
4
4
  "main": "dist/index.js",
5
5
  "module": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
@@ -56,7 +56,7 @@
56
56
  "lint": "oxlint src test",
57
57
  "precommit": "lint-staged",
58
58
  "test": "vitest run",
59
- "test:update": "vitest run --update-snapshots"
59
+ "test:update": "vitest run --update"
60
60
  },
61
61
  "lint-staged": {
62
62
  "{src,test}/**/*.{ts,tsx}": [
@@ -65,8 +65,8 @@
65
65
  ]
66
66
  },
67
67
  "peerDependencies": {
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
  "react": ">=18"
71
71
  },
72
72
  "engineStrict": false,
@@ -74,12 +74,11 @@
74
74
  "node": ">=20"
75
75
  },
76
76
  "devDependencies": {
77
- "@rjsf/core": "6.6.0",
78
- "@rjsf/snapshot-tests": "6.6.0",
79
- "@rjsf/utils": "6.6.0",
80
- "@rjsf/validator-ajv8": "6.6.0",
77
+ "@rjsf/core": "6.6.2",
78
+ "@rjsf/snapshot-tests": "6.6.2",
79
+ "@rjsf/utils": "6.6.2",
80
+ "@rjsf/validator-ajv8": "6.6.2",
81
81
  "@tailwindcss/cli": "^4.3.0",
82
- "jsdom": "^29.1.1",
83
82
  "tailwindcss": "^4.3.0"
84
83
  },
85
84
  "dependencies": {
@@ -1,4 +1,5 @@
1
- import { FormContextType, IconButtonProps, RJSFSchema, StrictRJSFSchema, TranslatableString } from '@rjsf/utils';
1
+ import type { FormContextType, IconButtonProps, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
2
+ import { TranslatableString } from '@rjsf/utils';
2
3
  import { PlusCircle } from 'lucide-react';
3
4
 
4
5
  import { Button } from '../components/ui/button';
@@ -1,11 +1,5 @@
1
- import {
2
- ArrayFieldItemTemplateProps,
3
- FormContextType,
4
- getTemplate,
5
- getUiOptions,
6
- RJSFSchema,
7
- StrictRJSFSchema,
8
- } from '@rjsf/utils';
1
+ import type { ArrayFieldItemTemplateProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
2
+ import { getTemplate, getUiOptions } from '@rjsf/utils';
9
3
 
10
4
  /** The `ArrayFieldItemTemplate` component is the template used to render an items of an array.
11
5
  *
@@ -1,12 +1,5 @@
1
- import {
2
- ArrayFieldTemplateProps,
3
- buttonId,
4
- FormContextType,
5
- getTemplate,
6
- getUiOptions,
7
- RJSFSchema,
8
- StrictRJSFSchema,
9
- } from '@rjsf/utils';
1
+ import type { ArrayFieldTemplateProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
2
+ import { buttonId, getTemplate, getUiOptions } from '@rjsf/utils';
10
3
 
11
4
  /** The `ArrayFieldTemplate` component is the template used to render all items in an array.
12
5
  *
@@ -1,14 +1,8 @@
1
- import { ChangeEvent, FocusEvent, MouseEvent, useCallback } from 'react';
1
+ import type { ChangeEvent, FocusEvent, MouseEvent } from 'react';
2
+ import { useCallback } from 'react';
2
3
  import { SchemaExamples } from '@rjsf/core';
3
- import {
4
- ariaDescribedByIds,
5
- BaseInputTemplateProps,
6
- examplesId,
7
- FormContextType,
8
- getInputProps,
9
- RJSFSchema,
10
- StrictRJSFSchema,
11
- } from '@rjsf/utils';
4
+ import type { BaseInputTemplateProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
5
+ import { ariaDescribedByIds, examplesId, getInputProps } from '@rjsf/utils';
12
6
 
13
7
  import { Input } from '../components/ui/input';
14
8
  import { cn } from '../lib/utils';
@@ -50,11 +44,11 @@ export default function BaseInputTemplate<
50
44
  ...extraProps,
51
45
  ...getInputProps<T, S, F>(schema, type, options),
52
46
  };
53
- const _onChange = ({ target: { value } }: ChangeEvent<HTMLInputElement>) =>
54
- onChange(value === '' ? options.emptyValue : value);
55
- const _onBlur = ({ target }: FocusEvent<HTMLInputElement>) => onBlur(id, target && target.value);
56
- const _onFocus = ({ target }: FocusEvent<HTMLInputElement>) => onFocus(id, target && target.value);
57
- const _onClear = useCallback(
47
+ const handleChange = ({ target: { value: newValue } }: ChangeEvent<HTMLInputElement>) =>
48
+ onChange(newValue === '' ? options.emptyValue : newValue);
49
+ const handleBlur = ({ target }: FocusEvent<HTMLInputElement>) => onBlur(id, target && target.value);
50
+ const handleFocus = ({ target }: FocusEvent<HTMLInputElement>) => onFocus(id, target && target.value);
51
+ const handleClear = useCallback(
58
52
  (e: MouseEvent) => {
59
53
  e.preventDefault();
60
54
  e.stopPropagation();
@@ -78,13 +72,13 @@ export default function BaseInputTemplate<
78
72
  list={schema.examples ? examplesId(id) : undefined}
79
73
  {...inputProps}
80
74
  value={value || value === 0 ? value : ''}
81
- onChange={onChangeOverride || _onChange}
82
- onBlur={_onBlur}
83
- onFocus={_onFocus}
75
+ onChange={onChangeOverride || handleChange}
76
+ onBlur={handleBlur}
77
+ onFocus={handleFocus}
84
78
  aria-describedby={ariaDescribedByIds(id, !!schema.examples)}
85
79
  />
86
80
  {options.allowClearTextInputs && !readonly && !disabled && value && (
87
- <ClearButton onClick={_onClear} registry={registry} />
81
+ <ClearButton onClick={handleClear} registry={registry} />
88
82
  )}
89
83
  {children}
90
84
  <SchemaExamples id={id} schema={schema} />
@@ -1,14 +1,5 @@
1
- import {
2
- ariaDescribedByIds,
3
- descriptionId,
4
- FormContextType,
5
- getTemplate,
6
- labelValue,
7
- RJSFSchema,
8
- schemaRequiresTrueValue,
9
- StrictRJSFSchema,
10
- WidgetProps,
11
- } from '@rjsf/utils';
1
+ import type { FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps } from '@rjsf/utils';
2
+ import { ariaDescribedByIds, descriptionId, getTemplate, labelValue, schemaRequiresTrueValue } from '@rjsf/utils';
12
3
 
13
4
  import { Checkbox } from '../components/ui/checkbox';
14
5
  import { Label } from '../components/ui/label';
@@ -51,9 +42,9 @@ export default function CheckboxWidget<
51
42
  options,
52
43
  );
53
44
 
54
- const _onChange = (checked: boolean) => onChange(checked);
55
- const _onBlur = () => onBlur(id, value);
56
- const _onFocus = () => onFocus(id, value);
45
+ const handleChange = (checked: boolean) => onChange(checked);
46
+ const handleBlur = () => onBlur(id, value);
47
+ const handleFocus = () => onFocus(id, value);
57
48
 
58
49
  const description = options.description || schema.description;
59
50
  return (
@@ -78,9 +69,9 @@ export default function CheckboxWidget<
78
69
  required={required}
79
70
  disabled={disabled || readonly}
80
71
  autoFocus={autofocus}
81
- onCheckedChange={_onChange}
82
- onBlur={_onBlur}
83
- onFocus={_onFocus}
72
+ onCheckedChange={handleChange}
73
+ onBlur={handleBlur}
74
+ onFocus={handleFocus}
84
75
  className={className}
85
76
  />
86
77
  <Label className='leading-tight' htmlFor={id}>
@@ -1,4 +1,5 @@
1
- import { FocusEvent } from 'react';
1
+ import type { FocusEvent } from 'react';
2
+ import type { FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps } from '@rjsf/utils';
2
3
  import {
3
4
  ariaDescribedByIds,
4
5
  enumOptionValueDecoder,
@@ -6,11 +7,7 @@ import {
6
7
  enumOptionsIsSelected,
7
8
  enumOptionsSelectValue,
8
9
  getOptionValueFormat,
9
- FormContextType,
10
10
  optionId,
11
- RJSFSchema,
12
- StrictRJSFSchema,
13
- WidgetProps,
14
11
  } from '@rjsf/utils';
15
12
 
16
13
  import { Checkbox } from '../components/ui/checkbox';
@@ -44,9 +41,9 @@ export default function CheckboxesWidget<
44
41
  const optionValueFormat = getOptionValueFormat(options);
45
42
  const checkboxesValues = Array.isArray(value) ? value : [value];
46
43
 
47
- const _onBlur = ({ target }: FocusEvent<HTMLButtonElement>) =>
44
+ const handleBlur = ({ target }: FocusEvent<HTMLButtonElement>) =>
48
45
  onBlur(id, enumOptionValueDecoder<S>(target && (target as any).value, enumOptions, optionValueFormat, emptyValue));
49
- const _onFocus = ({ target }: FocusEvent<HTMLButtonElement>) =>
46
+ const handleFocus = ({ target }: FocusEvent<HTMLButtonElement>) =>
50
47
  onFocus(id, enumOptionValueDecoder<S>(target && (target as any).value, enumOptions, optionValueFormat, emptyValue));
51
48
 
52
49
  return (
@@ -54,7 +51,7 @@ export default function CheckboxesWidget<
54
51
  {Array.isArray(enumOptions) &&
55
52
  enumOptions.map((option, index: number) => {
56
53
  const checked = enumOptionsIsSelected<S>(option.value, checkboxesValues);
57
- const itemDisabled = Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) !== -1;
54
+ const itemDisabled = Array.isArray(enumDisabled) && enumDisabled.includes(option.value);
58
55
  const indexOptionId = optionId(id, index);
59
56
 
60
57
  return (
@@ -74,8 +71,8 @@ export default function CheckboxesWidget<
74
71
  className={className}
75
72
  checked={checked}
76
73
  autoFocus={autofocus && index === 0}
77
- onBlur={_onBlur}
78
- onFocus={_onFocus}
74
+ onBlur={handleBlur}
75
+ onFocus={handleFocus}
79
76
  aria-describedby={ariaDescribedByIds(id)}
80
77
  />
81
78
  <Label className='leading-tight' htmlFor={optionId(id, index)}>
@@ -1,5 +1,5 @@
1
1
  import { RichDescription } from '@rjsf/core';
2
- import { DescriptionFieldProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
2
+ import type { DescriptionFieldProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
3
3
 
4
4
  /** The `DescriptionField` is the template to use to render the description of a field
5
5
  *
@@ -1,4 +1,5 @@
1
- import { ErrorListProps, FormContextType, RJSFSchema, StrictRJSFSchema, TranslatableString } from '@rjsf/utils';
1
+ import type { ErrorListProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
2
+ import { TranslatableString } from '@rjsf/utils';
2
3
  import { AlertCircle } from 'lucide-react';
3
4
 
4
5
  import { Alert, AlertDescription, AlertTitle } from '../components/ui/alert';
@@ -17,9 +18,10 @@ export default function ErrorList<T = any, S extends StrictRJSFSchema = RJSFSche
17
18
  <AlertCircle className='h-4 w-4' />
18
19
  <AlertTitle>{translateString(TranslatableString.ErrorsLabel)}</AlertTitle>
19
20
  <AlertDescription className='flex flex-col gap-1'>
20
- {errors.map((error, i: number) => {
21
- return <span key={i}>&#x2022; {error.stack}</span>;
22
- })}
21
+ {errors.map((error, i: number) => (
22
+ // oxlint-disable-next-line react/no-array-index-key
23
+ <span key={i}>&#x2022; {error.stack}</span>
24
+ ))}
23
25
  </AlertDescription>
24
26
  </Alert>
25
27
  );
@@ -1,4 +1,5 @@
1
- import { FieldErrorProps, FormContextType, RJSFSchema, StrictRJSFSchema, errorId } from '@rjsf/utils';
1
+ import type { FieldErrorProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
2
+ import { errorId } from '@rjsf/utils';
2
3
 
3
4
  /** The `FieldErrorTemplate` component renders the errors local to the particular field
4
5
  *
@@ -17,13 +18,12 @@ export default function FieldErrorTemplate<
17
18
 
18
19
  return (
19
20
  <div className='flex flex-col gap-1' id={id}>
20
- {errors.map((error, i: number) => {
21
- return (
22
- <span className={'text-xs font-medium text-destructive mb-1'} key={i}>
23
- {error}
24
- </span>
25
- );
26
- })}
21
+ {errors.map((error, i: number) => (
22
+ // oxlint-disable-next-line react/no-array-index-key
23
+ <span className='text-xs font-medium text-destructive mb-1' key={i}>
24
+ {error}
25
+ </span>
26
+ ))}
27
27
  </div>
28
28
  );
29
29
  }
@@ -1,5 +1,6 @@
1
1
  import { RichHelp } from '@rjsf/core';
2
- import { FieldHelpProps, FormContextType, RJSFSchema, StrictRJSFSchema, helpId } from '@rjsf/utils';
2
+ import type { FieldHelpProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
3
+ import { helpId } from '@rjsf/utils';
3
4
 
4
5
  import { cn } from '../lib/utils';
5
6
 
@@ -1,11 +1,5 @@
1
- import {
2
- FieldTemplateProps,
3
- FormContextType,
4
- getTemplate,
5
- getUiOptions,
6
- RJSFSchema,
7
- StrictRJSFSchema,
8
- } from '@rjsf/utils';
1
+ import type { FieldTemplateProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
2
+ import { getTemplate, getUiOptions } from '@rjsf/utils';
9
3
 
10
4
  import { cn } from '../lib/utils';
11
5
 
package/src/Form/Form.tsx CHANGED
@@ -1,6 +1,7 @@
1
- import { ComponentType } from 'react';
2
- import { FormProps, withTheme } 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,4 +1,4 @@
1
- import { GridTemplateProps } from '@rjsf/utils';
1
+ import type { GridTemplateProps } from '@rjsf/utils';
2
2
 
3
3
  import { cn } from '../lib/utils';
4
4
 
@@ -1,8 +1,11 @@
1
- import { FormContextType, IconButtonProps, RJSFSchema, StrictRJSFSchema, TranslatableString } from '@rjsf/utils';
1
+ import { memo } from 'react';
2
+ import type { FormContextType, IconButtonProps, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
3
+ import { TranslatableString } from '@rjsf/utils';
2
4
  import type { VariantProps } from 'class-variance-authority';
3
5
  import { ChevronDown, ChevronUp, Copy, Trash2, X } from 'lucide-react';
4
6
 
5
- import { Button, buttonVariants } from '../components/ui/button';
7
+ import type { buttonVariants } from '../components/ui/button';
8
+ import { Button } from '../components/ui/button';
6
9
 
7
10
  export type ShadIconButtonProps<
8
11
  T = any,
@@ -17,7 +20,7 @@ export type ShadIconButtonProps<
17
20
  *
18
21
  * @param props - The combined props from RJSF IconButtonProps and Shadcn ButtonProps, including icon and event handlers
19
22
  */
20
- export default function IconButton<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
23
+ function IconButtonFn<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
21
24
  props: ShadIconButtonProps<T, S, F>,
22
25
  ) {
23
26
  const { icon, iconType, className, uiSchema, registry, ...otherProps } = props;
@@ -27,6 +30,8 @@ export default function IconButton<T = any, S extends StrictRJSFSchema = RJSFSch
27
30
  </Button>
28
31
  );
29
32
  }
33
+ const IconButton = memo(IconButtonFn) as typeof IconButtonFn;
34
+ export default IconButton;
30
35
 
31
36
  /** Renders a copy button for RJSF array fields that allows users to duplicate array items.
32
37
  * The button includes a copy icon and uses the RJSF translation system for the tooltip text.
@@ -34,7 +39,7 @@ export default function IconButton<T = any, S extends StrictRJSFSchema = RJSFSch
34
39
  *
35
40
  * @param props - The RJSF icon button properties, including registry for translations and event handlers
36
41
  */
37
- export function CopyButton<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
42
+ function CopyButtonFn<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
38
43
  props: ShadIconButtonProps<T, S, F>,
39
44
  ) {
40
45
  const {
@@ -44,6 +49,7 @@ export function CopyButton<T = any, S extends StrictRJSFSchema = RJSFSchema, F e
44
49
  <IconButton title={translateString(TranslatableString.CopyButton)} {...props} icon={<Copy className='h-4 w-4' />} />
45
50
  );
46
51
  }
52
+ export const CopyButton = memo(CopyButtonFn) as typeof CopyButtonFn;
47
53
 
48
54
  /** Renders a move down button for RJSF array fields that allows reordering of array items.
49
55
  * The button includes a chevron-down icon and uses the RJSF translation system for the tooltip text.
@@ -51,7 +57,7 @@ export function CopyButton<T = any, S extends StrictRJSFSchema = RJSFSchema, F e
51
57
  *
52
58
  * @param props - The RJSF icon button properties, including registry for translations and event handlers
53
59
  */
54
- export function MoveDownButton<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
60
+ function MoveDownButtonFn<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
55
61
  props: ShadIconButtonProps<T, S, F>,
56
62
  ) {
57
63
  const {
@@ -65,6 +71,7 @@ export function MoveDownButton<T = any, S extends StrictRJSFSchema = RJSFSchema,
65
71
  />
66
72
  );
67
73
  }
74
+ export const MoveDownButton = memo(MoveDownButtonFn) as typeof MoveDownButtonFn;
68
75
 
69
76
  /** Renders a move up button for RJSF array fields that allows reordering of array items.
70
77
  * The button includes a chevron-up icon and uses the RJSF translation system for the tooltip text.
@@ -72,7 +79,7 @@ export function MoveDownButton<T = any, S extends StrictRJSFSchema = RJSFSchema,
72
79
  *
73
80
  * @param props - The RJSF icon button properties, including registry for translations and event handlers
74
81
  */
75
- export function MoveUpButton<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
82
+ function MoveUpButtonFn<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
76
83
  props: ShadIconButtonProps<T, S, F>,
77
84
  ) {
78
85
  const {
@@ -86,6 +93,7 @@ export function MoveUpButton<T = any, S extends StrictRJSFSchema = RJSFSchema, F
86
93
  />
87
94
  );
88
95
  }
96
+ export const MoveUpButton = memo(MoveUpButtonFn) as typeof MoveUpButtonFn;
89
97
 
90
98
  /** Renders a remove button for RJSF array fields that allows deletion of array items.
91
99
  * The button includes a trash icon and uses the RJSF translation system for the tooltip text.
@@ -94,7 +102,7 @@ export function MoveUpButton<T = any, S extends StrictRJSFSchema = RJSFSchema, F
94
102
  *
95
103
  * @param props - The RJSF icon button properties, including registry for translations and event handlers
96
104
  */
97
- export function RemoveButton<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
105
+ function RemoveButtonFn<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
98
106
  props: ShadIconButtonProps<T, S, F>,
99
107
  ) {
100
108
  const {
@@ -104,13 +112,14 @@ export function RemoveButton<T = any, S extends StrictRJSFSchema = RJSFSchema, F
104
112
  <IconButton
105
113
  title={translateString(TranslatableString.RemoveButton)}
106
114
  {...props}
107
- className={'border-destructive'}
115
+ className='border-destructive'
108
116
  icon={<Trash2 className='h-4 w-4 stroke-destructive' />}
109
117
  />
110
118
  );
111
119
  }
120
+ export const RemoveButton = memo(RemoveButtonFn) as typeof RemoveButtonFn;
112
121
 
113
- export function ClearButton<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
122
+ function ClearButtonFn<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
114
123
  props: ShadIconButtonProps<T, S, F>,
115
124
  ) {
116
125
  const {
@@ -118,3 +127,4 @@ export function ClearButton<T = any, S extends StrictRJSFSchema = RJSFSchema, F
118
127
  } = props;
119
128
  return <IconButton title={translateString(TranslatableString.ClearButton)} {...props} icon={<X />} />;
120
129
  }
130
+ export const ClearButton = memo(ClearButtonFn) as typeof ClearButtonFn;
@@ -1,4 +1,4 @@
1
- import { FormContextType, MultiSchemaFieldTemplateProps, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
1
+ import type { FormContextType, MultiSchemaFieldTemplateProps, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
2
2
 
3
3
  import { cn } from '../lib/utils';
4
4
 
@@ -1,15 +1,5 @@
1
- import {
2
- buttonId,
3
- canExpand,
4
- descriptionId,
5
- FormContextType,
6
- getTemplate,
7
- getUiOptions,
8
- ObjectFieldTemplateProps,
9
- RJSFSchema,
10
- StrictRJSFSchema,
11
- titleId,
12
- } from '@rjsf/utils';
1
+ import type { FormContextType, ObjectFieldTemplateProps, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
2
+ import { buttonId, canExpand, descriptionId, getTemplate, getUiOptions, titleId } from '@rjsf/utils';
13
3
 
14
4
  /** The `ObjectFieldTemplate` is the template to use to render all the inner properties of an object along with the
15
5
  * title and description if available. If the object is expandable, then an `AddButton` is also rendered after all
@@ -72,8 +62,8 @@ export default function ObjectFieldTemplate<
72
62
  )}
73
63
  <div className='flex flex-col gap-2'>
74
64
  {!showOptionalDataControlInTitle ? optionalDataControl : undefined}
75
- {properties.map((element: any, index: number) => (
76
- <div key={index} className={`${element.hidden ? 'hidden' : ''} flex`}>
65
+ {properties.map((element: any) => (
66
+ <div key={element.name} className={`${element.hidden ? 'hidden' : ''} flex`}>
77
67
  <div className='w-full'>{element.content}</div>
78
68
  </div>
79
69
  ))}
@@ -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 { PlusCircle } from 'lucide-react';
3
3
 
4
4
  import IconButton, { RemoveButton } from '../IconButton';
@@ -29,7 +29,8 @@ export default function OptionalDataControlsTemplate<
29
29
  size='xs'
30
30
  />
31
31
  );
32
- } else if (onRemoveClick) {
32
+ }
33
+ if (onRemoveClick) {
33
34
  return (
34
35
  <RemoveButton
35
36
  id={id}
@@ -1,15 +1,12 @@
1
- import { FocusEvent } from 'react';
1
+ import type { FocusEvent } from 'react';
2
+ import type { FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps } from '@rjsf/utils';
2
3
  import {
3
4
  ariaDescribedByIds,
4
5
  enumOptionValueDecoder,
5
6
  enumOptionValueEncoder,
6
7
  enumOptionsIsSelected,
7
8
  getOptionValueFormat,
8
- FormContextType,
9
9
  optionId,
10
- RJSFSchema,
11
- StrictRJSFSchema,
12
- WidgetProps,
13
10
  } from '@rjsf/utils';
14
11
 
15
12
  import { Label } from '../components/ui/label';
@@ -36,11 +33,11 @@ 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 = (value: string) =>
40
- onChange(enumOptionValueDecoder<S>(value, enumOptions, optionValueFormat, emptyValue));
41
- const _onBlur = ({ target }: FocusEvent<HTMLInputElement>) =>
36
+ const handleChange = (enumValue: string) =>
37
+ onChange(enumOptionValueDecoder<S>(enumValue, enumOptions, optionValueFormat, emptyValue));
38
+ const handleBlur = ({ target }: FocusEvent<HTMLInputElement>) =>
42
39
  onBlur(id, enumOptionValueDecoder<S>(target && target.value, enumOptions, optionValueFormat, emptyValue));
43
- const _onFocus = ({ target }: FocusEvent<HTMLInputElement>) =>
40
+ const handleFocus = ({ target }: FocusEvent<HTMLInputElement>) =>
44
41
  onFocus(id, enumOptionValueDecoder<S>(target && target.value, enumOptions, optionValueFormat, emptyValue));
45
42
 
46
43
  const inline = Boolean(options && options.inline);
@@ -52,17 +49,17 @@ export default function RadioWidget<T = any, S extends StrictRJSFSchema = RJSFSc
52
49
  required={required}
53
50
  disabled={disabled || readonly}
54
51
  onValueChange={(e: string) => {
55
- _onChange(e);
52
+ handleChange(e);
56
53
  }}
57
- onBlur={_onBlur}
58
- onFocus={_onFocus}
54
+ onBlur={handleBlur}
55
+ onFocus={handleFocus}
59
56
  aria-describedby={ariaDescribedByIds(id)}
60
57
  orientation={inline ? 'horizontal' : 'vertical'}
61
58
  className={cn('flex flex-wrap', { 'flex-col': !inline }, className)}
62
59
  >
63
60
  {Array.isArray(enumOptions) &&
64
61
  enumOptions.map((option, index) => {
65
- const itemDisabled = Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) !== -1;
62
+ const itemDisabled = Array.isArray(enumDisabled) && enumDisabled.includes(option.value);
66
63
  const checked = enumOptionsIsSelected<S>(option.value, value);
67
64
  return (
68
65
  <div className='flex items-center gap-2' key={optionId(id, index)}>
@@ -1,4 +1,5 @@
1
- import { ariaDescribedByIds, FormContextType, rangeSpec, RJSFSchema, StrictRJSFSchema, WidgetProps } from '@rjsf/utils';
1
+ import type { FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps } from '@rjsf/utils';
2
+ import { ariaDescribedByIds, rangeSpec } from '@rjsf/utils';
2
3
  import _pick from 'lodash/pick';
3
4
 
4
5
  import { Slider } from '../components/ui/slider';
@@ -41,8 +42,8 @@ export default function RangeWidget<T = any, S extends StrictRJSFSchema = RJSFSc
41
42
  onChange,
42
43
  label,
43
44
  id,
44
- }: WidgetProps<T, S, F>): JSX.Element {
45
- const _onChange = (value: number[]) => onChange(value[0]);
45
+ }: WidgetProps<T, S, F>) {
46
+ const handleChange = (newValue: number[]) => onChange(newValue[0]);
46
47
 
47
48
  const sliderProps = { value, label, id, ...rangeSpec<S>(schema) };
48
49
  const uiProps = { id, ..._pick((options.props as object) || {}, allowedProps) };
@@ -54,7 +55,7 @@ export default function RangeWidget<T = any, S extends StrictRJSFSchema = RJSFSc
54
55
  max={sliderProps.max}
55
56
  step={sliderProps.step}
56
57
  value={[value as number]}
57
- onValueChange={_onChange}
58
+ onValueChange={handleChange}
58
59
  {...uiProps}
59
60
  aria-describedby={ariaDescribedByIds(id)}
60
61
  />
@@ -1,13 +1,10 @@
1
+ import type { FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps } from '@rjsf/utils';
1
2
  import {
2
3
  ariaDescribedByIds,
3
4
  enumOptionSelectedValue,
4
5
  enumOptionValueDecoder,
5
6
  enumOptionValueEncoder,
6
7
  getOptionValueFormat,
7
- FormContextType,
8
- RJSFSchema,
9
- StrictRJSFSchema,
10
- WidgetProps,
11
8
  } from '@rjsf/utils';
12
9
 
13
10
  import { FancyMultiSelect } from '../components/ui/fancy-multi-select';
@@ -42,19 +39,19 @@ export default function SelectWidget<
42
39
  const { enumOptions, enumDisabled, emptyValue: optEmptyValue } = options;
43
40
  const optionValueFormat = getOptionValueFormat(options);
44
41
 
45
- const _onFancyFocus = () => {
42
+ const handleFancyFocus = () => {
46
43
  onFocus(id, enumOptionValueDecoder<S>(value, enumOptions, optionValueFormat, optEmptyValue));
47
44
  };
48
45
 
49
- const _onFancyBlur = () => {
46
+ const handleFancyBlur = () => {
50
47
  onBlur(id, enumOptionValueDecoder<S>(value, enumOptions, optionValueFormat, optEmptyValue));
51
48
  };
52
49
 
53
- const items = (enumOptions as any)?.map(({ value, label }: any, index: number) => ({
54
- value: multiple ? value : enumOptionValueEncoder(value, index, optionValueFormat),
55
- label: label,
50
+ const items = (enumOptions as any)?.map(({ value: enumValue, label: enumLabel }: any, index: number) => ({
51
+ value: multiple ? enumValue : enumOptionValueEncoder(enumValue, index, optionValueFormat),
52
+ label: enumLabel,
56
53
  index,
57
- disabled: Array.isArray(enumDisabled) && enumDisabled.includes(value),
54
+ disabled: Array.isArray(enumDisabled) && enumDisabled.includes(enumValue),
58
55
  }));
59
56
 
60
57
  const cnClassName = cn({ 'border-destructive': rawErrors.length > 0 }, className);
@@ -73,8 +70,8 @@ export default function SelectWidget<
73
70
  required={required}
74
71
  placeholder={placeholder}
75
72
  className={cnClassName}
76
- onFocus={_onFancyFocus}
77
- onBlur={_onFancyBlur}
73
+ onFocus={handleFancyFocus}
74
+ onBlur={handleFancyBlur}
78
75
  ariaDescribedby={ariaDescribedByIds(id)}
79
76
  />
80
77
  ) : (
@@ -89,8 +86,8 @@ export default function SelectWidget<
89
86
  onValueChange={(values) => {
90
87
  onChange(enumOptionValueDecoder<S>(values.map(String), enumOptions, optionValueFormat, optEmptyValue));
91
88
  }}
92
- onFocus={_onFancyFocus}
93
- onBlur={_onFancyBlur}
89
+ onFocus={handleFancyFocus}
90
+ onBlur={handleFancyBlur}
94
91
  />
95
92
  )}
96
93
  </div>
@@ -1,4 +1,5 @@
1
- import { FormContextType, getSubmitButtonOptions, RJSFSchema, StrictRJSFSchema, SubmitButtonProps } from '@rjsf/utils';
1
+ import type { FormContextType, RJSFSchema, StrictRJSFSchema, SubmitButtonProps } from '@rjsf/utils';
2
+ import { getSubmitButtonOptions } from '@rjsf/utils';
2
3
 
3
4
  import { Button } from '../components/ui/button';
4
5
  import { cn } from '../lib/utils';