@react-fabric/form 1.0.0-beta.61 → 1.0.0-beta.63
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/css/_colorPicker.css +35 -5
- package/css/_file.css +2 -2
- package/dist/cjs/builder/FileField.js +14 -11
- package/dist/cjs/builder/SchemaEditor.js +1 -1
- package/dist/cjs/builder/components/SchemaArrayForm.js +2 -4
- package/dist/cjs/builder/components/SchemaField.js +3 -3
- package/dist/cjs/form/Controller.js +1 -1
- package/dist/cjs/form/Form.js +42 -41
- package/dist/cjs/form/useForm.js +32 -0
- package/dist/cjs/hooks/useFileUploader.js +44 -32
- package/dist/cjs/hooks/useFormBuilder.js +3 -3
- package/dist/cjs/i18n/index.js +4 -4
- package/dist/cjs/index.js +2 -1
- package/dist/cjs/input/ArrayInput.js +66 -19
- package/dist/cjs/input/AvatarInput.js +21 -16
- package/dist/cjs/input/Checkbox.js +1 -1
- package/dist/cjs/input/ColorInput.js +26 -19
- package/dist/cjs/input/ColorPicker.js +16 -9
- package/dist/cjs/input/DateInput.js +3 -3
- package/dist/cjs/input/Field.js +1 -1
- package/dist/cjs/input/File.js +1 -1
- package/dist/cjs/input/Hidden.js +2 -11
- package/dist/cjs/input/Input.js +1 -1
- package/dist/cjs/input/Number.js +1 -1
- package/dist/cjs/input/Password.js +1 -1
- package/dist/cjs/input/Radio.js +1 -1
- package/dist/cjs/input/RadioGroup.js +7 -3
- package/dist/cjs/input/RangeSlider.js +1 -1
- package/dist/cjs/input/Search.js +1 -1
- package/dist/cjs/input/Slider.js +1 -1
- package/dist/cjs/input/Switch.js +4 -4
- package/dist/cjs/input/Textarea.js +1 -1
- package/dist/cjs/internal/InputWrapper.js +2 -2
- package/dist/cjs/ranger/index.js +5 -5
- package/dist/cjs/select/AutoComplete.js +4 -2
- package/dist/cjs/select/DualList.js +3 -3
- package/dist/cjs/select/List.js +7 -4
- package/dist/cjs/select/Options.js +5 -4
- package/dist/cjs/select/Select.js +5 -3
- package/dist/cjs/select/useSelect.js +15 -13
- package/dist/esm/builder/FileField.js +14 -11
- package/dist/esm/builder/SchemaEditor.js +1 -1
- package/dist/esm/builder/components/SchemaArrayForm.js +2 -4
- package/dist/esm/builder/components/SchemaField.js +3 -3
- package/dist/esm/form/Controller.js +1 -1
- package/dist/esm/form/Form.js +45 -43
- package/dist/esm/form/useForm.js +32 -0
- package/dist/esm/hooks/useFileUploader.js +45 -33
- package/dist/esm/hooks/useFormBuilder.js +3 -3
- package/dist/esm/i18n/index.js +2 -2
- package/dist/esm/index.js +2 -1
- package/dist/esm/input/ArrayInput.js +66 -19
- package/dist/esm/input/AvatarInput.js +21 -16
- package/dist/esm/input/Checkbox.js +1 -1
- package/dist/esm/input/ColorInput.js +27 -20
- package/dist/esm/input/ColorPicker.js +17 -10
- package/dist/esm/input/DateInput.js +3 -3
- package/dist/esm/input/Field.js +1 -1
- package/dist/esm/input/File.js +1 -1
- package/dist/esm/input/Hidden.js +3 -12
- package/dist/esm/input/Input.js +1 -1
- package/dist/esm/input/Number.js +1 -1
- package/dist/esm/input/Password.js +1 -1
- package/dist/esm/input/Radio.js +1 -1
- package/dist/esm/input/RadioGroup.js +7 -3
- package/dist/esm/input/RangeSlider.js +1 -1
- package/dist/esm/input/Search.js +1 -1
- package/dist/esm/input/Slider.js +1 -1
- package/dist/esm/input/Switch.js +4 -4
- package/dist/esm/input/Textarea.js +1 -1
- package/dist/esm/internal/InputWrapper.js +2 -2
- package/dist/esm/ranger/index.js +5 -5
- package/dist/esm/select/AutoComplete.js +4 -2
- package/dist/esm/select/DualList.js +3 -3
- package/dist/esm/select/List.js +8 -5
- package/dist/esm/select/Options.js +5 -4
- package/dist/esm/select/Select.js +6 -4
- package/dist/esm/select/useSelect.js +15 -13
- package/dist/types/builder/FileField.d.ts +2 -1
- package/dist/types/builder/SchemaEditor.d.ts +1 -1
- package/dist/types/form/Controller.d.ts +1 -1
- package/dist/types/form/Form.d.ts +7 -14
- package/dist/types/form/useForm.d.ts +11 -0
- package/dist/types/hooks/useFileUploader.d.ts +4 -2
- package/dist/types/index.d.ts +3 -2
- package/dist/types/input/ArrayInput.d.ts +5 -4
- package/dist/types/input/AvatarInput.d.ts +2 -2
- package/dist/types/input/Checkbox.d.ts +2 -2
- package/dist/types/input/ColorInput.d.ts +1 -1
- package/dist/types/input/ColorPicker.d.ts +5 -1
- package/dist/types/input/DateInput.d.ts +1 -1
- package/dist/types/input/Field.d.ts +1 -1
- package/dist/types/input/File.d.ts +1 -1
- package/dist/types/input/Hidden.d.ts +4 -12
- package/dist/types/input/Input.d.ts +1 -1
- package/dist/types/input/Number.d.ts +1 -1
- package/dist/types/input/Password.d.ts +1 -1
- package/dist/types/input/Radio.d.ts +2 -2
- package/dist/types/input/RadioGroup.d.ts +7 -3
- package/dist/types/input/RangeSlider.d.ts +1 -1
- package/dist/types/input/Search.d.ts +1 -1
- package/dist/types/input/Slider.d.ts +1 -1
- package/dist/types/input/Switch.d.ts +2 -2
- package/dist/types/input/Textarea.d.ts +1 -1
- package/dist/types/select/AutoComplete.d.ts +1 -1
- package/dist/types/select/DualList.d.ts +1 -1
- package/dist/types/select/List.d.ts +1 -1
- package/dist/types/select/Select.d.ts +1 -1
- package/dist/types/types/index.d.ts +3 -3
- package/dist/types/types/schema.d.ts +1 -1
- package/package.json +14 -14
- package/src/builder/FileField.tsx +5 -3
- package/src/builder/SchemaEditor.tsx +2 -2
- package/src/builder/components/SchemaArrayForm.tsx +1 -3
- package/src/builder/components/SchemaField.tsx +3 -3
- package/src/form/Controller.tsx +1 -1
- package/src/form/Form.tsx +21 -43
- package/src/form/useForm.ts +44 -0
- package/src/hooks/useFileUploader.ts +41 -29
- package/src/i18n/index.ts +2 -2
- package/src/index.ts +3 -7
- package/src/input/ArrayInput.tsx +20 -10
- package/src/input/AvatarInput.tsx +12 -12
- package/src/input/Checkbox.tsx +2 -2
- package/src/input/ColorInput.tsx +29 -45
- package/src/input/ColorPicker.tsx +42 -49
- package/src/input/DateInput.tsx +3 -3
- package/src/input/Field.tsx +2 -2
- package/src/input/File.tsx +1 -1
- package/src/input/Hidden.tsx +5 -25
- package/src/input/Input.tsx +1 -1
- package/src/input/Number.tsx +1 -1
- package/src/input/Password.tsx +1 -1
- package/src/input/Radio.tsx +2 -2
- package/src/input/RadioGroup.tsx +11 -3
- package/src/input/RangeSlider.tsx +1 -1
- package/src/input/Search.tsx +1 -1
- package/src/input/Slider.tsx +1 -1
- package/src/input/Switch.tsx +6 -6
- package/src/input/Textarea.tsx +1 -1
- package/src/internal/InputWrapper.tsx +1 -2
- package/src/select/AutoComplete.tsx +13 -52
- package/src/select/DualList.tsx +3 -3
- package/src/select/List.tsx +31 -69
- package/src/select/Options.tsx +4 -3
- package/src/select/Select.tsx +19 -41
- package/src/select/useSelect.tsx +24 -69
- package/src/types/index.ts +3 -3
- package/src/types/schema.ts +1 -1
- /package/dist/cjs/i18n/{ar.json.js → ar/form.json.js} +0 -0
- /package/dist/cjs/i18n/{en.json.js → en/form.json.js} +0 -0
- /package/dist/esm/i18n/{ar.json.js → ar/form.json.js} +0 -0
- /package/dist/esm/i18n/{en.json.js → en/form.json.js} +0 -0
- /package/src/i18n/{ar.json → ar/form.json} +0 -0
- /package/src/i18n/{en.json → en/form.json} +0 -0
package/src/input/DateInput.tsx
CHANGED
|
@@ -77,7 +77,7 @@ export interface DateProps
|
|
|
77
77
|
* The component supports both date and datetime types, with appropriate formatting.
|
|
78
78
|
*
|
|
79
79
|
* @param {DateProps} props - The properties for the DateInput component.
|
|
80
|
-
* @returns {
|
|
80
|
+
* @returns {React.ReactElement} - The rendered DateInput component.
|
|
81
81
|
*/
|
|
82
82
|
export const DateInput = ({
|
|
83
83
|
ref,
|
|
@@ -236,7 +236,7 @@ export const DateInput = ({
|
|
|
236
236
|
zIndex: "var(--z-popover)",
|
|
237
237
|
...floatingStyles,
|
|
238
238
|
}}
|
|
239
|
-
className="shadow-lg bg-
|
|
239
|
+
className="shadow-lg bg-default ring-1 ring-tint-100"
|
|
240
240
|
data-ref="dropdownBody"
|
|
241
241
|
{...getFloatingProps()}
|
|
242
242
|
>
|
|
@@ -251,7 +251,7 @@ export const DateInput = ({
|
|
|
251
251
|
ref={arrowRef}
|
|
252
252
|
context={context}
|
|
253
253
|
strokeWidth={0.5}
|
|
254
|
-
className="fill-
|
|
254
|
+
className="fill-default stroke-muted"
|
|
255
255
|
/>
|
|
256
256
|
</div>
|
|
257
257
|
)}
|
package/src/input/Field.tsx
CHANGED
|
@@ -38,7 +38,7 @@ export interface FieldProps extends ChildrenProp, CssProp {
|
|
|
38
38
|
/**
|
|
39
39
|
* append to label end
|
|
40
40
|
*/
|
|
41
|
-
appendLabel?:
|
|
41
|
+
appendLabel?: React.ReactElement | string | number | boolean;
|
|
42
42
|
/**
|
|
43
43
|
* info label at bottom
|
|
44
44
|
*/
|
|
@@ -90,7 +90,7 @@ export const Field = ({
|
|
|
90
90
|
className={classNames(
|
|
91
91
|
"fabric-fieldGroup",
|
|
92
92
|
!plain && !noOutline && "outline",
|
|
93
|
-
!plain && "bg-
|
|
93
|
+
!plain && "bg-default",
|
|
94
94
|
plain && "flex-wrap",
|
|
95
95
|
"flex-1 rounded",
|
|
96
96
|
!vertical && "flex",
|
package/src/input/File.tsx
CHANGED
|
@@ -82,7 +82,7 @@ const FileExists = (prop: AnyObject) => {
|
|
|
82
82
|
* It handles file changes, invalid states, and read-only or disabled states.
|
|
83
83
|
*
|
|
84
84
|
* @param {FileInputProps} props - The properties for the FileInput component.
|
|
85
|
-
* @returns {
|
|
85
|
+
* @returns {React.ReactElement} - The rendered FileInput component.
|
|
86
86
|
*/
|
|
87
87
|
export const FileInput = ({
|
|
88
88
|
ref,
|
package/src/input/Hidden.tsx
CHANGED
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
|
-
import { Fragment
|
|
24
|
+
import { Fragment } from "react";
|
|
25
25
|
import { ErrorIcon } from "../internal/ErrorIcon";
|
|
26
26
|
|
|
27
27
|
interface Props {
|
|
@@ -30,17 +30,9 @@ interface Props {
|
|
|
30
30
|
*/
|
|
31
31
|
name?: string;
|
|
32
32
|
/**
|
|
33
|
-
* hidden value
|
|
33
|
+
* hidden input value
|
|
34
34
|
*/
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* default avatar image
|
|
38
|
-
*/
|
|
39
|
-
defaultValue?: string;
|
|
40
|
-
/**
|
|
41
|
-
* form onChange handler
|
|
42
|
-
*/
|
|
43
|
-
onChange?: (value: AnyObject) => void;
|
|
35
|
+
value?: AnyObject;
|
|
44
36
|
}
|
|
45
37
|
|
|
46
38
|
/**
|
|
@@ -49,31 +41,19 @@ interface Props {
|
|
|
49
41
|
* This is useful for cases where you need to update the form state without user interaction.
|
|
50
42
|
*
|
|
51
43
|
* @param {Object} props - Component properties.
|
|
52
|
-
* @returns {
|
|
44
|
+
* @returns {React.ReactElement} The rendered hidden input field and error icon.
|
|
53
45
|
*/
|
|
54
46
|
export const HiddenInput = ({
|
|
55
|
-
hiddenValue,
|
|
56
|
-
defaultValue,
|
|
57
|
-
onChange,
|
|
58
47
|
// @ts-expect-error ignore
|
|
59
|
-
// eslint-disable-next-line react/prop-types
|
|
60
48
|
invalid,
|
|
61
49
|
// @ts-expect-error ignore
|
|
62
|
-
// eslint-disable-next-line react/prop-types
|
|
63
50
|
error,
|
|
64
|
-
// @ts-expect-error ignore
|
|
65
|
-
// eslint-disable-next-line react/prop-types
|
|
66
51
|
value = "",
|
|
67
52
|
name,
|
|
68
53
|
}: Props) => {
|
|
69
|
-
useEffect(() => {
|
|
70
|
-
setTimeout(() => {
|
|
71
|
-
onChange?.(hiddenValue ?? defaultValue);
|
|
72
|
-
}, 50);
|
|
73
|
-
}, [hiddenValue, defaultValue]);
|
|
74
54
|
return (
|
|
75
55
|
<Fragment>
|
|
76
|
-
<input type="hidden"
|
|
56
|
+
<input type="hidden" value={value} name={name} />
|
|
77
57
|
<ErrorIcon invalid={invalid} error={error} />
|
|
78
58
|
</Fragment>
|
|
79
59
|
);
|
package/src/input/Input.tsx
CHANGED
|
@@ -47,7 +47,7 @@ export interface TextInputProps extends InputProps, RefProp<HTMLInputElement> {
|
|
|
47
47
|
* The component uses a wrapper to handle the clear button and styling, and it supports deferred value updates to optimize performance.
|
|
48
48
|
*
|
|
49
49
|
* @param {TextInputProps} props - The properties for the text input component.
|
|
50
|
-
* @returns {
|
|
50
|
+
* @returns {React.ReactElement} - A JSX element representing the text input field.
|
|
51
51
|
*/
|
|
52
52
|
export const Input = ({
|
|
53
53
|
ref,
|
package/src/input/Number.tsx
CHANGED
|
@@ -56,7 +56,7 @@ export interface NumberProps
|
|
|
56
56
|
* It also includes a clear button to reset the input value.
|
|
57
57
|
*
|
|
58
58
|
* @param {NumberProps} props - The properties for the Number input component.
|
|
59
|
-
* @returns {
|
|
59
|
+
* @returns {React.ReactElement} The rendered Number input component.
|
|
60
60
|
*/
|
|
61
61
|
export const Number = ({
|
|
62
62
|
ref,
|
package/src/input/Password.tsx
CHANGED
|
@@ -51,7 +51,7 @@ export interface PasswordProps extends InputProps, RefProp<HTMLInputElement> {
|
|
|
51
51
|
* Password input component with optional strength meter and toggle visibility.
|
|
52
52
|
*
|
|
53
53
|
* @param {PasswordProps} props - The properties for the Password component.
|
|
54
|
-
* @returns {
|
|
54
|
+
* @returns {React.ReactElement} The rendered Password input component.
|
|
55
55
|
*/
|
|
56
56
|
export const Password = ({
|
|
57
57
|
ref,
|
package/src/input/Radio.tsx
CHANGED
|
@@ -31,7 +31,7 @@ export interface RadioProps extends RefProp<HTMLInputElement> {
|
|
|
31
31
|
/**
|
|
32
32
|
* radio label
|
|
33
33
|
*/
|
|
34
|
-
label?:
|
|
34
|
+
label?: React.ReactElement | string;
|
|
35
35
|
/**
|
|
36
36
|
* value
|
|
37
37
|
*/
|
|
@@ -76,7 +76,7 @@ export interface RadioProps extends RefProp<HTMLInputElement> {
|
|
|
76
76
|
* It supports disabled and invalid states, and allows for custom width.
|
|
77
77
|
*
|
|
78
78
|
* @param {RadioProps} props - The properties for the Radio component.
|
|
79
|
-
* @returns {
|
|
79
|
+
* @returns {React.ReactElement} The rendered Radio input component.
|
|
80
80
|
*/
|
|
81
81
|
export const Radio = ({
|
|
82
82
|
ref,
|
package/src/input/RadioGroup.tsx
CHANGED
|
@@ -26,6 +26,7 @@ import {
|
|
|
26
26
|
type ChildrenProp,
|
|
27
27
|
type CssProp,
|
|
28
28
|
} from "@react-fabric/core/dist/types/types";
|
|
29
|
+
import classNames from "classnames";
|
|
29
30
|
import { cloneElement } from "react";
|
|
30
31
|
import { FieldWrapper } from "../internal/FieldWrapper";
|
|
31
32
|
import { type Radio } from "./Radio";
|
|
@@ -38,7 +39,7 @@ export interface RadioGroupProps extends ChildrenProp<typeof Radio>, CssProp {
|
|
|
38
39
|
/**
|
|
39
40
|
* append to label end
|
|
40
41
|
*/
|
|
41
|
-
appendLabel?:
|
|
42
|
+
appendLabel?: React.ReactElement | string | number | boolean;
|
|
42
43
|
/**
|
|
43
44
|
* field info
|
|
44
45
|
*/
|
|
@@ -68,6 +69,10 @@ export interface RadioGroupProps extends ChildrenProp<typeof Radio>, CssProp {
|
|
|
68
69
|
* vertical orientation
|
|
69
70
|
*/
|
|
70
71
|
vertical?: boolean;
|
|
72
|
+
/**
|
|
73
|
+
* value
|
|
74
|
+
*/
|
|
75
|
+
value?: string | number;
|
|
71
76
|
/**
|
|
72
77
|
* change handler
|
|
73
78
|
*/
|
|
@@ -80,22 +85,25 @@ export interface RadioGroupProps extends ChildrenProp<typeof Radio>, CssProp {
|
|
|
80
85
|
* The component supports inline and vertical orientations, and can handle change events.
|
|
81
86
|
*
|
|
82
87
|
* @param {RadioGroupProps} props - The properties for the RadioGroup component.
|
|
83
|
-
* @returns {
|
|
88
|
+
* @returns {React.ReactElement} The rendered RadioGroup component.
|
|
84
89
|
*/
|
|
85
90
|
export const RadioGroup = ({
|
|
86
91
|
children,
|
|
87
92
|
name,
|
|
88
93
|
className,
|
|
89
94
|
optionWidth,
|
|
95
|
+
vertical,
|
|
96
|
+
value,
|
|
90
97
|
onChange,
|
|
91
98
|
...rest
|
|
92
99
|
}: RadioGroupProps) => {
|
|
93
100
|
return (
|
|
94
101
|
<FieldWrapper {...rest}>
|
|
95
|
-
<div className={className}>
|
|
102
|
+
<div className={classNames(className, vertical && "flex flex-col gap-1")}>
|
|
96
103
|
{cloneChildren(children, (child: AnyObject) =>
|
|
97
104
|
cloneElement(child, {
|
|
98
105
|
name,
|
|
106
|
+
checked: child.props.value === value,
|
|
99
107
|
onChange,
|
|
100
108
|
width: optionWidth,
|
|
101
109
|
}),
|
|
@@ -103,7 +103,7 @@ export interface RangeProps
|
|
|
103
103
|
* The component is designed to be flexible and customizable, allowing for various configurations.
|
|
104
104
|
*
|
|
105
105
|
* @param {RangeProps} props - The properties for the RangeSlider component.
|
|
106
|
-
* @returns {
|
|
106
|
+
* @returns {React.ReactElement} The rendered RangeSlider component.
|
|
107
107
|
*/
|
|
108
108
|
export const RangeSlider = ({
|
|
109
109
|
error,
|
package/src/input/Search.tsx
CHANGED
|
@@ -62,7 +62,7 @@ export interface SearchProps extends InputProps, RefProp<HTMLInputElement> {
|
|
|
62
62
|
* and handling search actions with a debounce mechanism.
|
|
63
63
|
*
|
|
64
64
|
* @param {SearchProps} props - The properties for the Search component.
|
|
65
|
-
* @returns {
|
|
65
|
+
* @returns {React.ReactElement} The rendered Search input component.
|
|
66
66
|
*/
|
|
67
67
|
export const Search = ({
|
|
68
68
|
ref,
|
package/src/input/Slider.tsx
CHANGED
|
@@ -105,7 +105,7 @@ export interface SliderProps
|
|
|
105
105
|
* It also supports deferred value updates for smoother interactions.
|
|
106
106
|
*
|
|
107
107
|
* @param {SliderProps} props - The properties for the Slider component.
|
|
108
|
-
* @returns {
|
|
108
|
+
* @returns {React.ReactElement} The rendered Slider component.
|
|
109
109
|
*/
|
|
110
110
|
export const Slider = ({
|
|
111
111
|
error,
|
package/src/input/Switch.tsx
CHANGED
|
@@ -41,7 +41,7 @@ export interface SwitchProps extends RefProp<HTMLInputElement> {
|
|
|
41
41
|
/**
|
|
42
42
|
* Switch label
|
|
43
43
|
*/
|
|
44
|
-
label?:
|
|
44
|
+
label?: React.ReactElement | string;
|
|
45
45
|
/**
|
|
46
46
|
* checked
|
|
47
47
|
*/
|
|
@@ -94,7 +94,7 @@ export interface SwitchProps extends RefProp<HTMLInputElement> {
|
|
|
94
94
|
* It supports disabled and invalid states, and handles change events.
|
|
95
95
|
*
|
|
96
96
|
* @param {SwitchProps} props - The properties for the Switch component.
|
|
97
|
-
* @returns {
|
|
97
|
+
* @returns {React.ReactElement} The rendered Switch input component.
|
|
98
98
|
*/
|
|
99
99
|
export const Switch = ({
|
|
100
100
|
ref,
|
|
@@ -137,8 +137,8 @@ export const Switch = ({
|
|
|
137
137
|
invalid ? "ring-danger-500" : "ring-primary-500",
|
|
138
138
|
disabled
|
|
139
139
|
? "opacity-50 cursor-not-allowed"
|
|
140
|
-
: "hover:opacity-100 cursor-pointer",
|
|
141
|
-
"inline-flex gap-1 py-1 items-center relative
|
|
140
|
+
: "opacity-85 hover:opacity-100 cursor-pointer",
|
|
141
|
+
"inline-flex gap-1 py-1 items-center relative rounded ring-offset-2 has-focus-visible:ring-1",
|
|
142
142
|
)}
|
|
143
143
|
style={{ width }}
|
|
144
144
|
>
|
|
@@ -147,7 +147,7 @@ export const Switch = ({
|
|
|
147
147
|
actualValue && getBgClass(color ? `${color}-500` : "primary-500"),
|
|
148
148
|
!actualValue &&
|
|
149
149
|
(defaultColor ? getBgClass(`${defaultColor}-500`) : "bg-tint-200"),
|
|
150
|
-
"relative grid grid-cols-2 items-center h-[1.5em] min-w-[2.5em]
|
|
150
|
+
"relative grid grid-cols-2 items-center h-[1.5em] min-w-[2.5em] rounded-full p-[0.25em] transition-colors duration-200 ease-in-out",
|
|
151
151
|
)}
|
|
152
152
|
style={{
|
|
153
153
|
backgroundColor: actualValue
|
|
@@ -157,7 +157,7 @@ export const Switch = ({
|
|
|
157
157
|
>
|
|
158
158
|
<input
|
|
159
159
|
className={classNames(
|
|
160
|
-
"appearance-none absolute opacity-0 inset-0 bg-transparent border-none outline-none ring-0",
|
|
160
|
+
"appearance-none absolute opacity-0 inset-0 bg-transparent border-none cursor-[inherit] outline-none ring-0",
|
|
161
161
|
)}
|
|
162
162
|
aria-invalid={invalid}
|
|
163
163
|
aria-disabled={disabled}
|
package/src/input/Textarea.tsx
CHANGED
|
@@ -63,7 +63,7 @@ export interface TextareaProps
|
|
|
63
63
|
* providing a clear interface for text input with optional validation and accessibility features.
|
|
64
64
|
*
|
|
65
65
|
* @param {TextareaProps} props - The properties for the Textarea component.
|
|
66
|
-
* @returns {
|
|
66
|
+
* @returns {React.ReactElement} The rendered Textarea component.
|
|
67
67
|
*/
|
|
68
68
|
export const Textarea = ({
|
|
69
69
|
ref,
|
|
@@ -152,7 +152,6 @@ export const InputWrapper = ({
|
|
|
152
152
|
className={classNames(
|
|
153
153
|
"text-tint-500 hover:text-tint-700 p-1 z-1 flex-content",
|
|
154
154
|
"fabric-inputClear",
|
|
155
|
-
textarea && "self-start mt-1 me-1",
|
|
156
155
|
)}
|
|
157
156
|
/>
|
|
158
157
|
)}
|
|
@@ -190,7 +189,7 @@ export const InputWrapper = ({
|
|
|
190
189
|
? "icon-[mdi--arrow-collapse]"
|
|
191
190
|
: "icon-[mdi--arrow-expand]"
|
|
192
191
|
}
|
|
193
|
-
className="hidden group-hover:block absolute top-0
|
|
192
|
+
className="hidden group-hover:block absolute top-0 inset-e-0 bg-default hover:bg-tint-200 p-1 opacity-65 rounded-capped"
|
|
194
193
|
/>
|
|
195
194
|
)}
|
|
196
195
|
</div>
|
|
@@ -43,10 +43,7 @@ import { type SelectProps } from "../types";
|
|
|
43
43
|
import { Options } from "./Options";
|
|
44
44
|
import { useSelect } from "./useSelect";
|
|
45
45
|
|
|
46
|
-
type AutoCompleteProps = Omit<
|
|
47
|
-
SelectProps<string>,
|
|
48
|
-
"options" | "allowCreate" | "createOption"
|
|
49
|
-
> & {
|
|
46
|
+
type AutoCompleteProps = Omit<SelectProps<string>, "options" | "allowCreate" | "createOption"> & {
|
|
50
47
|
/**
|
|
51
48
|
* auto-complete history
|
|
52
49
|
*/
|
|
@@ -66,7 +63,7 @@ type AutoCompleteProps = Omit<
|
|
|
66
63
|
* It supports multiple selections, history suggestions, and custom styling.
|
|
67
64
|
*
|
|
68
65
|
* @param {AutoCompleteProps} props - The properties for the AutoComplete component.
|
|
69
|
-
* @returns {
|
|
66
|
+
* @returns {React.ReactElement} The rendered AutoComplete component.
|
|
70
67
|
*/
|
|
71
68
|
export const AutoComplete = ({
|
|
72
69
|
ref,
|
|
@@ -156,9 +153,7 @@ export const AutoComplete = ({
|
|
|
156
153
|
},
|
|
157
154
|
});
|
|
158
155
|
|
|
159
|
-
const { getReferenceProps, getFloatingProps, getItemProps } = useInteractions(
|
|
160
|
-
[dismiss, navigation, typeahead],
|
|
161
|
-
);
|
|
156
|
+
const { getReferenceProps, getFloatingProps, getItemProps } = useInteractions([dismiss, navigation, typeahead]);
|
|
162
157
|
|
|
163
158
|
const referenceProps = useMemo(() => {
|
|
164
159
|
const props: AnyObject = getReferenceProps();
|
|
@@ -167,9 +162,7 @@ export const AutoComplete = ({
|
|
|
167
162
|
...props,
|
|
168
163
|
onFocus,
|
|
169
164
|
onBlur(evt: React.FocusEvent) {
|
|
170
|
-
if (
|
|
171
|
-
evt.relatedTarget?.closest(`[data-select-dropdown="${dropdownKey}"]`)
|
|
172
|
-
) {
|
|
165
|
+
if (evt.relatedTarget?.closest(`[data-select-dropdown="${dropdownKey}"]`)) {
|
|
173
166
|
refs.domReference.current?.querySelector("input")?.focus();
|
|
174
167
|
return;
|
|
175
168
|
}
|
|
@@ -195,10 +188,7 @@ export const AutoComplete = ({
|
|
|
195
188
|
} else if (evt.key === "Backspace") {
|
|
196
189
|
!state.query && multiple && handleRemove();
|
|
197
190
|
} else if (["ArrowUp", "ArrowDown"].includes(evt.key)) {
|
|
198
|
-
if (
|
|
199
|
-
["ArrowUp", "ArrowDown"].includes(evt.key) &&
|
|
200
|
-
state.activeIndex === null
|
|
201
|
-
) {
|
|
191
|
+
if (["ArrowUp", "ArrowDown"].includes(evt.key) && state.activeIndex === null) {
|
|
202
192
|
setActiveIndex(state.selectedIndex);
|
|
203
193
|
}
|
|
204
194
|
setTimeout(() => {
|
|
@@ -207,17 +197,7 @@ export const AutoComplete = ({
|
|
|
207
197
|
}
|
|
208
198
|
},
|
|
209
199
|
};
|
|
210
|
-
}, [
|
|
211
|
-
getReferenceProps,
|
|
212
|
-
onEnterPressed,
|
|
213
|
-
handleQuery,
|
|
214
|
-
onFocus,
|
|
215
|
-
onBlur,
|
|
216
|
-
multiple,
|
|
217
|
-
refs,
|
|
218
|
-
state.query,
|
|
219
|
-
state.activeIndex,
|
|
220
|
-
]);
|
|
200
|
+
}, [getReferenceProps, onEnterPressed, handleQuery, onFocus, onBlur, multiple, refs, state.query, state.activeIndex]);
|
|
221
201
|
|
|
222
202
|
const floatingProps = useMemo(() => {
|
|
223
203
|
return getFloatingProps({
|
|
@@ -227,9 +207,7 @@ export const AutoComplete = ({
|
|
|
227
207
|
|
|
228
208
|
const makeItemProps = useCallback(
|
|
229
209
|
(item: AnyObject) => {
|
|
230
|
-
const selected = isArray(state.value)
|
|
231
|
-
? state.value?.includes?.(item)
|
|
232
|
-
: state.value === item;
|
|
210
|
+
const selected = isArray(state.value) ? state.value?.includes?.(item) : state.value === item;
|
|
233
211
|
return getItemProps({
|
|
234
212
|
"data-selected": selected ? true : undefined,
|
|
235
213
|
onClick() {
|
|
@@ -287,9 +265,7 @@ export const AutoComplete = ({
|
|
|
287
265
|
"group flex-1 py-1 px-2 truncate text-start flex gap-1 relative min-h-5 justify-start",
|
|
288
266
|
multiple ? "flex-wrap" : "flex-nowrap overflow-hidden",
|
|
289
267
|
)}
|
|
290
|
-
onMouseUp={(e) =>
|
|
291
|
-
e.currentTarget.querySelector<HTMLElement>("input")?.focus()
|
|
292
|
-
}
|
|
268
|
+
onMouseUp={(e) => e.currentTarget.querySelector<HTMLElement>("input")?.focus()}
|
|
293
269
|
>
|
|
294
270
|
{displayValue}
|
|
295
271
|
<textarea
|
|
@@ -314,28 +290,17 @@ export const AutoComplete = ({
|
|
|
314
290
|
{...referenceProps}
|
|
315
291
|
onChange={(evt) => handleQuery(evt.target.value)}
|
|
316
292
|
/>
|
|
317
|
-
<button
|
|
318
|
-
type="submit"
|
|
319
|
-
ref={submitRef}
|
|
320
|
-
tabIndex={-1}
|
|
321
|
-
className="opacity-0 absolute"
|
|
322
|
-
/>
|
|
293
|
+
<button type="submit" ref={submitRef} tabIndex={-1} className="opacity-0 absolute" />
|
|
323
294
|
</div>
|
|
324
295
|
{state.loading && (
|
|
325
296
|
<Icon
|
|
326
|
-
className={classNames(
|
|
327
|
-
"flex-content p-2 z-0 order-9 text-muted pointer-events-none",
|
|
328
|
-
)}
|
|
297
|
+
className={classNames("flex-content p-2 z-0 order-9 text-muted pointer-events-none")}
|
|
329
298
|
icon="icon-[svg-spinners--eclipse]"
|
|
330
299
|
/>
|
|
331
300
|
)}
|
|
332
301
|
{state.open && !state.loading && (
|
|
333
|
-
<FloatingPortal>
|
|
334
|
-
<FloatingFocusManager
|
|
335
|
-
context={context}
|
|
336
|
-
initialFocus={-1}
|
|
337
|
-
visuallyHiddenDismiss
|
|
338
|
-
>
|
|
302
|
+
<FloatingPortal root={refs.domReference.current?.closest<HTMLElement>(".theme-base") ?? undefined}>
|
|
303
|
+
<FloatingFocusManager context={context} initialFocus={-1} visuallyHiddenDismiss closeOnFocusOut>
|
|
339
304
|
<Options
|
|
340
305
|
ref={refs.setFloating}
|
|
341
306
|
className="outline shadow-lg max-h-[40vh] z-(--z-popover)"
|
|
@@ -348,11 +313,7 @@ export const AutoComplete = ({
|
|
|
348
313
|
active={state.activeIndex}
|
|
349
314
|
itemRef={setItemRef}
|
|
350
315
|
itemProps={makeItemProps}
|
|
351
|
-
empty={
|
|
352
|
-
<div className="text-muted text-sm px-2 py-1">
|
|
353
|
-
No history available
|
|
354
|
-
</div>
|
|
355
|
-
}
|
|
316
|
+
empty={<div className="text-muted text-sm px-2 py-1">No history available</div>}
|
|
356
317
|
>
|
|
357
318
|
{(item) => item}
|
|
358
319
|
</Options>
|
package/src/select/DualList.tsx
CHANGED
|
@@ -95,7 +95,7 @@ export interface DualListProps<T>
|
|
|
95
95
|
* This component is useful for scenarios where users need to manage selections from a larger set of options, such as in forms or settings.
|
|
96
96
|
*
|
|
97
97
|
* @param {DualListProps<T>} props - The properties for the DualList component.
|
|
98
|
-
* @returns {
|
|
98
|
+
* @returns {React.ReactElement} The rendered DualList component.
|
|
99
99
|
*/
|
|
100
100
|
export const DualList = <T extends AnyObject = string>({
|
|
101
101
|
ref,
|
|
@@ -105,7 +105,7 @@ export const DualList = <T extends AnyObject = string>({
|
|
|
105
105
|
groupProperty,
|
|
106
106
|
height = "18rem",
|
|
107
107
|
labelProperty = "label" as AnyObject,
|
|
108
|
-
valueProperty = "
|
|
108
|
+
valueProperty = "value" as AnyObject,
|
|
109
109
|
renderer,
|
|
110
110
|
onChange,
|
|
111
111
|
// @ts-expect-error ignore
|
|
@@ -241,7 +241,7 @@ export const DualList = <T extends AnyObject = string>({
|
|
|
241
241
|
/>
|
|
242
242
|
</div>
|
|
243
243
|
<div className="self-center mx-2">
|
|
244
|
-
<ButtonGroup vertical className="outline overflow-hidden bg-
|
|
244
|
+
<ButtonGroup vertical className="outline overflow-hidden bg-default">
|
|
245
245
|
<Button
|
|
246
246
|
size="sm"
|
|
247
247
|
variant="link"
|