@yamada-ui/checkbox 0.1.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.
@@ -0,0 +1,537 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/checkbox.tsx
21
+ var checkbox_exports = {};
22
+ __export(checkbox_exports, {
23
+ Checkbox: () => Checkbox,
24
+ CheckboxIcon: () => CheckboxIcon,
25
+ useCheckbox: () => useCheckbox
26
+ });
27
+ module.exports = __toCommonJS(checkbox_exports);
28
+ var import_core = require("@yamada-ui/core");
29
+ var import_form_control2 = require("@yamada-ui/form-control");
30
+ var import_motion = require("@yamada-ui/motion");
31
+ var import_use_focus_visible = require("@yamada-ui/use-focus-visible");
32
+ var import_utils2 = require("@yamada-ui/utils");
33
+ var import_react2 = require("react");
34
+
35
+ // src/checkbox-group.tsx
36
+ var import_form_control = require("@yamada-ui/form-control");
37
+ var import_layouts = require("@yamada-ui/layouts");
38
+ var import_use_controllable_state = require("@yamada-ui/use-controllable-state");
39
+ var import_utils = require("@yamada-ui/utils");
40
+ var import_react = require("react");
41
+ var import_jsx_runtime = require("react/jsx-runtime");
42
+ var isEvent = (value) => value && (0, import_utils.isObject)(value) && (0, import_utils.isObject)(value.target);
43
+ var useCheckboxGroup = ({
44
+ isNative,
45
+ ...props
46
+ }) => {
47
+ props.onChange = (0, import_utils.useCallbackRef)(props.onChange);
48
+ const [value, setValue] = (0, import_use_controllable_state.useControllableState)({
49
+ value: props.value,
50
+ defaultValue: props.defaultValue || [],
51
+ onChange: props.onChange
52
+ });
53
+ const onChange = (0, import_react.useCallback)(
54
+ (evOrValue) => {
55
+ const isChecked = isEvent(evOrValue) ? evOrValue.target.checked : !value.includes(evOrValue);
56
+ const selectedValue = isEvent(evOrValue) ? evOrValue.target.value : evOrValue;
57
+ const nextValue = isChecked ? [...value, selectedValue] : value.filter((v) => String(v) !== String(selectedValue));
58
+ setValue(nextValue);
59
+ },
60
+ [value, setValue]
61
+ );
62
+ const getCheckboxProps = (0, import_react.useCallback)(
63
+ (props2 = {}, ref = null) => ({
64
+ ...props2,
65
+ ref,
66
+ [isNative ? "checked" : "isChecked"]: value.some(
67
+ (val) => String(props2.value) === String(val)
68
+ ),
69
+ onChange
70
+ }),
71
+ [onChange, isNative, value]
72
+ );
73
+ return { value, setValue, onChange, getCheckboxProps };
74
+ };
75
+ var [CheckboxGroupProvider, useCheckboxGroupContext] = (0, import_utils.createContext)(
76
+ {
77
+ strict: false,
78
+ name: "CheckboxGroupContext"
79
+ }
80
+ );
81
+ var CheckboxGroup = (0, import_react.forwardRef)(
82
+ ({
83
+ className,
84
+ size,
85
+ variant,
86
+ colorScheme,
87
+ children,
88
+ direction = "column",
89
+ gap,
90
+ ...props
91
+ }, ref) => {
92
+ const { value, onChange } = useCheckboxGroup(props);
93
+ const { isRequired, isReadOnly, isDisabled, isInvalid } = (0, import_form_control.useFormControl)(props);
94
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
95
+ CheckboxGroupProvider,
96
+ {
97
+ value: {
98
+ size,
99
+ variant,
100
+ colorScheme,
101
+ isRequired,
102
+ isReadOnly,
103
+ isDisabled,
104
+ isInvalid,
105
+ value,
106
+ onChange
107
+ },
108
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
109
+ import_layouts.Flex,
110
+ {
111
+ ref,
112
+ className: (0, import_utils.cx)("ui-checkbox-group", className),
113
+ role: "group",
114
+ direction,
115
+ gap: gap != null ? gap : direction === "row" ? "1rem" : void 0,
116
+ ...(0, import_utils.omitObject)(props, ["value", "defaultValue", "onChange"]),
117
+ children
118
+ }
119
+ )
120
+ }
121
+ );
122
+ }
123
+ );
124
+ CheckboxGroup.displayName = "CheckboxGroup";
125
+
126
+ // src/checkbox.tsx
127
+ var import_jsx_runtime2 = require("react/jsx-runtime");
128
+ var useCheckbox = (props) => {
129
+ const {
130
+ id,
131
+ name,
132
+ value,
133
+ defaultChecked,
134
+ tabIndex,
135
+ required,
136
+ disabled,
137
+ readOnly,
138
+ isIndeterminate,
139
+ ...rest
140
+ } = (0, import_form_control2.useFormControlProps)(props);
141
+ const [isFocusVisible, setIsFocusVisible] = (0, import_react2.useState)(false);
142
+ const [isFocused, setFocused] = (0, import_react2.useState)(false);
143
+ const [isHovered, setHovered] = (0, import_react2.useState)(false);
144
+ const [isActive, setActive] = (0, import_react2.useState)(false);
145
+ const inputRef = (0, import_react2.useRef)(null);
146
+ const [isLabel, setIsLabel] = (0, import_react2.useState)(true);
147
+ const [isChecked, setIsChecked] = (0, import_react2.useState)(!!defaultChecked);
148
+ const isControlled = props.isChecked !== void 0;
149
+ const checked = isControlled ? props.isChecked : isChecked;
150
+ const onChange = (0, import_utils2.useCallbackRef)(
151
+ (ev) => {
152
+ var _a;
153
+ if (readOnly || disabled) {
154
+ ev.preventDefault();
155
+ return;
156
+ }
157
+ if (!isControlled)
158
+ setIsChecked(!checked || isIndeterminate ? true : ev.target.checked);
159
+ (_a = rest.onChange) == null ? void 0 : _a.call(rest, ev);
160
+ },
161
+ [readOnly, disabled, isControlled, checked, isIndeterminate]
162
+ );
163
+ const onBlur = (0, import_utils2.useCallbackRef)(rest.onBlur);
164
+ const onFocus = (0, import_utils2.useCallbackRef)(rest.onFocus);
165
+ const onKeyDown = (0, import_react2.useCallback)(
166
+ ({ key }) => {
167
+ if (key === " ")
168
+ setActive(true);
169
+ },
170
+ [setActive]
171
+ );
172
+ const onKeyUp = (0, import_react2.useCallback)(
173
+ ({ key }) => {
174
+ if (key === " ")
175
+ setActive(false);
176
+ },
177
+ [setActive]
178
+ );
179
+ (0, import_react2.useEffect)(() => {
180
+ return (0, import_use_focus_visible.trackFocusVisible)(setIsFocusVisible);
181
+ }, []);
182
+ (0, import_utils2.useSafeLayoutEffect)(() => {
183
+ if (inputRef.current)
184
+ inputRef.current.indeterminate = Boolean(isIndeterminate);
185
+ }, [isIndeterminate]);
186
+ (0, import_utils2.useUpdateEffect)(() => {
187
+ if (disabled)
188
+ setFocused(false);
189
+ }, [disabled, setFocused]);
190
+ (0, import_utils2.useSafeLayoutEffect)(() => {
191
+ var _a;
192
+ if (!((_a = inputRef.current) == null ? void 0 : _a.form))
193
+ return;
194
+ inputRef.current.form.onreset = () => setIsChecked(!!defaultChecked);
195
+ }, []);
196
+ (0, import_utils2.useSafeLayoutEffect)(() => {
197
+ if (!inputRef.current)
198
+ return;
199
+ if (inputRef.current.checked !== checked)
200
+ setIsChecked(inputRef.current.checked);
201
+ }, [inputRef.current]);
202
+ const getContainerProps = (0, import_react2.useCallback)(
203
+ (props2 = {}, ref = null) => ({
204
+ ...(0, import_utils2.pickObject)(rest, import_form_control2.formControlProperties),
205
+ ...props2,
206
+ ref: (0, import_utils2.mergeRefs)(ref, (el) => {
207
+ if (el)
208
+ setIsLabel(el.tagName === "LABEL");
209
+ }),
210
+ "data-checked": (0, import_utils2.dataAttr)(checked),
211
+ onClick: (0, import_utils2.handlerAll)(props2.onClick, () => {
212
+ var _a;
213
+ if (isLabel)
214
+ return;
215
+ (_a = inputRef.current) == null ? void 0 : _a.click();
216
+ requestAnimationFrame(() => {
217
+ var _a2;
218
+ return (_a2 = inputRef.current) == null ? void 0 : _a2.focus();
219
+ });
220
+ })
221
+ }),
222
+ [checked, isLabel, rest]
223
+ );
224
+ const getIconProps = (0, import_react2.useCallback)(
225
+ (props2 = {}, ref = null) => ({
226
+ ...(0, import_utils2.pickObject)(rest, import_form_control2.formControlProperties),
227
+ ...props2,
228
+ ref,
229
+ "data-active": (0, import_utils2.dataAttr)(isActive),
230
+ "data-hover": (0, import_utils2.dataAttr)(isHovered),
231
+ "data-checked": (0, import_utils2.dataAttr)(checked),
232
+ "data-focus": (0, import_utils2.dataAttr)(isFocused),
233
+ "data-focus-visible": (0, import_utils2.dataAttr)(isFocused && isFocusVisible),
234
+ "data-indeterminate": (0, import_utils2.dataAttr)(isIndeterminate),
235
+ "aria-hidden": true,
236
+ onMouseDown: (0, import_utils2.handlerAll)(props2.onMouseDown, (ev) => {
237
+ if (isFocused)
238
+ ev.preventDefault();
239
+ setActive(true);
240
+ }),
241
+ onMouseUp: (0, import_utils2.handlerAll)(props2.onMouseUp, () => setActive(false)),
242
+ onMouseEnter: (0, import_utils2.handlerAll)(props2.onMouseEnter, () => setHovered(true)),
243
+ onMouseLeave: (0, import_utils2.handlerAll)(props2.onMouseLeave, () => setHovered(false))
244
+ }),
245
+ [isActive, checked, isFocused, isHovered, isFocusVisible, isIndeterminate, rest]
246
+ );
247
+ const getInputProps = (0, import_react2.useCallback)(
248
+ (props2 = {}, ref = null) => ({
249
+ ...(0, import_utils2.pickObject)(rest, import_form_control2.formControlProperties),
250
+ ...props2,
251
+ ref: (0, import_utils2.mergeRefs)(inputRef, ref),
252
+ id,
253
+ type: "checkbox",
254
+ name,
255
+ value,
256
+ tabIndex,
257
+ required,
258
+ disabled,
259
+ readOnly,
260
+ checked,
261
+ style: {
262
+ border: "0px",
263
+ clip: "rect(0px, 0px, 0px, 0px)",
264
+ height: "1px",
265
+ width: "1px",
266
+ margin: "-1px",
267
+ padding: "0px",
268
+ overflow: "hidden",
269
+ whiteSpace: "nowrap",
270
+ position: "absolute"
271
+ },
272
+ onChange: (0, import_utils2.handlerAll)(props2.onChange, onChange),
273
+ onBlur: (0, import_utils2.handlerAll)(props2.onBlur, onBlur, () => setFocused(false)),
274
+ onFocus: (0, import_utils2.handlerAll)(props2.onFocus, onFocus, () => setFocused(true)),
275
+ onKeyDown: (0, import_utils2.handlerAll)(props2.onKeyDown, onKeyDown),
276
+ onKeyUp: (0, import_utils2.handlerAll)(props2.onKeyUp, onKeyUp)
277
+ }),
278
+ [
279
+ rest,
280
+ id,
281
+ name,
282
+ value,
283
+ tabIndex,
284
+ required,
285
+ disabled,
286
+ readOnly,
287
+ checked,
288
+ onChange,
289
+ onBlur,
290
+ onFocus,
291
+ onKeyDown,
292
+ onKeyUp
293
+ ]
294
+ );
295
+ const getLabelProps = (0, import_react2.useCallback)(
296
+ (props2 = {}, ref = null) => ({
297
+ ...(0, import_utils2.pickObject)(rest, import_form_control2.formControlProperties),
298
+ ...props2,
299
+ ref,
300
+ "data-checked": (0, import_utils2.dataAttr)(checked),
301
+ onMouseDown: (0, import_utils2.handlerAll)(props2.onMouseDown, (ev) => {
302
+ ev.preventDefault();
303
+ ev.stopPropagation();
304
+ }),
305
+ onTouchStart: (0, import_utils2.handlerAll)(props2.onTouchStart, (ev) => {
306
+ ev.preventDefault();
307
+ ev.stopPropagation();
308
+ })
309
+ }),
310
+ [checked, rest]
311
+ );
312
+ return {
313
+ isFocusVisible,
314
+ isFocused,
315
+ isHovered,
316
+ isActive,
317
+ isChecked: checked,
318
+ isIndeterminate,
319
+ getContainerProps,
320
+ getIconProps,
321
+ getInputProps,
322
+ getLabelProps
323
+ };
324
+ };
325
+ var Checkbox = (0, import_react2.forwardRef)(
326
+ (props, ref) => {
327
+ var _a, _b, _c, _d, _e;
328
+ const group = useCheckboxGroupContext();
329
+ const control = (0, import_form_control2.useFormControl)(props);
330
+ const [styles, mergedProps] = (0, import_core.useMultiComponentStyle)("Checkbox", {
331
+ ...group ? (0, import_utils2.omitObject)(group, ["value"]) : {},
332
+ ...props
333
+ });
334
+ const {
335
+ className,
336
+ gap = "0.5rem",
337
+ isRequired = (_a = group == null ? void 0 : group.isRequired) != null ? _a : control.isRequired,
338
+ isReadOnly = (_b = group == null ? void 0 : group.isReadOnly) != null ? _b : control.isReadOnly,
339
+ isDisabled = (_c = group == null ? void 0 : group.isDisabled) != null ? _c : control.isDisabled,
340
+ isInvalid = (_d = group == null ? void 0 : group.isInvalid) != null ? _d : control.isInvalid,
341
+ iconProps,
342
+ inputProps,
343
+ labelProps,
344
+ children,
345
+ ...rest
346
+ } = (0, import_core.omitThemeProps)(mergedProps);
347
+ const {
348
+ isChecked,
349
+ isIndeterminate,
350
+ getContainerProps,
351
+ getInputProps,
352
+ getIconProps,
353
+ getLabelProps
354
+ } = useCheckbox({
355
+ ...rest,
356
+ isRequired,
357
+ isReadOnly,
358
+ isDisabled,
359
+ isInvalid,
360
+ isChecked: (group == null ? void 0 : group.value) && rest.value ? group.value.includes(rest.value) : rest.isChecked,
361
+ onChange: (group == null ? void 0 : group.onChange) && rest.value ? (0, import_utils2.funcAll)(group.onChange, rest.onChange) : rest.onChange
362
+ });
363
+ const cloneIcon = (0, import_react2.cloneElement)((_e = iconProps == null ? void 0 : iconProps.children) != null ? _e : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(CheckboxIcon, {}), {
364
+ __css: {
365
+ opacity: isChecked || isIndeterminate ? 1 : 0,
366
+ transform: isChecked || isIndeterminate ? "scale(1)" : "scale(0.95)",
367
+ transitionProperty: "transform",
368
+ transitionDuration: "normal"
369
+ },
370
+ isIndeterminate,
371
+ isChecked,
372
+ isRequired,
373
+ isReadOnly,
374
+ isDisabled,
375
+ isInvalid
376
+ });
377
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
378
+ import_core.ui.label,
379
+ {
380
+ className: (0, import_utils2.cx)("ui-checkbox", className),
381
+ ...getContainerProps(),
382
+ __css: {
383
+ cursor: "pointer",
384
+ position: "relative",
385
+ display: "inline-flex",
386
+ alignItems: "center",
387
+ verticalAlign: "top",
388
+ gap,
389
+ ...styles.container
390
+ },
391
+ ...(0, import_utils2.omitObject)(rest, [
392
+ "id",
393
+ "name",
394
+ "value",
395
+ "defaultValue",
396
+ "defaultChecked",
397
+ "isChecked",
398
+ "isIndeterminate",
399
+ "onChange",
400
+ "onBlur",
401
+ "onFocus",
402
+ "tabIndex"
403
+ ]),
404
+ children: [
405
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_core.ui.input, { className: "ui-checkbox-input", ...getInputProps(inputProps, ref) }),
406
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
407
+ import_core.ui.span,
408
+ {
409
+ className: "ui-checkbox-icon",
410
+ __css: {
411
+ pointerEvents: isReadOnly ? "none" : void 0,
412
+ position: "relative",
413
+ display: "inline-block",
414
+ userSelect: "none",
415
+ ...styles.icon
416
+ },
417
+ ...getIconProps((0, import_utils2.omitObject)(iconProps != null ? iconProps : { children: void 0 }, ["children"])),
418
+ children: cloneIcon
419
+ }
420
+ ),
421
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
422
+ import_core.ui.span,
423
+ {
424
+ className: "ui-checkbox-label",
425
+ __css: { ...styles.label },
426
+ ...getLabelProps(labelProps),
427
+ children
428
+ }
429
+ )
430
+ ]
431
+ }
432
+ );
433
+ }
434
+ );
435
+ Checkbox.displayName = "Checkbox";
436
+ var CheckboxIcon = ({
437
+ isIndeterminate,
438
+ isChecked,
439
+ isRequired,
440
+ isReadOnly,
441
+ isDisabled,
442
+ isInvalid,
443
+ ...rest
444
+ }) => {
445
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_motion.AnimatePresence, { initial: false, children: isIndeterminate || isChecked ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
446
+ import_core.ui.div,
447
+ {
448
+ __css: {
449
+ position: "absolute",
450
+ top: "50%",
451
+ left: "50%",
452
+ transform: "translate(-50%, -50%)"
453
+ },
454
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
455
+ import_core.ui.div,
456
+ {
457
+ as: import_motion.motion.div,
458
+ variants: {
459
+ unchecked: { scale: 0.5 },
460
+ checked: { scale: 1 }
461
+ },
462
+ initial: "unchecked",
463
+ animate: "checked",
464
+ exit: "unchecked",
465
+ style: {
466
+ display: "flex",
467
+ alignItems: "center",
468
+ justifyContent: "center"
469
+ },
470
+ children: isIndeterminate ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(IndeterminateIcon, { ...rest }) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(CheckIcon, { ...rest })
471
+ }
472
+ )
473
+ }
474
+ ) : null });
475
+ };
476
+ var CheckIcon = (props) => {
477
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
478
+ import_core.ui.svg,
479
+ {
480
+ as: import_motion.motion.svg,
481
+ width: "1.2em",
482
+ viewBox: "0 0 12 10",
483
+ variants: {
484
+ unchecked: {
485
+ opacity: 0,
486
+ strokeDashoffset: 16
487
+ },
488
+ checked: {
489
+ opacity: 1,
490
+ strokeDashoffset: 0,
491
+ transition: { duration: 0.2 }
492
+ }
493
+ },
494
+ style: {
495
+ fill: "none",
496
+ strokeWidth: 2,
497
+ stroke: "currentColor",
498
+ strokeDasharray: 16
499
+ },
500
+ ...props,
501
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("polyline", { points: "1.5 6 4.5 9 10.5 1" })
502
+ }
503
+ );
504
+ };
505
+ var IndeterminateIcon = (props) => {
506
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
507
+ import_core.ui.svg,
508
+ {
509
+ as: import_motion.motion.svg,
510
+ width: "1.2em",
511
+ viewBox: "0 0 24 24",
512
+ variants: {
513
+ unchecked: {
514
+ scaleX: 0.65,
515
+ opacity: 0
516
+ },
517
+ checked: {
518
+ scaleX: 1,
519
+ opacity: 1,
520
+ transition: {
521
+ scaleX: { duration: 0 },
522
+ opacity: { duration: 0.02 }
523
+ }
524
+ }
525
+ },
526
+ style: { stroke: "currentColor", strokeWidth: 4 },
527
+ ...props,
528
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("line", { x1: "21", x2: "3", y1: "12", y2: "12" })
529
+ }
530
+ );
531
+ };
532
+ // Annotate the CommonJS export names for ESM import in node:
533
+ 0 && (module.exports = {
534
+ Checkbox,
535
+ CheckboxIcon,
536
+ useCheckbox
537
+ });
@@ -0,0 +1,11 @@
1
+ import {
2
+ Checkbox,
3
+ CheckboxIcon,
4
+ useCheckbox
5
+ } from "./chunk-WVMK5AIG.mjs";
6
+ import "./chunk-3MZZPRTR.mjs";
7
+ export {
8
+ Checkbox,
9
+ CheckboxIcon,
10
+ useCheckbox
11
+ };
@@ -0,0 +1,102 @@
1
+ // src/checkbox-group.tsx
2
+ import { useFormControl } from "@yamada-ui/form-control";
3
+ import { Flex } from "@yamada-ui/layouts";
4
+ import { useControllableState } from "@yamada-ui/use-controllable-state";
5
+ import {
6
+ createContext,
7
+ cx,
8
+ isObject,
9
+ omitObject,
10
+ useCallbackRef
11
+ } from "@yamada-ui/utils";
12
+ import { forwardRef, useCallback } from "react";
13
+ import { jsx } from "react/jsx-runtime";
14
+ var isEvent = (value) => value && isObject(value) && isObject(value.target);
15
+ var useCheckboxGroup = ({
16
+ isNative,
17
+ ...props
18
+ }) => {
19
+ props.onChange = useCallbackRef(props.onChange);
20
+ const [value, setValue] = useControllableState({
21
+ value: props.value,
22
+ defaultValue: props.defaultValue || [],
23
+ onChange: props.onChange
24
+ });
25
+ const onChange = useCallback(
26
+ (evOrValue) => {
27
+ const isChecked = isEvent(evOrValue) ? evOrValue.target.checked : !value.includes(evOrValue);
28
+ const selectedValue = isEvent(evOrValue) ? evOrValue.target.value : evOrValue;
29
+ const nextValue = isChecked ? [...value, selectedValue] : value.filter((v) => String(v) !== String(selectedValue));
30
+ setValue(nextValue);
31
+ },
32
+ [value, setValue]
33
+ );
34
+ const getCheckboxProps = useCallback(
35
+ (props2 = {}, ref = null) => ({
36
+ ...props2,
37
+ ref,
38
+ [isNative ? "checked" : "isChecked"]: value.some(
39
+ (val) => String(props2.value) === String(val)
40
+ ),
41
+ onChange
42
+ }),
43
+ [onChange, isNative, value]
44
+ );
45
+ return { value, setValue, onChange, getCheckboxProps };
46
+ };
47
+ var [CheckboxGroupProvider, useCheckboxGroupContext] = createContext(
48
+ {
49
+ strict: false,
50
+ name: "CheckboxGroupContext"
51
+ }
52
+ );
53
+ var CheckboxGroup = forwardRef(
54
+ ({
55
+ className,
56
+ size,
57
+ variant,
58
+ colorScheme,
59
+ children,
60
+ direction = "column",
61
+ gap,
62
+ ...props
63
+ }, ref) => {
64
+ const { value, onChange } = useCheckboxGroup(props);
65
+ const { isRequired, isReadOnly, isDisabled, isInvalid } = useFormControl(props);
66
+ return /* @__PURE__ */ jsx(
67
+ CheckboxGroupProvider,
68
+ {
69
+ value: {
70
+ size,
71
+ variant,
72
+ colorScheme,
73
+ isRequired,
74
+ isReadOnly,
75
+ isDisabled,
76
+ isInvalid,
77
+ value,
78
+ onChange
79
+ },
80
+ children: /* @__PURE__ */ jsx(
81
+ Flex,
82
+ {
83
+ ref,
84
+ className: cx("ui-checkbox-group", className),
85
+ role: "group",
86
+ direction,
87
+ gap: gap != null ? gap : direction === "row" ? "1rem" : void 0,
88
+ ...omitObject(props, ["value", "defaultValue", "onChange"]),
89
+ children
90
+ }
91
+ )
92
+ }
93
+ );
94
+ }
95
+ );
96
+ CheckboxGroup.displayName = "CheckboxGroup";
97
+
98
+ export {
99
+ useCheckboxGroup,
100
+ useCheckboxGroupContext,
101
+ CheckboxGroup
102
+ };