@yamada-ui/checkbox 1.1.10-dev-20241005220629 → 1.1.10-dev-20241006000212
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/checkbox-context.d.mts +2 -2
- package/dist/checkbox-context.d.ts +2 -2
- package/dist/checkbox-context.js +2 -2
- package/dist/checkbox-context.js.map +1 -1
- package/dist/checkbox-context.mjs +1 -1
- package/dist/checkbox-group.d.mts +20 -20
- package/dist/checkbox-group.d.ts +20 -20
- package/dist/checkbox-group.js +104 -104
- package/dist/checkbox-group.js.map +1 -1
- package/dist/checkbox-group.mjs +3 -3
- package/dist/checkbox.d.mts +40 -40
- package/dist/checkbox.d.ts +40 -40
- package/dist/checkbox.js +85 -85
- package/dist/checkbox.js.map +1 -1
- package/dist/checkbox.mjs +2 -2
- package/dist/{chunk-W56OJMPU.mjs → chunk-4ELRAD27.mjs} +97 -97
- package/dist/chunk-4ELRAD27.mjs.map +1 -0
- package/dist/{chunk-IZINMNYX.mjs → chunk-HJSSXHRX.mjs} +3 -3
- package/dist/chunk-HJSSXHRX.mjs.map +1 -0
- package/dist/{chunk-RPX4B2TW.mjs → chunk-JVJ55H5Q.mjs} +24 -24
- package/dist/chunk-JVJ55H5Q.mjs.map +1 -0
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +104 -104
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +3 -3
- package/package.json +8 -8
- package/dist/chunk-IZINMNYX.mjs.map +0 -1
- package/dist/chunk-RPX4B2TW.mjs.map +0 -1
- package/dist/chunk-W56OJMPU.mjs.map +0 -1
|
@@ -4,8 +4,8 @@ import { ThemeProps } from '@yamada-ui/core';
|
|
|
4
4
|
import { FormControlOptions } from '@yamada-ui/form-control';
|
|
5
5
|
|
|
6
6
|
interface CheckboxGroupContext extends ThemeProps<"Checkbox">, FormControlOptions {
|
|
7
|
-
value: (
|
|
8
|
-
onChange: (evOrValue: ChangeEvent<HTMLInputElement> |
|
|
7
|
+
value: (number | string)[];
|
|
8
|
+
onChange: (evOrValue: ChangeEvent<HTMLInputElement> | number | string) => void;
|
|
9
9
|
}
|
|
10
10
|
declare const CheckboxGroupProvider: react.Provider<CheckboxGroupContext | undefined>;
|
|
11
11
|
declare const useCheckboxGroupContext: () => CheckboxGroupContext | undefined;
|
|
@@ -4,8 +4,8 @@ import { ThemeProps } from '@yamada-ui/core';
|
|
|
4
4
|
import { FormControlOptions } from '@yamada-ui/form-control';
|
|
5
5
|
|
|
6
6
|
interface CheckboxGroupContext extends ThemeProps<"Checkbox">, FormControlOptions {
|
|
7
|
-
value: (
|
|
8
|
-
onChange: (evOrValue: ChangeEvent<HTMLInputElement> |
|
|
7
|
+
value: (number | string)[];
|
|
8
|
+
onChange: (evOrValue: ChangeEvent<HTMLInputElement> | number | string) => void;
|
|
9
9
|
}
|
|
10
10
|
declare const CheckboxGroupProvider: react.Provider<CheckboxGroupContext | undefined>;
|
|
11
11
|
declare const useCheckboxGroupContext: () => CheckboxGroupContext | undefined;
|
package/dist/checkbox-context.js
CHANGED
|
@@ -27,8 +27,8 @@ __export(checkbox_context_exports, {
|
|
|
27
27
|
module.exports = __toCommonJS(checkbox_context_exports);
|
|
28
28
|
var import_utils = require("@yamada-ui/utils");
|
|
29
29
|
var [CheckboxGroupProvider, useCheckboxGroupContext] = (0, import_utils.createContext)({
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
name: "CheckboxGroupContext",
|
|
31
|
+
strict: false
|
|
32
32
|
});
|
|
33
33
|
// Annotate the CommonJS export names for ESM import in node:
|
|
34
34
|
0 && (module.exports = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/checkbox-context.tsx"],"sourcesContent":["import type { ThemeProps } from \"@yamada-ui/core\"\nimport type { FormControlOptions } from \"@yamada-ui/form-control\"\nimport {
|
|
1
|
+
{"version":3,"sources":["../src/checkbox-context.tsx"],"sourcesContent":["import type { ThemeProps } from \"@yamada-ui/core\"\nimport type { FormControlOptions } from \"@yamada-ui/form-control\"\nimport type { ChangeEvent } from \"react\"\nimport { createContext } from \"@yamada-ui/utils\"\n\nexport interface CheckboxGroupContext\n extends ThemeProps<\"Checkbox\">,\n FormControlOptions {\n value: (number | string)[]\n onChange: (evOrValue: ChangeEvent<HTMLInputElement> | number | string) => void\n}\n\nexport const [CheckboxGroupProvider, useCheckboxGroupContext] = createContext<\n CheckboxGroupContext | undefined\n>({\n name: \"CheckboxGroupContext\",\n strict: false,\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,mBAA8B;AASvB,IAAM,CAAC,uBAAuB,uBAAuB,QAAI,4BAE9D;AAAA,EACA,MAAM;AAAA,EACN,QAAQ;AACV,CAAC;","names":[]}
|
|
@@ -1,28 +1,20 @@
|
|
|
1
1
|
import { CheckboxProps } from './checkbox.mjs';
|
|
2
2
|
import * as react from 'react';
|
|
3
|
-
import { ChangeEvent, RefAttributes } from 'react';
|
|
3
|
+
import { ChangeEvent, RefAttributes, ReactElement } from 'react';
|
|
4
4
|
import { PropGetter, ThemeProps, ComponentArgs } from '@yamada-ui/core';
|
|
5
5
|
import { FormControlOptions } from '@yamada-ui/form-control';
|
|
6
6
|
import { FlexProps } from '@yamada-ui/layouts';
|
|
7
7
|
import { Dict } from '@yamada-ui/utils';
|
|
8
8
|
import '@yamada-ui/motion';
|
|
9
9
|
|
|
10
|
-
interface CheckboxItem<Y extends
|
|
10
|
+
interface CheckboxItem<Y extends number | string = string> extends CheckboxProps<Y> {
|
|
11
11
|
label?: string;
|
|
12
12
|
}
|
|
13
|
-
interface UseCheckboxGroupProps<Y extends
|
|
14
|
-
/**
|
|
15
|
-
* The value of the checkbox group.
|
|
16
|
-
*/
|
|
17
|
-
value?: Y[];
|
|
13
|
+
interface UseCheckboxGroupProps<Y extends number | string = string> {
|
|
18
14
|
/**
|
|
19
15
|
* The initial value of the checkbox group.
|
|
20
16
|
*/
|
|
21
17
|
defaultValue?: Y[];
|
|
22
|
-
/**
|
|
23
|
-
* The callback fired when any children checkbox is checked or unchecked.
|
|
24
|
-
*/
|
|
25
|
-
onChange?: (value: Y[]) => void;
|
|
26
18
|
/**
|
|
27
19
|
* If `true`, input elements will receive `checked` attribute instead of `isChecked`.
|
|
28
20
|
*
|
|
@@ -31,23 +23,31 @@ interface UseCheckboxGroupProps<Y extends string | number = string> {
|
|
|
31
23
|
* @default false
|
|
32
24
|
*/
|
|
33
25
|
isNative?: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* The value of the checkbox group.
|
|
28
|
+
*/
|
|
29
|
+
value?: Y[];
|
|
30
|
+
/**
|
|
31
|
+
* The callback fired when any children checkbox is checked or unchecked.
|
|
32
|
+
*/
|
|
33
|
+
onChange?: (value: Y[]) => void;
|
|
34
34
|
}
|
|
35
|
-
declare const useCheckboxGroup: <Y extends
|
|
36
|
-
props: Omit<UseCheckboxGroupProps<Y
|
|
37
|
-
value: Y[];
|
|
35
|
+
declare const useCheckboxGroup: <Y extends number | string, M extends Dict = Dict<any>>({ defaultValue, isNative, value: valueProp, onChange: onChangeProp, ...props }: M & UseCheckboxGroupProps<Y>) => {
|
|
36
|
+
props: Omit<M & UseCheckboxGroupProps<Y>, "defaultValue" | "onChange" | "value" | "isNative">;
|
|
38
37
|
setValue: react.Dispatch<react.SetStateAction<Y[]>>;
|
|
39
|
-
|
|
40
|
-
getContainerProps: PropGetter<"div", undefined>;
|
|
38
|
+
value: Y[];
|
|
41
39
|
getCheckboxProps: PropGetter<{
|
|
42
40
|
value?: Y;
|
|
43
41
|
}, {
|
|
44
|
-
value?: Y;
|
|
45
42
|
checked?: boolean;
|
|
46
43
|
isChecked?: boolean;
|
|
44
|
+
value?: Y;
|
|
47
45
|
}>;
|
|
46
|
+
getContainerProps: PropGetter<"div", undefined>;
|
|
47
|
+
onChange: (evOrValue: ChangeEvent<HTMLInputElement> | Y) => void;
|
|
48
48
|
};
|
|
49
|
-
type UseCheckboxGroupReturn<Y extends
|
|
50
|
-
interface CheckboxGroupProps<Y extends
|
|
49
|
+
type UseCheckboxGroupReturn<Y extends number | string = string> = ReturnType<typeof useCheckboxGroup<Y>>;
|
|
50
|
+
interface CheckboxGroupProps<Y extends number | string = string> extends ThemeProps<"Checkbox">, Omit<FlexProps, "defaultValue" | "onChange">, UseCheckboxGroupProps<Y>, FormControlOptions {
|
|
51
51
|
/**
|
|
52
52
|
* If provided, generate checkboxes based on items.
|
|
53
53
|
*
|
|
@@ -56,7 +56,7 @@ interface CheckboxGroupProps<Y extends string | number = string> extends ThemePr
|
|
|
56
56
|
items?: CheckboxItem<Y>[];
|
|
57
57
|
}
|
|
58
58
|
declare const CheckboxGroup: {
|
|
59
|
-
<Y extends
|
|
59
|
+
<Y extends number | string = string>(props: CheckboxGroupProps<Y> & RefAttributes<HTMLDivElement>): ReactElement;
|
|
60
60
|
} & ComponentArgs;
|
|
61
61
|
|
|
62
62
|
export { CheckboxGroup, type CheckboxGroupProps, type CheckboxItem, type UseCheckboxGroupProps, type UseCheckboxGroupReturn, useCheckboxGroup };
|
package/dist/checkbox-group.d.ts
CHANGED
|
@@ -1,28 +1,20 @@
|
|
|
1
1
|
import { CheckboxProps } from './checkbox.js';
|
|
2
2
|
import * as react from 'react';
|
|
3
|
-
import { ChangeEvent, RefAttributes } from 'react';
|
|
3
|
+
import { ChangeEvent, RefAttributes, ReactElement } from 'react';
|
|
4
4
|
import { PropGetter, ThemeProps, ComponentArgs } from '@yamada-ui/core';
|
|
5
5
|
import { FormControlOptions } from '@yamada-ui/form-control';
|
|
6
6
|
import { FlexProps } from '@yamada-ui/layouts';
|
|
7
7
|
import { Dict } from '@yamada-ui/utils';
|
|
8
8
|
import '@yamada-ui/motion';
|
|
9
9
|
|
|
10
|
-
interface CheckboxItem<Y extends
|
|
10
|
+
interface CheckboxItem<Y extends number | string = string> extends CheckboxProps<Y> {
|
|
11
11
|
label?: string;
|
|
12
12
|
}
|
|
13
|
-
interface UseCheckboxGroupProps<Y extends
|
|
14
|
-
/**
|
|
15
|
-
* The value of the checkbox group.
|
|
16
|
-
*/
|
|
17
|
-
value?: Y[];
|
|
13
|
+
interface UseCheckboxGroupProps<Y extends number | string = string> {
|
|
18
14
|
/**
|
|
19
15
|
* The initial value of the checkbox group.
|
|
20
16
|
*/
|
|
21
17
|
defaultValue?: Y[];
|
|
22
|
-
/**
|
|
23
|
-
* The callback fired when any children checkbox is checked or unchecked.
|
|
24
|
-
*/
|
|
25
|
-
onChange?: (value: Y[]) => void;
|
|
26
18
|
/**
|
|
27
19
|
* If `true`, input elements will receive `checked` attribute instead of `isChecked`.
|
|
28
20
|
*
|
|
@@ -31,23 +23,31 @@ interface UseCheckboxGroupProps<Y extends string | number = string> {
|
|
|
31
23
|
* @default false
|
|
32
24
|
*/
|
|
33
25
|
isNative?: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* The value of the checkbox group.
|
|
28
|
+
*/
|
|
29
|
+
value?: Y[];
|
|
30
|
+
/**
|
|
31
|
+
* The callback fired when any children checkbox is checked or unchecked.
|
|
32
|
+
*/
|
|
33
|
+
onChange?: (value: Y[]) => void;
|
|
34
34
|
}
|
|
35
|
-
declare const useCheckboxGroup: <Y extends
|
|
36
|
-
props: Omit<UseCheckboxGroupProps<Y
|
|
37
|
-
value: Y[];
|
|
35
|
+
declare const useCheckboxGroup: <Y extends number | string, M extends Dict = Dict<any>>({ defaultValue, isNative, value: valueProp, onChange: onChangeProp, ...props }: M & UseCheckboxGroupProps<Y>) => {
|
|
36
|
+
props: Omit<M & UseCheckboxGroupProps<Y>, "defaultValue" | "onChange" | "value" | "isNative">;
|
|
38
37
|
setValue: react.Dispatch<react.SetStateAction<Y[]>>;
|
|
39
|
-
|
|
40
|
-
getContainerProps: PropGetter<"div", undefined>;
|
|
38
|
+
value: Y[];
|
|
41
39
|
getCheckboxProps: PropGetter<{
|
|
42
40
|
value?: Y;
|
|
43
41
|
}, {
|
|
44
|
-
value?: Y;
|
|
45
42
|
checked?: boolean;
|
|
46
43
|
isChecked?: boolean;
|
|
44
|
+
value?: Y;
|
|
47
45
|
}>;
|
|
46
|
+
getContainerProps: PropGetter<"div", undefined>;
|
|
47
|
+
onChange: (evOrValue: ChangeEvent<HTMLInputElement> | Y) => void;
|
|
48
48
|
};
|
|
49
|
-
type UseCheckboxGroupReturn<Y extends
|
|
50
|
-
interface CheckboxGroupProps<Y extends
|
|
49
|
+
type UseCheckboxGroupReturn<Y extends number | string = string> = ReturnType<typeof useCheckboxGroup<Y>>;
|
|
50
|
+
interface CheckboxGroupProps<Y extends number | string = string> extends ThemeProps<"Checkbox">, Omit<FlexProps, "defaultValue" | "onChange">, UseCheckboxGroupProps<Y>, FormControlOptions {
|
|
51
51
|
/**
|
|
52
52
|
* If provided, generate checkboxes based on items.
|
|
53
53
|
*
|
|
@@ -56,7 +56,7 @@ interface CheckboxGroupProps<Y extends string | number = string> extends ThemePr
|
|
|
56
56
|
items?: CheckboxItem<Y>[];
|
|
57
57
|
}
|
|
58
58
|
declare const CheckboxGroup: {
|
|
59
|
-
<Y extends
|
|
59
|
+
<Y extends number | string = string>(props: CheckboxGroupProps<Y> & RefAttributes<HTMLDivElement>): ReactElement;
|
|
60
60
|
} & ComponentArgs;
|
|
61
61
|
|
|
62
62
|
export { CheckboxGroup, type CheckboxGroupProps, type CheckboxItem, type UseCheckboxGroupProps, type UseCheckboxGroupReturn, useCheckboxGroup };
|
package/dist/checkbox-group.js
CHANGED
|
@@ -42,8 +42,8 @@ var import_react = require("react");
|
|
|
42
42
|
// src/checkbox-context.tsx
|
|
43
43
|
var import_utils = require("@yamada-ui/utils");
|
|
44
44
|
var [CheckboxGroupProvider, useCheckboxGroupContext] = (0, import_utils.createContext)({
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
name: "CheckboxGroupContext",
|
|
46
|
+
strict: false
|
|
47
47
|
});
|
|
48
48
|
|
|
49
49
|
// src/checkbox.tsx
|
|
@@ -57,22 +57,22 @@ var useCheckbox = ({
|
|
|
57
57
|
const {
|
|
58
58
|
id: _id,
|
|
59
59
|
name,
|
|
60
|
-
value,
|
|
61
|
-
isChecked: isCheckedProp,
|
|
62
60
|
defaultIsChecked,
|
|
63
|
-
|
|
61
|
+
isChecked: isCheckedProp,
|
|
64
62
|
isIndeterminate,
|
|
63
|
+
tabIndex,
|
|
64
|
+
value,
|
|
65
65
|
onChange: onChangeProp,
|
|
66
66
|
...computedProps
|
|
67
67
|
} = (0, import_form_control.useFormControlProps)({ id, ...props });
|
|
68
68
|
const [
|
|
69
69
|
{
|
|
70
|
-
required,
|
|
71
70
|
disabled,
|
|
72
71
|
readOnly,
|
|
72
|
+
required,
|
|
73
73
|
"aria-readonly": _ariaReadonly,
|
|
74
|
-
onFocus: onFocusProp,
|
|
75
74
|
onBlur: onBlurProp,
|
|
75
|
+
onFocus: onFocusProp,
|
|
76
76
|
...formControlProps
|
|
77
77
|
},
|
|
78
78
|
rest
|
|
@@ -157,20 +157,20 @@ var useCheckbox = ({
|
|
|
157
157
|
...formControlProps,
|
|
158
158
|
...props2,
|
|
159
159
|
ref,
|
|
160
|
+
"aria-hidden": true,
|
|
160
161
|
"data-active": (0, import_utils2.dataAttr)(isActive),
|
|
161
|
-
"data-hover": (0, import_utils2.dataAttr)(isHovered),
|
|
162
162
|
"data-checked": (0, import_utils2.dataAttr)(checked),
|
|
163
163
|
"data-focus": (0, import_utils2.dataAttr)(isFocused),
|
|
164
164
|
"data-focus-visible": (0, import_utils2.dataAttr)(isFocused && isFocusVisible),
|
|
165
|
+
"data-hover": (0, import_utils2.dataAttr)(isHovered),
|
|
165
166
|
"data-indeterminate": (0, import_utils2.dataAttr)(isIndeterminate),
|
|
166
|
-
"aria-hidden": true,
|
|
167
167
|
onMouseDown: (0, import_utils2.handlerAll)(props2.onMouseDown, (ev) => {
|
|
168
168
|
if (isFocused) ev.preventDefault();
|
|
169
169
|
setActive(true);
|
|
170
170
|
}),
|
|
171
|
-
onMouseUp: (0, import_utils2.handlerAll)(props2.onMouseUp, () => setActive(false)),
|
|
172
171
|
onMouseEnter: (0, import_utils2.handlerAll)(props2.onMouseEnter, () => setHovered(true)),
|
|
173
|
-
onMouseLeave: (0, import_utils2.handlerAll)(props2.onMouseLeave, () => setHovered(false))
|
|
172
|
+
onMouseLeave: (0, import_utils2.handlerAll)(props2.onMouseLeave, () => setHovered(false)),
|
|
173
|
+
onMouseUp: (0, import_utils2.handlerAll)(props2.onMouseUp, () => setActive(false))
|
|
174
174
|
}),
|
|
175
175
|
[
|
|
176
176
|
isActive,
|
|
@@ -186,30 +186,30 @@ var useCheckbox = ({
|
|
|
186
186
|
(props2 = {}, ref = null) => ({
|
|
187
187
|
...formControlProps,
|
|
188
188
|
...props2,
|
|
189
|
-
ref: (0, import_utils2.mergeRefs)(inputRef, ref),
|
|
190
189
|
id,
|
|
190
|
+
ref: (0, import_utils2.mergeRefs)(inputRef, ref),
|
|
191
191
|
type: "checkbox",
|
|
192
192
|
name,
|
|
193
|
-
value,
|
|
194
|
-
tabIndex,
|
|
195
|
-
required,
|
|
196
|
-
disabled,
|
|
197
|
-
readOnly,
|
|
198
|
-
checked,
|
|
199
|
-
"aria-checked": isIndeterminate ? "mixed" : checked,
|
|
200
193
|
style: {
|
|
201
194
|
border: "0px",
|
|
202
195
|
clip: "rect(0px, 0px, 0px, 0px)",
|
|
203
196
|
height: "1px",
|
|
204
|
-
width: "1px",
|
|
205
197
|
margin: "-1px",
|
|
206
|
-
padding: "0px",
|
|
207
198
|
overflow: "hidden",
|
|
199
|
+
padding: "0px",
|
|
200
|
+
position: "absolute",
|
|
208
201
|
whiteSpace: "nowrap",
|
|
209
|
-
|
|
202
|
+
width: "1px"
|
|
210
203
|
},
|
|
211
|
-
|
|
204
|
+
checked,
|
|
205
|
+
disabled,
|
|
206
|
+
readOnly,
|
|
207
|
+
required,
|
|
208
|
+
tabIndex,
|
|
209
|
+
value,
|
|
210
|
+
"aria-checked": isIndeterminate ? "mixed" : checked,
|
|
212
211
|
onBlur: (0, import_utils2.handlerAll)(props2.onBlur, onBlur, () => setFocused(false)),
|
|
212
|
+
onChange: (0, import_utils2.handlerAll)(props2.onChange, onChange),
|
|
213
213
|
onFocus: (0, import_utils2.handlerAll)(props2.onFocus, onFocus, () => setFocused(true)),
|
|
214
214
|
onKeyDown: (0, import_utils2.handlerAll)(props2.onKeyDown, onKeyDown),
|
|
215
215
|
onKeyUp: (0, import_utils2.handlerAll)(props2.onKeyUp, onKeyUp)
|
|
@@ -250,13 +250,13 @@ var useCheckbox = ({
|
|
|
250
250
|
[checked, formControlProps]
|
|
251
251
|
);
|
|
252
252
|
return {
|
|
253
|
-
props: rest,
|
|
254
|
-
isFocusVisible,
|
|
255
|
-
isFocused,
|
|
256
|
-
isHovered,
|
|
257
253
|
isActive,
|
|
258
254
|
isChecked: checked,
|
|
255
|
+
isFocused,
|
|
256
|
+
isFocusVisible,
|
|
257
|
+
isHovered,
|
|
259
258
|
isIndeterminate,
|
|
259
|
+
props: rest,
|
|
260
260
|
getContainerProps,
|
|
261
261
|
getIconProps,
|
|
262
262
|
getInputProps,
|
|
@@ -275,15 +275,15 @@ var Checkbox = (0, import_react.forwardRef)(
|
|
|
275
275
|
});
|
|
276
276
|
const {
|
|
277
277
|
className,
|
|
278
|
+
children,
|
|
278
279
|
gap = "0.5rem",
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
280
|
+
isDisabled = (_a = groupProps.isDisabled) != null ? _a : control.isDisabled,
|
|
281
|
+
isInvalid = (_b = groupProps.isInvalid) != null ? _b : control.isInvalid,
|
|
282
|
+
isReadOnly = (_c = groupProps.isReadOnly) != null ? _c : control.isReadOnly,
|
|
283
|
+
isRequired = (_d = groupProps.isRequired) != null ? _d : control.isRequired,
|
|
283
284
|
iconProps,
|
|
284
285
|
inputProps,
|
|
285
286
|
labelProps,
|
|
286
|
-
children,
|
|
287
287
|
...computedProps
|
|
288
288
|
} = (0, import_core.omitThemeProps)(mergedProps);
|
|
289
289
|
const isCheckedProp = groupValue && computedProps.value ? groupValue.includes(computedProps.value) : computedProps.isChecked;
|
|
@@ -291,34 +291,34 @@ var Checkbox = (0, import_react.forwardRef)(
|
|
|
291
291
|
const {
|
|
292
292
|
isChecked,
|
|
293
293
|
isIndeterminate,
|
|
294
|
+
props: rest,
|
|
294
295
|
getContainerProps,
|
|
295
|
-
getInputProps,
|
|
296
296
|
getIconProps,
|
|
297
|
-
|
|
298
|
-
|
|
297
|
+
getInputProps,
|
|
298
|
+
getLabelProps
|
|
299
299
|
} = useCheckbox({
|
|
300
300
|
...computedProps,
|
|
301
|
-
|
|
302
|
-
isReadOnly,
|
|
301
|
+
isChecked: isCheckedProp,
|
|
303
302
|
isDisabled,
|
|
304
303
|
isInvalid,
|
|
305
|
-
|
|
304
|
+
isReadOnly,
|
|
305
|
+
isRequired,
|
|
306
306
|
onChange
|
|
307
307
|
});
|
|
308
308
|
const { children: customIcon, ...resolvedIconProps } = { ...iconProps };
|
|
309
309
|
const cloneIcon = (0, import_react.cloneElement)(customIcon != null ? customIcon : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CheckboxIcon, {}), {
|
|
310
|
+
isChecked,
|
|
311
|
+
isDisabled,
|
|
312
|
+
isIndeterminate,
|
|
313
|
+
isInvalid,
|
|
314
|
+
isReadOnly,
|
|
315
|
+
isRequired,
|
|
310
316
|
__css: {
|
|
311
317
|
opacity: isChecked || isIndeterminate ? 1 : 0,
|
|
312
318
|
transform: isChecked || isIndeterminate ? "scale(1)" : "scale(0.95)",
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
}
|
|
316
|
-
isIndeterminate,
|
|
317
|
-
isChecked,
|
|
318
|
-
isRequired,
|
|
319
|
-
isReadOnly,
|
|
320
|
-
isDisabled,
|
|
321
|
-
isInvalid
|
|
319
|
+
transitionDuration: "normal",
|
|
320
|
+
transitionProperty: "transform"
|
|
321
|
+
}
|
|
322
322
|
});
|
|
323
323
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
324
324
|
import_core.ui.label,
|
|
@@ -326,12 +326,12 @@ var Checkbox = (0, import_react.forwardRef)(
|
|
|
326
326
|
className: (0, import_utils2.cx)("ui-checkbox", className),
|
|
327
327
|
...getContainerProps(),
|
|
328
328
|
__css: {
|
|
329
|
+
alignItems: "center",
|
|
329
330
|
cursor: "pointer",
|
|
330
|
-
position: "relative",
|
|
331
331
|
display: "inline-flex",
|
|
332
|
-
alignItems: "center",
|
|
333
|
-
verticalAlign: "top",
|
|
334
332
|
gap,
|
|
333
|
+
position: "relative",
|
|
334
|
+
verticalAlign: "top",
|
|
335
335
|
...styles.container
|
|
336
336
|
},
|
|
337
337
|
...rest,
|
|
@@ -348,9 +348,9 @@ var Checkbox = (0, import_react.forwardRef)(
|
|
|
348
348
|
{
|
|
349
349
|
className: "ui-checkbox__icon",
|
|
350
350
|
__css: {
|
|
351
|
+
display: "inline-block",
|
|
351
352
|
pointerEvents: isReadOnly ? "none" : void 0,
|
|
352
353
|
position: "relative",
|
|
353
|
-
display: "inline-block",
|
|
354
354
|
userSelect: "none",
|
|
355
355
|
...styles.icon
|
|
356
356
|
},
|
|
@@ -375,38 +375,38 @@ var Checkbox = (0, import_react.forwardRef)(
|
|
|
375
375
|
Checkbox.displayName = "Checkbox";
|
|
376
376
|
Checkbox.__ui__ = "Checkbox";
|
|
377
377
|
var CheckboxIcon = ({
|
|
378
|
-
isIndeterminate,
|
|
379
378
|
isChecked,
|
|
380
|
-
isRequired: _isRequired,
|
|
381
|
-
isReadOnly: _isReadOnly,
|
|
382
379
|
isDisabled: _isDisabled,
|
|
380
|
+
isIndeterminate,
|
|
383
381
|
isInvalid: _isInvalid,
|
|
382
|
+
isReadOnly: _isReadOnly,
|
|
383
|
+
isRequired: _isRequired,
|
|
384
384
|
...rest
|
|
385
385
|
}) => {
|
|
386
386
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_motion.AnimatePresence, { initial: false, children: isIndeterminate || isChecked ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
387
387
|
import_core.ui.div,
|
|
388
388
|
{
|
|
389
389
|
__css: {
|
|
390
|
+
left: "50%",
|
|
390
391
|
position: "absolute",
|
|
391
392
|
top: "50%",
|
|
392
|
-
left: "50%",
|
|
393
393
|
transform: "translate(-50%, -50%)"
|
|
394
394
|
},
|
|
395
395
|
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
396
396
|
import_motion.motion.div,
|
|
397
397
|
{
|
|
398
|
-
variants: {
|
|
399
|
-
unchecked: { scale: 0.5 },
|
|
400
|
-
checked: { scale: 1 }
|
|
401
|
-
},
|
|
402
|
-
initial: "unchecked",
|
|
403
|
-
animate: "checked",
|
|
404
|
-
exit: "unchecked",
|
|
405
398
|
style: {
|
|
406
|
-
display: "flex",
|
|
407
399
|
alignItems: "center",
|
|
400
|
+
display: "flex",
|
|
408
401
|
justifyContent: "center"
|
|
409
402
|
},
|
|
403
|
+
animate: "checked",
|
|
404
|
+
exit: "unchecked",
|
|
405
|
+
initial: "unchecked",
|
|
406
|
+
variants: {
|
|
407
|
+
checked: { scale: 1 },
|
|
408
|
+
unchecked: { scale: 0.5 }
|
|
409
|
+
},
|
|
410
410
|
children: isIndeterminate ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CheckboxIndeterminateIcon, { ...rest }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CheckboxCheckIcon, { ...rest })
|
|
411
411
|
}
|
|
412
412
|
)
|
|
@@ -419,25 +419,25 @@ var CheckboxCheckIcon = (props) => {
|
|
|
419
419
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
420
420
|
import_motion.motion.svg,
|
|
421
421
|
{
|
|
422
|
-
|
|
423
|
-
|
|
422
|
+
style: {
|
|
423
|
+
fill: "none",
|
|
424
|
+
stroke: "currentColor",
|
|
425
|
+
strokeDasharray: 16,
|
|
426
|
+
strokeWidth: 2
|
|
427
|
+
},
|
|
424
428
|
variants: {
|
|
425
|
-
unchecked: {
|
|
426
|
-
opacity: 0,
|
|
427
|
-
strokeDashoffset: 16
|
|
428
|
-
},
|
|
429
429
|
checked: {
|
|
430
430
|
opacity: 1,
|
|
431
431
|
strokeDashoffset: 0,
|
|
432
432
|
transition: { duration: 0.2 }
|
|
433
|
+
},
|
|
434
|
+
unchecked: {
|
|
435
|
+
opacity: 0,
|
|
436
|
+
strokeDashoffset: 16
|
|
433
437
|
}
|
|
434
438
|
},
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
strokeWidth: 2,
|
|
438
|
-
stroke: "currentColor",
|
|
439
|
-
strokeDasharray: 16
|
|
440
|
-
},
|
|
439
|
+
viewBox: "0 0 12 10",
|
|
440
|
+
width: "1.2em",
|
|
441
441
|
...props,
|
|
442
442
|
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("polyline", { points: "1.5 6 4.5 9 10.5 1" })
|
|
443
443
|
}
|
|
@@ -449,23 +449,23 @@ var CheckboxIndeterminateIcon = (props) => {
|
|
|
449
449
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
450
450
|
import_motion.motion.svg,
|
|
451
451
|
{
|
|
452
|
-
|
|
453
|
-
viewBox: "0 0 24 24",
|
|
452
|
+
style: { stroke: "currentColor", strokeWidth: 4 },
|
|
454
453
|
variants: {
|
|
455
|
-
unchecked: {
|
|
456
|
-
scaleX: 0.65,
|
|
457
|
-
opacity: 0
|
|
458
|
-
},
|
|
459
454
|
checked: {
|
|
460
|
-
scaleX: 1,
|
|
461
455
|
opacity: 1,
|
|
456
|
+
scaleX: 1,
|
|
462
457
|
transition: {
|
|
463
|
-
|
|
464
|
-
|
|
458
|
+
opacity: { duration: 0.02 },
|
|
459
|
+
scaleX: { duration: 0 }
|
|
465
460
|
}
|
|
461
|
+
},
|
|
462
|
+
unchecked: {
|
|
463
|
+
opacity: 0,
|
|
464
|
+
scaleX: 0.65
|
|
466
465
|
}
|
|
467
466
|
},
|
|
468
|
-
|
|
467
|
+
viewBox: "0 0 24 24",
|
|
468
|
+
width: "1.2em",
|
|
469
469
|
...props,
|
|
470
470
|
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("line", { x1: "21", x2: "3", y1: "12", y2: "12" })
|
|
471
471
|
}
|
|
@@ -478,16 +478,16 @@ CheckboxIndeterminateIcon.__ui__ = "CheckboxIndeterminateIcon";
|
|
|
478
478
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
479
479
|
var isEvent = (value) => value && (0, import_utils3.isObject)(value) && (0, import_utils3.isObject)(value.target);
|
|
480
480
|
var useCheckboxGroup = ({
|
|
481
|
-
value: valueProp,
|
|
482
481
|
defaultValue = [],
|
|
483
|
-
onChange: onChangeProp,
|
|
484
482
|
isNative,
|
|
483
|
+
value: valueProp,
|
|
484
|
+
onChange: onChangeProp,
|
|
485
485
|
...props
|
|
486
486
|
}) => {
|
|
487
487
|
const onChangeRef = (0, import_utils3.useCallbackRef)(onChangeProp);
|
|
488
488
|
const [value, setValue] = (0, import_use_controllable_state.useControllableState)({
|
|
489
|
-
value: valueProp,
|
|
490
489
|
defaultValue,
|
|
490
|
+
value: valueProp,
|
|
491
491
|
onChange: onChangeRef
|
|
492
492
|
});
|
|
493
493
|
const onChange = (0, import_react2.useCallback)(
|
|
@@ -512,7 +512,7 @@ var useCheckboxGroup = ({
|
|
|
512
512
|
...props2,
|
|
513
513
|
ref,
|
|
514
514
|
[isNative ? "checked" : "isChecked"]: value.some(
|
|
515
|
-
(val) => String(props2
|
|
515
|
+
(val) => String(props2.value) === String(val)
|
|
516
516
|
),
|
|
517
517
|
onChange
|
|
518
518
|
}),
|
|
@@ -520,32 +520,32 @@ var useCheckboxGroup = ({
|
|
|
520
520
|
);
|
|
521
521
|
return {
|
|
522
522
|
props,
|
|
523
|
-
value,
|
|
524
523
|
setValue,
|
|
525
|
-
|
|
524
|
+
value,
|
|
525
|
+
getCheckboxProps,
|
|
526
526
|
getContainerProps,
|
|
527
|
-
|
|
527
|
+
onChange
|
|
528
528
|
};
|
|
529
529
|
};
|
|
530
530
|
var CheckboxGroup = (0, import_react2.forwardRef)(
|
|
531
531
|
({
|
|
532
532
|
className,
|
|
533
|
-
size,
|
|
534
|
-
variant,
|
|
535
|
-
colorScheme,
|
|
536
533
|
children,
|
|
537
|
-
|
|
534
|
+
colorScheme,
|
|
538
535
|
direction = "column",
|
|
539
536
|
gap,
|
|
537
|
+
items = [],
|
|
538
|
+
size,
|
|
539
|
+
variant,
|
|
540
540
|
...props
|
|
541
541
|
}, ref) => {
|
|
542
542
|
const {
|
|
543
|
-
value,
|
|
544
|
-
onChange,
|
|
545
543
|
props: computedProps,
|
|
546
|
-
|
|
544
|
+
value,
|
|
545
|
+
getContainerProps,
|
|
546
|
+
onChange
|
|
547
547
|
} = useCheckboxGroup(props);
|
|
548
|
-
const {
|
|
548
|
+
const { isDisabled, isInvalid, isReadOnly, isRequired, labelId, ...rest } = (0, import_form_control2.useFormControl)(computedProps);
|
|
549
549
|
const validChildren = (0, import_utils3.getValidChildren)(children);
|
|
550
550
|
let computedChildren = [];
|
|
551
551
|
if (!validChildren.length && items.length) {
|
|
@@ -555,14 +555,14 @@ var CheckboxGroup = (0, import_react2.forwardRef)(
|
|
|
555
555
|
CheckboxGroupProvider,
|
|
556
556
|
{
|
|
557
557
|
value: {
|
|
558
|
-
size,
|
|
559
|
-
variant,
|
|
560
558
|
colorScheme,
|
|
561
|
-
isRequired,
|
|
562
|
-
isReadOnly,
|
|
563
559
|
isDisabled,
|
|
564
560
|
isInvalid,
|
|
561
|
+
isReadOnly,
|
|
562
|
+
isRequired,
|
|
563
|
+
size,
|
|
565
564
|
value,
|
|
565
|
+
variant,
|
|
566
566
|
onChange
|
|
567
567
|
},
|
|
568
568
|
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|