@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.
- package/dist/index.cjs +117 -100
- package/dist/index.cjs.map +3 -3
- package/dist/rjsf-shadcn.esm.js +105 -124
- package/dist/rjsf-shadcn.esm.js.map +3 -3
- package/dist/rjsf-shadcn.umd.js +96 -80
- package/lib/AddButton/AddButton.d.ts +1 -1
- package/lib/AddButton/AddButton.js.map +1 -1
- package/lib/ArrayFieldItemTemplate/ArrayFieldItemTemplate.d.ts +1 -1
- package/lib/ArrayFieldItemTemplate/ArrayFieldItemTemplate.js +1 -1
- package/lib/ArrayFieldItemTemplate/ArrayFieldItemTemplate.js.map +1 -1
- package/lib/ArrayFieldTemplate/ArrayFieldTemplate.d.ts +1 -1
- package/lib/ArrayFieldTemplate/ArrayFieldTemplate.js +1 -1
- package/lib/ArrayFieldTemplate/ArrayFieldTemplate.js.map +1 -1
- package/lib/BaseInputTemplate/BaseInputTemplate.d.ts +1 -1
- package/lib/BaseInputTemplate/BaseInputTemplate.js +6 -6
- package/lib/BaseInputTemplate/BaseInputTemplate.js.map +1 -1
- package/lib/CheckboxWidget/CheckboxWidget.d.ts +1 -1
- package/lib/CheckboxWidget/CheckboxWidget.js +5 -5
- package/lib/CheckboxWidget/CheckboxWidget.js.map +1 -1
- package/lib/CheckboxesWidget/CheckboxesWidget.d.ts +1 -1
- package/lib/CheckboxesWidget/CheckboxesWidget.js +4 -4
- package/lib/CheckboxesWidget/CheckboxesWidget.js.map +1 -1
- package/lib/DescriptionField/DescriptionField.d.ts +1 -1
- package/lib/ErrorList/ErrorList.d.ts +1 -1
- package/lib/ErrorList/ErrorList.js +1 -3
- package/lib/ErrorList/ErrorList.js.map +1 -1
- package/lib/FieldErrorTemplate/FieldErrorTemplate.d.ts +1 -1
- package/lib/FieldErrorTemplate/FieldErrorTemplate.js +1 -3
- package/lib/FieldErrorTemplate/FieldErrorTemplate.js.map +1 -1
- package/lib/FieldHelpTemplate/FieldHelpTemplate.d.ts +1 -1
- package/lib/FieldHelpTemplate/FieldHelpTemplate.js.map +1 -1
- package/lib/FieldTemplate/FieldTemplate.d.ts +1 -1
- package/lib/FieldTemplate/FieldTemplate.js +1 -1
- package/lib/FieldTemplate/FieldTemplate.js.map +1 -1
- package/lib/Form/Form.d.ts +3 -3
- package/lib/Form/Form.js.map +1 -1
- package/lib/GridTemplate/GridTemplate.d.ts +1 -1
- package/lib/IconButton/IconButton.d.ts +15 -8
- package/lib/IconButton/IconButton.js +14 -6
- package/lib/IconButton/IconButton.js.map +1 -1
- package/lib/MultiSchemaFieldTemplate/MultiSchemaFieldTemplate.d.ts +1 -1
- package/lib/ObjectFieldTemplate/ObjectFieldTemplate.d.ts +1 -1
- package/lib/ObjectFieldTemplate/ObjectFieldTemplate.js +2 -2
- package/lib/ObjectFieldTemplate/ObjectFieldTemplate.js.map +1 -1
- package/lib/OptionalDataControlsTemplate/OptionalDataControlsTemplate.d.ts +1 -1
- package/lib/OptionalDataControlsTemplate/OptionalDataControlsTemplate.js +1 -1
- package/lib/OptionalDataControlsTemplate/OptionalDataControlsTemplate.js.map +1 -1
- package/lib/RadioWidget/RadioWidget.d.ts +1 -1
- package/lib/RadioWidget/RadioWidget.js +6 -6
- package/lib/RadioWidget/RadioWidget.js.map +1 -1
- package/lib/RangeWidget/RangeWidget.d.ts +2 -2
- package/lib/RangeWidget/RangeWidget.js +2 -2
- package/lib/RangeWidget/RangeWidget.js.map +1 -1
- package/lib/SelectWidget/SelectWidget.d.ts +1 -1
- package/lib/SelectWidget/SelectWidget.js +8 -8
- package/lib/SelectWidget/SelectWidget.js.map +1 -1
- package/lib/SubmitButton/SubmitButton.d.ts +1 -1
- package/lib/SubmitButton/SubmitButton.js.map +1 -1
- package/lib/Templates/Templates.d.ts +1 -1
- package/lib/TextareaWidget/TextareaWidget.d.ts +1 -1
- package/lib/TextareaWidget/TextareaWidget.js +4 -4
- package/lib/TextareaWidget/TextareaWidget.js.map +1 -1
- package/lib/Theme/Theme.d.ts +2 -2
- package/lib/TitleField/TitleField.d.ts +1 -1
- package/lib/TitleField/TitleField.js.map +1 -1
- package/lib/Widgets/Widgets.d.ts +1 -1
- package/lib/WrapIfAdditionalTemplate/WrapIfAdditionalTemplate.d.ts +1 -1
- package/lib/WrapIfAdditionalTemplate/WrapIfAdditionalTemplate.js +1 -1
- package/lib/WrapIfAdditionalTemplate/WrapIfAdditionalTemplate.js.map +1 -1
- package/lib/components/ui/alert.d.ts +1 -1
- package/lib/components/ui/badge.d.ts +1 -1
- package/lib/components/ui/button.d.ts +1 -1
- package/lib/components/ui/checkbox.d.ts +1 -1
- package/lib/components/ui/command.d.ts +1 -1
- package/lib/components/ui/command.js +1 -3
- package/lib/components/ui/command.js.map +1 -1
- package/lib/components/ui/dialog.d.ts +1 -1
- package/lib/components/ui/fancy-multi-select.d.ts +3 -3
- package/lib/components/ui/fancy-multi-select.js +2 -2
- package/lib/components/ui/fancy-multi-select.js.map +1 -1
- package/lib/components/ui/fancy-select.d.ts +3 -3
- package/lib/components/ui/fancy-select.js +1 -1
- package/lib/components/ui/fancy-select.js.map +1 -1
- package/lib/components/ui/input.d.ts +1 -1
- package/lib/components/ui/label.d.ts +1 -1
- package/lib/components/ui/radio-group.d.ts +1 -1
- package/lib/components/ui/separator.d.ts +1 -1
- package/lib/components/ui/slider.d.ts +1 -1
- package/lib/components/ui/slider.js +10 -2
- package/lib/components/ui/slider.js.map +1 -1
- package/lib/components/ui/textarea.d.ts +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +8 -9
- package/src/AddButton/AddButton.tsx +2 -1
- package/src/ArrayFieldItemTemplate/ArrayFieldItemTemplate.tsx +2 -8
- package/src/ArrayFieldTemplate/ArrayFieldTemplate.tsx +2 -9
- package/src/BaseInputTemplate/BaseInputTemplate.tsx +13 -19
- package/src/CheckboxWidget/CheckboxWidget.tsx +8 -17
- package/src/CheckboxesWidget/CheckboxesWidget.tsx +7 -10
- package/src/DescriptionField/DescriptionField.tsx +1 -1
- package/src/ErrorList/ErrorList.tsx +6 -4
- package/src/FieldErrorTemplate/FieldErrorTemplate.tsx +8 -8
- package/src/FieldHelpTemplate/FieldHelpTemplate.tsx +2 -1
- package/src/FieldTemplate/FieldTemplate.tsx +2 -8
- package/src/Form/Form.tsx +4 -3
- package/src/GridTemplate/GridTemplate.tsx +1 -1
- package/src/IconButton/IconButton.tsx +19 -9
- package/src/MultiSchemaFieldTemplate/MultiSchemaFieldTemplate.tsx +1 -1
- package/src/ObjectFieldTemplate/ObjectFieldTemplate.tsx +4 -14
- package/src/OptionalDataControlsTemplate/OptionalDataControlsTemplate.tsx +3 -2
- package/src/RadioWidget/RadioWidget.tsx +10 -13
- package/src/RangeWidget/RangeWidget.tsx +5 -4
- package/src/SelectWidget/SelectWidget.tsx +11 -14
- package/src/SubmitButton/SubmitButton.tsx +2 -1
- package/src/Templates/Templates.ts +1 -1
- package/src/TextareaWidget/TextareaWidget.tsx +10 -9
- package/src/Theme/Theme.tsx +2 -2
- package/src/TitleField/TitleField.tsx +2 -1
- package/src/Widgets/Widgets.ts +1 -1
- package/src/WrapIfAdditionalTemplate/WrapIfAdditionalTemplate.tsx +2 -9
- package/src/components/ui/alert.tsx +1 -1
- package/src/components/ui/badge.tsx +1 -1
- package/src/components/ui/button.tsx +1 -1
- package/src/components/ui/checkbox.tsx +1 -1
- package/src/components/ui/command.tsx +13 -14
- package/src/components/ui/dialog.tsx +1 -1
- package/src/components/ui/fancy-multi-select.tsx +5 -13
- package/src/components/ui/fancy-select.tsx +7 -3
- package/src/components/ui/input.tsx +1 -1
- package/src/components/ui/label.tsx +1 -1
- package/src/components/ui/radio-group.tsx +1 -1
- package/src/components/ui/separator.tsx +1 -1
- package/src/components/ui/slider.tsx +12 -6
- package/src/components/ui/textarea.tsx +1 -1
|
@@ -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,5 +1,6 @@
|
|
|
1
|
-
import { ChangeEvent, FocusEvent } from 'react';
|
|
2
|
-
import {
|
|
1
|
+
import type { ChangeEvent, FocusEvent } from 'react';
|
|
2
|
+
import type { FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps } from '@rjsf/utils';
|
|
3
|
+
import { ariaDescribedByIds } from '@rjsf/utils';
|
|
3
4
|
|
|
4
5
|
import { Textarea } from '../components/ui/textarea';
|
|
5
6
|
|
|
@@ -34,10 +35,10 @@ export default function TextareaWidget<
|
|
|
34
35
|
options,
|
|
35
36
|
className,
|
|
36
37
|
}: CustomWidgetProps<T, S, F>) {
|
|
37
|
-
const
|
|
38
|
-
onChange(
|
|
39
|
-
const
|
|
40
|
-
const
|
|
38
|
+
const handleChange = ({ target: { value: newValue } }: ChangeEvent<HTMLTextAreaElement>) =>
|
|
39
|
+
onChange(newValue === '' ? options.emptyValue : newValue);
|
|
40
|
+
const handleBlur = ({ target }: FocusEvent<HTMLTextAreaElement>) => onBlur(id, target && target.value);
|
|
41
|
+
const handleFocus = ({ target }: FocusEvent<HTMLTextAreaElement>) => onFocus(id, target && target.value);
|
|
41
42
|
|
|
42
43
|
return (
|
|
43
44
|
<div className='flex p-0.5'>
|
|
@@ -51,9 +52,9 @@ export default function TextareaWidget<
|
|
|
51
52
|
required={required}
|
|
52
53
|
autoFocus={autofocus}
|
|
53
54
|
rows={options.rows || 5}
|
|
54
|
-
onChange={
|
|
55
|
-
onBlur={
|
|
56
|
-
onFocus={
|
|
55
|
+
onChange={handleChange}
|
|
56
|
+
onBlur={handleBlur}
|
|
57
|
+
onFocus={handleFocus}
|
|
57
58
|
aria-describedby={ariaDescribedByIds(id)}
|
|
58
59
|
className={className}
|
|
59
60
|
/>
|
package/src/Theme/Theme.tsx
CHANGED
|
@@ -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,4 +1,5 @@
|
|
|
1
|
-
import { FormContextType,
|
|
1
|
+
import type { FormContextType, RJSFSchema, StrictRJSFSchema, TitleFieldProps } from '@rjsf/utils';
|
|
2
|
+
import { getUiOptions } from '@rjsf/utils';
|
|
2
3
|
|
|
3
4
|
import { Separator } from '../components/ui/separator';
|
|
4
5
|
|
package/src/Widgets/Widgets.ts
CHANGED
|
@@ -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 CheckboxesWidget from '../CheckboxesWidget/CheckboxesWidget';
|
|
4
4
|
import CheckboxWidget from '../CheckboxWidget/CheckboxWidget';
|
|
@@ -1,12 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
buttonId,
|
|
4
|
-
FormContextType,
|
|
5
|
-
RJSFSchema,
|
|
6
|
-
StrictRJSFSchema,
|
|
7
|
-
TranslatableString,
|
|
8
|
-
WrapIfAdditionalTemplateProps,
|
|
9
|
-
} from '@rjsf/utils';
|
|
1
|
+
import type { FormContextType, RJSFSchema, StrictRJSFSchema, WrapIfAdditionalTemplateProps } from '@rjsf/utils';
|
|
2
|
+
import { ADDITIONAL_PROPERTY_FLAG, buttonId, TranslatableString } from '@rjsf/utils';
|
|
10
3
|
|
|
11
4
|
import { Input } from '../components/ui/input';
|
|
12
5
|
import { Separator } from '../components/ui/separator';
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import { ComponentProps, ComponentPropsWithoutRef, ElementRef
|
|
3
|
+
import type { ComponentProps, ComponentPropsWithoutRef, ElementRef } from 'react';
|
|
4
|
+
import { forwardRef } from 'react';
|
|
4
5
|
import { Command as CommandPrimitive } from 'cmdk';
|
|
5
6
|
import { Search } from 'lucide-react';
|
|
6
7
|
|
|
@@ -14,19 +15,17 @@ import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } f
|
|
|
14
15
|
*/
|
|
15
16
|
|
|
16
17
|
const Command = forwardRef<ElementRef<typeof CommandPrimitive>, ComponentPropsWithoutRef<typeof CommandPrimitive>>(
|
|
17
|
-
({ className, ...props }, ref) =>
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
);
|
|
29
|
-
},
|
|
18
|
+
({ className, ...props }, ref) => (
|
|
19
|
+
<CommandPrimitive
|
|
20
|
+
ref={ref}
|
|
21
|
+
data-slot='command'
|
|
22
|
+
className={cn(
|
|
23
|
+
'bg-popover text-popover-foreground flex h-full w-full flex-col overflow-hidden rounded-md',
|
|
24
|
+
className,
|
|
25
|
+
)}
|
|
26
|
+
{...props}
|
|
27
|
+
/>
|
|
28
|
+
),
|
|
30
29
|
);
|
|
31
30
|
|
|
32
31
|
/**
|
|
@@ -1,15 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
FocusEventHandler,
|
|
6
|
-
KeyboardEvent,
|
|
7
|
-
ReactElement,
|
|
8
|
-
useCallback,
|
|
9
|
-
useMemo,
|
|
10
|
-
useRef,
|
|
11
|
-
useState,
|
|
12
|
-
} from 'react';
|
|
3
|
+
import type { FocusEvent, FocusEventHandler, KeyboardEvent, ReactElement } from 'react';
|
|
4
|
+
import { useCallback, useMemo, useRef, useState } from 'react';
|
|
13
5
|
import { Command as CommandPrimitive } from 'cmdk';
|
|
14
6
|
import isEqual from 'lodash/isEqual';
|
|
15
7
|
import { X } from 'lucide-react';
|
|
@@ -21,7 +13,7 @@ import { Command, CommandGroup, CommandItem, CommandList } from './command';
|
|
|
21
13
|
/**
|
|
22
14
|
* Represents an item in the fancy multi-select dropdown
|
|
23
15
|
*/
|
|
24
|
-
export
|
|
16
|
+
export interface FancySelectItem {
|
|
25
17
|
/** The value of the item */
|
|
26
18
|
value: any;
|
|
27
19
|
/** The display label for the item */
|
|
@@ -30,7 +22,7 @@ export type FancySelectItem = {
|
|
|
30
22
|
index: number;
|
|
31
23
|
/** Whether the item is disabled */
|
|
32
24
|
disabled?: boolean;
|
|
33
|
-
}
|
|
25
|
+
}
|
|
34
26
|
|
|
35
27
|
/**
|
|
36
28
|
* Props interface for the FancyMultiSelect component
|
|
@@ -129,7 +121,7 @@ export function FancyMultiSelect({
|
|
|
129
121
|
}
|
|
130
122
|
setInputValue('');
|
|
131
123
|
const newSelected = multiple ? [...selectedItems, item] : [item];
|
|
132
|
-
onValueChange?.(newSelected.map((
|
|
124
|
+
onValueChange?.(newSelected.map((selectedItem) => selectedItem.index));
|
|
133
125
|
},
|
|
134
126
|
[multiple, selectedItems, onValueChange, disabled],
|
|
135
127
|
);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import { FocusEvent, FocusEventHandler, ReactElement
|
|
3
|
+
import type { FocusEvent, FocusEventHandler, ReactElement } from 'react';
|
|
4
|
+
import { useEffect, useRef, useState } from 'react';
|
|
4
5
|
import { Check, ChevronDown } from 'lucide-react';
|
|
5
6
|
|
|
6
7
|
import { cn } from '../../lib/utils';
|
|
@@ -9,7 +10,7 @@ import { Command, CommandGroup, CommandItem, CommandList } from './command';
|
|
|
9
10
|
/**
|
|
10
11
|
* Represents an item in the fancy select dropdown
|
|
11
12
|
*/
|
|
12
|
-
export
|
|
13
|
+
export interface FancySelectItem {
|
|
13
14
|
/** The value of the item */
|
|
14
15
|
value: any;
|
|
15
16
|
/** The display label for the item */
|
|
@@ -18,7 +19,7 @@ export type FancySelectItem = {
|
|
|
18
19
|
index: number;
|
|
19
20
|
/** Whether the item is disabled */
|
|
20
21
|
disabled?: boolean;
|
|
21
|
-
}
|
|
22
|
+
}
|
|
22
23
|
|
|
23
24
|
/**
|
|
24
25
|
* Props interface for the FancySelect component
|
|
@@ -101,7 +102,10 @@ export function FancySelect({
|
|
|
101
102
|
aria-placeholder={ariaPlaceholder}
|
|
102
103
|
>
|
|
103
104
|
<div
|
|
105
|
+
role='button'
|
|
106
|
+
tabIndex={disabled ? -1 : 0}
|
|
104
107
|
onClick={() => !disabled && setOpen(!open)}
|
|
108
|
+
onKeyDown={(e) => (e.key === 'Enter' || e.key === ' ') && !disabled && setOpen(!open)}
|
|
105
109
|
className={cn(
|
|
106
110
|
'flex h-9 w-full items-center justify-between gap-2 whitespace-nowrap rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50',
|
|
107
111
|
!selectedItem && required && 'border-red-500',
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import { ComponentProps
|
|
3
|
+
import type { ComponentProps } from 'react';
|
|
4
|
+
import { useMemo } from 'react';
|
|
4
5
|
import { Range, Root, Thumb, Track } from '@radix-ui/react-slider';
|
|
5
6
|
|
|
6
7
|
import { cn } from '../../lib/utils';
|
|
@@ -14,10 +15,15 @@ import { cn } from '../../lib/utils';
|
|
|
14
15
|
* @returns A slider input element with track and thumb
|
|
15
16
|
*/
|
|
16
17
|
function Slider({ className, defaultValue, value, min = 0, max = 100, ...props }: ComponentProps<typeof Root>) {
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
const enumValues = useMemo(() => {
|
|
19
|
+
if (Array.isArray(value)) {
|
|
20
|
+
return value;
|
|
21
|
+
}
|
|
22
|
+
if (Array.isArray(defaultValue)) {
|
|
23
|
+
return defaultValue;
|
|
24
|
+
}
|
|
25
|
+
return [min, max];
|
|
26
|
+
}, [value, defaultValue, min, max]);
|
|
21
27
|
return (
|
|
22
28
|
<Root
|
|
23
29
|
data-slot='slider'
|
|
@@ -42,7 +48,7 @@ function Slider({ className, defaultValue, value, min = 0, max = 100, ...props }
|
|
|
42
48
|
className={cn('bg-primary absolute data-[orientation=horizontal]:h-full data-[orientation=vertical]:w-full')}
|
|
43
49
|
/>
|
|
44
50
|
</Track>
|
|
45
|
-
{Array.from({ length:
|
|
51
|
+
{Array.from({ length: enumValues.length }, (_, index) => (
|
|
46
52
|
<Thumb
|
|
47
53
|
data-slot='slider-thumb'
|
|
48
54
|
key={index}
|