@tamagui/checkbox 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2021 Radix
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,318 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var Checkbox_exports = {};
30
+ __export(Checkbox_exports, {
31
+ BubbleInput: () => BubbleInput,
32
+ Checkbox: () => Checkbox,
33
+ CheckboxFrame: () => CheckboxFrame,
34
+ createCheckboxScope: () => createCheckboxScope,
35
+ getState: () => getState,
36
+ isIndeterminate: () => isIndeterminate
37
+ });
38
+ module.exports = __toCommonJS(Checkbox_exports);
39
+ var import_jsx_runtime = require("react/jsx-runtime");
40
+ var import_react_use_previous = require("@radix-ui/react-use-previous");
41
+ var import_core = require("@tamagui/core");
42
+ var import_create_context = require("@tamagui/create-context");
43
+ var import_focusable = require("@tamagui/focusable");
44
+ var import_font_size = require("@tamagui/font-size");
45
+ var import_get_size = require("@tamagui/get-size");
46
+ var import_helpers_tamagui = require("@tamagui/helpers-tamagui");
47
+ var import_label = require("@tamagui/label");
48
+ var import_stacks = require("@tamagui/stacks");
49
+ var import_use_controllable_state = require("@tamagui/use-controllable-state");
50
+ var React = __toESM(require("react"));
51
+ function isIndeterminate(checked) {
52
+ return checked === "indeterminate";
53
+ }
54
+ function getState(checked) {
55
+ return isIndeterminate(checked) ? "indeterminate" : checked ? "checked" : "unchecked";
56
+ }
57
+ const BubbleInput = (props) => {
58
+ const { checked, bubbles = true, control, isHidden, ...inputProps } = props;
59
+ const ref = React.useRef(null);
60
+ const prevChecked = (0, import_react_use_previous.usePrevious)(checked);
61
+ React.useEffect(() => {
62
+ const input = ref.current;
63
+ const inputProto = window.HTMLInputElement.prototype;
64
+ const descriptor = Object.getOwnPropertyDescriptor(
65
+ inputProto,
66
+ "checked"
67
+ );
68
+ const setChecked = descriptor.set;
69
+ if (prevChecked !== checked && setChecked) {
70
+ const event = new Event("click", { bubbles });
71
+ input.indeterminate = isIndeterminate(checked);
72
+ setChecked.call(input, isIndeterminate(checked) ? false : checked);
73
+ input.dispatchEvent(event);
74
+ }
75
+ }, [prevChecked, checked, bubbles]);
76
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
77
+ "input",
78
+ {
79
+ type: "checkbox",
80
+ defaultChecked: isIndeterminate(checked) ? false : checked,
81
+ ...inputProps,
82
+ tabIndex: -1,
83
+ ref,
84
+ "aria-hidden": isHidden,
85
+ style: {
86
+ ...isHidden ? {
87
+ // ...controlSize,
88
+ position: "absolute",
89
+ pointerEvents: "none",
90
+ opacity: 0,
91
+ margin: 0
92
+ } : {
93
+ appearance: "auto",
94
+ accentColor: "var(--color6)"
95
+ },
96
+ ...props.style
97
+ }
98
+ }
99
+ );
100
+ };
101
+ const INDICATOR_NAME = "CheckboxIndicator";
102
+ const CheckboxIndicatorFrame = (0, import_core.styled)(import_stacks.ThemeableStack, {
103
+ name: INDICATOR_NAME
104
+ });
105
+ const CheckboxIndicator = React.forwardRef(
106
+ (props, forwardedRef) => {
107
+ const {
108
+ __scopeCheckbox,
109
+ children: childrenProp,
110
+ forceMount,
111
+ disablePassStyles,
112
+ ...indicatorProps
113
+ } = props;
114
+ const context = useCheckboxContext(INDICATOR_NAME, __scopeCheckbox);
115
+ const iconSize = (typeof context.size === "number" ? context.size * 0.65 : (0, import_font_size.getFontSize)(context.size)) * context.scaleIcon;
116
+ const theme = (0, import_core.useTheme)();
117
+ const getThemedIcon = (0, import_helpers_tamagui.useGetThemedIcon)({ size: iconSize, color: theme.color });
118
+ const childrens = React.Children.toArray(childrenProp);
119
+ const children = childrens.map((child) => {
120
+ if (disablePassStyles || !React.isValidElement(child)) {
121
+ return child;
122
+ }
123
+ return getThemedIcon(child);
124
+ });
125
+ if (forceMount || isIndeterminate(context.state) || context.state === true)
126
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
127
+ CheckboxIndicatorFrame,
128
+ {
129
+ theme: "active",
130
+ "data-state": getState(context.state),
131
+ "data-disabled": context.disabled ? "" : void 0,
132
+ pointerEvents: "none",
133
+ ...indicatorProps,
134
+ ref: forwardedRef,
135
+ children
136
+ }
137
+ );
138
+ return null;
139
+ }
140
+ );
141
+ CheckboxIndicator.displayName = INDICATOR_NAME;
142
+ const CHECKBOX_NAME = "Checkbox";
143
+ const CheckboxFrame = (0, import_core.styled)(import_stacks.ThemeableStack, {
144
+ name: CHECKBOX_NAME,
145
+ tag: "button",
146
+ backgroundColor: "$background",
147
+ alignItems: "center",
148
+ justifyContent: "center",
149
+ pressTheme: true,
150
+ focusable: true,
151
+ borderWidth: 2,
152
+ borderColor: "transparent",
153
+ focusStyle: {
154
+ borderColor: "$borderColorFocus"
155
+ },
156
+ variants: {
157
+ size: {
158
+ "...size": (val, { tokens }) => {
159
+ const radiusToken = (0, import_core.getVariableValue)((0, import_get_size.getSize)(val)) / 8;
160
+ return {
161
+ borderRadius: radiusToken
162
+ };
163
+ }
164
+ }
165
+ },
166
+ defaultVariants: {
167
+ size: "$true"
168
+ }
169
+ });
170
+ const [createCheckboxContext, createCheckboxScope] = (0, import_create_context.createContextScope)(CHECKBOX_NAME);
171
+ const [CheckboxProvider, useCheckboxContext] = createCheckboxContext(CHECKBOX_NAME);
172
+ const Checkbox = (0, import_core.withStaticProperties)(
173
+ CheckboxFrame.extractable(
174
+ React.forwardRef(
175
+ (props, forwardedRef) => {
176
+ const {
177
+ __scopeCheckbox,
178
+ labelledBy: ariaLabelledby,
179
+ name,
180
+ checked: checkedProp,
181
+ defaultChecked,
182
+ required,
183
+ scaleIcon = 1,
184
+ sizeAdjust = 0,
185
+ disabled,
186
+ value = "on",
187
+ onCheckedChange,
188
+ native,
189
+ ...checkboxProps
190
+ } = props;
191
+ const [button, setButton] = React.useState(null);
192
+ const composedRefs = (0, import_core.useComposedRefs)(forwardedRef, (node) => setButton(node));
193
+ const hasConsumerStoppedPropagationRef = React.useRef(false);
194
+ const propsActive = (0, import_core.useMediaPropsActive)(props);
195
+ const isFormControl = import_core.isWeb ? button ? Boolean(button.closest("form")) : true : false;
196
+ const [checked = false, setChecked] = (0, import_use_controllable_state.useControllableState)({
197
+ prop: checkedProp,
198
+ defaultProp: defaultChecked,
199
+ onChange: onCheckedChange
200
+ });
201
+ const adjustedSizeToken = (0, import_get_size.stepTokenUpOrDown)("size", propsActive.size, sizeAdjust);
202
+ const size = Math.floor((0, import_core.getVariableValue)(adjustedSizeToken) * 0.5);
203
+ const labelId = (0, import_label.useLabelContext)(button);
204
+ const labelledBy = ariaLabelledby || labelId;
205
+ if (!import_core.isWeb) {
206
+ React.useEffect(() => {
207
+ if (!props.id)
208
+ return;
209
+ return (0, import_focusable.registerFocusable)(props.id, {
210
+ focusAndSelect: () => {
211
+ setChecked((x) => !x);
212
+ },
213
+ focus: () => {
214
+ }
215
+ });
216
+ }, [props.id, setChecked]);
217
+ }
218
+ return (
219
+ // YStack is here to provide theme for native input
220
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stacks.YStack, { asChild: true, theme: checkboxProps.theme, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
221
+ CheckboxProvider,
222
+ {
223
+ scope: __scopeCheckbox,
224
+ state: checked,
225
+ disabled,
226
+ size,
227
+ scaleIcon,
228
+ children: import_core.isWeb && native ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
229
+ BubbleInput,
230
+ {
231
+ control: button,
232
+ bubbles: !hasConsumerStoppedPropagationRef.current,
233
+ name,
234
+ value,
235
+ checked,
236
+ required,
237
+ disabled,
238
+ id: props.id
239
+ }
240
+ ) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
241
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
242
+ CheckboxFrame,
243
+ {
244
+ width: size,
245
+ height: size,
246
+ theme: checked ? "active" : null,
247
+ tag: "button",
248
+ role: "checkbox",
249
+ "aria-labelledby": labelledBy,
250
+ "aria-checked": isIndeterminate(checked) ? "mixed" : checked,
251
+ "aria-required": required,
252
+ "data-state": getState(checked),
253
+ "data-disabled": disabled ? "" : void 0,
254
+ disabled,
255
+ ...checkboxProps,
256
+ ref: composedRefs,
257
+ ...import_core.isWeb && {
258
+ type: "button",
259
+ value,
260
+ onKeyDown: (0, import_core.composeEventHandlers)(
261
+ props.onKeyDown,
262
+ (event) => {
263
+ if (event.key === "Enter")
264
+ event.preventDefault();
265
+ }
266
+ )
267
+ },
268
+ onPress: (0, import_core.composeEventHandlers)(props.onPress, (event) => {
269
+ setChecked(
270
+ (prevChecked) => isIndeterminate(prevChecked) ? true : !prevChecked
271
+ );
272
+ if (isFormControl) {
273
+ hasConsumerStoppedPropagationRef.current = event.isPropagationStopped();
274
+ if (!hasConsumerStoppedPropagationRef.current)
275
+ event.stopPropagation();
276
+ }
277
+ })
278
+ }
279
+ ),
280
+ import_core.isWeb && isFormControl ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
281
+ BubbleInput,
282
+ {
283
+ isHidden: true,
284
+ control: button,
285
+ bubbles: !hasConsumerStoppedPropagationRef.current,
286
+ name,
287
+ value,
288
+ checked,
289
+ required,
290
+ disabled
291
+ }
292
+ ) : null
293
+ ] })
294
+ }
295
+ ) })
296
+ );
297
+ }
298
+ )
299
+ ),
300
+ {
301
+ Indicator: CheckboxIndicator
302
+ }
303
+ );
304
+ Checkbox.displayName = CHECKBOX_NAME;
305
+ const cloneElementWithPropOrder = (child, props) => {
306
+ const next = (0, import_core.mergeProps)(child.props, props, false, (0, import_core.getConfig)().shorthands)[0];
307
+ return React.cloneElement({ ...child, props: null }, next);
308
+ };
309
+ // Annotate the CommonJS export names for ESM import in node:
310
+ 0 && (module.exports = {
311
+ BubbleInput,
312
+ Checkbox,
313
+ CheckboxFrame,
314
+ createCheckboxScope,
315
+ getState,
316
+ isIndeterminate
317
+ });
318
+ //# sourceMappingURL=Checkbox.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/Checkbox.tsx"],
4
+ "sourcesContent": ["// fork of radix\n// https://github.com/radix-ui/primitives/tree/main/packages/react/checkbox/src/Checkbox.tsx\n\nimport { usePrevious } from '@radix-ui/react-use-previous'\nimport {\n GetProps,\n SizeTokens,\n TamaguiElement,\n composeEventHandlers,\n getConfig,\n getVariableValue,\n isWeb,\n mergeProps,\n styled,\n useComposedRefs,\n useMediaPropsActive,\n useTheme,\n withStaticProperties,\n} from '@tamagui/core'\nimport type { Scope } from '@tamagui/create-context'\nimport { createContextScope } from '@tamagui/create-context'\nimport { registerFocusable } from '@tamagui/focusable'\nimport { getFontSize } from '@tamagui/font-size'\nimport { getSize, stepTokenUpOrDown } from '@tamagui/get-size'\nimport { useGetThemedIcon } from '@tamagui/helpers-tamagui'\nimport { useLabelContext } from '@tamagui/label'\nimport { ThemeableStack, YStack } from '@tamagui/stacks'\nimport { useControllableState } from '@tamagui/use-controllable-state'\nimport * as React from 'react'\n\nexport type CheckedState = boolean | 'indeterminate'\n\nexport function isIndeterminate(checked?: CheckedState): checked is 'indeterminate' {\n return checked === 'indeterminate'\n}\n\nexport function getState(checked: CheckedState) {\n return isIndeterminate(checked) ? 'indeterminate' : checked ? 'checked' : 'unchecked'\n}\n\ntype InputProps = any //Radix.ComponentPropsWithoutRef<'input'>\ninterface BubbleInputProps extends Omit<InputProps, 'checked'> {\n checked: CheckedState\n control: HTMLElement | null\n bubbles: boolean\n\n isHidden?: boolean\n}\n\nexport const BubbleInput = (props: BubbleInputProps) => {\n const { checked, bubbles = true, control, isHidden, ...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(\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 return (\n <input\n type=\"checkbox\"\n defaultChecked={isIndeterminate(checked) ? false : checked}\n {...inputProps}\n tabIndex={-1}\n ref={ref}\n aria-hidden={isHidden}\n style={{\n ...(isHidden\n ? {\n // ...controlSize,\n position: 'absolute',\n pointerEvents: 'none',\n opacity: 0,\n margin: 0,\n }\n : {\n appearance: 'auto',\n accentColor: 'var(--color6)',\n }),\n\n ...props.style,\n }}\n />\n )\n}\n\n/* -------------------------------------------------------------------------------------------------\n * CheckboxIndicator\n * -----------------------------------------------------------------------------------------------*/\n\nconst INDICATOR_NAME = 'CheckboxIndicator'\n\nconst CheckboxIndicatorFrame = styled(ThemeableStack, {\n name: INDICATOR_NAME,\n})\n\ntype CheckboxIndicatorFrameProps = GetProps<typeof CheckboxIndicatorFrame>\n\nexport type CheckboxIndicatorProps = CheckboxIndicatorFrameProps & {\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 * Used to disable passing styles down to children.\n */\n disablePassStyles?: boolean\n}\n\nconst CheckboxIndicator = React.forwardRef<TamaguiElement, CheckboxIndicatorProps>(\n (props: ScopedProps<CheckboxIndicatorProps>, forwardedRef) => {\n const {\n __scopeCheckbox,\n children: childrenProp,\n forceMount,\n disablePassStyles,\n ...indicatorProps\n } = props\n const context = useCheckboxContext(INDICATOR_NAME, __scopeCheckbox)\n const iconSize =\n (typeof context.size === 'number'\n ? context.size * 0.65\n : getFontSize(context.size)) * context.scaleIcon\n const theme = useTheme()\n const getThemedIcon = useGetThemedIcon({ size: iconSize, color: theme.color })\n\n const childrens = React.Children.toArray(childrenProp)\n const children = childrens.map((child) => {\n if (disablePassStyles || !React.isValidElement(child)) {\n return child\n }\n return getThemedIcon(child)\n })\n\n if (forceMount || isIndeterminate(context.state) || context.state === true)\n return (\n <CheckboxIndicatorFrame\n theme=\"active\"\n data-state={getState(context.state)}\n data-disabled={context.disabled ? '' : undefined}\n pointerEvents=\"none\"\n {...indicatorProps}\n ref={forwardedRef}\n >\n {children}\n </CheckboxIndicatorFrame>\n )\n\n return null\n }\n)\n\nCheckboxIndicator.displayName = INDICATOR_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * Checkbox\n * -----------------------------------------------------------------------------------------------*/\n\nconst CHECKBOX_NAME = 'Checkbox'\n\nexport const CheckboxFrame = styled(ThemeableStack, {\n name: CHECKBOX_NAME,\n tag: 'button',\n backgroundColor: '$background',\n alignItems: 'center',\n justifyContent: 'center',\n pressTheme: true,\n focusable: true,\n borderWidth: 2,\n borderColor: 'transparent',\n\n focusStyle: {\n borderColor: '$borderColorFocus',\n },\n\n variants: {\n size: {\n '...size': (val, { tokens }) => {\n const radiusToken = getVariableValue(getSize(val)) / 8\n return {\n borderRadius: radiusToken,\n }\n },\n },\n } as const,\n\n defaultVariants: {\n size: '$true',\n },\n})\n\ntype ScopedProps<P> = P & { __scopeCheckbox?: Scope }\nconst [createCheckboxContext, createCheckboxScope] = createContextScope(CHECKBOX_NAME)\n\ntype CheckboxContextValue = {\n state: CheckedState\n disabled?: boolean\n size: SizeTokens\n scaleIcon: number\n}\n\nconst [CheckboxProvider, useCheckboxContext] =\n createCheckboxContext<CheckboxContextValue>(CHECKBOX_NAME)\n\ntype CheckboxFrameProps = GetProps<typeof CheckboxFrame>\nexport interface CheckboxProps\n extends Omit<CheckboxFrameProps, 'checked' | 'defaultChecked'> {\n checked?: CheckedState\n defaultChecked?: CheckedState\n required?: boolean\n onCheckedChange?(checked: CheckedState): void\n labelledBy?: string\n name?: string\n value?: string\n native?: boolean\n scaleIcon?: number\n sizeAdjust?: number\n}\n\nexport const Checkbox = withStaticProperties(\n CheckboxFrame.extractable(\n React.forwardRef<HTMLButtonElement, CheckboxProps>(\n (props: ScopedProps<CheckboxProps>, forwardedRef) => {\n const {\n __scopeCheckbox,\n labelledBy: ariaLabelledby,\n name,\n checked: checkedProp,\n defaultChecked,\n required,\n scaleIcon = 1,\n sizeAdjust = 0,\n disabled,\n value = 'on',\n onCheckedChange,\n native,\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 const propsActive = useMediaPropsActive(props)\n // We set this to true by default so that events bubble to forms without JS (SSR)\n const isFormControl = isWeb\n ? button\n ? Boolean(button.closest('form'))\n : true\n : false\n const [checked = false, setChecked] = useControllableState({\n prop: checkedProp,\n defaultProp: defaultChecked!,\n onChange: onCheckedChange,\n })\n\n const adjustedSizeToken = stepTokenUpOrDown('size', propsActive.size, sizeAdjust)\n const size = Math.floor(getVariableValue(adjustedSizeToken) * 0.5)\n\n const labelId = useLabelContext(button)\n const labelledBy = ariaLabelledby || labelId\n\n if (!isWeb) {\n // eslint-disable-next-line react-hooks/rules-of-hooks\n React.useEffect(() => {\n if (!props.id) return\n return registerFocusable(props.id, {\n focusAndSelect: () => {\n setChecked((x) => !x)\n },\n focus: () => {},\n })\n }, [props.id, setChecked])\n }\n\n return (\n // YStack is here to provide theme for native input\n <YStack asChild theme={checkboxProps.theme}>\n <CheckboxProvider\n scope={__scopeCheckbox}\n state={checked}\n disabled={disabled}\n size={size}\n scaleIcon={scaleIcon}\n >\n {isWeb && native ? (\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 id={props.id}\n />\n ) : (\n <>\n <CheckboxFrame\n width={size}\n height={size}\n theme={checked ? 'active' : null}\n tag=\"button\"\n role=\"checkbox\"\n aria-labelledby={labelledBy}\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 {...checkboxProps}\n ref={composedRefs}\n {...(isWeb && {\n type: 'button',\n value: value,\n onKeyDown: composeEventHandlers(\n (props as React.HTMLProps<HTMLButtonElement>).onKeyDown,\n (event) => {\n // According to WAI ARIA, Checkboxes don't activate on enter keypress\n if (event.key === 'Enter') event.preventDefault()\n }\n ),\n })}\n onPress={composeEventHandlers(props.onPress as any, (event) => {\n setChecked((prevChecked) =>\n isIndeterminate(prevChecked) ? true : !prevChecked\n )\n if (isFormControl) {\n hasConsumerStoppedPropagationRef.current =\n 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)\n event.stopPropagation()\n }\n })}\n />\n\n {isWeb && isFormControl ? (\n <BubbleInput\n isHidden\n control={button}\n bubbles={!hasConsumerStoppedPropagationRef.current}\n name={name}\n value={value}\n checked={checked}\n required={required}\n disabled={disabled}\n />\n ) : null}\n </>\n )}\n </CheckboxProvider>\n </YStack>\n )\n }\n )\n ),\n {\n Indicator: CheckboxIndicator,\n }\n)\n\nCheckbox.displayName = CHECKBOX_NAME\n\nexport { createCheckboxScope }\n\nconst cloneElementWithPropOrder = (child: any, props: Object) => {\n const next = mergeProps(child.props, props, false, getConfig().shorthands)[0]\n return React.cloneElement({ ...child, props: null }, next)\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA0EI;AAvEJ,gCAA4B;AAC5B,kBAcO;A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CAAM,eAAe;AAAA,wBAClD;AAAA,sBACF;AAAA,oBACF;AAAA,oBACA,aAAS,kCAAqB,MAAM,SAAgB,CAAC,UAAU;AAC7D;AAAA,wBAAW,CAAC,gBACV,gBAAgB,WAAW,IAAI,OAAO,CAAC;AAAA,sBACzC;AACA,0BAAI,eAAe;AACjB,yDAAiC,UAC/B,MAAM,qBAAqB;AAI7B,4BAAI,CAAC,iCAAiC;AACpC,gCAAM,gBAAgB;AAAA,sBAC1B;AAAA,oBACF,CAAC;AAAA;AAAA,gBACH;AAAA,gBAEC,qBAAS,gBACR;AAAA,kBAAC;AAAA;AAAA,oBACC,UAAQ;AAAA,oBACR,SAAS;AAAA,oBACT,SAAS,CAAC,iCAAiC;AAAA,oBAC3C;AAAA,oBACA;AAAA,oBACA;AAAA,oBACA;AAAA,oBACA;AAAA;AAAA,gBACF,IACE;AAAA,iBACN;AAAA;AAAA,UAEJ,GACF;AAAA;AAAA,MAEJ;AAAA,IACF;AAAA,EACF;AAAA,EACA;AAAA,IACE,WAAW;AAAA,EACb;AACF;AAEA,SAAS,cAAc;AAIvB,MAAM,4BAA4B,CAAC,OAAY,UAAkB;AAC/D,QAAM,WAAO,wBAAW,MAAM,OAAO,OAAO,WAAO,uBAAU,EAAE,UAAU,EAAE,CAAC;AAC5E,SAAO,MAAM,aAAa,EAAE,GAAG,OAAO,OAAO,KAAK,GAAG,IAAI;AAC3D;",
6
+ "names": []
7
+ }
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
15
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
16
+ var src_exports = {};
17
+ module.exports = __toCommonJS(src_exports);
18
+ __reExport(src_exports, require("./Checkbox"), module.exports);
19
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/index.ts"],
4
+ "sourcesContent": ["export * from './Checkbox'\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,wBAAc,uBAAd;",
6
+ "names": []
7
+ }