@radix-ui/react-checkbox 0.0.0-20250116175529

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/README.md ADDED
@@ -0,0 +1,13 @@
1
+ # `react-checkbox`
2
+
3
+ ## Installation
4
+
5
+ ```sh
6
+ $ yarn add @radix-ui/react-checkbox
7
+ # or
8
+ $ npm install @radix-ui/react-checkbox
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ View docs [here](https://radix-ui.com/primitives/docs/components/checkbox).
@@ -0,0 +1,27 @@
1
+ import * as _radix_ui_react_context from '@radix-ui/react-context';
2
+ import * as React from 'react';
3
+ import { Primitive } from '@radix-ui/react-primitive';
4
+
5
+ declare const createCheckboxScope: _radix_ui_react_context.CreateScope;
6
+ type CheckedState = boolean | 'indeterminate';
7
+ type PrimitiveButtonProps = React.ComponentPropsWithoutRef<typeof Primitive.button>;
8
+ interface CheckboxProps extends Omit<PrimitiveButtonProps, 'checked' | 'defaultChecked'> {
9
+ checked?: CheckedState;
10
+ defaultChecked?: CheckedState;
11
+ required?: boolean;
12
+ onCheckedChange?(checked: CheckedState): void;
13
+ }
14
+ declare const Checkbox: React.ForwardRefExoticComponent<CheckboxProps & React.RefAttributes<HTMLButtonElement>>;
15
+ type PrimitiveSpanProps = React.ComponentPropsWithoutRef<typeof Primitive.span>;
16
+ interface CheckboxIndicatorProps extends PrimitiveSpanProps {
17
+ /**
18
+ * Used to force mounting when more control is needed. Useful when
19
+ * controlling animation with React animation libraries.
20
+ */
21
+ forceMount?: true;
22
+ }
23
+ declare const CheckboxIndicator: React.ForwardRefExoticComponent<CheckboxIndicatorProps & React.RefAttributes<HTMLSpanElement>>;
24
+ declare const Root: React.ForwardRefExoticComponent<CheckboxProps & React.RefAttributes<HTMLButtonElement>>;
25
+ declare const Indicator: React.ForwardRefExoticComponent<CheckboxIndicatorProps & React.RefAttributes<HTMLSpanElement>>;
26
+
27
+ export { Checkbox, CheckboxIndicator, type CheckboxIndicatorProps, type CheckboxProps, type CheckedState, Indicator, Root, createCheckboxScope };
@@ -0,0 +1,27 @@
1
+ import * as _radix_ui_react_context from '@radix-ui/react-context';
2
+ import * as React from 'react';
3
+ import { Primitive } from '@radix-ui/react-primitive';
4
+
5
+ declare const createCheckboxScope: _radix_ui_react_context.CreateScope;
6
+ type CheckedState = boolean | 'indeterminate';
7
+ type PrimitiveButtonProps = React.ComponentPropsWithoutRef<typeof Primitive.button>;
8
+ interface CheckboxProps extends Omit<PrimitiveButtonProps, 'checked' | 'defaultChecked'> {
9
+ checked?: CheckedState;
10
+ defaultChecked?: CheckedState;
11
+ required?: boolean;
12
+ onCheckedChange?(checked: CheckedState): void;
13
+ }
14
+ declare const Checkbox: React.ForwardRefExoticComponent<CheckboxProps & React.RefAttributes<HTMLButtonElement>>;
15
+ type PrimitiveSpanProps = React.ComponentPropsWithoutRef<typeof Primitive.span>;
16
+ interface CheckboxIndicatorProps extends PrimitiveSpanProps {
17
+ /**
18
+ * Used to force mounting when more control is needed. Useful when
19
+ * controlling animation with React animation libraries.
20
+ */
21
+ forceMount?: true;
22
+ }
23
+ declare const CheckboxIndicator: React.ForwardRefExoticComponent<CheckboxIndicatorProps & React.RefAttributes<HTMLSpanElement>>;
24
+ declare const Root: React.ForwardRefExoticComponent<CheckboxProps & React.RefAttributes<HTMLButtonElement>>;
25
+ declare const Indicator: React.ForwardRefExoticComponent<CheckboxIndicatorProps & React.RefAttributes<HTMLSpanElement>>;
26
+
27
+ export { Checkbox, CheckboxIndicator, type CheckboxIndicatorProps, type CheckboxProps, type CheckedState, Indicator, Root, createCheckboxScope };
package/dist/index.js ADDED
@@ -0,0 +1,197 @@
1
+ "use strict";
2
+ "use client";
3
+ var __create = Object.create;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __export = (target, all) => {
10
+ for (var name in all)
11
+ __defProp(target, name, { get: all[name], enumerable: true });
12
+ };
13
+ var __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from))
16
+ if (!__hasOwnProp.call(to, key) && key !== except)
17
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
+ }
19
+ return to;
20
+ };
21
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
+ // If the importer is in node compatibility mode or this is not an ESM
23
+ // file that has been converted to a CommonJS file using a Babel-
24
+ // compatible transform (i.e. "__esModule" has not been set), then set
25
+ // "default" to the CommonJS "module.exports" for node compatibility.
26
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
+ mod
28
+ ));
29
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
+
31
+ // packages/react/checkbox/src/index.ts
32
+ var src_exports = {};
33
+ __export(src_exports, {
34
+ Checkbox: () => Checkbox,
35
+ CheckboxIndicator: () => CheckboxIndicator,
36
+ Indicator: () => Indicator,
37
+ Root: () => Root,
38
+ createCheckboxScope: () => createCheckboxScope
39
+ });
40
+ module.exports = __toCommonJS(src_exports);
41
+
42
+ // packages/react/checkbox/src/Checkbox.tsx
43
+ var React = __toESM(require("react"));
44
+ var import_react_compose_refs = require("@radix-ui/react-compose-refs");
45
+ var import_react_context = require("@radix-ui/react-context");
46
+ var import_primitive = require("@radix-ui/primitive");
47
+ var import_react_use_controllable_state = require("@radix-ui/react-use-controllable-state");
48
+ var import_react_use_previous = require("@radix-ui/react-use-previous");
49
+ var import_react_use_size = require("@radix-ui/react-use-size");
50
+ var import_react_presence = require("@radix-ui/react-presence");
51
+ var import_react_primitive = require("@radix-ui/react-primitive");
52
+ var import_jsx_runtime = require("react/jsx-runtime");
53
+ var CHECKBOX_NAME = "Checkbox";
54
+ var [createCheckboxContext, createCheckboxScope] = (0, import_react_context.createContextScope)(CHECKBOX_NAME);
55
+ var [CheckboxProvider, useCheckboxContext] = createCheckboxContext(CHECKBOX_NAME);
56
+ var Checkbox = React.forwardRef(
57
+ (props, forwardedRef) => {
58
+ const {
59
+ __scopeCheckbox,
60
+ name,
61
+ checked: checkedProp,
62
+ defaultChecked,
63
+ required,
64
+ disabled,
65
+ value = "on",
66
+ onCheckedChange,
67
+ form,
68
+ ...checkboxProps
69
+ } = props;
70
+ const [button, setButton] = React.useState(null);
71
+ const composedRefs = (0, import_react_compose_refs.useComposedRefs)(forwardedRef, (node) => setButton(node));
72
+ const hasConsumerStoppedPropagationRef = React.useRef(false);
73
+ const isFormControl = button ? form || !!button.closest("form") : true;
74
+ const [checked = false, setChecked] = (0, import_react_use_controllable_state.useControllableState)({
75
+ prop: checkedProp,
76
+ defaultProp: defaultChecked,
77
+ onChange: onCheckedChange
78
+ });
79
+ const initialCheckedStateRef = React.useRef(checked);
80
+ React.useEffect(() => {
81
+ const form2 = button?.form;
82
+ if (form2) {
83
+ const reset = () => setChecked(initialCheckedStateRef.current);
84
+ form2.addEventListener("reset", reset);
85
+ return () => form2.removeEventListener("reset", reset);
86
+ }
87
+ }, [button, setChecked]);
88
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(CheckboxProvider, { scope: __scopeCheckbox, state: checked, disabled, children: [
89
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
90
+ import_react_primitive.Primitive.button,
91
+ {
92
+ type: "button",
93
+ role: "checkbox",
94
+ "aria-checked": isIndeterminate(checked) ? "mixed" : checked,
95
+ "aria-required": required,
96
+ "data-state": getState(checked),
97
+ "data-disabled": disabled ? "" : void 0,
98
+ disabled,
99
+ value,
100
+ ...checkboxProps,
101
+ ref: composedRefs,
102
+ onKeyDown: (0, import_primitive.composeEventHandlers)(props.onKeyDown, (event) => {
103
+ if (event.key === "Enter") event.preventDefault();
104
+ }),
105
+ onClick: (0, import_primitive.composeEventHandlers)(props.onClick, (event) => {
106
+ setChecked((prevChecked) => isIndeterminate(prevChecked) ? true : !prevChecked);
107
+ if (isFormControl) {
108
+ hasConsumerStoppedPropagationRef.current = event.isPropagationStopped();
109
+ if (!hasConsumerStoppedPropagationRef.current) event.stopPropagation();
110
+ }
111
+ })
112
+ }
113
+ ),
114
+ isFormControl && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
115
+ BubbleInput,
116
+ {
117
+ control: button,
118
+ bubbles: !hasConsumerStoppedPropagationRef.current,
119
+ name,
120
+ value,
121
+ checked,
122
+ required,
123
+ disabled,
124
+ form,
125
+ style: { transform: "translateX(-100%)" },
126
+ defaultChecked: isIndeterminate(defaultChecked) ? false : defaultChecked
127
+ }
128
+ )
129
+ ] });
130
+ }
131
+ );
132
+ Checkbox.displayName = CHECKBOX_NAME;
133
+ var INDICATOR_NAME = "CheckboxIndicator";
134
+ var CheckboxIndicator = React.forwardRef(
135
+ (props, forwardedRef) => {
136
+ const { __scopeCheckbox, forceMount, ...indicatorProps } = props;
137
+ const context = useCheckboxContext(INDICATOR_NAME, __scopeCheckbox);
138
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_presence.Presence, { present: forceMount || isIndeterminate(context.state) || context.state === true, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
139
+ import_react_primitive.Primitive.span,
140
+ {
141
+ "data-state": getState(context.state),
142
+ "data-disabled": context.disabled ? "" : void 0,
143
+ ...indicatorProps,
144
+ ref: forwardedRef,
145
+ style: { pointerEvents: "none", ...props.style }
146
+ }
147
+ ) });
148
+ }
149
+ );
150
+ CheckboxIndicator.displayName = INDICATOR_NAME;
151
+ var BubbleInput = (props) => {
152
+ const { control, checked, bubbles = true, defaultChecked, ...inputProps } = props;
153
+ const ref = React.useRef(null);
154
+ const prevChecked = (0, import_react_use_previous.usePrevious)(checked);
155
+ const controlSize = (0, import_react_use_size.useSize)(control);
156
+ React.useEffect(() => {
157
+ const input = ref.current;
158
+ const inputProto = window.HTMLInputElement.prototype;
159
+ const descriptor = Object.getOwnPropertyDescriptor(inputProto, "checked");
160
+ const setChecked = descriptor.set;
161
+ if (prevChecked !== checked && setChecked) {
162
+ const event = new Event("click", { bubbles });
163
+ input.indeterminate = isIndeterminate(checked);
164
+ setChecked.call(input, isIndeterminate(checked) ? false : checked);
165
+ input.dispatchEvent(event);
166
+ }
167
+ }, [prevChecked, checked, bubbles]);
168
+ const defaultCheckedRef = React.useRef(isIndeterminate(checked) ? false : checked);
169
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
170
+ "input",
171
+ {
172
+ type: "checkbox",
173
+ "aria-hidden": true,
174
+ defaultChecked: defaultChecked ?? defaultCheckedRef.current,
175
+ ...inputProps,
176
+ tabIndex: -1,
177
+ ref,
178
+ style: {
179
+ ...props.style,
180
+ ...controlSize,
181
+ position: "absolute",
182
+ pointerEvents: "none",
183
+ opacity: 0,
184
+ margin: 0
185
+ }
186
+ }
187
+ );
188
+ };
189
+ function isIndeterminate(checked) {
190
+ return checked === "indeterminate";
191
+ }
192
+ function getState(checked) {
193
+ return isIndeterminate(checked) ? "indeterminate" : checked ? "checked" : "unchecked";
194
+ }
195
+ var Root = Checkbox;
196
+ var Indicator = CheckboxIndicator;
197
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/index.ts", "../src/Checkbox.tsx"],
4
+ "sourcesContent": ["'use client';\nexport {\n createCheckboxScope,\n //\n Checkbox,\n CheckboxIndicator,\n //\n Root,\n Indicator,\n} from './Checkbox';\nexport type { CheckboxProps, CheckboxIndicatorProps, CheckedState } from './Checkbox';\n", "import * as React from 'react';\nimport { useComposedRefs } from '@radix-ui/react-compose-refs';\nimport { createContextScope } from '@radix-ui/react-context';\nimport { composeEventHandlers } from '@radix-ui/primitive';\nimport { useControllableState } from '@radix-ui/react-use-controllable-state';\nimport { usePrevious } from '@radix-ui/react-use-previous';\nimport { useSize } from '@radix-ui/react-use-size';\nimport { Presence } from '@radix-ui/react-presence';\nimport { Primitive } from '@radix-ui/react-primitive';\n\nimport type { Scope } from '@radix-ui/react-context';\n\n/* -------------------------------------------------------------------------------------------------\n * Checkbox\n * -----------------------------------------------------------------------------------------------*/\n\nconst CHECKBOX_NAME = 'Checkbox';\n\ntype ScopedProps<P> = P & { __scopeCheckbox?: Scope };\nconst [createCheckboxContext, createCheckboxScope] = createContextScope(CHECKBOX_NAME);\n\ntype CheckedState = boolean | 'indeterminate';\n\ntype CheckboxContextValue = {\n state: CheckedState;\n disabled?: boolean;\n};\n\nconst [CheckboxProvider, useCheckboxContext] =\n createCheckboxContext<CheckboxContextValue>(CHECKBOX_NAME);\n\ntype CheckboxElement = React.ElementRef<typeof Primitive.button>;\ntype PrimitiveButtonProps = React.ComponentPropsWithoutRef<typeof Primitive.button>;\ninterface CheckboxProps extends Omit<PrimitiveButtonProps, 'checked' | 'defaultChecked'> {\n checked?: CheckedState;\n defaultChecked?: CheckedState;\n required?: boolean;\n onCheckedChange?(checked: CheckedState): void;\n}\n\nconst Checkbox = React.forwardRef<CheckboxElement, CheckboxProps>(\n (props: ScopedProps<CheckboxProps>, forwardedRef) => {\n const {\n __scopeCheckbox,\n name,\n checked: checkedProp,\n defaultChecked,\n required,\n disabled,\n value = 'on',\n onCheckedChange,\n form,\n ...checkboxProps\n } = props;\n const [button, setButton] = React.useState<HTMLButtonElement | null>(null);\n const composedRefs = useComposedRefs(forwardedRef, (node) => setButton(node));\n const hasConsumerStoppedPropagationRef = React.useRef(false);\n // We set this to true by default so that events bubble to forms without JS (SSR)\n const isFormControl = button ? form || !!button.closest('form') : true;\n const [checked = false, setChecked] = useControllableState({\n prop: checkedProp,\n defaultProp: defaultChecked,\n onChange: onCheckedChange,\n });\n const initialCheckedStateRef = React.useRef(checked);\n React.useEffect(() => {\n const form = button?.form;\n if (form) {\n const reset = () => setChecked(initialCheckedStateRef.current);\n form.addEventListener('reset', reset);\n return () => form.removeEventListener('reset', reset);\n }\n }, [button, setChecked]);\n\n return (\n <CheckboxProvider scope={__scopeCheckbox} state={checked} disabled={disabled}>\n <Primitive.button\n type=\"button\"\n role=\"checkbox\"\n aria-checked={isIndeterminate(checked) ? 'mixed' : checked}\n aria-required={required}\n data-state={getState(checked)}\n data-disabled={disabled ? '' : undefined}\n disabled={disabled}\n value={value}\n {...checkboxProps}\n ref={composedRefs}\n onKeyDown={composeEventHandlers(props.onKeyDown, (event) => {\n // According to WAI ARIA, Checkboxes don't activate on enter keypress\n if (event.key === 'Enter') event.preventDefault();\n })}\n onClick={composeEventHandlers(props.onClick, (event) => {\n setChecked((prevChecked) => (isIndeterminate(prevChecked) ? true : !prevChecked));\n if (isFormControl) {\n hasConsumerStoppedPropagationRef.current = event.isPropagationStopped();\n // if checkbox is in a form, stop propagation from the button so that we only propagate\n // one click event (from the input). We propagate changes from an input so that native\n // form validation works and form events reflect checkbox updates.\n if (!hasConsumerStoppedPropagationRef.current) event.stopPropagation();\n }\n })}\n />\n {isFormControl && (\n <BubbleInput\n control={button}\n bubbles={!hasConsumerStoppedPropagationRef.current}\n name={name}\n value={value}\n checked={checked}\n required={required}\n disabled={disabled}\n form={form}\n // We transform because the input is absolutely positioned but we have\n // rendered it **after** the button. This pulls it back to sit on top\n // of the button.\n style={{ transform: 'translateX(-100%)' }}\n defaultChecked={isIndeterminate(defaultChecked) ? false : defaultChecked}\n />\n )}\n </CheckboxProvider>\n );\n }\n);\n\nCheckbox.displayName = CHECKBOX_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * CheckboxIndicator\n * -----------------------------------------------------------------------------------------------*/\n\nconst INDICATOR_NAME = 'CheckboxIndicator';\n\ntype CheckboxIndicatorElement = React.ElementRef<typeof Primitive.span>;\ntype PrimitiveSpanProps = React.ComponentPropsWithoutRef<typeof Primitive.span>;\ninterface CheckboxIndicatorProps extends PrimitiveSpanProps {\n /**\n * Used to force mounting when more control is needed. Useful when\n * controlling animation with React animation libraries.\n */\n forceMount?: true;\n}\n\nconst CheckboxIndicator = React.forwardRef<CheckboxIndicatorElement, CheckboxIndicatorProps>(\n (props: ScopedProps<CheckboxIndicatorProps>, forwardedRef) => {\n const { __scopeCheckbox, forceMount, ...indicatorProps } = props;\n const context = useCheckboxContext(INDICATOR_NAME, __scopeCheckbox);\n return (\n <Presence present={forceMount || isIndeterminate(context.state) || context.state === true}>\n <Primitive.span\n data-state={getState(context.state)}\n data-disabled={context.disabled ? '' : undefined}\n {...indicatorProps}\n ref={forwardedRef}\n style={{ pointerEvents: 'none', ...props.style }}\n />\n </Presence>\n );\n }\n);\n\nCheckboxIndicator.displayName = INDICATOR_NAME;\n\n/* ---------------------------------------------------------------------------------------------- */\n\ntype InputProps = React.ComponentPropsWithoutRef<'input'>;\ninterface BubbleInputProps extends Omit<InputProps, 'checked'> {\n checked: CheckedState;\n control: HTMLElement | null;\n bubbles: boolean;\n}\n\nconst BubbleInput = (props: BubbleInputProps) => {\n const { control, checked, bubbles = true, defaultChecked, ...inputProps } = props;\n const ref = React.useRef<HTMLInputElement>(null);\n const prevChecked = usePrevious(checked);\n const controlSize = useSize(control);\n\n // Bubble checked change to parents (e.g form change event)\n React.useEffect(() => {\n const input = ref.current!;\n const inputProto = window.HTMLInputElement.prototype;\n const descriptor = Object.getOwnPropertyDescriptor(inputProto, 'checked') as PropertyDescriptor;\n const setChecked = descriptor.set;\n\n if (prevChecked !== checked && setChecked) {\n const event = new Event('click', { bubbles });\n input.indeterminate = isIndeterminate(checked);\n setChecked.call(input, isIndeterminate(checked) ? false : checked);\n input.dispatchEvent(event);\n }\n }, [prevChecked, checked, bubbles]);\n\n const defaultCheckedRef = React.useRef(isIndeterminate(checked) ? false : checked);\n return (\n <input\n type=\"checkbox\"\n aria-hidden\n defaultChecked={defaultChecked ?? defaultCheckedRef.current}\n {...inputProps}\n tabIndex={-1}\n ref={ref}\n style={{\n ...props.style,\n ...controlSize,\n position: 'absolute',\n pointerEvents: 'none',\n opacity: 0,\n margin: 0,\n }}\n />\n );\n};\n\nfunction isIndeterminate(checked?: CheckedState): checked is 'indeterminate' {\n return checked === 'indeterminate';\n}\n\nfunction getState(checked: CheckedState) {\n return isIndeterminate(checked) ? 'indeterminate' : checked ? 'checked' : 'unchecked';\n}\n\nconst Root = Checkbox;\nconst Indicator = CheckboxIndicator;\n\nexport {\n createCheckboxScope,\n //\n Checkbox,\n CheckboxIndicator,\n //\n Root,\n Indicator,\n};\nexport type { CheckboxProps, CheckboxIndicatorProps, CheckedState };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,YAAuB;AACvB,gCAAgC;AAChC,2BAAmC;AACnC,uBAAqC;AACrC,0CAAqC;AACrC,gCAA4B;AAC5B,4BAAwB;AACxB,4BAAyB;AACzB,6BAA0B;AAmEpB;AA3DN,IAAM,gBAAgB;AAGtB,IAAM,CAAC,uBAAuB,mBAAmB,QAAI,yCAAmB,aAAa;AASrF,IAAM,CAAC,kBAAkB,kBAAkB,IACzC,sBAA4C,aAAa;AAW3D,IAAM,WAAiB;AAAA,EACrB,CAAC,OAAmC,iBAAiB;AACnD,UAAM;AAAA,MACJ;AAAA,MACA;AAAA,MACA,SAAS;AAAA,MACT;AAAA,MACA;AAAA,MACA;AAAA,MACA,QAAQ;AAAA,MACR;AAAA,MACA;AAAA,MACA,GAAG;AAAA,IACL,IAAI;AACJ,UAAM,CAAC,QAAQ,SAAS,IAAU,eAAmC,IAAI;AACzE,UAAM,mBAAe,2CAAgB,cAAc,CAAC,SAAS,UAAU,IAAI,CAAC;AAC5E,UAAM,mCAAyC,aAAO,KAAK;AAE3D,UAAM,gBAAgB,SAAS,QAAQ,CAAC,CAAC,OAAO,QAAQ,MAAM,IAAI;AAClE,UAAM,CAAC,UAAU,OAAO,UAAU,QAAI,0DAAqB;AAAA,MACzD,MAAM;AAAA,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,CAAC;AAElC,QAAM,oBAA0B,aAAO,gBAAgB,OAAO,IAAI,QAAQ,OAAO;AACjF,SACE;AAAA,IAAC;AAAA;AAAA,MACC,MAAK;AAAA,MACL,eAAW;AAAA,MACX,gBAAgB,kBAAkB,kBAAkB;AAAA,MACnD,GAAG;AAAA,MACJ,UAAU;AAAA,MACV;AAAA,MACA,OAAO;AAAA,QACL,GAAG,MAAM;AAAA,QACT,GAAG;AAAA,QACH,UAAU;AAAA,QACV,eAAe;AAAA,QACf,SAAS;AAAA,QACT,QAAQ;AAAA,MACV;AAAA;AAAA,EACF;AAEJ;AAEA,SAAS,gBAAgB,SAAoD;AAC3E,SAAO,YAAY;AACrB;AAEA,SAAS,SAAS,SAAuB;AACvC,SAAO,gBAAgB,OAAO,IAAI,kBAAkB,UAAU,YAAY;AAC5E;AAEA,IAAM,OAAO;AACb,IAAM,YAAY;",
6
+ "names": ["form"]
7
+ }
package/dist/index.mjs ADDED
@@ -0,0 +1,165 @@
1
+ "use client";
2
+
3
+ // packages/react/checkbox/src/Checkbox.tsx
4
+ import * as React from "react";
5
+ import { useComposedRefs } from "@radix-ui/react-compose-refs";
6
+ import { createContextScope } from "@radix-ui/react-context";
7
+ import { composeEventHandlers } from "@radix-ui/primitive";
8
+ import { useControllableState } from "@radix-ui/react-use-controllable-state";
9
+ import { usePrevious } from "@radix-ui/react-use-previous";
10
+ import { useSize } from "@radix-ui/react-use-size";
11
+ import { Presence } from "@radix-ui/react-presence";
12
+ import { Primitive } from "@radix-ui/react-primitive";
13
+ import { jsx, jsxs } from "react/jsx-runtime";
14
+ var CHECKBOX_NAME = "Checkbox";
15
+ var [createCheckboxContext, createCheckboxScope] = createContextScope(CHECKBOX_NAME);
16
+ var [CheckboxProvider, useCheckboxContext] = createCheckboxContext(CHECKBOX_NAME);
17
+ var Checkbox = React.forwardRef(
18
+ (props, forwardedRef) => {
19
+ const {
20
+ __scopeCheckbox,
21
+ name,
22
+ checked: checkedProp,
23
+ defaultChecked,
24
+ required,
25
+ disabled,
26
+ value = "on",
27
+ onCheckedChange,
28
+ form,
29
+ ...checkboxProps
30
+ } = props;
31
+ const [button, setButton] = React.useState(null);
32
+ const composedRefs = useComposedRefs(forwardedRef, (node) => setButton(node));
33
+ const hasConsumerStoppedPropagationRef = React.useRef(false);
34
+ const isFormControl = button ? form || !!button.closest("form") : true;
35
+ const [checked = false, setChecked] = useControllableState({
36
+ prop: checkedProp,
37
+ defaultProp: defaultChecked,
38
+ onChange: onCheckedChange
39
+ });
40
+ const initialCheckedStateRef = React.useRef(checked);
41
+ React.useEffect(() => {
42
+ const form2 = button?.form;
43
+ if (form2) {
44
+ const reset = () => setChecked(initialCheckedStateRef.current);
45
+ form2.addEventListener("reset", reset);
46
+ return () => form2.removeEventListener("reset", reset);
47
+ }
48
+ }, [button, setChecked]);
49
+ return /* @__PURE__ */ jsxs(CheckboxProvider, { scope: __scopeCheckbox, state: checked, disabled, children: [
50
+ /* @__PURE__ */ jsx(
51
+ Primitive.button,
52
+ {
53
+ type: "button",
54
+ role: "checkbox",
55
+ "aria-checked": isIndeterminate(checked) ? "mixed" : checked,
56
+ "aria-required": required,
57
+ "data-state": getState(checked),
58
+ "data-disabled": disabled ? "" : void 0,
59
+ disabled,
60
+ value,
61
+ ...checkboxProps,
62
+ ref: composedRefs,
63
+ onKeyDown: composeEventHandlers(props.onKeyDown, (event) => {
64
+ if (event.key === "Enter") event.preventDefault();
65
+ }),
66
+ onClick: composeEventHandlers(props.onClick, (event) => {
67
+ setChecked((prevChecked) => isIndeterminate(prevChecked) ? true : !prevChecked);
68
+ if (isFormControl) {
69
+ hasConsumerStoppedPropagationRef.current = event.isPropagationStopped();
70
+ if (!hasConsumerStoppedPropagationRef.current) event.stopPropagation();
71
+ }
72
+ })
73
+ }
74
+ ),
75
+ isFormControl && /* @__PURE__ */ jsx(
76
+ BubbleInput,
77
+ {
78
+ control: button,
79
+ bubbles: !hasConsumerStoppedPropagationRef.current,
80
+ name,
81
+ value,
82
+ checked,
83
+ required,
84
+ disabled,
85
+ form,
86
+ style: { transform: "translateX(-100%)" },
87
+ defaultChecked: isIndeterminate(defaultChecked) ? false : defaultChecked
88
+ }
89
+ )
90
+ ] });
91
+ }
92
+ );
93
+ Checkbox.displayName = CHECKBOX_NAME;
94
+ var INDICATOR_NAME = "CheckboxIndicator";
95
+ var CheckboxIndicator = React.forwardRef(
96
+ (props, forwardedRef) => {
97
+ const { __scopeCheckbox, forceMount, ...indicatorProps } = props;
98
+ const context = useCheckboxContext(INDICATOR_NAME, __scopeCheckbox);
99
+ return /* @__PURE__ */ jsx(Presence, { present: forceMount || isIndeterminate(context.state) || context.state === true, children: /* @__PURE__ */ jsx(
100
+ Primitive.span,
101
+ {
102
+ "data-state": getState(context.state),
103
+ "data-disabled": context.disabled ? "" : void 0,
104
+ ...indicatorProps,
105
+ ref: forwardedRef,
106
+ style: { pointerEvents: "none", ...props.style }
107
+ }
108
+ ) });
109
+ }
110
+ );
111
+ CheckboxIndicator.displayName = INDICATOR_NAME;
112
+ var BubbleInput = (props) => {
113
+ const { control, checked, bubbles = true, defaultChecked, ...inputProps } = props;
114
+ const ref = React.useRef(null);
115
+ const prevChecked = usePrevious(checked);
116
+ const controlSize = useSize(control);
117
+ React.useEffect(() => {
118
+ const input = ref.current;
119
+ const inputProto = window.HTMLInputElement.prototype;
120
+ const descriptor = Object.getOwnPropertyDescriptor(inputProto, "checked");
121
+ const setChecked = descriptor.set;
122
+ if (prevChecked !== checked && setChecked) {
123
+ const event = new Event("click", { bubbles });
124
+ input.indeterminate = isIndeterminate(checked);
125
+ setChecked.call(input, isIndeterminate(checked) ? false : checked);
126
+ input.dispatchEvent(event);
127
+ }
128
+ }, [prevChecked, checked, bubbles]);
129
+ const defaultCheckedRef = React.useRef(isIndeterminate(checked) ? false : checked);
130
+ return /* @__PURE__ */ jsx(
131
+ "input",
132
+ {
133
+ type: "checkbox",
134
+ "aria-hidden": true,
135
+ defaultChecked: defaultChecked ?? defaultCheckedRef.current,
136
+ ...inputProps,
137
+ tabIndex: -1,
138
+ ref,
139
+ style: {
140
+ ...props.style,
141
+ ...controlSize,
142
+ position: "absolute",
143
+ pointerEvents: "none",
144
+ opacity: 0,
145
+ margin: 0
146
+ }
147
+ }
148
+ );
149
+ };
150
+ function isIndeterminate(checked) {
151
+ return checked === "indeterminate";
152
+ }
153
+ function getState(checked) {
154
+ return isIndeterminate(checked) ? "indeterminate" : checked ? "checked" : "unchecked";
155
+ }
156
+ var Root = Checkbox;
157
+ var Indicator = CheckboxIndicator;
158
+ export {
159
+ Checkbox,
160
+ CheckboxIndicator,
161
+ Indicator,
162
+ Root,
163
+ createCheckboxScope
164
+ };
165
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/Checkbox.tsx"],
4
+ "sourcesContent": ["import * as React from 'react';\nimport { useComposedRefs } from '@radix-ui/react-compose-refs';\nimport { createContextScope } from '@radix-ui/react-context';\nimport { composeEventHandlers } from '@radix-ui/primitive';\nimport { useControllableState } from '@radix-ui/react-use-controllable-state';\nimport { usePrevious } from '@radix-ui/react-use-previous';\nimport { useSize } from '@radix-ui/react-use-size';\nimport { Presence } from '@radix-ui/react-presence';\nimport { Primitive } from '@radix-ui/react-primitive';\n\nimport type { Scope } from '@radix-ui/react-context';\n\n/* -------------------------------------------------------------------------------------------------\n * Checkbox\n * -----------------------------------------------------------------------------------------------*/\n\nconst CHECKBOX_NAME = 'Checkbox';\n\ntype ScopedProps<P> = P & { __scopeCheckbox?: Scope };\nconst [createCheckboxContext, createCheckboxScope] = createContextScope(CHECKBOX_NAME);\n\ntype CheckedState = boolean | 'indeterminate';\n\ntype CheckboxContextValue = {\n state: CheckedState;\n disabled?: boolean;\n};\n\nconst [CheckboxProvider, useCheckboxContext] =\n createCheckboxContext<CheckboxContextValue>(CHECKBOX_NAME);\n\ntype CheckboxElement = React.ElementRef<typeof Primitive.button>;\ntype PrimitiveButtonProps = React.ComponentPropsWithoutRef<typeof Primitive.button>;\ninterface CheckboxProps extends Omit<PrimitiveButtonProps, 'checked' | 'defaultChecked'> {\n checked?: CheckedState;\n defaultChecked?: CheckedState;\n required?: boolean;\n onCheckedChange?(checked: CheckedState): void;\n}\n\nconst Checkbox = React.forwardRef<CheckboxElement, CheckboxProps>(\n (props: ScopedProps<CheckboxProps>, forwardedRef) => {\n const {\n __scopeCheckbox,\n name,\n checked: checkedProp,\n defaultChecked,\n required,\n disabled,\n value = 'on',\n onCheckedChange,\n form,\n ...checkboxProps\n } = props;\n const [button, setButton] = React.useState<HTMLButtonElement | null>(null);\n const composedRefs = useComposedRefs(forwardedRef, (node) => setButton(node));\n const hasConsumerStoppedPropagationRef = React.useRef(false);\n // We set this to true by default so that events bubble to forms without JS (SSR)\n const isFormControl = button ? form || !!button.closest('form') : true;\n const [checked = false, setChecked] = useControllableState({\n prop: checkedProp,\n defaultProp: defaultChecked,\n onChange: onCheckedChange,\n });\n const initialCheckedStateRef = React.useRef(checked);\n React.useEffect(() => {\n const form = button?.form;\n if (form) {\n const reset = () => setChecked(initialCheckedStateRef.current);\n form.addEventListener('reset', reset);\n return () => form.removeEventListener('reset', reset);\n }\n }, [button, setChecked]);\n\n return (\n <CheckboxProvider scope={__scopeCheckbox} state={checked} disabled={disabled}>\n <Primitive.button\n type=\"button\"\n role=\"checkbox\"\n aria-checked={isIndeterminate(checked) ? 'mixed' : checked}\n aria-required={required}\n data-state={getState(checked)}\n data-disabled={disabled ? '' : undefined}\n disabled={disabled}\n value={value}\n {...checkboxProps}\n ref={composedRefs}\n onKeyDown={composeEventHandlers(props.onKeyDown, (event) => {\n // According to WAI ARIA, Checkboxes don't activate on enter keypress\n if (event.key === 'Enter') event.preventDefault();\n })}\n onClick={composeEventHandlers(props.onClick, (event) => {\n setChecked((prevChecked) => (isIndeterminate(prevChecked) ? true : !prevChecked));\n if (isFormControl) {\n hasConsumerStoppedPropagationRef.current = event.isPropagationStopped();\n // if checkbox is in a form, stop propagation from the button so that we only propagate\n // one click event (from the input). We propagate changes from an input so that native\n // form validation works and form events reflect checkbox updates.\n if (!hasConsumerStoppedPropagationRef.current) event.stopPropagation();\n }\n })}\n />\n {isFormControl && (\n <BubbleInput\n control={button}\n bubbles={!hasConsumerStoppedPropagationRef.current}\n name={name}\n value={value}\n checked={checked}\n required={required}\n disabled={disabled}\n form={form}\n // We transform because the input is absolutely positioned but we have\n // rendered it **after** the button. This pulls it back to sit on top\n // of the button.\n style={{ transform: 'translateX(-100%)' }}\n defaultChecked={isIndeterminate(defaultChecked) ? false : defaultChecked}\n />\n )}\n </CheckboxProvider>\n );\n }\n);\n\nCheckbox.displayName = CHECKBOX_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * CheckboxIndicator\n * -----------------------------------------------------------------------------------------------*/\n\nconst INDICATOR_NAME = 'CheckboxIndicator';\n\ntype CheckboxIndicatorElement = React.ElementRef<typeof Primitive.span>;\ntype PrimitiveSpanProps = React.ComponentPropsWithoutRef<typeof Primitive.span>;\ninterface CheckboxIndicatorProps extends PrimitiveSpanProps {\n /**\n * Used to force mounting when more control is needed. Useful when\n * controlling animation with React animation libraries.\n */\n forceMount?: true;\n}\n\nconst CheckboxIndicator = React.forwardRef<CheckboxIndicatorElement, CheckboxIndicatorProps>(\n (props: ScopedProps<CheckboxIndicatorProps>, forwardedRef) => {\n const { __scopeCheckbox, forceMount, ...indicatorProps } = props;\n const context = useCheckboxContext(INDICATOR_NAME, __scopeCheckbox);\n return (\n <Presence present={forceMount || isIndeterminate(context.state) || context.state === true}>\n <Primitive.span\n data-state={getState(context.state)}\n data-disabled={context.disabled ? '' : undefined}\n {...indicatorProps}\n ref={forwardedRef}\n style={{ pointerEvents: 'none', ...props.style }}\n />\n </Presence>\n );\n }\n);\n\nCheckboxIndicator.displayName = INDICATOR_NAME;\n\n/* ---------------------------------------------------------------------------------------------- */\n\ntype InputProps = React.ComponentPropsWithoutRef<'input'>;\ninterface BubbleInputProps extends Omit<InputProps, 'checked'> {\n checked: CheckedState;\n control: HTMLElement | null;\n bubbles: boolean;\n}\n\nconst BubbleInput = (props: BubbleInputProps) => {\n const { control, checked, bubbles = true, defaultChecked, ...inputProps } = props;\n const ref = React.useRef<HTMLInputElement>(null);\n const prevChecked = usePrevious(checked);\n const controlSize = useSize(control);\n\n // Bubble checked change to parents (e.g form change event)\n React.useEffect(() => {\n const input = ref.current!;\n const inputProto = window.HTMLInputElement.prototype;\n const descriptor = Object.getOwnPropertyDescriptor(inputProto, 'checked') as PropertyDescriptor;\n const setChecked = descriptor.set;\n\n if (prevChecked !== checked && setChecked) {\n const event = new Event('click', { bubbles });\n input.indeterminate = isIndeterminate(checked);\n setChecked.call(input, isIndeterminate(checked) ? false : checked);\n input.dispatchEvent(event);\n }\n }, [prevChecked, checked, bubbles]);\n\n const defaultCheckedRef = React.useRef(isIndeterminate(checked) ? false : checked);\n return (\n <input\n type=\"checkbox\"\n aria-hidden\n defaultChecked={defaultChecked ?? defaultCheckedRef.current}\n {...inputProps}\n tabIndex={-1}\n ref={ref}\n style={{\n ...props.style,\n ...controlSize,\n position: 'absolute',\n pointerEvents: 'none',\n opacity: 0,\n margin: 0,\n }}\n />\n );\n};\n\nfunction isIndeterminate(checked?: CheckedState): checked is 'indeterminate' {\n return checked === 'indeterminate';\n}\n\nfunction getState(checked: CheckedState) {\n return isIndeterminate(checked) ? 'indeterminate' : checked ? 'checked' : 'unchecked';\n}\n\nconst Root = Checkbox;\nconst Indicator = CheckboxIndicator;\n\nexport {\n createCheckboxScope,\n //\n Checkbox,\n CheckboxIndicator,\n //\n Root,\n Indicator,\n};\nexport type { CheckboxProps, CheckboxIndicatorProps, CheckedState };\n"],
5
+ "mappings": ";;;AAAA,YAAY,WAAW;AACvB,SAAS,uBAAuB;AAChC,SAAS,0BAA0B;AACnC,SAAS,4BAA4B;AACrC,SAAS,4BAA4B;AACrC,SAAS,mBAAmB;AAC5B,SAAS,eAAe;AACxB,SAAS,gBAAgB;AACzB,SAAS,iBAAiB;AAmEpB,SACE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,61 @@
1
+ {
2
+ "name": "@radix-ui/react-checkbox",
3
+ "version": "0.0.0-20250116175529",
4
+ "license": "MIT",
5
+ "exports": {
6
+ ".": {
7
+ "import": {
8
+ "types": "./dist/index.d.mts",
9
+ "default": "./dist/index.mjs"
10
+ },
11
+ "require": {
12
+ "types": "./dist/index.d.ts",
13
+ "default": "./dist/index.js"
14
+ }
15
+ }
16
+ },
17
+ "source": "./src/index.ts",
18
+ "main": "./dist/index.js",
19
+ "module": "./dist/index.mjs",
20
+ "types": "./dist/index.d.ts",
21
+ "files": [
22
+ "dist",
23
+ "README.md"
24
+ ],
25
+ "sideEffects": false,
26
+ "scripts": {
27
+ "clean": "rm -rf dist"
28
+ },
29
+ "dependencies": {
30
+ "@radix-ui/primitive": "workspace:*",
31
+ "@radix-ui/react-compose-refs": "workspace:*",
32
+ "@radix-ui/react-context": "workspace:*",
33
+ "@radix-ui/react-presence": "workspace:*",
34
+ "@radix-ui/react-primitive": "workspace:*",
35
+ "@radix-ui/react-use-controllable-state": "workspace:*",
36
+ "@radix-ui/react-use-previous": "workspace:*",
37
+ "@radix-ui/react-use-size": "workspace:*"
38
+ },
39
+ "peerDependencies": {
40
+ "@types/react": "*",
41
+ "@types/react-dom": "*",
42
+ "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc",
43
+ "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc"
44
+ },
45
+ "peerDependenciesMeta": {
46
+ "@types/react": {
47
+ "optional": true
48
+ },
49
+ "@types/react-dom": {
50
+ "optional": true
51
+ }
52
+ },
53
+ "homepage": "https://radix-ui.com/primitives",
54
+ "repository": {
55
+ "type": "git",
56
+ "url": "git+https://github.com/radix-ui/primitives.git"
57
+ },
58
+ "bugs": {
59
+ "url": "https://github.com/radix-ui/primitives/issues"
60
+ }
61
+ }