@xaui/native 0.9.1-alpha.4 → 0.9.1-alpha.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-2EGR4LWD.js +145 -0
- package/dist/chunk-2NRZKJG7.js +531 -0
- package/dist/chunk-2PMXMKS5.js +67 -0
- package/dist/chunk-2XPG2243.js +586 -0
- package/dist/chunk-36PRYGAM.js +13 -0
- package/dist/chunk-3E7CDKFO.cjs +696 -0
- package/dist/chunk-3GFRSZYR.js +54 -0
- package/dist/chunk-423RQBOX.js +21 -0
- package/dist/chunk-4CUZZWFW.js +92 -0
- package/dist/chunk-4GTAZM2C.js +174 -0
- package/dist/chunk-4KFKWBN5.cjs +89 -0
- package/dist/{chunk-3QBT3Q65.cjs → chunk-57SJ4LJF.cjs} +7 -2
- package/dist/chunk-5R26NM4M.cjs +402 -0
- package/dist/chunk-5VKYNBNA.js +607 -0
- package/dist/chunk-64MXEVT3.js +66 -0
- package/dist/chunk-6DOLGZVV.cjs +147 -0
- package/dist/chunk-6L2TS2R3.cjs +92 -0
- package/dist/chunk-6UEZJRVI.js +669 -0
- package/dist/chunk-734MFAX4.js +27 -0
- package/dist/chunk-73RKQC5X.js +104 -0
- package/dist/chunk-7DPL3ZDS.cjs +21 -0
- package/dist/chunk-7EIHHOHP.cjs +42 -0
- package/dist/chunk-7GHM4GKL.cjs +119 -0
- package/dist/chunk-7YF5NAHQ.cjs +74 -0
- package/dist/{chunk-X2K2FX3W.js → chunk-A3EGFI6T.js} +6 -1
- package/dist/chunk-ABAGZTXZ.cjs +736 -0
- package/dist/{chunk-AW63PTQ4.cjs → chunk-ACAPTWE3.cjs} +85 -81
- package/dist/chunk-AMCSSOJT.cjs +104 -0
- package/dist/chunk-BA2DBSAN.js +102 -0
- package/dist/chunk-BRRXFOBY.js +431 -0
- package/dist/chunk-C5YLPCFC.cjs +293 -0
- package/dist/chunk-DA3OKXHV.cjs +700 -0
- package/dist/chunk-DD4276RF.js +366 -0
- package/dist/chunk-DG2I4PJG.js +701 -0
- package/dist/chunk-DHGLGSH6.js +661 -0
- package/dist/chunk-DIBUQ46Y.js +346 -0
- package/dist/chunk-EGLLDKN6.js +9 -0
- package/dist/chunk-EJQCQPET.cjs +9 -0
- package/dist/chunk-EKS3W46M.cjs +66 -0
- package/dist/chunk-EZEYMLO3.js +402 -0
- package/dist/chunk-F6CQ6CBI.cjs +112 -0
- package/dist/chunk-F6W3JQ7K.js +42 -0
- package/dist/chunk-FHUYHV6J.js +89 -0
- package/dist/chunk-FNEUOBCV.cjs +174 -0
- package/dist/chunk-G3CCT4EY.js +518 -0
- package/dist/chunk-G7P3ERYF.cjs +478 -0
- package/dist/chunk-GA6PBWNT.js +147 -0
- package/dist/chunk-GFUZ3MUT.cjs +455 -0
- package/dist/chunk-GGW43Q37.cjs +1 -0
- package/dist/chunk-GTR5X65M.cjs +27 -0
- package/dist/chunk-H4E4HDEP.cjs +13 -0
- package/dist/chunk-H7DS4IO7.js +198 -0
- package/dist/chunk-HDVVZG4S.cjs +198 -0
- package/dist/chunk-IKJVLJKT.js +151 -0
- package/dist/chunk-J3MB4PI5.cjs +531 -0
- package/dist/chunk-K72UDPVN.js +119 -0
- package/dist/chunk-KCMYU7WF.js +86 -0
- package/dist/chunk-LRN3RNDO.js +940 -0
- package/dist/chunk-LTX6TB5I.js +124 -0
- package/dist/chunk-LUPCPLND.cjs +145 -0
- package/dist/chunk-M63GFNKV.js +194 -0
- package/dist/chunk-N3KTZMPG.js +293 -0
- package/dist/chunk-NCTOTTVW.js +13 -0
- package/dist/chunk-NWGLP6JX.cjs +410 -0
- package/dist/chunk-R73XQK7X.cjs +314 -0
- package/dist/chunk-RU7JCMWC.cjs +881 -0
- package/dist/chunk-SNIHUKDA.cjs +184 -0
- package/dist/chunk-T5FV5F7A.cjs +607 -0
- package/dist/chunk-TDTUAIFF.cjs +153 -0
- package/dist/chunk-TJ74XVZN.cjs +431 -0
- package/dist/chunk-TK44VBIE.cjs +194 -0
- package/dist/chunk-UAWBAD4E.cjs +346 -0
- package/dist/chunk-UFTCTTKK.js +381 -0
- package/dist/chunk-VLKBESEV.cjs +407 -0
- package/dist/chunk-WDDXU3OH.cjs +67 -0
- package/dist/chunk-WFEMJCXO.cjs +13 -0
- package/dist/chunk-WHJTBTYM.js +0 -0
- package/dist/{chunk-2KXQATVL.js → chunk-WKCQ6VGW.js} +59 -55
- package/dist/chunk-XFPQFCEK.js +455 -0
- package/dist/chunk-XSQPVDFH.cjs +60 -0
- package/dist/chunk-XTC2SLFT.js +153 -0
- package/dist/chunk-XV735BSA.cjs +366 -0
- package/dist/chunk-XWNG2U4K.cjs +124 -0
- package/dist/chunk-YGYYJ3LQ.js +314 -0
- package/dist/chunk-YVHT2UVW.js +74 -0
- package/dist/chunk-ZFOOJK37.cjs +86 -0
- package/dist/close-button.type-BUYuoSt2.d.ts +36 -0
- package/dist/close-button.type-CHsgZ3wO.d.cts +36 -0
- package/dist/components/accordion/index.cjs +35 -0
- package/dist/components/accordion/index.d.cts +299 -0
- package/dist/components/accordion/index.d.ts +299 -0
- package/dist/components/accordion/index.js +35 -0
- package/dist/components/alert/index.cjs +20 -0
- package/dist/components/alert/index.d.cts +169 -0
- package/dist/components/alert/index.d.ts +169 -0
- package/dist/components/alert/index.js +20 -0
- package/dist/components/avatar/index.cjs +16 -0
- package/dist/components/avatar/index.d.cts +131 -0
- package/dist/components/avatar/index.d.ts +131 -0
- package/dist/components/avatar/index.js +16 -0
- package/dist/components/badge/index.cjs +15 -0
- package/dist/components/badge/index.d.cts +157 -0
- package/dist/components/badge/index.d.ts +157 -0
- package/dist/components/badge/index.js +15 -0
- package/dist/components/button/index.cjs +22 -0
- package/dist/components/button/index.d.cts +613 -0
- package/dist/components/button/index.d.ts +613 -0
- package/dist/components/button/index.js +22 -0
- package/dist/components/card/index.cjs +22 -0
- package/dist/components/card/index.d.cts +620 -0
- package/dist/components/card/index.d.ts +620 -0
- package/dist/components/card/index.js +22 -0
- package/dist/components/checkbox/index.cjs +26 -0
- package/dist/components/checkbox/index.d.cts +1136 -0
- package/dist/components/checkbox/index.d.ts +1136 -0
- package/dist/components/checkbox/index.js +26 -0
- package/dist/components/chip/index.cjs +20 -0
- package/dist/components/chip/index.d.cts +608 -0
- package/dist/components/chip/index.d.ts +608 -0
- package/dist/components/chip/index.js +20 -0
- package/dist/components/divider/index.cjs +13 -0
- package/dist/components/divider/index.d.cts +117 -0
- package/dist/components/divider/index.d.ts +117 -0
- package/dist/components/divider/index.js +13 -0
- package/dist/components/field-group/index.cjs +27 -0
- package/dist/components/field-group/index.d.cts +270 -0
- package/dist/components/field-group/index.d.ts +270 -0
- package/dist/components/field-group/index.js +27 -0
- package/dist/components/input-otp/index.cjs +29 -0
- package/dist/components/input-otp/index.d.cts +325 -0
- package/dist/components/input-otp/index.d.ts +325 -0
- package/dist/components/input-otp/index.js +29 -0
- package/dist/components/menu/index.cjs +49 -0
- package/dist/components/menu/index.d.cts +351 -0
- package/dist/components/menu/index.d.ts +351 -0
- package/dist/components/menu/index.js +49 -0
- package/dist/components/popover/index.cjs +38 -0
- package/dist/components/popover/index.d.cts +254 -0
- package/dist/components/popover/index.d.ts +254 -0
- package/dist/components/popover/index.js +38 -0
- package/dist/components/radio/index.cjs +26 -0
- package/dist/components/radio/index.d.cts +1102 -0
- package/dist/components/radio/index.d.ts +1102 -0
- package/dist/components/radio/index.js +26 -0
- package/dist/components/select/index.cjs +50 -0
- package/dist/components/select/index.d.cts +498 -0
- package/dist/components/select/index.d.ts +498 -0
- package/dist/components/select/index.js +50 -0
- package/dist/components/skeleton/index.cjs +11 -0
- package/dist/components/skeleton/index.d.cts +111 -0
- package/dist/components/skeleton/index.d.ts +111 -0
- package/dist/components/skeleton/index.js +11 -0
- package/dist/components/spinner/index.cjs +17 -0
- package/dist/components/spinner/index.d.cts +104 -0
- package/dist/components/spinner/index.d.ts +104 -0
- package/dist/components/spinner/index.js +17 -0
- package/dist/components/switch/index.cjs +27 -0
- package/dist/components/switch/index.d.cts +1154 -0
- package/dist/components/switch/index.d.ts +1154 -0
- package/dist/components/switch/index.js +27 -0
- package/dist/components/tabs/index.cjs +33 -0
- package/dist/components/tabs/index.d.cts +261 -0
- package/dist/components/tabs/index.d.ts +261 -0
- package/dist/components/tabs/index.js +33 -0
- package/dist/components/text-area/index.cjs +14 -0
- package/dist/components/text-area/index.d.cts +73 -0
- package/dist/components/text-area/index.d.ts +73 -0
- package/dist/components/text-area/index.js +14 -0
- package/dist/components/text-field/index.cjs +25 -0
- package/dist/components/text-field/index.d.cts +205 -0
- package/dist/components/text-field/index.d.ts +205 -0
- package/dist/components/text-field/index.js +25 -0
- package/dist/components/typography/index.cjs +15 -0
- package/dist/components/typography/index.d.cts +116 -0
- package/dist/components/typography/index.d.ts +116 -0
- package/dist/components/typography/index.js +15 -0
- package/dist/components/view/index.cjs +17 -0
- package/dist/components/view/index.d.cts +152 -0
- package/dist/components/view/index.d.ts +152 -0
- package/dist/components/view/index.js +17 -0
- package/dist/create-recipe-BdVd2ffi.d.ts +114 -0
- package/dist/create-recipe-dC7wMfnj.d.cts +114 -0
- package/dist/icon.type-Kml72iSz.d.ts +73 -0
- package/dist/icon.type-d_i9ma-i.d.cts +73 -0
- package/dist/index.cjs +423 -5
- package/dist/index.d.cts +119 -4
- package/dist/index.d.ts +119 -4
- package/dist/index.js +445 -27
- package/dist/placement-DHa0Rrh1.d.cts +38 -0
- package/dist/placement-DHa0Rrh1.d.ts +38 -0
- package/dist/pressable-feedback.type-BA2C9sSz.d.cts +127 -0
- package/dist/pressable-feedback.type-Bs4dQlGj.d.ts +127 -0
- package/dist/style-props.type-CfnoGEP7.d.cts +31 -0
- package/dist/style-props.type-CfnoGEP7.d.ts +31 -0
- package/dist/system/index.cjs +73 -4
- package/dist/system/index.d.cts +379 -193
- package/dist/system/index.d.ts +379 -193
- package/dist/system/index.js +87 -18
- package/dist/text-field.type-0l73acce.d.ts +167 -0
- package/dist/text-field.type-DBh06DU5.d.cts +167 -0
- package/dist/theme/index.cjs +5 -3
- package/dist/theme/index.d.cts +55 -24
- package/dist/theme/index.d.ts +55 -24
- package/dist/theme/index.js +4 -2
- package/dist/{theme.type-C9bFJKFm.d.cts → theme.type-C2gNHpEx.d.cts} +1 -1
- package/dist/{theme.type-C9bFJKFm.d.ts → theme.type-C2gNHpEx.d.ts} +1 -1
- package/package.json +264 -18
- package/dist/chunk-ECDWSSHJ.js +0 -688
- package/dist/chunk-IYFGO523.cjs +0 -688
|
@@ -0,0 +1,700 @@
|
|
|
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 _chunk3E7CDKFOcjs = require('./chunk-3E7CDKFO.cjs');
|
|
41
|
+
var _chunk7DPL3ZDScjs = require('./chunk-7DPL3ZDS.cjs');
|
|
42
|
+
var _chunkFNEUOBCVcjs = require('./chunk-FNEUOBCV.cjs');
|
|
43
|
+
var _chunk57SJ4LJFcjs = require('./chunk-57SJ4LJF.cjs');
|
|
44
|
+
var _chunk7GHM4GKLcjs = require('./chunk-7GHM4GKL.cjs');
|
|
45
|
+
var _chunkTK44VBIEcjs = require('./chunk-TK44VBIE.cjs');
|
|
46
|
+
|
|
47
|
+
// src/components/switch/switch-label.tsx
|
|
48
|
+
var _react = require('react');
|
|
49
|
+
var _reactnative = require('react-native');
|
|
50
|
+
|
|
51
|
+
// src/components/switch/switch.context.ts
|
|
52
|
+
var [SwitchProvider, useSwitch] = _chunk7GHM4GKLcjs.createSlotContext.call(void 0, "Switch");
|
|
53
|
+
|
|
54
|
+
// src/components/switch/switch-label.tsx
|
|
55
|
+
var _jsxruntime = require('react/jsx-runtime');
|
|
56
|
+
var SwitchLabel = _react.forwardRef.call(void 0, function SwitchLabel2({
|
|
57
|
+
children,
|
|
58
|
+
style,
|
|
59
|
+
...props
|
|
60
|
+
}, ref) {
|
|
61
|
+
const {
|
|
62
|
+
labelStyle
|
|
63
|
+
} = useSwitch();
|
|
64
|
+
const [styleProps, rest] = _chunkTK44VBIEcjs.useStyleProps.call(void 0, props);
|
|
65
|
+
return /* @__PURE__ */_jsxruntime.jsx.call(void 0, _reactnative.Text, {
|
|
66
|
+
ref,
|
|
67
|
+
style: [labelStyle, styleProps, style],
|
|
68
|
+
...rest,
|
|
69
|
+
children
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
SwitchLabel.displayName = "XAUI.Switch.Label";
|
|
73
|
+
|
|
74
|
+
// src/components/switch/switch-thumb.tsx
|
|
75
|
+
|
|
76
|
+
var _reactnativereanimated = require('react-native-reanimated');
|
|
77
|
+
var _reactnativereanimated2 = _interopRequireDefault(_reactnativereanimated);
|
|
78
|
+
|
|
79
|
+
// src/components/switch/switch.style.ts
|
|
80
|
+
var SWITCH_DURATION = 175;
|
|
81
|
+
|
|
82
|
+
// src/components/switch/switch-thumb.tsx
|
|
83
|
+
|
|
84
|
+
var SwitchThumb = _react.forwardRef.call(void 0, function SwitchThumb2({
|
|
85
|
+
children,
|
|
86
|
+
animation = true,
|
|
87
|
+
style,
|
|
88
|
+
...props
|
|
89
|
+
}, ref) {
|
|
90
|
+
const {
|
|
91
|
+
thumbStyle,
|
|
92
|
+
thumb,
|
|
93
|
+
travel,
|
|
94
|
+
isSelected
|
|
95
|
+
} = useSwitch();
|
|
96
|
+
const [styleProps, rest] = _chunkTK44VBIEcjs.useStyleProps.call(void 0, props);
|
|
97
|
+
const base = [thumbStyle, styleProps, style];
|
|
98
|
+
const distance = _reactnative.I18nManager.isRTL ? -travel : travel;
|
|
99
|
+
if (!animation) {
|
|
100
|
+
return /* @__PURE__ */_jsxruntime.jsx.call(void 0, _reactnative.View, {
|
|
101
|
+
ref,
|
|
102
|
+
...rest,
|
|
103
|
+
style: [base, {
|
|
104
|
+
backgroundColor: isSelected ? thumb.on : thumb.off,
|
|
105
|
+
transform: [{
|
|
106
|
+
translateX: isSelected ? distance : 0
|
|
107
|
+
}]
|
|
108
|
+
}],
|
|
109
|
+
children
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
return /* @__PURE__ */_jsxruntime.jsx.call(void 0, SlidingThumb, {
|
|
113
|
+
ref,
|
|
114
|
+
style: base,
|
|
115
|
+
colors: thumb,
|
|
116
|
+
distance,
|
|
117
|
+
isSelected,
|
|
118
|
+
...rest,
|
|
119
|
+
children
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
SwitchThumb.displayName = "XAUI.Switch.Thumb";
|
|
123
|
+
const _worklet_10975315955288_init_data = {
|
|
124
|
+
code: "function chunkDA3OKXHVCjs1(){const{_reactnativereanimated,isSelected,SWITCH_DURATION}=this.__closure;return _reactnativereanimated.withTiming.call(void 0,isSelected?1:0,{duration:SWITCH_DURATION});}",
|
|
125
|
+
location: "/home/runner/work/xaui/xaui/packages/native/dist/chunk-DA3OKXHV.cjs",
|
|
126
|
+
sourceMap: "{\"version\":3,\"names\":[\"chunkDA3OKXHVCjs1\",\"_reactnativereanimated\",\"isSelected\",\"SWITCH_DURATION\",\"__closure\",\"withTiming\",\"call\",\"duration\"],\"sources\":[\"/home/runner/work/xaui/xaui/packages/native/dist/chunk-DA3OKXHV.cjs\"],\"mappings\":\"AA4FuE,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\":[]}"
|
|
127
|
+
};
|
|
128
|
+
const _worklet_3751124314066_init_data = {
|
|
129
|
+
code: "function chunkDA3OKXHVCjs2(){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])};}",
|
|
130
|
+
location: "/home/runner/work/xaui/xaui/packages/native/dist/chunk-DA3OKXHV.cjs",
|
|
131
|
+
sourceMap: "{\"version\":3,\"names\":[\"chunkDA3OKXHVCjs2\",\"progress\",\"distance\",\"_reactnativereanimated\",\"colors\",\"__closure\",\"transform\",\"translateX\",\"value\",\"backgroundColor\",\"interpolateColor\",\"call\",\"off\",\"on\"],\"sources\":[\"/home/runner/work/xaui/xaui/packages/native/dist/chunk-DA3OKXHV.cjs\"],\"mappings\":\"AAgG6E,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\":[]}"
|
|
132
|
+
};
|
|
133
|
+
var SlidingThumb = _react.forwardRef.call(void 0, function SlidingThumb2({
|
|
134
|
+
style,
|
|
135
|
+
colors,
|
|
136
|
+
distance,
|
|
137
|
+
isSelected,
|
|
138
|
+
children,
|
|
139
|
+
...rest
|
|
140
|
+
}, ref) {
|
|
141
|
+
const progress = _reactnativereanimated.useDerivedValue.call(void 0, function chunkDA3OKXHVCjs1Factory({
|
|
142
|
+
_worklet_10975315955288_init_data,
|
|
143
|
+
_reactnativereanimated,
|
|
144
|
+
isSelected,
|
|
145
|
+
SWITCH_DURATION
|
|
146
|
+
}) {
|
|
147
|
+
const _e = [new global.Error(), -4, -27];
|
|
148
|
+
const chunkDA3OKXHVCjs1 = function () {
|
|
149
|
+
return _reactnativereanimated.withTiming.call(void 0, isSelected ? 1 : 0, {
|
|
150
|
+
duration: SWITCH_DURATION
|
|
151
|
+
});
|
|
152
|
+
};
|
|
153
|
+
chunkDA3OKXHVCjs1.__closure = {
|
|
154
|
+
_reactnativereanimated,
|
|
155
|
+
isSelected,
|
|
156
|
+
SWITCH_DURATION
|
|
157
|
+
};
|
|
158
|
+
chunkDA3OKXHVCjs1.__workletHash = 10975315955288;
|
|
159
|
+
chunkDA3OKXHVCjs1.__pluginVersion = "0.7.4";
|
|
160
|
+
chunkDA3OKXHVCjs1.__initData = _worklet_10975315955288_init_data;
|
|
161
|
+
chunkDA3OKXHVCjs1.__stackDetails = _e;
|
|
162
|
+
return chunkDA3OKXHVCjs1;
|
|
163
|
+
}({
|
|
164
|
+
_worklet_10975315955288_init_data,
|
|
165
|
+
_reactnativereanimated,
|
|
166
|
+
isSelected,
|
|
167
|
+
SWITCH_DURATION
|
|
168
|
+
}), [isSelected]);
|
|
169
|
+
const animatedStyle = _reactnativereanimated.useAnimatedStyle.call(void 0, function chunkDA3OKXHVCjs2Factory({
|
|
170
|
+
_worklet_3751124314066_init_data,
|
|
171
|
+
progress,
|
|
172
|
+
distance,
|
|
173
|
+
_reactnativereanimated,
|
|
174
|
+
colors
|
|
175
|
+
}) {
|
|
176
|
+
const _e = [new global.Error(), -5, -27];
|
|
177
|
+
const chunkDA3OKXHVCjs2 = function () {
|
|
178
|
+
return {
|
|
179
|
+
transform: [{
|
|
180
|
+
translateX: progress.value * distance
|
|
181
|
+
}],
|
|
182
|
+
backgroundColor: _reactnativereanimated.interpolateColor.call(void 0, progress.value, [0, 1], [colors.off, colors.on])
|
|
183
|
+
};
|
|
184
|
+
};
|
|
185
|
+
chunkDA3OKXHVCjs2.__closure = {
|
|
186
|
+
progress,
|
|
187
|
+
distance,
|
|
188
|
+
_reactnativereanimated,
|
|
189
|
+
colors
|
|
190
|
+
};
|
|
191
|
+
chunkDA3OKXHVCjs2.__workletHash = 3751124314066;
|
|
192
|
+
chunkDA3OKXHVCjs2.__pluginVersion = "0.7.4";
|
|
193
|
+
chunkDA3OKXHVCjs2.__initData = _worklet_3751124314066_init_data;
|
|
194
|
+
chunkDA3OKXHVCjs2.__stackDetails = _e;
|
|
195
|
+
return chunkDA3OKXHVCjs2;
|
|
196
|
+
}({
|
|
197
|
+
_worklet_3751124314066_init_data,
|
|
198
|
+
progress,
|
|
199
|
+
distance,
|
|
200
|
+
_reactnativereanimated,
|
|
201
|
+
colors
|
|
202
|
+
}), [progress, distance, colors.off, colors.on]);
|
|
203
|
+
return /* @__PURE__ */_jsxruntime.jsx.call(void 0, _reactnativereanimated2.default.View, {
|
|
204
|
+
ref,
|
|
205
|
+
...rest,
|
|
206
|
+
style: [style, animatedStyle],
|
|
207
|
+
children
|
|
208
|
+
});
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
// src/components/switch/switch-track.tsx
|
|
212
|
+
|
|
213
|
+
var SwitchTrack = _react.forwardRef.call(void 0, function SwitchTrack2({
|
|
214
|
+
children,
|
|
215
|
+
animation = true,
|
|
216
|
+
style,
|
|
217
|
+
...props
|
|
218
|
+
}, ref) {
|
|
219
|
+
const {
|
|
220
|
+
trackStyle,
|
|
221
|
+
track,
|
|
222
|
+
isSelected
|
|
223
|
+
} = useSwitch();
|
|
224
|
+
const [styleProps, rest] = _chunkTK44VBIEcjs.useStyleProps.call(void 0, props);
|
|
225
|
+
const base = [trackStyle, styleProps, style];
|
|
226
|
+
if (!animation) {
|
|
227
|
+
return /* @__PURE__ */_jsxruntime.jsx.call(void 0, _reactnative.View, {
|
|
228
|
+
ref,
|
|
229
|
+
...rest,
|
|
230
|
+
style: [base, {
|
|
231
|
+
backgroundColor: isSelected ? track.on : track.off
|
|
232
|
+
}],
|
|
233
|
+
children
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
return /* @__PURE__ */_jsxruntime.jsx.call(void 0, CrossfadingTrack, {
|
|
237
|
+
ref,
|
|
238
|
+
style: base,
|
|
239
|
+
colors: track,
|
|
240
|
+
isSelected,
|
|
241
|
+
...rest,
|
|
242
|
+
children
|
|
243
|
+
});
|
|
244
|
+
});
|
|
245
|
+
SwitchTrack.displayName = "XAUI.Switch.Track";
|
|
246
|
+
const _worklet_1509738733082_init_data = {
|
|
247
|
+
code: "function chunkDA3OKXHVCjs3(){const{_reactnativereanimated,isSelected,SWITCH_DURATION}=this.__closure;return _reactnativereanimated.withTiming.call(void 0,isSelected?1:0,{duration:SWITCH_DURATION});}",
|
|
248
|
+
location: "/home/runner/work/xaui/xaui/packages/native/dist/chunk-DA3OKXHV.cjs",
|
|
249
|
+
sourceMap: "{\"version\":3,\"names\":[\"chunkDA3OKXHVCjs3\",\"_reactnativereanimated\",\"isSelected\",\"SWITCH_DURATION\",\"__closure\",\"withTiming\",\"call\",\"duration\"],\"sources\":[\"/home/runner/work/xaui/xaui/packages/native/dist/chunk-DA3OKXHV.cjs\"],\"mappings\":\"AAqJuE,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\":[]}"
|
|
250
|
+
};
|
|
251
|
+
const _worklet_12850558082612_init_data = {
|
|
252
|
+
code: "function chunkDA3OKXHVCjs4(){const{_reactnativereanimated,progress,colors}=this.__closure;return{backgroundColor:_reactnativereanimated.interpolateColor.call(void 0,progress.value,[0,1],[colors.off,colors.on])};}",
|
|
253
|
+
location: "/home/runner/work/xaui/xaui/packages/native/dist/chunk-DA3OKXHV.cjs",
|
|
254
|
+
sourceMap: "{\"version\":3,\"names\":[\"chunkDA3OKXHVCjs4\",\"_reactnativereanimated\",\"progress\",\"colors\",\"__closure\",\"backgroundColor\",\"interpolateColor\",\"call\",\"value\",\"off\",\"on\"],\"sources\":[\"/home/runner/work/xaui/xaui/packages/native/dist/chunk-DA3OKXHV.cjs\"],\"mappings\":\"AAyJ6E,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\":[]}"
|
|
255
|
+
};
|
|
256
|
+
var CrossfadingTrack = _react.forwardRef.call(void 0, function CrossfadingTrack2({
|
|
257
|
+
style,
|
|
258
|
+
colors,
|
|
259
|
+
isSelected,
|
|
260
|
+
children,
|
|
261
|
+
...rest
|
|
262
|
+
}, ref) {
|
|
263
|
+
const progress = _reactnativereanimated.useDerivedValue.call(void 0, function chunkDA3OKXHVCjs3Factory({
|
|
264
|
+
_worklet_1509738733082_init_data,
|
|
265
|
+
_reactnativereanimated,
|
|
266
|
+
isSelected,
|
|
267
|
+
SWITCH_DURATION
|
|
268
|
+
}) {
|
|
269
|
+
const _e = [new global.Error(), -4, -27];
|
|
270
|
+
const chunkDA3OKXHVCjs3 = function () {
|
|
271
|
+
return _reactnativereanimated.withTiming.call(void 0, isSelected ? 1 : 0, {
|
|
272
|
+
duration: SWITCH_DURATION
|
|
273
|
+
});
|
|
274
|
+
};
|
|
275
|
+
chunkDA3OKXHVCjs3.__closure = {
|
|
276
|
+
_reactnativereanimated,
|
|
277
|
+
isSelected,
|
|
278
|
+
SWITCH_DURATION
|
|
279
|
+
};
|
|
280
|
+
chunkDA3OKXHVCjs3.__workletHash = 1509738733082;
|
|
281
|
+
chunkDA3OKXHVCjs3.__pluginVersion = "0.7.4";
|
|
282
|
+
chunkDA3OKXHVCjs3.__initData = _worklet_1509738733082_init_data;
|
|
283
|
+
chunkDA3OKXHVCjs3.__stackDetails = _e;
|
|
284
|
+
return chunkDA3OKXHVCjs3;
|
|
285
|
+
}({
|
|
286
|
+
_worklet_1509738733082_init_data,
|
|
287
|
+
_reactnativereanimated,
|
|
288
|
+
isSelected,
|
|
289
|
+
SWITCH_DURATION
|
|
290
|
+
}), [isSelected]);
|
|
291
|
+
const animatedStyle = _reactnativereanimated.useAnimatedStyle.call(void 0, function chunkDA3OKXHVCjs4Factory({
|
|
292
|
+
_worklet_12850558082612_init_data,
|
|
293
|
+
_reactnativereanimated,
|
|
294
|
+
progress,
|
|
295
|
+
colors
|
|
296
|
+
}) {
|
|
297
|
+
const _e = [new global.Error(), -4, -27];
|
|
298
|
+
const chunkDA3OKXHVCjs4 = function () {
|
|
299
|
+
return {
|
|
300
|
+
backgroundColor: _reactnativereanimated.interpolateColor.call(void 0, progress.value, [0, 1], [colors.off, colors.on])
|
|
301
|
+
};
|
|
302
|
+
};
|
|
303
|
+
chunkDA3OKXHVCjs4.__closure = {
|
|
304
|
+
_reactnativereanimated,
|
|
305
|
+
progress,
|
|
306
|
+
colors
|
|
307
|
+
};
|
|
308
|
+
chunkDA3OKXHVCjs4.__workletHash = 12850558082612;
|
|
309
|
+
chunkDA3OKXHVCjs4.__pluginVersion = "0.7.4";
|
|
310
|
+
chunkDA3OKXHVCjs4.__initData = _worklet_12850558082612_init_data;
|
|
311
|
+
chunkDA3OKXHVCjs4.__stackDetails = _e;
|
|
312
|
+
return chunkDA3OKXHVCjs4;
|
|
313
|
+
}({
|
|
314
|
+
_worklet_12850558082612_init_data,
|
|
315
|
+
_reactnativereanimated,
|
|
316
|
+
progress,
|
|
317
|
+
colors
|
|
318
|
+
}), [progress, colors.off, colors.on]);
|
|
319
|
+
return /* @__PURE__ */_jsxruntime.jsx.call(void 0, _reactnativereanimated2.default.View, {
|
|
320
|
+
ref,
|
|
321
|
+
...rest,
|
|
322
|
+
style: [style, animatedStyle],
|
|
323
|
+
children
|
|
324
|
+
});
|
|
325
|
+
});
|
|
326
|
+
|
|
327
|
+
// src/components/switch/switch.tsx
|
|
328
|
+
|
|
329
|
+
// src/components/switch/switch.recipe.ts
|
|
330
|
+
var SLOTS = ["root", "track", "trackSelected", "thumb", "thumbSelected", "label"];
|
|
331
|
+
var VARIANT_TOKENS = {
|
|
332
|
+
primary: {
|
|
333
|
+
bg: "default",
|
|
334
|
+
fg: "white",
|
|
335
|
+
bgSelected: "accent",
|
|
336
|
+
fgSelected: "accentForeground"
|
|
337
|
+
},
|
|
338
|
+
secondary: {
|
|
339
|
+
bg: "default",
|
|
340
|
+
fg: "white",
|
|
341
|
+
bgSelected: "accent",
|
|
342
|
+
fgSelected: "accentForeground"
|
|
343
|
+
}
|
|
344
|
+
};
|
|
345
|
+
function sizeAxis(step) {
|
|
346
|
+
const {
|
|
347
|
+
track,
|
|
348
|
+
height,
|
|
349
|
+
thumb,
|
|
350
|
+
padding,
|
|
351
|
+
gap,
|
|
352
|
+
label
|
|
353
|
+
} = step;
|
|
354
|
+
return theme => {
|
|
355
|
+
const trackHeight = theme.spacing(height);
|
|
356
|
+
const knob = theme.spacing(thumb);
|
|
357
|
+
return {
|
|
358
|
+
root: {
|
|
359
|
+
gap: theme.spacing(gap)
|
|
360
|
+
},
|
|
361
|
+
track: {
|
|
362
|
+
width: theme.spacing(track),
|
|
363
|
+
height: trackHeight
|
|
364
|
+
},
|
|
365
|
+
thumb: {
|
|
366
|
+
width: knob,
|
|
367
|
+
height: knob,
|
|
368
|
+
// `start`, never `left` (R13): the knob rests at the leading edge, and RTL mirrors
|
|
369
|
+
// the logical property and only it.
|
|
370
|
+
start: theme.spacing(padding),
|
|
371
|
+
top: (trackHeight - knob) / 2
|
|
372
|
+
},
|
|
373
|
+
label: {
|
|
374
|
+
fontSize: theme.fontSizes[label],
|
|
375
|
+
lineHeight: theme.lineHeights[label]
|
|
376
|
+
}
|
|
377
|
+
};
|
|
378
|
+
};
|
|
379
|
+
}
|
|
380
|
+
var INSIDE = {
|
|
381
|
+
sm: {
|
|
382
|
+
track: 11,
|
|
383
|
+
height: 6.5,
|
|
384
|
+
thumb: 5,
|
|
385
|
+
padding: 0.75,
|
|
386
|
+
gap: 2,
|
|
387
|
+
label: "sm"
|
|
388
|
+
},
|
|
389
|
+
md: {
|
|
390
|
+
track: 12,
|
|
391
|
+
height: 7,
|
|
392
|
+
thumb: 5.5,
|
|
393
|
+
padding: 0.75,
|
|
394
|
+
gap: 2,
|
|
395
|
+
label: "md"
|
|
396
|
+
},
|
|
397
|
+
lg: {
|
|
398
|
+
track: 14,
|
|
399
|
+
height: 8,
|
|
400
|
+
thumb: 6.5,
|
|
401
|
+
padding: 0.75,
|
|
402
|
+
gap: 2.5,
|
|
403
|
+
label: "lg"
|
|
404
|
+
}
|
|
405
|
+
};
|
|
406
|
+
var OVERLAP = {
|
|
407
|
+
sm: {
|
|
408
|
+
track: 11,
|
|
409
|
+
height: 4.5,
|
|
410
|
+
thumb: 6,
|
|
411
|
+
padding: 0,
|
|
412
|
+
gap: 2,
|
|
413
|
+
label: "sm"
|
|
414
|
+
},
|
|
415
|
+
md: {
|
|
416
|
+
track: 12,
|
|
417
|
+
height: 4.5,
|
|
418
|
+
thumb: 6.5,
|
|
419
|
+
padding: 0,
|
|
420
|
+
gap: 2,
|
|
421
|
+
label: "md"
|
|
422
|
+
},
|
|
423
|
+
lg: {
|
|
424
|
+
track: 14,
|
|
425
|
+
height: 5,
|
|
426
|
+
thumb: 7.5,
|
|
427
|
+
padding: 0,
|
|
428
|
+
gap: 2.5,
|
|
429
|
+
label: "lg"
|
|
430
|
+
}
|
|
431
|
+
};
|
|
432
|
+
var switchRecipe = _chunkFNEUOBCVcjs.createRecipe.call(void 0, {
|
|
433
|
+
slots: SLOTS,
|
|
434
|
+
base: theme => ({
|
|
435
|
+
root: {
|
|
436
|
+
flexDirection: "row",
|
|
437
|
+
alignItems: "center",
|
|
438
|
+
alignSelf: "flex-start"
|
|
439
|
+
},
|
|
440
|
+
track: {
|
|
441
|
+
borderRadius: theme.radius.full,
|
|
442
|
+
borderCurve: "continuous",
|
|
443
|
+
// Never `hidden`: on `secondary` the thumb stands outside the track, and clipping it
|
|
444
|
+
// would cut the knob in half rather than let it overlap.
|
|
445
|
+
overflow: "visible"
|
|
446
|
+
},
|
|
447
|
+
thumb: {
|
|
448
|
+
position: "absolute",
|
|
449
|
+
borderRadius: theme.radius.full,
|
|
450
|
+
alignItems: "center",
|
|
451
|
+
justifyContent: "center",
|
|
452
|
+
// The knob is the thing that moves, and a shadow is what says so.
|
|
453
|
+
...theme.shadows.field
|
|
454
|
+
},
|
|
455
|
+
label: {
|
|
456
|
+
fontFamily: theme.fontFamilies.body,
|
|
457
|
+
color: theme.colors.foreground
|
|
458
|
+
}
|
|
459
|
+
}),
|
|
460
|
+
variantTokens: VARIANT_TOKENS,
|
|
461
|
+
/**
|
|
462
|
+
* Four colours on four slots, and the two `*Selected` ones exist to be **flattened into
|
|
463
|
+
* values** rather than rendered: the track crosses from one to the other and the thumb
|
|
464
|
+
* with it, which is an interpolation on the UI thread rather than a style swap.
|
|
465
|
+
*
|
|
466
|
+
* They are roles for the reason the `Checkbox`'s are: the tint pass re-runs `paint` and
|
|
467
|
+
* never the axes, so this is what makes `color` the colour the switch turns on to.
|
|
468
|
+
*/
|
|
469
|
+
paint: (_theme, colors) => ({
|
|
470
|
+
track: {
|
|
471
|
+
backgroundColor: colors.bg
|
|
472
|
+
},
|
|
473
|
+
trackSelected: {
|
|
474
|
+
backgroundColor: colors.bgSelected
|
|
475
|
+
},
|
|
476
|
+
thumb: {
|
|
477
|
+
backgroundColor: colors.fg
|
|
478
|
+
},
|
|
479
|
+
thumbSelected: {
|
|
480
|
+
backgroundColor: colors.fgSelected
|
|
481
|
+
}
|
|
482
|
+
}),
|
|
483
|
+
variants: {
|
|
484
|
+
/**
|
|
485
|
+
* Declared and empty, which is unusual and deliberate: **every** number of this
|
|
486
|
+
* component depends on the shape as well as the size, so the whole table lives in the
|
|
487
|
+
* compounds below. The axis is here because the selection needs it to be typed, and
|
|
488
|
+
* because a reader looking for "what does `size` do" should find the answer next to
|
|
489
|
+
* the other axes rather than infer it from an absence.
|
|
490
|
+
*/
|
|
491
|
+
size: {
|
|
492
|
+
sm: () => ({}),
|
|
493
|
+
md: () => ({}),
|
|
494
|
+
lg: () => ({})
|
|
495
|
+
},
|
|
496
|
+
/**
|
|
497
|
+
* Both, always together: a track that lost its capsule while the knob kept its circle
|
|
498
|
+
* is a control rounded by halves. The knob's corner is the same named value rather
|
|
499
|
+
* than the track's less the padding — that nesting rule reaches zero before the outer
|
|
500
|
+
* radius does, and a sharp knob inside a slightly rounded track looks like a mistake.
|
|
501
|
+
*/
|
|
502
|
+
radius: _chunkFNEUOBCVcjs.radiusAxis.call(void 0, "track", "thumb")
|
|
503
|
+
},
|
|
504
|
+
/** The six geometries — two shapes, three sizes — and nothing else. */
|
|
505
|
+
compoundVariants: [{
|
|
506
|
+
when: {
|
|
507
|
+
variant: "primary",
|
|
508
|
+
size: "sm"
|
|
509
|
+
},
|
|
510
|
+
style: sizeAxis(INSIDE.sm)
|
|
511
|
+
}, {
|
|
512
|
+
when: {
|
|
513
|
+
variant: "primary",
|
|
514
|
+
size: "md"
|
|
515
|
+
},
|
|
516
|
+
style: sizeAxis(INSIDE.md)
|
|
517
|
+
}, {
|
|
518
|
+
when: {
|
|
519
|
+
variant: "primary",
|
|
520
|
+
size: "lg"
|
|
521
|
+
},
|
|
522
|
+
style: sizeAxis(INSIDE.lg)
|
|
523
|
+
}, {
|
|
524
|
+
when: {
|
|
525
|
+
variant: "secondary",
|
|
526
|
+
size: "sm"
|
|
527
|
+
},
|
|
528
|
+
style: sizeAxis(OVERLAP.sm)
|
|
529
|
+
}, {
|
|
530
|
+
when: {
|
|
531
|
+
variant: "secondary",
|
|
532
|
+
size: "md"
|
|
533
|
+
},
|
|
534
|
+
style: sizeAxis(OVERLAP.md)
|
|
535
|
+
}, {
|
|
536
|
+
when: {
|
|
537
|
+
variant: "secondary",
|
|
538
|
+
size: "lg"
|
|
539
|
+
},
|
|
540
|
+
style: sizeAxis(OVERLAP.lg)
|
|
541
|
+
}],
|
|
542
|
+
states: {
|
|
543
|
+
disabled: theme => ({
|
|
544
|
+
root: {
|
|
545
|
+
opacity: theme.opacity.disabled
|
|
546
|
+
}
|
|
547
|
+
})
|
|
548
|
+
},
|
|
549
|
+
defaultVariants: {
|
|
550
|
+
variant: "primary",
|
|
551
|
+
size: "md"
|
|
552
|
+
}
|
|
553
|
+
});
|
|
554
|
+
|
|
555
|
+
// src/components/switch/switch.tsx
|
|
556
|
+
|
|
557
|
+
var SwitchRoot = _react.forwardRef.call(void 0, function Switch({
|
|
558
|
+
children,
|
|
559
|
+
variant,
|
|
560
|
+
size,
|
|
561
|
+
radius,
|
|
562
|
+
color,
|
|
563
|
+
isSelected,
|
|
564
|
+
defaultSelected = false,
|
|
565
|
+
onSelectedChange,
|
|
566
|
+
isDisabled = false,
|
|
567
|
+
asChild = false,
|
|
568
|
+
accessibilityRole,
|
|
569
|
+
accessibilityState,
|
|
570
|
+
animation,
|
|
571
|
+
style,
|
|
572
|
+
onPress,
|
|
573
|
+
onPressIn,
|
|
574
|
+
onPressOut,
|
|
575
|
+
...props
|
|
576
|
+
}, ref) {
|
|
577
|
+
const theme = _chunk57SJ4LJFcjs.useXAUITheme.call(void 0);
|
|
578
|
+
const [styleProps, rest] = _chunkTK44VBIEcjs.useStyleProps.call(void 0, props);
|
|
579
|
+
const [isPressed, press] = _chunk7DPL3ZDScjs.usePressState.call(void 0, {
|
|
580
|
+
onPressIn,
|
|
581
|
+
onPressOut
|
|
582
|
+
});
|
|
583
|
+
const [selected, setSelected] = _chunk7EIHHOHPcjs.useControllableState.call(void 0, {
|
|
584
|
+
value: isSelected,
|
|
585
|
+
defaultValue: defaultSelected,
|
|
586
|
+
onChange: onSelectedChange
|
|
587
|
+
});
|
|
588
|
+
const handlePress = _react.useCallback.call(void 0, event => {
|
|
589
|
+
setSelected(current => !current);
|
|
590
|
+
_optionalChain([onPress, 'optionalCall', _ => _(event)]);
|
|
591
|
+
}, [setSelected, onPress]);
|
|
592
|
+
const selection = {
|
|
593
|
+
variant,
|
|
594
|
+
size,
|
|
595
|
+
radius
|
|
596
|
+
};
|
|
597
|
+
const states = {
|
|
598
|
+
pressed: isPressed,
|
|
599
|
+
disabled: isDisabled
|
|
600
|
+
};
|
|
601
|
+
const styles = switchRecipe.resolve({
|
|
602
|
+
theme,
|
|
603
|
+
selection,
|
|
604
|
+
states
|
|
605
|
+
});
|
|
606
|
+
const tint = color ? switchRecipe.tint({
|
|
607
|
+
theme,
|
|
608
|
+
color,
|
|
609
|
+
selection,
|
|
610
|
+
states
|
|
611
|
+
}) : void 0;
|
|
612
|
+
const context = _react.useMemo.call(void 0, () => {
|
|
613
|
+
const track = _reactnative.StyleSheet.flatten(styles.track);
|
|
614
|
+
const thumb = _reactnative.StyleSheet.flatten(styles.thumb);
|
|
615
|
+
return {
|
|
616
|
+
trackStyle: styles.track,
|
|
617
|
+
thumbStyle: styles.thumb,
|
|
618
|
+
labelStyle: styles.label,
|
|
619
|
+
// Values, not styles: the two ends of a colour that is crossed on the UI thread.
|
|
620
|
+
// The tint moves the "on" end alone — the track at rest keeps its neutral, because
|
|
621
|
+
// a switch that is off is off in every brand.
|
|
622
|
+
track: {
|
|
623
|
+
off: colorOf(track),
|
|
624
|
+
on: colorOf(_reactnative.StyleSheet.flatten([styles.trackSelected, _optionalChain([tint, 'optionalAccess', _2 => _2.trackSelected])]))
|
|
625
|
+
},
|
|
626
|
+
thumb: {
|
|
627
|
+
off: colorOf(thumb),
|
|
628
|
+
on: colorOf(_reactnative.StyleSheet.flatten([styles.thumbSelected, _optionalChain([tint, 'optionalAccess', _3 => _3.thumbSelected])]))
|
|
629
|
+
},
|
|
630
|
+
// The distance the knob slides, and the one number the recipe cannot write: it is
|
|
631
|
+
// the track's width less the thumb and the padding at both ends, and it has to be a
|
|
632
|
+
// number rather than a style because the slide happens in a worklet.
|
|
633
|
+
travel: travelOf(track, thumb),
|
|
634
|
+
isSelected: selected,
|
|
635
|
+
isDisabled
|
|
636
|
+
};
|
|
637
|
+
}, [styles, tint, selected, isDisabled]);
|
|
638
|
+
const rootStyle = [styles.root, styleProps, typeof style === "function" ? style({
|
|
639
|
+
pressed: isPressed
|
|
640
|
+
}) : style];
|
|
641
|
+
const text = _chunk7GHM4GKLcjs.childrenToString.call(void 0, children);
|
|
642
|
+
const content = text !== null ? /* @__PURE__ */_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, {
|
|
643
|
+
children: [/* @__PURE__ */_jsxruntime.jsx.call(void 0, SwitchTrack, {
|
|
644
|
+
children: /* @__PURE__ */_jsxruntime.jsx.call(void 0, SwitchThumb, {})
|
|
645
|
+
}), /* @__PURE__ */_jsxruntime.jsx.call(void 0, SwitchLabel, {
|
|
646
|
+
children: text
|
|
647
|
+
})]
|
|
648
|
+
}) : _nullishCoalesce(children, () => (/* @__PURE__ */_jsxruntime.jsx.call(void 0, SwitchTrack, {
|
|
649
|
+
children: /* @__PURE__ */_jsxruntime.jsx.call(void 0, SwitchThumb, {})
|
|
650
|
+
})));
|
|
651
|
+
return /* @__PURE__ */_jsxruntime.jsx.call(void 0, SwitchProvider, {
|
|
652
|
+
value: context,
|
|
653
|
+
children: /* @__PURE__ */_jsxruntime.jsx.call(void 0, _chunk3E7CDKFOcjs.PressableFeedback, {
|
|
654
|
+
ref,
|
|
655
|
+
isPressed,
|
|
656
|
+
isDisabled,
|
|
657
|
+
asChild,
|
|
658
|
+
animation,
|
|
659
|
+
accessibilityRole: _nullishCoalesce(accessibilityRole, () => "switch"),
|
|
660
|
+
accessibilityState: {
|
|
661
|
+
checked: selected,
|
|
662
|
+
disabled: isDisabled,
|
|
663
|
+
...accessibilityState
|
|
664
|
+
},
|
|
665
|
+
...rest,
|
|
666
|
+
style: rootStyle,
|
|
667
|
+
onPress: handlePress,
|
|
668
|
+
onPressIn: press.onPressIn,
|
|
669
|
+
onPressOut: press.onPressOut,
|
|
670
|
+
children: asChild ? children : content
|
|
671
|
+
})
|
|
672
|
+
});
|
|
673
|
+
});
|
|
674
|
+
SwitchRoot.displayName = "XAUI.Switch.Root";
|
|
675
|
+
function colorOf(style) {
|
|
676
|
+
return typeof style.backgroundColor === "string" ? style.backgroundColor : "";
|
|
677
|
+
}
|
|
678
|
+
function travelOf(track, thumb) {
|
|
679
|
+
const width = pointsOf(track.width);
|
|
680
|
+
const knob = pointsOf(thumb.width);
|
|
681
|
+
const inset = pointsOf(thumb.start);
|
|
682
|
+
return Math.max(width - knob - inset * 2, 0);
|
|
683
|
+
}
|
|
684
|
+
function pointsOf(value) {
|
|
685
|
+
return typeof value === "number" ? value : 0;
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
// src/components/switch/index.ts
|
|
689
|
+
var Switch2 = Object.assign(SwitchRoot, {
|
|
690
|
+
Track: SwitchTrack,
|
|
691
|
+
Thumb: SwitchThumb,
|
|
692
|
+
Label: SwitchLabel
|
|
693
|
+
});
|
|
694
|
+
exports.useSwitch = useSwitch;
|
|
695
|
+
exports.SwitchLabel = SwitchLabel;
|
|
696
|
+
exports.SwitchThumb = SwitchThumb;
|
|
697
|
+
exports.SwitchTrack = SwitchTrack;
|
|
698
|
+
exports.switchRecipe = switchRecipe;
|
|
699
|
+
exports.SwitchRoot = SwitchRoot;
|
|
700
|
+
exports.Switch = Switch2;
|