@xaui/native 0.9.1-alpha.28 → 0.9.1-alpha.29

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.
Files changed (66) hide show
  1. package/dist/{chunk-3JATAB7S.js → chunk-4GTAZM2C.js} +4 -2
  2. package/dist/{chunk-N4UJYDOW.js → chunk-5RFRASSB.js} +20 -18
  3. package/dist/{chunk-V2FQN6ZK.js → chunk-7BOFQN2G.js} +1 -1
  4. package/dist/{chunk-5OXZIZRZ.cjs → chunk-APONC4DB.cjs} +7 -7
  5. package/dist/{chunk-6FBGCF5T.cjs → chunk-AQNWXJYV.cjs} +2 -2
  6. package/dist/chunk-BA2DBSAN.js +102 -0
  7. package/dist/{chunk-TR2TGPDQ.js → chunk-D4SOU26X.js} +1 -1
  8. package/dist/{chunk-CQRUNV6S.cjs → chunk-E25JH7W2.cjs} +17 -17
  9. package/dist/{chunk-V6DGGDHF.cjs → chunk-F3H4TXAY.cjs} +5 -5
  10. package/dist/chunk-F6CQ6CBI.cjs +112 -0
  11. package/dist/{chunk-ZTA47PO5.js → chunk-FDSQOPJH.js} +1 -1
  12. package/dist/{chunk-JCKVYYZO.cjs → chunk-FFEUGWVA.cjs} +3 -3
  13. package/dist/{chunk-YXVKQMCK.cjs → chunk-FNEUOBCV.cjs} +4 -2
  14. package/dist/{chunk-Y7U6ACMB.cjs → chunk-FXHRNUCS.cjs} +2 -2
  15. package/dist/{chunk-J4JFIC4W.cjs → chunk-GCU5A5MM.cjs} +3 -3
  16. package/dist/{chunk-G52TQJBI.js → chunk-HOIQRGSK.js} +1 -1
  17. package/dist/chunk-L3Q5TVYE.js +659 -0
  18. package/dist/{chunk-WEMZ4VMC.js → chunk-NG4GFBDR.js} +1 -1
  19. package/dist/chunk-O5KDIEDH.cjs +735 -0
  20. package/dist/chunk-RZC4VFB5.cjs +698 -0
  21. package/dist/{chunk-5A4M6X5B.cjs → chunk-SVRZJEDU.cjs} +5 -5
  22. package/dist/{chunk-3LKGVKQY.cjs → chunk-TFNB2PNI.cjs} +4 -4
  23. package/dist/{chunk-3YN7JQ55.js → chunk-V3KS5PPK.js} +2 -2
  24. package/dist/{chunk-AXSJPWSJ.js → chunk-V56334S3.js} +1 -1
  25. package/dist/{chunk-EHARM2EN.js → chunk-VUEDYW3M.js} +1 -1
  26. package/dist/{chunk-LKB3RIR2.js → chunk-XYFMSRNJ.js} +2 -2
  27. package/dist/{chunk-56KVKM27.js → chunk-YGOXQSNU.js} +15 -15
  28. package/dist/{chunk-H7DVR52Z.cjs → chunk-YWBTIWT5.cjs} +3 -3
  29. package/dist/components/alert/index.cjs +3 -3
  30. package/dist/components/alert/index.js +2 -2
  31. package/dist/components/button/index.cjs +3 -3
  32. package/dist/components/button/index.js +2 -2
  33. package/dist/components/card/index.cjs +3 -3
  34. package/dist/components/card/index.js +2 -2
  35. package/dist/components/checkbox/index.cjs +4 -4
  36. package/dist/components/checkbox/index.js +3 -3
  37. package/dist/components/chip/index.cjs +3 -3
  38. package/dist/components/chip/index.js +2 -2
  39. package/dist/components/input/index.cjs +3 -3
  40. package/dist/components/input/index.js +2 -2
  41. package/dist/components/input-group/index.cjs +4 -4
  42. package/dist/components/input-group/index.js +3 -3
  43. package/dist/components/input-otp/index.cjs +3 -3
  44. package/dist/components/input-otp/index.js +2 -2
  45. package/dist/components/radio/index.cjs +4 -4
  46. package/dist/components/radio/index.js +3 -3
  47. package/dist/components/switch/index.cjs +25 -0
  48. package/dist/components/switch/index.d.cts +1154 -0
  49. package/dist/components/switch/index.d.ts +1154 -0
  50. package/dist/components/switch/index.js +25 -0
  51. package/dist/components/text-area/index.cjs +4 -4
  52. package/dist/components/text-area/index.js +3 -3
  53. package/dist/components/typography/index.cjs +3 -3
  54. package/dist/components/typography/index.js +2 -2
  55. package/dist/index.cjs +30 -14
  56. package/dist/index.d.cts +1 -0
  57. package/dist/index.d.ts +1 -0
  58. package/dist/index.js +29 -13
  59. package/dist/system/index.cjs +3 -3
  60. package/dist/system/index.d.cts +13 -1
  61. package/dist/system/index.d.ts +13 -1
  62. package/dist/system/index.js +2 -2
  63. package/package.json +11 -1
  64. package/dist/chunk-63TWVWHG.cjs +0 -584
  65. package/dist/chunk-E6EFYPJR.cjs +0 -41
  66. package/dist/chunk-EYJEUXXC.js +0 -98
@@ -0,0 +1,698 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ function _interopRequireDefault(obj) {
7
+ return obj && obj.__esModule ? obj : {
8
+ default: obj
9
+ };
10
+ }
11
+ function _nullishCoalesce(lhs, rhsFn) {
12
+ if (lhs != null) {
13
+ return lhs;
14
+ } else {
15
+ return rhsFn();
16
+ }
17
+ }
18
+ function _optionalChain(ops) {
19
+ let lastAccessLHS = undefined;
20
+ let value = ops[0];
21
+ let i = 1;
22
+ while (i < ops.length) {
23
+ const op = ops[i];
24
+ const fn = ops[i + 1];
25
+ i += 2;
26
+ if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) {
27
+ return undefined;
28
+ }
29
+ if (op === 'access' || op === 'optionalAccess') {
30
+ lastAccessLHS = value;
31
+ value = fn(value);
32
+ } else if (op === 'call' || op === 'optionalCall') {
33
+ value = fn((...args) => value.call(lastAccessLHS, ...args));
34
+ lastAccessLHS = undefined;
35
+ }
36
+ }
37
+ return value;
38
+ }
39
+ var _chunk7EIHHOHPcjs = require('./chunk-7EIHHOHP.cjs');
40
+ var _chunkIG4Q3WQOcjs = require('./chunk-IG4Q3WQO.cjs');
41
+ var _chunkFNEUOBCVcjs = require('./chunk-FNEUOBCV.cjs');
42
+ var _chunkHUZ4AUM2cjs = require('./chunk-HUZ4AUM2.cjs');
43
+ var _chunk57SJ4LJFcjs = require('./chunk-57SJ4LJF.cjs');
44
+
45
+ // src/components/switch/switch-label.tsx
46
+ var _react = require('react');
47
+ var _reactnative = require('react-native');
48
+
49
+ // src/components/switch/switch.context.ts
50
+ var [SwitchProvider, useSwitch] = _chunkHUZ4AUM2cjs.createSlotContext.call(void 0, "Switch");
51
+
52
+ // src/components/switch/switch-label.tsx
53
+ var _jsxruntime = require('react/jsx-runtime');
54
+ var SwitchLabel = _react.forwardRef.call(void 0, function SwitchLabel2({
55
+ children,
56
+ style,
57
+ ...props
58
+ }, ref) {
59
+ const {
60
+ labelStyle
61
+ } = useSwitch();
62
+ const [styleProps, rest] = _chunkHUZ4AUM2cjs.useStyleProps.call(void 0, props);
63
+ return /* @__PURE__ */_jsxruntime.jsx.call(void 0, _reactnative.Text, {
64
+ ref,
65
+ style: [labelStyle, styleProps, style],
66
+ ...rest,
67
+ children
68
+ });
69
+ });
70
+ SwitchLabel.displayName = "XAUI.Switch.Label";
71
+
72
+ // src/components/switch/switch-thumb.tsx
73
+
74
+ var _reactnativereanimated = require('react-native-reanimated');
75
+ var _reactnativereanimated2 = _interopRequireDefault(_reactnativereanimated);
76
+
77
+ // src/components/switch/switch.style.ts
78
+ var SWITCH_DURATION = 175;
79
+
80
+ // src/components/switch/switch-thumb.tsx
81
+
82
+ var SwitchThumb = _react.forwardRef.call(void 0, function SwitchThumb2({
83
+ children,
84
+ animation = true,
85
+ style,
86
+ ...props
87
+ }, ref) {
88
+ const {
89
+ thumbStyle,
90
+ thumb,
91
+ travel,
92
+ isSelected
93
+ } = useSwitch();
94
+ const [styleProps, rest] = _chunkHUZ4AUM2cjs.useStyleProps.call(void 0, props);
95
+ const base = [thumbStyle, styleProps, style];
96
+ const distance = _reactnative.I18nManager.isRTL ? -travel : travel;
97
+ if (!animation) {
98
+ return /* @__PURE__ */_jsxruntime.jsx.call(void 0, _reactnative.View, {
99
+ ref,
100
+ ...rest,
101
+ style: [base, {
102
+ backgroundColor: isSelected ? thumb.on : thumb.off,
103
+ transform: [{
104
+ translateX: isSelected ? distance : 0
105
+ }]
106
+ }],
107
+ children
108
+ });
109
+ }
110
+ return /* @__PURE__ */_jsxruntime.jsx.call(void 0, SlidingThumb, {
111
+ ref,
112
+ style: base,
113
+ colors: thumb,
114
+ distance,
115
+ isSelected,
116
+ ...rest,
117
+ children
118
+ });
119
+ });
120
+ SwitchThumb.displayName = "XAUI.Switch.Thumb";
121
+ const _worklet_9469358480916_init_data = {
122
+ code: "function chunkRZC4VFB5Cjs1(){const{_reactnativereanimated,isSelected,SWITCH_DURATION}=this.__closure;return _reactnativereanimated.withTiming.call(void 0,isSelected?1:0,{duration:SWITCH_DURATION});}",
123
+ location: "/home/runner/work/xaui/xaui/packages/native/dist/chunk-RZC4VFB5.cjs",
124
+ sourceMap: "{\"version\":3,\"names\":[\"chunkRZC4VFB5Cjs1\",\"_reactnativereanimated\",\"isSelected\",\"SWITCH_DURATION\",\"__closure\",\"withTiming\",\"call\",\"duration\"],\"sources\":[\"/home/runner/work/xaui/xaui/packages/native/dist/chunk-RZC4VFB5.cjs\"],\"mappings\":\"AAwFuE,SAAAA,iBAAMA,CAAA,QAAAC,sBAAA,CAAAC,UAAA,CAAAC,eAAA,OAAAC,SAAA,CAEzE,MAAO,CAAAH,sBAAsB,CAACI,UAAU,CAACC,IAAI,CAAC,IAAK,EAAC,CAAEJ,UAAU,CAAG,CAAC,CAAG,CAAC,CAAE,CAAEK,QAAQ,CAAEJ,eAAgB,CAAC,CAAC,CAC1G\",\"ignoreList\":[]}"
125
+ };
126
+ const _worklet_8105943337118_init_data = {
127
+ code: "function chunkRZC4VFB5Cjs2(){const{progress,distance,_reactnativereanimated,colors}=this.__closure;return{transform:[{translateX:progress.value*distance}],backgroundColor:_reactnativereanimated.interpolateColor.call(void 0,progress.value,[0,1],[colors.off,colors.on])};}",
128
+ location: "/home/runner/work/xaui/xaui/packages/native/dist/chunk-RZC4VFB5.cjs",
129
+ sourceMap: "{\"version\":3,\"names\":[\"chunkRZC4VFB5Cjs2\",\"progress\",\"distance\",\"_reactnativereanimated\",\"colors\",\"__closure\",\"transform\",\"translateX\",\"value\",\"backgroundColor\",\"interpolateColor\",\"call\",\"off\",\"on\"],\"sources\":[\"/home/runner/work/xaui/xaui/packages/native/dist/chunk-RZC4VFB5.cjs\"],\"mappings\":\"AA4F6E,SAAAA,iBAAMA,CAAA,QAAAC,QAAA,CAAAC,QAAA,CAAAC,sBAAA,CAAAC,MAAA,OAAAC,SAAA,CAE/E,MAAO,CACLC,SAAS,CAAE,CAAC,CAAEC,UAAU,CAAEN,QAAQ,CAACO,KAAK,CAAGN,QAAS,CAAC,CAAC,CACtDO,eAAe,CAAEN,sBAAsB,CAACO,gBAAgB,CAACC,IAAI,CAAC,IAAK,EAAC,CAClEV,QAAQ,CAACO,KAAK,CACd,CAAC,CAAC,CAAE,CAAC,CAAC,CACN,CAACJ,MAAM,CAACQ,GAAG,CAAER,MAAM,CAACS,EAAE,CACxB,CACF,CAAC,CACH\",\"ignoreList\":[]}"
130
+ };
131
+ var SlidingThumb = _react.forwardRef.call(void 0, function SlidingThumb2({
132
+ style,
133
+ colors,
134
+ distance,
135
+ isSelected,
136
+ children,
137
+ ...rest
138
+ }, ref) {
139
+ const progress = _reactnativereanimated.useDerivedValue.call(void 0, function chunkRZC4VFB5Cjs1Factory({
140
+ _worklet_9469358480916_init_data,
141
+ _reactnativereanimated,
142
+ isSelected,
143
+ SWITCH_DURATION
144
+ }) {
145
+ const _e = [new global.Error(), -4, -27];
146
+ const chunkRZC4VFB5Cjs1 = function () {
147
+ return _reactnativereanimated.withTiming.call(void 0, isSelected ? 1 : 0, {
148
+ duration: SWITCH_DURATION
149
+ });
150
+ };
151
+ chunkRZC4VFB5Cjs1.__closure = {
152
+ _reactnativereanimated,
153
+ isSelected,
154
+ SWITCH_DURATION
155
+ };
156
+ chunkRZC4VFB5Cjs1.__workletHash = 9469358480916;
157
+ chunkRZC4VFB5Cjs1.__pluginVersion = "0.7.4";
158
+ chunkRZC4VFB5Cjs1.__initData = _worklet_9469358480916_init_data;
159
+ chunkRZC4VFB5Cjs1.__stackDetails = _e;
160
+ return chunkRZC4VFB5Cjs1;
161
+ }({
162
+ _worklet_9469358480916_init_data,
163
+ _reactnativereanimated,
164
+ isSelected,
165
+ SWITCH_DURATION
166
+ }), [isSelected]);
167
+ const animatedStyle = _reactnativereanimated.useAnimatedStyle.call(void 0, function chunkRZC4VFB5Cjs2Factory({
168
+ _worklet_8105943337118_init_data,
169
+ progress,
170
+ distance,
171
+ _reactnativereanimated,
172
+ colors
173
+ }) {
174
+ const _e = [new global.Error(), -5, -27];
175
+ const chunkRZC4VFB5Cjs2 = function () {
176
+ return {
177
+ transform: [{
178
+ translateX: progress.value * distance
179
+ }],
180
+ backgroundColor: _reactnativereanimated.interpolateColor.call(void 0, progress.value, [0, 1], [colors.off, colors.on])
181
+ };
182
+ };
183
+ chunkRZC4VFB5Cjs2.__closure = {
184
+ progress,
185
+ distance,
186
+ _reactnativereanimated,
187
+ colors
188
+ };
189
+ chunkRZC4VFB5Cjs2.__workletHash = 8105943337118;
190
+ chunkRZC4VFB5Cjs2.__pluginVersion = "0.7.4";
191
+ chunkRZC4VFB5Cjs2.__initData = _worklet_8105943337118_init_data;
192
+ chunkRZC4VFB5Cjs2.__stackDetails = _e;
193
+ return chunkRZC4VFB5Cjs2;
194
+ }({
195
+ _worklet_8105943337118_init_data,
196
+ progress,
197
+ distance,
198
+ _reactnativereanimated,
199
+ colors
200
+ }), [progress, distance, colors.off, colors.on]);
201
+ return /* @__PURE__ */_jsxruntime.jsx.call(void 0, _reactnativereanimated2.default.View, {
202
+ ref,
203
+ ...rest,
204
+ style: [style, animatedStyle],
205
+ children
206
+ });
207
+ });
208
+
209
+ // src/components/switch/switch-track.tsx
210
+
211
+ var SwitchTrack = _react.forwardRef.call(void 0, function SwitchTrack2({
212
+ children,
213
+ animation = true,
214
+ style,
215
+ ...props
216
+ }, ref) {
217
+ const {
218
+ trackStyle,
219
+ track,
220
+ isSelected
221
+ } = useSwitch();
222
+ const [styleProps, rest] = _chunkHUZ4AUM2cjs.useStyleProps.call(void 0, props);
223
+ const base = [trackStyle, styleProps, style];
224
+ if (!animation) {
225
+ return /* @__PURE__ */_jsxruntime.jsx.call(void 0, _reactnative.View, {
226
+ ref,
227
+ ...rest,
228
+ style: [base, {
229
+ backgroundColor: isSelected ? track.on : track.off
230
+ }],
231
+ children
232
+ });
233
+ }
234
+ return /* @__PURE__ */_jsxruntime.jsx.call(void 0, CrossfadingTrack, {
235
+ ref,
236
+ style: base,
237
+ colors: track,
238
+ isSelected,
239
+ ...rest,
240
+ children
241
+ });
242
+ });
243
+ SwitchTrack.displayName = "XAUI.Switch.Track";
244
+ const _worklet_6231260519766_init_data = {
245
+ code: "function chunkRZC4VFB5Cjs3(){const{_reactnativereanimated,isSelected,SWITCH_DURATION}=this.__closure;return _reactnativereanimated.withTiming.call(void 0,isSelected?1:0,{duration:SWITCH_DURATION});}",
246
+ location: "/home/runner/work/xaui/xaui/packages/native/dist/chunk-RZC4VFB5.cjs",
247
+ sourceMap: "{\"version\":3,\"names\":[\"chunkRZC4VFB5Cjs3\",\"_reactnativereanimated\",\"isSelected\",\"SWITCH_DURATION\",\"__closure\",\"withTiming\",\"call\",\"duration\"],\"sources\":[\"/home/runner/work/xaui/xaui/packages/native/dist/chunk-RZC4VFB5.cjs\"],\"mappings\":\"AAiJuE,SAAAA,iBAAMA,CAAA,QAAAC,sBAAA,CAAAC,UAAA,CAAAC,eAAA,OAAAC,SAAA,CAEzE,MAAO,CAAAH,sBAAsB,CAACI,UAAU,CAACC,IAAI,CAAC,IAAK,EAAC,CAAEJ,UAAU,CAAG,CAAC,CAAG,CAAC,CAAE,CAAEK,QAAQ,CAAEJ,eAAgB,CAAC,CAAC,CAC1G\",\"ignoreList\":[]}"
248
+ };
249
+ const _worklet_7981790206264_init_data = {
250
+ code: "function chunkRZC4VFB5Cjs4(){const{_reactnativereanimated,progress,colors}=this.__closure;return{backgroundColor:_reactnativereanimated.interpolateColor.call(void 0,progress.value,[0,1],[colors.off,colors.on])};}",
251
+ location: "/home/runner/work/xaui/xaui/packages/native/dist/chunk-RZC4VFB5.cjs",
252
+ sourceMap: "{\"version\":3,\"names\":[\"chunkRZC4VFB5Cjs4\",\"_reactnativereanimated\",\"progress\",\"colors\",\"__closure\",\"backgroundColor\",\"interpolateColor\",\"call\",\"value\",\"off\",\"on\"],\"sources\":[\"/home/runner/work/xaui/xaui/packages/native/dist/chunk-RZC4VFB5.cjs\"],\"mappings\":\"AAqJ6E,SAAAA,iBAAMA,CAAA,QAAAC,sBAAA,CAAAC,QAAA,CAAAC,MAAA,OAAAC,SAAA,CAE/E,MAAO,CACLC,eAAe,CAAEJ,sBAAsB,CAACK,gBAAgB,CAACC,IAAI,CAAC,IAAK,EAAC,CAClEL,QAAQ,CAACM,KAAK,CACd,CAAC,CAAC,CAAE,CAAC,CAAC,CACN,CAACL,MAAM,CAACM,GAAG,CAAEN,MAAM,CAACO,EAAE,CACxB,CACF,CAAC,CACH\",\"ignoreList\":[]}"
253
+ };
254
+ var CrossfadingTrack = _react.forwardRef.call(void 0, function CrossfadingTrack2({
255
+ style,
256
+ colors,
257
+ isSelected,
258
+ children,
259
+ ...rest
260
+ }, ref) {
261
+ const progress = _reactnativereanimated.useDerivedValue.call(void 0, function chunkRZC4VFB5Cjs3Factory({
262
+ _worklet_6231260519766_init_data,
263
+ _reactnativereanimated,
264
+ isSelected,
265
+ SWITCH_DURATION
266
+ }) {
267
+ const _e = [new global.Error(), -4, -27];
268
+ const chunkRZC4VFB5Cjs3 = function () {
269
+ return _reactnativereanimated.withTiming.call(void 0, isSelected ? 1 : 0, {
270
+ duration: SWITCH_DURATION
271
+ });
272
+ };
273
+ chunkRZC4VFB5Cjs3.__closure = {
274
+ _reactnativereanimated,
275
+ isSelected,
276
+ SWITCH_DURATION
277
+ };
278
+ chunkRZC4VFB5Cjs3.__workletHash = 6231260519766;
279
+ chunkRZC4VFB5Cjs3.__pluginVersion = "0.7.4";
280
+ chunkRZC4VFB5Cjs3.__initData = _worklet_6231260519766_init_data;
281
+ chunkRZC4VFB5Cjs3.__stackDetails = _e;
282
+ return chunkRZC4VFB5Cjs3;
283
+ }({
284
+ _worklet_6231260519766_init_data,
285
+ _reactnativereanimated,
286
+ isSelected,
287
+ SWITCH_DURATION
288
+ }), [isSelected]);
289
+ const animatedStyle = _reactnativereanimated.useAnimatedStyle.call(void 0, function chunkRZC4VFB5Cjs4Factory({
290
+ _worklet_7981790206264_init_data,
291
+ _reactnativereanimated,
292
+ progress,
293
+ colors
294
+ }) {
295
+ const _e = [new global.Error(), -4, -27];
296
+ const chunkRZC4VFB5Cjs4 = function () {
297
+ return {
298
+ backgroundColor: _reactnativereanimated.interpolateColor.call(void 0, progress.value, [0, 1], [colors.off, colors.on])
299
+ };
300
+ };
301
+ chunkRZC4VFB5Cjs4.__closure = {
302
+ _reactnativereanimated,
303
+ progress,
304
+ colors
305
+ };
306
+ chunkRZC4VFB5Cjs4.__workletHash = 7981790206264;
307
+ chunkRZC4VFB5Cjs4.__pluginVersion = "0.7.4";
308
+ chunkRZC4VFB5Cjs4.__initData = _worklet_7981790206264_init_data;
309
+ chunkRZC4VFB5Cjs4.__stackDetails = _e;
310
+ return chunkRZC4VFB5Cjs4;
311
+ }({
312
+ _worklet_7981790206264_init_data,
313
+ _reactnativereanimated,
314
+ progress,
315
+ colors
316
+ }), [progress, colors.off, colors.on]);
317
+ return /* @__PURE__ */_jsxruntime.jsx.call(void 0, _reactnativereanimated2.default.View, {
318
+ ref,
319
+ ...rest,
320
+ style: [style, animatedStyle],
321
+ children
322
+ });
323
+ });
324
+
325
+ // src/components/switch/switch.tsx
326
+
327
+ // src/components/switch/switch.recipe.ts
328
+ var SLOTS = ["root", "track", "trackSelected", "thumb", "thumbSelected", "label"];
329
+ var VARIANT_TOKENS = {
330
+ primary: {
331
+ bg: "default",
332
+ fg: "white",
333
+ bgSelected: "accent",
334
+ fgSelected: "accentForeground"
335
+ },
336
+ secondary: {
337
+ bg: "default",
338
+ fg: "white",
339
+ bgSelected: "accent",
340
+ fgSelected: "accentForeground"
341
+ }
342
+ };
343
+ function sizeAxis(step) {
344
+ const {
345
+ track,
346
+ height,
347
+ thumb,
348
+ padding,
349
+ gap,
350
+ label
351
+ } = step;
352
+ return theme => {
353
+ const trackHeight = theme.spacing(height);
354
+ const knob = theme.spacing(thumb);
355
+ return {
356
+ root: {
357
+ gap: theme.spacing(gap)
358
+ },
359
+ track: {
360
+ width: theme.spacing(track),
361
+ height: trackHeight
362
+ },
363
+ thumb: {
364
+ width: knob,
365
+ height: knob,
366
+ // `start`, never `left` (R13): the knob rests at the leading edge, and RTL mirrors
367
+ // the logical property and only it.
368
+ start: theme.spacing(padding),
369
+ top: (trackHeight - knob) / 2
370
+ },
371
+ label: {
372
+ fontSize: theme.fontSizes[label],
373
+ lineHeight: theme.lineHeights[label]
374
+ }
375
+ };
376
+ };
377
+ }
378
+ var INSIDE = {
379
+ sm: {
380
+ track: 11,
381
+ height: 6.5,
382
+ thumb: 5,
383
+ padding: 0.75,
384
+ gap: 2,
385
+ label: "sm"
386
+ },
387
+ md: {
388
+ track: 12,
389
+ height: 7,
390
+ thumb: 5.5,
391
+ padding: 0.75,
392
+ gap: 2,
393
+ label: "md"
394
+ },
395
+ lg: {
396
+ track: 14,
397
+ height: 8,
398
+ thumb: 6.5,
399
+ padding: 0.75,
400
+ gap: 2.5,
401
+ label: "lg"
402
+ }
403
+ };
404
+ var OVERLAP = {
405
+ sm: {
406
+ track: 11,
407
+ height: 4.5,
408
+ thumb: 6,
409
+ padding: 0,
410
+ gap: 2,
411
+ label: "sm"
412
+ },
413
+ md: {
414
+ track: 12,
415
+ height: 4.5,
416
+ thumb: 6.5,
417
+ padding: 0,
418
+ gap: 2,
419
+ label: "md"
420
+ },
421
+ lg: {
422
+ track: 14,
423
+ height: 5,
424
+ thumb: 7.5,
425
+ padding: 0,
426
+ gap: 2.5,
427
+ label: "lg"
428
+ }
429
+ };
430
+ var switchRecipe = _chunkFNEUOBCVcjs.createRecipe.call(void 0, {
431
+ slots: SLOTS,
432
+ base: theme => ({
433
+ root: {
434
+ flexDirection: "row",
435
+ alignItems: "center",
436
+ alignSelf: "flex-start"
437
+ },
438
+ track: {
439
+ borderRadius: theme.radius.full,
440
+ borderCurve: "continuous",
441
+ // Never `hidden`: on `secondary` the thumb stands outside the track, and clipping it
442
+ // would cut the knob in half rather than let it overlap.
443
+ overflow: "visible"
444
+ },
445
+ thumb: {
446
+ position: "absolute",
447
+ borderRadius: theme.radius.full,
448
+ alignItems: "center",
449
+ justifyContent: "center",
450
+ // The knob is the thing that moves, and a shadow is what says so.
451
+ ...theme.shadows.field
452
+ },
453
+ label: {
454
+ fontFamily: theme.fontFamilies.body,
455
+ color: theme.colors.foreground
456
+ }
457
+ }),
458
+ variantTokens: VARIANT_TOKENS,
459
+ /**
460
+ * Four colours on four slots, and the two `*Selected` ones exist to be **flattened into
461
+ * values** rather than rendered: the track crosses from one to the other and the thumb
462
+ * with it, which is an interpolation on the UI thread rather than a style swap.
463
+ *
464
+ * They are roles for the reason the `Checkbox`'s are: the tint pass re-runs `paint` and
465
+ * never the axes, so this is what makes `color` the colour the switch turns on to.
466
+ */
467
+ paint: (_theme, colors) => ({
468
+ track: {
469
+ backgroundColor: colors.bg
470
+ },
471
+ trackSelected: {
472
+ backgroundColor: colors.bgSelected
473
+ },
474
+ thumb: {
475
+ backgroundColor: colors.fg
476
+ },
477
+ thumbSelected: {
478
+ backgroundColor: colors.fgSelected
479
+ }
480
+ }),
481
+ variants: {
482
+ /**
483
+ * Declared and empty, which is unusual and deliberate: **every** number of this
484
+ * component depends on the shape as well as the size, so the whole table lives in the
485
+ * compounds below. The axis is here because the selection needs it to be typed, and
486
+ * because a reader looking for "what does `size` do" should find the answer next to
487
+ * the other axes rather than infer it from an absence.
488
+ */
489
+ size: {
490
+ sm: () => ({}),
491
+ md: () => ({}),
492
+ lg: () => ({})
493
+ },
494
+ /**
495
+ * Both, always together: a track that lost its capsule while the knob kept its circle
496
+ * is a control rounded by halves. The knob's corner is the same named value rather
497
+ * than the track's less the padding — that nesting rule reaches zero before the outer
498
+ * radius does, and a sharp knob inside a slightly rounded track looks like a mistake.
499
+ */
500
+ radius: _chunkFNEUOBCVcjs.radiusAxis.call(void 0, "track", "thumb")
501
+ },
502
+ /** The six geometries — two shapes, three sizes — and nothing else. */
503
+ compoundVariants: [{
504
+ when: {
505
+ variant: "primary",
506
+ size: "sm"
507
+ },
508
+ style: sizeAxis(INSIDE.sm)
509
+ }, {
510
+ when: {
511
+ variant: "primary",
512
+ size: "md"
513
+ },
514
+ style: sizeAxis(INSIDE.md)
515
+ }, {
516
+ when: {
517
+ variant: "primary",
518
+ size: "lg"
519
+ },
520
+ style: sizeAxis(INSIDE.lg)
521
+ }, {
522
+ when: {
523
+ variant: "secondary",
524
+ size: "sm"
525
+ },
526
+ style: sizeAxis(OVERLAP.sm)
527
+ }, {
528
+ when: {
529
+ variant: "secondary",
530
+ size: "md"
531
+ },
532
+ style: sizeAxis(OVERLAP.md)
533
+ }, {
534
+ when: {
535
+ variant: "secondary",
536
+ size: "lg"
537
+ },
538
+ style: sizeAxis(OVERLAP.lg)
539
+ }],
540
+ states: {
541
+ disabled: theme => ({
542
+ root: {
543
+ opacity: theme.opacity.disabled
544
+ }
545
+ })
546
+ },
547
+ defaultVariants: {
548
+ variant: "primary",
549
+ size: "md"
550
+ }
551
+ });
552
+
553
+ // src/components/switch/switch.tsx
554
+
555
+ var SwitchRoot = _react.forwardRef.call(void 0, function Switch({
556
+ children,
557
+ variant,
558
+ size,
559
+ radius,
560
+ color,
561
+ isSelected,
562
+ defaultSelected = false,
563
+ onSelectedChange,
564
+ isDisabled = false,
565
+ asChild = false,
566
+ accessibilityRole,
567
+ accessibilityState,
568
+ animation,
569
+ style,
570
+ onPress,
571
+ onPressIn,
572
+ onPressOut,
573
+ ...props
574
+ }, ref) {
575
+ const theme = _chunk57SJ4LJFcjs.useXAUITheme.call(void 0);
576
+ const [styleProps, rest] = _chunkHUZ4AUM2cjs.useStyleProps.call(void 0, props);
577
+ const [isPressed, press] = _chunkIG4Q3WQOcjs.usePressState.call(void 0, {
578
+ onPressIn,
579
+ onPressOut
580
+ });
581
+ const [selected, setSelected] = _chunk7EIHHOHPcjs.useControllableState.call(void 0, {
582
+ value: isSelected,
583
+ defaultValue: defaultSelected,
584
+ onChange: onSelectedChange
585
+ });
586
+ const handlePress = _react.useCallback.call(void 0, event => {
587
+ setSelected(current => !current);
588
+ _optionalChain([onPress, 'optionalCall', _ => _(event)]);
589
+ }, [setSelected, onPress]);
590
+ const selection = {
591
+ variant,
592
+ size,
593
+ radius
594
+ };
595
+ const states = {
596
+ pressed: isPressed,
597
+ disabled: isDisabled
598
+ };
599
+ const styles = switchRecipe.resolve({
600
+ theme,
601
+ selection,
602
+ states
603
+ });
604
+ const tint = color ? switchRecipe.tint({
605
+ theme,
606
+ color,
607
+ selection,
608
+ states
609
+ }) : void 0;
610
+ const context = _react.useMemo.call(void 0, () => {
611
+ const track = _reactnative.StyleSheet.flatten(styles.track);
612
+ const thumb = _reactnative.StyleSheet.flatten(styles.thumb);
613
+ return {
614
+ trackStyle: styles.track,
615
+ thumbStyle: styles.thumb,
616
+ labelStyle: styles.label,
617
+ // Values, not styles: the two ends of a colour that is crossed on the UI thread.
618
+ // The tint moves the "on" end alone — the track at rest keeps its neutral, because
619
+ // a switch that is off is off in every brand.
620
+ track: {
621
+ off: colorOf(track),
622
+ on: colorOf(_reactnative.StyleSheet.flatten([styles.trackSelected, _optionalChain([tint, 'optionalAccess', _2 => _2.trackSelected])]))
623
+ },
624
+ thumb: {
625
+ off: colorOf(thumb),
626
+ on: colorOf(_reactnative.StyleSheet.flatten([styles.thumbSelected, _optionalChain([tint, 'optionalAccess', _3 => _3.thumbSelected])]))
627
+ },
628
+ // The distance the knob slides, and the one number the recipe cannot write: it is
629
+ // the track's width less the thumb and the padding at both ends, and it has to be a
630
+ // number rather than a style because the slide happens in a worklet.
631
+ travel: travelOf(track, thumb),
632
+ isSelected: selected,
633
+ isDisabled
634
+ };
635
+ }, [styles, tint, selected, isDisabled]);
636
+ const rootStyle = [styles.root, styleProps, typeof style === "function" ? style({
637
+ pressed: isPressed
638
+ }) : style];
639
+ const text = _chunkHUZ4AUM2cjs.childrenToString.call(void 0, children);
640
+ const content = text !== null ? /* @__PURE__ */_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, {
641
+ children: [/* @__PURE__ */_jsxruntime.jsx.call(void 0, SwitchTrack, {
642
+ children: /* @__PURE__ */_jsxruntime.jsx.call(void 0, SwitchThumb, {})
643
+ }), /* @__PURE__ */_jsxruntime.jsx.call(void 0, SwitchLabel, {
644
+ children: text
645
+ })]
646
+ }) : _nullishCoalesce(children, () => (/* @__PURE__ */_jsxruntime.jsx.call(void 0, SwitchTrack, {
647
+ children: /* @__PURE__ */_jsxruntime.jsx.call(void 0, SwitchThumb, {})
648
+ })));
649
+ return /* @__PURE__ */_jsxruntime.jsx.call(void 0, SwitchProvider, {
650
+ value: context,
651
+ children: /* @__PURE__ */_jsxruntime.jsx.call(void 0, _chunkIG4Q3WQOcjs.PressableFeedback, {
652
+ ref,
653
+ isPressed,
654
+ isDisabled,
655
+ asChild,
656
+ animation,
657
+ accessibilityRole: _nullishCoalesce(accessibilityRole, () => "switch"),
658
+ accessibilityState: {
659
+ checked: selected,
660
+ disabled: isDisabled,
661
+ ...accessibilityState
662
+ },
663
+ ...rest,
664
+ style: rootStyle,
665
+ onPress: handlePress,
666
+ onPressIn: press.onPressIn,
667
+ onPressOut: press.onPressOut,
668
+ children: asChild ? children : content
669
+ })
670
+ });
671
+ });
672
+ SwitchRoot.displayName = "XAUI.Switch.Root";
673
+ function colorOf(style) {
674
+ return typeof style.backgroundColor === "string" ? style.backgroundColor : "";
675
+ }
676
+ function travelOf(track, thumb) {
677
+ const width = pointsOf(track.width);
678
+ const knob = pointsOf(thumb.width);
679
+ const inset = pointsOf(thumb.start);
680
+ return Math.max(width - knob - inset * 2, 0);
681
+ }
682
+ function pointsOf(value) {
683
+ return typeof value === "number" ? value : 0;
684
+ }
685
+
686
+ // src/components/switch/index.ts
687
+ var Switch2 = Object.assign(SwitchRoot, {
688
+ Track: SwitchTrack,
689
+ Thumb: SwitchThumb,
690
+ Label: SwitchLabel
691
+ });
692
+ exports.useSwitch = useSwitch;
693
+ exports.SwitchLabel = SwitchLabel;
694
+ exports.SwitchThumb = SwitchThumb;
695
+ exports.SwitchTrack = SwitchTrack;
696
+ exports.switchRecipe = switchRecipe;
697
+ exports.SwitchRoot = SwitchRoot;
698
+ exports.Switch = Switch2;