@seed-design/react-checkbox 0.0.2 → 0.0.4

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.
@@ -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 jsxRuntime = require('react/jsx-runtime');
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
@@ -22,7 +22,7 @@ declare function useCheckbox(props: UseCheckboxProps): {
22
22
  focusVisible: boolean;
23
23
  setFocusVisible: react.Dispatch<react.SetStateAction<boolean>>;
24
24
  refs: {
25
- input: react.RefObject<HTMLInputElement>;
25
+ input: react.RefObject<HTMLInputElement | null>;
26
26
  };
27
27
  stateProps: {
28
28
  defaultChecked?: boolean | undefined | undefined;
@@ -72,6 +72,10 @@ declare function useCheckbox(props: UseCheckboxProps): {
72
72
  results?: number | undefined | undefined;
73
73
  security?: string | undefined | undefined;
74
74
  unselectable?: "on" | "off" | undefined | undefined;
75
+ popover?: "" | "auto" | "manual" | undefined | undefined;
76
+ popoverTargetAction?: "toggle" | "show" | "hide" | undefined | undefined;
77
+ popoverTarget?: string | undefined | undefined;
78
+ inert?: boolean | undefined | undefined;
75
79
  inputMode?: "none" | "text" | "tel" | "url" | "email" | "numeric" | "decimal" | "search" | undefined | undefined;
76
80
  is?: string | undefined | undefined;
77
81
  exportparts?: string | undefined | undefined;
@@ -151,7 +155,7 @@ declare function useCheckbox(props: UseCheckboxProps): {
151
155
  onBlurCapture?: react.FocusEventHandler<HTMLElement> | undefined;
152
156
  onChange?: react.FormEventHandler<HTMLElement> | undefined;
153
157
  onChangeCapture?: react.FormEventHandler<HTMLElement> | undefined;
154
- onBeforeInput?: react.FormEventHandler<HTMLElement> | undefined;
158
+ onBeforeInput?: react.InputEventHandler<HTMLElement> | undefined;
155
159
  onBeforeInputCapture?: react.FormEventHandler<HTMLElement> | undefined;
156
160
  onInput?: react.FormEventHandler<HTMLElement> | undefined;
157
161
  onInputCapture?: react.FormEventHandler<HTMLElement> | undefined;
@@ -201,8 +205,6 @@ declare function useCheckbox(props: UseCheckboxProps): {
201
205
  onProgressCapture?: react.ReactEventHandler<HTMLElement> | undefined;
202
206
  onRateChange?: react.ReactEventHandler<HTMLElement> | undefined;
203
207
  onRateChangeCapture?: react.ReactEventHandler<HTMLElement> | undefined;
204
- onResize?: react.ReactEventHandler<HTMLElement> | undefined;
205
- onResizeCapture?: react.ReactEventHandler<HTMLElement> | undefined;
206
208
  onSeeked?: react.ReactEventHandler<HTMLElement> | undefined;
207
209
  onSeekedCapture?: react.ReactEventHandler<HTMLElement> | undefined;
208
210
  onSeeking?: react.ReactEventHandler<HTMLElement> | undefined;
@@ -283,6 +285,8 @@ declare function useCheckbox(props: UseCheckboxProps): {
283
285
  onLostPointerCaptureCapture?: react.PointerEventHandler<HTMLElement> | undefined;
284
286
  onScroll?: react.UIEventHandler<HTMLElement> | undefined;
285
287
  onScrollCapture?: react.UIEventHandler<HTMLElement> | undefined;
288
+ onScrollEnd?: react.UIEventHandler<HTMLElement> | undefined;
289
+ onScrollEndCapture?: react.UIEventHandler<HTMLElement> | undefined;
286
290
  onWheel?: react.WheelEventHandler<HTMLElement> | undefined;
287
291
  onWheelCapture?: react.WheelEventHandler<HTMLElement> | undefined;
288
292
  onAnimationStart?: react.AnimationEventHandler<HTMLElement> | undefined;
@@ -291,8 +295,16 @@ declare function useCheckbox(props: UseCheckboxProps): {
291
295
  onAnimationEndCapture?: react.AnimationEventHandler<HTMLElement> | undefined;
292
296
  onAnimationIteration?: react.AnimationEventHandler<HTMLElement> | undefined;
293
297
  onAnimationIterationCapture?: react.AnimationEventHandler<HTMLElement> | undefined;
298
+ onToggle?: react.ToggleEventHandler<HTMLElement> | undefined;
299
+ onBeforeToggle?: react.ToggleEventHandler<HTMLElement> | undefined;
300
+ onTransitionCancel?: react.TransitionEventHandler<HTMLElement> | undefined;
301
+ onTransitionCancelCapture?: react.TransitionEventHandler<HTMLElement> | undefined;
294
302
  onTransitionEnd?: react.TransitionEventHandler<HTMLElement> | undefined;
295
303
  onTransitionEndCapture?: react.TransitionEventHandler<HTMLElement> | undefined;
304
+ onTransitionRun?: react.TransitionEventHandler<HTMLElement> | undefined;
305
+ onTransitionRunCapture?: react.TransitionEventHandler<HTMLElement> | undefined;
306
+ onTransitionStart?: react.TransitionEventHandler<HTMLElement> | undefined;
307
+ onTransitionStartCapture?: react.TransitionEventHandler<HTMLElement> | undefined;
296
308
  };
297
309
  rootProps: {
298
310
  defaultChecked?: boolean | undefined | undefined;
@@ -342,6 +354,10 @@ declare function useCheckbox(props: UseCheckboxProps): {
342
354
  results?: number | undefined | undefined;
343
355
  security?: string | undefined | undefined;
344
356
  unselectable?: "on" | "off" | undefined | undefined;
357
+ popover?: "" | "auto" | "manual" | undefined | undefined;
358
+ popoverTargetAction?: "toggle" | "show" | "hide" | undefined | undefined;
359
+ popoverTarget?: string | undefined | undefined;
360
+ inert?: boolean | undefined | undefined;
345
361
  inputMode?: "none" | "text" | "tel" | "url" | "email" | "numeric" | "decimal" | "search" | undefined | undefined;
346
362
  is?: string | undefined | undefined;
347
363
  exportparts?: string | undefined | undefined;
@@ -421,7 +437,7 @@ declare function useCheckbox(props: UseCheckboxProps): {
421
437
  onBlurCapture?: react.FocusEventHandler<HTMLLabelElement> | undefined;
422
438
  onChange?: react.FormEventHandler<HTMLLabelElement> | undefined;
423
439
  onChangeCapture?: react.FormEventHandler<HTMLLabelElement> | undefined;
424
- onBeforeInput?: react.FormEventHandler<HTMLLabelElement> | undefined;
440
+ onBeforeInput?: react.InputEventHandler<HTMLLabelElement> | undefined;
425
441
  onBeforeInputCapture?: react.FormEventHandler<HTMLLabelElement> | undefined;
426
442
  onInput?: react.FormEventHandler<HTMLLabelElement> | undefined;
427
443
  onInputCapture?: react.FormEventHandler<HTMLLabelElement> | undefined;
@@ -471,8 +487,6 @@ declare function useCheckbox(props: UseCheckboxProps): {
471
487
  onProgressCapture?: react.ReactEventHandler<HTMLLabelElement> | undefined;
472
488
  onRateChange?: react.ReactEventHandler<HTMLLabelElement> | undefined;
473
489
  onRateChangeCapture?: react.ReactEventHandler<HTMLLabelElement> | undefined;
474
- onResize?: react.ReactEventHandler<HTMLLabelElement> | undefined;
475
- onResizeCapture?: react.ReactEventHandler<HTMLLabelElement> | undefined;
476
490
  onSeeked?: react.ReactEventHandler<HTMLLabelElement> | undefined;
477
491
  onSeekedCapture?: react.ReactEventHandler<HTMLLabelElement> | undefined;
478
492
  onSeeking?: react.ReactEventHandler<HTMLLabelElement> | undefined;
@@ -553,6 +567,8 @@ declare function useCheckbox(props: UseCheckboxProps): {
553
567
  onLostPointerCaptureCapture?: react.PointerEventHandler<HTMLLabelElement> | undefined;
554
568
  onScroll?: react.UIEventHandler<HTMLLabelElement> | undefined;
555
569
  onScrollCapture?: react.UIEventHandler<HTMLLabelElement> | undefined;
570
+ onScrollEnd?: react.UIEventHandler<HTMLLabelElement> | undefined;
571
+ onScrollEndCapture?: react.UIEventHandler<HTMLLabelElement> | undefined;
556
572
  onWheel?: react.WheelEventHandler<HTMLLabelElement> | undefined;
557
573
  onWheelCapture?: react.WheelEventHandler<HTMLLabelElement> | undefined;
558
574
  onAnimationStart?: react.AnimationEventHandler<HTMLLabelElement> | undefined;
@@ -561,8 +577,16 @@ declare function useCheckbox(props: UseCheckboxProps): {
561
577
  onAnimationEndCapture?: react.AnimationEventHandler<HTMLLabelElement> | undefined;
562
578
  onAnimationIteration?: react.AnimationEventHandler<HTMLLabelElement> | undefined;
563
579
  onAnimationIterationCapture?: react.AnimationEventHandler<HTMLLabelElement> | undefined;
580
+ onToggle?: react.ToggleEventHandler<HTMLLabelElement> | undefined;
581
+ onBeforeToggle?: react.ToggleEventHandler<HTMLLabelElement> | undefined;
582
+ onTransitionCancel?: react.TransitionEventHandler<HTMLLabelElement> | undefined;
583
+ onTransitionCancelCapture?: react.TransitionEventHandler<HTMLLabelElement> | undefined;
564
584
  onTransitionEnd?: react.TransitionEventHandler<HTMLLabelElement> | undefined;
565
585
  onTransitionEndCapture?: react.TransitionEventHandler<HTMLLabelElement> | undefined;
586
+ onTransitionRun?: react.TransitionEventHandler<HTMLLabelElement> | undefined;
587
+ onTransitionRunCapture?: react.TransitionEventHandler<HTMLLabelElement> | undefined;
588
+ onTransitionStart?: react.TransitionEventHandler<HTMLLabelElement> | undefined;
589
+ onTransitionStartCapture?: react.TransitionEventHandler<HTMLLabelElement> | undefined;
566
590
  form?: string | undefined | undefined;
567
591
  htmlFor?: string | undefined | undefined;
568
592
  };
@@ -614,6 +638,10 @@ declare function useCheckbox(props: UseCheckboxProps): {
614
638
  results?: number | undefined | undefined;
615
639
  security?: string | undefined | undefined;
616
640
  unselectable?: "on" | "off" | undefined | undefined;
641
+ popover?: "" | "auto" | "manual" | undefined | undefined;
642
+ popoverTargetAction?: "toggle" | "show" | "hide" | undefined | undefined;
643
+ popoverTarget?: string | undefined | undefined;
644
+ inert?: boolean | undefined | undefined;
617
645
  inputMode?: "none" | "text" | "tel" | "url" | "email" | "numeric" | "decimal" | "search" | undefined | undefined;
618
646
  is?: string | undefined | undefined;
619
647
  exportparts?: string | undefined | undefined;
@@ -693,7 +721,7 @@ declare function useCheckbox(props: UseCheckboxProps): {
693
721
  onBlurCapture?: react.FocusEventHandler<HTMLElement> | undefined;
694
722
  onChange?: react.FormEventHandler<HTMLElement> | undefined;
695
723
  onChangeCapture?: react.FormEventHandler<HTMLElement> | undefined;
696
- onBeforeInput?: react.FormEventHandler<HTMLElement> | undefined;
724
+ onBeforeInput?: react.InputEventHandler<HTMLElement> | undefined;
697
725
  onBeforeInputCapture?: react.FormEventHandler<HTMLElement> | undefined;
698
726
  onInput?: react.FormEventHandler<HTMLElement> | undefined;
699
727
  onInputCapture?: react.FormEventHandler<HTMLElement> | undefined;
@@ -743,8 +771,6 @@ declare function useCheckbox(props: UseCheckboxProps): {
743
771
  onProgressCapture?: react.ReactEventHandler<HTMLElement> | undefined;
744
772
  onRateChange?: react.ReactEventHandler<HTMLElement> | undefined;
745
773
  onRateChangeCapture?: react.ReactEventHandler<HTMLElement> | undefined;
746
- onResize?: react.ReactEventHandler<HTMLElement> | undefined;
747
- onResizeCapture?: react.ReactEventHandler<HTMLElement> | undefined;
748
774
  onSeeked?: react.ReactEventHandler<HTMLElement> | undefined;
749
775
  onSeekedCapture?: react.ReactEventHandler<HTMLElement> | undefined;
750
776
  onSeeking?: react.ReactEventHandler<HTMLElement> | undefined;
@@ -825,6 +851,8 @@ declare function useCheckbox(props: UseCheckboxProps): {
825
851
  onLostPointerCaptureCapture?: react.PointerEventHandler<HTMLElement> | undefined;
826
852
  onScroll?: react.UIEventHandler<HTMLElement> | undefined;
827
853
  onScrollCapture?: react.UIEventHandler<HTMLElement> | undefined;
854
+ onScrollEnd?: react.UIEventHandler<HTMLElement> | undefined;
855
+ onScrollEndCapture?: react.UIEventHandler<HTMLElement> | undefined;
828
856
  onWheel?: react.WheelEventHandler<HTMLElement> | undefined;
829
857
  onWheelCapture?: react.WheelEventHandler<HTMLElement> | undefined;
830
858
  onAnimationStart?: react.AnimationEventHandler<HTMLElement> | undefined;
@@ -833,8 +861,16 @@ declare function useCheckbox(props: UseCheckboxProps): {
833
861
  onAnimationEndCapture?: react.AnimationEventHandler<HTMLElement> | undefined;
834
862
  onAnimationIteration?: react.AnimationEventHandler<HTMLElement> | undefined;
835
863
  onAnimationIterationCapture?: react.AnimationEventHandler<HTMLElement> | undefined;
864
+ onToggle?: react.ToggleEventHandler<HTMLElement> | undefined;
865
+ onBeforeToggle?: react.ToggleEventHandler<HTMLElement> | undefined;
866
+ onTransitionCancel?: react.TransitionEventHandler<HTMLElement> | undefined;
867
+ onTransitionCancelCapture?: react.TransitionEventHandler<HTMLElement> | undefined;
836
868
  onTransitionEnd?: react.TransitionEventHandler<HTMLElement> | undefined;
837
869
  onTransitionEndCapture?: react.TransitionEventHandler<HTMLElement> | undefined;
870
+ onTransitionRun?: react.TransitionEventHandler<HTMLElement> | undefined;
871
+ onTransitionRunCapture?: react.TransitionEventHandler<HTMLElement> | undefined;
872
+ onTransitionStart?: react.TransitionEventHandler<HTMLElement> | undefined;
873
+ onTransitionStartCapture?: react.TransitionEventHandler<HTMLElement> | undefined;
838
874
  };
839
875
  hiddenInputProps: {
840
876
  disabled?: boolean | undefined | undefined;
@@ -887,6 +923,10 @@ declare function useCheckbox(props: UseCheckboxProps): {
887
923
  results?: number | undefined | undefined;
888
924
  security?: string | undefined | undefined;
889
925
  unselectable?: "on" | "off" | undefined | undefined;
926
+ popover?: "" | "auto" | "manual" | undefined | undefined;
927
+ popoverTargetAction?: "toggle" | "show" | "hide" | undefined | undefined;
928
+ popoverTarget?: string | undefined | undefined;
929
+ inert?: boolean | undefined | undefined;
890
930
  inputMode?: "none" | "text" | "tel" | "url" | "email" | "numeric" | "decimal" | "search" | undefined | undefined;
891
931
  is?: string | undefined | undefined;
892
932
  exportparts?: string | undefined | undefined;
@@ -966,7 +1006,7 @@ declare function useCheckbox(props: UseCheckboxProps): {
966
1006
  onBlurCapture?: react.FocusEventHandler<HTMLInputElement> | undefined;
967
1007
  onChange?: react.ChangeEventHandler<HTMLInputElement> | undefined;
968
1008
  onChangeCapture?: react.FormEventHandler<HTMLInputElement> | undefined;
969
- onBeforeInput?: react.FormEventHandler<HTMLInputElement> | undefined;
1009
+ onBeforeInput?: react.InputEventHandler<HTMLInputElement> | undefined;
970
1010
  onBeforeInputCapture?: react.FormEventHandler<HTMLInputElement> | undefined;
971
1011
  onInput?: react.FormEventHandler<HTMLInputElement> | undefined;
972
1012
  onInputCapture?: react.FormEventHandler<HTMLInputElement> | undefined;
@@ -1016,8 +1056,6 @@ declare function useCheckbox(props: UseCheckboxProps): {
1016
1056
  onProgressCapture?: react.ReactEventHandler<HTMLInputElement> | undefined;
1017
1057
  onRateChange?: react.ReactEventHandler<HTMLInputElement> | undefined;
1018
1058
  onRateChangeCapture?: react.ReactEventHandler<HTMLInputElement> | undefined;
1019
- onResize?: react.ReactEventHandler<HTMLInputElement> | undefined;
1020
- onResizeCapture?: react.ReactEventHandler<HTMLInputElement> | undefined;
1021
1059
  onSeeked?: react.ReactEventHandler<HTMLInputElement> | undefined;
1022
1060
  onSeekedCapture?: react.ReactEventHandler<HTMLInputElement> | undefined;
1023
1061
  onSeeking?: react.ReactEventHandler<HTMLInputElement> | undefined;
@@ -1098,6 +1136,8 @@ declare function useCheckbox(props: UseCheckboxProps): {
1098
1136
  onLostPointerCaptureCapture?: react.PointerEventHandler<HTMLInputElement> | undefined;
1099
1137
  onScroll?: react.UIEventHandler<HTMLInputElement> | undefined;
1100
1138
  onScrollCapture?: react.UIEventHandler<HTMLInputElement> | undefined;
1139
+ onScrollEnd?: react.UIEventHandler<HTMLInputElement> | undefined;
1140
+ onScrollEndCapture?: react.UIEventHandler<HTMLInputElement> | undefined;
1101
1141
  onWheel?: react.WheelEventHandler<HTMLInputElement> | undefined;
1102
1142
  onWheelCapture?: react.WheelEventHandler<HTMLInputElement> | undefined;
1103
1143
  onAnimationStart?: react.AnimationEventHandler<HTMLInputElement> | undefined;
@@ -1106,14 +1146,22 @@ declare function useCheckbox(props: UseCheckboxProps): {
1106
1146
  onAnimationEndCapture?: react.AnimationEventHandler<HTMLInputElement> | undefined;
1107
1147
  onAnimationIteration?: react.AnimationEventHandler<HTMLInputElement> | undefined;
1108
1148
  onAnimationIterationCapture?: react.AnimationEventHandler<HTMLInputElement> | undefined;
1149
+ onToggle?: react.ToggleEventHandler<HTMLInputElement> | undefined;
1150
+ onBeforeToggle?: react.ToggleEventHandler<HTMLInputElement> | undefined;
1151
+ onTransitionCancel?: react.TransitionEventHandler<HTMLInputElement> | undefined;
1152
+ onTransitionCancelCapture?: react.TransitionEventHandler<HTMLInputElement> | undefined;
1109
1153
  onTransitionEnd?: react.TransitionEventHandler<HTMLInputElement> | undefined;
1110
1154
  onTransitionEndCapture?: react.TransitionEventHandler<HTMLInputElement> | undefined;
1155
+ onTransitionRun?: react.TransitionEventHandler<HTMLInputElement> | undefined;
1156
+ onTransitionRunCapture?: react.TransitionEventHandler<HTMLInputElement> | undefined;
1157
+ onTransitionStart?: react.TransitionEventHandler<HTMLInputElement> | undefined;
1158
+ onTransitionStartCapture?: react.TransitionEventHandler<HTMLInputElement> | undefined;
1111
1159
  accept?: string | undefined | undefined;
1112
1160
  alt?: string | undefined | undefined;
1113
1161
  autoComplete?: react.HTMLInputAutoCompleteAttribute | undefined;
1114
1162
  capture?: boolean | "user" | "environment" | undefined | undefined;
1115
1163
  form?: string | undefined | undefined;
1116
- formAction?: string | undefined;
1164
+ formAction?: string | ((formData: FormData) => void | Promise<void>) | undefined;
1117
1165
  formEncType?: string | undefined | undefined;
1118
1166
  formMethod?: string | undefined | undefined;
1119
1167
  formNoValidate?: boolean | undefined | undefined;
package/lib/index.js CHANGED
@@ -1,184 +1,5 @@
1
- import { jsx } from 'react/jsx-runtime';
2
- import { elementProps, dataAttr, inputProps, labelProps, visuallyHidden, mergeProps } from '@seed-design/dom-utils';
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, useCheckboxContext };
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.2",
3
+ "version": "0.0.4",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/daangn/seed-design.git",
@@ -30,12 +30,12 @@
30
30
  "@radix-ui/react-compose-refs": "^1.1.2",
31
31
  "@radix-ui/react-use-controllable-state": "1.2.2",
32
32
  "@seed-design/dom-utils": "0.0.2",
33
- "@seed-design/react-primitive": "0.0.2"
33
+ "@seed-design/react-primitive": "0.0.3"
34
34
  },
35
35
  "devDependencies": {
36
- "@types/react": "^18.3.20",
37
- "react": "^18.3.1",
38
- "react-dom": "^18.3.1"
36
+ "@types/react": "^19.1.6",
37
+ "react": "^19.1.0",
38
+ "react-dom": "^19.1.0"
39
39
  },
40
40
  "peerDependencies": {
41
41
  "react": ">=18.0.0",
package/src/Checkbox.tsx CHANGED
@@ -1,3 +1,5 @@
1
+ "use client";
2
+
1
3
  import { mergeProps } from "@seed-design/dom-utils";
2
4
  import { Primitive, type PrimitiveProps } from "@seed-design/react-primitive";
3
5
  import type * as React from "react";