@tamagui/switch 2.7.7 → 3.0.0-beta.643.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/StyledContext.cjs +19 -23
- package/dist/cjs/StyledContext.native.cjs +33 -0
- package/dist/cjs/StyledContext.native.js +19 -22
- package/dist/cjs/StyledContext.native.js.map +1 -1
- package/dist/cjs/Switch.cjs +140 -86
- package/dist/cjs/Switch.native.cjs +163 -0
- package/dist/cjs/Switch.native.js +147 -90
- package/dist/cjs/Switch.native.js.map +1 -1
- package/dist/cjs/index.cjs +14 -25
- package/dist/cjs/index.native.cjs +31 -0
- package/dist/cjs/index.native.js +15 -25
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/cjs/types.cjs +10 -11
- package/dist/cjs/types.native.cjs +19 -0
- package/dist/cjs/types.native.js +10 -10
- package/dist/cjs/types.native.js.map +1 -1
- package/dist/cjs/useSwitchNative.cjs +16 -19
- package/dist/cjs/useSwitchNative.native.cjs +65 -0
- package/dist/cjs/useSwitchNative.native.js +44 -54
- package/dist/cjs/useSwitchNative.native.js.map +1 -1
- package/dist/esm/StyledContext.mjs +6 -5
- package/dist/esm/StyledContext.mjs.map +1 -1
- package/dist/esm/StyledContext.native.js +6 -5
- package/dist/esm/StyledContext.native.js.map +1 -1
- package/dist/esm/Switch.mjs +119 -71
- package/dist/esm/Switch.mjs.map +1 -1
- package/dist/esm/Switch.native.js +126 -76
- package/dist/esm/Switch.native.js.map +1 -1
- package/dist/esm/index.js +8 -12
- package/dist/esm/index.mjs +8 -12
- package/dist/esm/index.native.js +8 -12
- package/dist/esm/types.mjs +0 -2
- package/dist/esm/types.native.js +0 -2
- package/dist/esm/useSwitchNative.mjs +2 -1
- package/dist/esm/useSwitchNative.mjs.map +1 -1
- package/dist/esm/useSwitchNative.native.js +30 -31
- package/dist/esm/useSwitchNative.native.js.map +1 -1
- package/dist/jsx/StyledContext.mjs +6 -5
- package/dist/jsx/StyledContext.mjs.map +1 -1
- package/dist/jsx/StyledContext.native.cjs +33 -0
- package/dist/jsx/StyledContext.native.js +19 -22
- package/dist/jsx/StyledContext.native.js.map +1 -1
- package/dist/jsx/Switch.mjs +119 -71
- package/dist/jsx/Switch.mjs.map +1 -1
- package/dist/jsx/Switch.native.cjs +163 -0
- package/dist/jsx/Switch.native.js +147 -90
- package/dist/jsx/Switch.native.js.map +1 -1
- package/dist/jsx/index.js +8 -12
- package/dist/jsx/index.mjs +8 -12
- package/dist/jsx/index.native.cjs +31 -0
- package/dist/jsx/index.native.js +15 -25
- package/dist/jsx/index.native.js.map +1 -1
- package/dist/jsx/types.mjs +0 -2
- package/dist/jsx/types.native.cjs +19 -0
- package/dist/jsx/types.native.js +10 -10
- package/dist/jsx/types.native.js.map +1 -1
- package/dist/jsx/useSwitchNative.mjs +2 -1
- package/dist/jsx/useSwitchNative.mjs.map +1 -1
- package/dist/jsx/useSwitchNative.native.cjs +65 -0
- package/dist/jsx/useSwitchNative.native.js +44 -54
- package/dist/jsx/useSwitchNative.native.js.map +1 -1
- package/package.json +7 -14
- package/src/StyledContext.tsx +1 -3
- package/src/Switch.tsx +190 -89
- package/src/index.ts +0 -20
- package/src/types.ts +3 -5
- package/types/StyledContext.d.ts +2 -3
- package/types/StyledContext.d.ts.map +1 -1
- package/types/Switch.d.ts +209 -37
- package/types/Switch.d.ts.map +1 -1
- package/types/index.d.ts +0 -146
- package/types/index.d.ts.map +1 -1
- package/types/types.d.ts +3 -4
- package/types/types.d.ts.map +1 -1
- package/dist/cjs/createSwitch.cjs +0 -186
- package/dist/cjs/createSwitch.native.js +0 -194
- package/dist/cjs/createSwitch.native.js.map +0 -1
- package/dist/esm/createSwitch.mjs +0 -150
- package/dist/esm/createSwitch.mjs.map +0 -1
- package/dist/esm/createSwitch.native.js +0 -155
- package/dist/esm/createSwitch.native.js.map +0 -1
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/index.mjs.map +0 -1
- package/dist/esm/index.native.js.map +0 -1
- package/dist/esm/types.mjs.map +0 -1
- package/dist/esm/types.native.js.map +0 -1
- package/dist/jsx/createSwitch.mjs +0 -150
- package/dist/jsx/createSwitch.mjs.map +0 -1
- package/dist/jsx/createSwitch.native.js +0 -194
- package/dist/jsx/createSwitch.native.js.map +0 -1
- package/dist/jsx/index.js.map +0 -1
- package/dist/jsx/index.mjs.map +0 -1
- package/dist/jsx/types.mjs.map +0 -1
- package/src/Switch.draggable-tmp +0 -340
- package/src/createSwitch.tsx +0 -201
- package/types/createSwitch.d.ts +0 -141
- package/types/createSwitch.d.ts.map +0 -1
|
@@ -1,79 +1,129 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
},
|
|
14
|
-
size: {
|
|
15
|
-
"...size": function (val) {
|
|
16
|
-
var size = getSwitchHeight(val);
|
|
17
|
-
return {
|
|
18
|
-
height: size,
|
|
19
|
-
width: size
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
},
|
|
24
|
-
defaultVariants: {
|
|
25
|
-
unstyled: process.env.TAMAGUI_HEADLESS === "1"
|
|
26
|
-
}
|
|
27
|
-
}, {
|
|
28
|
-
accept: {
|
|
29
|
-
activeStyle: "style"
|
|
30
|
-
}
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Theme, View, composeEventHandlers, createStyledHOC, getVariableValue, isWeb, styled, withStaticProperties } from "@tamagui/core";
|
|
3
|
+
import { useSwitch } from "@tamagui/switch-headless";
|
|
4
|
+
import { useControllableState } from "@tamagui/use-controllable-state";
|
|
5
|
+
import * as React from "react";
|
|
6
|
+
import { SwitchStyledContext } from "./StyledContext.native.js";
|
|
7
|
+
import { useSwitchNative } from "./useSwitchNative.native.js";
|
|
8
|
+
|
|
9
|
+
var SwitchThumbFrame = styled(View, {
|
|
10
|
+
displayName: "SwitchThumb",
|
|
11
|
+
context: SwitchStyledContext
|
|
31
12
|
});
|
|
32
|
-
var
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
};
|
|
38
|
-
var SwitchFrame = styled(YStack, {
|
|
39
|
-
name: "Switch",
|
|
40
|
-
render: "button",
|
|
41
|
-
tabIndex: 0,
|
|
42
|
-
variants: {
|
|
43
|
-
unstyled: {
|
|
44
|
-
false: {
|
|
45
|
-
borderRadius: 1e3,
|
|
46
|
-
backgroundColor: "$background",
|
|
47
|
-
focusVisibleStyle: {
|
|
48
|
-
outlineColor: "$outlineColor",
|
|
49
|
-
outlineStyle: "solid",
|
|
50
|
-
outlineWidth: 2
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
},
|
|
54
|
-
size: {
|
|
55
|
-
"...size": function (val, param) {
|
|
56
|
-
var {
|
|
57
|
-
props
|
|
58
|
-
} = param;
|
|
59
|
-
if (props["unstyled"]) return;
|
|
60
|
-
var height = getSwitchHeight(val);
|
|
61
|
-
var width = getSwitchWidth(val);
|
|
62
|
-
return {
|
|
63
|
-
height,
|
|
64
|
-
minHeight: height,
|
|
65
|
-
width
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
},
|
|
70
|
-
defaultVariants: {
|
|
71
|
-
unstyled: process.env.TAMAGUI_HEADLESS === "1"
|
|
72
|
-
}
|
|
73
|
-
}, {
|
|
74
|
-
accept: {
|
|
75
|
-
activeStyle: "style"
|
|
76
|
-
}
|
|
13
|
+
var SwitchFrame = styled(View, {
|
|
14
|
+
displayName: "Switch",
|
|
15
|
+
context: SwitchStyledContext,
|
|
16
|
+
render: "button",
|
|
17
|
+
tabIndex: 0
|
|
77
18
|
});
|
|
78
|
-
|
|
19
|
+
function createSwitch(createProps) {
|
|
20
|
+
var _createProps_Frame;
|
|
21
|
+
var Frame = (_createProps_Frame = createProps.Frame) !== null && _createProps_Frame !== void 0 ? _createProps_Frame : SwitchFrame;
|
|
22
|
+
var _createProps_Thumb;
|
|
23
|
+
var Thumb = (_createProps_Thumb = createProps.Thumb) !== null && _createProps_Thumb !== void 0 ? _createProps_Thumb : SwitchThumbFrame;
|
|
24
|
+
Frame.staticConfig.context = SwitchStyledContext;
|
|
25
|
+
Thumb.staticConfig.context = SwitchStyledContext;
|
|
26
|
+
var SwitchThumbComponent = createStyledHOC(Thumb, function SwitchThumb2(props, forwardedRef) {
|
|
27
|
+
var _createProps_componentThemes;
|
|
28
|
+
var { size: sizeProp, activeStyle, theme, ...thumbProps } = props;
|
|
29
|
+
var styledContext = SwitchStyledContext.useStyledContext();
|
|
30
|
+
var { size: sizeContext, active, disabled, frameWidth = 0 } = styledContext;
|
|
31
|
+
var _ref;
|
|
32
|
+
var size = (_ref = sizeProp !== null && sizeProp !== void 0 ? sizeProp : sizeContext) !== null && _ref !== void 0 ? _ref : true;
|
|
33
|
+
var initialChecked = React.useRef(active).current;
|
|
34
|
+
var initialWidth = getVariableValue(props.width, "size");
|
|
35
|
+
var [thumbWidth, setThumbWidth] = React.useState(typeof initialWidth === "number" ? initialWidth : 0);
|
|
36
|
+
var distance = frameWidth - thumbWidth;
|
|
37
|
+
var x = initialChecked ? active ? 0 : -distance : active ? distance : 0;
|
|
38
|
+
var thumb = /* @__PURE__ */ jsx(Thumb, {
|
|
39
|
+
ref: forwardedRef,
|
|
40
|
+
size,
|
|
41
|
+
alignSelf: initialChecked ? "flex-end" : "flex-start",
|
|
42
|
+
x,
|
|
43
|
+
onLayout: composeEventHandlers(props.onLayout, function(event) {
|
|
44
|
+
setThumbWidth(event.nativeEvent.layout.width);
|
|
45
|
+
}),
|
|
46
|
+
disabled,
|
|
47
|
+
...thumbProps,
|
|
48
|
+
...active && activeStyle
|
|
49
|
+
});
|
|
50
|
+
var themeName = theme !== null && theme !== void 0 ? theme : (_createProps_componentThemes = createProps.componentThemes) === null || _createProps_componentThemes === void 0 ? void 0 : _createProps_componentThemes.thumb;
|
|
51
|
+
return themeName ? /* @__PURE__ */ jsx(Theme, {
|
|
52
|
+
name: themeName,
|
|
53
|
+
children: thumb
|
|
54
|
+
}) : thumb;
|
|
55
|
+
});
|
|
56
|
+
var SwitchComponent = createStyledHOC(Frame, function Switch2(_props, forwardedRef) {
|
|
57
|
+
var _createProps_componentThemes;
|
|
58
|
+
var { native, nativeProps, checked: checkedProp, defaultChecked, onCheckedChange, activeStyle, activeTheme, theme, ...props } = _props;
|
|
59
|
+
var [checked, setChecked] = useControllableState({
|
|
60
|
+
prop: checkedProp,
|
|
61
|
+
defaultProp: defaultChecked || false,
|
|
62
|
+
onChange: onCheckedChange,
|
|
63
|
+
transition: true
|
|
64
|
+
});
|
|
65
|
+
var styledContext = React.useContext(SwitchStyledContext.context);
|
|
66
|
+
var [frameWidth, setFrameInnerWidth] = React.useState(0);
|
|
67
|
+
var { switchProps, bubbleInput, switchRef } = useSwitch(props, [checked, setChecked], forwardedRef);
|
|
68
|
+
var nativeSwitch = useSwitchNative({
|
|
69
|
+
id: props.id,
|
|
70
|
+
disabled: props.disabled,
|
|
71
|
+
native,
|
|
72
|
+
nativeProps,
|
|
73
|
+
checked,
|
|
74
|
+
setChecked
|
|
75
|
+
});
|
|
76
|
+
if (nativeSwitch) {
|
|
77
|
+
return nativeSwitch;
|
|
78
|
+
}
|
|
79
|
+
var disabled = props.disabled;
|
|
80
|
+
var _styledContext_size, _ref;
|
|
81
|
+
var size = (_ref = (_styledContext_size = styledContext.size) !== null && _styledContext_size !== void 0 ? _styledContext_size : props.size) !== null && _ref !== void 0 ? _ref : true;
|
|
82
|
+
var handleLayout = function(event) {
|
|
83
|
+
var next = event.nativeEvent.layout.width;
|
|
84
|
+
if (next !== frameWidth) {
|
|
85
|
+
setFrameInnerWidth(next);
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
var frame = /* @__PURE__ */ jsx(Frame, {
|
|
89
|
+
ref: switchRef,
|
|
90
|
+
render: "button",
|
|
91
|
+
...isWeb && { type: "button" },
|
|
92
|
+
size,
|
|
93
|
+
...props,
|
|
94
|
+
...switchProps,
|
|
95
|
+
disabled,
|
|
96
|
+
...checked && activeStyle,
|
|
97
|
+
children: /* @__PURE__ */ jsx(View, {
|
|
98
|
+
alignSelf: "stretch",
|
|
99
|
+
flex: 1,
|
|
100
|
+
onLayout: handleLayout,
|
|
101
|
+
children: props.children
|
|
102
|
+
})
|
|
103
|
+
});
|
|
104
|
+
var _ref1, _ref2;
|
|
105
|
+
var frameTheme = (_ref2 = (_ref1 = checked ? activeTheme : void 0) !== null && _ref1 !== void 0 ? _ref1 : theme) !== null && _ref2 !== void 0 ? _ref2 : (_createProps_componentThemes = createProps.componentThemes) === null || _createProps_componentThemes === void 0 ? void 0 : _createProps_componentThemes.frame;
|
|
106
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(SwitchStyledContext.Provider, {
|
|
107
|
+
size,
|
|
108
|
+
active: checked,
|
|
109
|
+
disabled,
|
|
110
|
+
frameWidth,
|
|
111
|
+
children: frameTheme ? /* @__PURE__ */ jsx(Theme, {
|
|
112
|
+
name: frameTheme,
|
|
113
|
+
children: frame
|
|
114
|
+
}) : frame
|
|
115
|
+
}), bubbleInput] });
|
|
116
|
+
}, { disableTheme: true });
|
|
117
|
+
return withStaticProperties(SwitchComponent, {
|
|
118
|
+
Frame,
|
|
119
|
+
Thumb: SwitchThumbComponent
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
var Switch = createSwitch({
|
|
123
|
+
Frame: SwitchFrame,
|
|
124
|
+
Thumb: SwitchThumbFrame
|
|
125
|
+
});
|
|
126
|
+
var SwitchThumb = Switch.Thumb;
|
|
127
|
+
|
|
128
|
+
export { Switch, SwitchFrame, SwitchThumb, SwitchThumbFrame, createSwitch };
|
|
79
129
|
//# sourceMappingURL=Switch.native.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"Switch.native.js","names":["_Fragment"],"sources":["esm/Switch.native.js"],"sourcesContent":["import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from \"react/jsx-runtime\";\nimport { composeEventHandlers, createStyledHOC, getVariableValue, isWeb, styled, Theme, View, withStaticProperties } from \"@tamagui/core\";\nimport { useSwitch } from \"@tamagui/switch-headless\";\nimport { useControllableState } from \"@tamagui/use-controllable-state\";\nimport * as React from \"react\";\nimport { SwitchStyledContext } from \"./StyledContext\";\nimport { useSwitchNative } from \"./useSwitchNative\";\nvar SwitchThumbFrame = styled(View, {\n displayName: \"SwitchThumb\",\n context: SwitchStyledContext\n});\nvar SwitchFrame = styled(View, {\n displayName: \"Switch\",\n context: SwitchStyledContext,\n render: \"button\",\n tabIndex: 0\n});\nfunction createSwitch(createProps) {\n var _createProps_Frame;\n var Frame = (_createProps_Frame = createProps.Frame) !== null && _createProps_Frame !== void 0 ? _createProps_Frame : SwitchFrame;\n var _createProps_Thumb;\n var Thumb = (_createProps_Thumb = createProps.Thumb) !== null && _createProps_Thumb !== void 0 ? _createProps_Thumb : SwitchThumbFrame;\n Frame.staticConfig.context = SwitchStyledContext;\n Thumb.staticConfig.context = SwitchStyledContext;\n var SwitchThumbComponent = createStyledHOC(Thumb, function SwitchThumb2(props, forwardedRef) {\n var _createProps_componentThemes;\n var { size: sizeProp, activeStyle, theme, ...thumbProps } = props;\n var styledContext = SwitchStyledContext.useStyledContext();\n var { size: sizeContext, active, disabled, frameWidth = 0 } = styledContext;\n var _ref;\n var size = (_ref = sizeProp !== null && sizeProp !== void 0 ? sizeProp : sizeContext) !== null && _ref !== void 0 ? _ref : true;\n var initialChecked = React.useRef(active).current;\n var initialWidth = getVariableValue(props.width, \"size\");\n var [thumbWidth, setThumbWidth] = React.useState(typeof initialWidth === \"number\" ? initialWidth : 0);\n var distance = frameWidth - thumbWidth;\n var x = initialChecked ? active ? 0 : -distance : active ? distance : 0;\n var thumb = /* @__PURE__ */ _jsx(Thumb, {\n ref: forwardedRef,\n size,\n alignSelf: initialChecked ? \"flex-end\" : \"flex-start\",\n x,\n onLayout: composeEventHandlers(props.onLayout, function(event) {\n setThumbWidth(event.nativeEvent.layout.width);\n }),\n disabled,\n ...thumbProps,\n ...active && activeStyle\n });\n var themeName = theme !== null && theme !== void 0 ? theme : (_createProps_componentThemes = createProps.componentThemes) === null || _createProps_componentThemes === void 0 ? void 0 : _createProps_componentThemes.thumb;\n return themeName ? /* @__PURE__ */ _jsx(Theme, {\n name: themeName,\n children: thumb\n }) : thumb;\n });\n var SwitchComponent = createStyledHOC(Frame, function Switch2(_props, forwardedRef) {\n var _createProps_componentThemes;\n var { native, nativeProps, checked: checkedProp, defaultChecked, onCheckedChange, activeStyle, activeTheme, theme, ...props } = _props;\n var [checked, setChecked] = useControllableState({\n prop: checkedProp,\n defaultProp: defaultChecked || false,\n onChange: onCheckedChange,\n transition: true\n });\n var styledContext = React.useContext(SwitchStyledContext.context);\n var [frameWidth, setFrameInnerWidth] = React.useState(0);\n var { switchProps, bubbleInput, switchRef } = useSwitch(\n props,\n [\n checked,\n setChecked\n ],\n // @ts-ignore TODO tamagui react 19 type error\n forwardedRef\n );\n var nativeSwitch = useSwitchNative({\n id: props.id,\n disabled: props.disabled,\n native,\n nativeProps,\n checked,\n setChecked\n });\n if (nativeSwitch) {\n return nativeSwitch;\n }\n var disabled = props.disabled;\n var _styledContext_size, _ref;\n var size = (_ref = (_styledContext_size = styledContext.size) !== null && _styledContext_size !== void 0 ? _styledContext_size : props.size) !== null && _ref !== void 0 ? _ref : true;\n var handleLayout = function(event) {\n var next = event.nativeEvent.layout.width;\n if (next !== frameWidth) {\n setFrameInnerWidth(next);\n }\n };\n var frame = /* @__PURE__ */ _jsx(Frame, {\n ref: switchRef,\n render: \"button\",\n ...isWeb && {\n type: \"button\"\n },\n size,\n ...props,\n ...switchProps,\n disabled,\n ...checked && activeStyle,\n children: /* @__PURE__ */ _jsx(View, {\n alignSelf: \"stretch\",\n flex: 1,\n onLayout: handleLayout,\n children: props.children\n })\n });\n var _ref1, _ref2;\n var frameTheme = (_ref2 = (_ref1 = checked ? activeTheme : void 0) !== null && _ref1 !== void 0 ? _ref1 : theme) !== null && _ref2 !== void 0 ? _ref2 : (_createProps_componentThemes = createProps.componentThemes) === null || _createProps_componentThemes === void 0 ? void 0 : _createProps_componentThemes.frame;\n return /* @__PURE__ */ _jsxs(_Fragment, {\n children: [\n /* @__PURE__ */ _jsx(SwitchStyledContext.Provider, {\n size,\n active: checked,\n disabled,\n frameWidth,\n children: frameTheme ? /* @__PURE__ */ _jsx(Theme, {\n name: frameTheme,\n children: frame\n }) : frame\n }),\n bubbleInput\n ]\n });\n }, {\n disableTheme: true\n });\n return withStaticProperties(SwitchComponent, {\n Frame,\n Thumb: SwitchThumbComponent\n });\n}\nvar Switch = createSwitch({\n Frame: SwitchFrame,\n Thumb: SwitchThumbFrame\n});\nvar SwitchThumb = Switch.Thumb;\nexport {\n Switch,\n SwitchFrame,\n SwitchThumb,\n SwitchThumbFrame,\n createSwitch\n};\n//# sourceMappingURL=Switch.js.map\n"],"mappings":";;;;;;;;;AAOA,IAAI,mBAAmB,OAAO,MAAM;CAClC,aAAa;CACb,SAAS;AACX,CAAC;AACD,IAAI,cAAc,OAAO,MAAM;CAC7B,aAAa;CACb,SAAS;CACT,QAAQ;CACR,UAAU;AACZ,CAAC;AACD,SAAS,aAAa,aAAa;CACjC,IAAI;CACJ,IAAI,SAAS,qBAAqB,YAAY,WAAW,QAAQ,uBAAuB,KAAK,IAAI,qBAAqB;CACtH,IAAI;CACJ,IAAI,SAAS,qBAAqB,YAAY,WAAW,QAAQ,uBAAuB,KAAK,IAAI,qBAAqB;CACtH,MAAM,aAAa,UAAU;CAC7B,MAAM,aAAa,UAAU;CAC7B,IAAI,uBAAuB,gBAAgB,OAAO,SAAS,aAAa,OAAO,cAAc;EAC3F,IAAI;EACJ,IAAI,EAAE,MAAM,UAAU,aAAa,OAAO,GAAG,eAAe;EA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OAAO;CACT,CAAC;AACH;AACA,IAAI,SAAS,aAAa;CACxB,OAAO;CACP,OAAO;AACT,CAAC;AACD,IAAI,cAAc,OAAO"}
|
package/dist/esm/index.js
CHANGED
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
import { createSwitch } from "./createSwitch.mjs";
|
|
2
|
-
import { SwitchFrame, SwitchThumb } from "./Switch.mjs";
|
|
3
|
-
export * from "./createSwitch.mjs";
|
|
4
|
-
export * from "./StyledContext.mjs";
|
|
5
|
-
export * from "./Switch.mjs";
|
|
6
|
-
export * from "./types.mjs";
|
|
7
1
|
import { useSwitchNative } from "./useSwitchNative.mjs";
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
2
|
+
|
|
3
|
+
export * from "./StyledContext.mjs"
|
|
4
|
+
|
|
5
|
+
export * from "./Switch.mjs"
|
|
6
|
+
|
|
7
|
+
export * from "./types.mjs"
|
|
8
|
+
|
|
9
|
+
export { useSwitchNative };
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
import { createSwitch } from "./createSwitch.mjs";
|
|
2
|
-
import { SwitchFrame, SwitchThumb } from "./Switch.mjs";
|
|
3
|
-
export * from "./createSwitch.mjs";
|
|
4
|
-
export * from "./StyledContext.mjs";
|
|
5
|
-
export * from "./Switch.mjs";
|
|
6
|
-
export * from "./types.mjs";
|
|
7
1
|
import { useSwitchNative } from "./useSwitchNative.mjs";
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
2
|
+
|
|
3
|
+
export * from "./StyledContext.mjs"
|
|
4
|
+
|
|
5
|
+
export * from "./Switch.mjs"
|
|
6
|
+
|
|
7
|
+
export * from "./types.mjs"
|
|
8
|
+
|
|
9
|
+
export { useSwitchNative };
|
package/dist/esm/index.native.js
CHANGED
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
import { createSwitch } from "./createSwitch.native.js";
|
|
2
|
-
import { SwitchFrame, SwitchThumb } from "./Switch.native.js";
|
|
3
|
-
export * from "./createSwitch.native.js";
|
|
4
|
-
export * from "./StyledContext.native.js";
|
|
5
|
-
export * from "./Switch.native.js";
|
|
6
|
-
export * from "./types.native.js";
|
|
7
1
|
import { useSwitchNative } from "./useSwitchNative.native.js";
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
2
|
+
|
|
3
|
+
export * from "./StyledContext.native.js"
|
|
4
|
+
|
|
5
|
+
export * from "./Switch.native.js"
|
|
6
|
+
|
|
7
|
+
export * from "./types.native.js"
|
|
8
|
+
|
|
9
|
+
export { useSwitchNative };
|
package/dist/esm/types.mjs
CHANGED
package/dist/esm/types.native.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"useSwitchNative.js","names":[],"sources":["esm/useSwitchNative.js"],"sourcesContent":["function useSwitchNative(_props) {\n return null;\n}\nexport {\n useSwitchNative\n};\n//# sourceMappingURL=useSwitchNative.js.map\n"],"mappings":";AAAA,SAAS,gBAAgB,QAAQ;CAC/B,OAAO;AACT"}
|
|
@@ -1,38 +1,37 @@
|
|
|
1
|
-
import { jsx
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { shouldRenderNativePlatform } from "@tamagui/core";
|
|
3
3
|
import { registerFocusable } from "@tamagui/focusable";
|
|
4
4
|
import * as React from "react";
|
|
5
|
-
import { Switch
|
|
5
|
+
import { Switch } from "react-native";
|
|
6
|
+
|
|
6
7
|
function useSwitchNative(props) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
return null;
|
|
8
|
+
var { id, disabled, native, nativeProps, checked, setChecked } = props;
|
|
9
|
+
React.useEffect(function() {
|
|
10
|
+
if (!id) return;
|
|
11
|
+
if (disabled) return;
|
|
12
|
+
return registerFocusable(id, {
|
|
13
|
+
focusAndSelect: function() {
|
|
14
|
+
setChecked(function(value) {
|
|
15
|
+
return !value;
|
|
16
|
+
});
|
|
17
|
+
},
|
|
18
|
+
focus: function() {}
|
|
19
|
+
});
|
|
20
|
+
}, [
|
|
21
|
+
id,
|
|
22
|
+
disabled,
|
|
23
|
+
setChecked
|
|
24
|
+
]);
|
|
25
|
+
var renderNative = shouldRenderNativePlatform(native);
|
|
26
|
+
if (renderNative === "android" || renderNative === "ios") {
|
|
27
|
+
return /* @__PURE__ */ jsx(Switch, {
|
|
28
|
+
value: checked,
|
|
29
|
+
onValueChange: setChecked,
|
|
30
|
+
...nativeProps
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
return null;
|
|
36
34
|
}
|
|
35
|
+
|
|
37
36
|
export { useSwitchNative };
|
|
38
37
|
//# sourceMappingURL=useSwitchNative.native.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"file":"useSwitchNative.native.js","names":["NativeSwitch"],"sources":["esm/useSwitchNative.native.js"],"sourcesContent":["import { jsx as _jsx } from \"react/jsx-runtime\";\nimport { shouldRenderNativePlatform } from \"@tamagui/core\";\nimport { registerFocusable } from \"@tamagui/focusable\";\nimport * as React from \"react\";\nimport { Switch as NativeSwitch } from \"react-native\";\nfunction useSwitchNative(props) {\n var { id, disabled, native, nativeProps, checked, setChecked } = props;\n React.useEffect(function() {\n if (!id) return;\n if (disabled) return;\n return registerFocusable(id, {\n focusAndSelect: function() {\n setChecked(function(value) {\n return !value;\n });\n },\n focus: function() {\n }\n });\n }, [\n id,\n disabled,\n setChecked\n ]);\n var renderNative = shouldRenderNativePlatform(native);\n if (renderNative === \"android\" || renderNative === \"ios\") {\n return /* @__PURE__ */ _jsx(NativeSwitch, {\n value: checked,\n onValueChange: setChecked,\n ...nativeProps\n });\n }\n return null;\n}\nexport {\n useSwitchNative\n};\n//# sourceMappingURL=useSwitchNative.native.js.map\n"],"mappings":";;;;;;;AAKA,SAAS,gBAAgB,OAAO;CAC9B,IAAI,EAAE,IAAI,UAAU,QAAQ,aAAa,SAAS,eAAe;CACjE,MAAM,UAAU,WAAW;EACzB,IAAI,CAAC,IAAI;EACT,IAAI,UAAU;EACd,OAAO,kBAAkB,IAAI;GAC3B,gBAAgB,WAAW;IACzB,WAAW,SAAS,OAAO;KACzB,OAAO,CAAC;IACV,CAAC;GACH;GACA,OAAO,WAAW,CAClB;EACF,CAAC;CACH,GAAG;EACD;EACA;EACA;CACF,CAAC;CACD,IAAI,eAAe,2BAA2B,MAAM;CACpD,IAAI,iBAAiB,aAAa,iBAAiB,OAAO;EACxD,OAAuB,oBAAKA,QAAc;GACxC,OAAO;GACP,eAAe;GACf,GAAG;EACL,CAAC;CACH;CACA,OAAO;AACT"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { createStyledContext } from "@tamagui/core";
|
|
2
|
+
|
|
2
3
|
const SwitchStyledContext = createStyledContext({
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
unstyled: process.env.TAMAGUI_HEADLESS === "1"
|
|
4
|
+
active: false,
|
|
5
|
+
disabled: false,
|
|
6
|
+
frameWidth: void 0,
|
|
7
|
+
size: void 0
|
|
8
8
|
});
|
|
9
|
+
|
|
9
10
|
export { SwitchStyledContext };
|
|
10
11
|
//# sourceMappingURL=StyledContext.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"StyledContext.js","names":[],"sources":["jsx/StyledContext.js"],"sourcesContent":["import { createStyledContext } from \"@tamagui/core\";\nconst SwitchStyledContext = createStyledContext({\n active: false,\n disabled: false,\n frameWidth: void 0,\n size: void 0\n});\nexport {\n SwitchStyledContext\n};\n//# sourceMappingURL=StyledContext.js.map\n"],"mappings":";;;AACA,MAAM,sBAAsB,oBAAoB;CAC9C,QAAQ;CACR,UAAU;CACV,YAAY,KAAK;CACjB,MAAM,KAAK;AACb,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all) __defProp(target, name, {
|
|
10
|
+
get: all[name],
|
|
11
|
+
enumerable: true
|
|
12
|
+
});
|
|
13
|
+
};
|
|
14
|
+
var __copyProps = (to, from, except, desc) => {
|
|
15
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
16
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
17
|
+
get: () => from[key],
|
|
18
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
return to;
|
|
22
|
+
};
|
|
23
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
24
|
+
var StyledContext_exports = {};
|
|
25
|
+
__export(StyledContext_exports, { SwitchStyledContext: () => SwitchStyledContext });
|
|
26
|
+
module.exports = __toCommonJS(StyledContext_exports);
|
|
27
|
+
var import_core = require("@tamagui/core");
|
|
28
|
+
var SwitchStyledContext = (0, import_core.createStyledContext)({
|
|
29
|
+
active: false,
|
|
30
|
+
disabled: false,
|
|
31
|
+
frameWidth: void 0,
|
|
32
|
+
size: void 0
|
|
33
|
+
});
|
|
@@ -1,38 +1,35 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
|
|
3
4
|
var __defProp = Object.defineProperty;
|
|
4
5
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
6
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
8
|
var __export = (target, all) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
for (var name in all) __defProp(target, name, {
|
|
10
|
+
get: all[name],
|
|
11
|
+
enumerable: true
|
|
12
|
+
});
|
|
12
13
|
};
|
|
13
14
|
var __copyProps = (to, from, except, desc) => {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
15
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
16
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
17
|
+
get: () => from[key],
|
|
18
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
return to;
|
|
21
22
|
};
|
|
22
|
-
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
23
|
-
value: true
|
|
24
|
-
}), mod);
|
|
23
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
24
|
var StyledContext_exports = {};
|
|
26
|
-
__export(StyledContext_exports, {
|
|
27
|
-
SwitchStyledContext: () => SwitchStyledContext
|
|
28
|
-
});
|
|
25
|
+
__export(StyledContext_exports, { SwitchStyledContext: () => SwitchStyledContext });
|
|
29
26
|
module.exports = __toCommonJS(StyledContext_exports);
|
|
30
27
|
var import_core = require("@tamagui/core");
|
|
31
28
|
var SwitchStyledContext = (0, import_core.createStyledContext)({
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
unstyled: process.env.TAMAGUI_HEADLESS === "1"
|
|
29
|
+
active: false,
|
|
30
|
+
disabled: false,
|
|
31
|
+
frameWidth: void 0,
|
|
32
|
+
size: void 0
|
|
37
33
|
});
|
|
34
|
+
|
|
38
35
|
//# sourceMappingURL=StyledContext.native.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"StyledContext.native.js","names":[],"sources":["jsx/StyledContext.native.js"],"sourcesContent":["\"use strict\";\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\nvar StyledContext_exports = {};\n__export(StyledContext_exports, {\n SwitchStyledContext: () => SwitchStyledContext\n});\nmodule.exports = __toCommonJS(StyledContext_exports);\nvar import_core = require(\"@tamagui/core\");\nvar SwitchStyledContext = (0, import_core.createStyledContext)({\n active: false,\n disabled: false,\n frameWidth: void 0,\n size: void 0\n});\n//# sourceMappingURL=StyledContext.js.map\n"],"mappings":";;;;AACA,IAAI,YAAY,OAAO;AACvB,IAAI,mBAAmB,OAAO;AAC9B,IAAI,oBAAoB,OAAO;AAC/B,IAAI,eAAe,OAAO,UAAU;AACpC,IAAI,YAAY,QAAQ,QAAQ;CAC9B,KAAK,IAAI,QAAQ,KACf,UAAU,QAAQ,MAAM;EAAE,KAAK,IAAI;EAAO,YAAY;CAAK,CAAC;AAChE;AACA,IAAI,eAAe,IAAI,MAAM,QAAQ,SAAS;CAC5C,IAAI,QAAQ,OAAO,SAAS,YAAY,OAAO,SAAS,YAAY;EAClE,KAAK,IAAI,OAAO,kBAAkB,IAAI,GACpC,IAAI,CAAC,aAAa,KAAK,IAAI,GAAG,KAAK,QAAQ,QACzC,UAAU,IAAI,KAAK;GAAE,WAAW,KAAK;GAAM,YAAY,EAAE,OAAO,iBAAiB,MAAM,GAAG,MAAM,KAAK;EAAW,CAAC;CACvH;CACA,OAAO;AACT;AACA,IAAI,gBAAgB,QAAQ,YAAY,UAAU,CAAC,GAAG,cAAc,EAAE,OAAO,KAAK,CAAC,GAAG,GAAG;AACzF,IAAI,wBAAwB,CAAC;AAC7B,SAAS,uBAAuB,EAC9B,2BAA2B,oBAC7B,CAAC;AACD,OAAO,UAAU,aAAa,qBAAqB;AACnD,IAAI,cAAc,QAAQ,eAAe;AACzC,IAAI,uBAAuB,GAAG,YAAY,qBAAqB;CAC7D,QAAQ;CACR,UAAU;CACV,YAAY,KAAK;CACjB,MAAM,KAAK;AACb,CAAC"}
|