@yamada-ui/checkbox 1.1.8-dev-20240915031944 → 1.1.8-dev-20240917033401
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 +13 -0
- package/dist/checkbox-context.d.ts +13 -0
- package/dist/checkbox-context.js +38 -0
- package/dist/checkbox-context.js.map +1 -0
- package/dist/checkbox-context.mjs +10 -0
- package/dist/checkbox-context.mjs.map +1 -0
- package/dist/checkbox-group.d.mts +15 -22
- package/dist/checkbox-group.d.ts +15 -22
- package/dist/checkbox-group.js +51 -48
- package/dist/checkbox-group.js.map +1 -1
- package/dist/checkbox-group.mjs +5 -5
- package/dist/checkbox.d.mts +19 -125
- package/dist/checkbox.d.ts +19 -125
- package/dist/checkbox.js +36 -149
- package/dist/checkbox.js.map +1 -1
- package/dist/checkbox.mjs +2 -1
- package/dist/chunk-IZINMNYX.mjs +14 -0
- package/dist/chunk-IZINMNYX.mjs.map +1 -0
- package/dist/chunk-J27S43KM.mjs +134 -0
- package/dist/chunk-J27S43KM.mjs.map +1 -0
- package/dist/{chunk-DMNICJ3Z.mjs → chunk-LP6DPNQY.mjs} +36 -164
- package/dist/chunk-LP6DPNQY.mjs.map +1 -0
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +152 -149
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +7 -4
- package/package.json +8 -8
- package/dist/chunk-DMNICJ3Z.mjs.map +0 -1
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { ChangeEvent } from 'react';
|
|
3
|
+
import { ThemeProps } from '@yamada-ui/core';
|
|
4
|
+
import { FormControlOptions } from '@yamada-ui/form-control';
|
|
5
|
+
|
|
6
|
+
interface CheckboxGroupContext extends ThemeProps<"Checkbox">, FormControlOptions {
|
|
7
|
+
value: (string | number)[];
|
|
8
|
+
onChange: (evOrValue: ChangeEvent<HTMLInputElement> | string | number) => void;
|
|
9
|
+
}
|
|
10
|
+
declare const CheckboxGroupProvider: react.Provider<CheckboxGroupContext | undefined>;
|
|
11
|
+
declare const useCheckboxGroupContext: () => CheckboxGroupContext | undefined;
|
|
12
|
+
|
|
13
|
+
export { type CheckboxGroupContext, CheckboxGroupProvider, useCheckboxGroupContext };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { ChangeEvent } from 'react';
|
|
3
|
+
import { ThemeProps } from '@yamada-ui/core';
|
|
4
|
+
import { FormControlOptions } from '@yamada-ui/form-control';
|
|
5
|
+
|
|
6
|
+
interface CheckboxGroupContext extends ThemeProps<"Checkbox">, FormControlOptions {
|
|
7
|
+
value: (string | number)[];
|
|
8
|
+
onChange: (evOrValue: ChangeEvent<HTMLInputElement> | string | number) => void;
|
|
9
|
+
}
|
|
10
|
+
declare const CheckboxGroupProvider: react.Provider<CheckboxGroupContext | undefined>;
|
|
11
|
+
declare const useCheckboxGroupContext: () => CheckboxGroupContext | undefined;
|
|
12
|
+
|
|
13
|
+
export { type CheckboxGroupContext, CheckboxGroupProvider, useCheckboxGroupContext };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
"use strict";
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
|
|
21
|
+
// src/checkbox-context.tsx
|
|
22
|
+
var checkbox_context_exports = {};
|
|
23
|
+
__export(checkbox_context_exports, {
|
|
24
|
+
CheckboxGroupProvider: () => CheckboxGroupProvider,
|
|
25
|
+
useCheckboxGroupContext: () => useCheckboxGroupContext
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(checkbox_context_exports);
|
|
28
|
+
var import_utils = require("@yamada-ui/utils");
|
|
29
|
+
var [CheckboxGroupProvider, useCheckboxGroupContext] = (0, import_utils.createContext)({
|
|
30
|
+
strict: false,
|
|
31
|
+
name: "CheckboxGroupContext"
|
|
32
|
+
});
|
|
33
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
34
|
+
0 && (module.exports = {
|
|
35
|
+
CheckboxGroupProvider,
|
|
36
|
+
useCheckboxGroupContext
|
|
37
|
+
});
|
|
38
|
+
//# sourceMappingURL=checkbox-context.js.map
|
|
@@ -0,0 +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 { createContext } from \"@yamada-ui/utils\"\nimport type { ChangeEvent } from \"react\"\n\nexport interface CheckboxGroupContext\n extends ThemeProps<\"Checkbox\">,\n FormControlOptions {\n value: (string | number)[]\n onChange: (evOrValue: ChangeEvent<HTMLInputElement> | string | number) => void\n}\n\nexport const [CheckboxGroupProvider, useCheckboxGroupContext] = createContext<\n CheckboxGroupContext | undefined\n>({\n strict: false,\n name: \"CheckboxGroupContext\",\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,mBAA8B;AAUvB,IAAM,CAAC,uBAAuB,uBAAuB,QAAI,4BAE9D;AAAA,EACA,QAAQ;AAAA,EACR,MAAM;AACR,CAAC;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { CheckboxProps } from './checkbox.mjs';
|
|
2
2
|
import * as react from 'react';
|
|
3
|
-
import { ChangeEvent,
|
|
4
|
-
import {
|
|
3
|
+
import { ChangeEvent, RefAttributes } from 'react';
|
|
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
|
-
import { Dict
|
|
7
|
+
import { Dict } from '@yamada-ui/utils';
|
|
8
8
|
import '@yamada-ui/motion';
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
interface CheckboxItem<Y extends string | number = string> extends CheckboxProps<Y> {
|
|
11
11
|
label?: string;
|
|
12
|
-
}
|
|
13
|
-
|
|
12
|
+
}
|
|
13
|
+
interface UseCheckboxGroupProps<Y extends string | number = string> {
|
|
14
14
|
/**
|
|
15
15
|
* The value of the checkbox group.
|
|
16
16
|
*/
|
|
@@ -31,39 +31,32 @@ type UseCheckboxGroupProps<Y extends string | number = string> = {
|
|
|
31
31
|
* @default false
|
|
32
32
|
*/
|
|
33
33
|
isNative?: boolean;
|
|
34
|
-
}
|
|
35
|
-
declare const useCheckboxGroup: <Y extends string | number
|
|
34
|
+
}
|
|
35
|
+
declare const useCheckboxGroup: <Y extends string | number, M extends Dict = Dict<any>>({ value: valueProp, defaultValue, onChange: onChangeProp, isNative, ...props }: UseCheckboxGroupProps<Y> & M) => {
|
|
36
36
|
props: Omit<UseCheckboxGroupProps<Y> & M, "defaultValue" | "onChange" | "value" | "isNative">;
|
|
37
37
|
value: Y[];
|
|
38
38
|
setValue: react.Dispatch<react.SetStateAction<Y[]>>;
|
|
39
39
|
onChange: (evOrValue: ChangeEvent<HTMLInputElement> | Y) => void;
|
|
40
|
-
getContainerProps: PropGetter
|
|
41
|
-
getCheckboxProps:
|
|
40
|
+
getContainerProps: PropGetter<"div", undefined>;
|
|
41
|
+
getCheckboxProps: PropGetter<{
|
|
42
42
|
value?: Y;
|
|
43
43
|
}, {
|
|
44
44
|
value?: Y;
|
|
45
|
+
checked?: boolean;
|
|
45
46
|
isChecked?: boolean;
|
|
46
47
|
}>;
|
|
47
48
|
};
|
|
48
49
|
type UseCheckboxGroupReturn<Y extends string | number = string> = ReturnType<typeof useCheckboxGroup<Y>>;
|
|
49
|
-
|
|
50
|
+
interface CheckboxGroupProps<Y extends string | number = string> extends ThemeProps<"Checkbox">, Omit<FlexProps, "defaultValue" | "onChange">, UseCheckboxGroupProps<Y>, FormControlOptions {
|
|
50
51
|
/**
|
|
51
52
|
* If provided, generate checkboxes based on items.
|
|
52
53
|
*
|
|
53
54
|
* @default '[]'
|
|
54
55
|
*/
|
|
55
56
|
items?: CheckboxItem<Y>[];
|
|
56
|
-
}
|
|
57
|
-
type CheckboxContext = ThemeProps<"Checkbox"> & FormControlOptions & {
|
|
58
|
-
value: (string | number)[];
|
|
59
|
-
onChange: (evOrValue: ChangeEvent<HTMLInputElement> | string | number) => void;
|
|
60
|
-
};
|
|
61
|
-
declare const useCheckboxGroupContext: () => CheckboxContext | undefined;
|
|
62
|
-
|
|
57
|
+
}
|
|
63
58
|
declare const CheckboxGroup: {
|
|
64
|
-
<Y extends string | number = string>(props: CheckboxGroupProps<Y> &
|
|
65
|
-
ref?: Ref<HTMLDivElement>;
|
|
66
|
-
}): JSX.Element;
|
|
59
|
+
<Y extends string | number = string>(props: CheckboxGroupProps<Y> & RefAttributes<HTMLDivElement>): JSX.Element;
|
|
67
60
|
} & ComponentArgs;
|
|
68
61
|
|
|
69
|
-
export { CheckboxGroup, type CheckboxGroupProps, type CheckboxItem, type UseCheckboxGroupProps, type UseCheckboxGroupReturn, useCheckboxGroup
|
|
62
|
+
export { CheckboxGroup, type CheckboxGroupProps, type CheckboxItem, type UseCheckboxGroupProps, type UseCheckboxGroupReturn, useCheckboxGroup };
|
package/dist/checkbox-group.d.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { CheckboxProps } from './checkbox.js';
|
|
2
2
|
import * as react from 'react';
|
|
3
|
-
import { ChangeEvent,
|
|
4
|
-
import {
|
|
3
|
+
import { ChangeEvent, RefAttributes } from 'react';
|
|
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
|
-
import { Dict
|
|
7
|
+
import { Dict } from '@yamada-ui/utils';
|
|
8
8
|
import '@yamada-ui/motion';
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
interface CheckboxItem<Y extends string | number = string> extends CheckboxProps<Y> {
|
|
11
11
|
label?: string;
|
|
12
|
-
}
|
|
13
|
-
|
|
12
|
+
}
|
|
13
|
+
interface UseCheckboxGroupProps<Y extends string | number = string> {
|
|
14
14
|
/**
|
|
15
15
|
* The value of the checkbox group.
|
|
16
16
|
*/
|
|
@@ -31,39 +31,32 @@ type UseCheckboxGroupProps<Y extends string | number = string> = {
|
|
|
31
31
|
* @default false
|
|
32
32
|
*/
|
|
33
33
|
isNative?: boolean;
|
|
34
|
-
}
|
|
35
|
-
declare const useCheckboxGroup: <Y extends string | number
|
|
34
|
+
}
|
|
35
|
+
declare const useCheckboxGroup: <Y extends string | number, M extends Dict = Dict<any>>({ value: valueProp, defaultValue, onChange: onChangeProp, isNative, ...props }: UseCheckboxGroupProps<Y> & M) => {
|
|
36
36
|
props: Omit<UseCheckboxGroupProps<Y> & M, "defaultValue" | "onChange" | "value" | "isNative">;
|
|
37
37
|
value: Y[];
|
|
38
38
|
setValue: react.Dispatch<react.SetStateAction<Y[]>>;
|
|
39
39
|
onChange: (evOrValue: ChangeEvent<HTMLInputElement> | Y) => void;
|
|
40
|
-
getContainerProps: PropGetter
|
|
41
|
-
getCheckboxProps:
|
|
40
|
+
getContainerProps: PropGetter<"div", undefined>;
|
|
41
|
+
getCheckboxProps: PropGetter<{
|
|
42
42
|
value?: Y;
|
|
43
43
|
}, {
|
|
44
44
|
value?: Y;
|
|
45
|
+
checked?: boolean;
|
|
45
46
|
isChecked?: boolean;
|
|
46
47
|
}>;
|
|
47
48
|
};
|
|
48
49
|
type UseCheckboxGroupReturn<Y extends string | number = string> = ReturnType<typeof useCheckboxGroup<Y>>;
|
|
49
|
-
|
|
50
|
+
interface CheckboxGroupProps<Y extends string | number = string> extends ThemeProps<"Checkbox">, Omit<FlexProps, "defaultValue" | "onChange">, UseCheckboxGroupProps<Y>, FormControlOptions {
|
|
50
51
|
/**
|
|
51
52
|
* If provided, generate checkboxes based on items.
|
|
52
53
|
*
|
|
53
54
|
* @default '[]'
|
|
54
55
|
*/
|
|
55
56
|
items?: CheckboxItem<Y>[];
|
|
56
|
-
}
|
|
57
|
-
type CheckboxContext = ThemeProps<"Checkbox"> & FormControlOptions & {
|
|
58
|
-
value: (string | number)[];
|
|
59
|
-
onChange: (evOrValue: ChangeEvent<HTMLInputElement> | string | number) => void;
|
|
60
|
-
};
|
|
61
|
-
declare const useCheckboxGroupContext: () => CheckboxContext | undefined;
|
|
62
|
-
|
|
57
|
+
}
|
|
63
58
|
declare const CheckboxGroup: {
|
|
64
|
-
<Y extends string | number = string>(props: CheckboxGroupProps<Y> &
|
|
65
|
-
ref?: Ref<HTMLDivElement>;
|
|
66
|
-
}): JSX.Element;
|
|
59
|
+
<Y extends string | number = string>(props: CheckboxGroupProps<Y> & RefAttributes<HTMLDivElement>): JSX.Element;
|
|
67
60
|
} & ComponentArgs;
|
|
68
61
|
|
|
69
|
-
export { CheckboxGroup, type CheckboxGroupProps, type CheckboxItem, type UseCheckboxGroupProps, type UseCheckboxGroupReturn, useCheckboxGroup
|
|
62
|
+
export { CheckboxGroup, type CheckboxGroupProps, type CheckboxItem, type UseCheckboxGroupProps, type UseCheckboxGroupReturn, useCheckboxGroup };
|
package/dist/checkbox-group.js
CHANGED
|
@@ -22,14 +22,13 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
22
22
|
var checkbox_group_exports = {};
|
|
23
23
|
__export(checkbox_group_exports, {
|
|
24
24
|
CheckboxGroup: () => CheckboxGroup,
|
|
25
|
-
useCheckboxGroup: () => useCheckboxGroup
|
|
26
|
-
useCheckboxGroupContext: () => useCheckboxGroupContext
|
|
25
|
+
useCheckboxGroup: () => useCheckboxGroup
|
|
27
26
|
});
|
|
28
27
|
module.exports = __toCommonJS(checkbox_group_exports);
|
|
29
28
|
var import_form_control2 = require("@yamada-ui/form-control");
|
|
30
29
|
var import_layouts = require("@yamada-ui/layouts");
|
|
31
30
|
var import_use_controllable_state = require("@yamada-ui/use-controllable-state");
|
|
32
|
-
var
|
|
31
|
+
var import_utils3 = require("@yamada-ui/utils");
|
|
33
32
|
var import_react2 = require("react");
|
|
34
33
|
|
|
35
34
|
// src/checkbox.tsx
|
|
@@ -37,8 +36,17 @@ var import_core = require("@yamada-ui/core");
|
|
|
37
36
|
var import_form_control = require("@yamada-ui/form-control");
|
|
38
37
|
var import_motion = require("@yamada-ui/motion");
|
|
39
38
|
var import_use_focus_visible = require("@yamada-ui/use-focus-visible");
|
|
40
|
-
var
|
|
39
|
+
var import_utils2 = require("@yamada-ui/utils");
|
|
41
40
|
var import_react = require("react");
|
|
41
|
+
|
|
42
|
+
// src/checkbox-context.tsx
|
|
43
|
+
var import_utils = require("@yamada-ui/utils");
|
|
44
|
+
var [CheckboxGroupProvider, useCheckboxGroupContext] = (0, import_utils.createContext)({
|
|
45
|
+
strict: false,
|
|
46
|
+
name: "CheckboxGroupContext"
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
// src/checkbox.tsx
|
|
42
50
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
43
51
|
var useCheckbox = ({
|
|
44
52
|
id,
|
|
@@ -67,7 +75,7 @@ var useCheckbox = ({
|
|
|
67
75
|
...formControlProps
|
|
68
76
|
},
|
|
69
77
|
rest
|
|
70
|
-
] = (0,
|
|
78
|
+
] = (0, import_utils2.splitObject)(computedProps, import_form_control.formControlProperties);
|
|
71
79
|
const [isFocusVisible, setIsFocusVisible] = (0, import_react.useState)(false);
|
|
72
80
|
const [isFocused, setFocused] = (0, import_react.useState)(false);
|
|
73
81
|
const [isHovered, setHovered] = (0, import_react.useState)(false);
|
|
@@ -77,7 +85,7 @@ var useCheckbox = ({
|
|
|
77
85
|
const [isChecked, setIsChecked] = (0, import_react.useState)(!!defaultIsChecked);
|
|
78
86
|
const isControlled = isCheckedProp !== void 0;
|
|
79
87
|
const checked = isControlled ? isCheckedProp : isChecked;
|
|
80
|
-
const onChange = (0,
|
|
88
|
+
const onChange = (0, import_utils2.useCallbackRef)(
|
|
81
89
|
(ev) => {
|
|
82
90
|
if (readOnly || disabled) {
|
|
83
91
|
ev.preventDefault();
|
|
@@ -89,8 +97,8 @@ var useCheckbox = ({
|
|
|
89
97
|
},
|
|
90
98
|
[readOnly, disabled, isControlled, checked, isIndeterminate]
|
|
91
99
|
);
|
|
92
|
-
const onFocus = (0,
|
|
93
|
-
const onBlur = (0,
|
|
100
|
+
const onFocus = (0, import_utils2.useCallbackRef)(onFocusProp);
|
|
101
|
+
const onBlur = (0, import_utils2.useCallbackRef)(onBlurProp);
|
|
94
102
|
const onKeyDown = (0, import_react.useCallback)(
|
|
95
103
|
({ key }) => {
|
|
96
104
|
if (key === " ") setActive(true);
|
|
@@ -106,19 +114,19 @@ var useCheckbox = ({
|
|
|
106
114
|
(0, import_react.useEffect)(() => {
|
|
107
115
|
return (0, import_use_focus_visible.trackFocusVisible)(setIsFocusVisible);
|
|
108
116
|
}, []);
|
|
109
|
-
(0,
|
|
117
|
+
(0, import_utils2.useSafeLayoutEffect)(() => {
|
|
110
118
|
if (inputRef.current)
|
|
111
119
|
inputRef.current.indeterminate = Boolean(isIndeterminate);
|
|
112
120
|
}, [isIndeterminate]);
|
|
113
|
-
(0,
|
|
121
|
+
(0, import_utils2.useUpdateEffect)(() => {
|
|
114
122
|
if (disabled) setFocused(false);
|
|
115
123
|
}, [disabled, setFocused]);
|
|
116
|
-
(0,
|
|
124
|
+
(0, import_utils2.useSafeLayoutEffect)(() => {
|
|
117
125
|
var _a;
|
|
118
126
|
if (!((_a = inputRef.current) == null ? void 0 : _a.form)) return;
|
|
119
127
|
inputRef.current.form.onreset = () => setIsChecked(!!defaultIsChecked);
|
|
120
128
|
}, []);
|
|
121
|
-
(0,
|
|
129
|
+
(0, import_utils2.useSafeLayoutEffect)(() => {
|
|
122
130
|
if (!inputRef.current) return;
|
|
123
131
|
if (inputRef.current.checked !== checked)
|
|
124
132
|
setIsChecked(inputRef.current.checked);
|
|
@@ -127,11 +135,11 @@ var useCheckbox = ({
|
|
|
127
135
|
(props2 = {}, ref = null) => ({
|
|
128
136
|
...formControlProps,
|
|
129
137
|
...props2,
|
|
130
|
-
ref: (0,
|
|
138
|
+
ref: (0, import_utils2.mergeRefs)(ref, (el) => {
|
|
131
139
|
if (el) setIsLabel(el.tagName === "LABEL");
|
|
132
140
|
}),
|
|
133
|
-
"data-checked": (0,
|
|
134
|
-
onClick: (0,
|
|
141
|
+
"data-checked": (0, import_utils2.dataAttr)(checked),
|
|
142
|
+
onClick: (0, import_utils2.handlerAll)(props2.onClick, () => {
|
|
135
143
|
var _a;
|
|
136
144
|
if (isLabel) return;
|
|
137
145
|
(_a = inputRef.current) == null ? void 0 : _a.click();
|
|
@@ -148,20 +156,20 @@ var useCheckbox = ({
|
|
|
148
156
|
...formControlProps,
|
|
149
157
|
...props2,
|
|
150
158
|
ref,
|
|
151
|
-
"data-active": (0,
|
|
152
|
-
"data-hover": (0,
|
|
153
|
-
"data-checked": (0,
|
|
154
|
-
"data-focus": (0,
|
|
155
|
-
"data-focus-visible": (0,
|
|
156
|
-
"data-indeterminate": (0,
|
|
159
|
+
"data-active": (0, import_utils2.dataAttr)(isActive),
|
|
160
|
+
"data-hover": (0, import_utils2.dataAttr)(isHovered),
|
|
161
|
+
"data-checked": (0, import_utils2.dataAttr)(checked),
|
|
162
|
+
"data-focus": (0, import_utils2.dataAttr)(isFocused),
|
|
163
|
+
"data-focus-visible": (0, import_utils2.dataAttr)(isFocused && isFocusVisible),
|
|
164
|
+
"data-indeterminate": (0, import_utils2.dataAttr)(isIndeterminate),
|
|
157
165
|
"aria-hidden": true,
|
|
158
|
-
onMouseDown: (0,
|
|
166
|
+
onMouseDown: (0, import_utils2.handlerAll)(props2.onMouseDown, (ev) => {
|
|
159
167
|
if (isFocused) ev.preventDefault();
|
|
160
168
|
setActive(true);
|
|
161
169
|
}),
|
|
162
|
-
onMouseUp: (0,
|
|
163
|
-
onMouseEnter: (0,
|
|
164
|
-
onMouseLeave: (0,
|
|
170
|
+
onMouseUp: (0, import_utils2.handlerAll)(props2.onMouseUp, () => setActive(false)),
|
|
171
|
+
onMouseEnter: (0, import_utils2.handlerAll)(props2.onMouseEnter, () => setHovered(true)),
|
|
172
|
+
onMouseLeave: (0, import_utils2.handlerAll)(props2.onMouseLeave, () => setHovered(false))
|
|
165
173
|
}),
|
|
166
174
|
[
|
|
167
175
|
isActive,
|
|
@@ -177,7 +185,7 @@ var useCheckbox = ({
|
|
|
177
185
|
(props2 = {}, ref = null) => ({
|
|
178
186
|
...formControlProps,
|
|
179
187
|
...props2,
|
|
180
|
-
ref: (0,
|
|
188
|
+
ref: (0, import_utils2.mergeRefs)(inputRef, ref),
|
|
181
189
|
id,
|
|
182
190
|
type: "checkbox",
|
|
183
191
|
name,
|
|
@@ -199,11 +207,11 @@ var useCheckbox = ({
|
|
|
199
207
|
whiteSpace: "nowrap",
|
|
200
208
|
position: "absolute"
|
|
201
209
|
},
|
|
202
|
-
onChange: (0,
|
|
203
|
-
onBlur: (0,
|
|
204
|
-
onFocus: (0,
|
|
205
|
-
onKeyDown: (0,
|
|
206
|
-
onKeyUp: (0,
|
|
210
|
+
onChange: (0, import_utils2.handlerAll)(props2.onChange, onChange),
|
|
211
|
+
onBlur: (0, import_utils2.handlerAll)(props2.onBlur, onBlur, () => setFocused(false)),
|
|
212
|
+
onFocus: (0, import_utils2.handlerAll)(props2.onFocus, onFocus, () => setFocused(true)),
|
|
213
|
+
onKeyDown: (0, import_utils2.handlerAll)(props2.onKeyDown, onKeyDown),
|
|
214
|
+
onKeyUp: (0, import_utils2.handlerAll)(props2.onKeyUp, onKeyUp)
|
|
207
215
|
}),
|
|
208
216
|
[
|
|
209
217
|
isIndeterminate,
|
|
@@ -228,12 +236,12 @@ var useCheckbox = ({
|
|
|
228
236
|
...formControlProps,
|
|
229
237
|
...props2,
|
|
230
238
|
ref,
|
|
231
|
-
"data-checked": (0,
|
|
232
|
-
onMouseDown: (0,
|
|
239
|
+
"data-checked": (0, import_utils2.dataAttr)(checked),
|
|
240
|
+
onMouseDown: (0, import_utils2.handlerAll)(props2.onMouseDown, (ev) => {
|
|
233
241
|
ev.preventDefault();
|
|
234
242
|
ev.stopPropagation();
|
|
235
243
|
}),
|
|
236
|
-
onTouchStart: (0,
|
|
244
|
+
onTouchStart: (0, import_utils2.handlerAll)(props2.onTouchStart, (ev) => {
|
|
237
245
|
ev.preventDefault();
|
|
238
246
|
ev.stopPropagation();
|
|
239
247
|
})
|
|
@@ -260,7 +268,7 @@ var Checkbox = (0, import_react.forwardRef)(
|
|
|
260
268
|
const group = useCheckboxGroupContext();
|
|
261
269
|
const { value: groupValue, ...groupProps } = { ...group };
|
|
262
270
|
const control = (0, import_form_control.useFormControl)(props);
|
|
263
|
-
const [styles, mergedProps] = (0, import_core.
|
|
271
|
+
const [styles, mergedProps] = (0, import_core.useComponentMultiStyle)("Checkbox", {
|
|
264
272
|
...groupProps,
|
|
265
273
|
...props
|
|
266
274
|
});
|
|
@@ -278,7 +286,7 @@ var Checkbox = (0, import_react.forwardRef)(
|
|
|
278
286
|
...computedProps
|
|
279
287
|
} = (0, import_core.omitThemeProps)(mergedProps);
|
|
280
288
|
const isCheckedProp = groupValue && computedProps.value ? groupValue.includes(computedProps.value) : computedProps.isChecked;
|
|
281
|
-
const onChange = groupProps.onChange && computedProps.value ? (0,
|
|
289
|
+
const onChange = groupProps.onChange && computedProps.value ? (0, import_utils2.funcAll)(groupProps.onChange, computedProps.onChange) : computedProps.onChange;
|
|
282
290
|
const {
|
|
283
291
|
isChecked,
|
|
284
292
|
isIndeterminate,
|
|
@@ -314,7 +322,7 @@ var Checkbox = (0, import_react.forwardRef)(
|
|
|
314
322
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
315
323
|
import_core.ui.label,
|
|
316
324
|
{
|
|
317
|
-
className: (0,
|
|
325
|
+
className: (0, import_utils2.cx)("ui-checkbox", className),
|
|
318
326
|
...getContainerProps(),
|
|
319
327
|
__css: {
|
|
320
328
|
cursor: "pointer",
|
|
@@ -460,7 +468,7 @@ var IndeterminateIcon = (props) => {
|
|
|
460
468
|
|
|
461
469
|
// src/checkbox-group.tsx
|
|
462
470
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
463
|
-
var isEvent = (value) => value && (0,
|
|
471
|
+
var isEvent = (value) => value && (0, import_utils3.isObject)(value) && (0, import_utils3.isObject)(value.target);
|
|
464
472
|
var useCheckboxGroup = ({
|
|
465
473
|
value: valueProp,
|
|
466
474
|
defaultValue = [],
|
|
@@ -468,7 +476,7 @@ var useCheckboxGroup = ({
|
|
|
468
476
|
isNative,
|
|
469
477
|
...props
|
|
470
478
|
}) => {
|
|
471
|
-
const onChangeRef = (0,
|
|
479
|
+
const onChangeRef = (0, import_utils3.useCallbackRef)(onChangeProp);
|
|
472
480
|
const [value, setValue] = (0, import_use_controllable_state.useControllableState)({
|
|
473
481
|
value: valueProp,
|
|
474
482
|
defaultValue,
|
|
@@ -492,7 +500,7 @@ var useCheckboxGroup = ({
|
|
|
492
500
|
[]
|
|
493
501
|
);
|
|
494
502
|
const getCheckboxProps = (0, import_react2.useCallback)(
|
|
495
|
-
(props2, ref = null) => ({
|
|
503
|
+
(props2 = {}, ref = null) => ({
|
|
496
504
|
...props2,
|
|
497
505
|
ref,
|
|
498
506
|
[isNative ? "checked" : "isChecked"]: value.some(
|
|
@@ -511,10 +519,6 @@ var useCheckboxGroup = ({
|
|
|
511
519
|
getCheckboxProps
|
|
512
520
|
};
|
|
513
521
|
};
|
|
514
|
-
var [CheckboxGroupProvider, useCheckboxGroupContext] = (0, import_utils2.createContext)({
|
|
515
|
-
strict: false,
|
|
516
|
-
name: "CheckboxGroupContext"
|
|
517
|
-
});
|
|
518
522
|
var CheckboxGroup = (0, import_react2.forwardRef)(
|
|
519
523
|
({
|
|
520
524
|
className,
|
|
@@ -534,7 +538,7 @@ var CheckboxGroup = (0, import_react2.forwardRef)(
|
|
|
534
538
|
getContainerProps
|
|
535
539
|
} = useCheckboxGroup(props);
|
|
536
540
|
const { labelId, isRequired, isReadOnly, isDisabled, isInvalid, ...rest } = (0, import_form_control2.useFormControl)(computedProps);
|
|
537
|
-
const validChildren = (0,
|
|
541
|
+
const validChildren = (0, import_utils3.getValidChildren)(children);
|
|
538
542
|
let computedChildren = [];
|
|
539
543
|
if (!validChildren.length && items.length) {
|
|
540
544
|
computedChildren = items.map(({ label, value: value2, ...props2 }, i) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Checkbox, { value: value2, ...props2, children: label }, i));
|
|
@@ -557,7 +561,7 @@ var CheckboxGroup = (0, import_react2.forwardRef)(
|
|
|
557
561
|
import_layouts.Flex,
|
|
558
562
|
{
|
|
559
563
|
ref,
|
|
560
|
-
className: (0,
|
|
564
|
+
className: (0, import_utils3.cx)("ui-checkbox-group", className),
|
|
561
565
|
direction,
|
|
562
566
|
gap: gap != null ? gap : direction === "row" ? "1rem" : void 0,
|
|
563
567
|
...getContainerProps({
|
|
@@ -575,7 +579,6 @@ CheckboxGroup.displayName = "CheckboxGroup";
|
|
|
575
579
|
// Annotate the CommonJS export names for ESM import in node:
|
|
576
580
|
0 && (module.exports = {
|
|
577
581
|
CheckboxGroup,
|
|
578
|
-
useCheckboxGroup
|
|
579
|
-
useCheckboxGroupContext
|
|
582
|
+
useCheckboxGroup
|
|
580
583
|
});
|
|
581
584
|
//# sourceMappingURL=checkbox-group.js.map
|