@tamagui/switch 1.135.4 → 1.135.6
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/cjs/StyledContext.native.js +22 -18
- package/dist/cjs/StyledContext.native.js.map +1 -6
- package/dist/cjs/Switch.native.js +82 -73
- package/dist/cjs/Switch.native.js.map +1 -6
- package/dist/cjs/createSwitch.cjs +1 -1
- package/dist/cjs/createSwitch.js +1 -1
- package/dist/cjs/createSwitch.js.map +1 -1
- package/dist/cjs/createSwitch.native.js +168 -111
- package/dist/cjs/createSwitch.native.js.map +1 -6
- package/dist/cjs/index.native.js +23 -21
- package/dist/cjs/index.native.js.map +1 -6
- package/dist/jsx/StyledContext.native.js +32 -8
- package/dist/jsx/StyledContext.native.js.map +1 -6
- package/dist/jsx/Switch.native.js +94 -66
- package/dist/jsx/Switch.native.js.map +1 -6
- package/dist/jsx/createSwitch.native.js +186 -108
- package/dist/jsx/createSwitch.native.js.map +1 -6
- package/dist/jsx/index.native.js +37 -12
- package/dist/jsx/index.native.js.map +1 -6
- package/package.json +14 -13
|
@@ -1,29 +1,33 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
7
|
var __export = (target, all) => {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
8
|
+
for (var name in all) __defProp(target, name, {
|
|
9
|
+
get: all[name],
|
|
10
|
+
enumerable: !0
|
|
11
|
+
});
|
|
12
|
+
},
|
|
13
|
+
__copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
|
|
15
|
+
get: () => from[key],
|
|
16
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
|
+
});
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
21
|
+
value: !0
|
|
22
|
+
}), mod);
|
|
16
23
|
var StyledContext_exports = {};
|
|
17
24
|
__export(StyledContext_exports, {
|
|
18
25
|
SwitchStyledContext: () => SwitchStyledContext
|
|
19
26
|
});
|
|
20
27
|
module.exports = __toCommonJS(StyledContext_exports);
|
|
21
|
-
var import_core = require("@tamagui/core"),
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
SwitchStyledContext
|
|
28
|
-
});
|
|
29
|
-
//# sourceMappingURL=StyledContext.js.map
|
|
28
|
+
var import_core = require("@tamagui/core"),
|
|
29
|
+
SwitchStyledContext = (0, import_core.createStyledContext)({
|
|
30
|
+
size: void 0,
|
|
31
|
+
unstyled: process.env.TAMAGUI_HEADLESS === "1"
|
|
32
|
+
});
|
|
33
|
+
//# sourceMappingURL=StyledContext.native.js.map
|
|
@@ -1,6 +1 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/StyledContext.tsx"],
|
|
4
|
-
"mappings": ";;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAoC,0BACzB,0BAAsB,iCAAoB;AAAA,EACjD,MAAM;AAAA,EACN,UAAU,QAAQ,IAAI,qBAAqB;AAC/C,CAAC;",
|
|
5
|
-
"names": []
|
|
6
|
-
}
|
|
1
|
+
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","StyledContext_exports","__export","SwitchStyledContext","module","exports","import_core","require","createStyledContext","size","unstyled","process","env","TAMAGUI_HEADLESS"],"sources":["../../src/StyledContext.tsx"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,qBAAA;AAAAC,QAAA,CAAAD,qBAAA;EAAAE,mBAAA,EAAAA,CAAA,KAAAA;AAAA;AACAC,MAAA,CAAAC,OAAA,GAAAT,YAAoC,CAAAK,qBAAA;AAE7B,IAAAK,WAAM,GAAAC,OAAA,gBAAsB;EAAAJ,mBAAA,GAGhC,IAAAG,WAAA,CAAAE,mBAAA;IACDC,IAAA,EAAM;IACNC,QAAA,EAAUC,OAAA,CAAQC,GAAA,CAAIC,gBAAA,KAAqB;EAC7C,CAAC","ignoreList":[]}
|
|
@@ -1,93 +1,102 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
7
|
var __export = (target, all) => {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
8
|
+
for (var name in all) __defProp(target, name, {
|
|
9
|
+
get: all[name],
|
|
10
|
+
enumerable: !0
|
|
11
|
+
});
|
|
12
|
+
},
|
|
13
|
+
__copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
|
|
15
|
+
get: () => from[key],
|
|
16
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
|
+
});
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
21
|
+
value: !0
|
|
22
|
+
}), mod);
|
|
16
23
|
var Switch_exports = {};
|
|
17
24
|
__export(Switch_exports, {
|
|
18
25
|
SwitchFrame: () => SwitchFrame,
|
|
19
26
|
SwitchThumb: () => SwitchThumb
|
|
20
27
|
});
|
|
21
28
|
module.exports = __toCommonJS(Switch_exports);
|
|
22
|
-
var import_core = require("@tamagui/core"),
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
29
|
+
var import_core = require("@tamagui/core"),
|
|
30
|
+
import_get_token = require("@tamagui/get-token"),
|
|
31
|
+
import_stacks = require("@tamagui/stacks"),
|
|
32
|
+
SwitchThumb = (0, import_core.styled)(import_stacks.ThemeableStack, {
|
|
33
|
+
name: "SwitchThumb",
|
|
34
|
+
variants: {
|
|
35
|
+
unstyled: {
|
|
36
|
+
false: {
|
|
37
|
+
size: "$true",
|
|
38
|
+
backgroundColor: "$background",
|
|
39
|
+
borderRadius: 1e3
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
checked: {
|
|
43
|
+
true: {}
|
|
44
|
+
},
|
|
45
|
+
size: {
|
|
46
|
+
"...size": function (val) {
|
|
47
|
+
var size = getSwitchHeight(val);
|
|
48
|
+
return {
|
|
49
|
+
height: size,
|
|
50
|
+
width: size
|
|
51
|
+
};
|
|
52
|
+
}
|
|
30
53
|
}
|
|
31
54
|
},
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
},
|
|
35
|
-
size: {
|
|
36
|
-
"...size": function(val) {
|
|
37
|
-
var size = getSwitchHeight(val);
|
|
38
|
-
return {
|
|
39
|
-
height: size,
|
|
40
|
-
width: size
|
|
41
|
-
};
|
|
42
|
-
}
|
|
55
|
+
defaultVariants: {
|
|
56
|
+
unstyled: process.env.TAMAGUI_HEADLESS === "1"
|
|
43
57
|
}
|
|
58
|
+
}),
|
|
59
|
+
getSwitchHeight = function (val) {
|
|
60
|
+
return Math.round((0, import_core.getVariableValue)((0, import_get_token.getSize)(val)) * 0.65);
|
|
61
|
+
},
|
|
62
|
+
getSwitchWidth = function (val) {
|
|
63
|
+
return getSwitchHeight(val) * 2;
|
|
44
64
|
},
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
65
|
+
SwitchFrame = (0, import_core.styled)(import_stacks.YStack, {
|
|
66
|
+
name: "Switch",
|
|
67
|
+
tag: "button",
|
|
68
|
+
tabIndex: 0,
|
|
69
|
+
variants: {
|
|
70
|
+
unstyled: {
|
|
71
|
+
false: {
|
|
72
|
+
borderRadius: 1e3,
|
|
73
|
+
backgroundColor: "$background",
|
|
74
|
+
borderWidth: 2,
|
|
75
|
+
borderColor: "$background",
|
|
76
|
+
focusVisibleStyle: {
|
|
77
|
+
outlineColor: "$outlineColor",
|
|
78
|
+
outlineStyle: "solid",
|
|
79
|
+
outlineWidth: 2
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
checked: {
|
|
84
|
+
true: {}
|
|
85
|
+
},
|
|
86
|
+
size: {
|
|
87
|
+
"...size": function (val) {
|
|
88
|
+
var height = getSwitchHeight(val) + 4,
|
|
89
|
+
width = getSwitchWidth(val) + 4;
|
|
90
|
+
return {
|
|
91
|
+
height,
|
|
92
|
+
minHeight: height,
|
|
93
|
+
width
|
|
94
|
+
};
|
|
67
95
|
}
|
|
68
96
|
}
|
|
69
97
|
},
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
},
|
|
73
|
-
size: {
|
|
74
|
-
"...size": function(val) {
|
|
75
|
-
var height = getSwitchHeight(val) + 4, width = getSwitchWidth(val) + 4;
|
|
76
|
-
return {
|
|
77
|
-
height,
|
|
78
|
-
minHeight: height,
|
|
79
|
-
width
|
|
80
|
-
};
|
|
81
|
-
}
|
|
98
|
+
defaultVariants: {
|
|
99
|
+
unstyled: process.env.TAMAGUI_HEADLESS === "1"
|
|
82
100
|
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
unstyled: process.env.TAMAGUI_HEADLESS === "1"
|
|
86
|
-
}
|
|
87
|
-
});
|
|
88
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
89
|
-
0 && (module.exports = {
|
|
90
|
-
SwitchFrame,
|
|
91
|
-
SwitchThumb
|
|
92
|
-
});
|
|
93
|
-
//# sourceMappingURL=Switch.js.map
|
|
101
|
+
});
|
|
102
|
+
//# sourceMappingURL=Switch.native.js.map
|
|
@@ -1,6 +1 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/Switch.tsx"],
|
|
4
|
-
"mappings": ";;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAyC,0BACzC,mBAAwB,+BACxB,gBAAuC,4BAC5B,kBAAc,oBAAO,8BAAgB;AAAA,EAC5C,MAAM;AAAA,EACN,UAAU;AAAA,IACN,UAAU;AAAA,MACN,OAAO;AAAA,QACH,MAAM;AAAA,QACN,iBAAiB;AAAA,QACjB,cAAc;AAAA,MAClB;AAAA,IACJ;AAAA,IACA,SAAS;AAAA,MACL,MAAM,CAAC;AAAA,IACX;AAAA,IACA,MAAM;AAAA,MACF,WAAW,SAAS,KAAK;AACrB,YAAI,OAAO,gBAAgB,GAAG;AAC9B,eAAO;AAAA,UACH,QAAQ;AAAA,UACR,OAAO;AAAA,QACX;AAAA,MACJ;AAAA,IACJ;AAAA,EACJ;AAAA,EACA,iBAAiB;AAAA,IACb,UAAU,QAAQ,IAAI,qBAAqB;AAAA,EAC/C;AACJ,CAAC,GACG,kBAAkB,SAAS,KAAK;AAChC,SAAO,KAAK,UAAM,kCAAiB,0BAAQ,GAAG,CAAC,IAAI,IAAI;AAC3D,GACI,iBAAiB,SAAS,KAAK;AAC/B,SAAO,gBAAgB,GAAG,IAAI;AAClC,GACW,kBAAc,oBAAO,sBAAQ;AAAA,EACpC,MAAM;AAAA,EACN,KAAK;AAAA,EACL,UAAU;AAAA,EACV,UAAU;AAAA,IACN,UAAU;AAAA,MACN,OAAO;AAAA,QACH,cAAc;AAAA,QACd,iBAAiB;AAAA,QACjB,aAAa;AAAA,QACb,aAAa;AAAA,QACb,mBAAmB;AAAA,UACf,cAAc;AAAA,UACd,cAAc;AAAA,UACd,cAAc;AAAA,QAClB;AAAA,MACJ;AAAA,IACJ;AAAA,IACA,SAAS;AAAA,MACL,MAAM,CAAC;AAAA,IACX;AAAA,IACA,MAAM;AAAA,MACF,WAAW,SAAS,KAAK;AACrB,YAAI,SAAS,gBAAgB,GAAG,IAAI,GAChC,QAAQ,eAAe,GAAG,IAAI;AAClC,eAAO;AAAA,UACH;AAAA,UACA,WAAW;AAAA,UACX;AAAA,QACJ;AAAA,MACJ;AAAA,IACJ;AAAA,EACJ;AAAA,EACA,iBAAiB;AAAA,IACb,UAAU,QAAQ,IAAI,qBAAqB;AAAA,EAC/C;AACJ,CAAC;",
|
|
5
|
-
"names": []
|
|
6
|
-
}
|
|
1
|
+
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","Switch_exports","__export","SwitchFrame","SwitchThumb","module","exports","import_core","require","import_get_token","import_stacks","styled","ThemeableStack","name","variants","unstyled","false","size","backgroundColor","borderRadius","checked","true","...size","val","getSwitchHeight","height","width","defaultVariants","process","env","TAMAGUI_HEADLESS","Math","round","getVariableValue","getSize","getSwitchWidth","YStack","tag","tabIndex","borderWidth","borderColor","focusVisibleStyle","outlineColor","outlineStyle","outlineWidth","minHeight"],"sources":["../../src/Switch.tsx"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;AAAA,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O;IAAAC,QACL;IAAcxB,QACd;MAAiBC,QACjB;QAAaC,KACb;UAEAG,YAAA;UAAmBD,eACjB,EAAc;UAAAqB,WACd;UAAcC,WACd,eAAc;UAChBC,iBAAA;YACFC,YAAA;YACFC,YAAA;YAEAC,YAAS;UACP;QACF;MAEA;MAAMxB,OACJ;QACEC,IAAA;MAEA;MAAOJ,IAAA,EACL;QAAA,SACA,WAAAK,CAAWC,GAAA;UAAA,IACXE,MAAA,GAAAD,eAAA,CAAAD,GAAA;YAAAG,KAAA,GAAAS,cAAA,CAAAZ,GAAA;UACF;YACFE,MAAA;YACFoB,SAAA,EAAApB,MAAA;YACFC;UAEA;QACE;MACF;IACD","ignoreList":[]}
|
|
@@ -39,7 +39,7 @@ var import_core = require("@tamagui/core"),
|
|
|
39
39
|
import_focusable = require("@tamagui/focusable"),
|
|
40
40
|
import_switch_headless = require("@tamagui/switch-headless"),
|
|
41
41
|
import_use_controllable_state = require("@tamagui/use-controllable-state"),
|
|
42
|
-
React = __toESM(require("react")),
|
|
42
|
+
React = __toESM(require("react"), 1),
|
|
43
43
|
import_react_native = require("react-native-web"),
|
|
44
44
|
import_StyledContext = require("./StyledContext.cjs"),
|
|
45
45
|
import_Switch = require("./Switch.cjs"),
|
package/dist/cjs/createSwitch.js
CHANGED
|
@@ -26,7 +26,7 @@ __export(createSwitch_exports, {
|
|
|
26
26
|
createSwitch: () => createSwitch
|
|
27
27
|
});
|
|
28
28
|
module.exports = __toCommonJS(createSwitch_exports);
|
|
29
|
-
var 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-web"), import_StyledContext = require("./StyledContext"), import_Switch = require("./Switch"), import_jsx_runtime = require("react/jsx-runtime");
|
|
29
|
+
var 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"), 1), import_react_native = require("react-native-web"), import_StyledContext = require("./StyledContext"), import_Switch = require("./Switch"), import_jsx_runtime = require("react/jsx-runtime");
|
|
30
30
|
const SwitchContext = React.createContext({
|
|
31
31
|
checked: !1,
|
|
32
32
|
disabled: !1,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/createSwitch.tsx"],
|
|
4
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,kBAOO,0BACP,mBAAkC,+BAKlC,yBAA0B,qCAC1B,gCAAqC,4CACrC,QAAuB,
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,kBAOO,0BACP,mBAAkC,+BAKlC,yBAA0B,qCAC1B,gCAAqC,4CACrC,QAAuB,8BAMvB,sBAA6C,yBAC7C,uBAAoC,4BACpC,gBAA+D,qBAwFvD;AApED,MAAM,gBAAgB,MAAM,cAIhC;AAAA,EACD,SAAS;AAAA,EACT,UAAU;AAAA,EACV,YAAY;AACd,CAAC;AAKM,SAAS,aAGd,aAAqE;AACrE,QAAM;AAAA,IACJ;AAAA,IACA,QAAQ,cAAAA;AAAA,IACR,QAAQ;AAAA,EACV,IAAI;AAMJ,EAAI,QAAQ,IAAI,aAAa,kBAExB,UAAU,cAAAA,eACT,MAAM,aAAa,WACnB,MAAM,aAAa,YAAY,4CAChC,UAAU,6BACT,MAAM,aAAa,WACnB,MAAM,aAAa,YAAY,6CAEjC,QAAQ;AAAA,IACN;AAAA,EACF,GAIJ,MAAM,aAAa,UAAU,0CAC7B,MAAM,aAAa,UAAU;AAE7B,QAAM,uBAAuB,MAAM;AAAA,IACjC,SAAqB,OAAO,cAAc;AACxC,YAAM,EAAE,MAAM,UAAU,UAAU,cAAc,UAAU,GAAG,WAAW,IAA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AAA,YACA;AAAA,YACC,GAAG;AAAA,YACH,GAAI;AAAA,YACJ,GAAI,CAAC,sBACJ,CAAC,MAAM,YAAY;AAAA,cACjB,OAAO,UAAU,WAAW;AAAA,YAC9B;AAAA,YAEF;AAAA,YACA;AAAA,YAEA,sDAAC,4BAAK,OAAO,uBAAuB,UAAU,cAC3C,UAAC,aAAoB,MAAM,WAAb,MACjB;AAAA;AAAA,QACF;AAAA,QAEC;AAAA,SACH;AAAA,IAEJ;AAAA,IACA;AAAA,MACE,cAAc;AAAA,IAChB;AAAA,EACF;AAEA,aAAO,kCAAqB,iBAAiB;AAAA,IAC3C,OAAO;AAAA,EACT,CAAC;AACH;AAEA,MAAM,wBAAwB;AAAA,EAC5B,WAAW;AAAA,EACX,MAAM;AACR;",
|
|
5
5
|
"names": ["DefaultSwitchFrame", "NativeSwitch"]
|
|
6
6
|
}
|
|
@@ -1,152 +1,214 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
|
|
2
3
|
var __create = Object.create;
|
|
3
4
|
var __defProp = Object.defineProperty;
|
|
4
5
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
6
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf,
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf,
|
|
8
|
+
__hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
9
|
var __export = (target, all) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
10
|
+
for (var name in all) __defProp(target, name, {
|
|
11
|
+
get: all[name],
|
|
12
|
+
enumerable: !0
|
|
13
|
+
});
|
|
14
|
+
},
|
|
15
|
+
__copyProps = (to, from, except, desc) => {
|
|
16
|
+
if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
|
|
17
|
+
get: () => from[key],
|
|
18
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
19
|
+
});
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
16
22
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
17
23
|
// If the importer is in node compatibility mode or this is not an ESM
|
|
18
24
|
// file that has been converted to a CommonJS file using a Babel-
|
|
19
25
|
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
20
26
|
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
21
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
22
|
-
|
|
23
|
-
|
|
27
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
28
|
+
value: mod,
|
|
29
|
+
enumerable: !0
|
|
30
|
+
}) : target, mod)),
|
|
31
|
+
__toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
32
|
+
value: !0
|
|
33
|
+
}), mod);
|
|
24
34
|
var createSwitch_exports = {};
|
|
25
35
|
__export(createSwitch_exports, {
|
|
26
36
|
SwitchContext: () => SwitchContext,
|
|
27
37
|
createSwitch: () => createSwitch
|
|
28
38
|
});
|
|
29
39
|
module.exports = __toCommonJS(createSwitch_exports);
|
|
30
|
-
var import_jsx_runtime = require("react/jsx-runtime"),
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
40
|
+
var import_jsx_runtime = require("react/jsx-runtime"),
|
|
41
|
+
import_core = require("@tamagui/core"),
|
|
42
|
+
import_focusable = require("@tamagui/focusable"),
|
|
43
|
+
import_switch_headless = require("@tamagui/switch-headless"),
|
|
44
|
+
import_use_controllable_state = require("@tamagui/use-controllable-state"),
|
|
45
|
+
React = __toESM(require("react"), 1),
|
|
46
|
+
import_react_native = require("react-native"),
|
|
47
|
+
import_StyledContext = require("./StyledContext.native.js"),
|
|
48
|
+
import_Switch = require("./Switch.native.js"),
|
|
49
|
+
SwitchContext = /* @__PURE__ */React.createContext({
|
|
50
|
+
checked: !1,
|
|
51
|
+
disabled: !1,
|
|
52
|
+
frameWidth: 0
|
|
53
|
+
});
|
|
35
54
|
function createSwitch(createProps) {
|
|
36
|
-
var {
|
|
55
|
+
var {
|
|
56
|
+
disableActiveTheme,
|
|
57
|
+
Frame = import_Switch.SwitchFrame,
|
|
58
|
+
Thumb = import_Switch.SwitchThumb
|
|
59
|
+
} = createProps;
|
|
37
60
|
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;
|
|
38
|
-
var SwitchThumbComponent = Thumb.styleable(function(props, forwardedRef) {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
61
|
+
var SwitchThumbComponent = Thumb.styleable(function (props, forwardedRef) {
|
|
62
|
+
var {
|
|
63
|
+
size: sizeProp,
|
|
64
|
+
unstyled: unstyledProp,
|
|
65
|
+
nativeID,
|
|
66
|
+
...thumbProps
|
|
67
|
+
} = props,
|
|
68
|
+
context = React.useContext(SwitchContext),
|
|
69
|
+
{
|
|
70
|
+
checked,
|
|
71
|
+
disabled,
|
|
72
|
+
frameWidth
|
|
73
|
+
} = context,
|
|
74
|
+
styledContext = import_StyledContext.SwitchStyledContext.useStyledContext(),
|
|
75
|
+
{
|
|
76
|
+
unstyled: unstyledContext,
|
|
77
|
+
size: sizeContext
|
|
78
|
+
} = styledContext,
|
|
79
|
+
_ref,
|
|
80
|
+
unstyled = process.env.TAMAGUI_HEADLESS === "1" ? !0 : (_ref = unstyledProp ?? unstyledContext) !== null && _ref !== void 0 ? _ref : !1,
|
|
81
|
+
_ref1,
|
|
82
|
+
size = (_ref1 = sizeProp ?? sizeContext) !== null && _ref1 !== void 0 ? _ref1 : "$true",
|
|
83
|
+
initialChecked = React.useRef(checked).current,
|
|
84
|
+
initialWidth = (0, import_core.getVariableValue)(props.width, "size"),
|
|
85
|
+
[thumbWidth, setThumbWidth] = React.useState(typeof initialWidth == "number" ? initialWidth : 0),
|
|
86
|
+
distance = frameWidth - thumbWidth,
|
|
87
|
+
x = initialChecked ? checked ? 0 : -distance : checked ? distance : 0;
|
|
88
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(Thumb, {
|
|
89
|
+
ref: forwardedRef,
|
|
90
|
+
unstyled,
|
|
91
|
+
...(unstyled === !1 && {
|
|
92
|
+
size,
|
|
93
|
+
...(!disableActiveTheme && !unstyled && {
|
|
94
|
+
theme: checked ? "active" : null
|
|
95
|
+
})
|
|
96
|
+
}),
|
|
97
|
+
alignSelf: initialChecked ? "flex-end" : "flex-start",
|
|
98
|
+
x,
|
|
99
|
+
onLayout: (0, import_core.composeEventHandlers)(props.onLayout, function (e) {
|
|
100
|
+
var next = e.nativeEvent.layout.width;
|
|
101
|
+
next !== thumbWidth && setThumbWidth(next);
|
|
102
|
+
}),
|
|
103
|
+
// expected variants
|
|
75
104
|
checked,
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
)
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
105
|
+
disabled,
|
|
106
|
+
...thumbProps
|
|
107
|
+
});
|
|
108
|
+
}),
|
|
109
|
+
SwitchComponent = Frame.styleable(function (_props, forwardedRef) {
|
|
110
|
+
var {
|
|
111
|
+
native,
|
|
112
|
+
nativeProps,
|
|
113
|
+
checked: checkedProp,
|
|
114
|
+
defaultChecked,
|
|
115
|
+
onCheckedChange,
|
|
116
|
+
...props
|
|
117
|
+
} = _props,
|
|
118
|
+
[checked, setChecked] = (0, import_use_controllable_state.useControllableState)({
|
|
119
|
+
prop: checkedProp,
|
|
120
|
+
defaultProp: defaultChecked || !1,
|
|
121
|
+
onChange: onCheckedChange,
|
|
122
|
+
transition: !0
|
|
123
|
+
}),
|
|
124
|
+
styledContext = React.useContext(import_StyledContext.SwitchStyledContext.context),
|
|
125
|
+
estimatedInitialWidth = 0,
|
|
126
|
+
estWidth = (0, import_core.getVariableValue)((0, import_core.getShorthandValue)(props, "width"), "size");
|
|
127
|
+
if (estWidth) {
|
|
128
|
+
var _getShorthandValue,
|
|
129
|
+
_ref,
|
|
130
|
+
estPad = (_ref = (_getShorthandValue = (0, import_core.getShorthandValue)(props, "paddingHorizontal")) !== null && _getShorthandValue !== void 0 ? _getShorthandValue : (0, import_core.getShorthandValue)(props, "padding")) !== null && _ref !== void 0 ? _ref : 0,
|
|
131
|
+
_getShorthandValue1,
|
|
132
|
+
_ref1,
|
|
133
|
+
estLeftPad = (_ref1 = (_getShorthandValue1 = (0, import_core.getShorthandValue)(props, "paddingLeft")) !== null && _getShorthandValue1 !== void 0 ? _getShorthandValue1 : estPad) !== null && _ref1 !== void 0 ? _ref1 : 0,
|
|
134
|
+
_getShorthandValue2,
|
|
135
|
+
_ref2,
|
|
136
|
+
estRightPad = (_ref2 = (_getShorthandValue2 = (0, import_core.getShorthandValue)(props, "paddingRight")) !== null && _getShorthandValue2 !== void 0 ? _getShorthandValue2 : estPad) !== null && _ref2 !== void 0 ? _ref2 : 0;
|
|
137
|
+
estimatedInitialWidth = estWidth - (estLeftPad ? (0, import_core.getVariableValue)(estLeftPad, "size") : 0) - (estRightPad ? (0, import_core.getVariableValue)(estRightPad, "size") : 0);
|
|
138
|
+
}
|
|
139
|
+
var [frameWidth, setFrameInnerWidth] = React.useState(estimatedInitialWidth),
|
|
140
|
+
{
|
|
141
|
+
switchProps,
|
|
142
|
+
bubbleInput,
|
|
143
|
+
switchRef
|
|
144
|
+
} = (0, import_switch_headless.useSwitch)(
|
|
145
|
+
// @ts-ignore
|
|
146
|
+
props, [checked, setChecked],
|
|
147
|
+
// @ts-ignore TODO tamagui react 19 type error
|
|
148
|
+
forwardedRef);
|
|
149
|
+
React.useEffect(function () {
|
|
150
|
+
if (props.id && !props.disabled) return (0, import_focusable.registerFocusable)(props.id, {
|
|
151
|
+
focusAndSelect: function () {
|
|
152
|
+
setChecked?.(function (value2) {
|
|
86
153
|
return !value2;
|
|
87
154
|
});
|
|
88
155
|
},
|
|
89
|
-
focus: function() {
|
|
90
|
-
}
|
|
156
|
+
focus: function () {}
|
|
91
157
|
});
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
]);
|
|
96
|
-
var renderNative = (0, import_core.shouldRenderNativePlatform)(native);
|
|
97
|
-
if (renderNative === "android" || renderNative === "ios")
|
|
98
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native.Switch, {
|
|
158
|
+
}, [props.id, props.disabled]);
|
|
159
|
+
var renderNative = (0, import_core.shouldRenderNativePlatform)(native);
|
|
160
|
+
if (renderNative === "android" || renderNative === "ios") return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_react_native.Switch, {
|
|
99
161
|
value: checked,
|
|
100
162
|
onValueChange: setChecked,
|
|
101
163
|
...nativeProps
|
|
102
164
|
});
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
165
|
+
var disabled = props.disabled,
|
|
166
|
+
value = React.useMemo(function () {
|
|
167
|
+
return {
|
|
168
|
+
checked,
|
|
169
|
+
disabled,
|
|
170
|
+
frameWidth
|
|
171
|
+
};
|
|
172
|
+
}, [checked, disabled, frameWidth]),
|
|
173
|
+
handleLayout = function (e) {
|
|
174
|
+
var next = e.nativeEvent.layout.width;
|
|
175
|
+
next !== frameWidth && setFrameInnerWidth(next);
|
|
176
|
+
},
|
|
177
|
+
_styledContext_unstyled,
|
|
178
|
+
_ref3,
|
|
179
|
+
unstyled = (_ref3 = (_styledContext_unstyled = styledContext.unstyled) !== null && _styledContext_unstyled !== void 0 ? _styledContext_unstyled : props.unstyled) !== null && _ref3 !== void 0 ? _ref3 : !1,
|
|
180
|
+
_styledContext_size,
|
|
181
|
+
_ref4;
|
|
182
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsxs)(SwitchContext.Provider, {
|
|
183
|
+
value,
|
|
184
|
+
children: [/* @__PURE__ */(0, import_jsx_runtime.jsx)(Frame, {
|
|
121
185
|
ref: switchRef,
|
|
122
186
|
tag: "button",
|
|
123
|
-
...import_core.isWeb && {
|
|
187
|
+
...(import_core.isWeb && {
|
|
124
188
|
type: "button"
|
|
125
|
-
},
|
|
126
|
-
|
|
189
|
+
}),
|
|
190
|
+
...(!unstyled && {
|
|
127
191
|
size: (_ref4 = (_styledContext_size = styledContext.size) !== null && _styledContext_size !== void 0 ? _styledContext_size : props.size) !== null && _ref4 !== void 0 ? _ref4 : "$true"
|
|
128
|
-
},
|
|
192
|
+
}),
|
|
129
193
|
unstyled,
|
|
130
194
|
...props,
|
|
131
195
|
...switchProps,
|
|
132
|
-
|
|
196
|
+
...(!disableActiveTheme && !props.unstyled && {
|
|
133
197
|
theme: checked ? "active" : null
|
|
134
|
-
},
|
|
198
|
+
}),
|
|
135
199
|
// expected variants
|
|
136
200
|
checked,
|
|
137
201
|
disabled,
|
|
138
|
-
children: /* @__PURE__ */
|
|
202
|
+
children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_react_native.View, {
|
|
139
203
|
style: measureContainerStyle,
|
|
140
204
|
onLayout: handleLayout,
|
|
141
205
|
children: frameWidth ? props.children : null
|
|
142
206
|
})
|
|
143
|
-
}),
|
|
144
|
-
|
|
145
|
-
|
|
207
|
+
}), bubbleInput]
|
|
208
|
+
});
|
|
209
|
+
}, {
|
|
210
|
+
disableTheme: !0
|
|
146
211
|
});
|
|
147
|
-
}, {
|
|
148
|
-
disableTheme: !0
|
|
149
|
-
});
|
|
150
212
|
return (0, import_core.withStaticProperties)(SwitchComponent, {
|
|
151
213
|
Thumb: SwitchThumbComponent
|
|
152
214
|
});
|
|
@@ -155,9 +217,4 @@ var measureContainerStyle = {
|
|
|
155
217
|
alignSelf: "stretch",
|
|
156
218
|
flex: 1
|
|
157
219
|
};
|
|
158
|
-
|
|
159
|
-
0 && (module.exports = {
|
|
160
|
-
SwitchContext,
|
|
161
|
-
createSwitch
|
|
162
|
-
});
|
|
163
|
-
//# sourceMappingURL=createSwitch.js.map
|
|
220
|
+
//# sourceMappingURL=createSwitch.native.js.map
|