@tamagui/switch-headless 1.113.1 → 1.113.2
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/esm/index.native.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from "./useSwitch
|
|
2
|
-
//# sourceMappingURL=index.
|
|
1
|
+
export * from "./useSwitch";
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -8,30 +8,22 @@ import * as React from "react";
|
|
|
8
8
|
function getState(checked) {
|
|
9
9
|
return checked ? "checked" : "unchecked";
|
|
10
10
|
}
|
|
11
|
-
var BubbleInput = function
|
|
12
|
-
var {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
bubbles = !0,
|
|
16
|
-
...inputProps
|
|
17
|
-
} = props,
|
|
18
|
-
ref = React.useRef(null),
|
|
19
|
-
prevChecked = usePrevious(checked);
|
|
20
|
-
return React.useEffect(function () {
|
|
21
|
-
var input = ref.current,
|
|
22
|
-
inputProto = window.HTMLInputElement.prototype,
|
|
23
|
-
descriptor = Object.getOwnPropertyDescriptor(inputProto, "checked"),
|
|
24
|
-
setChecked = descriptor.set;
|
|
11
|
+
var BubbleInput = function(props) {
|
|
12
|
+
var { control, checked, bubbles = !0, ...inputProps } = props, ref = React.useRef(null), prevChecked = usePrevious(checked);
|
|
13
|
+
return React.useEffect(function() {
|
|
14
|
+
var input = ref.current, inputProto = window.HTMLInputElement.prototype, descriptor = Object.getOwnPropertyDescriptor(inputProto, "checked"), setChecked = descriptor.set;
|
|
25
15
|
if (prevChecked !== checked && setChecked) {
|
|
26
16
|
var event = new Event("click", {
|
|
27
17
|
bubbles
|
|
28
18
|
});
|
|
29
19
|
setChecked.call(input, checked), input.dispatchEvent(event);
|
|
30
20
|
}
|
|
31
|
-
}, [
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
21
|
+
}, [
|
|
22
|
+
prevChecked,
|
|
23
|
+
checked,
|
|
24
|
+
bubbles
|
|
25
|
+
]), // @ts-ignore
|
|
26
|
+
/* @__PURE__ */ _jsx("input", {
|
|
35
27
|
type: "checkbox",
|
|
36
28
|
"aria-hidden": !0,
|
|
37
29
|
defaultChecked: checked,
|
|
@@ -48,33 +40,21 @@ var BubbleInput = function (props) {
|
|
|
48
40
|
});
|
|
49
41
|
};
|
|
50
42
|
function useSwitch(props, param, ref) {
|
|
51
|
-
var [checked, setChecked] = param,
|
|
52
|
-
{
|
|
53
|
-
disabled,
|
|
54
|
-
name,
|
|
55
|
-
value,
|
|
56
|
-
required
|
|
57
|
-
} = props,
|
|
58
|
-
hasConsumerStoppedPropagationRef = React.useRef(!1),
|
|
59
|
-
[button, setButton] = React.useState(null),
|
|
60
|
-
composedRefs = useComposedRefs(ref, setButton),
|
|
61
|
-
isFormControl = isWeb ? button ? !!button.closest("form") : !0 : !1,
|
|
62
|
-
labelId = useLabelContext(button),
|
|
63
|
-
ariaLabelledBy = props["aria-labelledby"] || props.labeledBy || labelId;
|
|
43
|
+
var [checked, setChecked] = param, { disabled, name, value, required } = props, hasConsumerStoppedPropagationRef = React.useRef(!1), [button, setButton] = React.useState(null), composedRefs = useComposedRefs(ref, setButton), isFormControl = isWeb ? button ? !!button.closest("form") : !0 : !1, labelId = useLabelContext(button), ariaLabelledBy = props["aria-labelledby"] || props.labeledBy || labelId;
|
|
64
44
|
return {
|
|
65
45
|
switchProps: {
|
|
66
46
|
role: "switch",
|
|
67
47
|
"aria-checked": checked,
|
|
68
|
-
...
|
|
48
|
+
...isWeb ? {
|
|
69
49
|
tabIndex: disabled ? void 0 : 0,
|
|
70
50
|
"data-state": getState(checked),
|
|
71
51
|
"data-disabled": disabled ? "" : void 0,
|
|
72
52
|
disabled
|
|
73
|
-
} : {}
|
|
53
|
+
} : {},
|
|
74
54
|
...props,
|
|
75
55
|
"aria-labelledby": ariaLabelledBy,
|
|
76
|
-
onPress: composeEventHandlers(props.onPress, function
|
|
77
|
-
setChecked(function
|
|
56
|
+
onPress: composeEventHandlers(props.onPress, function(event) {
|
|
57
|
+
setChecked(function(prevChecked) {
|
|
78
58
|
return !prevChecked;
|
|
79
59
|
}), isWeb && isFormControl && (hasConsumerStoppedPropagationRef.current = event.isPropagationStopped(), hasConsumerStoppedPropagationRef.current || event.stopPropagation());
|
|
80
60
|
})
|
|
@@ -83,7 +63,7 @@ function useSwitch(props, param, ref) {
|
|
|
83
63
|
/**
|
|
84
64
|
* insert as a sibling of your switch (should not be inside the switch)
|
|
85
65
|
*/
|
|
86
|
-
bubbleInput: isWeb && isFormControl ? /* @__PURE__ */_jsx(BubbleInput, {
|
|
66
|
+
bubbleInput: isWeb && isFormControl ? /* @__PURE__ */ _jsx(BubbleInput, {
|
|
87
67
|
control: button,
|
|
88
68
|
bubbles: !hasConsumerStoppedPropagationRef.current,
|
|
89
69
|
name,
|
|
@@ -100,5 +80,7 @@ function useSwitch(props, param, ref) {
|
|
|
100
80
|
}) : null
|
|
101
81
|
};
|
|
102
82
|
}
|
|
103
|
-
export {
|
|
104
|
-
|
|
83
|
+
export {
|
|
84
|
+
useSwitch
|
|
85
|
+
};
|
|
86
|
+
//# sourceMappingURL=useSwitch.js.map
|
|
@@ -1 +1,6 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/Users/n8/tamagui/code/ui/switch-headless/src/useSwitch.tsx"],
|
|
4
|
+
"mappings": ";AAAA,SAASA,uBAAuB;AAChC,SAASC,aAAa;AACtB,SAASC,4BAA4B;AACrC,SAASC,uBAAuB;AAChC,SAASC,mBAAmB;AAC5B,YAAYC,WAAW;AAmBvB,SAASC,SAASC,SAAoB;AACpC,SAAOA,UAAU,YAAY;AAC/B;AAWA,IAAMC,cAAc,SAACC,OAAAA;AACnB,MAAM,EAAEC,SAASH,SAASI,UAAU,IAAM,GAAGC,WAAAA,IAAeH,OACtDI,MAAMR,MAAMS,OAAyB,IAAA,GACrCC,cAAcX,YAAYG,OAAAA;AAGhCF,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AAC5CF,mBAAW,SAACX,aAAAA;iBAAgB,CAACA;YACzBd,SAASkD,kBACXL,iCAAiC5B,UAAUU,MAAMiC,qBAAoB,GAIhEf,iCAAiC5B,WAASU,MAAMkC,gBAAe;MAExE,CAAA;IACF;IACAC,WAAWb;;;;IAIXc,aACE/D,SAASkD,gBACP,qBAAC3C,aAAAA;MACCE,SAASqC;MACTpC,SAAS,CAACmC,iCAAiC5B;MAC3CyB;MACAC;MACArC;MACAsC;MACAH;;;;MAIAN,OAAO;QAAE6B,WAAW;MAAoB;SAExC;EACR;AACF;",
|
|
5
|
+
"names": ["useComposedRefs", "isWeb", "composeEventHandlers", "useLabelContext", "usePrevious", "React", "getState", "checked", "BubbleInput", "props", "control", "bubbles", "inputProps", "ref", "useRef", "prevChecked", "useEffect", "input", "current", "inputProto", "window", "HTMLInputElement", "prototype", "descriptor", "Object", "getOwnPropertyDescriptor", "setChecked", "set", "event", "Event", "call", "dispatchEvent", "type", "aria-hidden", "defaultChecked", "tabIndex", "style", "position", "pointerEvents", "opacity", "margin", "useSwitch", "disabled", "name", "value", "required", "hasConsumerStoppedPropagationRef", "button", "setButton", "useState", "composedRefs", "isFormControl", "Boolean", "closest", "labelId", "ariaLabelledBy", "labeledBy", "switchProps", "role", "undefined", "onPress", "isPropagationStopped", "stopPropagation", "switchRef", "bubbleInput", "transform"]
|
|
6
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/switch-headless",
|
|
3
|
-
"version": "1.113.
|
|
3
|
+
"version": "1.113.2",
|
|
4
4
|
"sideEffects": [
|
|
5
5
|
"*.css"
|
|
6
6
|
],
|
|
@@ -33,17 +33,17 @@
|
|
|
33
33
|
}
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@tamagui/compose-refs": "1.113.
|
|
37
|
-
"@tamagui/constants": "1.113.
|
|
38
|
-
"@tamagui/helpers": "1.113.
|
|
39
|
-
"@tamagui/label": "1.113.
|
|
40
|
-
"@tamagui/use-previous": "1.113.
|
|
36
|
+
"@tamagui/compose-refs": "1.113.2",
|
|
37
|
+
"@tamagui/constants": "1.113.2",
|
|
38
|
+
"@tamagui/helpers": "1.113.2",
|
|
39
|
+
"@tamagui/label": "1.113.2",
|
|
40
|
+
"@tamagui/use-previous": "1.113.2"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
43
|
"react": "*"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"@tamagui/build": "1.113.
|
|
46
|
+
"@tamagui/build": "1.113.2",
|
|
47
47
|
"react": "^18.2.0 || ^19.0.0",
|
|
48
48
|
"react-native": "0.74.1"
|
|
49
49
|
},
|