@seed-design/react-checkbox 0.0.1 → 0.0.3
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-12s-BeV5Lkaw.js +184 -0
- package/lib/Checkbox-12s-Y3jZEb8V.cjs +187 -0
- package/lib/index.cjs +8 -188
- package/lib/index.d.ts +18 -8
- package/lib/index.js +3 -182
- package/package.json +8 -6
- package/src/Checkbox.tsx +2 -0
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { elementProps, dataAttr, inputProps, labelProps, visuallyHidden, mergeProps } from '@seed-design/dom-utils';
|
|
4
|
+
import { Primitive } from '@seed-design/react-primitive';
|
|
5
|
+
import { useState, useRef, useEffect, createContext, useContext, forwardRef } from 'react';
|
|
6
|
+
import { useControllableState } from '@radix-ui/react-use-controllable-state';
|
|
7
|
+
import { composeRefs } from '@radix-ui/react-compose-refs';
|
|
8
|
+
|
|
9
|
+
function useCheckboxState(props) {
|
|
10
|
+
const [isChecked = false, setIsChecked] = useControllableState({
|
|
11
|
+
prop: props.checked,
|
|
12
|
+
defaultProp: props.defaultChecked,
|
|
13
|
+
onChange: props.onCheckedChange
|
|
14
|
+
});
|
|
15
|
+
const [isHovered, setIsHovered] = useState(false);
|
|
16
|
+
const [isActive, setIsActive] = useState(false);
|
|
17
|
+
const [isFocused, setIsFocused] = useState(false);
|
|
18
|
+
const [isFocusVisible, setIsFocusVisible] = useState(false);
|
|
19
|
+
const inputRef = useRef(null);
|
|
20
|
+
const initialCheckedRef = useRef(isChecked);
|
|
21
|
+
useEffect(()=>{
|
|
22
|
+
const form = inputRef.current?.form;
|
|
23
|
+
if (form) {
|
|
24
|
+
const reset = ()=>setIsChecked(initialCheckedRef.current);
|
|
25
|
+
form.addEventListener("reset", reset);
|
|
26
|
+
return ()=>form.removeEventListener("reset", reset);
|
|
27
|
+
}
|
|
28
|
+
}, [
|
|
29
|
+
setIsChecked
|
|
30
|
+
]);
|
|
31
|
+
useEffect(()=>{
|
|
32
|
+
if (!inputRef.current) return;
|
|
33
|
+
inputRef.current.indeterminate = props.indeterminate ?? false;
|
|
34
|
+
}, [
|
|
35
|
+
props.indeterminate
|
|
36
|
+
]);
|
|
37
|
+
return {
|
|
38
|
+
refs: {
|
|
39
|
+
input: inputRef
|
|
40
|
+
},
|
|
41
|
+
isIndeterminate: props.indeterminate ?? false,
|
|
42
|
+
isChecked,
|
|
43
|
+
setIsChecked,
|
|
44
|
+
isHovered,
|
|
45
|
+
setIsHovered,
|
|
46
|
+
isActive,
|
|
47
|
+
setIsActive,
|
|
48
|
+
isFocused,
|
|
49
|
+
setIsFocused,
|
|
50
|
+
isFocusVisible,
|
|
51
|
+
setIsFocusVisible
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
function useCheckbox(props) {
|
|
55
|
+
const { refs, isIndeterminate, setIsChecked, isChecked, setIsHovered, isHovered, setIsActive, isActive, setIsFocused, isFocused, setIsFocusVisible, isFocusVisible } = useCheckboxState(props);
|
|
56
|
+
const stateProps = elementProps({
|
|
57
|
+
"data-checked": dataAttr(isChecked),
|
|
58
|
+
"data-indeterminate": dataAttr(isIndeterminate),
|
|
59
|
+
"data-hover": dataAttr(isHovered),
|
|
60
|
+
"data-active": dataAttr(isActive),
|
|
61
|
+
"data-focus": dataAttr(isFocused),
|
|
62
|
+
"data-focus-visible": dataAttr(isFocusVisible),
|
|
63
|
+
"data-disabled": dataAttr(props.disabled),
|
|
64
|
+
"data-invalid": dataAttr(props.invalid),
|
|
65
|
+
"data-required": dataAttr(props.required)
|
|
66
|
+
});
|
|
67
|
+
const isControlled = props.checked != null;
|
|
68
|
+
return {
|
|
69
|
+
indeterminate: isIndeterminate,
|
|
70
|
+
checked: isChecked,
|
|
71
|
+
setChecked: setIsChecked,
|
|
72
|
+
focused: isFocused,
|
|
73
|
+
setFocused: setIsFocused,
|
|
74
|
+
focusVisible: isFocusVisible,
|
|
75
|
+
setFocusVisible: setIsFocusVisible,
|
|
76
|
+
refs,
|
|
77
|
+
stateProps,
|
|
78
|
+
rootProps: labelProps({
|
|
79
|
+
...stateProps,
|
|
80
|
+
onPointerMove () {
|
|
81
|
+
setIsHovered(true);
|
|
82
|
+
},
|
|
83
|
+
onPointerDown () {
|
|
84
|
+
setIsActive(true);
|
|
85
|
+
},
|
|
86
|
+
onPointerUp () {
|
|
87
|
+
setIsActive(false);
|
|
88
|
+
},
|
|
89
|
+
onPointerLeave () {
|
|
90
|
+
setIsHovered(false);
|
|
91
|
+
setIsActive(false);
|
|
92
|
+
}
|
|
93
|
+
}),
|
|
94
|
+
controlProps: elementProps({
|
|
95
|
+
...stateProps,
|
|
96
|
+
"aria-hidden": true
|
|
97
|
+
}),
|
|
98
|
+
hiddenInputProps: inputProps({
|
|
99
|
+
type: "checkbox",
|
|
100
|
+
role: "checkbox",
|
|
101
|
+
checked: isControlled ? isChecked : undefined,
|
|
102
|
+
defaultChecked: !isControlled ? isChecked : undefined,
|
|
103
|
+
disabled: props.disabled,
|
|
104
|
+
required: props.required,
|
|
105
|
+
"aria-invalid": props.invalid,
|
|
106
|
+
style: visuallyHidden,
|
|
107
|
+
...stateProps,
|
|
108
|
+
onChange (event) {
|
|
109
|
+
setIsChecked(event.currentTarget.checked);
|
|
110
|
+
setIsFocusVisible(event.target.matches(":focus-visible"));
|
|
111
|
+
},
|
|
112
|
+
onFocus (event) {
|
|
113
|
+
setIsFocused(true);
|
|
114
|
+
setIsFocusVisible(event.target.matches(":focus-visible"));
|
|
115
|
+
},
|
|
116
|
+
onBlur () {
|
|
117
|
+
setIsFocused(false);
|
|
118
|
+
setIsFocusVisible(false);
|
|
119
|
+
},
|
|
120
|
+
onKeyDown (event) {
|
|
121
|
+
if (event.key === " ") {
|
|
122
|
+
setIsActive(true);
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
onKeyUp (event) {
|
|
126
|
+
if (event.key === " ") {
|
|
127
|
+
setIsActive(false);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
})
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
const CheckboxContext = /*#__PURE__*/ createContext(null);
|
|
135
|
+
const CheckboxProvider = CheckboxContext.Provider;
|
|
136
|
+
function useCheckboxContext({ strict = true } = {}) {
|
|
137
|
+
const context = useContext(CheckboxContext);
|
|
138
|
+
if (!context && strict) {
|
|
139
|
+
throw new Error("useCheckboxContext must be used within a Checkbox");
|
|
140
|
+
}
|
|
141
|
+
return context;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
const CheckboxRoot = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
145
|
+
const { checked, defaultChecked, onCheckedChange, indeterminate, disabled, invalid, required, ...otherProps } = props;
|
|
146
|
+
const api = useCheckbox({
|
|
147
|
+
checked,
|
|
148
|
+
defaultChecked,
|
|
149
|
+
onCheckedChange,
|
|
150
|
+
indeterminate,
|
|
151
|
+
disabled,
|
|
152
|
+
invalid,
|
|
153
|
+
required
|
|
154
|
+
});
|
|
155
|
+
const mergedProps = mergeProps(api.rootProps, otherProps);
|
|
156
|
+
return /*#__PURE__*/ jsx(CheckboxProvider, {
|
|
157
|
+
value: api,
|
|
158
|
+
children: /*#__PURE__*/ jsx(Primitive.label, {
|
|
159
|
+
ref: ref,
|
|
160
|
+
...mergedProps
|
|
161
|
+
})
|
|
162
|
+
});
|
|
163
|
+
});
|
|
164
|
+
CheckboxRoot.displayName = "CheckboxRoot";
|
|
165
|
+
const CheckboxControl = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
166
|
+
const { controlProps } = useCheckboxContext();
|
|
167
|
+
const mergedProps = mergeProps(controlProps, props);
|
|
168
|
+
return /*#__PURE__*/ jsx(Primitive.div, {
|
|
169
|
+
ref: ref,
|
|
170
|
+
...mergedProps
|
|
171
|
+
});
|
|
172
|
+
});
|
|
173
|
+
CheckboxControl.displayName = "CheckboxControl";
|
|
174
|
+
const CheckboxHiddenInput = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
175
|
+
const { refs, hiddenInputProps } = useCheckboxContext();
|
|
176
|
+
const mergedProps = mergeProps(hiddenInputProps, props);
|
|
177
|
+
return /*#__PURE__*/ jsx(Primitive.input, {
|
|
178
|
+
ref: composeRefs(refs.input, ref),
|
|
179
|
+
...mergedProps
|
|
180
|
+
});
|
|
181
|
+
});
|
|
182
|
+
CheckboxHiddenInput.displayName = "CheckboxHiddenInput";
|
|
183
|
+
|
|
184
|
+
export { CheckboxControl as C, CheckboxHiddenInput as a, CheckboxRoot as b, useCheckboxContext as u };
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
3
|
+
var domUtils = require('@seed-design/dom-utils');
|
|
4
|
+
var reactPrimitive = require('@seed-design/react-primitive');
|
|
5
|
+
var react = require('react');
|
|
6
|
+
var reactUseControllableState = require('@radix-ui/react-use-controllable-state');
|
|
7
|
+
var reactComposeRefs = require('@radix-ui/react-compose-refs');
|
|
8
|
+
|
|
9
|
+
function useCheckboxState(props) {
|
|
10
|
+
const [isChecked = false, setIsChecked] = reactUseControllableState.useControllableState({
|
|
11
|
+
prop: props.checked,
|
|
12
|
+
defaultProp: props.defaultChecked,
|
|
13
|
+
onChange: props.onCheckedChange
|
|
14
|
+
});
|
|
15
|
+
const [isHovered, setIsHovered] = react.useState(false);
|
|
16
|
+
const [isActive, setIsActive] = react.useState(false);
|
|
17
|
+
const [isFocused, setIsFocused] = react.useState(false);
|
|
18
|
+
const [isFocusVisible, setIsFocusVisible] = react.useState(false);
|
|
19
|
+
const inputRef = react.useRef(null);
|
|
20
|
+
const initialCheckedRef = react.useRef(isChecked);
|
|
21
|
+
react.useEffect(()=>{
|
|
22
|
+
const form = inputRef.current?.form;
|
|
23
|
+
if (form) {
|
|
24
|
+
const reset = ()=>setIsChecked(initialCheckedRef.current);
|
|
25
|
+
form.addEventListener("reset", reset);
|
|
26
|
+
return ()=>form.removeEventListener("reset", reset);
|
|
27
|
+
}
|
|
28
|
+
}, [
|
|
29
|
+
setIsChecked
|
|
30
|
+
]);
|
|
31
|
+
react.useEffect(()=>{
|
|
32
|
+
if (!inputRef.current) return;
|
|
33
|
+
inputRef.current.indeterminate = props.indeterminate ?? false;
|
|
34
|
+
}, [
|
|
35
|
+
props.indeterminate
|
|
36
|
+
]);
|
|
37
|
+
return {
|
|
38
|
+
refs: {
|
|
39
|
+
input: inputRef
|
|
40
|
+
},
|
|
41
|
+
isIndeterminate: props.indeterminate ?? false,
|
|
42
|
+
isChecked,
|
|
43
|
+
setIsChecked,
|
|
44
|
+
isHovered,
|
|
45
|
+
setIsHovered,
|
|
46
|
+
isActive,
|
|
47
|
+
setIsActive,
|
|
48
|
+
isFocused,
|
|
49
|
+
setIsFocused,
|
|
50
|
+
isFocusVisible,
|
|
51
|
+
setIsFocusVisible
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
function useCheckbox(props) {
|
|
55
|
+
const { refs, isIndeterminate, setIsChecked, isChecked, setIsHovered, isHovered, setIsActive, isActive, setIsFocused, isFocused, setIsFocusVisible, isFocusVisible } = useCheckboxState(props);
|
|
56
|
+
const stateProps = domUtils.elementProps({
|
|
57
|
+
"data-checked": domUtils.dataAttr(isChecked),
|
|
58
|
+
"data-indeterminate": domUtils.dataAttr(isIndeterminate),
|
|
59
|
+
"data-hover": domUtils.dataAttr(isHovered),
|
|
60
|
+
"data-active": domUtils.dataAttr(isActive),
|
|
61
|
+
"data-focus": domUtils.dataAttr(isFocused),
|
|
62
|
+
"data-focus-visible": domUtils.dataAttr(isFocusVisible),
|
|
63
|
+
"data-disabled": domUtils.dataAttr(props.disabled),
|
|
64
|
+
"data-invalid": domUtils.dataAttr(props.invalid),
|
|
65
|
+
"data-required": domUtils.dataAttr(props.required)
|
|
66
|
+
});
|
|
67
|
+
const isControlled = props.checked != null;
|
|
68
|
+
return {
|
|
69
|
+
indeterminate: isIndeterminate,
|
|
70
|
+
checked: isChecked,
|
|
71
|
+
setChecked: setIsChecked,
|
|
72
|
+
focused: isFocused,
|
|
73
|
+
setFocused: setIsFocused,
|
|
74
|
+
focusVisible: isFocusVisible,
|
|
75
|
+
setFocusVisible: setIsFocusVisible,
|
|
76
|
+
refs,
|
|
77
|
+
stateProps,
|
|
78
|
+
rootProps: domUtils.labelProps({
|
|
79
|
+
...stateProps,
|
|
80
|
+
onPointerMove () {
|
|
81
|
+
setIsHovered(true);
|
|
82
|
+
},
|
|
83
|
+
onPointerDown () {
|
|
84
|
+
setIsActive(true);
|
|
85
|
+
},
|
|
86
|
+
onPointerUp () {
|
|
87
|
+
setIsActive(false);
|
|
88
|
+
},
|
|
89
|
+
onPointerLeave () {
|
|
90
|
+
setIsHovered(false);
|
|
91
|
+
setIsActive(false);
|
|
92
|
+
}
|
|
93
|
+
}),
|
|
94
|
+
controlProps: domUtils.elementProps({
|
|
95
|
+
...stateProps,
|
|
96
|
+
"aria-hidden": true
|
|
97
|
+
}),
|
|
98
|
+
hiddenInputProps: domUtils.inputProps({
|
|
99
|
+
type: "checkbox",
|
|
100
|
+
role: "checkbox",
|
|
101
|
+
checked: isControlled ? isChecked : undefined,
|
|
102
|
+
defaultChecked: !isControlled ? isChecked : undefined,
|
|
103
|
+
disabled: props.disabled,
|
|
104
|
+
required: props.required,
|
|
105
|
+
"aria-invalid": props.invalid,
|
|
106
|
+
style: domUtils.visuallyHidden,
|
|
107
|
+
...stateProps,
|
|
108
|
+
onChange (event) {
|
|
109
|
+
setIsChecked(event.currentTarget.checked);
|
|
110
|
+
setIsFocusVisible(event.target.matches(":focus-visible"));
|
|
111
|
+
},
|
|
112
|
+
onFocus (event) {
|
|
113
|
+
setIsFocused(true);
|
|
114
|
+
setIsFocusVisible(event.target.matches(":focus-visible"));
|
|
115
|
+
},
|
|
116
|
+
onBlur () {
|
|
117
|
+
setIsFocused(false);
|
|
118
|
+
setIsFocusVisible(false);
|
|
119
|
+
},
|
|
120
|
+
onKeyDown (event) {
|
|
121
|
+
if (event.key === " ") {
|
|
122
|
+
setIsActive(true);
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
onKeyUp (event) {
|
|
126
|
+
if (event.key === " ") {
|
|
127
|
+
setIsActive(false);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
})
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
const CheckboxContext = /*#__PURE__*/ react.createContext(null);
|
|
135
|
+
const CheckboxProvider = CheckboxContext.Provider;
|
|
136
|
+
function useCheckboxContext({ strict = true } = {}) {
|
|
137
|
+
const context = react.useContext(CheckboxContext);
|
|
138
|
+
if (!context && strict) {
|
|
139
|
+
throw new Error("useCheckboxContext must be used within a Checkbox");
|
|
140
|
+
}
|
|
141
|
+
return context;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
const CheckboxRoot = /*#__PURE__*/ react.forwardRef((props, ref)=>{
|
|
145
|
+
const { checked, defaultChecked, onCheckedChange, indeterminate, disabled, invalid, required, ...otherProps } = props;
|
|
146
|
+
const api = useCheckbox({
|
|
147
|
+
checked,
|
|
148
|
+
defaultChecked,
|
|
149
|
+
onCheckedChange,
|
|
150
|
+
indeterminate,
|
|
151
|
+
disabled,
|
|
152
|
+
invalid,
|
|
153
|
+
required
|
|
154
|
+
});
|
|
155
|
+
const mergedProps = domUtils.mergeProps(api.rootProps, otherProps);
|
|
156
|
+
return /*#__PURE__*/ jsxRuntime.jsx(CheckboxProvider, {
|
|
157
|
+
value: api,
|
|
158
|
+
children: /*#__PURE__*/ jsxRuntime.jsx(reactPrimitive.Primitive.label, {
|
|
159
|
+
ref: ref,
|
|
160
|
+
...mergedProps
|
|
161
|
+
})
|
|
162
|
+
});
|
|
163
|
+
});
|
|
164
|
+
CheckboxRoot.displayName = "CheckboxRoot";
|
|
165
|
+
const CheckboxControl = /*#__PURE__*/ react.forwardRef((props, ref)=>{
|
|
166
|
+
const { controlProps } = useCheckboxContext();
|
|
167
|
+
const mergedProps = domUtils.mergeProps(controlProps, props);
|
|
168
|
+
return /*#__PURE__*/ jsxRuntime.jsx(reactPrimitive.Primitive.div, {
|
|
169
|
+
ref: ref,
|
|
170
|
+
...mergedProps
|
|
171
|
+
});
|
|
172
|
+
});
|
|
173
|
+
CheckboxControl.displayName = "CheckboxControl";
|
|
174
|
+
const CheckboxHiddenInput = /*#__PURE__*/ react.forwardRef((props, ref)=>{
|
|
175
|
+
const { refs, hiddenInputProps } = useCheckboxContext();
|
|
176
|
+
const mergedProps = domUtils.mergeProps(hiddenInputProps, props);
|
|
177
|
+
return /*#__PURE__*/ jsxRuntime.jsx(reactPrimitive.Primitive.input, {
|
|
178
|
+
ref: reactComposeRefs.composeRefs(refs.input, ref),
|
|
179
|
+
...mergedProps
|
|
180
|
+
});
|
|
181
|
+
});
|
|
182
|
+
CheckboxHiddenInput.displayName = "CheckboxHiddenInput";
|
|
183
|
+
|
|
184
|
+
exports.CheckboxControl = CheckboxControl;
|
|
185
|
+
exports.CheckboxHiddenInput = CheckboxHiddenInput;
|
|
186
|
+
exports.CheckboxRoot = CheckboxRoot;
|
|
187
|
+
exports.useCheckboxContext = useCheckboxContext;
|
package/lib/index.cjs
CHANGED
|
@@ -1,194 +1,14 @@
|
|
|
1
|
-
var
|
|
2
|
-
var domUtils = require('@seed-design/dom-utils');
|
|
3
|
-
var reactPrimitive = require('@seed-design/react-primitive');
|
|
4
|
-
var react = require('react');
|
|
5
|
-
var reactUseControllableState = require('@radix-ui/react-use-controllable-state');
|
|
6
|
-
var reactComposeRefs = require('@radix-ui/react-compose-refs');
|
|
7
|
-
|
|
8
|
-
function useCheckboxState(props) {
|
|
9
|
-
const [isChecked = false, setIsChecked] = reactUseControllableState.useControllableState({
|
|
10
|
-
prop: props.checked,
|
|
11
|
-
defaultProp: props.defaultChecked,
|
|
12
|
-
onChange: props.onCheckedChange
|
|
13
|
-
});
|
|
14
|
-
const [isHovered, setIsHovered] = react.useState(false);
|
|
15
|
-
const [isActive, setIsActive] = react.useState(false);
|
|
16
|
-
const [isFocused, setIsFocused] = react.useState(false);
|
|
17
|
-
const [isFocusVisible, setIsFocusVisible] = react.useState(false);
|
|
18
|
-
const inputRef = react.useRef(null);
|
|
19
|
-
const initialCheckedRef = react.useRef(isChecked);
|
|
20
|
-
react.useEffect(()=>{
|
|
21
|
-
const form = inputRef.current?.form;
|
|
22
|
-
if (form) {
|
|
23
|
-
const reset = ()=>setIsChecked(initialCheckedRef.current);
|
|
24
|
-
form.addEventListener("reset", reset);
|
|
25
|
-
return ()=>form.removeEventListener("reset", reset);
|
|
26
|
-
}
|
|
27
|
-
}, [
|
|
28
|
-
setIsChecked
|
|
29
|
-
]);
|
|
30
|
-
react.useEffect(()=>{
|
|
31
|
-
if (!inputRef.current) return;
|
|
32
|
-
inputRef.current.indeterminate = props.indeterminate ?? false;
|
|
33
|
-
}, [
|
|
34
|
-
props.indeterminate
|
|
35
|
-
]);
|
|
36
|
-
return {
|
|
37
|
-
refs: {
|
|
38
|
-
input: inputRef
|
|
39
|
-
},
|
|
40
|
-
isIndeterminate: props.indeterminate ?? false,
|
|
41
|
-
isChecked,
|
|
42
|
-
setIsChecked,
|
|
43
|
-
isHovered,
|
|
44
|
-
setIsHovered,
|
|
45
|
-
isActive,
|
|
46
|
-
setIsActive,
|
|
47
|
-
isFocused,
|
|
48
|
-
setIsFocused,
|
|
49
|
-
isFocusVisible,
|
|
50
|
-
setIsFocusVisible
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
function useCheckbox(props) {
|
|
54
|
-
const { refs, isIndeterminate, setIsChecked, isChecked, setIsHovered, isHovered, setIsActive, isActive, setIsFocused, isFocused, setIsFocusVisible, isFocusVisible } = useCheckboxState(props);
|
|
55
|
-
const stateProps = domUtils.elementProps({
|
|
56
|
-
"data-checked": domUtils.dataAttr(isChecked),
|
|
57
|
-
"data-indeterminate": domUtils.dataAttr(isIndeterminate),
|
|
58
|
-
"data-hover": domUtils.dataAttr(isHovered),
|
|
59
|
-
"data-active": domUtils.dataAttr(isActive),
|
|
60
|
-
"data-focus": domUtils.dataAttr(isFocused),
|
|
61
|
-
"data-focus-visible": domUtils.dataAttr(isFocusVisible),
|
|
62
|
-
"data-disabled": domUtils.dataAttr(props.disabled),
|
|
63
|
-
"data-invalid": domUtils.dataAttr(props.invalid),
|
|
64
|
-
"data-required": domUtils.dataAttr(props.required)
|
|
65
|
-
});
|
|
66
|
-
const isControlled = props.checked != null;
|
|
67
|
-
return {
|
|
68
|
-
indeterminate: isIndeterminate,
|
|
69
|
-
checked: isChecked,
|
|
70
|
-
setChecked: setIsChecked,
|
|
71
|
-
focused: isFocused,
|
|
72
|
-
setFocused: setIsFocused,
|
|
73
|
-
focusVisible: isFocusVisible,
|
|
74
|
-
setFocusVisible: setIsFocusVisible,
|
|
75
|
-
refs,
|
|
76
|
-
stateProps,
|
|
77
|
-
rootProps: domUtils.labelProps({
|
|
78
|
-
...stateProps,
|
|
79
|
-
onPointerMove () {
|
|
80
|
-
setIsHovered(true);
|
|
81
|
-
},
|
|
82
|
-
onPointerDown () {
|
|
83
|
-
setIsActive(true);
|
|
84
|
-
},
|
|
85
|
-
onPointerUp () {
|
|
86
|
-
setIsActive(false);
|
|
87
|
-
},
|
|
88
|
-
onPointerLeave () {
|
|
89
|
-
setIsHovered(false);
|
|
90
|
-
setIsActive(false);
|
|
91
|
-
}
|
|
92
|
-
}),
|
|
93
|
-
controlProps: domUtils.elementProps({
|
|
94
|
-
...stateProps,
|
|
95
|
-
"aria-hidden": true
|
|
96
|
-
}),
|
|
97
|
-
hiddenInputProps: domUtils.inputProps({
|
|
98
|
-
type: "checkbox",
|
|
99
|
-
role: "checkbox",
|
|
100
|
-
checked: isControlled ? isChecked : undefined,
|
|
101
|
-
defaultChecked: !isControlled ? isChecked : undefined,
|
|
102
|
-
disabled: props.disabled,
|
|
103
|
-
required: props.required,
|
|
104
|
-
"aria-invalid": props.invalid,
|
|
105
|
-
style: domUtils.visuallyHidden,
|
|
106
|
-
...stateProps,
|
|
107
|
-
onChange (event) {
|
|
108
|
-
setIsChecked(event.currentTarget.checked);
|
|
109
|
-
setIsFocusVisible(event.target.matches(":focus-visible"));
|
|
110
|
-
},
|
|
111
|
-
onFocus (event) {
|
|
112
|
-
setIsFocused(true);
|
|
113
|
-
setIsFocusVisible(event.target.matches(":focus-visible"));
|
|
114
|
-
},
|
|
115
|
-
onBlur () {
|
|
116
|
-
setIsFocused(false);
|
|
117
|
-
setIsFocusVisible(false);
|
|
118
|
-
},
|
|
119
|
-
onKeyDown (event) {
|
|
120
|
-
if (event.key === " ") {
|
|
121
|
-
setIsActive(true);
|
|
122
|
-
}
|
|
123
|
-
},
|
|
124
|
-
onKeyUp (event) {
|
|
125
|
-
if (event.key === " ") {
|
|
126
|
-
setIsActive(false);
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
})
|
|
130
|
-
};
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
const CheckboxContext = /*#__PURE__*/ react.createContext(null);
|
|
134
|
-
const CheckboxProvider = CheckboxContext.Provider;
|
|
135
|
-
function useCheckboxContext({ strict = true } = {}) {
|
|
136
|
-
const context = react.useContext(CheckboxContext);
|
|
137
|
-
if (!context && strict) {
|
|
138
|
-
throw new Error("useCheckboxContext must be used within a Checkbox");
|
|
139
|
-
}
|
|
140
|
-
return context;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
const CheckboxRoot = /*#__PURE__*/ react.forwardRef((props, ref)=>{
|
|
144
|
-
const { checked, defaultChecked, onCheckedChange, indeterminate, disabled, invalid, required, ...otherProps } = props;
|
|
145
|
-
const api = useCheckbox({
|
|
146
|
-
checked,
|
|
147
|
-
defaultChecked,
|
|
148
|
-
onCheckedChange,
|
|
149
|
-
indeterminate,
|
|
150
|
-
disabled,
|
|
151
|
-
invalid,
|
|
152
|
-
required
|
|
153
|
-
});
|
|
154
|
-
const mergedProps = domUtils.mergeProps(api.rootProps, otherProps);
|
|
155
|
-
return /*#__PURE__*/ jsxRuntime.jsx(CheckboxProvider, {
|
|
156
|
-
value: api,
|
|
157
|
-
children: /*#__PURE__*/ jsxRuntime.jsx(reactPrimitive.Primitive.label, {
|
|
158
|
-
ref: ref,
|
|
159
|
-
...mergedProps
|
|
160
|
-
})
|
|
161
|
-
});
|
|
162
|
-
});
|
|
163
|
-
CheckboxRoot.displayName = "CheckboxRoot";
|
|
164
|
-
const CheckboxControl = /*#__PURE__*/ react.forwardRef((props, ref)=>{
|
|
165
|
-
const { controlProps } = useCheckboxContext();
|
|
166
|
-
const mergedProps = domUtils.mergeProps(controlProps, props);
|
|
167
|
-
return /*#__PURE__*/ jsxRuntime.jsx(reactPrimitive.Primitive.div, {
|
|
168
|
-
ref: ref,
|
|
169
|
-
...mergedProps
|
|
170
|
-
});
|
|
171
|
-
});
|
|
172
|
-
CheckboxControl.displayName = "CheckboxControl";
|
|
173
|
-
const CheckboxHiddenInput = /*#__PURE__*/ react.forwardRef((props, ref)=>{
|
|
174
|
-
const { refs, hiddenInputProps } = useCheckboxContext();
|
|
175
|
-
const mergedProps = domUtils.mergeProps(hiddenInputProps, props);
|
|
176
|
-
return /*#__PURE__*/ jsxRuntime.jsx(reactPrimitive.Primitive.input, {
|
|
177
|
-
ref: reactComposeRefs.composeRefs(refs.input, ref),
|
|
178
|
-
...mergedProps
|
|
179
|
-
});
|
|
180
|
-
});
|
|
181
|
-
CheckboxHiddenInput.displayName = "CheckboxHiddenInput";
|
|
1
|
+
var Checkbox12s = require('./Checkbox-12s-Y3jZEb8V.cjs');
|
|
182
2
|
|
|
183
3
|
var Checkbox_namespace = {
|
|
184
4
|
__proto__: null,
|
|
185
|
-
Control: CheckboxControl,
|
|
186
|
-
HiddenInput: CheckboxHiddenInput,
|
|
187
|
-
Root: CheckboxRoot
|
|
5
|
+
Control: Checkbox12s.CheckboxControl,
|
|
6
|
+
HiddenInput: Checkbox12s.CheckboxHiddenInput,
|
|
7
|
+
Root: Checkbox12s.CheckboxRoot
|
|
188
8
|
};
|
|
189
9
|
|
|
10
|
+
exports.CheckboxControl = Checkbox12s.CheckboxControl;
|
|
11
|
+
exports.CheckboxHiddenInput = Checkbox12s.CheckboxHiddenInput;
|
|
12
|
+
exports.CheckboxRoot = Checkbox12s.CheckboxRoot;
|
|
13
|
+
exports.useCheckboxContext = Checkbox12s.useCheckboxContext;
|
|
190
14
|
exports.Checkbox = Checkbox_namespace;
|
|
191
|
-
exports.CheckboxControl = CheckboxControl;
|
|
192
|
-
exports.CheckboxHiddenInput = CheckboxHiddenInput;
|
|
193
|
-
exports.CheckboxRoot = CheckboxRoot;
|
|
194
|
-
exports.useCheckboxContext = useCheckboxContext;
|
package/lib/index.d.ts
CHANGED
|
@@ -16,7 +16,7 @@ type UseCheckboxReturn = ReturnType<typeof useCheckbox>;
|
|
|
16
16
|
declare function useCheckbox(props: UseCheckboxProps): {
|
|
17
17
|
indeterminate: boolean;
|
|
18
18
|
checked: boolean;
|
|
19
|
-
setChecked: react.
|
|
19
|
+
setChecked: (value: react.SetStateAction<boolean>) => void;
|
|
20
20
|
focused: boolean;
|
|
21
21
|
setFocused: react.Dispatch<react.SetStateAction<boolean>>;
|
|
22
22
|
focusVisible: boolean;
|
|
@@ -74,6 +74,8 @@ declare function useCheckbox(props: UseCheckboxProps): {
|
|
|
74
74
|
unselectable?: "on" | "off" | undefined | undefined;
|
|
75
75
|
inputMode?: "none" | "text" | "tel" | "url" | "email" | "numeric" | "decimal" | "search" | undefined | undefined;
|
|
76
76
|
is?: string | undefined | undefined;
|
|
77
|
+
exportparts?: string | undefined | undefined;
|
|
78
|
+
part?: string | undefined | undefined;
|
|
77
79
|
"aria-activedescendant"?: string | undefined | undefined;
|
|
78
80
|
"aria-atomic"?: (boolean | "true" | "false") | undefined;
|
|
79
81
|
"aria-autocomplete"?: "none" | "inline" | "list" | "both" | undefined | undefined;
|
|
@@ -342,6 +344,8 @@ declare function useCheckbox(props: UseCheckboxProps): {
|
|
|
342
344
|
unselectable?: "on" | "off" | undefined | undefined;
|
|
343
345
|
inputMode?: "none" | "text" | "tel" | "url" | "email" | "numeric" | "decimal" | "search" | undefined | undefined;
|
|
344
346
|
is?: string | undefined | undefined;
|
|
347
|
+
exportparts?: string | undefined | undefined;
|
|
348
|
+
part?: string | undefined | undefined;
|
|
345
349
|
"aria-activedescendant"?: string | undefined | undefined;
|
|
346
350
|
"aria-atomic"?: (boolean | "true" | "false") | undefined;
|
|
347
351
|
"aria-autocomplete"?: "none" | "inline" | "list" | "both" | undefined | undefined;
|
|
@@ -612,6 +616,8 @@ declare function useCheckbox(props: UseCheckboxProps): {
|
|
|
612
616
|
unselectable?: "on" | "off" | undefined | undefined;
|
|
613
617
|
inputMode?: "none" | "text" | "tel" | "url" | "email" | "numeric" | "decimal" | "search" | undefined | undefined;
|
|
614
618
|
is?: string | undefined | undefined;
|
|
619
|
+
exportparts?: string | undefined | undefined;
|
|
620
|
+
part?: string | undefined | undefined;
|
|
615
621
|
"aria-activedescendant"?: string | undefined | undefined;
|
|
616
622
|
"aria-atomic"?: (boolean | "true" | "false") | undefined;
|
|
617
623
|
"aria-autocomplete"?: "none" | "inline" | "list" | "both" | undefined | undefined;
|
|
@@ -833,6 +839,7 @@ declare function useCheckbox(props: UseCheckboxProps): {
|
|
|
833
839
|
hiddenInputProps: {
|
|
834
840
|
disabled?: boolean | undefined | undefined;
|
|
835
841
|
required?: boolean | undefined | undefined;
|
|
842
|
+
checked?: boolean | undefined | undefined;
|
|
836
843
|
defaultChecked?: boolean | undefined | undefined;
|
|
837
844
|
defaultValue?: string | number | readonly string[] | undefined;
|
|
838
845
|
suppressContentEditableWarning?: boolean | undefined | undefined;
|
|
@@ -882,6 +889,8 @@ declare function useCheckbox(props: UseCheckboxProps): {
|
|
|
882
889
|
unselectable?: "on" | "off" | undefined | undefined;
|
|
883
890
|
inputMode?: "none" | "text" | "tel" | "url" | "email" | "numeric" | "decimal" | "search" | undefined | undefined;
|
|
884
891
|
is?: string | undefined | undefined;
|
|
892
|
+
exportparts?: string | undefined | undefined;
|
|
893
|
+
part?: string | undefined | undefined;
|
|
885
894
|
"aria-activedescendant"?: string | undefined | undefined;
|
|
886
895
|
"aria-atomic"?: (boolean | "true" | "false") | undefined;
|
|
887
896
|
"aria-autocomplete"?: "none" | "inline" | "list" | "both" | undefined | undefined;
|
|
@@ -1099,21 +1108,18 @@ declare function useCheckbox(props: UseCheckboxProps): {
|
|
|
1099
1108
|
onAnimationIterationCapture?: react.AnimationEventHandler<HTMLInputElement> | undefined;
|
|
1100
1109
|
onTransitionEnd?: react.TransitionEventHandler<HTMLInputElement> | undefined;
|
|
1101
1110
|
onTransitionEndCapture?: react.TransitionEventHandler<HTMLInputElement> | undefined;
|
|
1102
|
-
form?: string | undefined | undefined;
|
|
1103
|
-
list?: string | undefined | undefined;
|
|
1104
|
-
step?: number | string | undefined | undefined;
|
|
1105
|
-
type?: react.HTMLInputTypeAttribute | undefined;
|
|
1106
|
-
checked?: boolean | undefined | undefined;
|
|
1107
1111
|
accept?: string | undefined | undefined;
|
|
1108
1112
|
alt?: string | undefined | undefined;
|
|
1109
1113
|
autoComplete?: react.HTMLInputAutoCompleteAttribute | undefined;
|
|
1110
1114
|
capture?: boolean | "user" | "environment" | undefined | undefined;
|
|
1115
|
+
form?: string | undefined | undefined;
|
|
1111
1116
|
formAction?: string | undefined;
|
|
1112
1117
|
formEncType?: string | undefined | undefined;
|
|
1113
1118
|
formMethod?: string | undefined | undefined;
|
|
1114
1119
|
formNoValidate?: boolean | undefined | undefined;
|
|
1115
1120
|
formTarget?: string | undefined | undefined;
|
|
1116
1121
|
height?: number | string | undefined | undefined;
|
|
1122
|
+
list?: string | undefined | undefined;
|
|
1117
1123
|
max?: number | string | undefined | undefined;
|
|
1118
1124
|
maxLength?: number | undefined | undefined;
|
|
1119
1125
|
min?: number | string | undefined | undefined;
|
|
@@ -1125,6 +1131,8 @@ declare function useCheckbox(props: UseCheckboxProps): {
|
|
|
1125
1131
|
readOnly?: boolean | undefined | undefined;
|
|
1126
1132
|
size?: number | undefined | undefined;
|
|
1127
1133
|
src?: string | undefined | undefined;
|
|
1134
|
+
step?: number | string | undefined | undefined;
|
|
1135
|
+
type?: react.HTMLInputTypeAttribute | undefined;
|
|
1128
1136
|
value?: string | number | readonly string[] | undefined;
|
|
1129
1137
|
width?: number | string | undefined | undefined;
|
|
1130
1138
|
};
|
|
@@ -1147,7 +1155,9 @@ declare function useCheckboxContext<T extends boolean | undefined = true>({ stri
|
|
|
1147
1155
|
}): T extends false ? UseCheckboxContext | null : UseCheckboxContext;
|
|
1148
1156
|
|
|
1149
1157
|
declare namespace Checkbox_namespace {
|
|
1150
|
-
export { CheckboxControl as Control,
|
|
1158
|
+
export { CheckboxControl as Control, CheckboxHiddenInput as HiddenInput, CheckboxRoot as Root };
|
|
1159
|
+
export type { CheckboxControlProps as ControlProps, CheckboxHiddenInputProps as HiddenInputProps, CheckboxRootProps as RootProps };
|
|
1151
1160
|
}
|
|
1152
1161
|
|
|
1153
|
-
export { Checkbox_namespace as Checkbox, CheckboxControl,
|
|
1162
|
+
export { Checkbox_namespace as Checkbox, CheckboxControl, CheckboxHiddenInput, CheckboxRoot, useCheckboxContext };
|
|
1163
|
+
export type { CheckboxControlProps, CheckboxHiddenInputProps, CheckboxRootProps, UseCheckboxContext };
|
package/lib/index.js
CHANGED
|
@@ -1,184 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import { Primitive } from '@seed-design/react-primitive';
|
|
4
|
-
import { useState, useRef, useEffect, createContext, useContext, forwardRef } from 'react';
|
|
5
|
-
import { useControllableState } from '@radix-ui/react-use-controllable-state';
|
|
6
|
-
import { composeRefs } from '@radix-ui/react-compose-refs';
|
|
7
|
-
|
|
8
|
-
function useCheckboxState(props) {
|
|
9
|
-
const [isChecked = false, setIsChecked] = useControllableState({
|
|
10
|
-
prop: props.checked,
|
|
11
|
-
defaultProp: props.defaultChecked,
|
|
12
|
-
onChange: props.onCheckedChange
|
|
13
|
-
});
|
|
14
|
-
const [isHovered, setIsHovered] = useState(false);
|
|
15
|
-
const [isActive, setIsActive] = useState(false);
|
|
16
|
-
const [isFocused, setIsFocused] = useState(false);
|
|
17
|
-
const [isFocusVisible, setIsFocusVisible] = useState(false);
|
|
18
|
-
const inputRef = useRef(null);
|
|
19
|
-
const initialCheckedRef = useRef(isChecked);
|
|
20
|
-
useEffect(()=>{
|
|
21
|
-
const form = inputRef.current?.form;
|
|
22
|
-
if (form) {
|
|
23
|
-
const reset = ()=>setIsChecked(initialCheckedRef.current);
|
|
24
|
-
form.addEventListener("reset", reset);
|
|
25
|
-
return ()=>form.removeEventListener("reset", reset);
|
|
26
|
-
}
|
|
27
|
-
}, [
|
|
28
|
-
setIsChecked
|
|
29
|
-
]);
|
|
30
|
-
useEffect(()=>{
|
|
31
|
-
if (!inputRef.current) return;
|
|
32
|
-
inputRef.current.indeterminate = props.indeterminate ?? false;
|
|
33
|
-
}, [
|
|
34
|
-
props.indeterminate
|
|
35
|
-
]);
|
|
36
|
-
return {
|
|
37
|
-
refs: {
|
|
38
|
-
input: inputRef
|
|
39
|
-
},
|
|
40
|
-
isIndeterminate: props.indeterminate ?? false,
|
|
41
|
-
isChecked,
|
|
42
|
-
setIsChecked,
|
|
43
|
-
isHovered,
|
|
44
|
-
setIsHovered,
|
|
45
|
-
isActive,
|
|
46
|
-
setIsActive,
|
|
47
|
-
isFocused,
|
|
48
|
-
setIsFocused,
|
|
49
|
-
isFocusVisible,
|
|
50
|
-
setIsFocusVisible
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
function useCheckbox(props) {
|
|
54
|
-
const { refs, isIndeterminate, setIsChecked, isChecked, setIsHovered, isHovered, setIsActive, isActive, setIsFocused, isFocused, setIsFocusVisible, isFocusVisible } = useCheckboxState(props);
|
|
55
|
-
const stateProps = elementProps({
|
|
56
|
-
"data-checked": dataAttr(isChecked),
|
|
57
|
-
"data-indeterminate": dataAttr(isIndeterminate),
|
|
58
|
-
"data-hover": dataAttr(isHovered),
|
|
59
|
-
"data-active": dataAttr(isActive),
|
|
60
|
-
"data-focus": dataAttr(isFocused),
|
|
61
|
-
"data-focus-visible": dataAttr(isFocusVisible),
|
|
62
|
-
"data-disabled": dataAttr(props.disabled),
|
|
63
|
-
"data-invalid": dataAttr(props.invalid),
|
|
64
|
-
"data-required": dataAttr(props.required)
|
|
65
|
-
});
|
|
66
|
-
const isControlled = props.checked != null;
|
|
67
|
-
return {
|
|
68
|
-
indeterminate: isIndeterminate,
|
|
69
|
-
checked: isChecked,
|
|
70
|
-
setChecked: setIsChecked,
|
|
71
|
-
focused: isFocused,
|
|
72
|
-
setFocused: setIsFocused,
|
|
73
|
-
focusVisible: isFocusVisible,
|
|
74
|
-
setFocusVisible: setIsFocusVisible,
|
|
75
|
-
refs,
|
|
76
|
-
stateProps,
|
|
77
|
-
rootProps: labelProps({
|
|
78
|
-
...stateProps,
|
|
79
|
-
onPointerMove () {
|
|
80
|
-
setIsHovered(true);
|
|
81
|
-
},
|
|
82
|
-
onPointerDown () {
|
|
83
|
-
setIsActive(true);
|
|
84
|
-
},
|
|
85
|
-
onPointerUp () {
|
|
86
|
-
setIsActive(false);
|
|
87
|
-
},
|
|
88
|
-
onPointerLeave () {
|
|
89
|
-
setIsHovered(false);
|
|
90
|
-
setIsActive(false);
|
|
91
|
-
}
|
|
92
|
-
}),
|
|
93
|
-
controlProps: elementProps({
|
|
94
|
-
...stateProps,
|
|
95
|
-
"aria-hidden": true
|
|
96
|
-
}),
|
|
97
|
-
hiddenInputProps: inputProps({
|
|
98
|
-
type: "checkbox",
|
|
99
|
-
role: "checkbox",
|
|
100
|
-
checked: isControlled ? isChecked : undefined,
|
|
101
|
-
defaultChecked: !isControlled ? isChecked : undefined,
|
|
102
|
-
disabled: props.disabled,
|
|
103
|
-
required: props.required,
|
|
104
|
-
"aria-invalid": props.invalid,
|
|
105
|
-
style: visuallyHidden,
|
|
106
|
-
...stateProps,
|
|
107
|
-
onChange (event) {
|
|
108
|
-
setIsChecked(event.currentTarget.checked);
|
|
109
|
-
setIsFocusVisible(event.target.matches(":focus-visible"));
|
|
110
|
-
},
|
|
111
|
-
onFocus (event) {
|
|
112
|
-
setIsFocused(true);
|
|
113
|
-
setIsFocusVisible(event.target.matches(":focus-visible"));
|
|
114
|
-
},
|
|
115
|
-
onBlur () {
|
|
116
|
-
setIsFocused(false);
|
|
117
|
-
setIsFocusVisible(false);
|
|
118
|
-
},
|
|
119
|
-
onKeyDown (event) {
|
|
120
|
-
if (event.key === " ") {
|
|
121
|
-
setIsActive(true);
|
|
122
|
-
}
|
|
123
|
-
},
|
|
124
|
-
onKeyUp (event) {
|
|
125
|
-
if (event.key === " ") {
|
|
126
|
-
setIsActive(false);
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
})
|
|
130
|
-
};
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
const CheckboxContext = /*#__PURE__*/ createContext(null);
|
|
134
|
-
const CheckboxProvider = CheckboxContext.Provider;
|
|
135
|
-
function useCheckboxContext({ strict = true } = {}) {
|
|
136
|
-
const context = useContext(CheckboxContext);
|
|
137
|
-
if (!context && strict) {
|
|
138
|
-
throw new Error("useCheckboxContext must be used within a Checkbox");
|
|
139
|
-
}
|
|
140
|
-
return context;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
const CheckboxRoot = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
144
|
-
const { checked, defaultChecked, onCheckedChange, indeterminate, disabled, invalid, required, ...otherProps } = props;
|
|
145
|
-
const api = useCheckbox({
|
|
146
|
-
checked,
|
|
147
|
-
defaultChecked,
|
|
148
|
-
onCheckedChange,
|
|
149
|
-
indeterminate,
|
|
150
|
-
disabled,
|
|
151
|
-
invalid,
|
|
152
|
-
required
|
|
153
|
-
});
|
|
154
|
-
const mergedProps = mergeProps(api.rootProps, otherProps);
|
|
155
|
-
return /*#__PURE__*/ jsx(CheckboxProvider, {
|
|
156
|
-
value: api,
|
|
157
|
-
children: /*#__PURE__*/ jsx(Primitive.label, {
|
|
158
|
-
ref: ref,
|
|
159
|
-
...mergedProps
|
|
160
|
-
})
|
|
161
|
-
});
|
|
162
|
-
});
|
|
163
|
-
CheckboxRoot.displayName = "CheckboxRoot";
|
|
164
|
-
const CheckboxControl = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
165
|
-
const { controlProps } = useCheckboxContext();
|
|
166
|
-
const mergedProps = mergeProps(controlProps, props);
|
|
167
|
-
return /*#__PURE__*/ jsx(Primitive.div, {
|
|
168
|
-
ref: ref,
|
|
169
|
-
...mergedProps
|
|
170
|
-
});
|
|
171
|
-
});
|
|
172
|
-
CheckboxControl.displayName = "CheckboxControl";
|
|
173
|
-
const CheckboxHiddenInput = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
174
|
-
const { refs, hiddenInputProps } = useCheckboxContext();
|
|
175
|
-
const mergedProps = mergeProps(hiddenInputProps, props);
|
|
176
|
-
return /*#__PURE__*/ jsx(Primitive.input, {
|
|
177
|
-
ref: composeRefs(refs.input, ref),
|
|
178
|
-
...mergedProps
|
|
179
|
-
});
|
|
180
|
-
});
|
|
181
|
-
CheckboxHiddenInput.displayName = "CheckboxHiddenInput";
|
|
1
|
+
import { C as CheckboxControl, a as CheckboxHiddenInput, b as CheckboxRoot } from './Checkbox-12s-BeV5Lkaw.js';
|
|
2
|
+
export { u as useCheckboxContext } from './Checkbox-12s-BeV5Lkaw.js';
|
|
182
3
|
|
|
183
4
|
var Checkbox_namespace = {
|
|
184
5
|
__proto__: null,
|
|
@@ -187,4 +8,4 @@ var Checkbox_namespace = {
|
|
|
187
8
|
Root: CheckboxRoot
|
|
188
9
|
};
|
|
189
10
|
|
|
190
|
-
export { Checkbox_namespace as Checkbox, CheckboxControl, CheckboxHiddenInput, CheckboxRoot
|
|
11
|
+
export { Checkbox_namespace as Checkbox, CheckboxControl, CheckboxHiddenInput, CheckboxRoot };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@seed-design/react-checkbox",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/daangn/seed-design.git",
|
|
@@ -27,13 +27,15 @@
|
|
|
27
27
|
"lint:publish": "bun publint"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@radix-ui/react-compose-refs": "^1.1.
|
|
31
|
-
"@radix-ui/react-use-controllable-state": "1.
|
|
32
|
-
"@seed-design/dom-utils": "0.0.
|
|
33
|
-
"@seed-design/react-primitive": "0.0.
|
|
30
|
+
"@radix-ui/react-compose-refs": "^1.1.2",
|
|
31
|
+
"@radix-ui/react-use-controllable-state": "1.2.2",
|
|
32
|
+
"@seed-design/dom-utils": "0.0.2",
|
|
33
|
+
"@seed-design/react-primitive": "0.0.2"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"@types/react": "^18.3.
|
|
36
|
+
"@types/react": "^18.3.20",
|
|
37
|
+
"react": "^18.3.1",
|
|
38
|
+
"react-dom": "^18.3.1"
|
|
37
39
|
},
|
|
38
40
|
"peerDependencies": {
|
|
39
41
|
"react": ">=18.0.0",
|