@radix-ui/react-checkbox 1.2.4-rc.1745345395380 → 1.3.0-rc.1745972185559

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/dist/index.d.mts CHANGED
@@ -1,9 +1,30 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
1
2
  import * as _radix_ui_react_context from '@radix-ui/react-context';
3
+ import { Scope } from '@radix-ui/react-context';
2
4
  import * as React from 'react';
3
5
  import { Primitive } from '@radix-ui/react-primitive';
4
6
 
7
+ type ScopedProps<P> = P & {
8
+ __scopeCheckbox?: Scope;
9
+ };
5
10
  declare const createCheckboxScope: _radix_ui_react_context.CreateScope;
6
11
  type CheckedState = boolean | 'indeterminate';
12
+ interface CheckboxProviderProps<State extends CheckedState = CheckedState> {
13
+ checked?: State | boolean;
14
+ defaultChecked?: State | boolean;
15
+ required?: boolean;
16
+ onCheckedChange?(checked: State | boolean): void;
17
+ name?: string;
18
+ form?: string;
19
+ disabled?: boolean;
20
+ value?: string | number | readonly string[];
21
+ children?: React.ReactNode;
22
+ }
23
+ declare function CheckboxProvider<State extends CheckedState = CheckedState>({ __scopeCheckbox, checked: checkedProp, children, defaultChecked, disabled, form, name, onCheckedChange, required, value, internal_do_not_use_render, }: ScopedProps<CheckboxProviderProps<State>>): react_jsx_runtime.JSX.Element;
24
+ interface CheckboxTriggerProps extends Omit<React.ComponentPropsWithoutRef<typeof Primitive.button>, keyof CheckboxProviderProps> {
25
+ children?: React.ReactNode;
26
+ }
27
+ declare const CheckboxTrigger: React.ForwardRefExoticComponent<CheckboxTriggerProps & React.RefAttributes<HTMLButtonElement>>;
7
28
  type PrimitiveButtonProps = React.ComponentPropsWithoutRef<typeof Primitive.button>;
8
29
  interface CheckboxProps extends Omit<PrimitiveButtonProps, 'checked' | 'defaultChecked'> {
9
30
  checked?: CheckedState;
@@ -21,7 +42,14 @@ interface CheckboxIndicatorProps extends PrimitiveSpanProps {
21
42
  forceMount?: true;
22
43
  }
23
44
  declare const CheckboxIndicator: React.ForwardRefExoticComponent<CheckboxIndicatorProps & React.RefAttributes<HTMLSpanElement>>;
45
+ type InputProps = React.ComponentPropsWithoutRef<typeof Primitive.input>;
46
+ interface CheckboxBubbleInputProps extends Omit<InputProps, 'checked'> {
47
+ }
48
+ declare const CheckboxBubbleInput: React.ForwardRefExoticComponent<CheckboxBubbleInputProps & React.RefAttributes<HTMLInputElement>>;
49
+ declare const Provider: typeof CheckboxProvider;
50
+ declare const Trigger: React.ForwardRefExoticComponent<CheckboxTriggerProps & React.RefAttributes<HTMLButtonElement>>;
24
51
  declare const Root: React.ForwardRefExoticComponent<CheckboxProps & React.RefAttributes<HTMLButtonElement>>;
25
52
  declare const Indicator: React.ForwardRefExoticComponent<CheckboxIndicatorProps & React.RefAttributes<HTMLSpanElement>>;
53
+ declare const BubbleInput: React.ForwardRefExoticComponent<CheckboxBubbleInputProps & React.RefAttributes<HTMLInputElement>>;
26
54
 
27
- export { Checkbox, CheckboxIndicator, type CheckboxIndicatorProps, type CheckboxProps, type CheckedState, Indicator, Root, createCheckboxScope };
55
+ export { Checkbox, CheckboxIndicator, type CheckboxIndicatorProps, type CheckboxProps, type CheckedState, Indicator, Root, createCheckboxScope, BubbleInput as unstable_BubbleInput, CheckboxBubbleInput as unstable_CheckboxBubbleInput, type CheckboxBubbleInputProps as unstable_CheckboxBubbleInputProps, CheckboxProvider as unstable_CheckboxProvider, type CheckboxProviderProps as unstable_CheckboxProviderProps, CheckboxTrigger as unstable_CheckboxTrigger, type CheckboxTriggerProps as unstable_CheckboxTriggerProps, Provider as unstable_Provider, Trigger as unstable_Trigger };
package/dist/index.d.ts CHANGED
@@ -1,9 +1,30 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
1
2
  import * as _radix_ui_react_context from '@radix-ui/react-context';
3
+ import { Scope } from '@radix-ui/react-context';
2
4
  import * as React from 'react';
3
5
  import { Primitive } from '@radix-ui/react-primitive';
4
6
 
7
+ type ScopedProps<P> = P & {
8
+ __scopeCheckbox?: Scope;
9
+ };
5
10
  declare const createCheckboxScope: _radix_ui_react_context.CreateScope;
6
11
  type CheckedState = boolean | 'indeterminate';
12
+ interface CheckboxProviderProps<State extends CheckedState = CheckedState> {
13
+ checked?: State | boolean;
14
+ defaultChecked?: State | boolean;
15
+ required?: boolean;
16
+ onCheckedChange?(checked: State | boolean): void;
17
+ name?: string;
18
+ form?: string;
19
+ disabled?: boolean;
20
+ value?: string | number | readonly string[];
21
+ children?: React.ReactNode;
22
+ }
23
+ declare function CheckboxProvider<State extends CheckedState = CheckedState>({ __scopeCheckbox, checked: checkedProp, children, defaultChecked, disabled, form, name, onCheckedChange, required, value, internal_do_not_use_render, }: ScopedProps<CheckboxProviderProps<State>>): react_jsx_runtime.JSX.Element;
24
+ interface CheckboxTriggerProps extends Omit<React.ComponentPropsWithoutRef<typeof Primitive.button>, keyof CheckboxProviderProps> {
25
+ children?: React.ReactNode;
26
+ }
27
+ declare const CheckboxTrigger: React.ForwardRefExoticComponent<CheckboxTriggerProps & React.RefAttributes<HTMLButtonElement>>;
7
28
  type PrimitiveButtonProps = React.ComponentPropsWithoutRef<typeof Primitive.button>;
8
29
  interface CheckboxProps extends Omit<PrimitiveButtonProps, 'checked' | 'defaultChecked'> {
9
30
  checked?: CheckedState;
@@ -21,7 +42,14 @@ interface CheckboxIndicatorProps extends PrimitiveSpanProps {
21
42
  forceMount?: true;
22
43
  }
23
44
  declare const CheckboxIndicator: React.ForwardRefExoticComponent<CheckboxIndicatorProps & React.RefAttributes<HTMLSpanElement>>;
45
+ type InputProps = React.ComponentPropsWithoutRef<typeof Primitive.input>;
46
+ interface CheckboxBubbleInputProps extends Omit<InputProps, 'checked'> {
47
+ }
48
+ declare const CheckboxBubbleInput: React.ForwardRefExoticComponent<CheckboxBubbleInputProps & React.RefAttributes<HTMLInputElement>>;
49
+ declare const Provider: typeof CheckboxProvider;
50
+ declare const Trigger: React.ForwardRefExoticComponent<CheckboxTriggerProps & React.RefAttributes<HTMLButtonElement>>;
24
51
  declare const Root: React.ForwardRefExoticComponent<CheckboxProps & React.RefAttributes<HTMLButtonElement>>;
25
52
  declare const Indicator: React.ForwardRefExoticComponent<CheckboxIndicatorProps & React.RefAttributes<HTMLSpanElement>>;
53
+ declare const BubbleInput: React.ForwardRefExoticComponent<CheckboxBubbleInputProps & React.RefAttributes<HTMLInputElement>>;
26
54
 
27
- export { Checkbox, CheckboxIndicator, type CheckboxIndicatorProps, type CheckboxProps, type CheckedState, Indicator, Root, createCheckboxScope };
55
+ export { Checkbox, CheckboxIndicator, type CheckboxIndicatorProps, type CheckboxProps, type CheckedState, Indicator, Root, createCheckboxScope, BubbleInput as unstable_BubbleInput, CheckboxBubbleInput as unstable_CheckboxBubbleInput, type CheckboxBubbleInputProps as unstable_CheckboxBubbleInputProps, CheckboxProvider as unstable_CheckboxProvider, type CheckboxProviderProps as unstable_CheckboxProviderProps, CheckboxTrigger as unstable_CheckboxTrigger, type CheckboxTriggerProps as unstable_CheckboxTriggerProps, Provider as unstable_Provider, Trigger as unstable_Trigger };
package/dist/index.js CHANGED
@@ -35,7 +35,13 @@ __export(index_exports, {
35
35
  CheckboxIndicator: () => CheckboxIndicator,
36
36
  Indicator: () => Indicator,
37
37
  Root: () => Root,
38
- createCheckboxScope: () => createCheckboxScope
38
+ createCheckboxScope: () => createCheckboxScope,
39
+ unstable_BubbleInput: () => BubbleInput,
40
+ unstable_CheckboxBubbleInput: () => CheckboxBubbleInput,
41
+ unstable_CheckboxProvider: () => CheckboxProvider,
42
+ unstable_CheckboxTrigger: () => CheckboxTrigger,
43
+ unstable_Provider: () => Provider,
44
+ unstable_Trigger: () => Trigger
39
45
  });
40
46
  module.exports = __toCommonJS(index_exports);
41
47
 
@@ -52,82 +58,144 @@ var import_react_primitive = require("@radix-ui/react-primitive");
52
58
  var import_jsx_runtime = require("react/jsx-runtime");
53
59
  var CHECKBOX_NAME = "Checkbox";
54
60
  var [createCheckboxContext, createCheckboxScope] = (0, import_react_context.createContextScope)(CHECKBOX_NAME);
55
- var [CheckboxProvider, useCheckboxContext] = createCheckboxContext(CHECKBOX_NAME);
61
+ var [CheckboxProviderImpl, useCheckboxContext] = createCheckboxContext(CHECKBOX_NAME);
62
+ function CheckboxProvider({
63
+ __scopeCheckbox,
64
+ checked: checkedProp,
65
+ children,
66
+ defaultChecked,
67
+ disabled,
68
+ form,
69
+ name,
70
+ onCheckedChange,
71
+ required,
72
+ value = "on",
73
+ // @ts-expect-error
74
+ internal_do_not_use_render
75
+ }) {
76
+ const [checked, setChecked] = (0, import_react_use_controllable_state.useControllableState)({
77
+ prop: checkedProp,
78
+ defaultProp: defaultChecked ?? false,
79
+ onChange: onCheckedChange,
80
+ caller: CHECKBOX_NAME
81
+ });
82
+ const [control, setControl] = React.useState(null);
83
+ const [bubbleInput, setBubbleInput] = React.useState(null);
84
+ const hasConsumerStoppedPropagationRef = React.useRef(false);
85
+ const isFormControl = control ? !!form || !!control.closest("form") : (
86
+ // We set this to true by default so that events bubble to forms without JS (SSR)
87
+ true
88
+ );
89
+ const context = {
90
+ checked,
91
+ disabled,
92
+ setChecked,
93
+ control,
94
+ setControl,
95
+ name,
96
+ form,
97
+ value,
98
+ hasConsumerStoppedPropagationRef,
99
+ required,
100
+ defaultChecked: isIndeterminate(defaultChecked) ? false : defaultChecked,
101
+ isFormControl,
102
+ bubbleInput,
103
+ setBubbleInput
104
+ };
105
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
106
+ CheckboxProviderImpl,
107
+ {
108
+ scope: __scopeCheckbox,
109
+ ...context,
110
+ children: isFunction(internal_do_not_use_render) ? internal_do_not_use_render(context) : children
111
+ }
112
+ );
113
+ }
114
+ var TRIGGER_NAME = "CheckboxTrigger";
115
+ var CheckboxTrigger = React.forwardRef(
116
+ ({ __scopeCheckbox, onKeyDown, onClick, ...checkboxProps }, forwardedRef) => {
117
+ const {
118
+ control,
119
+ value,
120
+ disabled,
121
+ checked,
122
+ required,
123
+ setControl,
124
+ setChecked,
125
+ hasConsumerStoppedPropagationRef,
126
+ isFormControl,
127
+ bubbleInput
128
+ } = useCheckboxContext(TRIGGER_NAME, __scopeCheckbox);
129
+ const composedRefs = (0, import_react_compose_refs.useComposedRefs)(forwardedRef, setControl);
130
+ const initialCheckedStateRef = React.useRef(checked);
131
+ React.useEffect(() => {
132
+ const form = control?.form;
133
+ if (form) {
134
+ const reset = () => setChecked(initialCheckedStateRef.current);
135
+ form.addEventListener("reset", reset);
136
+ return () => form.removeEventListener("reset", reset);
137
+ }
138
+ }, [control, setChecked]);
139
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
140
+ import_react_primitive.Primitive.button,
141
+ {
142
+ type: "button",
143
+ role: "checkbox",
144
+ "aria-checked": isIndeterminate(checked) ? "mixed" : checked,
145
+ "aria-required": required,
146
+ "data-state": getState(checked),
147
+ "data-disabled": disabled ? "" : void 0,
148
+ disabled,
149
+ value,
150
+ ...checkboxProps,
151
+ ref: composedRefs,
152
+ onKeyDown: (0, import_primitive.composeEventHandlers)(onKeyDown, (event) => {
153
+ if (event.key === "Enter") event.preventDefault();
154
+ }),
155
+ onClick: (0, import_primitive.composeEventHandlers)(onClick, (event) => {
156
+ setChecked((prevChecked) => isIndeterminate(prevChecked) ? true : !prevChecked);
157
+ if (bubbleInput && isFormControl) {
158
+ hasConsumerStoppedPropagationRef.current = event.isPropagationStopped();
159
+ if (!hasConsumerStoppedPropagationRef.current) event.stopPropagation();
160
+ }
161
+ })
162
+ }
163
+ );
164
+ }
165
+ );
166
+ CheckboxTrigger.displayName = TRIGGER_NAME;
56
167
  var Checkbox = React.forwardRef(
57
168
  (props, forwardedRef) => {
58
169
  const {
59
170
  __scopeCheckbox,
60
171
  name,
61
- checked: checkedProp,
172
+ checked,
62
173
  defaultChecked,
63
174
  required,
64
175
  disabled,
65
- value = "on",
176
+ value,
66
177
  onCheckedChange,
67
178
  form,
68
179
  ...checkboxProps
69
180
  } = 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, setChecked] = (0, import_react_use_controllable_state.useControllableState)({
75
- prop: checkedProp,
76
- defaultProp: defaultChecked ?? false,
77
- onChange: onCheckedChange,
78
- caller: CHECKBOX_NAME
79
- });
80
- const initialCheckedStateRef = React.useRef(checked);
81
- React.useEffect(() => {
82
- const form2 = button?.form;
83
- if (form2) {
84
- const reset = () => setChecked(initialCheckedStateRef.current);
85
- form2.addEventListener("reset", reset);
86
- return () => form2.removeEventListener("reset", reset);
181
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
182
+ CheckboxProvider,
183
+ {
184
+ __scopeCheckbox,
185
+ checked,
186
+ defaultChecked,
187
+ disabled,
188
+ required,
189
+ onCheckedChange,
190
+ name,
191
+ form,
192
+ value,
193
+ internal_do_not_use_render: ({ isFormControl }) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
194
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CheckboxTrigger, { ...checkboxProps, ref: forwardedRef }),
195
+ isFormControl && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CheckboxBubbleInput, {})
196
+ ] })
87
197
  }
88
- }, [button, setChecked]);
89
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(CheckboxProvider, { scope: __scopeCheckbox, state: checked, disabled, children: [
90
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
91
- import_react_primitive.Primitive.button,
92
- {
93
- type: "button",
94
- role: "checkbox",
95
- "aria-checked": isIndeterminate(checked) ? "mixed" : checked,
96
- "aria-required": required,
97
- "data-state": getState(checked),
98
- "data-disabled": disabled ? "" : void 0,
99
- disabled,
100
- value,
101
- ...checkboxProps,
102
- ref: composedRefs,
103
- onKeyDown: (0, import_primitive.composeEventHandlers)(props.onKeyDown, (event) => {
104
- if (event.key === "Enter") event.preventDefault();
105
- }),
106
- onClick: (0, import_primitive.composeEventHandlers)(props.onClick, (event) => {
107
- setChecked((prevChecked) => isIndeterminate(prevChecked) ? true : !prevChecked);
108
- if (isFormControl) {
109
- hasConsumerStoppedPropagationRef.current = event.isPropagationStopped();
110
- if (!hasConsumerStoppedPropagationRef.current) event.stopPropagation();
111
- }
112
- })
113
- }
114
- ),
115
- isFormControl && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
116
- CheckboxBubbleInput,
117
- {
118
- control: button,
119
- bubbles: !hasConsumerStoppedPropagationRef.current,
120
- name,
121
- value,
122
- checked,
123
- required,
124
- disabled,
125
- form,
126
- style: { transform: "translateX(-100%)" },
127
- defaultChecked: isIndeterminate(defaultChecked) ? false : defaultChecked
128
- }
129
- )
130
- ] });
198
+ );
131
199
  }
132
200
  );
133
201
  Checkbox.displayName = CHECKBOX_NAME;
@@ -136,16 +204,22 @@ var CheckboxIndicator = React.forwardRef(
136
204
  (props, forwardedRef) => {
137
205
  const { __scopeCheckbox, forceMount, ...indicatorProps } = props;
138
206
  const context = useCheckboxContext(INDICATOR_NAME, __scopeCheckbox);
139
- 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)(
140
- import_react_primitive.Primitive.span,
207
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
208
+ import_react_presence.Presence,
141
209
  {
142
- "data-state": getState(context.state),
143
- "data-disabled": context.disabled ? "" : void 0,
144
- ...indicatorProps,
145
- ref: forwardedRef,
146
- style: { pointerEvents: "none", ...props.style }
210
+ present: forceMount || isIndeterminate(context.checked) || context.checked === true,
211
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
212
+ import_react_primitive.Primitive.span,
213
+ {
214
+ "data-state": getState(context.checked),
215
+ "data-disabled": context.disabled ? "" : void 0,
216
+ ...indicatorProps,
217
+ ref: forwardedRef,
218
+ style: { pointerEvents: "none", ...props.style }
219
+ }
220
+ )
147
221
  }
148
- ) });
222
+ );
149
223
  }
150
224
  );
151
225
  CheckboxIndicator.displayName = INDICATOR_NAME;
@@ -153,18 +227,26 @@ var BUBBLE_INPUT_NAME = "CheckboxBubbleInput";
153
227
  var CheckboxBubbleInput = React.forwardRef(
154
228
  ({
155
229
  __scopeCheckbox,
156
- control,
157
- checked,
158
- bubbles = true,
159
- defaultChecked,
160
230
  ...props
161
231
  }, forwardedRef) => {
162
- const ref = React.useRef(null);
163
- const composedRefs = (0, import_react_compose_refs.useComposedRefs)(ref, forwardedRef);
232
+ const {
233
+ control,
234
+ hasConsumerStoppedPropagationRef,
235
+ checked,
236
+ defaultChecked,
237
+ required,
238
+ disabled,
239
+ name,
240
+ value,
241
+ form,
242
+ bubbleInput,
243
+ setBubbleInput
244
+ } = useCheckboxContext(BUBBLE_INPUT_NAME, __scopeCheckbox);
245
+ const composedRefs = (0, import_react_compose_refs.useComposedRefs)(forwardedRef, setBubbleInput);
164
246
  const prevChecked = (0, import_react_use_previous.usePrevious)(checked);
165
247
  const controlSize = (0, import_react_use_size.useSize)(control);
166
248
  React.useEffect(() => {
167
- const input = ref.current;
249
+ const input = bubbleInput;
168
250
  if (!input) return;
169
251
  const inputProto = window.HTMLInputElement.prototype;
170
252
  const descriptor = Object.getOwnPropertyDescriptor(
@@ -172,13 +254,14 @@ var CheckboxBubbleInput = React.forwardRef(
172
254
  "checked"
173
255
  );
174
256
  const setChecked = descriptor.set;
257
+ const bubbles = !hasConsumerStoppedPropagationRef.current;
175
258
  if (prevChecked !== checked && setChecked) {
176
259
  const event = new Event("click", { bubbles });
177
260
  input.indeterminate = isIndeterminate(checked);
178
261
  setChecked.call(input, isIndeterminate(checked) ? false : checked);
179
262
  input.dispatchEvent(event);
180
263
  }
181
- }, [prevChecked, checked, bubbles]);
264
+ }, [bubbleInput, prevChecked, checked, hasConsumerStoppedPropagationRef]);
182
265
  const defaultCheckedRef = React.useRef(isIndeterminate(checked) ? false : checked);
183
266
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
184
267
  import_react_primitive.Primitive.input,
@@ -186,6 +269,11 @@ var CheckboxBubbleInput = React.forwardRef(
186
269
  type: "checkbox",
187
270
  "aria-hidden": true,
188
271
  defaultChecked: defaultChecked ?? defaultCheckedRef.current,
272
+ required,
273
+ disabled,
274
+ name,
275
+ value,
276
+ form,
189
277
  ...props,
190
278
  tabIndex: -1,
191
279
  ref: composedRefs,
@@ -195,19 +283,29 @@ var CheckboxBubbleInput = React.forwardRef(
195
283
  position: "absolute",
196
284
  pointerEvents: "none",
197
285
  opacity: 0,
198
- margin: 0
286
+ margin: 0,
287
+ // We transform because the input is absolutely positioned but we have
288
+ // rendered it **after** the button. This pulls it back to sit on top
289
+ // of the button.
290
+ transform: "translateX(-100%)"
199
291
  }
200
292
  }
201
293
  );
202
294
  }
203
295
  );
204
296
  CheckboxBubbleInput.displayName = BUBBLE_INPUT_NAME;
297
+ function isFunction(value) {
298
+ return typeof value === "function";
299
+ }
205
300
  function isIndeterminate(checked) {
206
301
  return checked === "indeterminate";
207
302
  }
208
303
  function getState(checked) {
209
304
  return isIndeterminate(checked) ? "indeterminate" : checked ? "checked" : "unchecked";
210
305
  }
306
+ var Provider = CheckboxProvider;
307
+ var Trigger = CheckboxTrigger;
211
308
  var Root = Checkbox;
212
309
  var Indicator = CheckboxIndicator;
310
+ var BubbleInput = CheckboxBubbleInput;
213
311
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
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, setChecked] = useControllableState({\n prop: checkedProp,\n defaultProp: defaultChecked ?? false,\n onChange: onCheckedChange,\n caller: CHECKBOX_NAME,\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 <CheckboxBubbleInput\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 * CheckboxBubbleInput\n * -----------------------------------------------------------------------------------------------*/\n\nconst BUBBLE_INPUT_NAME = 'CheckboxBubbleInput';\n\ntype InputProps = React.ComponentPropsWithoutRef<typeof Primitive.input>;\ninterface CheckboxBubbleInputProps extends Omit<InputProps, 'checked'> {\n checked: CheckedState;\n control: HTMLElement | null;\n bubbles: boolean;\n}\n\nconst CheckboxBubbleInput = React.forwardRef<HTMLInputElement, CheckboxBubbleInputProps>(\n (\n {\n __scopeCheckbox,\n control,\n checked,\n bubbles = true,\n defaultChecked,\n ...props\n }: ScopedProps<CheckboxBubbleInputProps>,\n forwardedRef\n ) => {\n const ref = React.useRef<HTMLInputElement>(null);\n const composedRefs = useComposedRefs(ref, forwardedRef);\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 if (!input) return;\n\n const inputProto = window.HTMLInputElement.prototype;\n const descriptor = Object.getOwnPropertyDescriptor(\n inputProto,\n 'checked'\n ) 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 <Primitive.input\n type=\"checkbox\"\n aria-hidden\n defaultChecked={defaultChecked ?? defaultCheckedRef.current}\n {...props}\n tabIndex={-1}\n ref={composedRefs}\n style={{\n ...props.style,\n ...controlSize,\n position: 'absolute',\n pointerEvents: 'none',\n opacity: 0,\n margin: 0,\n }}\n />\n );\n }\n);\n\nCheckboxBubbleInput.displayName = BUBBLE_INPUT_NAME;\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;AAoEpB;AA5DN,IAAM,gBAAgB;AAGtB,IAAM,CAAC,uBAAuB,mBAAmB,QAAI,yCAAmB,aAAa;AASrF,IAAM,CAAC,kBAAkB,kBAAkB,IACzC,sBAA4C,aAAa;AAW3D,IAAM,WAAiB;AAA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;",
6
- "names": ["form"]
4
+ "sourcesContent": ["'use client';\nexport {\n createCheckboxScope,\n //\n Checkbox,\n CheckboxProvider as unstable_CheckboxProvider,\n CheckboxTrigger as unstable_CheckboxTrigger,\n CheckboxIndicator,\n CheckboxBubbleInput as unstable_CheckboxBubbleInput,\n //\n Root,\n Provider as unstable_Provider,\n Trigger as unstable_Trigger,\n Indicator,\n BubbleInput as unstable_BubbleInput,\n} from './checkbox';\nexport type {\n CheckboxProps,\n CheckboxProviderProps as unstable_CheckboxProviderProps,\n CheckboxTriggerProps as unstable_CheckboxTriggerProps,\n CheckboxIndicatorProps,\n CheckboxBubbleInputProps as unstable_CheckboxBubbleInputProps,\n CheckedState,\n} 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\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<State extends CheckedState | boolean = CheckedState> = {\n checked: State | boolean;\n setChecked: React.Dispatch<React.SetStateAction<State | boolean>>;\n disabled: boolean | undefined;\n control: HTMLButtonElement | null;\n setControl: React.Dispatch<React.SetStateAction<HTMLButtonElement | null>>;\n name: string | undefined;\n form: string | undefined;\n value: string | number | readonly string[];\n hasConsumerStoppedPropagationRef: React.RefObject<boolean>;\n required: boolean | undefined;\n defaultChecked: boolean | undefined;\n isFormControl: boolean;\n bubbleInput: HTMLInputElement | null;\n setBubbleInput: React.Dispatch<React.SetStateAction<HTMLInputElement | null>>;\n};\n\nconst [CheckboxProviderImpl, useCheckboxContext] =\n createCheckboxContext<CheckboxContextValue>(CHECKBOX_NAME);\n\n/* -------------------------------------------------------------------------------------------------\n * CheckboxProvider\n * -----------------------------------------------------------------------------------------------*/\n\ninterface CheckboxProviderProps<State extends CheckedState = CheckedState> {\n checked?: State | boolean;\n defaultChecked?: State | boolean;\n required?: boolean;\n onCheckedChange?(checked: State | boolean): void;\n name?: string;\n form?: string;\n disabled?: boolean;\n value?: string | number | readonly string[];\n children?: React.ReactNode;\n}\n\nfunction CheckboxProvider<State extends CheckedState = CheckedState>({\n __scopeCheckbox,\n checked: checkedProp,\n children,\n defaultChecked,\n disabled,\n form,\n name,\n onCheckedChange,\n required,\n value = 'on',\n // @ts-expect-error\n internal_do_not_use_render,\n}: ScopedProps<CheckboxProviderProps<State>>) {\n const [checked, setChecked] = useControllableState({\n prop: checkedProp,\n defaultProp: defaultChecked ?? false,\n onChange: onCheckedChange,\n caller: CHECKBOX_NAME,\n });\n const [control, setControl] = React.useState<HTMLButtonElement | null>(null);\n const [bubbleInput, setBubbleInput] = React.useState<HTMLInputElement | null>(null);\n const hasConsumerStoppedPropagationRef = React.useRef(false);\n const isFormControl = control\n ? !!form || !!control.closest('form')\n : // We set this to true by default so that events bubble to forms without JS (SSR)\n true;\n\n const context: CheckboxContextValue<State> = {\n checked: checked,\n disabled: disabled,\n setChecked: setChecked,\n control: control,\n setControl: setControl,\n name: name,\n form: form,\n value: value,\n hasConsumerStoppedPropagationRef: hasConsumerStoppedPropagationRef,\n required: required,\n defaultChecked: isIndeterminate(defaultChecked) ? false : defaultChecked,\n isFormControl: isFormControl,\n bubbleInput,\n setBubbleInput,\n };\n\n return (\n <CheckboxProviderImpl\n scope={__scopeCheckbox}\n {...(context as unknown as CheckboxContextValue<CheckedState>)}\n >\n {isFunction(internal_do_not_use_render) ? internal_do_not_use_render(context) : children}\n </CheckboxProviderImpl>\n );\n}\n\n/* -------------------------------------------------------------------------------------------------\n * CheckboxTrigger\n * -----------------------------------------------------------------------------------------------*/\n\nconst TRIGGER_NAME = 'CheckboxTrigger';\n\ninterface CheckboxTriggerProps\n extends Omit<\n React.ComponentPropsWithoutRef<typeof Primitive.button>,\n keyof CheckboxProviderProps\n > {\n children?: React.ReactNode;\n}\n\nconst CheckboxTrigger = React.forwardRef<HTMLButtonElement, CheckboxTriggerProps>(\n (\n { __scopeCheckbox, onKeyDown, onClick, ...checkboxProps }: ScopedProps<CheckboxTriggerProps>,\n forwardedRef\n ) => {\n const {\n control,\n value,\n disabled,\n checked,\n required,\n setControl,\n setChecked,\n hasConsumerStoppedPropagationRef,\n isFormControl,\n bubbleInput,\n } = useCheckboxContext(TRIGGER_NAME, __scopeCheckbox);\n const composedRefs = useComposedRefs(forwardedRef, setControl);\n\n const initialCheckedStateRef = React.useRef(checked);\n React.useEffect(() => {\n const form = control?.form;\n if (form) {\n const reset = () => setChecked(initialCheckedStateRef.current);\n form.addEventListener('reset', reset);\n return () => form.removeEventListener('reset', reset);\n }\n }, [control, setChecked]);\n\n return (\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(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(onClick, (event) => {\n setChecked((prevChecked) => (isIndeterminate(prevChecked) ? true : !prevChecked));\n if (bubbleInput && isFormControl) {\n hasConsumerStoppedPropagationRef.current = event.isPropagationStopped();\n // if checkbox has a bubble input and is a form control, stop\n // propagation from the button so that we only propagate one click\n // event (from the input). We propagate changes from an input so\n // that native form validation works and form events reflect\n // checkbox updates.\n if (!hasConsumerStoppedPropagationRef.current) event.stopPropagation();\n }\n })}\n />\n );\n }\n);\n\nCheckboxTrigger.displayName = TRIGGER_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * Checkbox\n * -----------------------------------------------------------------------------------------------*/\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,\n defaultChecked,\n required,\n disabled,\n value,\n onCheckedChange,\n form,\n ...checkboxProps\n } = props;\n\n return (\n <CheckboxProvider\n __scopeCheckbox={__scopeCheckbox}\n checked={checked}\n defaultChecked={defaultChecked}\n disabled={disabled}\n required={required}\n onCheckedChange={onCheckedChange}\n name={name}\n form={form}\n value={value}\n // @ts-expect-error\n internal_do_not_use_render={({ isFormControl }: CheckboxContextValue) => (\n <>\n <CheckboxTrigger {...checkboxProps} ref={forwardedRef} />\n {isFormControl && <CheckboxBubbleInput />}\n </>\n )}\n />\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\n present={forceMount || isIndeterminate(context.checked) || context.checked === true}\n >\n <Primitive.span\n data-state={getState(context.checked)}\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 * CheckboxBubbleInput\n * -----------------------------------------------------------------------------------------------*/\n\nconst BUBBLE_INPUT_NAME = 'CheckboxBubbleInput';\n\ntype InputProps = React.ComponentPropsWithoutRef<typeof Primitive.input>;\ninterface CheckboxBubbleInputProps extends Omit<InputProps, 'checked'> {}\n\nconst CheckboxBubbleInput = React.forwardRef<HTMLInputElement, CheckboxBubbleInputProps>(\n (\n {\n __scopeCheckbox,\n\n ...props\n }: ScopedProps<CheckboxBubbleInputProps>,\n forwardedRef\n ) => {\n const {\n control,\n hasConsumerStoppedPropagationRef,\n checked,\n defaultChecked,\n required,\n disabled,\n name,\n value,\n form,\n bubbleInput,\n setBubbleInput,\n } = useCheckboxContext(BUBBLE_INPUT_NAME, __scopeCheckbox);\n\n const composedRefs = useComposedRefs(forwardedRef, setBubbleInput);\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 = bubbleInput;\n if (!input) return;\n\n const inputProto = window.HTMLInputElement.prototype;\n const descriptor = Object.getOwnPropertyDescriptor(\n inputProto,\n 'checked'\n ) as PropertyDescriptor;\n const setChecked = descriptor.set;\n\n const bubbles = !hasConsumerStoppedPropagationRef.current;\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 }, [bubbleInput, prevChecked, checked, hasConsumerStoppedPropagationRef]);\n\n const defaultCheckedRef = React.useRef(isIndeterminate(checked) ? false : checked);\n return (\n <Primitive.input\n type=\"checkbox\"\n aria-hidden\n defaultChecked={defaultChecked ?? defaultCheckedRef.current}\n required={required}\n disabled={disabled}\n name={name}\n value={value}\n form={form}\n {...props}\n tabIndex={-1}\n ref={composedRefs}\n style={{\n ...props.style,\n ...controlSize,\n position: 'absolute',\n pointerEvents: 'none',\n opacity: 0,\n margin: 0,\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 transform: 'translateX(-100%)',\n }}\n />\n );\n }\n);\n\nCheckboxBubbleInput.displayName = BUBBLE_INPUT_NAME;\n\n/* ---------------------------------------------------------------------------------------------- */\n\nfunction isFunction(value: unknown): value is (...args: any[]) => any {\n return typeof value === 'function';\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 Provider = CheckboxProvider;\nconst Trigger = CheckboxTrigger;\nconst Root = Checkbox;\nconst Indicator = CheckboxIndicator;\nconst BubbleInput = CheckboxBubbleInput;\n\nexport {\n createCheckboxScope,\n //\n Checkbox,\n CheckboxProvider,\n CheckboxTrigger,\n CheckboxIndicator,\n CheckboxBubbleInput,\n //\n Root,\n Trigger,\n Provider,\n Indicator,\n BubbleInput,\n};\nexport type {\n CheckboxProps,\n CheckboxProviderProps,\n CheckboxTriggerProps,\n CheckboxIndicatorProps,\n CheckboxBubbleInputProps,\n CheckedState,\n};\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,YAAuB;AACvB,gCAAgC;AAChC,2BAAmC;AAC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A,SAAS,gBAAgB,SAAoD;AAC3E,SAAO,YAAY;AACrB;AAEA,SAAS,SAAS,SAAuB;AACvC,SAAO,gBAAgB,OAAO,IAAI,kBAAkB,UAAU,YAAY;AAC5E;AAEA,IAAM,WAAW;AACjB,IAAM,UAAU;AAChB,IAAM,OAAO;AACb,IAAM,YAAY;AAClB,IAAM,cAAc;",
6
+ "names": []
7
7
  }
package/dist/index.mjs CHANGED
@@ -10,85 +10,147 @@ import { usePrevious } from "@radix-ui/react-use-previous";
10
10
  import { useSize } from "@radix-ui/react-use-size";
11
11
  import { Presence } from "@radix-ui/react-presence";
12
12
  import { Primitive } from "@radix-ui/react-primitive";
13
- import { jsx, jsxs } from "react/jsx-runtime";
13
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
14
14
  var CHECKBOX_NAME = "Checkbox";
15
15
  var [createCheckboxContext, createCheckboxScope] = createContextScope(CHECKBOX_NAME);
16
- var [CheckboxProvider, useCheckboxContext] = createCheckboxContext(CHECKBOX_NAME);
16
+ var [CheckboxProviderImpl, useCheckboxContext] = createCheckboxContext(CHECKBOX_NAME);
17
+ function CheckboxProvider({
18
+ __scopeCheckbox,
19
+ checked: checkedProp,
20
+ children,
21
+ defaultChecked,
22
+ disabled,
23
+ form,
24
+ name,
25
+ onCheckedChange,
26
+ required,
27
+ value = "on",
28
+ // @ts-expect-error
29
+ internal_do_not_use_render
30
+ }) {
31
+ const [checked, setChecked] = useControllableState({
32
+ prop: checkedProp,
33
+ defaultProp: defaultChecked ?? false,
34
+ onChange: onCheckedChange,
35
+ caller: CHECKBOX_NAME
36
+ });
37
+ const [control, setControl] = React.useState(null);
38
+ const [bubbleInput, setBubbleInput] = React.useState(null);
39
+ const hasConsumerStoppedPropagationRef = React.useRef(false);
40
+ const isFormControl = control ? !!form || !!control.closest("form") : (
41
+ // We set this to true by default so that events bubble to forms without JS (SSR)
42
+ true
43
+ );
44
+ const context = {
45
+ checked,
46
+ disabled,
47
+ setChecked,
48
+ control,
49
+ setControl,
50
+ name,
51
+ form,
52
+ value,
53
+ hasConsumerStoppedPropagationRef,
54
+ required,
55
+ defaultChecked: isIndeterminate(defaultChecked) ? false : defaultChecked,
56
+ isFormControl,
57
+ bubbleInput,
58
+ setBubbleInput
59
+ };
60
+ return /* @__PURE__ */ jsx(
61
+ CheckboxProviderImpl,
62
+ {
63
+ scope: __scopeCheckbox,
64
+ ...context,
65
+ children: isFunction(internal_do_not_use_render) ? internal_do_not_use_render(context) : children
66
+ }
67
+ );
68
+ }
69
+ var TRIGGER_NAME = "CheckboxTrigger";
70
+ var CheckboxTrigger = React.forwardRef(
71
+ ({ __scopeCheckbox, onKeyDown, onClick, ...checkboxProps }, forwardedRef) => {
72
+ const {
73
+ control,
74
+ value,
75
+ disabled,
76
+ checked,
77
+ required,
78
+ setControl,
79
+ setChecked,
80
+ hasConsumerStoppedPropagationRef,
81
+ isFormControl,
82
+ bubbleInput
83
+ } = useCheckboxContext(TRIGGER_NAME, __scopeCheckbox);
84
+ const composedRefs = useComposedRefs(forwardedRef, setControl);
85
+ const initialCheckedStateRef = React.useRef(checked);
86
+ React.useEffect(() => {
87
+ const form = control?.form;
88
+ if (form) {
89
+ const reset = () => setChecked(initialCheckedStateRef.current);
90
+ form.addEventListener("reset", reset);
91
+ return () => form.removeEventListener("reset", reset);
92
+ }
93
+ }, [control, setChecked]);
94
+ return /* @__PURE__ */ jsx(
95
+ Primitive.button,
96
+ {
97
+ type: "button",
98
+ role: "checkbox",
99
+ "aria-checked": isIndeterminate(checked) ? "mixed" : checked,
100
+ "aria-required": required,
101
+ "data-state": getState(checked),
102
+ "data-disabled": disabled ? "" : void 0,
103
+ disabled,
104
+ value,
105
+ ...checkboxProps,
106
+ ref: composedRefs,
107
+ onKeyDown: composeEventHandlers(onKeyDown, (event) => {
108
+ if (event.key === "Enter") event.preventDefault();
109
+ }),
110
+ onClick: composeEventHandlers(onClick, (event) => {
111
+ setChecked((prevChecked) => isIndeterminate(prevChecked) ? true : !prevChecked);
112
+ if (bubbleInput && isFormControl) {
113
+ hasConsumerStoppedPropagationRef.current = event.isPropagationStopped();
114
+ if (!hasConsumerStoppedPropagationRef.current) event.stopPropagation();
115
+ }
116
+ })
117
+ }
118
+ );
119
+ }
120
+ );
121
+ CheckboxTrigger.displayName = TRIGGER_NAME;
17
122
  var Checkbox = React.forwardRef(
18
123
  (props, forwardedRef) => {
19
124
  const {
20
125
  __scopeCheckbox,
21
126
  name,
22
- checked: checkedProp,
127
+ checked,
23
128
  defaultChecked,
24
129
  required,
25
130
  disabled,
26
- value = "on",
131
+ value,
27
132
  onCheckedChange,
28
133
  form,
29
134
  ...checkboxProps
30
135
  } = 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, setChecked] = useControllableState({
36
- prop: checkedProp,
37
- defaultProp: defaultChecked ?? false,
38
- onChange: onCheckedChange,
39
- caller: CHECKBOX_NAME
40
- });
41
- const initialCheckedStateRef = React.useRef(checked);
42
- React.useEffect(() => {
43
- const form2 = button?.form;
44
- if (form2) {
45
- const reset = () => setChecked(initialCheckedStateRef.current);
46
- form2.addEventListener("reset", reset);
47
- return () => form2.removeEventListener("reset", reset);
136
+ return /* @__PURE__ */ jsx(
137
+ CheckboxProvider,
138
+ {
139
+ __scopeCheckbox,
140
+ checked,
141
+ defaultChecked,
142
+ disabled,
143
+ required,
144
+ onCheckedChange,
145
+ name,
146
+ form,
147
+ value,
148
+ internal_do_not_use_render: ({ isFormControl }) => /* @__PURE__ */ jsxs(Fragment, { children: [
149
+ /* @__PURE__ */ jsx(CheckboxTrigger, { ...checkboxProps, ref: forwardedRef }),
150
+ isFormControl && /* @__PURE__ */ jsx(CheckboxBubbleInput, {})
151
+ ] })
48
152
  }
49
- }, [button, setChecked]);
50
- return /* @__PURE__ */ jsxs(CheckboxProvider, { scope: __scopeCheckbox, state: checked, disabled, children: [
51
- /* @__PURE__ */ jsx(
52
- Primitive.button,
53
- {
54
- type: "button",
55
- role: "checkbox",
56
- "aria-checked": isIndeterminate(checked) ? "mixed" : checked,
57
- "aria-required": required,
58
- "data-state": getState(checked),
59
- "data-disabled": disabled ? "" : void 0,
60
- disabled,
61
- value,
62
- ...checkboxProps,
63
- ref: composedRefs,
64
- onKeyDown: composeEventHandlers(props.onKeyDown, (event) => {
65
- if (event.key === "Enter") event.preventDefault();
66
- }),
67
- onClick: composeEventHandlers(props.onClick, (event) => {
68
- setChecked((prevChecked) => isIndeterminate(prevChecked) ? true : !prevChecked);
69
- if (isFormControl) {
70
- hasConsumerStoppedPropagationRef.current = event.isPropagationStopped();
71
- if (!hasConsumerStoppedPropagationRef.current) event.stopPropagation();
72
- }
73
- })
74
- }
75
- ),
76
- isFormControl && /* @__PURE__ */ jsx(
77
- CheckboxBubbleInput,
78
- {
79
- control: button,
80
- bubbles: !hasConsumerStoppedPropagationRef.current,
81
- name,
82
- value,
83
- checked,
84
- required,
85
- disabled,
86
- form,
87
- style: { transform: "translateX(-100%)" },
88
- defaultChecked: isIndeterminate(defaultChecked) ? false : defaultChecked
89
- }
90
- )
91
- ] });
153
+ );
92
154
  }
93
155
  );
94
156
  Checkbox.displayName = CHECKBOX_NAME;
@@ -97,16 +159,22 @@ var CheckboxIndicator = React.forwardRef(
97
159
  (props, forwardedRef) => {
98
160
  const { __scopeCheckbox, forceMount, ...indicatorProps } = props;
99
161
  const context = useCheckboxContext(INDICATOR_NAME, __scopeCheckbox);
100
- return /* @__PURE__ */ jsx(Presence, { present: forceMount || isIndeterminate(context.state) || context.state === true, children: /* @__PURE__ */ jsx(
101
- Primitive.span,
162
+ return /* @__PURE__ */ jsx(
163
+ Presence,
102
164
  {
103
- "data-state": getState(context.state),
104
- "data-disabled": context.disabled ? "" : void 0,
105
- ...indicatorProps,
106
- ref: forwardedRef,
107
- style: { pointerEvents: "none", ...props.style }
165
+ present: forceMount || isIndeterminate(context.checked) || context.checked === true,
166
+ children: /* @__PURE__ */ jsx(
167
+ Primitive.span,
168
+ {
169
+ "data-state": getState(context.checked),
170
+ "data-disabled": context.disabled ? "" : void 0,
171
+ ...indicatorProps,
172
+ ref: forwardedRef,
173
+ style: { pointerEvents: "none", ...props.style }
174
+ }
175
+ )
108
176
  }
109
- ) });
177
+ );
110
178
  }
111
179
  );
112
180
  CheckboxIndicator.displayName = INDICATOR_NAME;
@@ -114,18 +182,26 @@ var BUBBLE_INPUT_NAME = "CheckboxBubbleInput";
114
182
  var CheckboxBubbleInput = React.forwardRef(
115
183
  ({
116
184
  __scopeCheckbox,
117
- control,
118
- checked,
119
- bubbles = true,
120
- defaultChecked,
121
185
  ...props
122
186
  }, forwardedRef) => {
123
- const ref = React.useRef(null);
124
- const composedRefs = useComposedRefs(ref, forwardedRef);
187
+ const {
188
+ control,
189
+ hasConsumerStoppedPropagationRef,
190
+ checked,
191
+ defaultChecked,
192
+ required,
193
+ disabled,
194
+ name,
195
+ value,
196
+ form,
197
+ bubbleInput,
198
+ setBubbleInput
199
+ } = useCheckboxContext(BUBBLE_INPUT_NAME, __scopeCheckbox);
200
+ const composedRefs = useComposedRefs(forwardedRef, setBubbleInput);
125
201
  const prevChecked = usePrevious(checked);
126
202
  const controlSize = useSize(control);
127
203
  React.useEffect(() => {
128
- const input = ref.current;
204
+ const input = bubbleInput;
129
205
  if (!input) return;
130
206
  const inputProto = window.HTMLInputElement.prototype;
131
207
  const descriptor = Object.getOwnPropertyDescriptor(
@@ -133,13 +209,14 @@ var CheckboxBubbleInput = React.forwardRef(
133
209
  "checked"
134
210
  );
135
211
  const setChecked = descriptor.set;
212
+ const bubbles = !hasConsumerStoppedPropagationRef.current;
136
213
  if (prevChecked !== checked && setChecked) {
137
214
  const event = new Event("click", { bubbles });
138
215
  input.indeterminate = isIndeterminate(checked);
139
216
  setChecked.call(input, isIndeterminate(checked) ? false : checked);
140
217
  input.dispatchEvent(event);
141
218
  }
142
- }, [prevChecked, checked, bubbles]);
219
+ }, [bubbleInput, prevChecked, checked, hasConsumerStoppedPropagationRef]);
143
220
  const defaultCheckedRef = React.useRef(isIndeterminate(checked) ? false : checked);
144
221
  return /* @__PURE__ */ jsx(
145
222
  Primitive.input,
@@ -147,6 +224,11 @@ var CheckboxBubbleInput = React.forwardRef(
147
224
  type: "checkbox",
148
225
  "aria-hidden": true,
149
226
  defaultChecked: defaultChecked ?? defaultCheckedRef.current,
227
+ required,
228
+ disabled,
229
+ name,
230
+ value,
231
+ form,
150
232
  ...props,
151
233
  tabIndex: -1,
152
234
  ref: composedRefs,
@@ -156,26 +238,42 @@ var CheckboxBubbleInput = React.forwardRef(
156
238
  position: "absolute",
157
239
  pointerEvents: "none",
158
240
  opacity: 0,
159
- margin: 0
241
+ margin: 0,
242
+ // We transform because the input is absolutely positioned but we have
243
+ // rendered it **after** the button. This pulls it back to sit on top
244
+ // of the button.
245
+ transform: "translateX(-100%)"
160
246
  }
161
247
  }
162
248
  );
163
249
  }
164
250
  );
165
251
  CheckboxBubbleInput.displayName = BUBBLE_INPUT_NAME;
252
+ function isFunction(value) {
253
+ return typeof value === "function";
254
+ }
166
255
  function isIndeterminate(checked) {
167
256
  return checked === "indeterminate";
168
257
  }
169
258
  function getState(checked) {
170
259
  return isIndeterminate(checked) ? "indeterminate" : checked ? "checked" : "unchecked";
171
260
  }
261
+ var Provider = CheckboxProvider;
262
+ var Trigger = CheckboxTrigger;
172
263
  var Root = Checkbox;
173
264
  var Indicator = CheckboxIndicator;
265
+ var BubbleInput = CheckboxBubbleInput;
174
266
  export {
175
267
  Checkbox,
176
268
  CheckboxIndicator,
177
269
  Indicator,
178
270
  Root,
179
- createCheckboxScope
271
+ createCheckboxScope,
272
+ BubbleInput as unstable_BubbleInput,
273
+ CheckboxBubbleInput as unstable_CheckboxBubbleInput,
274
+ CheckboxProvider as unstable_CheckboxProvider,
275
+ CheckboxTrigger as unstable_CheckboxTrigger,
276
+ Provider as unstable_Provider,
277
+ Trigger as unstable_Trigger
180
278
  };
181
279
  //# sourceMappingURL=index.mjs.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
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, setChecked] = useControllableState({\n prop: checkedProp,\n defaultProp: defaultChecked ?? false,\n onChange: onCheckedChange,\n caller: CHECKBOX_NAME,\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 <CheckboxBubbleInput\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 * CheckboxBubbleInput\n * -----------------------------------------------------------------------------------------------*/\n\nconst BUBBLE_INPUT_NAME = 'CheckboxBubbleInput';\n\ntype InputProps = React.ComponentPropsWithoutRef<typeof Primitive.input>;\ninterface CheckboxBubbleInputProps extends Omit<InputProps, 'checked'> {\n checked: CheckedState;\n control: HTMLElement | null;\n bubbles: boolean;\n}\n\nconst CheckboxBubbleInput = React.forwardRef<HTMLInputElement, CheckboxBubbleInputProps>(\n (\n {\n __scopeCheckbox,\n control,\n checked,\n bubbles = true,\n defaultChecked,\n ...props\n }: ScopedProps<CheckboxBubbleInputProps>,\n forwardedRef\n ) => {\n const ref = React.useRef<HTMLInputElement>(null);\n const composedRefs = useComposedRefs(ref, forwardedRef);\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 if (!input) return;\n\n const inputProto = window.HTMLInputElement.prototype;\n const descriptor = Object.getOwnPropertyDescriptor(\n inputProto,\n 'checked'\n ) 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 <Primitive.input\n type=\"checkbox\"\n aria-hidden\n defaultChecked={defaultChecked ?? defaultCheckedRef.current}\n {...props}\n tabIndex={-1}\n ref={composedRefs}\n style={{\n ...props.style,\n ...controlSize,\n position: 'absolute',\n pointerEvents: 'none',\n opacity: 0,\n margin: 0,\n }}\n />\n );\n }\n);\n\nCheckboxBubbleInput.displayName = BUBBLE_INPUT_NAME;\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;AAoEpB,SACE,KADF;AA5DN,IAAM,gBAAgB;AAGtB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AEA,SAAS,SAAS,SAAuB;AACvC,SAAO,gBAAgB,OAAO,IAAI,kBAAkB,UAAU,YAAY;AAC5E;AAEA,IAAM,OAAO;AACb,IAAM,YAAY;",
6
- "names": ["form"]
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\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<State extends CheckedState | boolean = CheckedState> = {\n checked: State | boolean;\n setChecked: React.Dispatch<React.SetStateAction<State | boolean>>;\n disabled: boolean | undefined;\n control: HTMLButtonElement | null;\n setControl: React.Dispatch<React.SetStateAction<HTMLButtonElement | null>>;\n name: string | undefined;\n form: string | undefined;\n value: string | number | readonly string[];\n hasConsumerStoppedPropagationRef: React.RefObject<boolean>;\n required: boolean | undefined;\n defaultChecked: boolean | undefined;\n isFormControl: boolean;\n bubbleInput: HTMLInputElement | null;\n setBubbleInput: React.Dispatch<React.SetStateAction<HTMLInputElement | null>>;\n};\n\nconst [CheckboxProviderImpl, useCheckboxContext] =\n createCheckboxContext<CheckboxContextValue>(CHECKBOX_NAME);\n\n/* -------------------------------------------------------------------------------------------------\n * CheckboxProvider\n * -----------------------------------------------------------------------------------------------*/\n\ninterface CheckboxProviderProps<State extends CheckedState = CheckedState> {\n checked?: State | boolean;\n defaultChecked?: State | boolean;\n required?: boolean;\n onCheckedChange?(checked: State | boolean): void;\n name?: string;\n form?: string;\n disabled?: boolean;\n value?: string | number | readonly string[];\n children?: React.ReactNode;\n}\n\nfunction CheckboxProvider<State extends CheckedState = CheckedState>({\n __scopeCheckbox,\n checked: checkedProp,\n children,\n defaultChecked,\n disabled,\n form,\n name,\n onCheckedChange,\n required,\n value = 'on',\n // @ts-expect-error\n internal_do_not_use_render,\n}: ScopedProps<CheckboxProviderProps<State>>) {\n const [checked, setChecked] = useControllableState({\n prop: checkedProp,\n defaultProp: defaultChecked ?? false,\n onChange: onCheckedChange,\n caller: CHECKBOX_NAME,\n });\n const [control, setControl] = React.useState<HTMLButtonElement | null>(null);\n const [bubbleInput, setBubbleInput] = React.useState<HTMLInputElement | null>(null);\n const hasConsumerStoppedPropagationRef = React.useRef(false);\n const isFormControl = control\n ? !!form || !!control.closest('form')\n : // We set this to true by default so that events bubble to forms without JS (SSR)\n true;\n\n const context: CheckboxContextValue<State> = {\n checked: checked,\n disabled: disabled,\n setChecked: setChecked,\n control: control,\n setControl: setControl,\n name: name,\n form: form,\n value: value,\n hasConsumerStoppedPropagationRef: hasConsumerStoppedPropagationRef,\n required: required,\n defaultChecked: isIndeterminate(defaultChecked) ? false : defaultChecked,\n isFormControl: isFormControl,\n bubbleInput,\n setBubbleInput,\n };\n\n return (\n <CheckboxProviderImpl\n scope={__scopeCheckbox}\n {...(context as unknown as CheckboxContextValue<CheckedState>)}\n >\n {isFunction(internal_do_not_use_render) ? internal_do_not_use_render(context) : children}\n </CheckboxProviderImpl>\n );\n}\n\n/* -------------------------------------------------------------------------------------------------\n * CheckboxTrigger\n * -----------------------------------------------------------------------------------------------*/\n\nconst TRIGGER_NAME = 'CheckboxTrigger';\n\ninterface CheckboxTriggerProps\n extends Omit<\n React.ComponentPropsWithoutRef<typeof Primitive.button>,\n keyof CheckboxProviderProps\n > {\n children?: React.ReactNode;\n}\n\nconst CheckboxTrigger = React.forwardRef<HTMLButtonElement, CheckboxTriggerProps>(\n (\n { __scopeCheckbox, onKeyDown, onClick, ...checkboxProps }: ScopedProps<CheckboxTriggerProps>,\n forwardedRef\n ) => {\n const {\n control,\n value,\n disabled,\n checked,\n required,\n setControl,\n setChecked,\n hasConsumerStoppedPropagationRef,\n isFormControl,\n bubbleInput,\n } = useCheckboxContext(TRIGGER_NAME, __scopeCheckbox);\n const composedRefs = useComposedRefs(forwardedRef, setControl);\n\n const initialCheckedStateRef = React.useRef(checked);\n React.useEffect(() => {\n const form = control?.form;\n if (form) {\n const reset = () => setChecked(initialCheckedStateRef.current);\n form.addEventListener('reset', reset);\n return () => form.removeEventListener('reset', reset);\n }\n }, [control, setChecked]);\n\n return (\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(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(onClick, (event) => {\n setChecked((prevChecked) => (isIndeterminate(prevChecked) ? true : !prevChecked));\n if (bubbleInput && isFormControl) {\n hasConsumerStoppedPropagationRef.current = event.isPropagationStopped();\n // if checkbox has a bubble input and is a form control, stop\n // propagation from the button so that we only propagate one click\n // event (from the input). We propagate changes from an input so\n // that native form validation works and form events reflect\n // checkbox updates.\n if (!hasConsumerStoppedPropagationRef.current) event.stopPropagation();\n }\n })}\n />\n );\n }\n);\n\nCheckboxTrigger.displayName = TRIGGER_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * Checkbox\n * -----------------------------------------------------------------------------------------------*/\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,\n defaultChecked,\n required,\n disabled,\n value,\n onCheckedChange,\n form,\n ...checkboxProps\n } = props;\n\n return (\n <CheckboxProvider\n __scopeCheckbox={__scopeCheckbox}\n checked={checked}\n defaultChecked={defaultChecked}\n disabled={disabled}\n required={required}\n onCheckedChange={onCheckedChange}\n name={name}\n form={form}\n value={value}\n // @ts-expect-error\n internal_do_not_use_render={({ isFormControl }: CheckboxContextValue) => (\n <>\n <CheckboxTrigger {...checkboxProps} ref={forwardedRef} />\n {isFormControl && <CheckboxBubbleInput />}\n </>\n )}\n />\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\n present={forceMount || isIndeterminate(context.checked) || context.checked === true}\n >\n <Primitive.span\n data-state={getState(context.checked)}\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 * CheckboxBubbleInput\n * -----------------------------------------------------------------------------------------------*/\n\nconst BUBBLE_INPUT_NAME = 'CheckboxBubbleInput';\n\ntype InputProps = React.ComponentPropsWithoutRef<typeof Primitive.input>;\ninterface CheckboxBubbleInputProps extends Omit<InputProps, 'checked'> {}\n\nconst CheckboxBubbleInput = React.forwardRef<HTMLInputElement, CheckboxBubbleInputProps>(\n (\n {\n __scopeCheckbox,\n\n ...props\n }: ScopedProps<CheckboxBubbleInputProps>,\n forwardedRef\n ) => {\n const {\n control,\n hasConsumerStoppedPropagationRef,\n checked,\n defaultChecked,\n required,\n disabled,\n name,\n value,\n form,\n bubbleInput,\n setBubbleInput,\n } = useCheckboxContext(BUBBLE_INPUT_NAME, __scopeCheckbox);\n\n const composedRefs = useComposedRefs(forwardedRef, setBubbleInput);\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 = bubbleInput;\n if (!input) return;\n\n const inputProto = window.HTMLInputElement.prototype;\n const descriptor = Object.getOwnPropertyDescriptor(\n inputProto,\n 'checked'\n ) as PropertyDescriptor;\n const setChecked = descriptor.set;\n\n const bubbles = !hasConsumerStoppedPropagationRef.current;\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 }, [bubbleInput, prevChecked, checked, hasConsumerStoppedPropagationRef]);\n\n const defaultCheckedRef = React.useRef(isIndeterminate(checked) ? false : checked);\n return (\n <Primitive.input\n type=\"checkbox\"\n aria-hidden\n defaultChecked={defaultChecked ?? defaultCheckedRef.current}\n required={required}\n disabled={disabled}\n name={name}\n value={value}\n form={form}\n {...props}\n tabIndex={-1}\n ref={composedRefs}\n style={{\n ...props.style,\n ...controlSize,\n position: 'absolute',\n pointerEvents: 'none',\n opacity: 0,\n margin: 0,\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 transform: 'translateX(-100%)',\n }}\n />\n );\n }\n);\n\nCheckboxBubbleInput.displayName = BUBBLE_INPUT_NAME;\n\n/* ---------------------------------------------------------------------------------------------- */\n\nfunction isFunction(value: unknown): value is (...args: any[]) => any {\n return typeof value === 'function';\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 Provider = CheckboxProvider;\nconst Trigger = CheckboxTrigger;\nconst Root = Checkbox;\nconst Indicator = CheckboxIndicator;\nconst BubbleInput = CheckboxBubbleInput;\n\nexport {\n createCheckboxScope,\n //\n Checkbox,\n CheckboxProvider,\n CheckboxTrigger,\n CheckboxIndicator,\n CheckboxBubbleInput,\n //\n Root,\n Trigger,\n Provider,\n Indicator,\n BubbleInput,\n};\nexport type {\n CheckboxProps,\n CheckboxProviderProps,\n CheckboxTriggerProps,\n CheckboxIndicatorProps,\n CheckboxBubbleInputProps,\n CheckedState,\n};\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;AA6FtB,SAgIM,UAhIN,KAgIM,YAhIN;AAzFJ,IAAM,gBAAgB;AAGtB,IAAM,CAAC,uBAAuB,mBAAmB,IAAI,mBAAmB,aAAa;AAqBrF,IAAM,CAAC,sBAAsB,kBAAkB,IAC7C,sBAA4C,aAAa;AAkB3D,SAAS,iBAA4D;AAAA,EACnE;AAAA,EACA,SAAS;AAAA,EACT;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAA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1.3.0-rc.1745972185559",
4
4
  "license": "MIT",
5
5
  "source": "./src/index.ts",
6
6
  "main": "./dist/index.js",
@@ -14,11 +14,11 @@
14
14
  "@radix-ui/primitive": "1.1.2",
15
15
  "@radix-ui/react-compose-refs": "1.1.2",
16
16
  "@radix-ui/react-context": "1.1.2",
17
- "@radix-ui/react-primitive": "2.1.1-rc.1745345395380",
18
17
  "@radix-ui/react-presence": "1.1.4",
18
+ "@radix-ui/react-primitive": "2.1.1-rc.1745972185559",
19
19
  "@radix-ui/react-use-controllable-state": "1.2.2",
20
- "@radix-ui/react-use-size": "1.1.1",
21
- "@radix-ui/react-use-previous": "1.1.1"
20
+ "@radix-ui/react-use-previous": "1.1.1",
21
+ "@radix-ui/react-use-size": "1.1.1"
22
22
  },
23
23
  "devDependencies": {
24
24
  "@types/react": "^19.0.7",
@@ -27,9 +27,9 @@
27
27
  "react": "^19.1.0",
28
28
  "react-dom": "^19.1.0",
29
29
  "typescript": "^5.7.3",
30
+ "@repo/builder": "0.0.0",
30
31
  "@repo/typescript-config": "0.0.0",
31
- "@repo/eslint-config": "0.0.0",
32
- "@repo/builder": "0.0.0"
32
+ "@repo/eslint-config": "0.0.0"
33
33
  },
34
34
  "peerDependencies": {
35
35
  "@types/react": "*",