tamagui 1.68.0 → 1.68.1

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/native.js CHANGED
@@ -16220,6 +16220,119 @@ var require_index_native60 = __commonJS({
16220
16220
  }
16221
16221
  });
16222
16222
 
16223
+ // ../switch/dist/cjs/SwitchContext.native.js
16224
+ var require_SwitchContext_native = __commonJS({
16225
+ "../switch/dist/cjs/SwitchContext.native.js"(exports, module2) {
16226
+ "use strict";
16227
+ var __defProp2 = Object.defineProperty, __getOwnPropDesc2 = Object.getOwnPropertyDescriptor, __getOwnPropNames2 = Object.getOwnPropertyNames, __hasOwnProp2 = Object.prototype.hasOwnProperty, __export2 = (target, all) => {
16228
+ for (var name in all)
16229
+ __defProp2(target, name, { get: all[name], enumerable: !0 });
16230
+ }, __copyProps2 = (to, from, except, desc) => {
16231
+ if (from && typeof from == "object" || typeof from == "function")
16232
+ for (let key of __getOwnPropNames2(from))
16233
+ !__hasOwnProp2.call(to, key) && key !== except && __defProp2(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable });
16234
+ return to;
16235
+ }, __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: !0 }), mod), SwitchContext_exports = {};
16236
+ __export2(SwitchContext_exports, {
16237
+ SwitchContext: () => SwitchContext
16238
+ });
16239
+ module2.exports = __toCommonJS2(SwitchContext_exports);
16240
+ var import_core12 = require_index_native10(), SwitchContext = (0, import_core12.createStyledContext)({
16241
+ checked: !1,
16242
+ disabled: !1,
16243
+ size: void 0,
16244
+ frameWidth: 0,
16245
+ unstyled: !1
16246
+ });
16247
+ }
16248
+ });
16249
+
16250
+ // ../switch/dist/cjs/Switch.native.js
16251
+ var require_Switch_native = __commonJS({
16252
+ "../switch/dist/cjs/Switch.native.js"(exports, module2) {
16253
+ "use strict";
16254
+ var __defProp2 = Object.defineProperty, __getOwnPropDesc2 = Object.getOwnPropertyDescriptor, __getOwnPropNames2 = Object.getOwnPropertyNames, __hasOwnProp2 = Object.prototype.hasOwnProperty, __export2 = (target, all) => {
16255
+ for (var name in all)
16256
+ __defProp2(target, name, { get: all[name], enumerable: !0 });
16257
+ }, __copyProps2 = (to, from, except, desc) => {
16258
+ if (from && typeof from == "object" || typeof from == "function")
16259
+ for (let key of __getOwnPropNames2(from))
16260
+ !__hasOwnProp2.call(to, key) && key !== except && __defProp2(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable });
16261
+ return to;
16262
+ }, __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: !0 }), mod), Switch_exports = {};
16263
+ __export2(Switch_exports, {
16264
+ SwitchFrame: () => SwitchFrame,
16265
+ SwitchThumb: () => SwitchThumb
16266
+ });
16267
+ module2.exports = __toCommonJS2(Switch_exports);
16268
+ var import_core12 = require_index_native10(), import_get_token2 = require_index_native18(), import_stacks3 = require_index_native20(), import_SwitchContext = require_SwitchContext_native(), SwitchThumb = (0, import_core12.styled)(import_stacks3.ThemeableStack, {
16269
+ name: "SwitchThumb",
16270
+ context: import_SwitchContext.SwitchContext,
16271
+ variants: {
16272
+ unstyled: {
16273
+ false: {
16274
+ size: "$true",
16275
+ backgroundColor: "$background",
16276
+ borderRadius: 1e3
16277
+ }
16278
+ },
16279
+ size: {
16280
+ "...size": (val) => {
16281
+ let size = getSwitchHeight(val);
16282
+ return {
16283
+ height: size,
16284
+ width: size
16285
+ };
16286
+ }
16287
+ }
16288
+ },
16289
+ defaultVariants: {
16290
+ unstyled: !1
16291
+ }
16292
+ }), getSwitchHeight = (val) => Math.round((0, import_core12.getVariableValue)((0, import_get_token2.getSize)(val)) * 0.65), getSwitchWidth = (val) => getSwitchHeight(val) * 2, SwitchFrame = (0, import_core12.styled)(import_stacks3.YStack, {
16293
+ name: "Switch",
16294
+ tag: "button",
16295
+ context: import_SwitchContext.SwitchContext,
16296
+ variants: {
16297
+ unstyled: {
16298
+ false: {
16299
+ size: "$true",
16300
+ borderRadius: 1e3,
16301
+ borderWidth: 2,
16302
+ borderColor: "transparent",
16303
+ backgroundColor: "$background",
16304
+ focusStyle: {
16305
+ borderColor: "$borderColorFocus",
16306
+ outlineColor: "$borderColorFocus",
16307
+ outlineStyle: "solid",
16308
+ outlineWidth: 1
16309
+ }
16310
+ }
16311
+ },
16312
+ checked: {
16313
+ true: {}
16314
+ },
16315
+ frameWidth: {
16316
+ ":number": () => null
16317
+ },
16318
+ size: {
16319
+ "...size": (val) => {
16320
+ let height = getSwitchHeight(val) + 4, width = getSwitchWidth(val) + 4;
16321
+ return {
16322
+ height,
16323
+ minHeight: height,
16324
+ width
16325
+ };
16326
+ }
16327
+ }
16328
+ },
16329
+ defaultVariants: {
16330
+ unstyled: !1
16331
+ }
16332
+ });
16333
+ }
16334
+ });
16335
+
16223
16336
  // ../switch/dist/cjs/createSwitch.native.js
16224
16337
  var require_createSwitch_native = __commonJS({
16225
16338
  "../switch/dist/cjs/createSwitch.native.js"(exports, module2) {
@@ -16241,31 +16354,43 @@ var require_createSwitch_native = __commonJS({
16241
16354
  mod
16242
16355
  )), __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: !0 }), mod), createSwitch_exports = {};
16243
16356
  __export2(createSwitch_exports, {
16244
- SwitchContext: () => SwitchContext,
16245
16357
  createSwitch: () => createSwitch
16246
16358
  });
16247
16359
  module2.exports = __toCommonJS2(createSwitch_exports);
16248
- var import_compose_refs = require_index_native6(), import_core12 = require_index_native10(), import_focusable2 = require_index_native44(), import_get_token2 = require_index_native18(), import_label = require_index_native45(), import_use_controllable_state = require_index_native15(), import_use_previous = require_index_native46(), React2 = __toESM2(require("react")), import_react_native4 = require_fake_react_native(), import_jsx_runtime6 = (
16360
+ var import_compose_refs = require_index_native6(), import_core12 = require_index_native10(), import_focusable2 = require_index_native44(), import_get_token2 = require_index_native18(), import_label = require_index_native45(), import_use_controllable_state = require_index_native15(), import_use_previous = require_index_native46(), React2 = __toESM2(require("react")), import_react_native4 = require_fake_react_native(), import_Switch = require_Switch_native(), import_SwitchContext = require_SwitchContext_native(), import_jsx_runtime6 = (
16249
16361
  // @ts-ignore
16250
16362
  require("react/jsx-runtime")
16251
- ), SwitchContext = (0, import_core12.createStyledContext)({
16252
- checked: !1,
16253
- disabled: !1,
16254
- size: void 0,
16255
- frameWidth: 0,
16256
- unstyled: !1
16257
- });
16258
- function createSwitch({ Frame, Thumb, acceptsUnstyled }) {
16259
- let SwitchThumb = Thumb.styleable(function(props, forwardedRef) {
16260
- let { size: sizeProp, ...thumbProps } = props, { disabled, checked, unstyled, frameWidth } = React2.useContext(SwitchContext), [thumbWidth, setThumbWidth] = React2.useState(0), initialChecked = React2.useRef(checked).current, distance = frameWidth - thumbWidth;
16363
+ );
16364
+ function createSwitch({
16365
+ Frame = import_Switch.SwitchFrame,
16366
+ Thumb = import_Switch.SwitchThumb,
16367
+ acceptsUnstyled
16368
+ }) {
16369
+ process.env.NODE_ENV === "development" && (Frame !== import_Switch.SwitchFrame && Frame.staticConfig.context && console.warn(
16370
+ "Warning: createSwitch() needs to control context to pass checked state from Frame to Thumb, any custom context passed will be overridden."
16371
+ ), Thumb !== import_Switch.SwitchThumb && Thumb.staticConfig.context && console.warn(
16372
+ "Warning: createSwitch() needs to control context to pass checked state from Frame to Thumb, any custom context passed will be overridden."
16373
+ )), Frame.staticConfig.context = import_SwitchContext.SwitchContext, Thumb.staticConfig.context = import_SwitchContext.SwitchContext;
16374
+ let SwitchThumbComponent = Thumb.styleable(function(props, forwardedRef) {
16375
+ let { size: sizeProp, unstyled: unstyledProp, ...thumbProps } = props, context = React2.useContext(import_SwitchContext.SwitchContext), {
16376
+ disabled,
16377
+ checked,
16378
+ unstyled: unstyledContext,
16379
+ frameWidth,
16380
+ size: sizeContext
16381
+ } = context, [thumbWidth, setThumbWidth] = React2.useState(0), initialChecked = React2.useRef(checked).current, distance = frameWidth - thumbWidth, x = initialChecked ? checked ? 0 : -distance : checked ? distance : 0;
16261
16382
  return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
16262
16383
  Thumb,
16263
16384
  {
16264
- theme: unstyled === !1 && checked ? "active" : null,
16385
+ ...(unstyledProp ?? unstyledContext ?? !1) === !1 && {
16386
+ unstyled: !1,
16387
+ size: sizeProp ?? sizeContext ?? "$true",
16388
+ theme: checked ? "active" : null
16389
+ },
16265
16390
  "data-state": getState(checked),
16266
16391
  "data-disabled": disabled ? "" : void 0,
16267
16392
  alignSelf: initialChecked ? "flex-end" : "flex-start",
16268
- x: initialChecked ? checked ? 0 : -distance : checked ? distance : 0,
16393
+ x,
16269
16394
  ...thumbProps,
16270
16395
  onLayout: (0, import_core12.composeEventHandlers)(
16271
16396
  props.onLayout,
@@ -16278,8 +16403,8 @@ var require_createSwitch_native = __commonJS({
16278
16403
  }
16279
16404
  );
16280
16405
  }), SwitchComponent = Frame.extractable(
16281
- React2.forwardRef(function(propsIn, forwardedRef) {
16282
- let styledContext = React2.useContext(SwitchContext), props = (0, import_core12.useProps)(propsIn), {
16406
+ React2.forwardRef(function SwitchFrame2(propsIn, forwardedRef) {
16407
+ let styledContext = React2.useContext(import_SwitchContext.SwitchContext), props = (0, import_core12.useProps)(propsIn), {
16283
16408
  labeledBy: ariaLabelledby,
16284
16409
  name,
16285
16410
  checked: checkedProp,
@@ -16292,12 +16417,13 @@ var require_createSwitch_native = __commonJS({
16292
16417
  unstyled = styledContext.unstyled ?? !1,
16293
16418
  native: nativeProp,
16294
16419
  nativeProps,
16420
+ children,
16295
16421
  ...switchProps
16296
16422
  } = props, leftBorderWidth = (() => {
16297
16423
  let _;
16298
16424
  for (let key in switchProps)
16299
16425
  (key === "borderWidth" || key === "borderLeftWidth") && (_ = switchProps[key]);
16300
- return acceptsUnstyled && _ === void 0 && unstyled === !1 && (_ = 2), typeof _ == "string" && (_ = (0, import_core12.getVariableValue)((0, import_get_token2.getSize)(_))), +_;
16426
+ return Frame === SwitchFrame2 && acceptsUnstyled && _ == null && unstyled === !1 && (_ = 2), typeof _ == "string" && (_ = (0, import_core12.getVariableValue)((0, import_get_token2.getSize)(_))), typeof _ == "number" ? _ : 0;
16301
16427
  })(), native = Array.isArray(nativeProp) ? nativeProp : [nativeProp], shouldRenderMobileNative = !import_core12.isWeb && nativeProp === !0 || !import_core12.isWeb && native.includes("mobile") || native.includes("android") && import_react_native4.Platform.OS === "android" || native.includes("ios") && import_react_native4.Platform.OS === "ios", [button, setButton] = React2.useState(null), composedRefs = (0, import_compose_refs.useComposedRefs)(forwardedRef, (node) => setButton(node)), labelId = (0, import_label.useLabelContext)(button), labelledBy = ariaLabelledby || labelId, hasConsumerStoppedPropagationRef = React2.useRef(!1), isFormControl = import_core12.isWeb ? button ? !!button.closest("form") : !0 : !1, [frameWidth, setFrameWidth] = React2.useState(0), [checked = !1, setChecked] = (0, import_use_controllable_state.useControllableState)({
16302
16428
  prop: checkedProp,
16303
16429
  defaultProp: defaultChecked || !1,
@@ -16343,12 +16469,13 @@ var require_createSwitch_native = __commonJS({
16343
16469
  setChecked((prevChecked) => !prevChecked), import_core12.isWeb && isFormControl && (hasConsumerStoppedPropagationRef.current = event.isPropagationStopped(), hasConsumerStoppedPropagationRef.current || event.stopPropagation());
16344
16470
  }),
16345
16471
  onLayout: (0, import_core12.composeEventHandlers)(
16472
+ // @ts-ignore
16346
16473
  props.onLayout,
16347
- (e) => (
16348
- // @ts-ignore
16349
- setFrameWidth(e.nativeEvent.layout.width)
16350
- )
16351
- )
16474
+ (e) => {
16475
+ setFrameWidth(e.nativeEvent.layout.width);
16476
+ }
16477
+ ),
16478
+ children: typeof children == "function" ? children(checked) : children
16352
16479
  }
16353
16480
  ),
16354
16481
  import_core12.isWeb && isFormControl && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
@@ -16402,15 +16529,15 @@ var require_createSwitch_native = __commonJS({
16402
16529
  return checked ? "checked" : "unchecked";
16403
16530
  }
16404
16531
  return (0, import_core12.withStaticProperties)(SwitchComponent, {
16405
- Thumb: SwitchThumb
16532
+ Thumb: SwitchThumbComponent
16406
16533
  });
16407
16534
  }
16408
16535
  }
16409
16536
  });
16410
16537
 
16411
- // ../switch/dist/cjs/Switch.native.js
16412
- var require_Switch_native = __commonJS({
16413
- "../switch/dist/cjs/Switch.native.js"(exports, module2) {
16538
+ // ../switch/dist/cjs/index.native.js
16539
+ var require_index_native61 = __commonJS({
16540
+ "../switch/dist/cjs/index.native.js"(exports, module2) {
16414
16541
  "use strict";
16415
16542
  var __defProp2 = Object.defineProperty, __getOwnPropDesc2 = Object.getOwnPropertyDescriptor, __getOwnPropNames2 = Object.getOwnPropertyNames, __hasOwnProp2 = Object.prototype.hasOwnProperty, __export2 = (target, all) => {
16416
16543
  for (var name in all)
@@ -16420,98 +16547,19 @@ var require_Switch_native = __commonJS({
16420
16547
  for (let key of __getOwnPropNames2(from))
16421
16548
  !__hasOwnProp2.call(to, key) && key !== except && __defProp2(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable });
16422
16549
  return to;
16423
- }, __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: !0 }), mod), Switch_exports = {};
16424
- __export2(Switch_exports, {
16425
- Switch: () => Switch,
16426
- SwitchFrame: () => SwitchFrame,
16427
- SwitchThumb: () => SwitchThumb
16428
- });
16429
- module2.exports = __toCommonJS2(Switch_exports);
16430
- var import_core12 = require_index_native10(), import_get_token2 = require_index_native18(), import_stacks3 = require_index_native20(), import_createSwitch = require_createSwitch_native(), SwitchThumb = (0, import_core12.styled)(import_stacks3.ThemeableStack, {
16431
- name: "SwitchThumb",
16432
- context: import_createSwitch.SwitchContext,
16433
- variants: {
16434
- unstyled: {
16435
- false: {
16436
- size: "$true",
16437
- backgroundColor: "$background",
16438
- borderRadius: 1e3
16439
- }
16440
- },
16441
- size: {
16442
- "...size": (val) => {
16443
- let size = getSwitchHeight(val);
16444
- return {
16445
- height: size,
16446
- width: size
16447
- };
16448
- }
16449
- }
16450
- },
16451
- defaultVariants: {
16452
- unstyled: !1
16453
- }
16454
- }), getSwitchHeight = (val) => Math.round((0, import_core12.getVariableValue)((0, import_get_token2.getSize)(val)) * 0.65), getSwitchWidth = (val) => getSwitchHeight(val) * 2, SwitchFrame = (0, import_core12.styled)(import_stacks3.YStack, {
16455
- name: "Switch",
16456
- tag: "button",
16457
- context: import_createSwitch.SwitchContext,
16458
- variants: {
16459
- unstyled: {
16460
- false: {
16461
- size: "$true",
16462
- borderRadius: 1e3,
16463
- borderWidth: 2,
16464
- borderColor: "transparent",
16465
- backgroundColor: "$background",
16466
- focusStyle: {
16467
- borderColor: "$borderColorFocus",
16468
- outlineColor: "$borderColorFocus",
16469
- outlineStyle: "solid",
16470
- outlineWidth: 1
16471
- }
16472
- }
16473
- },
16474
- checked: {
16475
- true: {}
16476
- },
16477
- frameWidth: {
16478
- ":number": () => null
16479
- },
16480
- size: {
16481
- "...size": (val) => {
16482
- let height = getSwitchHeight(val) + 4, width = getSwitchWidth(val) + 4;
16483
- return {
16484
- height,
16485
- minHeight: height,
16486
- width
16487
- };
16488
- }
16489
- }
16490
- },
16491
- defaultVariants: {
16492
- unstyled: !1
16493
- }
16494
- }), Switch = (0, import_createSwitch.createSwitch)({
16495
- Frame: SwitchFrame,
16496
- Thumb: SwitchThumb,
16497
- acceptsUnstyled: !0
16498
- });
16499
- }
16500
- });
16501
-
16502
- // ../switch/dist/cjs/index.native.js
16503
- var require_index_native61 = __commonJS({
16504
- "../switch/dist/cjs/index.native.js"(exports, module2) {
16505
- "use strict";
16506
- var __defProp2 = Object.defineProperty, __getOwnPropDesc2 = Object.getOwnPropertyDescriptor, __getOwnPropNames2 = Object.getOwnPropertyNames, __hasOwnProp2 = Object.prototype.hasOwnProperty, __copyProps2 = (to, from, except, desc) => {
16507
- if (from && typeof from == "object" || typeof from == "function")
16508
- for (let key of __getOwnPropNames2(from))
16509
- !__hasOwnProp2.call(to, key) && key !== except && __defProp2(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable });
16510
- return to;
16511
16550
  }, __reExport2 = (target, mod, secondTarget) => (__copyProps2(target, mod, "default"), secondTarget && __copyProps2(secondTarget, mod, "default")), __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: !0 }), mod), src_exports2 = {};
16551
+ __export2(src_exports2, {
16552
+ Switch: () => Switch
16553
+ });
16512
16554
  module2.exports = __toCommonJS2(src_exports2);
16555
+ var import_createSwitch = require_createSwitch_native(), import_Switch = require_Switch_native();
16513
16556
  __reExport2(src_exports2, require_Switch_native(), module2.exports);
16514
16557
  __reExport2(src_exports2, require_createSwitch_native(), module2.exports);
16558
+ var Switch = (0, import_createSwitch.createSwitch)({
16559
+ Frame: import_Switch.SwitchFrame,
16560
+ Thumb: import_Switch.SwitchThumb,
16561
+ acceptsUnstyled: !0
16562
+ });
16515
16563
  }
16516
16564
  });
16517
16565