@react-fabric/form 1.0.0-beta.62 → 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 +6 -6
- package/dist/cjs/builder/SchemaEditor.js +1 -1
- package/dist/cjs/builder/components/SchemaArrayForm.js +1 -3
- package/dist/cjs/builder/components/SchemaField.js +1 -1
- package/dist/cjs/form/Controller.js +1 -1
- package/dist/cjs/form/Form.js +11 -35
- package/dist/cjs/form/useForm.js +32 -0
- package/dist/cjs/hooks/useFileUploader.js +5 -5
- package/dist/cjs/hooks/useFormBuilder.js +3 -3
- package/dist/cjs/index.js +2 -1
- package/dist/cjs/input/ArrayInput.js +66 -19
- package/dist/cjs/input/AvatarInput.js +7 -7
- 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 +1 -1
- 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 +5 -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 +2 -2
- package/dist/cjs/select/List.js +3 -2
- package/dist/cjs/select/Options.js +5 -4
- package/dist/cjs/select/Select.js +4 -2
- package/dist/cjs/select/useSelect.js +15 -13
- package/dist/esm/builder/FileField.js +6 -6
- package/dist/esm/builder/SchemaEditor.js +1 -1
- package/dist/esm/builder/components/SchemaArrayForm.js +1 -3
- package/dist/esm/builder/components/SchemaField.js +1 -1
- package/dist/esm/form/Controller.js +1 -1
- package/dist/esm/form/Form.js +14 -37
- package/dist/esm/form/useForm.js +32 -0
- package/dist/esm/hooks/useFileUploader.js +5 -5
- package/dist/esm/hooks/useFormBuilder.js +3 -3
- package/dist/esm/index.js +2 -1
- package/dist/esm/input/ArrayInput.js +66 -19
- package/dist/esm/input/AvatarInput.js +7 -7
- 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 +1 -1
- 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 +5 -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 +2 -2
- package/dist/esm/select/List.js +4 -3
- package/dist/esm/select/Options.js +5 -4
- package/dist/esm/select/Select.js +5 -3
- package/dist/esm/select/useSelect.js +15 -13
- 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 +1 -12
- package/dist/types/form/useForm.d.ts +11 -0
- package/dist/types/index.d.ts +3 -2
- package/dist/types/input/ArrayInput.d.ts +5 -4
- package/dist/types/input/AvatarInput.d.ts +1 -1
- 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 +1 -1
- 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 +3 -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/SchemaEditor.tsx +2 -2
- package/src/builder/components/SchemaArrayForm.tsx +0 -2
- package/src/builder/components/SchemaField.tsx +1 -1
- package/src/form/Controller.tsx +1 -1
- package/src/form/Form.tsx +1 -30
- package/src/form/useForm.ts +44 -0
- package/src/index.ts +3 -7
- package/src/input/ArrayInput.tsx +20 -10
- package/src/input/AvatarInput.tsx +1 -1
- 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 +1 -3
- 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 +5 -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 +2 -2
- package/src/select/List.tsx +29 -67
- package/src/select/Options.tsx +4 -3
- package/src/select/Select.tsx +18 -40
- package/src/select/useSelect.tsx +24 -69
- package/src/types/index.ts +3 -3
- package/src/types/schema.ts +1 -1
|
@@ -21,17 +21,9 @@
|
|
|
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
|
|
25
|
-
import {
|
|
26
|
-
|
|
27
|
-
startTransition,
|
|
28
|
-
useCallback,
|
|
29
|
-
useDeferredValue,
|
|
30
|
-
useEffect,
|
|
31
|
-
useState,
|
|
32
|
-
type FC,
|
|
33
|
-
} from "react";
|
|
34
|
-
import { SketchPicker } from "react-color";
|
|
24
|
+
import chroma from "chroma-js";
|
|
25
|
+
import { memo, startTransition, useCallback, useDeferredValue, useEffect, useState, type FC } from "react";
|
|
26
|
+
import { BlockPicker, SketchPicker } from "react-color";
|
|
35
27
|
|
|
36
28
|
export interface ColorProps {
|
|
37
29
|
/**
|
|
@@ -46,6 +38,10 @@ export interface ColorProps {
|
|
|
46
38
|
* hide alpha value
|
|
47
39
|
*/
|
|
48
40
|
hideAlpha?: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* show only swatches, hide the color picker
|
|
43
|
+
*/
|
|
44
|
+
picker?: "default" | "swatches";
|
|
49
45
|
/**
|
|
50
46
|
* color value
|
|
51
47
|
*/
|
|
@@ -57,16 +53,16 @@ export interface ColorProps {
|
|
|
57
53
|
}
|
|
58
54
|
|
|
59
55
|
const DEFAULT_SWATCHES = [
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
56
|
+
chroma.mix("#d7323a", "#171a1c", 0.5, "lab").hex(),
|
|
57
|
+
chroma.mix("#ff781c", "#171a1c", 0.5, "lab").hex(),
|
|
58
|
+
chroma.mix("#f7b731", "#171a1c", 0.5, "lab").hex(),
|
|
59
|
+
chroma.mix("#88ab1b", "#171a1c", 0.5, "lab").hex(),
|
|
60
|
+
chroma.mix("#22aa85", "#171a1c", 0.5, "lab").hex(),
|
|
61
|
+
chroma.mix("#399bec", "#171a1c", 0.5, "lab").hex(),
|
|
62
|
+
chroma.mix("#4862c8", "#171a1c", 0.5, "lab").hex(),
|
|
63
|
+
chroma.mix("#aa66cf", "#171a1c", 0.5, "lab").hex(),
|
|
64
|
+
chroma.mix("#f43f7b", "#171a1c", 0.5, "lab").hex(),
|
|
65
|
+
chroma.mix("#a37f4f", "#171a1c", 0.5, "lab").hex(),
|
|
70
66
|
|
|
71
67
|
"#d7323a",
|
|
72
68
|
"#ff781c",
|
|
@@ -79,16 +75,16 @@ const DEFAULT_SWATCHES = [
|
|
|
79
75
|
"#f43f7b",
|
|
80
76
|
"#a37f4f",
|
|
81
77
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
78
|
+
chroma.mix("#d7323a", "#f1f3f4", 0.5, "lab").hex(),
|
|
79
|
+
chroma.mix("#ff781c", "#f1f3f4", 0.5, "lab").hex(),
|
|
80
|
+
chroma.mix("#f7b731", "#f1f3f4", 0.5, "lab").hex(),
|
|
81
|
+
chroma.mix("#88ab1b", "#f1f3f4", 0.5, "lab").hex(),
|
|
82
|
+
chroma.mix("#22aa85", "#f1f3f4", 0.5, "lab").hex(),
|
|
83
|
+
chroma.mix("#399bec", "#f1f3f4", 0.5, "lab").hex(),
|
|
84
|
+
chroma.mix("#4862c8", "#f1f3f4", 0.5, "lab").hex(),
|
|
85
|
+
chroma.mix("#aa66cf", "#f1f3f4", 0.5, "lab").hex(),
|
|
86
|
+
chroma.mix("#f43f7b", "#f1f3f4", 0.5, "lab").hex(),
|
|
87
|
+
chroma.mix("#a37f4f", "#f1f3f4", 0.5, "lab").hex(),
|
|
92
88
|
|
|
93
89
|
"#171a1c",
|
|
94
90
|
"#2d3439",
|
|
@@ -108,19 +104,12 @@ const DEFAULT_SWATCHES = [
|
|
|
108
104
|
* The component uses the `react-color` library for the color picker functionality.
|
|
109
105
|
*
|
|
110
106
|
* @param {ColorProps} props - The properties for the ColorPicker component.
|
|
111
|
-
* @returns {
|
|
107
|
+
* @returns {React.ReactElement} The rendered ColorPicker component.
|
|
112
108
|
*
|
|
113
109
|
* @see {@link https://react-color.github.io/react-color/} for more details on the color picker library.
|
|
114
110
|
*/
|
|
115
|
-
// eslint-disable-next-line react/display-name
|
|
116
111
|
export const ColorPicker: FC<ColorProps> = memo(
|
|
117
|
-
({
|
|
118
|
-
value,
|
|
119
|
-
onChange,
|
|
120
|
-
hideAlpha,
|
|
121
|
-
defaultColor = "#fff",
|
|
122
|
-
swatches = DEFAULT_SWATCHES,
|
|
123
|
-
}: ColorProps) => {
|
|
112
|
+
({ value, onChange, hideAlpha, defaultColor = "#fff", swatches = DEFAULT_SWATCHES, picker = "default" }: ColorProps) => {
|
|
124
113
|
const [actualValue, setActualValue] = useState("");
|
|
125
114
|
const deferred = useDeferredValue(value ?? defaultColor);
|
|
126
115
|
|
|
@@ -136,13 +125,21 @@ export const ColorPicker: FC<ColorProps> = memo(
|
|
|
136
125
|
[onChange],
|
|
137
126
|
);
|
|
138
127
|
|
|
128
|
+
const E = (picker === "swatches" ? BlockPicker : SketchPicker) as unknown as FC<any>;
|
|
129
|
+
|
|
139
130
|
return (
|
|
140
131
|
<div
|
|
141
132
|
role="none"
|
|
133
|
+
className="fabric-colorPicker-container"
|
|
142
134
|
// prevent default on mouse down to avoid selection issues
|
|
143
135
|
onMouseDown={(e) => e.preventDefault()}
|
|
136
|
+
style={
|
|
137
|
+
{
|
|
138
|
+
"--color-selected": value,
|
|
139
|
+
} as any
|
|
140
|
+
}
|
|
144
141
|
>
|
|
145
|
-
<
|
|
142
|
+
<E
|
|
146
143
|
width="16rem"
|
|
147
144
|
className={"fabric-colorPicker"}
|
|
148
145
|
styles={
|
|
@@ -166,8 +163,7 @@ export const ColorPicker: FC<ColorProps> = memo(
|
|
|
166
163
|
},
|
|
167
164
|
picker: {
|
|
168
165
|
backgroundColor: "var(--fabric-bg)",
|
|
169
|
-
boxShadow:
|
|
170
|
-
"0 0 0 1px var(--color-shadow), 0 0 8px var(--fabric-shadow)",
|
|
166
|
+
boxShadow: "0 0 0 1px var(--color-shadow), 0 0 8px var(--fabric-shadow)",
|
|
171
167
|
},
|
|
172
168
|
checkboard: {
|
|
173
169
|
white: "transparent",
|
|
@@ -177,14 +173,11 @@ export const ColorPicker: FC<ColorProps> = memo(
|
|
|
177
173
|
} as AnyObject
|
|
178
174
|
}
|
|
179
175
|
color={actualValue}
|
|
176
|
+
colors={swatches}
|
|
180
177
|
presetColors={swatches}
|
|
181
178
|
disableAlpha={hideAlpha}
|
|
182
|
-
onChange={({ rgb: { a = 1, ...rgb } }) =>
|
|
183
|
-
|
|
184
|
-
}
|
|
185
|
-
onChangeComplete={({ rgb: { a = 1, ...rgb } }) =>
|
|
186
|
-
handleChange(Color(rgb).alpha(a)[a < 1 ? "hexa" : "hex"]())
|
|
187
|
-
}
|
|
179
|
+
onChange={({ rgb: { a = 1, ...rgb } }) => setActualValue(chroma(rgb).alpha(a).hex())}
|
|
180
|
+
onChangeComplete={({ rgb: { a = 1, ...rgb } }) => handleChange(chroma(rgb).alpha(a).hex())}
|
|
188
181
|
/>
|
|
189
182
|
</div>
|
|
190
183
|
);
|
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
|
@@ -41,14 +41,12 @@ interface Props {
|
|
|
41
41
|
* This is useful for cases where you need to update the form state without user interaction.
|
|
42
42
|
*
|
|
43
43
|
* @param {Object} props - Component properties.
|
|
44
|
-
* @returns {
|
|
44
|
+
* @returns {React.ReactElement} The rendered hidden input field and error icon.
|
|
45
45
|
*/
|
|
46
46
|
export const HiddenInput = ({
|
|
47
47
|
// @ts-expect-error ignore
|
|
48
|
-
// eslint-disable-next-line react/prop-types
|
|
49
48
|
invalid,
|
|
50
49
|
// @ts-expect-error ignore
|
|
51
|
-
// eslint-disable-next-line react/prop-types
|
|
52
50
|
error,
|
|
53
51
|
value = "",
|
|
54
52
|
name,
|
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
|
*/
|
|
@@ -84,20 +85,21 @@ export interface RadioGroupProps extends ChildrenProp<typeof Radio>, CssProp {
|
|
|
84
85
|
* The component supports inline and vertical orientations, and can handle change events.
|
|
85
86
|
*
|
|
86
87
|
* @param {RadioGroupProps} props - The properties for the RadioGroup component.
|
|
87
|
-
* @returns {
|
|
88
|
+
* @returns {React.ReactElement} The rendered RadioGroup component.
|
|
88
89
|
*/
|
|
89
90
|
export const RadioGroup = ({
|
|
90
91
|
children,
|
|
91
92
|
name,
|
|
92
93
|
className,
|
|
93
94
|
optionWidth,
|
|
95
|
+
vertical,
|
|
94
96
|
value,
|
|
95
97
|
onChange,
|
|
96
98
|
...rest
|
|
97
99
|
}: RadioGroupProps) => {
|
|
98
100
|
return (
|
|
99
101
|
<FieldWrapper {...rest}>
|
|
100
|
-
<div className={className}>
|
|
102
|
+
<div className={classNames(className, vertical && "flex flex-col gap-1")}>
|
|
101
103
|
{cloneChildren(children, (child: AnyObject) =>
|
|
102
104
|
cloneElement(child, {
|
|
103
105
|
name,
|
|
@@ -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,
|
|
@@ -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"
|