@tamagui/checkbox 1.61.2 → 1.62.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.
@@ -1,20 +1,15 @@
1
- "use strict";
2
1
  var __create = Object.create;
3
2
  var __defProp = Object.defineProperty;
4
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty;
8
6
  var __export = (target, all) => {
9
7
  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") {
8
+ __defProp(target, name, { get: all[name], enumerable: !0 });
9
+ }, __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from == "object" || typeof from == "function")
14
11
  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
- }
12
+ !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
13
  return to;
19
14
  };
20
15
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
@@ -22,10 +17,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
22
17
  // file that has been converted to a CommonJS file using a Babel-
23
18
  // compatible transform (i.e. "__esModule" has not been set), then set
24
19
  // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
20
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
26
21
  mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
22
+ )), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
29
23
  var Checkbox_exports = {};
30
24
  __export(Checkbox_exports, {
31
25
  BubbleInput: () => BubbleInput,
@@ -37,18 +31,7 @@ __export(Checkbox_exports, {
37
31
  isIndeterminate: () => isIndeterminate
38
32
  });
39
33
  module.exports = __toCommonJS(Checkbox_exports);
40
- var import_jsx_runtime = require("react/jsx-runtime");
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_token = require("@tamagui/get-token");
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 import_use_previous = require("@tamagui/use-previous");
51
- var React = __toESM(require("react"));
34
+ var import_core = require("@tamagui/core"), import_create_context = require("@tamagui/create-context"), import_focusable = require("@tamagui/focusable"), import_font_size = require("@tamagui/font-size"), import_get_token = require("@tamagui/get-token"), import_helpers_tamagui = require("@tamagui/helpers-tamagui"), import_label = require("@tamagui/label"), import_stacks = require("@tamagui/stacks"), import_use_controllable_state = require("@tamagui/use-controllable-state"), import_use_previous = require("@tamagui/use-previous"), React = __toESM(require("react")), import_jsx_runtime = require("react/jsx-runtime");
52
35
  const CheckboxStyledContext = (0, import_core.createStyledContext)({
53
36
  size: "$true",
54
37
  scaleIcon: 1
@@ -60,29 +43,21 @@ function getState(checked) {
60
43
  return isIndeterminate(checked) ? "indeterminate" : checked ? "checked" : "unchecked";
61
44
  }
62
45
  const BubbleInput = (props) => {
63
- const { checked, bubbles = true, control, isHidden, ...inputProps } = props;
64
- const ref = React.useRef(null);
65
- const prevChecked = (0, import_use_previous.usePrevious)(checked);
66
- React.useEffect(() => {
67
- const input = ref.current;
68
- const inputProto = window.HTMLInputElement.prototype;
69
- const descriptor = Object.getOwnPropertyDescriptor(
46
+ const { checked, bubbles = !0, control, isHidden, ...inputProps } = props, ref = React.useRef(null), prevChecked = (0, import_use_previous.usePrevious)(checked);
47
+ return React.useEffect(() => {
48
+ const input = ref.current, inputProto = window.HTMLInputElement.prototype, setChecked = Object.getOwnPropertyDescriptor(
70
49
  inputProto,
71
50
  "checked"
72
- );
73
- const setChecked = descriptor.set;
51
+ ).set;
74
52
  if (prevChecked !== checked && setChecked) {
75
53
  const event = new Event("click", { bubbles });
76
- input.indeterminate = isIndeterminate(checked);
77
- setChecked.call(input, isIndeterminate(checked) ? false : checked);
78
- input.dispatchEvent(event);
54
+ input.indeterminate = isIndeterminate(checked), setChecked.call(input, isIndeterminate(checked) ? !1 : checked), input.dispatchEvent(event);
79
55
  }
80
- }, [prevChecked, checked, bubbles]);
81
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
56
+ }, [prevChecked, checked, bubbles]), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
82
57
  "input",
83
58
  {
84
59
  type: "checkbox",
85
- defaultChecked: isIndeterminate(checked) ? false : checked,
60
+ defaultChecked: isIndeterminate(checked) ? !1 : checked,
86
61
  ...inputProps,
87
62
  tabIndex: -1,
88
63
  ref,
@@ -102,14 +77,11 @@ const BubbleInput = (props) => {
102
77
  }
103
78
  }
104
79
  );
105
- };
106
- const INDICATOR_NAME = "CheckboxIndicator";
107
- const CheckboxIndicatorFrame = (0, import_core.styled)(import_stacks.ThemeableStack, {
80
+ }, INDICATOR_NAME = "CheckboxIndicator", CheckboxIndicatorFrame = (0, import_core.styled)(import_stacks.ThemeableStack, {
108
81
  // use Checkbox for easier themes
109
82
  name: INDICATOR_NAME,
110
83
  context: CheckboxStyledContext
111
- });
112
- const CheckboxIndicator = CheckboxIndicatorFrame.extractable(
84
+ }), CheckboxIndicator = CheckboxIndicatorFrame.extractable(
113
85
  React.forwardRef(
114
86
  (props, forwardedRef) => {
115
87
  const {
@@ -119,42 +91,26 @@ const CheckboxIndicator = CheckboxIndicatorFrame.extractable(
119
91
  disablePassStyles,
120
92
  ...indicatorProps
121
93
  } = props;
122
- if (process.env.NODE_ENV === "development" && !childrenProp) {
123
- console.warn(
124
- `Warning: You created a Checkbox.Indicator without passing an child prop for it to use as an icon.`
125
- );
126
- }
127
- const context = useCheckboxContext(INDICATOR_NAME, __scopeCheckbox);
128
- const styledContext = React.useContext(CheckboxStyledContext);
129
- const iconSize = (typeof styledContext.size === "number" ? styledContext.size * 0.65 : (0, import_font_size.getFontSize)(styledContext.size)) * styledContext.scaleIcon;
130
- const theme = (0, import_core.useTheme)();
131
- const getThemedIcon = (0, import_helpers_tamagui.useGetThemedIcon)({ size: iconSize, color: theme.color });
132
- const childrens = React.Children.toArray(childrenProp);
133
- const children = childrens.map((child) => {
134
- if (disablePassStyles || !React.isValidElement(child)) {
135
- return child;
94
+ process.env.NODE_ENV === "development" && !childrenProp && console.warn(
95
+ "Warning: You created a Checkbox.Indicator without passing an child prop for it to use as an icon."
96
+ );
97
+ const context = useCheckboxContext(INDICATOR_NAME, __scopeCheckbox), styledContext = React.useContext(CheckboxStyledContext), iconSize = (typeof styledContext.size == "number" ? styledContext.size * 0.65 : (0, import_font_size.getFontSize)(styledContext.size)) * styledContext.scaleIcon, theme = (0, import_core.useTheme)(), getThemedIcon = (0, import_helpers_tamagui.useGetThemedIcon)({ size: iconSize, color: theme.color }), children = React.Children.toArray(childrenProp).map((child) => disablePassStyles || !React.isValidElement(child) ? child : getThemedIcon(child));
98
+ return forceMount || isIndeterminate(context.state) || context.state === !0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
99
+ CheckboxIndicatorFrame,
100
+ {
101
+ "data-state": getState(context.state),
102
+ "data-disabled": context.disabled ? "" : void 0,
103
+ pointerEvents: "none",
104
+ ...indicatorProps,
105
+ ref: forwardedRef,
106
+ children
136
107
  }
137
- return getThemedIcon(child);
138
- });
139
- if (forceMount || isIndeterminate(context.state) || context.state === true)
140
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
141
- CheckboxIndicatorFrame,
142
- {
143
- "data-state": getState(context.state),
144
- "data-disabled": context.disabled ? "" : void 0,
145
- pointerEvents: "none",
146
- ...indicatorProps,
147
- ref: forwardedRef,
148
- children
149
- }
150
- );
151
- return null;
108
+ ) : null;
152
109
  }
153
110
  )
154
111
  );
155
112
  CheckboxIndicator.displayName = INDICATOR_NAME;
156
- const CHECKBOX_NAME = "Checkbox";
157
- const CheckboxFrame = (0, import_core.styled)(import_stacks.ThemeableStack, {
113
+ const CHECKBOX_NAME = "Checkbox", CheckboxFrame = (0, import_core.styled)(import_stacks.ThemeableStack, {
158
114
  name: CHECKBOX_NAME,
159
115
  tag: "button",
160
116
  context: CheckboxStyledContext,
@@ -165,8 +121,8 @@ const CheckboxFrame = (0, import_core.styled)(import_stacks.ThemeableStack, {
165
121
  backgroundColor: "$background",
166
122
  alignItems: "center",
167
123
  justifyContent: "center",
168
- pressTheme: true,
169
- focusable: true,
124
+ pressTheme: !0,
125
+ focusable: !0,
170
126
  borderWidth: 1,
171
127
  borderColor: "$borderColor",
172
128
  hoverStyle: {
@@ -178,22 +134,16 @@ const CheckboxFrame = (0, import_core.styled)(import_stacks.ThemeableStack, {
178
134
  }
179
135
  },
180
136
  size: {
181
- "...size": (val, { tokens }) => {
182
- const radiusToken = (0, import_core.getVariableValue)((0, import_get_token.getSize)(val)) / 8;
183
- return {
184
- borderRadius: radiusToken
185
- };
186
- }
137
+ "...size": (val, { tokens }) => ({
138
+ borderRadius: (0, import_core.getVariableValue)((0, import_get_token.getSize)(val)) / 8
139
+ })
187
140
  }
188
141
  },
189
142
  defaultVariants: {
190
- unstyled: false
143
+ unstyled: !1
191
144
  }
192
- });
193
- const [createCheckboxContext, createCheckboxScope] = (0, import_create_context.createContextScope)(CHECKBOX_NAME);
194
- const [CheckboxProvider, useCheckboxContext] = createCheckboxContext(CHECKBOX_NAME);
195
- const CheckboxComponent = CheckboxFrame.extractable(
196
- React.forwardRef(function Checkbox(props, forwardedRef) {
145
+ }), [createCheckboxContext, createCheckboxScope] = (0, import_create_context.createContextScope)(CHECKBOX_NAME), [CheckboxProvider, useCheckboxContext] = createCheckboxContext(CHECKBOX_NAME), CheckboxComponent = CheckboxFrame.extractable(
146
+ React.forwardRef(function(props, forwardedRef) {
197
147
  const {
198
148
  __scopeCheckbox,
199
149
  labelledBy: ariaLabelledby,
@@ -209,39 +159,15 @@ const CheckboxComponent = CheckboxFrame.extractable(
209
159
  native,
210
160
  scaleIcon,
211
161
  ...checkboxProps
212
- } = props;
213
- const [button, setButton] = React.useState(null);
214
- const composedRefs = (0, import_core.useComposedRefs)(forwardedRef, (node) => setButton(node));
215
- const hasConsumerStoppedPropagationRef = React.useRef(false);
216
- const propsActive = (0, import_core.useProps)(props);
217
- const isFormControl = import_core.isWeb ? button ? Boolean(button.closest("form")) : true : false;
218
- const [checked = false, setChecked] = (0, import_use_controllable_state.useControllableState)({
162
+ } = props, [button, setButton] = React.useState(null), composedRefs = (0, import_core.useComposedRefs)(forwardedRef, (node) => setButton(node)), hasConsumerStoppedPropagationRef = React.useRef(!1), propsActive = (0, import_core.useProps)(props), isFormControl = import_core.isWeb ? button ? !!button.closest("form") : !0 : !1, [checked = !1, setChecked] = (0, import_use_controllable_state.useControllableState)({
219
163
  prop: checkedProp,
220
164
  defaultProp: defaultChecked,
221
165
  onChange: onCheckedChange
222
- });
223
- const styledContext = React.useContext(CheckboxStyledContext);
224
- const adjustedSize = (0, import_core.getVariableValue)(
225
- (0, import_get_token.getSize)(propsActive.size ?? (styledContext == null ? void 0 : styledContext.size) ?? "$true", {
166
+ }), styledContext = React.useContext(CheckboxStyledContext), adjustedSize = (0, import_core.getVariableValue)(
167
+ (0, import_get_token.getSize)(propsActive.size ?? styledContext?.size ?? "$true", {
226
168
  shift: sizeAdjust
227
169
  })
228
- );
229
- const size = scaleSize ? Math.round(adjustedSize * scaleSize) : adjustedSize;
230
- const labelId = (0, import_label.useLabelContext)(button);
231
- const labelledBy = ariaLabelledby || labelId;
232
- if (process.env.TAMAGUI_TARGET === "native") {
233
- React.useEffect(() => {
234
- if (!props.id)
235
- return;
236
- return (0, import_focusable.registerFocusable)(props.id, {
237
- focusAndSelect: () => {
238
- setChecked((x) => !x);
239
- },
240
- focus: () => {
241
- }
242
- });
243
- }, [props.id, setChecked]);
244
- }
170
+ ), size = scaleSize ? Math.round(adjustedSize * scaleSize) : adjustedSize, labelId = (0, import_label.useLabelContext)(button);
245
171
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CheckboxProvider, { scope: __scopeCheckbox, state: checked, disabled, children: import_core.isWeb && native ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
246
172
  BubbleInput,
247
173
  {
@@ -262,7 +188,7 @@ const CheckboxComponent = CheckboxFrame.extractable(
262
188
  height: size,
263
189
  tag: "button",
264
190
  role: "checkbox",
265
- "aria-labelledby": labelledBy,
191
+ "aria-labelledby": ariaLabelledby || labelId,
266
192
  "aria-checked": isIndeterminate(checked) ? "mixed" : checked,
267
193
  "aria-required": required,
268
194
  "data-state": getState(checked),
@@ -276,26 +202,20 @@ const CheckboxComponent = CheckboxFrame.extractable(
276
202
  onKeyDown: (0, import_core.composeEventHandlers)(
277
203
  props.onKeyDown,
278
204
  (event) => {
279
- if (event.key === "Enter")
280
- event.preventDefault();
205
+ event.key === "Enter" && event.preventDefault();
281
206
  }
282
207
  )
283
208
  },
284
209
  onPress: (0, import_core.composeEventHandlers)(props.onPress, (event) => {
285
210
  setChecked(
286
- (prevChecked) => isIndeterminate(prevChecked) ? true : !prevChecked
287
- );
288
- if (isFormControl) {
289
- hasConsumerStoppedPropagationRef.current = event.isPropagationStopped();
290
- if (!hasConsumerStoppedPropagationRef.current)
291
- event.stopPropagation();
292
- }
211
+ (prevChecked) => isIndeterminate(prevChecked) ? !0 : !prevChecked
212
+ ), isFormControl && (hasConsumerStoppedPropagationRef.current = event.isPropagationStopped(), hasConsumerStoppedPropagationRef.current || event.stopPropagation());
293
213
  }),
294
214
  children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
295
215
  CheckboxStyledContext.Provider,
296
216
  {
297
- size: propsActive.size ?? (styledContext == null ? void 0 : styledContext.size) ?? "$true",
298
- scaleIcon: scaleIcon ?? (styledContext == null ? void 0 : styledContext.scaleIcon) ?? 1,
217
+ size: propsActive.size ?? styledContext?.size ?? "$true",
218
+ scaleIcon: scaleIcon ?? styledContext?.scaleIcon ?? 1,
299
219
  children: propsActive.children
300
220
  }
301
221
  )
@@ -304,7 +224,7 @@ const CheckboxComponent = CheckboxFrame.extractable(
304
224
  import_core.isWeb && isFormControl ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
305
225
  BubbleInput,
306
226
  {
307
- isHidden: true,
227
+ isHidden: !0,
308
228
  control: button,
309
229
  bubbles: !hasConsumerStoppedPropagationRef.current,
310
230
  name,
@@ -316,8 +236,7 @@ const CheckboxComponent = CheckboxFrame.extractable(
316
236
  ) : null
317
237
  ] }) });
318
238
  })
319
- );
320
- const Checkbox2 = (0, import_core.withStaticProperties)(CheckboxComponent, {
239
+ ), Checkbox2 = (0, import_core.withStaticProperties)(CheckboxComponent, {
321
240
  Indicator: CheckboxIndicator,
322
241
  Props: CheckboxStyledContext.Provider
323
242
  });
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/Checkbox.tsx"],
4
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA,kBAAAA;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA8EI;AA3EJ,kBAaO;AAEP,4BAAmC;AACnC,uBAAkC;AAClC,uBAA4B;AAC5B,uBAA2C;AAC3C,6BAAiC;AACjC,mBAAgC;AAChC,oBAA+B;AAC/B,oCAAqC;AACrC,0BAA4B;AAC5B,YAAuB;AAEhB,MA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AAA,cAEnD,sBAAY;AAAA;AAAA,UACf;AAAA;AAAA,MACF;AAAA,MAEC,qBAAS,gBACR;AAAA,QAAC;AAAA;AAAA,UACC,UAAQ;AAAA,UACR,SAAS;AAAA,UACT,SAAS,CAAC,iCAAiC;AAAA,UAC3C;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA;AAAA,MACF,IACE;AAAA,OACN,GAEJ;AAAA,EAEJ,CAAC;AACH,GAEaA,gBAAW,kCAAqB,mBAAmB;AAAA,EAC9D,WAAW;AAAA,EACX,OAAO,sBAAsB;AAC/B,CAAC;",
5
5
  "names": ["Checkbox"]
6
6
  }
@@ -0,0 +1,263 @@
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, __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: !0 });
10
+ }, __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from == "object" || typeof from == "function")
12
+ for (let key of __getOwnPropNames(from))
13
+ !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ return to;
15
+ };
16
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
17
+ // If the importer is in node compatibility mode or this is not an ESM
18
+ // file that has been converted to a CommonJS file using a Babel-
19
+ // compatible transform (i.e. "__esModule" has not been set), then set
20
+ // "default" to the CommonJS "module.exports" for node compatibility.
21
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
22
+ mod
23
+ )), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
24
+ var Checkbox_exports = {};
25
+ __export(Checkbox_exports, {
26
+ BubbleInput: () => BubbleInput,
27
+ Checkbox: () => Checkbox2,
28
+ CheckboxFrame: () => CheckboxFrame,
29
+ CheckboxStyledContext: () => CheckboxStyledContext,
30
+ createCheckboxScope: () => createCheckboxScope,
31
+ getState: () => getState,
32
+ isIndeterminate: () => isIndeterminate
33
+ });
34
+ module.exports = __toCommonJS(Checkbox_exports);
35
+ var import_core = require("@tamagui/core"), import_create_context = require("@tamagui/create-context"), import_focusable = require("@tamagui/focusable"), import_font_size = require("@tamagui/font-size"), import_get_token = require("@tamagui/get-token"), import_helpers_tamagui = require("@tamagui/helpers-tamagui"), import_label = require("@tamagui/label"), import_stacks = require("@tamagui/stacks"), import_use_controllable_state = require("@tamagui/use-controllable-state"), import_use_previous = require("@tamagui/use-previous"), React = __toESM(require("react")), import_jsx_runtime = require("react/jsx-runtime");
36
+ const CheckboxStyledContext = (0, import_core.createStyledContext)({
37
+ size: "$true",
38
+ scaleIcon: 1
39
+ });
40
+ function isIndeterminate(checked) {
41
+ return checked === "indeterminate";
42
+ }
43
+ function getState(checked) {
44
+ return isIndeterminate(checked) ? "indeterminate" : checked ? "checked" : "unchecked";
45
+ }
46
+ const BubbleInput = (props) => {
47
+ const { checked, bubbles = !0, control, isHidden, ...inputProps } = props, ref = React.useRef(null), prevChecked = (0, import_use_previous.usePrevious)(checked);
48
+ return React.useEffect(() => {
49
+ const input = ref.current, inputProto = window.HTMLInputElement.prototype, setChecked = Object.getOwnPropertyDescriptor(
50
+ inputProto,
51
+ "checked"
52
+ ).set;
53
+ if (prevChecked !== checked && setChecked) {
54
+ const event = new Event("click", { bubbles });
55
+ input.indeterminate = isIndeterminate(checked), setChecked.call(input, isIndeterminate(checked) ? !1 : checked), input.dispatchEvent(event);
56
+ }
57
+ }, [prevChecked, checked, bubbles]), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
58
+ "input",
59
+ {
60
+ type: "checkbox",
61
+ defaultChecked: isIndeterminate(checked) ? !1 : checked,
62
+ ...inputProps,
63
+ tabIndex: -1,
64
+ ref,
65
+ "aria-hidden": isHidden,
66
+ style: {
67
+ ...isHidden ? {
68
+ // ...controlSize,
69
+ position: "absolute",
70
+ pointerEvents: "none",
71
+ opacity: 0,
72
+ margin: 0
73
+ } : {
74
+ appearance: "auto",
75
+ accentColor: "var(--color6)"
76
+ },
77
+ ...props.style
78
+ }
79
+ }
80
+ );
81
+ }, INDICATOR_NAME = "CheckboxIndicator", CheckboxIndicatorFrame = (0, import_core.styled)(import_stacks.ThemeableStack, {
82
+ // use Checkbox for easier themes
83
+ name: INDICATOR_NAME,
84
+ context: CheckboxStyledContext
85
+ }), CheckboxIndicator = CheckboxIndicatorFrame.extractable(
86
+ React.forwardRef(
87
+ (props, forwardedRef) => {
88
+ const {
89
+ __scopeCheckbox,
90
+ children: childrenProp,
91
+ forceMount,
92
+ disablePassStyles,
93
+ ...indicatorProps
94
+ } = props;
95
+ process.env.NODE_ENV === "development" && !childrenProp && console.warn(
96
+ "Warning: You created a Checkbox.Indicator without passing an child prop for it to use as an icon."
97
+ );
98
+ const context = useCheckboxContext(INDICATOR_NAME, __scopeCheckbox), styledContext = React.useContext(CheckboxStyledContext), iconSize = (typeof styledContext.size == "number" ? styledContext.size * 0.65 : (0, import_font_size.getFontSize)(styledContext.size)) * styledContext.scaleIcon, theme = (0, import_core.useTheme)(), getThemedIcon = (0, import_helpers_tamagui.useGetThemedIcon)({ size: iconSize, color: theme.color }), children = React.Children.toArray(childrenProp).map((child) => disablePassStyles || !React.isValidElement(child) ? child : getThemedIcon(child));
99
+ return forceMount || isIndeterminate(context.state) || context.state === !0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
100
+ CheckboxIndicatorFrame,
101
+ {
102
+ "data-state": getState(context.state),
103
+ "data-disabled": context.disabled ? "" : void 0,
104
+ pointerEvents: "none",
105
+ ...indicatorProps,
106
+ ref: forwardedRef,
107
+ children
108
+ }
109
+ ) : null;
110
+ }
111
+ )
112
+ );
113
+ CheckboxIndicator.displayName = INDICATOR_NAME;
114
+ const CHECKBOX_NAME = "Checkbox", CheckboxFrame = (0, import_core.styled)(import_stacks.ThemeableStack, {
115
+ name: CHECKBOX_NAME,
116
+ tag: "button",
117
+ context: CheckboxStyledContext,
118
+ variants: {
119
+ unstyled: {
120
+ false: {
121
+ size: "$true",
122
+ backgroundColor: "$background",
123
+ alignItems: "center",
124
+ justifyContent: "center",
125
+ pressTheme: !0,
126
+ focusable: !0,
127
+ borderWidth: 1,
128
+ borderColor: "$borderColor",
129
+ hoverStyle: {
130
+ borderColor: "$borderColorHover"
131
+ },
132
+ focusStyle: {
133
+ borderColor: "$borderColorFocus"
134
+ }
135
+ }
136
+ },
137
+ size: {
138
+ "...size": (val, { tokens }) => ({
139
+ borderRadius: (0, import_core.getVariableValue)((0, import_get_token.getSize)(val)) / 8
140
+ })
141
+ }
142
+ },
143
+ defaultVariants: {
144
+ unstyled: !1
145
+ }
146
+ }), [createCheckboxContext, createCheckboxScope] = (0, import_create_context.createContextScope)(CHECKBOX_NAME), [CheckboxProvider, useCheckboxContext] = createCheckboxContext(CHECKBOX_NAME), CheckboxComponent = CheckboxFrame.extractable(
147
+ React.forwardRef(function(props, forwardedRef) {
148
+ const {
149
+ __scopeCheckbox,
150
+ labelledBy: ariaLabelledby,
151
+ name,
152
+ checked: checkedProp,
153
+ defaultChecked,
154
+ required,
155
+ scaleSize = 0.45,
156
+ sizeAdjust = 0,
157
+ disabled,
158
+ value = "on",
159
+ onCheckedChange,
160
+ native,
161
+ scaleIcon,
162
+ ...checkboxProps
163
+ } = props, [button, setButton] = React.useState(null), composedRefs = (0, import_core.useComposedRefs)(forwardedRef, (node) => setButton(node)), hasConsumerStoppedPropagationRef = React.useRef(!1), propsActive = (0, import_core.useProps)(props), isFormControl = import_core.isWeb ? button ? !!button.closest("form") : !0 : !1, [checked = !1, setChecked] = (0, import_use_controllable_state.useControllableState)({
164
+ prop: checkedProp,
165
+ defaultProp: defaultChecked,
166
+ onChange: onCheckedChange
167
+ }), styledContext = React.useContext(CheckboxStyledContext), adjustedSize = (0, import_core.getVariableValue)(
168
+ (0, import_get_token.getSize)(propsActive.size ?? styledContext?.size ?? "$true", {
169
+ shift: sizeAdjust
170
+ })
171
+ ), size = scaleSize ? Math.round(adjustedSize * scaleSize) : adjustedSize, labelId = (0, import_label.useLabelContext)(button), labelledBy = ariaLabelledby || labelId;
172
+ return React.useEffect(() => {
173
+ if (props.id)
174
+ return (0, import_focusable.registerFocusable)(props.id, {
175
+ focusAndSelect: () => {
176
+ setChecked((x) => !x);
177
+ },
178
+ focus: () => {
179
+ }
180
+ });
181
+ }, [props.id, setChecked]), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CheckboxProvider, { scope: __scopeCheckbox, state: checked, disabled, children: import_core.isWeb && native ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
182
+ BubbleInput,
183
+ {
184
+ control: button,
185
+ bubbles: !hasConsumerStoppedPropagationRef.current,
186
+ name,
187
+ value,
188
+ checked,
189
+ required,
190
+ disabled,
191
+ id: props.id
192
+ }
193
+ ) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
194
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
195
+ CheckboxFrame,
196
+ {
197
+ width: size,
198
+ height: size,
199
+ tag: "button",
200
+ role: "checkbox",
201
+ "aria-labelledby": labelledBy,
202
+ "aria-checked": isIndeterminate(checked) ? "mixed" : checked,
203
+ "aria-required": required,
204
+ "data-state": getState(checked),
205
+ "data-disabled": disabled ? "" : void 0,
206
+ disabled,
207
+ ...checkboxProps,
208
+ ref: composedRefs,
209
+ ...import_core.isWeb && {
210
+ type: "button",
211
+ value,
212
+ onKeyDown: (0, import_core.composeEventHandlers)(
213
+ props.onKeyDown,
214
+ (event) => {
215
+ event.key === "Enter" && event.preventDefault();
216
+ }
217
+ )
218
+ },
219
+ onPress: (0, import_core.composeEventHandlers)(props.onPress, (event) => {
220
+ setChecked(
221
+ (prevChecked) => isIndeterminate(prevChecked) ? !0 : !prevChecked
222
+ ), isFormControl && (hasConsumerStoppedPropagationRef.current = event.isPropagationStopped(), hasConsumerStoppedPropagationRef.current || event.stopPropagation());
223
+ }),
224
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
225
+ CheckboxStyledContext.Provider,
226
+ {
227
+ size: propsActive.size ?? styledContext?.size ?? "$true",
228
+ scaleIcon: scaleIcon ?? styledContext?.scaleIcon ?? 1,
229
+ children: propsActive.children
230
+ }
231
+ )
232
+ }
233
+ ),
234
+ import_core.isWeb && isFormControl ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
235
+ BubbleInput,
236
+ {
237
+ isHidden: !0,
238
+ control: button,
239
+ bubbles: !hasConsumerStoppedPropagationRef.current,
240
+ name,
241
+ value,
242
+ checked,
243
+ required,
244
+ disabled
245
+ }
246
+ ) : null
247
+ ] }) });
248
+ })
249
+ ), Checkbox2 = (0, import_core.withStaticProperties)(CheckboxComponent, {
250
+ Indicator: CheckboxIndicator,
251
+ Props: CheckboxStyledContext.Provider
252
+ });
253
+ // Annotate the CommonJS export names for ESM import in node:
254
+ 0 && (module.exports = {
255
+ BubbleInput,
256
+ Checkbox,
257
+ CheckboxFrame,
258
+ CheckboxStyledContext,
259
+ createCheckboxScope,
260
+ getState,
261
+ isIndeterminate
262
+ });
263
+ //# sourceMappingURL=Checkbox.js.map
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/Checkbox.tsx"],
4
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA,kBAAAA;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAaO,0BAEP,wBAAmC,oCACnC,mBAAkC,+BAClC,mBAA4B,+BAC5B,mBAA2C,+BAC3C,yBAAiC,qCACjC,eAAgC,2BAChC,gBAA+B,4BAC/B,gCAAqC,4CACrC,sBAA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BACF,iCAAiC,UAAU,MAAM,qBAAqB,GAIjE,iCAAiC,WAAS,MAAM,gBAAgB;AAAA,UAEzE,CAAC;AAAA,UAED;AAAA,YAAC,sBAAsB;AAAA,YAAtB;AAAA,cACC,MAAM,YAAY,QAAQ,eAAe,QAAQ;AAAA,cACjD,WAAW,aAAa,eAAe,aAAa;AAAA,cAEnD,sBAAY;AAAA;AAAA,UACf;AAAA;AAAA,MACF;AAAA,MAEC,qBAAS,gBACR;AAAA,QAAC;AAAA;AAAA,UACC,UAAQ;AAAA,UACR,SAAS;AAAA,UACT,SAAS,CAAC,iCAAiC;AAAA,UAC3C;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA;AAAA,MACF,IACE;AAAA,OACN,GAEJ;AAAA,EAEJ,CAAC;AACH,GAEaA,gBAAW,kCAAqB,mBAAmB;AAAA,EAC9D,WAAW;AAAA,EACX,OAAO,sBAAsB;AAC/B,CAAC;",
5
+ "names": ["Checkbox"]
6
+ }
package/dist/cjs/index.js CHANGED
@@ -1,18 +1,14 @@
1
- "use strict";
2
1
  var __defProp = Object.defineProperty;
3
2
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
4
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
5
  var __copyProps = (to, from, except, desc) => {
7
- if (from && typeof from === "object" || typeof from === "function") {
6
+ if (from && typeof from == "object" || typeof from == "function")
8
7
  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
- }
8
+ !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
12
9
  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);
10
+ }, __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
11
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
16
12
  var src_exports = {};
17
13
  module.exports = __toCommonJS(src_exports);
18
14
  __reExport(src_exports, require("./Checkbox"), module.exports);