@tamagui/switch 1.110.5 → 1.111.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.
@@ -27,121 +27,25 @@ __export(createSwitch_exports, {
27
27
  createSwitch: () => createSwitch
28
28
  });
29
29
  module.exports = __toCommonJS(createSwitch_exports);
30
- var import_jsx_runtime = require("react/jsx-runtime"), import_core = require("@tamagui/core"), import_focusable = require("@tamagui/focusable"), import_switch_headless = require("@tamagui/switch-headless"), import_use_controllable_state = require("@tamagui/use-controllable-state"), React = __toESM(require("react")), import_react_native = require("react-native"), import_StyledContext = require("./StyledContext"), import_Switch = require("./Switch");
31
- function _array_like_to_array(arr, len) {
32
- (len == null || len > arr.length) && (len = arr.length);
33
- for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
34
- return arr2;
35
- }
36
- function _array_with_holes(arr) {
37
- if (Array.isArray(arr)) return arr;
38
- }
39
- function _define_property(obj, key, value) {
40
- return key in obj ? Object.defineProperty(obj, key, {
41
- value,
42
- enumerable: !0,
43
- configurable: !0,
44
- writable: !0
45
- }) : obj[key] = value, obj;
46
- }
47
- function _iterable_to_array_limit(arr, i) {
48
- var _i = arr == null ? null : typeof Symbol < "u" && arr[Symbol.iterator] || arr["@@iterator"];
49
- if (_i != null) {
50
- var _arr = [], _n = !0, _d = !1, _s, _e;
51
- try {
52
- for (_i = _i.call(arr); !(_n = (_s = _i.next()).done) && (_arr.push(_s.value), !(i && _arr.length === i)); _n = !0)
53
- ;
54
- } catch (err) {
55
- _d = !0, _e = err;
56
- } finally {
57
- try {
58
- !_n && _i.return != null && _i.return();
59
- } finally {
60
- if (_d) throw _e;
61
- }
62
- }
63
- return _arr;
64
- }
65
- }
66
- function _non_iterable_rest() {
67
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
68
- }
69
- function _object_spread(target) {
70
- for (var i = 1; i < arguments.length; i++) {
71
- var source = arguments[i] != null ? arguments[i] : {}, ownKeys2 = Object.keys(source);
72
- typeof Object.getOwnPropertySymbols == "function" && (ownKeys2 = ownKeys2.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
73
- return Object.getOwnPropertyDescriptor(source, sym).enumerable;
74
- }))), ownKeys2.forEach(function(key) {
75
- _define_property(target, key, source[key]);
76
- });
77
- }
78
- return target;
79
- }
80
- function ownKeys(object, enumerableOnly) {
81
- var keys = Object.keys(object);
82
- if (Object.getOwnPropertySymbols) {
83
- var symbols = Object.getOwnPropertySymbols(object);
84
- enumerableOnly && (symbols = symbols.filter(function(sym) {
85
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
86
- })), keys.push.apply(keys, symbols);
87
- }
88
- return keys;
89
- }
90
- function _object_spread_props(target, source) {
91
- return source = source ?? {}, Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function(key) {
92
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
93
- }), target;
94
- }
95
- function _object_without_properties(source, excluded) {
96
- if (source == null) return {};
97
- var target = _object_without_properties_loose(source, excluded), key, i;
98
- if (Object.getOwnPropertySymbols) {
99
- var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
100
- for (i = 0; i < sourceSymbolKeys.length; i++)
101
- key = sourceSymbolKeys[i], !(excluded.indexOf(key) >= 0) && Object.prototype.propertyIsEnumerable.call(source, key) && (target[key] = source[key]);
102
- }
103
- return target;
104
- }
105
- function _object_without_properties_loose(source, excluded) {
106
- if (source == null) return {};
107
- var target = {}, sourceKeys = Object.keys(source), key, i;
108
- for (i = 0; i < sourceKeys.length; i++)
109
- key = sourceKeys[i], !(excluded.indexOf(key) >= 0) && (target[key] = source[key]);
110
- return target;
111
- }
112
- function _sliced_to_array(arr, i) {
113
- return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
114
- }
115
- function _unsupported_iterable_to_array(o, minLen) {
116
- if (o) {
117
- if (typeof o == "string") return _array_like_to_array(o, minLen);
118
- var n = Object.prototype.toString.call(o).slice(8, -1);
119
- if (n === "Object" && o.constructor && (n = o.constructor.name), n === "Map" || n === "Set") return Array.from(n);
120
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
121
- }
122
- }
123
- var SwitchContext = /* @__PURE__ */ React.createContext({
30
+ var import_jsx_runtime = require("react/jsx-runtime"), import_core = require("@tamagui/core"), import_focusable = require("@tamagui/focusable"), import_switch_headless = require("@tamagui/switch-headless"), import_use_controllable_state = require("@tamagui/use-controllable-state"), React = __toESM(require("react")), import_react_native = require("react-native"), import_StyledContext = require("./StyledContext"), import_Switch = require("./Switch"), SwitchContext = /* @__PURE__ */ React.createContext({
124
31
  checked: !1,
125
32
  disabled: !1,
126
33
  frameWidth: 0
127
34
  });
128
35
  function createSwitch(createProps) {
129
- var disableActiveTheme = createProps.disableActiveTheme, _createProps_Frame = createProps.Frame, Frame = _createProps_Frame === void 0 ? import_Switch.SwitchFrame : _createProps_Frame, _createProps_Thumb = createProps.Thumb, Thumb = _createProps_Thumb === void 0 ? import_Switch.SwitchThumb : _createProps_Thumb;
36
+ var { disableActiveTheme, Frame = import_Switch.SwitchFrame, Thumb = import_Switch.SwitchThumb } = createProps;
130
37
  process.env.NODE_ENV === "development" && (Frame !== import_Switch.SwitchFrame && Frame.staticConfig.context && Frame.staticConfig.context !== import_StyledContext.SwitchStyledContext || Thumb !== import_Switch.SwitchThumb && Thumb.staticConfig.context && Thumb.staticConfig.context !== import_StyledContext.SwitchStyledContext) && console.warn("Warning: createSwitch() needs to control context to pass checked state from Frame to Thumb, any custom context passed will be overridden."), Frame.staticConfig.context = import_StyledContext.SwitchStyledContext, Thumb.staticConfig.context = import_StyledContext.SwitchStyledContext;
131
38
  var SwitchThumbComponent = Thumb.styleable(function(props, forwardedRef) {
132
- var sizeProp = props.size, unstyledProp = props.unstyled, nativeID = props.nativeID, thumbProps = _object_without_properties(props, [
133
- "size",
134
- "unstyled",
135
- "nativeID"
136
- ]), context = React.useContext(SwitchContext), checked = context.checked, disabled = context.disabled, frameWidth = context.frameWidth, styledContext = import_StyledContext.SwitchStyledContext.useStyledContext(), unstyledContext = styledContext.unstyled, sizeContext = styledContext.size, _ref, unstyled = process.env.TAMAGUI_HEADLESS === "1" ? !0 : (_ref = unstyledProp ?? unstyledContext) !== null && _ref !== void 0 ? _ref : !1, _ref1, size = (_ref1 = sizeProp ?? sizeContext) !== null && _ref1 !== void 0 ? _ref1 : "$true", initialChecked = React.useRef(checked).current, _React_useState = _sliced_to_array(React.useState(0), 2), thumbWidth = _React_useState[0], setThumbWidth = _React_useState[1], distance = frameWidth - thumbWidth, x = initialChecked ? checked ? 0 : -distance : checked ? distance : 0;
137
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Thumb, _object_spread(_object_spread_props(_object_spread({
39
+ var { size: sizeProp, unstyled: unstyledProp, nativeID, ...thumbProps } = props, context = React.useContext(SwitchContext), { checked, disabled, frameWidth } = context, styledContext = import_StyledContext.SwitchStyledContext.useStyledContext(), { unstyled: unstyledContext, size: sizeContext } = styledContext, _ref, unstyled = process.env.TAMAGUI_HEADLESS === "1" ? !0 : (_ref = unstyledProp ?? unstyledContext) !== null && _ref !== void 0 ? _ref : !1, _ref1, size = (_ref1 = sizeProp ?? sizeContext) !== null && _ref1 !== void 0 ? _ref1 : "$true", initialChecked = React.useRef(checked).current, [thumbWidth, setThumbWidth] = React.useState(0), distance = frameWidth - thumbWidth, x = initialChecked ? checked ? 0 : -distance : checked ? distance : 0;
40
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Thumb, {
138
41
  ref: forwardedRef,
139
- unstyled
140
- }, unstyled === !1 && _object_spread({
141
- size
142
- }, !disableActiveTheme && {
143
- theme: checked ? "active" : null
144
- })), {
42
+ unstyled,
43
+ ...unstyled === !1 && {
44
+ size,
45
+ ...!disableActiveTheme && {
46
+ theme: checked ? "active" : null
47
+ }
48
+ },
145
49
  alignSelf: initialChecked ? "flex-end" : "flex-start",
146
50
  x,
147
51
  // TODO: remove ViewProps cast
@@ -150,26 +54,21 @@ function createSwitch(createProps) {
150
54
  }),
151
55
  // expected variants
152
56
  checked,
153
- disabled
154
- }), thumbProps));
57
+ disabled,
58
+ ...thumbProps
59
+ });
155
60
  }), SwitchComponent = Frame.styleable(function(_props, forwardedRef) {
156
- var native = _props.native, nativeProps = _props.nativeProps, checkedProp = _props.checked, defaultChecked = _props.defaultChecked, onCheckedChange = _props.onCheckedChange, props = _object_without_properties(_props, [
157
- "native",
158
- "nativeProps",
159
- "checked",
160
- "defaultChecked",
161
- "onCheckedChange"
162
- ]), _useControllableState = _sliced_to_array((0, import_use_controllable_state.useControllableState)({
61
+ var { native, nativeProps, checked: checkedProp, defaultChecked, onCheckedChange, ...props } = _props, [checked, setChecked] = (0, import_use_controllable_state.useControllableState)({
163
62
  prop: checkedProp,
164
63
  defaultProp: defaultChecked || !1,
165
64
  onChange: onCheckedChange,
166
65
  transition: !0
167
- }), 2), checked = _useControllableState[0], setChecked = _useControllableState[1], styledContext = React.useContext(import_StyledContext.SwitchStyledContext.context), _React_useState = _sliced_to_array(React.useState(0), 2), frameWidth = _React_useState[0], setFrameWidth = _React_useState[1], propsActive = (0, import_core.useProps)(props, {
66
+ }), styledContext = React.useContext(import_StyledContext.SwitchStyledContext.context), [frameWidth, setFrameWidth] = React.useState(0), propsActive = (0, import_core.useProps)(props, {
168
67
  noNormalize: !0,
169
68
  noExpand: !0,
170
69
  resolveValues: "none",
171
70
  forComponent: Frame
172
- }), _styledContext_size, _ref, _styledContext_unstyled, _ref1, _useSwitch = (0, import_switch_headless.useSwitch)(
71
+ }), _styledContext_size, _ref, _styledContext_unstyled, _ref1, { switchProps, bubbleInput, switchRef } = (0, import_switch_headless.useSwitch)(
173
72
  // @ts-ignore
174
73
  Object.assign({
175
74
  size: (_ref = (_styledContext_size = styledContext.size) !== null && _styledContext_size !== void 0 ? _styledContext_size : props.size) !== null && _ref !== void 0 ? _ref : "$true",
@@ -180,7 +79,7 @@ function createSwitch(createProps) {
180
79
  setChecked
181
80
  ],
182
81
  forwardedRef
183
- ), switchProps = _useSwitch.switchProps, bubbleInput = _useSwitch.bubbleInput, switchRef = _useSwitch.switchRef;
82
+ );
184
83
  React.useEffect(function() {
185
84
  if (props.id && !props.disabled)
186
85
  return (0, import_focusable.registerFocusable)(props.id, {
@@ -197,25 +96,28 @@ function createSwitch(createProps) {
197
96
  props.disabled
198
97
  ]);
199
98
  var renderNative = (0, import_core.shouldRenderNativePlatform)(native);
200
- return renderNative === "android" || renderNative === "ios" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native.Switch, _object_spread({
99
+ return renderNative === "android" || renderNative === "ios" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native.Switch, {
201
100
  value: checked,
202
- onValueChange: setChecked
203
- }, nativeProps)) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(SwitchContext.Provider, {
101
+ onValueChange: setChecked,
102
+ ...nativeProps
103
+ }) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(SwitchContext.Provider, {
204
104
  value: {
205
105
  checked,
206
106
  disabled: switchProps.disabled,
207
107
  frameWidth
208
108
  },
209
109
  children: [
210
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Frame, _object_spread_props(_object_spread({
110
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Frame, {
211
111
  ref: switchRef,
212
- tag: "button"
213
- }, import_core.isWeb && {
214
- type: "button"
215
- }, switchProps, !disableActiveTheme && {
216
- theme: checked ? "active" : null,
217
- themeShallow: !0
218
- }), {
112
+ tag: "button",
113
+ ...import_core.isWeb && {
114
+ type: "button"
115
+ },
116
+ ...switchProps,
117
+ ...!disableActiveTheme && {
118
+ theme: checked ? "active" : null,
119
+ themeShallow: !0
120
+ },
219
121
  // expected variants
220
122
  checked,
221
123
  disabled: switchProps.disabled,
@@ -227,7 +129,7 @@ function createSwitch(createProps) {
227
129
  },
228
130
  children: switchProps.children
229
131
  })
230
- })),
132
+ }),
231
133
  bubbleInput
232
134
  ]
233
135
  });
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/Users/n8/tamagui/code/ui/switch/src/createSwitch.tsx"],
4
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;uDACA,cAOO,0BAKP,mBAAkC,+BAClC,yBAA0B,qCAC1B,gCAAqC,4CACrC,QAAuB,2BAEvB,sBAAuC,yBAEvC,uBAAoC,4BACpC,gBAA+D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoBxD,IAAMA,gBAAgBC,sBAAMC,cAIhC;EACDC,SAAS;EACTC,UAAU;EACVC,YAAY;AACd,CAAA;AAKO,SAASC,aAGdC,aAAmE;AACnE,MACEC,qBAGED,YAHFC,oBAAAA,qBAGED,YAFFE,OAAAA,QAAAA,uBAAAA,SAAQC,cAAAA,cAAAA,oBAAAA,qBAENH,YADFI,OAAAA,QAAAA,uBAAAA,SAAQC,4BAAAA;AAOV,EAAIC,QAAQC,IAAIC,aAAa,kBAExBN,UAAUC,cAAAA,eACTD,MAAMO,aAAaC,WACnBR,MAAMO,aAAaC,YAAYC,4CAChCP,UAAUC,6BACTD,MAAMK,aAAaC,WACnBN,MAAMK,aAAaC,YAAYC,6CAEjCC,QAAQC,KACL,2IAAA,GAKPX,MAAMO,aAAaC,UAAUC,0CAC7BP,MAAMK,aAAaC,UAAUC;AAE7B,MAAMG,uBAAuBV,MAAMW,UACjC,SAAqBC,OAAOC,cAAY;AACtC,QAAcC,WAA8DF,MAApEG,MAA0BC,eAA0CJ,MAApDK,UAAwBC,WAA4BN,MAA5BM,UAAaC,aAAAA,2BAAeP,OAAAA;MA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MAAMnB;KAAS;AAG/B,QAAMmF,mBAAeC,wCAA2B/B,MAAAA;AAChD,WAAI8B,iBAAiB,aAAaA,iBAAiB,QAE/C,uCAAA1C,KAAC4C,oBAAAA,QAAAA,eAAAA;MAAaJ,OAAOlF;MAASuF,eAAevB;OAAgBT,WAAAA,CAAAA,IAK/D,uCAAAiC,MAAC3F,cAAc4F,UAAQ;MACrBP,OAAO;QAAElF;QAASC,UAAU0E,YAAY1E;QAAUC;MAAW;;QAE7D,uCAAAwC,KAACpC,OAAAA,qBAAAA,eAAAA;UACCqC,KAAKkC;UACLa,KAAI;WACCC,qBAAS;UAAEC,MAAM;QAAS,GAC1BjB,aACA,CAACtE,sBAAsB;UAC1BuC,OAAO5C,UAAU,WAAW;UAC5B6F,cAAc;QAChB,CAAA,GAAA;;UAEA7F;UACAC,UAAU0E,YAAY1E;oBAEtB,uCAAAyC,KAACoD,mBAAAA;YACCjD,WAAU;YACVkD,MAAM;YACNjD,UAAU,SAACE,GAAAA;AACTiB,4BAAcjB,EAAEC,YAAYC,OAAOC,KAAK;YAC1C;sBAECwB,YAAYqB;;;QAIhBpB;;;EAGP,GACA;IACEqB,cAAc;EAChB,CAAA;AAGF,aAAOC,kCAAqB9C,iBAAiB;IAC3C5C,OAAOU;EACT,CAAA;AACF;",
5
- "names": ["SwitchContext", "React", "createContext", "checked", "disabled", "frameWidth", "createSwitch", "createProps", "disableActiveTheme", "Frame", "DefaultSwitchFrame", "Thumb", "SwitchThumb", "process", "env", "NODE_ENV", "staticConfig", "context", "SwitchStyledContext", "console", "warn", "SwitchThumbComponent", "styleable", "props", "forwardedRef", "sizeProp", "size", "unstyledProp", "unstyled", "nativeID", "thumbProps", "useContext", "styledContext", "useStyledContext", "unstyledContext", "sizeContext", "TAMAGUI_HEADLESS", "initialChecked", "useRef", "current", "useState", "thumbWidth", "setThumbWidth", "distance", "x", "_jsx", "ref", "theme", "alignSelf", "onLayout", "composeEventHandlers", "e", "nativeEvent", "layout", "width", "SwitchComponent", "_props", "native", "nativeProps", "checkedProp", "defaultChecked", "onCheckedChange", "useControllableState", "prop", "defaultProp", "onChange", "transition", "setChecked", "setFrameWidth", "propsActive", "useProps", "noNormalize", "noExpand", "resolveValues", "forComponent", "useSwitch", "Object", "assign", "switchProps", "bubbleInput", "switchRef", "useEffect", "id", "registerFocusable", "focusAndSelect", "value", "focus", "renderNative", "shouldRenderNativePlatform", "NativeSwitch", "onValueChange", "_jsxs", "Provider", "tag", "isWeb", "type", "themeShallow", "Stack", "flex", "children", "disableTheme", "withStaticProperties"]
4
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;uDACA,cAOO,0BAKP,mBAAkC,+BAClC,yBAA0B,qCAC1B,gCAAqC,4CACrC,QAAuB,2BAEvB,sBAAuC,yBAEvC,uBAAoC,4BACpC,gBAA+D,qBAoBlDA,gBAAgBC,sBAAMC,cAIhC;EACDC,SAAS;EACTC,UAAU;EACVC,YAAY;AACd,CAAA;AAKO,SAASC,aAGdC,aAAmE;AACnE,MAAM,EACJC,oBACAC,QAAQC,cAAAA,aACRC,QAAQC,0BAAW,IACjBL;AAMJ,EAAIM,QAAQC,IAAIC,aAAa,kBAExBN,UAAUC,cAAAA,eACTD,MAAMO,aAAaC,WACnBR,MAAMO,aAAaC,YAAYC,4CAChCP,UAAUC,6BACTD,MAAMK,aAAaC,WACnBN,MAAMK,aAAaC,YAAYC,6CAEjCC,QAAQC,KACN,2IAA2I,GAKjJX,MAAMO,aAAaC,UAAUC,0CAC7BP,MAAMK,aAAaC,UAAUC;AAE7B,MAAMG,uBAAuBV,MAAMW,UACjC,SAAqBC,OAAOC,cAAY;AACtC,QAAM,EAAEC,MAAMC,UAAUC,UAAUC,cAAcC,UAAU,GAAGC,WAAAA,IAAeP,OACtEN,UAAUhB,MAAM8B,WAAW/B,aAAAA,GAC3B,EAAEG,SAASC,UAAUC,WAAU,IAAKY,SAEpCe,gBAAgBd,yCAAoBe,iBAAgB,GACpD,EAAEN,UAAUO,iBAA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AA;AACTiB,4BAAcjB,EAAEC,YAAYC,OAAOC,KAAK;YAC1C;sBAECqB,YAAYwB;;;QAIhBvB;;;EAGP,GACA;IACEwB,cAAc;EAChB,CAAA;AAGF,aAAOC,kCAAqB9C,iBAAiB;IAC3C5C,OAAOU;EACT,CAAA;AACF;",
5
+ "names": ["SwitchContext", "React", "createContext", "checked", "disabled", "frameWidth", "createSwitch", "createProps", "disableActiveTheme", "Frame", "DefaultSwitchFrame", "Thumb", "SwitchThumb", "process", "env", "NODE_ENV", "staticConfig", "context", "SwitchStyledContext", "console", "warn", "SwitchThumbComponent", "styleable", "props", "forwardedRef", "size", "sizeProp", "unstyled", "unstyledProp", "nativeID", "thumbProps", "useContext", "styledContext", "useStyledContext", "unstyledContext", "sizeContext", "TAMAGUI_HEADLESS", "initialChecked", "useRef", "current", "thumbWidth", "setThumbWidth", "useState", "distance", "x", "_jsx", "ref", "theme", "alignSelf", "onLayout", "composeEventHandlers", "e", "nativeEvent", "layout", "width", "SwitchComponent", "_props", "native", "nativeProps", "checkedProp", "defaultChecked", "onCheckedChange", "setChecked", "useControllableState", "prop", "defaultProp", "onChange", "transition", "setFrameWidth", "propsActive", "useProps", "noNormalize", "noExpand", "resolveValues", "forComponent", "switchProps", "bubbleInput", "switchRef", "useSwitch", "Object", "assign", "useEffect", "id", "registerFocusable", "focusAndSelect", "value", "focus", "renderNative", "shouldRenderNativePlatform", "NativeSwitch", "onValueChange", "_jsxs", "Provider", "tag", "isWeb", "type", "themeShallow", "Stack", "flex", "children", "disableTheme", "withStaticProperties"]
6
6
  }
@@ -0,0 +1,7 @@
1
+ import { createStyledContext } from "@tamagui/core";
2
+ var SwitchStyledContext = createStyledContext({
3
+ size: void 0,
4
+ unstyled: process.env.TAMAGUI_HEADLESS === "1"
5
+ });
6
+ export { SwitchStyledContext };
7
+ //# sourceMappingURL=StyledContext.native.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createStyledContext","SwitchStyledContext","size","unstyled","process","env","TAMAGUI_HEADLESS"],"sources":["../../src/StyledContext.tsx"],"sourcesContent":[null],"mappings":"AACA,SAASA,mBAAA,QAA2B;AAE7B,IAAAC,mBAAM,GAAAD,mBAAsB;EAIjCE,IAAA,EAAM;EACNC,QAAA,EAAUC,OAAA,CAAQC,GAAA,CAAIC,gBAAA,KAAqB;AAC7C,CAAC","ignoreList":[]}
@@ -0,0 +1,75 @@
1
+ import { getVariableValue, styled } from "@tamagui/core";
2
+ import { getSize } from "@tamagui/get-token";
3
+ import { ThemeableStack, YStack } from "@tamagui/stacks";
4
+ var SwitchThumb = styled(ThemeableStack, {
5
+ name: "SwitchThumb",
6
+ variants: {
7
+ unstyled: {
8
+ false: {
9
+ size: "$true",
10
+ backgroundColor: "$background",
11
+ borderRadius: 1e3
12
+ }
13
+ },
14
+ checked: {
15
+ true: {}
16
+ },
17
+ size: {
18
+ "...size": function (val) {
19
+ var size = getSwitchHeight(val);
20
+ return {
21
+ height: size,
22
+ width: size
23
+ };
24
+ }
25
+ }
26
+ },
27
+ defaultVariants: {
28
+ unstyled: process.env.TAMAGUI_HEADLESS === "1"
29
+ }
30
+ }),
31
+ getSwitchHeight = function (val) {
32
+ return Math.round(getVariableValue(getSize(val)) * 0.65);
33
+ },
34
+ getSwitchWidth = function (val) {
35
+ return getSwitchHeight(val) * 2;
36
+ },
37
+ SwitchFrame = styled(YStack, {
38
+ name: "Switch",
39
+ tag: "button",
40
+ tabIndex: 0,
41
+ variants: {
42
+ unstyled: {
43
+ false: {
44
+ borderRadius: 1e3,
45
+ backgroundColor: "$background",
46
+ borderWidth: 2,
47
+ borderColor: "$background",
48
+ focusVisibleStyle: {
49
+ outlineColor: "$outlineColor",
50
+ outlineStyle: "solid",
51
+ outlineWidth: 2
52
+ }
53
+ }
54
+ },
55
+ checked: {
56
+ true: {}
57
+ },
58
+ size: {
59
+ "...size": function (val) {
60
+ var height = getSwitchHeight(val) + 4,
61
+ width = getSwitchWidth(val) + 4;
62
+ return {
63
+ height,
64
+ minHeight: height,
65
+ width
66
+ };
67
+ }
68
+ }
69
+ },
70
+ defaultVariants: {
71
+ unstyled: process.env.TAMAGUI_HEADLESS === "1"
72
+ }
73
+ });
74
+ export { SwitchFrame, SwitchThumb };
75
+ //# sourceMappingURL=Switch.native.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["getVariableValue","styled","getSize","ThemeableStack","YStack","SwitchThumb","name","variants","unstyled","false","size","backgroundColor","borderRadius","checked","true","...size","val","getSwitchHeight","height","width","defaultVariants","process","env","TAMAGUI_HEADLESS","Math","round","getSwitchWidth","SwitchFrame","tag","tabIndex","borderWidth","borderColor","focusVisibleStyle","outlineColor","outlineStyle","outlineWidth","minHeight"],"sources":["../../src/Switch.tsx"],"sourcesContent":[null],"mappings":"AACA,SAASA,gBAAA,EAAkBC,MAAA,QAAc;AACzC,SAASC,OAAA,QAAe;AACxB,SAASC,cAAA,EAAgBC,MAAA,QAAc;AAEhC,IAAAC,WAAM,GAAAJ,MAAc,CAAAE,cAAO;IAChCG,IAAA,EAAM;IAENC,QAAA,EAAU;MACRC,QAAA,EAAU;QACRC,KAAA,EAAO;UACLC,IAAA,EAAM;UACNC,eAAA,EAAiB;UACjBC,YAAA,EAAc;QAChB;MACF;MAEAC,OAAA,EAAS;QACPC,IAAA,EAAM,CAAC;MACT;MAEAJ,IAAA,EAAM;QACJ,WAAW,SAAAK,CAASC,GAAA;UAClB,IAAAN,IAAM,GAAAO,eAAO,CAAAD,GAAgB;UAC7B,OAAO;YACLE,MAAA,EAAQR,IAAA;YACRS,KAAA,EAAOT;UACT;QACF;MACF;IACF;IAEAU,eAAA,EAAiB;MACfZ,QAAA,EAAUa,OAAA,CAAQC,GAAA,CAAIC,gBAAA,KAAqB;IAC7C;EACF,CAAC;EAEKN,eAAA,GAAkB,SAAAA,CACtBD,GAAA,EAAK;IAKL,OAAMQ,IAAA,CAAAC,KAAA,CAAAzB,gBAAA,CAAAE,OAAA,CAAAc,GAAA;EAAA;EACNU,cAAK,YAAAA,CAAAV,GAAA;IACL,OAAAC,eAAU,CAAAD,GAAA;EAAA;EAEVW,WAAU,GAAA1B,MAAA,CAAAG,MAAA;IAAAE,IACR,UAAU;IAAAsB,GAAA,EACR,QAAO;IAAAC,QACL;IAActB,QACd;MAAiBC,QACjB;QAAaC,KACb;UAEAG,YAAA;UAAmBD,eACjB,EAAc;UAAAmB,WACd;UAAcC,WACd,eAAc;UAChBC,iBAAA;YACFC,YAAA;YACFC,YAAA;YAEAC,YAAS;UACP;QACF;MAEA;MAAMtB,OACJ;QACEC,IAAA;MAEA;MAAOJ,IAAA,EACL;QAAA,SACA,WAAAK,CAAWC,GAAA;UAAA,IACXE,MAAA,GAAAD,eAAA,CAAAD,GAAA;YAAAG,KAAA,GAAAO,cAAA,CAAAV,GAAA;UACF;YACFE,MAAA;YACFkB,SAAA,EAAAlB,MAAA;YACFC;UAEA;QACE;MACF;IACD","ignoreList":[]}
@@ -7,120 +7,25 @@ import * as React from "react";
7
7
  import { Switch as NativeSwitch } from "react-native";
8
8
  import { SwitchStyledContext } from "./StyledContext";
9
9
  import { SwitchFrame as DefaultSwitchFrame, SwitchThumb } from "./Switch";
10
- function _array_like_to_array(arr, len) {
11
- (len == null || len > arr.length) && (len = arr.length);
12
- for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
13
- return arr2;
14
- }
15
- function _array_with_holes(arr) {
16
- if (Array.isArray(arr)) return arr;
17
- }
18
- function _define_property(obj, key, value) {
19
- return key in obj ? Object.defineProperty(obj, key, {
20
- value,
21
- enumerable: !0,
22
- configurable: !0,
23
- writable: !0
24
- }) : obj[key] = value, obj;
25
- }
26
- function _iterable_to_array_limit(arr, i) {
27
- var _i = arr == null ? null : typeof Symbol < "u" && arr[Symbol.iterator] || arr["@@iterator"];
28
- if (_i != null) {
29
- var _arr = [], _n = !0, _d = !1, _s, _e;
30
- try {
31
- for (_i = _i.call(arr); !(_n = (_s = _i.next()).done) && (_arr.push(_s.value), !(i && _arr.length === i)); _n = !0)
32
- ;
33
- } catch (err) {
34
- _d = !0, _e = err;
35
- } finally {
36
- try {
37
- !_n && _i.return != null && _i.return();
38
- } finally {
39
- if (_d) throw _e;
40
- }
41
- }
42
- return _arr;
43
- }
44
- }
45
- function _non_iterable_rest() {
46
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
47
- }
48
- function _object_spread(target) {
49
- for (var i = 1; i < arguments.length; i++) {
50
- var source = arguments[i] != null ? arguments[i] : {}, ownKeys2 = Object.keys(source);
51
- typeof Object.getOwnPropertySymbols == "function" && (ownKeys2 = ownKeys2.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
52
- return Object.getOwnPropertyDescriptor(source, sym).enumerable;
53
- }))), ownKeys2.forEach(function(key) {
54
- _define_property(target, key, source[key]);
55
- });
56
- }
57
- return target;
58
- }
59
- function ownKeys(object, enumerableOnly) {
60
- var keys = Object.keys(object);
61
- if (Object.getOwnPropertySymbols) {
62
- var symbols = Object.getOwnPropertySymbols(object);
63
- enumerableOnly && (symbols = symbols.filter(function(sym) {
64
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
65
- })), keys.push.apply(keys, symbols);
66
- }
67
- return keys;
68
- }
69
- function _object_spread_props(target, source) {
70
- return source = source ?? {}, Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function(key) {
71
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
72
- }), target;
73
- }
74
- function _object_without_properties(source, excluded) {
75
- if (source == null) return {};
76
- var target = _object_without_properties_loose(source, excluded), key, i;
77
- if (Object.getOwnPropertySymbols) {
78
- var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
79
- for (i = 0; i < sourceSymbolKeys.length; i++)
80
- key = sourceSymbolKeys[i], !(excluded.indexOf(key) >= 0) && Object.prototype.propertyIsEnumerable.call(source, key) && (target[key] = source[key]);
81
- }
82
- return target;
83
- }
84
- function _object_without_properties_loose(source, excluded) {
85
- if (source == null) return {};
86
- var target = {}, sourceKeys = Object.keys(source), key, i;
87
- for (i = 0; i < sourceKeys.length; i++)
88
- key = sourceKeys[i], !(excluded.indexOf(key) >= 0) && (target[key] = source[key]);
89
- return target;
90
- }
91
- function _sliced_to_array(arr, i) {
92
- return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
93
- }
94
- function _unsupported_iterable_to_array(o, minLen) {
95
- if (o) {
96
- if (typeof o == "string") return _array_like_to_array(o, minLen);
97
- var n = Object.prototype.toString.call(o).slice(8, -1);
98
- if (n === "Object" && o.constructor && (n = o.constructor.name), n === "Map" || n === "Set") return Array.from(n);
99
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
100
- }
101
- }
102
10
  var SwitchContext = /* @__PURE__ */ React.createContext({
103
11
  checked: !1,
104
12
  disabled: !1,
105
13
  frameWidth: 0
106
14
  });
107
15
  function createSwitch(createProps) {
108
- var disableActiveTheme = createProps.disableActiveTheme, _createProps_Frame = createProps.Frame, Frame = _createProps_Frame === void 0 ? DefaultSwitchFrame : _createProps_Frame, _createProps_Thumb = createProps.Thumb, Thumb = _createProps_Thumb === void 0 ? SwitchThumb : _createProps_Thumb;
16
+ var { disableActiveTheme, Frame = DefaultSwitchFrame, Thumb = SwitchThumb } = createProps;
109
17
  process.env.NODE_ENV === "development" && (Frame !== DefaultSwitchFrame && Frame.staticConfig.context && Frame.staticConfig.context !== SwitchStyledContext || Thumb !== SwitchThumb && Thumb.staticConfig.context && Thumb.staticConfig.context !== SwitchStyledContext) && console.warn("Warning: createSwitch() needs to control context to pass checked state from Frame to Thumb, any custom context passed will be overridden."), Frame.staticConfig.context = SwitchStyledContext, Thumb.staticConfig.context = SwitchStyledContext;
110
18
  var SwitchThumbComponent = Thumb.styleable(function(props, forwardedRef) {
111
- var sizeProp = props.size, unstyledProp = props.unstyled, nativeID = props.nativeID, thumbProps = _object_without_properties(props, [
112
- "size",
113
- "unstyled",
114
- "nativeID"
115
- ]), context = React.useContext(SwitchContext), checked = context.checked, disabled = context.disabled, frameWidth = context.frameWidth, styledContext = SwitchStyledContext.useStyledContext(), unstyledContext = styledContext.unstyled, sizeContext = styledContext.size, _ref, unstyled = process.env.TAMAGUI_HEADLESS === "1" ? !0 : (_ref = unstyledProp ?? unstyledContext) !== null && _ref !== void 0 ? _ref : !1, _ref1, size = (_ref1 = sizeProp ?? sizeContext) !== null && _ref1 !== void 0 ? _ref1 : "$true", initialChecked = React.useRef(checked).current, _React_useState = _sliced_to_array(React.useState(0), 2), thumbWidth = _React_useState[0], setThumbWidth = _React_useState[1], distance = frameWidth - thumbWidth, x = initialChecked ? checked ? 0 : -distance : checked ? distance : 0;
116
- return /* @__PURE__ */ _jsx(Thumb, _object_spread(_object_spread_props(_object_spread({
19
+ var { size: sizeProp, unstyled: unstyledProp, nativeID, ...thumbProps } = props, context = React.useContext(SwitchContext), { checked, disabled, frameWidth } = context, styledContext = SwitchStyledContext.useStyledContext(), { unstyled: unstyledContext, size: sizeContext } = styledContext, _ref, unstyled = process.env.TAMAGUI_HEADLESS === "1" ? !0 : (_ref = unstyledProp ?? unstyledContext) !== null && _ref !== void 0 ? _ref : !1, _ref1, size = (_ref1 = sizeProp ?? sizeContext) !== null && _ref1 !== void 0 ? _ref1 : "$true", initialChecked = React.useRef(checked).current, [thumbWidth, setThumbWidth] = React.useState(0), distance = frameWidth - thumbWidth, x = initialChecked ? checked ? 0 : -distance : checked ? distance : 0;
20
+ return /* @__PURE__ */ _jsx(Thumb, {
117
21
  ref: forwardedRef,
118
- unstyled
119
- }, unstyled === !1 && _object_spread({
120
- size
121
- }, !disableActiveTheme && {
122
- theme: checked ? "active" : null
123
- })), {
22
+ unstyled,
23
+ ...unstyled === !1 && {
24
+ size,
25
+ ...!disableActiveTheme && {
26
+ theme: checked ? "active" : null
27
+ }
28
+ },
124
29
  alignSelf: initialChecked ? "flex-end" : "flex-start",
125
30
  x,
126
31
  // TODO: remove ViewProps cast
@@ -129,26 +34,21 @@ function createSwitch(createProps) {
129
34
  }),
130
35
  // expected variants
131
36
  checked,
132
- disabled
133
- }), thumbProps));
37
+ disabled,
38
+ ...thumbProps
39
+ });
134
40
  }), SwitchComponent = Frame.styleable(function(_props, forwardedRef) {
135
- var native = _props.native, nativeProps = _props.nativeProps, checkedProp = _props.checked, defaultChecked = _props.defaultChecked, onCheckedChange = _props.onCheckedChange, props = _object_without_properties(_props, [
136
- "native",
137
- "nativeProps",
138
- "checked",
139
- "defaultChecked",
140
- "onCheckedChange"
141
- ]), _useControllableState = _sliced_to_array(useControllableState({
41
+ var { native, nativeProps, checked: checkedProp, defaultChecked, onCheckedChange, ...props } = _props, [checked, setChecked] = useControllableState({
142
42
  prop: checkedProp,
143
43
  defaultProp: defaultChecked || !1,
144
44
  onChange: onCheckedChange,
145
45
  transition: !0
146
- }), 2), checked = _useControllableState[0], setChecked = _useControllableState[1], styledContext = React.useContext(SwitchStyledContext.context), _React_useState = _sliced_to_array(React.useState(0), 2), frameWidth = _React_useState[0], setFrameWidth = _React_useState[1], propsActive = useProps(props, {
46
+ }), styledContext = React.useContext(SwitchStyledContext.context), [frameWidth, setFrameWidth] = React.useState(0), propsActive = useProps(props, {
147
47
  noNormalize: !0,
148
48
  noExpand: !0,
149
49
  resolveValues: "none",
150
50
  forComponent: Frame
151
- }), _styledContext_size, _ref, _styledContext_unstyled, _ref1, _useSwitch = useSwitch(
51
+ }), _styledContext_size, _ref, _styledContext_unstyled, _ref1, { switchProps, bubbleInput, switchRef } = useSwitch(
152
52
  // @ts-ignore
153
53
  Object.assign({
154
54
  size: (_ref = (_styledContext_size = styledContext.size) !== null && _styledContext_size !== void 0 ? _styledContext_size : props.size) !== null && _ref !== void 0 ? _ref : "$true",
@@ -159,12 +59,12 @@ function createSwitch(createProps) {
159
59
  setChecked
160
60
  ],
161
61
  forwardedRef
162
- ), switchProps = _useSwitch.switchProps, bubbleInput = _useSwitch.bubbleInput, switchRef = _useSwitch.switchRef;
62
+ );
163
63
  React.useEffect(function() {
164
64
  if (props.id && !props.disabled)
165
65
  return registerFocusable(props.id, {
166
66
  focusAndSelect: function() {
167
- setChecked == null || setChecked(function(value) {
67
+ setChecked?.(function(value) {
168
68
  return !value;
169
69
  });
170
70
  },
@@ -176,25 +76,28 @@ function createSwitch(createProps) {
176
76
  props.disabled
177
77
  ]);
178
78
  var renderNative = shouldRenderNativePlatform(native);
179
- return renderNative === "android" || renderNative === "ios" ? /* @__PURE__ */ _jsx(NativeSwitch, _object_spread({
79
+ return renderNative === "android" || renderNative === "ios" ? /* @__PURE__ */ _jsx(NativeSwitch, {
180
80
  value: checked,
181
- onValueChange: setChecked
182
- }, nativeProps)) : /* @__PURE__ */ _jsxs(SwitchContext.Provider, {
81
+ onValueChange: setChecked,
82
+ ...nativeProps
83
+ }) : /* @__PURE__ */ _jsxs(SwitchContext.Provider, {
183
84
  value: {
184
85
  checked,
185
86
  disabled: switchProps.disabled,
186
87
  frameWidth
187
88
  },
188
89
  children: [
189
- /* @__PURE__ */ _jsx(Frame, _object_spread_props(_object_spread({
90
+ /* @__PURE__ */ _jsx(Frame, {
190
91
  ref: switchRef,
191
- tag: "button"
192
- }, isWeb && {
193
- type: "button"
194
- }, switchProps, !disableActiveTheme && {
195
- theme: checked ? "active" : null,
196
- themeShallow: !0
197
- }), {
92
+ tag: "button",
93
+ ...isWeb && {
94
+ type: "button"
95
+ },
96
+ ...switchProps,
97
+ ...!disableActiveTheme && {
98
+ theme: checked ? "active" : null,
99
+ themeShallow: !0
100
+ },
198
101
  // expected variants
199
102
  checked,
200
103
  disabled: switchProps.disabled,
@@ -206,7 +109,7 @@ function createSwitch(createProps) {
206
109
  },
207
110
  children: switchProps.children
208
111
  })
209
- })),
112
+ }),
210
113
  bubbleInput
211
114
  ]
212
115
  });
@@ -1,6 +1,6 @@
1
1
  {
2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MAAagF,OAAOzE;MAAS4E,eAAelB;OAAgBR,WAAAA,CAAAA,IAK/D,sBAACpD,cAAc+E,UAAQ;MACrBJ,OAAO;QAAEzE;QAASC,UAAUkE,YAAYlE;QAAUC;MAAW;;QAE7D,qBAACI,OAAAA,qBAAAA,eAAAA;UACCiC,KAAK8B;UACLS,KAAI;WACC9F,SAAS;UAAE+F,MAAM;QAAS,GAC1BZ,aACA,CAAC9D,sBAAsB;UAC1BmC,OAAOxC,UAAU,WAAW;UAC5BgF,cAAc;QAChB,CAAA,GAAA;;UAEAhF;UACAC,UAAUkE,YAAYlE;oBAEtB,qBAACnB,OAAAA;YACC2D,WAAU;YACVwC,MAAM;YACNvC,UAAU,SAACC,GAAAA;AACTgB,4BAAchB,EAAEC,YAAYC,OAAOC,KAAK;YAC1C;sBAECqB,YAAYe;;;QAIhBd;;;EAGP,GACA;IACEe,cAAc;EAChB,CAAA;AAGF,SAAOhG,qBAAqB4D,iBAAiB;IAC3CxC,OAAOQ;EACT,CAAA;AACF;",
5
- "names": ["Stack", "composeEventHandlers", "isWeb", "shouldRenderNativePlatform", "useProps", "withStaticProperties", "registerFocusable", "useSwitch", "useControllableState", "React", "Switch", "NativeSwitch", "SwitchStyledContext", "SwitchFrame", "DefaultSwitchFrame", "SwitchThumb", "SwitchContext", "createContext", "checked", "disabled", "frameWidth", "createSwitch", "createProps", "disableActiveTheme", "Frame", "Thumb", "process", "env", "NODE_ENV", "staticConfig", "context", "console", "warn", "SwitchThumbComponent", "styleable", "props", "forwardedRef", "sizeProp", "size", "unstyledProp", "unstyled", "nativeID", "thumbProps", "useContext", "styledContext", "useStyledContext", "unstyledContext", "sizeContext", "TAMAGUI_HEADLESS", "initialChecked", "useRef", "current", "useState", "thumbWidth", "setThumbWidth", "distance", "x", "ref", "theme", "alignSelf", "onLayout", "e", "nativeEvent", "layout", "width", "SwitchComponent", "_props", "native", "nativeProps", "checkedProp", "defaultChecked", "onCheckedChange", "prop", "defaultProp", "onChange", "transition", "setChecked", "setFrameWidth", "propsActive", "noNormalize", "noExpand", "resolveValues", "forComponent", "Object", "assign", "switchProps", "bubbleInput", "switchRef", "useEffect", "id", "focusAndSelect", "value", "focus", "renderNative", "onValueChange", "Provider", "tag", "type", "themeShallow", "flex", "children", "disableTheme"]
4
+ "mappings": ";AACA,SACEA,OACAC,sBACAC,OACAC,4BACAC,UACAC,4BACK;AAKP,SAASC,yBAAyB;AAClC,SAASC,iBAAiB;AAC1B,SAASC,4BAA4B;AACrC,YAAYC,WAAW;AAEvB,SAASC,UAAUC,oBAAoB;AAEvC,SAASC,2BAA2B;AACpC,SAASC,eAAeC,oBAAoBC,mBAAmB;AAoBxD,IAAMC,gBAAgBP,sBAAMQ,cAIhC;EACDC,SAAS;EACTC,UAAU;EACVC,YAAY;AACd,CAAA;AAKO,SAASC,aAGdC,aAAmE;AACnE,MAAM,EACJC,oBACAC,QAAQV,oBACRW,QAAQV,YAAW,IACjBO;AAMJ,EAAII,QAAQC,IAAIC,aAAa,kBAExBJ,UAAUV,sBACTU,MAAMK,aAAaC,WACnBN,MAAMK,aAAaC,YAAYlB,uBAChCa,UAAUV,eACTU,MAAMI,aAAaC,WACnBL,MAAMI,aAAaC,YAAYlB,wBAEjCmB,QAAQC,KACN,2IAA2I,GAKjJR,MAAMK,aAAaC,UAAUlB,qBAC7Ba,MAAMI,aAAaC,UAAUlB;AAE7B,MAAMqB,uBAAuBR,MAAMS,UACjC,SAAqBC,OAAOC,cAAY;AACtC,QAAM,EAAEC,MAAMC,UAAUC,UAAUC,cAAcC,UAAU,GAAGC,WAAAA,IAAeP,OACtEL,UAAUrB,MAAMkC,WAAW3B,aAAAA,GAC3B,EAAEE,SAASC,UAAUC,WAAU,IAAKU,SAEpCc,gBAAgBhC,oBAAoBiC,iBAAgB,GACpD,EAAEN,UAAUO,iBAAiBT,MAAMU,YAAW,IAAKH,eAInDJ,MAHAD,WACJb,QAAQC,IAAIqB,qBAAqB,MAC7B,MACAR,OAAAA,gBAAgBM,qBA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C,OAAOQ;EACT,CAAA;AACF;",
5
+ "names": ["Stack", "composeEventHandlers", "isWeb", "shouldRenderNativePlatform", "useProps", "withStaticProperties", "registerFocusable", "useSwitch", "useControllableState", "React", "Switch", "NativeSwitch", "SwitchStyledContext", "SwitchFrame", "DefaultSwitchFrame", "SwitchThumb", "SwitchContext", "createContext", "checked", "disabled", "frameWidth", "createSwitch", "createProps", "disableActiveTheme", "Frame", "Thumb", "process", "env", "NODE_ENV", "staticConfig", "context", "console", "warn", "SwitchThumbComponent", "styleable", "props", "forwardedRef", "size", "sizeProp", "unstyled", "unstyledProp", "nativeID", "thumbProps", "useContext", "styledContext", "useStyledContext", "unstyledContext", "sizeContext", "TAMAGUI_HEADLESS", "initialChecked", "useRef", "current", "thumbWidth", "setThumbWidth", "useState", "distance", "x", "ref", "theme", "alignSelf", "onLayout", "e", "nativeEvent", "layout", "width", "SwitchComponent", "_props", "native", "nativeProps", "checkedProp", "defaultChecked", "onCheckedChange", "setChecked", "prop", "defaultProp", "onChange", "transition", "setFrameWidth", "propsActive", "noNormalize", "noExpand", "resolveValues", "forComponent", "switchProps", "bubbleInput", "switchRef", "Object", "assign", "useEffect", "id", "focusAndSelect", "value", "focus", "renderNative", "onValueChange", "Provider", "tag", "type", "themeShallow", "flex", "children", "disableTheme"]
6
6
  }
@@ -0,0 +1,159 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Stack, composeEventHandlers, isWeb, shouldRenderNativePlatform, useProps, withStaticProperties } from "@tamagui/core";
3
+ import { registerFocusable } from "@tamagui/focusable";
4
+ import { useSwitch } from "@tamagui/switch-headless";
5
+ import { useControllableState } from "@tamagui/use-controllable-state";
6
+ import * as React from "react";
7
+ import { Switch as NativeSwitch } from "react-native";
8
+ import { SwitchStyledContext } from "./StyledContext.mjs";
9
+ import { SwitchFrame as DefaultSwitchFrame, SwitchThumb } from "./Switch.mjs";
10
+ var SwitchContext = /* @__PURE__ */React.createContext({
11
+ checked: !1,
12
+ disabled: !1,
13
+ frameWidth: 0
14
+ });
15
+ function createSwitch(createProps) {
16
+ var {
17
+ disableActiveTheme,
18
+ Frame = DefaultSwitchFrame,
19
+ Thumb = SwitchThumb
20
+ } = createProps;
21
+ process.env.NODE_ENV === "development" && (Frame !== DefaultSwitchFrame && Frame.staticConfig.context && Frame.staticConfig.context !== SwitchStyledContext || Thumb !== SwitchThumb && Thumb.staticConfig.context && Thumb.staticConfig.context !== SwitchStyledContext) && console.warn("Warning: createSwitch() needs to control context to pass checked state from Frame to Thumb, any custom context passed will be overridden."), Frame.staticConfig.context = SwitchStyledContext, Thumb.staticConfig.context = SwitchStyledContext;
22
+ var SwitchThumbComponent = Thumb.styleable(function (props, forwardedRef) {
23
+ var {
24
+ size: sizeProp,
25
+ unstyled: unstyledProp,
26
+ nativeID,
27
+ ...thumbProps
28
+ } = props,
29
+ context = React.useContext(SwitchContext),
30
+ {
31
+ checked,
32
+ disabled,
33
+ frameWidth
34
+ } = context,
35
+ styledContext = SwitchStyledContext.useStyledContext(),
36
+ {
37
+ unstyled: unstyledContext,
38
+ size: sizeContext
39
+ } = styledContext,
40
+ _ref,
41
+ unstyled = process.env.TAMAGUI_HEADLESS === "1" ? !0 : (_ref = unstyledProp ?? unstyledContext) !== null && _ref !== void 0 ? _ref : !1,
42
+ _ref1,
43
+ size = (_ref1 = sizeProp ?? sizeContext) !== null && _ref1 !== void 0 ? _ref1 : "$true",
44
+ initialChecked = React.useRef(checked).current,
45
+ [thumbWidth, setThumbWidth] = React.useState(0),
46
+ distance = frameWidth - thumbWidth,
47
+ x = initialChecked ? checked ? 0 : -distance : checked ? distance : 0;
48
+ return /* @__PURE__ */_jsx(Thumb, {
49
+ ref: forwardedRef,
50
+ unstyled,
51
+ ...(unstyled === !1 && {
52
+ size,
53
+ ...(!disableActiveTheme && {
54
+ theme: checked ? "active" : null
55
+ })
56
+ }),
57
+ alignSelf: initialChecked ? "flex-end" : "flex-start",
58
+ x,
59
+ // TODO: remove ViewProps cast
60
+ onLayout: composeEventHandlers(props.onLayout, function (e) {
61
+ return setThumbWidth(e.nativeEvent.layout.width);
62
+ }),
63
+ // expected variants
64
+ checked,
65
+ disabled,
66
+ ...thumbProps
67
+ });
68
+ }),
69
+ SwitchComponent = Frame.styleable(function (_props, forwardedRef) {
70
+ var {
71
+ native,
72
+ nativeProps,
73
+ checked: checkedProp,
74
+ defaultChecked,
75
+ onCheckedChange,
76
+ ...props
77
+ } = _props,
78
+ [checked, setChecked] = useControllableState({
79
+ prop: checkedProp,
80
+ defaultProp: defaultChecked || !1,
81
+ onChange: onCheckedChange,
82
+ transition: !0
83
+ }),
84
+ styledContext = React.useContext(SwitchStyledContext.context),
85
+ [frameWidth, setFrameWidth] = React.useState(0),
86
+ propsActive = useProps(props, {
87
+ noNormalize: !0,
88
+ noExpand: !0,
89
+ resolveValues: "none",
90
+ forComponent: Frame
91
+ }),
92
+ _styledContext_size,
93
+ _ref,
94
+ _styledContext_unstyled,
95
+ _ref1,
96
+ {
97
+ switchProps,
98
+ bubbleInput,
99
+ switchRef
100
+ } = useSwitch(
101
+ // @ts-ignore
102
+ Object.assign({
103
+ size: (_ref = (_styledContext_size = styledContext.size) !== null && _styledContext_size !== void 0 ? _styledContext_size : props.size) !== null && _ref !== void 0 ? _ref : "$true",
104
+ unstyled: (_ref1 = (_styledContext_unstyled = styledContext.unstyled) !== null && _styledContext_unstyled !== void 0 ? _styledContext_unstyled : props.unstyled) !== null && _ref1 !== void 0 ? _ref1 : !1
105
+ }, propsActive), [checked, setChecked], forwardedRef);
106
+ React.useEffect(function () {
107
+ if (props.id && !props.disabled) return registerFocusable(props.id, {
108
+ focusAndSelect: function () {
109
+ setChecked?.(function (value) {
110
+ return !value;
111
+ });
112
+ },
113
+ focus: function () {}
114
+ });
115
+ }, [props.id, props.disabled]);
116
+ var renderNative = shouldRenderNativePlatform(native);
117
+ return renderNative === "android" || renderNative === "ios" ? /* @__PURE__ */_jsx(NativeSwitch, {
118
+ value: checked,
119
+ onValueChange: setChecked,
120
+ ...nativeProps
121
+ }) : /* @__PURE__ */_jsxs(SwitchContext.Provider, {
122
+ value: {
123
+ checked,
124
+ disabled: switchProps.disabled,
125
+ frameWidth
126
+ },
127
+ children: [/* @__PURE__ */_jsx(Frame, {
128
+ ref: switchRef,
129
+ tag: "button",
130
+ ...(isWeb && {
131
+ type: "button"
132
+ }),
133
+ ...switchProps,
134
+ ...(!disableActiveTheme && {
135
+ theme: checked ? "active" : null,
136
+ themeShallow: !0
137
+ }),
138
+ // expected variants
139
+ checked,
140
+ disabled: switchProps.disabled,
141
+ children: /* @__PURE__ */_jsx(Stack, {
142
+ alignSelf: "stretch",
143
+ flex: 1,
144
+ onLayout: function (e) {
145
+ setFrameWidth(e.nativeEvent.layout.width);
146
+ },
147
+ children: switchProps.children
148
+ })
149
+ }), bubbleInput]
150
+ });
151
+ }, {
152
+ disableTheme: !0
153
+ });
154
+ return withStaticProperties(SwitchComponent, {
155
+ Thumb: SwitchThumbComponent
156
+ });
157
+ }
158
+ export { SwitchContext, createSwitch };
159
+ //# sourceMappingURL=createSwitch.native.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["jsx","_jsx","jsxs","_jsxs","Stack","composeEventHandlers","isWeb","shouldRenderNativePlatform","useProps","withStaticProperties","registerFocusable","useSwitch","useControllableState","React","Switch","NativeSwitch","SwitchStyledContext","SwitchFrame","DefaultSwitchFrame","SwitchThumb","SwitchContext","createContext","checked","disabled","frameWidth","createSwitch","createProps","disableActiveTheme","Frame","Thumb","process","env","NODE_ENV","staticConfig","context","console","warn","SwitchThumbComponent","styleable","props","forwardedRef","size","sizeProp","unstyled","unstyledProp","nativeID","thumbProps","useContext","styledContext","useStyledContext","unstyledContext","sizeContext","_ref","TAMAGUI_HEADLESS","_ref1","initialChecked","useRef","current","thumbWidth","setThumbWidth","useState","distance","x","ref","theme","alignSelf","onLayout","e","nativeEvent","layout","width","SwitchComponent","_props","native","nativeProps","checkedProp","defaultChecked","onCheckedChange","setChecked","prop","defaultProp","onChange","transition","setFrameWidth","propsActive","noNormalize","noExpand","resolveValues","forComponent","_styledContext_size","_styledContext_unstyled","switchProps","bubbleInput","switchRef","Object","assign","useEffect","id","focusAndSelect","value","focus","renderNative","onValueChange","Provider","children","tag","type","themeShallow","flex","disableTheme"],"sources":["../../src/createSwitch.tsx"],"sourcesContent":[null],"mappings":"AACA,SAAAA,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAAA,SACEC,KAAA,EAAAC,oBAAA,EAAAC,KAAA,EAAAC,0BAAA,EAAAC,QAAA,EAAAC,oBAAA;AAAA,SACAC,iBAAA;AAAA,SACAC,SAAA;AAAA,SACAC,oBAAA;AAAA,OACA,KAAAC,KAAA;AAAA,SACAC,MAAA,IAAAC,YAAA;AAAA,SACKC,mBAAA;AAKP,SAAkCC,WAAA,IAAAC,kBAAA,EAAAC,WAAA;AAClC,IAAAC,aAAS,kBAAiBP,KAAA,CAAAQ,aAAA;EAC1BC,OAAS;EACTC,QAAA,EAAY;EAEZC,UAAS;AAET;AACA,SAASC,aAAAC,WAAe;EAqFhB;IAAAC,kBAAA;IAAAC,KAAA,GAAAV,kBAAA;IAAAW,KAAA,GAAAV;EAAA,IAAAO,WAAA;EAjEDI,OAAM,CAAAC,GAAA,CAAAC,QAAgB,kBAAM,KAIhCJ,KAAA,KAAAV,kBAAA,IAAAU,KAAA,CAAAK,YAAA,CAAAC,OAAA,IAAAN,KAAA,CAAAK,YAAA,CAAAC,OAAA,KAAAlB,mBAAA,IAAAa,KAAA,KAAAV,WAAA,IAAAU,KAAA,CAAAI,YAAA,CAAAC,OAAA,IAAAL,KAAA,CAAAI,YAAA,CAAAC,OAAA,KAAAlB,mBAAA,KAAAmB,OAAA,CAAAC,IAAA,+IAAAR,KAAA,CAAAK,YAAA,CAAAC,OAAA,GAAAlB,mBAAA,EAAAa,KAAA,CAAAI,YAAA,CAAAC,OAAA,GAAAlB,mBAAA;EACD,IAAAqB,oBAAS,GAA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1C,KAAA,EAAAQ;EAAA;AAAA;AACH,SAEJjB,aACA,EAAAK,YACE","ignoreList":[]}
@@ -0,0 +1,11 @@
1
+ import { createSwitch } from "./createSwitch.mjs";
2
+ import { SwitchFrame, SwitchThumb } from "./Switch.mjs";
3
+ export * from "./createSwitch.mjs";
4
+ export * from "./StyledContext.mjs";
5
+ export * from "./Switch.mjs";
6
+ var Switch = createSwitch({
7
+ Frame: SwitchFrame,
8
+ Thumb: SwitchThumb
9
+ });
10
+ export { Switch };
11
+ //# sourceMappingURL=index.native.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createSwitch","SwitchFrame","SwitchThumb","Switch","Frame","Thumb"],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,YAAA,QAAoB;AAC7B,SAASC,WAAA,EAAaC,WAAA,QAAmB;AAEzC,cAAc;AACd,cAAc;AACd,cAAc;AAEP,IAAAC,MAAM,GAAAH,YAAS;EACpBI,KAAA,EAAOH,WAAA;EACPI,KAAA,EAAOH;AACT,CAAC","ignoreList":[]}
@@ -7,120 +7,25 @@ import * as React from "react";
7
7
  import { Switch as NativeSwitch } from "react-native";
8
8
  import { SwitchStyledContext } from "./StyledContext";
9
9
  import { SwitchFrame as DefaultSwitchFrame, SwitchThumb } from "./Switch";
10
- function _array_like_to_array(arr, len) {
11
- (len == null || len > arr.length) && (len = arr.length);
12
- for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
13
- return arr2;
14
- }
15
- function _array_with_holes(arr) {
16
- if (Array.isArray(arr)) return arr;
17
- }
18
- function _define_property(obj, key, value) {
19
- return key in obj ? Object.defineProperty(obj, key, {
20
- value,
21
- enumerable: !0,
22
- configurable: !0,
23
- writable: !0
24
- }) : obj[key] = value, obj;
25
- }
26
- function _iterable_to_array_limit(arr, i) {
27
- var _i = arr == null ? null : typeof Symbol < "u" && arr[Symbol.iterator] || arr["@@iterator"];
28
- if (_i != null) {
29
- var _arr = [], _n = !0, _d = !1, _s, _e;
30
- try {
31
- for (_i = _i.call(arr); !(_n = (_s = _i.next()).done) && (_arr.push(_s.value), !(i && _arr.length === i)); _n = !0)
32
- ;
33
- } catch (err) {
34
- _d = !0, _e = err;
35
- } finally {
36
- try {
37
- !_n && _i.return != null && _i.return();
38
- } finally {
39
- if (_d) throw _e;
40
- }
41
- }
42
- return _arr;
43
- }
44
- }
45
- function _non_iterable_rest() {
46
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
47
- }
48
- function _object_spread(target) {
49
- for (var i = 1; i < arguments.length; i++) {
50
- var source = arguments[i] != null ? arguments[i] : {}, ownKeys2 = Object.keys(source);
51
- typeof Object.getOwnPropertySymbols == "function" && (ownKeys2 = ownKeys2.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
52
- return Object.getOwnPropertyDescriptor(source, sym).enumerable;
53
- }))), ownKeys2.forEach(function(key) {
54
- _define_property(target, key, source[key]);
55
- });
56
- }
57
- return target;
58
- }
59
- function ownKeys(object, enumerableOnly) {
60
- var keys = Object.keys(object);
61
- if (Object.getOwnPropertySymbols) {
62
- var symbols = Object.getOwnPropertySymbols(object);
63
- enumerableOnly && (symbols = symbols.filter(function(sym) {
64
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
65
- })), keys.push.apply(keys, symbols);
66
- }
67
- return keys;
68
- }
69
- function _object_spread_props(target, source) {
70
- return source = source ?? {}, Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function(key) {
71
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
72
- }), target;
73
- }
74
- function _object_without_properties(source, excluded) {
75
- if (source == null) return {};
76
- var target = _object_without_properties_loose(source, excluded), key, i;
77
- if (Object.getOwnPropertySymbols) {
78
- var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
79
- for (i = 0; i < sourceSymbolKeys.length; i++)
80
- key = sourceSymbolKeys[i], !(excluded.indexOf(key) >= 0) && Object.prototype.propertyIsEnumerable.call(source, key) && (target[key] = source[key]);
81
- }
82
- return target;
83
- }
84
- function _object_without_properties_loose(source, excluded) {
85
- if (source == null) return {};
86
- var target = {}, sourceKeys = Object.keys(source), key, i;
87
- for (i = 0; i < sourceKeys.length; i++)
88
- key = sourceKeys[i], !(excluded.indexOf(key) >= 0) && (target[key] = source[key]);
89
- return target;
90
- }
91
- function _sliced_to_array(arr, i) {
92
- return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
93
- }
94
- function _unsupported_iterable_to_array(o, minLen) {
95
- if (o) {
96
- if (typeof o == "string") return _array_like_to_array(o, minLen);
97
- var n = Object.prototype.toString.call(o).slice(8, -1);
98
- if (n === "Object" && o.constructor && (n = o.constructor.name), n === "Map" || n === "Set") return Array.from(n);
99
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
100
- }
101
- }
102
10
  var SwitchContext = /* @__PURE__ */ React.createContext({
103
11
  checked: !1,
104
12
  disabled: !1,
105
13
  frameWidth: 0
106
14
  });
107
15
  function createSwitch(createProps) {
108
- var disableActiveTheme = createProps.disableActiveTheme, _createProps_Frame = createProps.Frame, Frame = _createProps_Frame === void 0 ? DefaultSwitchFrame : _createProps_Frame, _createProps_Thumb = createProps.Thumb, Thumb = _createProps_Thumb === void 0 ? SwitchThumb : _createProps_Thumb;
16
+ var { disableActiveTheme, Frame = DefaultSwitchFrame, Thumb = SwitchThumb } = createProps;
109
17
  process.env.NODE_ENV === "development" && (Frame !== DefaultSwitchFrame && Frame.staticConfig.context && Frame.staticConfig.context !== SwitchStyledContext || Thumb !== SwitchThumb && Thumb.staticConfig.context && Thumb.staticConfig.context !== SwitchStyledContext) && console.warn("Warning: createSwitch() needs to control context to pass checked state from Frame to Thumb, any custom context passed will be overridden."), Frame.staticConfig.context = SwitchStyledContext, Thumb.staticConfig.context = SwitchStyledContext;
110
18
  var SwitchThumbComponent = Thumb.styleable(function(props, forwardedRef) {
111
- var sizeProp = props.size, unstyledProp = props.unstyled, nativeID = props.nativeID, thumbProps = _object_without_properties(props, [
112
- "size",
113
- "unstyled",
114
- "nativeID"
115
- ]), context = React.useContext(SwitchContext), checked = context.checked, disabled = context.disabled, frameWidth = context.frameWidth, styledContext = SwitchStyledContext.useStyledContext(), unstyledContext = styledContext.unstyled, sizeContext = styledContext.size, _ref, unstyled = process.env.TAMAGUI_HEADLESS === "1" ? !0 : (_ref = unstyledProp ?? unstyledContext) !== null && _ref !== void 0 ? _ref : !1, _ref1, size = (_ref1 = sizeProp ?? sizeContext) !== null && _ref1 !== void 0 ? _ref1 : "$true", initialChecked = React.useRef(checked).current, _React_useState = _sliced_to_array(React.useState(0), 2), thumbWidth = _React_useState[0], setThumbWidth = _React_useState[1], distance = frameWidth - thumbWidth, x = initialChecked ? checked ? 0 : -distance : checked ? distance : 0;
116
- return /* @__PURE__ */ _jsx(Thumb, _object_spread(_object_spread_props(_object_spread({
19
+ var { size: sizeProp, unstyled: unstyledProp, nativeID, ...thumbProps } = props, context = React.useContext(SwitchContext), { checked, disabled, frameWidth } = context, styledContext = SwitchStyledContext.useStyledContext(), { unstyled: unstyledContext, size: sizeContext } = styledContext, _ref, unstyled = process.env.TAMAGUI_HEADLESS === "1" ? !0 : (_ref = unstyledProp ?? unstyledContext) !== null && _ref !== void 0 ? _ref : !1, _ref1, size = (_ref1 = sizeProp ?? sizeContext) !== null && _ref1 !== void 0 ? _ref1 : "$true", initialChecked = React.useRef(checked).current, [thumbWidth, setThumbWidth] = React.useState(0), distance = frameWidth - thumbWidth, x = initialChecked ? checked ? 0 : -distance : checked ? distance : 0;
20
+ return /* @__PURE__ */ _jsx(Thumb, {
117
21
  ref: forwardedRef,
118
- unstyled
119
- }, unstyled === !1 && _object_spread({
120
- size
121
- }, !disableActiveTheme && {
122
- theme: checked ? "active" : null
123
- })), {
22
+ unstyled,
23
+ ...unstyled === !1 && {
24
+ size,
25
+ ...!disableActiveTheme && {
26
+ theme: checked ? "active" : null
27
+ }
28
+ },
124
29
  alignSelf: initialChecked ? "flex-end" : "flex-start",
125
30
  x,
126
31
  // TODO: remove ViewProps cast
@@ -129,26 +34,21 @@ function createSwitch(createProps) {
129
34
  }),
130
35
  // expected variants
131
36
  checked,
132
- disabled
133
- }), thumbProps));
37
+ disabled,
38
+ ...thumbProps
39
+ });
134
40
  }), SwitchComponent = Frame.styleable(function(_props, forwardedRef) {
135
- var native = _props.native, nativeProps = _props.nativeProps, checkedProp = _props.checked, defaultChecked = _props.defaultChecked, onCheckedChange = _props.onCheckedChange, props = _object_without_properties(_props, [
136
- "native",
137
- "nativeProps",
138
- "checked",
139
- "defaultChecked",
140
- "onCheckedChange"
141
- ]), _useControllableState = _sliced_to_array(useControllableState({
41
+ var { native, nativeProps, checked: checkedProp, defaultChecked, onCheckedChange, ...props } = _props, [checked, setChecked] = useControllableState({
142
42
  prop: checkedProp,
143
43
  defaultProp: defaultChecked || !1,
144
44
  onChange: onCheckedChange,
145
45
  transition: !0
146
- }), 2), checked = _useControllableState[0], setChecked = _useControllableState[1], styledContext = React.useContext(SwitchStyledContext.context), _React_useState = _sliced_to_array(React.useState(0), 2), frameWidth = _React_useState[0], setFrameWidth = _React_useState[1], propsActive = useProps(props, {
46
+ }), styledContext = React.useContext(SwitchStyledContext.context), [frameWidth, setFrameWidth] = React.useState(0), propsActive = useProps(props, {
147
47
  noNormalize: !0,
148
48
  noExpand: !0,
149
49
  resolveValues: "none",
150
50
  forComponent: Frame
151
- }), _styledContext_size, _ref, _styledContext_unstyled, _ref1, _useSwitch = useSwitch(
51
+ }), _styledContext_size, _ref, _styledContext_unstyled, _ref1, { switchProps, bubbleInput, switchRef } = useSwitch(
152
52
  // @ts-ignore
153
53
  Object.assign({
154
54
  size: (_ref = (_styledContext_size = styledContext.size) !== null && _styledContext_size !== void 0 ? _styledContext_size : props.size) !== null && _ref !== void 0 ? _ref : "$true",
@@ -159,7 +59,7 @@ function createSwitch(createProps) {
159
59
  setChecked
160
60
  ],
161
61
  forwardedRef
162
- ), switchProps = _useSwitch.switchProps, bubbleInput = _useSwitch.bubbleInput, switchRef = _useSwitch.switchRef;
62
+ );
163
63
  React.useEffect(function() {
164
64
  if (props.id && !props.disabled)
165
65
  return registerFocusable(props.id, {
@@ -176,25 +76,28 @@ function createSwitch(createProps) {
176
76
  props.disabled
177
77
  ]);
178
78
  var renderNative = shouldRenderNativePlatform(native);
179
- return renderNative === "android" || renderNative === "ios" ? /* @__PURE__ */ _jsx(NativeSwitch, _object_spread({
79
+ return renderNative === "android" || renderNative === "ios" ? /* @__PURE__ */ _jsx(NativeSwitch, {
180
80
  value: checked,
181
- onValueChange: setChecked
182
- }, nativeProps)) : /* @__PURE__ */ _jsxs(SwitchContext.Provider, {
81
+ onValueChange: setChecked,
82
+ ...nativeProps
83
+ }) : /* @__PURE__ */ _jsxs(SwitchContext.Provider, {
183
84
  value: {
184
85
  checked,
185
86
  disabled: switchProps.disabled,
186
87
  frameWidth
187
88
  },
188
89
  children: [
189
- /* @__PURE__ */ _jsx(Frame, _object_spread_props(_object_spread({
90
+ /* @__PURE__ */ _jsx(Frame, {
190
91
  ref: switchRef,
191
- tag: "button"
192
- }, isWeb && {
193
- type: "button"
194
- }, switchProps, !disableActiveTheme && {
195
- theme: checked ? "active" : null,
196
- themeShallow: !0
197
- }), {
92
+ tag: "button",
93
+ ...isWeb && {
94
+ type: "button"
95
+ },
96
+ ...switchProps,
97
+ ...!disableActiveTheme && {
98
+ theme: checked ? "active" : null,
99
+ themeShallow: !0
100
+ },
198
101
  // expected variants
199
102
  checked,
200
103
  disabled: switchProps.disabled,
@@ -206,7 +109,7 @@ function createSwitch(createProps) {
206
109
  },
207
110
  children: switchProps.children
208
111
  })
209
- })),
112
+ }),
210
113
  bubbleInput
211
114
  ]
212
115
  });
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "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,OAAOzE;MAAS4E,eAAelB;OAAgBR,WAAAA,CAAAA,IAK/D,sBAACpD,cAAc+E,UAAQ;MACrBJ,OAAO;QAAEzE;QAASC,UAAUkE,YAAYlE;QAAUC;MAAW;;QAE7D,qBAACI,OAAAA,qBAAAA,eAAAA;UACCiC,KAAK8B;UACLS,KAAI;WACC9F,SAAS;UAAE+F,MAAM;QAAS,GAC1BZ,aACA,CAAC9D,sBAAsB;UAC1BmC,OAAOxC,UAAU,WAAW;UAC5BgF,cAAc;QAChB,CAAA,GAAA;;UAEAhF;UACAC,UAAUkE,YAAYlE;oBAEtB,qBAACnB,OAAAA;YACC2D,WAAU;YACVwC,MAAM;YACNvC,UAAU,SAACC,GAAAA;AACTgB,4BAAchB,EAAEC,YAAYC,OAAOC,KAAK;YAC1C;sBAECqB,YAAYe;;;QAIhBd;;;EAGP,GACA;IACEe,cAAc;EAChB,CAAA;AAGF,SAAOhG,qBAAqB4D,iBAAiB;IAC3CxC,OAAOQ;EACT,CAAA;AACF;",
5
- "names": ["Stack", "composeEventHandlers", "isWeb", "shouldRenderNativePlatform", "useProps", "withStaticProperties", "registerFocusable", "useSwitch", "useControllableState", "React", "Switch", "NativeSwitch", "SwitchStyledContext", "SwitchFrame", "DefaultSwitchFrame", "SwitchThumb", "SwitchContext", "createContext", "checked", "disabled", "frameWidth", "createSwitch", "createProps", "disableActiveTheme", "Frame", "Thumb", "process", "env", "NODE_ENV", "staticConfig", "context", "console", "warn", "SwitchThumbComponent", "styleable", "props", "forwardedRef", "sizeProp", "size", "unstyledProp", "unstyled", "nativeID", "thumbProps", "useContext", "styledContext", "useStyledContext", "unstyledContext", "sizeContext", "TAMAGUI_HEADLESS", "initialChecked", "useRef", "current", "useState", "thumbWidth", "setThumbWidth", "distance", "x", "ref", "theme", "alignSelf", "onLayout", "e", "nativeEvent", "layout", "width", "SwitchComponent", "_props", "native", "nativeProps", "checkedProp", "defaultChecked", "onCheckedChange", "prop", "defaultProp", "onChange", "transition", "setChecked", "setFrameWidth", "propsActive", "noNormalize", "noExpand", "resolveValues", "forComponent", "Object", "assign", "switchProps", "bubbleInput", "switchRef", "useEffect", "id", "focusAndSelect", "value", "focus", "renderNative", "onValueChange", "Provider", "tag", "type", "themeShallow", "flex", "children", "disableTheme"]
4
+ "mappings": ";AACA,SACEA,OACAC,sBACAC,OACAC,4BACAC,UACAC,4BACK;AAKP,SAASC,yBAAyB;AAClC,SAASC,iBAAiB;AAC1B,SAASC,4BAA4B;AACrC,YAAYC,WAAW;AAEvB,SAASC,UAAUC,oBAAoB;AAEvC,SAASC,2BAA2B;AACpC,SAASC,eAAeC,oBAAoBC,mBAAmB;AAoBxD,IAAMC,gBAAgBP,sBAAMQ,cAIhC;EACDC,SAAS;EACTC,UAAU;EACVC,YAAY;AACd,CAAA;AAKO,SAASC,aAGdC,aAAmE;AACnE,MAAM,EACJC,oBACAC,QAAQV,oBACRW,QAAQV,YAAW,IACjBO;AAMJ,EAAII,QAAQC,IAAIC,aAAa,kBAExBJ,UAAUV,sBACTU,MAAMK,aAAaC,WACnBN,MAAMK,aAAaC,YAAYlB,uBAChCa,UAAUV,eACTU,MAAMI,aAAaC,WACnBL,MAAMI,aAAaC,YAAYlB,wBAEjCmB,QAAQC,KACN,2IAA2I,GAKjJR,MAAMK,aAAaC,UAAUlB,qBAC7Ba,MAAMI,aAAaC,UAAUlB;AAE7B,MAAMqB,uBAAuBR,MAAMS,UACjC,SAAqBC,OAAOC,cAAY;AACtC,QAAM,EAAEC,MAAMC,UAAUC,UAAUC,cAAcC,UAAU,GAAGC,WAAAA,IAAeP,OACtEL,UAAUrB,MAAMkC,WAAW3B,aAAAA,GAC3B,EAAEE,SAASC,UAAUC,WAAU,IAAKU,SAEpCc,gBAAgBhC,oBAAoBiC,iBAAgB,GACpD,EAAEN,UAAUO,iBAAiBT,MAAMU,YAAW,IAAKH,eAInDJ,MAHAD,WACJb,QAAQC,IAAIqB,qBAAqB,MAC7B,MACAR,OAAAA,gBAAgBM,qBAAAA,Q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CxC,OAAOQ;EACT,CAAA;AACF;",
5
+ "names": ["Stack", "composeEventHandlers", "isWeb", "shouldRenderNativePlatform", "useProps", "withStaticProperties", "registerFocusable", "useSwitch", "useControllableState", "React", "Switch", "NativeSwitch", "SwitchStyledContext", "SwitchFrame", "DefaultSwitchFrame", "SwitchThumb", "SwitchContext", "createContext", "checked", "disabled", "frameWidth", "createSwitch", "createProps", "disableActiveTheme", "Frame", "Thumb", "process", "env", "NODE_ENV", "staticConfig", "context", "console", "warn", "SwitchThumbComponent", "styleable", "props", "forwardedRef", "size", "sizeProp", "unstyled", "unstyledProp", "nativeID", "thumbProps", "useContext", "styledContext", "useStyledContext", "unstyledContext", "sizeContext", "TAMAGUI_HEADLESS", "initialChecked", "useRef", "current", "thumbWidth", "setThumbWidth", "useState", "distance", "x", "ref", "theme", "alignSelf", "onLayout", "e", "nativeEvent", "layout", "width", "SwitchComponent", "_props", "native", "nativeProps", "checkedProp", "defaultChecked", "onCheckedChange", "setChecked", "prop", "defaultProp", "onChange", "transition", "setFrameWidth", "propsActive", "noNormalize", "noExpand", "resolveValues", "forComponent", "switchProps", "bubbleInput", "switchRef", "Object", "assign", "useEffect", "id", "focusAndSelect", "value", "focus", "renderNative", "onValueChange", "Provider", "tag", "type", "themeShallow", "flex", "children", "disableTheme"]
6
6
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tamagui/switch",
3
- "version": "1.110.5",
3
+ "version": "1.111.0",
4
4
  "removeSideEffects": true,
5
5
  "sideEffects": [
6
6
  "*.css"
@@ -34,23 +34,23 @@
34
34
  }
35
35
  },
36
36
  "dependencies": {
37
- "@tamagui/compose-refs": "1.110.5",
38
- "@tamagui/constants": "1.110.5",
39
- "@tamagui/core": "1.110.5",
40
- "@tamagui/focusable": "1.110.5",
41
- "@tamagui/get-token": "1.110.5",
42
- "@tamagui/helpers": "1.110.5",
43
- "@tamagui/label": "1.110.5",
44
- "@tamagui/stacks": "1.110.5",
45
- "@tamagui/switch-headless": "1.110.5",
46
- "@tamagui/use-controllable-state": "1.110.5",
47
- "@tamagui/use-previous": "1.110.5"
37
+ "@tamagui/compose-refs": "1.111.0",
38
+ "@tamagui/constants": "1.111.0",
39
+ "@tamagui/core": "1.111.0",
40
+ "@tamagui/focusable": "1.111.0",
41
+ "@tamagui/get-token": "1.111.0",
42
+ "@tamagui/helpers": "1.111.0",
43
+ "@tamagui/label": "1.111.0",
44
+ "@tamagui/stacks": "1.111.0",
45
+ "@tamagui/switch-headless": "1.111.0",
46
+ "@tamagui/use-controllable-state": "1.111.0",
47
+ "@tamagui/use-previous": "1.111.0"
48
48
  },
49
49
  "peerDependencies": {
50
50
  "react": "*"
51
51
  },
52
52
  "devDependencies": {
53
- "@tamagui/build": "1.110.5",
53
+ "@tamagui/build": "1.111.0",
54
54
  "react": "^18.2.0 || ^19.0.0"
55
55
  },
56
56
  "publishConfig": {