@seed-design/react-checkbox 0.0.0-alpha-20241030023710 → 0.0.1-rc.0
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/lib/Checkbox.d.ts +12 -0
- package/lib/Checkbox.namespace.d.ts +1 -0
- package/lib/index.d.ts +3 -46
- package/lib/index.js +134 -34
- package/lib/index.js.map +4 -4
- package/lib/index.mjs +141 -34
- package/lib/index.mjs.map +4 -4
- package/lib/useCheckbox.d.ts +1129 -0
- package/lib/useCheckboxContext.d.ts +7 -0
- package/package.json +11 -9
- package/src/Checkbox.namespace.ts +8 -0
- package/src/Checkbox.tsx +67 -0
- package/src/index.ts +12 -133
- package/src/useCheckbox.test.tsx +12 -40
- package/src/useCheckbox.ts +173 -0
- package/src/useCheckboxContext.tsx +19 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type PrimitiveProps } from "@seed-design/react-primitive";
|
|
2
|
+
import type * as React from "react";
|
|
3
|
+
import { type UseCheckboxProps } from "./useCheckbox";
|
|
4
|
+
export interface CheckboxRootProps extends UseCheckboxProps, PrimitiveProps, React.HTMLAttributes<HTMLLabelElement> {
|
|
5
|
+
}
|
|
6
|
+
export declare const CheckboxRoot: React.ForwardRefExoticComponent<CheckboxRootProps & React.RefAttributes<HTMLLabelElement>>;
|
|
7
|
+
export interface CheckboxControlProps extends PrimitiveProps, React.HTMLAttributes<HTMLDivElement> {
|
|
8
|
+
}
|
|
9
|
+
export declare const CheckboxControl: React.ForwardRefExoticComponent<CheckboxControlProps & React.RefAttributes<HTMLDivElement>>;
|
|
10
|
+
export interface CheckboxHiddenInputProps extends PrimitiveProps, React.InputHTMLAttributes<HTMLInputElement> {
|
|
11
|
+
}
|
|
12
|
+
export declare const CheckboxHiddenInput: React.ForwardRefExoticComponent<CheckboxHiddenInputProps & React.RefAttributes<HTMLInputElement>>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { CheckboxRoot as Root, CheckboxControl as Control, CheckboxHiddenInput as HiddenInput, type CheckboxRootProps as RootProps, type CheckboxControlProps as ControlProps, type CheckboxHiddenInputProps as HiddenInputProps, } from "./Checkbox";
|
package/lib/index.d.ts
CHANGED
|
@@ -1,46 +1,3 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
onCheckedChange?: (checked: boolean) => void;
|
|
5
|
-
}
|
|
6
|
-
export declare function useCheckboxState(props: UseCheckboxStateProps): {
|
|
7
|
-
isChecked: boolean;
|
|
8
|
-
setIsChecked: import("react").Dispatch<import("react").SetStateAction<boolean>>;
|
|
9
|
-
isHovered: boolean;
|
|
10
|
-
setIsHovered: import("react").Dispatch<import("react").SetStateAction<boolean>>;
|
|
11
|
-
isPressed: boolean;
|
|
12
|
-
setIsPressed: import("react").Dispatch<import("react").SetStateAction<boolean>>;
|
|
13
|
-
isFocused: boolean;
|
|
14
|
-
setIsFocused: import("react").Dispatch<import("react").SetStateAction<boolean>>;
|
|
15
|
-
isFocusVisible: boolean;
|
|
16
|
-
setIsFocusVisible: import("react").Dispatch<import("react").SetStateAction<boolean>>;
|
|
17
|
-
};
|
|
18
|
-
export interface UseCheckboxProps extends UseCheckboxStateProps {
|
|
19
|
-
disabled?: boolean;
|
|
20
|
-
invalid?: boolean;
|
|
21
|
-
}
|
|
22
|
-
export declare function useCheckbox(props: UseCheckboxProps): {
|
|
23
|
-
isChecked: boolean;
|
|
24
|
-
setIsChecked: import("react").Dispatch<import("react").SetStateAction<boolean>>;
|
|
25
|
-
isFocused: boolean;
|
|
26
|
-
setIsFocused: import("react").Dispatch<import("react").SetStateAction<boolean>>;
|
|
27
|
-
setIsFocusVisible: import("react").Dispatch<import("react").SetStateAction<boolean>>;
|
|
28
|
-
restProps: {};
|
|
29
|
-
stateProps: {
|
|
30
|
-
"data-checked": string;
|
|
31
|
-
"data-hover": string;
|
|
32
|
-
"data-active": string;
|
|
33
|
-
"data-focus": string;
|
|
34
|
-
"data-focus-visible": string;
|
|
35
|
-
"data-disabled": string;
|
|
36
|
-
};
|
|
37
|
-
rootProps: import("react").LabelHTMLAttributes<HTMLLabelElement> & {
|
|
38
|
-
[x: `data-${string}`]: string;
|
|
39
|
-
};
|
|
40
|
-
controlProps: import("react").HTMLAttributes<HTMLElement> & {
|
|
41
|
-
[x: `data-${string}`]: string;
|
|
42
|
-
};
|
|
43
|
-
hiddenInputProps: import("react").InputHTMLAttributes<HTMLInputElement> & {
|
|
44
|
-
[x: `data-${string}`]: string;
|
|
45
|
-
};
|
|
46
|
-
};
|
|
1
|
+
export { CheckboxRoot, CheckboxControl, CheckboxHiddenInput, type CheckboxRootProps, type CheckboxControlProps, type CheckboxHiddenInputProps, } from "./Checkbox";
|
|
2
|
+
export { useCheckboxContext, type UseCheckboxContext } from "./useCheckboxContext";
|
|
3
|
+
export * as Checkbox from "./Checkbox.namespace";
|
package/lib/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
var __defProp = Object.defineProperty;
|
|
2
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
6
6
|
var __export = (target, all) => {
|
|
7
7
|
for (var name in all)
|
|
8
8
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -18,69 +18,103 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
|
|
20
20
|
// src/index.ts
|
|
21
|
-
var
|
|
22
|
-
__export(
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
Checkbox: () => Checkbox_namespace_exports,
|
|
24
|
+
CheckboxControl: () => CheckboxControl,
|
|
25
|
+
CheckboxHiddenInput: () => CheckboxHiddenInput,
|
|
26
|
+
CheckboxRoot: () => CheckboxRoot,
|
|
27
|
+
useCheckboxContext: () => useCheckboxContext
|
|
25
28
|
});
|
|
26
|
-
module.exports = __toCommonJS(
|
|
29
|
+
module.exports = __toCommonJS(index_exports);
|
|
30
|
+
|
|
31
|
+
// src/Checkbox.tsx
|
|
32
|
+
var import_dom_utils2 = require("@seed-design/dom-utils");
|
|
33
|
+
var import_react_primitive = require("@seed-design/react-primitive");
|
|
34
|
+
var import_react3 = require("react");
|
|
35
|
+
|
|
36
|
+
// src/useCheckbox.ts
|
|
27
37
|
var import_react_use_controllable_state = require("@radix-ui/react-use-controllable-state");
|
|
28
38
|
var import_react = require("react");
|
|
29
39
|
var import_dom_utils = require("@seed-design/dom-utils");
|
|
30
40
|
function useCheckboxState(props) {
|
|
31
|
-
|
|
41
|
+
var _a;
|
|
42
|
+
const [isChecked = false, setIsChecked] = (0, import_react_use_controllable_state.useControllableState)({
|
|
32
43
|
prop: props.checked,
|
|
33
44
|
defaultProp: props.defaultChecked,
|
|
34
45
|
onChange: props.onCheckedChange
|
|
35
46
|
});
|
|
36
47
|
const [isHovered, setIsHovered] = (0, import_react.useState)(false);
|
|
37
|
-
const [
|
|
48
|
+
const [isActive, setIsActive] = (0, import_react.useState)(false);
|
|
38
49
|
const [isFocused, setIsFocused] = (0, import_react.useState)(false);
|
|
39
50
|
const [isFocusVisible, setIsFocusVisible] = (0, import_react.useState)(false);
|
|
51
|
+
const inputRef = (0, import_react.useRef)(null);
|
|
52
|
+
const initialCheckedRef = (0, import_react.useRef)(isChecked);
|
|
53
|
+
(0, import_react.useEffect)(() => {
|
|
54
|
+
var _a2;
|
|
55
|
+
const form = (_a2 = inputRef.current) == null ? void 0 : _a2.form;
|
|
56
|
+
if (form) {
|
|
57
|
+
const reset = () => setIsChecked(initialCheckedRef.current);
|
|
58
|
+
form.addEventListener("reset", reset);
|
|
59
|
+
return () => form.removeEventListener("reset", reset);
|
|
60
|
+
}
|
|
61
|
+
}, [setIsChecked]);
|
|
62
|
+
(0, import_react.useEffect)(() => {
|
|
63
|
+
var _a2;
|
|
64
|
+
if (!inputRef.current) return;
|
|
65
|
+
inputRef.current.indeterminate = (_a2 = props.indeterminate) != null ? _a2 : false;
|
|
66
|
+
}, [props.indeterminate]);
|
|
40
67
|
return {
|
|
68
|
+
refs: { input: inputRef },
|
|
69
|
+
isIndeterminate: (_a = props.indeterminate) != null ? _a : false,
|
|
41
70
|
isChecked,
|
|
42
71
|
setIsChecked,
|
|
43
72
|
isHovered,
|
|
44
73
|
setIsHovered,
|
|
45
|
-
|
|
46
|
-
|
|
74
|
+
isActive,
|
|
75
|
+
setIsActive,
|
|
47
76
|
isFocused,
|
|
48
77
|
setIsFocused,
|
|
49
78
|
isFocusVisible,
|
|
50
79
|
setIsFocusVisible
|
|
51
80
|
};
|
|
52
81
|
}
|
|
53
|
-
__name(useCheckboxState, "useCheckboxState");
|
|
54
82
|
function useCheckbox(props) {
|
|
55
|
-
const { checked, defaultChecked, disabled, invalid, onCheckedChange, ...restProps } = props;
|
|
56
83
|
const {
|
|
84
|
+
refs,
|
|
85
|
+
isIndeterminate,
|
|
57
86
|
setIsChecked,
|
|
58
87
|
isChecked,
|
|
59
88
|
setIsHovered,
|
|
60
89
|
isHovered,
|
|
61
|
-
|
|
62
|
-
|
|
90
|
+
setIsActive,
|
|
91
|
+
isActive,
|
|
63
92
|
setIsFocused,
|
|
64
93
|
isFocused,
|
|
65
94
|
setIsFocusVisible,
|
|
66
95
|
isFocusVisible
|
|
67
96
|
} = useCheckboxState(props);
|
|
68
|
-
const stateProps = {
|
|
97
|
+
const stateProps = (0, import_dom_utils.elementProps)({
|
|
69
98
|
"data-checked": (0, import_dom_utils.dataAttr)(isChecked),
|
|
99
|
+
"data-indeterminate": (0, import_dom_utils.dataAttr)(isIndeterminate),
|
|
70
100
|
"data-hover": (0, import_dom_utils.dataAttr)(isHovered),
|
|
71
|
-
"data-active": (0, import_dom_utils.dataAttr)(
|
|
101
|
+
"data-active": (0, import_dom_utils.dataAttr)(isActive),
|
|
72
102
|
"data-focus": (0, import_dom_utils.dataAttr)(isFocused),
|
|
73
103
|
"data-focus-visible": (0, import_dom_utils.dataAttr)(isFocusVisible),
|
|
74
|
-
"data-disabled": (0, import_dom_utils.dataAttr)(props.disabled)
|
|
75
|
-
|
|
76
|
-
|
|
104
|
+
"data-disabled": (0, import_dom_utils.dataAttr)(props.disabled),
|
|
105
|
+
"data-invalid": (0, import_dom_utils.dataAttr)(props.invalid),
|
|
106
|
+
"data-required": (0, import_dom_utils.dataAttr)(props.required)
|
|
107
|
+
});
|
|
108
|
+
const isControlled = props.checked != null;
|
|
77
109
|
return {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
110
|
+
indeterminate: isIndeterminate,
|
|
111
|
+
checked: isChecked,
|
|
112
|
+
setChecked: setIsChecked,
|
|
113
|
+
focused: isFocused,
|
|
114
|
+
setFocused: setIsFocused,
|
|
115
|
+
focusVisible: isFocusVisible,
|
|
116
|
+
setFocusVisible: setIsFocusVisible,
|
|
117
|
+
refs,
|
|
84
118
|
stateProps,
|
|
85
119
|
rootProps: (0, import_dom_utils.labelProps)({
|
|
86
120
|
...stateProps,
|
|
@@ -88,14 +122,14 @@ function useCheckbox(props) {
|
|
|
88
122
|
setIsHovered(true);
|
|
89
123
|
},
|
|
90
124
|
onPointerDown() {
|
|
91
|
-
|
|
125
|
+
setIsActive(true);
|
|
92
126
|
},
|
|
93
127
|
onPointerUp() {
|
|
94
|
-
|
|
128
|
+
setIsActive(false);
|
|
95
129
|
},
|
|
96
130
|
onPointerLeave() {
|
|
97
131
|
setIsHovered(false);
|
|
98
|
-
|
|
132
|
+
setIsActive(false);
|
|
99
133
|
}
|
|
100
134
|
}),
|
|
101
135
|
controlProps: (0, import_dom_utils.elementProps)({
|
|
@@ -104,9 +138,13 @@ function useCheckbox(props) {
|
|
|
104
138
|
}),
|
|
105
139
|
hiddenInputProps: (0, import_dom_utils.inputProps)({
|
|
106
140
|
type: "checkbox",
|
|
107
|
-
|
|
141
|
+
role: "checkbox",
|
|
108
142
|
checked: isControlled ? isChecked : void 0,
|
|
109
|
-
|
|
143
|
+
defaultChecked: !isControlled ? isChecked : void 0,
|
|
144
|
+
disabled: props.disabled,
|
|
145
|
+
required: props.required,
|
|
146
|
+
"aria-invalid": props.invalid,
|
|
147
|
+
style: import_dom_utils.visuallyHidden,
|
|
110
148
|
...stateProps,
|
|
111
149
|
onChange(event) {
|
|
112
150
|
setIsChecked(event.currentTarget.checked);
|
|
@@ -122,17 +160,79 @@ function useCheckbox(props) {
|
|
|
122
160
|
},
|
|
123
161
|
onKeyDown(event) {
|
|
124
162
|
if (event.key === " ") {
|
|
125
|
-
|
|
163
|
+
setIsActive(true);
|
|
126
164
|
}
|
|
127
165
|
},
|
|
128
166
|
onKeyUp(event) {
|
|
129
167
|
if (event.key === " ") {
|
|
130
|
-
|
|
168
|
+
setIsActive(false);
|
|
131
169
|
}
|
|
132
170
|
}
|
|
133
171
|
})
|
|
134
172
|
};
|
|
135
173
|
}
|
|
136
|
-
|
|
137
|
-
|
|
174
|
+
|
|
175
|
+
// src/useCheckboxContext.tsx
|
|
176
|
+
var import_react2 = require("react");
|
|
177
|
+
var CheckboxContext = (0, import_react2.createContext)(null);
|
|
178
|
+
var CheckboxProvider = CheckboxContext.Provider;
|
|
179
|
+
function useCheckboxContext({
|
|
180
|
+
strict = true
|
|
181
|
+
} = {}) {
|
|
182
|
+
const context = (0, import_react2.useContext)(CheckboxContext);
|
|
183
|
+
if (!context && strict) {
|
|
184
|
+
throw new Error("useCheckboxContext must be used within a Checkbox");
|
|
185
|
+
}
|
|
186
|
+
return context;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
// src/Checkbox.tsx
|
|
190
|
+
var import_react_compose_refs = require("@radix-ui/react-compose-refs");
|
|
191
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
192
|
+
var CheckboxRoot = (0, import_react3.forwardRef)((props, ref) => {
|
|
193
|
+
const {
|
|
194
|
+
checked,
|
|
195
|
+
defaultChecked,
|
|
196
|
+
onCheckedChange,
|
|
197
|
+
indeterminate,
|
|
198
|
+
disabled,
|
|
199
|
+
invalid,
|
|
200
|
+
required,
|
|
201
|
+
...otherProps
|
|
202
|
+
} = props;
|
|
203
|
+
const api = useCheckbox({
|
|
204
|
+
checked,
|
|
205
|
+
defaultChecked,
|
|
206
|
+
onCheckedChange,
|
|
207
|
+
indeterminate,
|
|
208
|
+
disabled,
|
|
209
|
+
invalid,
|
|
210
|
+
required
|
|
211
|
+
});
|
|
212
|
+
const mergedProps = (0, import_dom_utils2.mergeProps)(api.rootProps, otherProps);
|
|
213
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CheckboxProvider, { value: api, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_primitive.Primitive.label, { ref, ...mergedProps }) });
|
|
214
|
+
});
|
|
215
|
+
CheckboxRoot.displayName = "CheckboxRoot";
|
|
216
|
+
var CheckboxControl = (0, import_react3.forwardRef)((props, ref) => {
|
|
217
|
+
const { controlProps } = useCheckboxContext();
|
|
218
|
+
const mergedProps = (0, import_dom_utils2.mergeProps)(controlProps, props);
|
|
219
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_primitive.Primitive.div, { ref, ...mergedProps });
|
|
220
|
+
});
|
|
221
|
+
CheckboxControl.displayName = "CheckboxControl";
|
|
222
|
+
var CheckboxHiddenInput = (0, import_react3.forwardRef)(
|
|
223
|
+
(props, ref) => {
|
|
224
|
+
const { refs, hiddenInputProps } = useCheckboxContext();
|
|
225
|
+
const mergedProps = (0, import_dom_utils2.mergeProps)(hiddenInputProps, props);
|
|
226
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_primitive.Primitive.input, { ref: (0, import_react_compose_refs.composeRefs)(refs.input, ref), ...mergedProps });
|
|
227
|
+
}
|
|
228
|
+
);
|
|
229
|
+
CheckboxHiddenInput.displayName = "CheckboxHiddenInput";
|
|
230
|
+
|
|
231
|
+
// src/Checkbox.namespace.ts
|
|
232
|
+
var Checkbox_namespace_exports = {};
|
|
233
|
+
__export(Checkbox_namespace_exports, {
|
|
234
|
+
Control: () => CheckboxControl,
|
|
235
|
+
HiddenInput: () => CheckboxHiddenInput,
|
|
236
|
+
Root: () => CheckboxRoot
|
|
237
|
+
});
|
|
138
238
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../src/index.ts"],
|
|
4
|
-
"sourcesContent": ["import { useControllableState } from \"@radix-ui/react-use-controllable-state\";\nimport { useState } from \"react\";\n\nimport {
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0CAAqC;AACrC,
|
|
6
|
-
"names": []
|
|
3
|
+
"sources": ["../src/index.ts", "../src/Checkbox.tsx", "../src/useCheckbox.ts", "../src/useCheckboxContext.tsx", "../src/Checkbox.namespace.ts"],
|
|
4
|
+
"sourcesContent": ["export {\n CheckboxRoot,\n CheckboxControl,\n CheckboxHiddenInput,\n type CheckboxRootProps,\n type CheckboxControlProps,\n type CheckboxHiddenInputProps,\n} from \"./Checkbox\";\n\nexport { useCheckboxContext, type UseCheckboxContext } from \"./useCheckboxContext\";\n\nexport * as Checkbox from \"./Checkbox.namespace\";\n", "import { mergeProps } from \"@seed-design/dom-utils\";\nimport { Primitive, type PrimitiveProps } from \"@seed-design/react-primitive\";\nimport type * as React from \"react\";\nimport { forwardRef } from \"react\";\nimport { useCheckbox, type UseCheckboxProps } from \"./useCheckbox\";\nimport { CheckboxProvider, useCheckboxContext } from \"./useCheckboxContext\";\nimport { composeRefs } from \"@radix-ui/react-compose-refs\";\n\nexport interface CheckboxRootProps\n extends UseCheckboxProps,\n PrimitiveProps,\n React.HTMLAttributes<HTMLLabelElement> {}\n\nexport const CheckboxRoot = forwardRef<HTMLLabelElement, CheckboxRootProps>((props, ref) => {\n const {\n checked,\n defaultChecked,\n onCheckedChange,\n indeterminate,\n disabled,\n invalid,\n required,\n ...otherProps\n } = props;\n\n const api = useCheckbox({\n checked,\n defaultChecked,\n onCheckedChange,\n indeterminate,\n disabled,\n invalid,\n required,\n });\n const mergedProps = mergeProps(api.rootProps, otherProps);\n\n return (\n <CheckboxProvider value={api}>\n <Primitive.label ref={ref} {...mergedProps} />\n </CheckboxProvider>\n );\n});\nCheckboxRoot.displayName = \"CheckboxRoot\";\n\nexport interface CheckboxControlProps\n extends PrimitiveProps,\n React.HTMLAttributes<HTMLDivElement> {}\n\nexport const CheckboxControl = forwardRef<HTMLDivElement, CheckboxControlProps>((props, ref) => {\n const { controlProps } = useCheckboxContext();\n const mergedProps = mergeProps(controlProps, props);\n return <Primitive.div ref={ref} {...mergedProps} />;\n});\nCheckboxControl.displayName = \"CheckboxControl\";\n\nexport interface CheckboxHiddenInputProps\n extends PrimitiveProps,\n React.InputHTMLAttributes<HTMLInputElement> {}\n\nexport const CheckboxHiddenInput = forwardRef<HTMLInputElement, CheckboxHiddenInputProps>(\n (props, ref) => {\n const { refs, hiddenInputProps } = useCheckboxContext();\n const mergedProps = mergeProps(hiddenInputProps, props);\n return <Primitive.input ref={composeRefs(refs.input, ref)} {...mergedProps} />;\n },\n);\nCheckboxHiddenInput.displayName = \"CheckboxHiddenInput\";\n", "import { useControllableState } from \"@radix-ui/react-use-controllable-state\";\nimport { useEffect, useRef, useState } from \"react\";\n\nimport {\n dataAttr,\n elementProps,\n inputProps,\n labelProps,\n visuallyHidden,\n} from \"@seed-design/dom-utils\";\n\ninterface UseCheckboxStateProps {\n checked?: boolean;\n\n defaultChecked?: boolean;\n\n onCheckedChange?: (checked: boolean) => void;\n\n indeterminate?: boolean;\n}\n\nfunction useCheckboxState(props: UseCheckboxStateProps) {\n const [isChecked = false, setIsChecked] = useControllableState({\n prop: props.checked,\n defaultProp: props.defaultChecked,\n onChange: props.onCheckedChange,\n });\n const [isHovered, setIsHovered] = useState(false);\n const [isActive, setIsActive] = useState(false);\n const [isFocused, setIsFocused] = useState(false);\n const [isFocusVisible, setIsFocusVisible] = useState(false);\n\n const inputRef = useRef<HTMLInputElement>(null);\n const initialCheckedRef = useRef(isChecked);\n\n useEffect(() => {\n const form = inputRef.current?.form;\n if (form) {\n const reset = () => setIsChecked(initialCheckedRef.current);\n form.addEventListener(\"reset\", reset);\n return () => form.removeEventListener(\"reset\", reset);\n }\n }, [setIsChecked]);\n\n useEffect(() => {\n if (!inputRef.current) return;\n inputRef.current.indeterminate = props.indeterminate ?? false;\n }, [props.indeterminate]);\n\n return {\n refs: { input: inputRef },\n isIndeterminate: props.indeterminate ?? false,\n isChecked,\n setIsChecked,\n isHovered,\n setIsHovered,\n isActive,\n setIsActive,\n isFocused,\n setIsFocused,\n isFocusVisible,\n setIsFocusVisible,\n };\n}\n\nexport interface UseCheckboxProps extends UseCheckboxStateProps {\n disabled?: boolean;\n\n invalid?: boolean;\n\n required?: boolean;\n}\n\nexport type UseCheckboxReturn = ReturnType<typeof useCheckbox>;\n\nexport function useCheckbox(props: UseCheckboxProps) {\n const {\n refs,\n isIndeterminate,\n setIsChecked,\n isChecked,\n setIsHovered,\n isHovered,\n setIsActive,\n isActive,\n setIsFocused,\n isFocused,\n setIsFocusVisible,\n isFocusVisible,\n } = useCheckboxState(props);\n\n const stateProps = elementProps({\n \"data-checked\": dataAttr(isChecked),\n \"data-indeterminate\": dataAttr(isIndeterminate),\n \"data-hover\": dataAttr(isHovered),\n \"data-active\": dataAttr(isActive),\n \"data-focus\": dataAttr(isFocused),\n \"data-focus-visible\": dataAttr(isFocusVisible),\n \"data-disabled\": dataAttr(props.disabled),\n \"data-invalid\": dataAttr(props.invalid),\n \"data-required\": dataAttr(props.required),\n });\n\n const isControlled = props.checked != null;\n\n return {\n indeterminate: isIndeterminate,\n checked: isChecked,\n setChecked: setIsChecked,\n focused: isFocused,\n setFocused: setIsFocused,\n focusVisible: isFocusVisible,\n setFocusVisible: setIsFocusVisible,\n\n refs,\n stateProps,\n rootProps: labelProps({\n ...stateProps,\n onPointerMove() {\n setIsHovered(true);\n },\n onPointerDown() {\n setIsActive(true);\n },\n onPointerUp() {\n setIsActive(false);\n },\n onPointerLeave() {\n setIsHovered(false);\n setIsActive(false);\n },\n }),\n\n controlProps: elementProps({\n ...stateProps,\n \"aria-hidden\": true,\n }),\n\n hiddenInputProps: inputProps({\n type: \"checkbox\",\n role: \"checkbox\",\n checked: isControlled ? isChecked : undefined,\n defaultChecked: !isControlled ? isChecked : undefined,\n disabled: props.disabled,\n required: props.required,\n \"aria-invalid\": props.invalid,\n style: visuallyHidden,\n ...stateProps,\n onChange(event) {\n setIsChecked(event.currentTarget.checked);\n setIsFocusVisible(event.target.matches(\":focus-visible\"));\n },\n onFocus(event) {\n setIsFocused(true);\n setIsFocusVisible(event.target.matches(\":focus-visible\"));\n },\n onBlur() {\n setIsFocused(false);\n setIsFocusVisible(false);\n },\n onKeyDown(event) {\n if (event.key === \" \") {\n setIsActive(true);\n }\n },\n onKeyUp(event) {\n if (event.key === \" \") {\n setIsActive(false);\n }\n },\n }),\n };\n}\n", "import { createContext, useContext } from \"react\";\nimport type { UseCheckboxReturn } from \"./useCheckbox\";\n\nexport interface UseCheckboxContext extends UseCheckboxReturn {}\n\nconst CheckboxContext = createContext<UseCheckboxContext | null>(null);\n\nexport const CheckboxProvider = CheckboxContext.Provider;\n\nexport function useCheckboxContext<T extends boolean | undefined = true>({\n strict = true,\n}: { strict?: T } = {}): T extends false ? UseCheckboxContext | null : UseCheckboxContext {\n const context = useContext(CheckboxContext);\n if (!context && strict) {\n throw new Error(\"useCheckboxContext must be used within a Checkbox\");\n }\n\n return context as UseCheckboxContext;\n}\n", "export {\n CheckboxRoot as Root,\n CheckboxControl as Control,\n CheckboxHiddenInput as HiddenInput,\n type CheckboxRootProps as RootProps,\n type CheckboxControlProps as ControlProps,\n type CheckboxHiddenInputProps as HiddenInputProps,\n} from \"./Checkbox\";\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": ["import_dom_utils", "import_react", "_a", "import_react"]
|
|
7
7
|
}
|
package/lib/index.mjs
CHANGED
|
@@ -1,64 +1,102 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
|
-
var
|
|
2
|
+
var __export = (target, all) => {
|
|
3
|
+
for (var name in all)
|
|
4
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
// src/Checkbox.tsx
|
|
8
|
+
import { mergeProps } from "@seed-design/dom-utils";
|
|
9
|
+
import { Primitive } from "@seed-design/react-primitive";
|
|
10
|
+
import { forwardRef } from "react";
|
|
3
11
|
|
|
4
|
-
// src/
|
|
12
|
+
// src/useCheckbox.ts
|
|
5
13
|
import { useControllableState } from "@radix-ui/react-use-controllable-state";
|
|
6
|
-
import { useState } from "react";
|
|
7
|
-
import {
|
|
14
|
+
import { useEffect, useRef, useState } from "react";
|
|
15
|
+
import {
|
|
16
|
+
dataAttr,
|
|
17
|
+
elementProps,
|
|
18
|
+
inputProps,
|
|
19
|
+
labelProps,
|
|
20
|
+
visuallyHidden
|
|
21
|
+
} from "@seed-design/dom-utils";
|
|
8
22
|
function useCheckboxState(props) {
|
|
9
|
-
|
|
23
|
+
var _a;
|
|
24
|
+
const [isChecked = false, setIsChecked] = useControllableState({
|
|
10
25
|
prop: props.checked,
|
|
11
26
|
defaultProp: props.defaultChecked,
|
|
12
27
|
onChange: props.onCheckedChange
|
|
13
28
|
});
|
|
14
29
|
const [isHovered, setIsHovered] = useState(false);
|
|
15
|
-
const [
|
|
30
|
+
const [isActive, setIsActive] = useState(false);
|
|
16
31
|
const [isFocused, setIsFocused] = useState(false);
|
|
17
32
|
const [isFocusVisible, setIsFocusVisible] = useState(false);
|
|
33
|
+
const inputRef = useRef(null);
|
|
34
|
+
const initialCheckedRef = useRef(isChecked);
|
|
35
|
+
useEffect(() => {
|
|
36
|
+
var _a2;
|
|
37
|
+
const form = (_a2 = inputRef.current) == null ? void 0 : _a2.form;
|
|
38
|
+
if (form) {
|
|
39
|
+
const reset = () => setIsChecked(initialCheckedRef.current);
|
|
40
|
+
form.addEventListener("reset", reset);
|
|
41
|
+
return () => form.removeEventListener("reset", reset);
|
|
42
|
+
}
|
|
43
|
+
}, [setIsChecked]);
|
|
44
|
+
useEffect(() => {
|
|
45
|
+
var _a2;
|
|
46
|
+
if (!inputRef.current) return;
|
|
47
|
+
inputRef.current.indeterminate = (_a2 = props.indeterminate) != null ? _a2 : false;
|
|
48
|
+
}, [props.indeterminate]);
|
|
18
49
|
return {
|
|
50
|
+
refs: { input: inputRef },
|
|
51
|
+
isIndeterminate: (_a = props.indeterminate) != null ? _a : false,
|
|
19
52
|
isChecked,
|
|
20
53
|
setIsChecked,
|
|
21
54
|
isHovered,
|
|
22
55
|
setIsHovered,
|
|
23
|
-
|
|
24
|
-
|
|
56
|
+
isActive,
|
|
57
|
+
setIsActive,
|
|
25
58
|
isFocused,
|
|
26
59
|
setIsFocused,
|
|
27
60
|
isFocusVisible,
|
|
28
61
|
setIsFocusVisible
|
|
29
62
|
};
|
|
30
63
|
}
|
|
31
|
-
__name(useCheckboxState, "useCheckboxState");
|
|
32
64
|
function useCheckbox(props) {
|
|
33
|
-
const { checked, defaultChecked, disabled, invalid, onCheckedChange, ...restProps } = props;
|
|
34
65
|
const {
|
|
66
|
+
refs,
|
|
67
|
+
isIndeterminate,
|
|
35
68
|
setIsChecked,
|
|
36
69
|
isChecked,
|
|
37
70
|
setIsHovered,
|
|
38
71
|
isHovered,
|
|
39
|
-
|
|
40
|
-
|
|
72
|
+
setIsActive,
|
|
73
|
+
isActive,
|
|
41
74
|
setIsFocused,
|
|
42
75
|
isFocused,
|
|
43
76
|
setIsFocusVisible,
|
|
44
77
|
isFocusVisible
|
|
45
78
|
} = useCheckboxState(props);
|
|
46
|
-
const stateProps = {
|
|
79
|
+
const stateProps = elementProps({
|
|
47
80
|
"data-checked": dataAttr(isChecked),
|
|
81
|
+
"data-indeterminate": dataAttr(isIndeterminate),
|
|
48
82
|
"data-hover": dataAttr(isHovered),
|
|
49
|
-
"data-active": dataAttr(
|
|
83
|
+
"data-active": dataAttr(isActive),
|
|
50
84
|
"data-focus": dataAttr(isFocused),
|
|
51
85
|
"data-focus-visible": dataAttr(isFocusVisible),
|
|
52
|
-
"data-disabled": dataAttr(props.disabled)
|
|
53
|
-
|
|
54
|
-
|
|
86
|
+
"data-disabled": dataAttr(props.disabled),
|
|
87
|
+
"data-invalid": dataAttr(props.invalid),
|
|
88
|
+
"data-required": dataAttr(props.required)
|
|
89
|
+
});
|
|
90
|
+
const isControlled = props.checked != null;
|
|
55
91
|
return {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
92
|
+
indeterminate: isIndeterminate,
|
|
93
|
+
checked: isChecked,
|
|
94
|
+
setChecked: setIsChecked,
|
|
95
|
+
focused: isFocused,
|
|
96
|
+
setFocused: setIsFocused,
|
|
97
|
+
focusVisible: isFocusVisible,
|
|
98
|
+
setFocusVisible: setIsFocusVisible,
|
|
99
|
+
refs,
|
|
62
100
|
stateProps,
|
|
63
101
|
rootProps: labelProps({
|
|
64
102
|
...stateProps,
|
|
@@ -66,14 +104,14 @@ function useCheckbox(props) {
|
|
|
66
104
|
setIsHovered(true);
|
|
67
105
|
},
|
|
68
106
|
onPointerDown() {
|
|
69
|
-
|
|
107
|
+
setIsActive(true);
|
|
70
108
|
},
|
|
71
109
|
onPointerUp() {
|
|
72
|
-
|
|
110
|
+
setIsActive(false);
|
|
73
111
|
},
|
|
74
112
|
onPointerLeave() {
|
|
75
113
|
setIsHovered(false);
|
|
76
|
-
|
|
114
|
+
setIsActive(false);
|
|
77
115
|
}
|
|
78
116
|
}),
|
|
79
117
|
controlProps: elementProps({
|
|
@@ -82,9 +120,13 @@ function useCheckbox(props) {
|
|
|
82
120
|
}),
|
|
83
121
|
hiddenInputProps: inputProps({
|
|
84
122
|
type: "checkbox",
|
|
85
|
-
|
|
123
|
+
role: "checkbox",
|
|
86
124
|
checked: isControlled ? isChecked : void 0,
|
|
87
|
-
|
|
125
|
+
defaultChecked: !isControlled ? isChecked : void 0,
|
|
126
|
+
disabled: props.disabled,
|
|
127
|
+
required: props.required,
|
|
128
|
+
"aria-invalid": props.invalid,
|
|
129
|
+
style: visuallyHidden,
|
|
88
130
|
...stateProps,
|
|
89
131
|
onChange(event) {
|
|
90
132
|
setIsChecked(event.currentTarget.checked);
|
|
@@ -100,21 +142,86 @@ function useCheckbox(props) {
|
|
|
100
142
|
},
|
|
101
143
|
onKeyDown(event) {
|
|
102
144
|
if (event.key === " ") {
|
|
103
|
-
|
|
145
|
+
setIsActive(true);
|
|
104
146
|
}
|
|
105
147
|
},
|
|
106
148
|
onKeyUp(event) {
|
|
107
149
|
if (event.key === " ") {
|
|
108
|
-
|
|
150
|
+
setIsActive(false);
|
|
109
151
|
}
|
|
110
152
|
}
|
|
111
153
|
})
|
|
112
154
|
};
|
|
113
155
|
}
|
|
114
|
-
|
|
156
|
+
|
|
157
|
+
// src/useCheckboxContext.tsx
|
|
158
|
+
import { createContext, useContext } from "react";
|
|
159
|
+
var CheckboxContext = createContext(null);
|
|
160
|
+
var CheckboxProvider = CheckboxContext.Provider;
|
|
161
|
+
function useCheckboxContext({
|
|
162
|
+
strict = true
|
|
163
|
+
} = {}) {
|
|
164
|
+
const context = useContext(CheckboxContext);
|
|
165
|
+
if (!context && strict) {
|
|
166
|
+
throw new Error("useCheckboxContext must be used within a Checkbox");
|
|
167
|
+
}
|
|
168
|
+
return context;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// src/Checkbox.tsx
|
|
172
|
+
import { composeRefs } from "@radix-ui/react-compose-refs";
|
|
173
|
+
import { jsx } from "react/jsx-runtime";
|
|
174
|
+
var CheckboxRoot = forwardRef((props, ref) => {
|
|
175
|
+
const {
|
|
176
|
+
checked,
|
|
177
|
+
defaultChecked,
|
|
178
|
+
onCheckedChange,
|
|
179
|
+
indeterminate,
|
|
180
|
+
disabled,
|
|
181
|
+
invalid,
|
|
182
|
+
required,
|
|
183
|
+
...otherProps
|
|
184
|
+
} = props;
|
|
185
|
+
const api = useCheckbox({
|
|
186
|
+
checked,
|
|
187
|
+
defaultChecked,
|
|
188
|
+
onCheckedChange,
|
|
189
|
+
indeterminate,
|
|
190
|
+
disabled,
|
|
191
|
+
invalid,
|
|
192
|
+
required
|
|
193
|
+
});
|
|
194
|
+
const mergedProps = mergeProps(api.rootProps, otherProps);
|
|
195
|
+
return /* @__PURE__ */ jsx(CheckboxProvider, { value: api, children: /* @__PURE__ */ jsx(Primitive.label, { ref, ...mergedProps }) });
|
|
196
|
+
});
|
|
197
|
+
CheckboxRoot.displayName = "CheckboxRoot";
|
|
198
|
+
var CheckboxControl = forwardRef((props, ref) => {
|
|
199
|
+
const { controlProps } = useCheckboxContext();
|
|
200
|
+
const mergedProps = mergeProps(controlProps, props);
|
|
201
|
+
return /* @__PURE__ */ jsx(Primitive.div, { ref, ...mergedProps });
|
|
202
|
+
});
|
|
203
|
+
CheckboxControl.displayName = "CheckboxControl";
|
|
204
|
+
var CheckboxHiddenInput = forwardRef(
|
|
205
|
+
(props, ref) => {
|
|
206
|
+
const { refs, hiddenInputProps } = useCheckboxContext();
|
|
207
|
+
const mergedProps = mergeProps(hiddenInputProps, props);
|
|
208
|
+
return /* @__PURE__ */ jsx(Primitive.input, { ref: composeRefs(refs.input, ref), ...mergedProps });
|
|
209
|
+
}
|
|
210
|
+
);
|
|
211
|
+
CheckboxHiddenInput.displayName = "CheckboxHiddenInput";
|
|
212
|
+
|
|
213
|
+
// src/Checkbox.namespace.ts
|
|
214
|
+
var Checkbox_namespace_exports = {};
|
|
215
|
+
__export(Checkbox_namespace_exports, {
|
|
216
|
+
Control: () => CheckboxControl,
|
|
217
|
+
HiddenInput: () => CheckboxHiddenInput,
|
|
218
|
+
Root: () => CheckboxRoot
|
|
219
|
+
});
|
|
115
220
|
export {
|
|
116
|
-
|
|
117
|
-
|
|
221
|
+
Checkbox_namespace_exports as Checkbox,
|
|
222
|
+
CheckboxControl,
|
|
223
|
+
CheckboxHiddenInput,
|
|
224
|
+
CheckboxRoot,
|
|
225
|
+
useCheckboxContext
|
|
118
226
|
};
|
|
119
|
-
/*! For license information please see index.mjs.LEGAL.txt */
|
|
120
227
|
//# sourceMappingURL=index.mjs.map
|