@tamagui/checkbox-headless 1.110.4 → 1.111.0
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/BubbleInput.native.js +19 -73
- package/dist/cjs/BubbleInput.native.js.map +1 -1
- package/dist/cjs/useCheckbox.native.js +15 -113
- package/dist/cjs/useCheckbox.native.js.map +2 -2
- package/dist/esm/BubbleInput.native.js +18 -71
- package/dist/esm/BubbleInput.native.js.map +1 -1
- package/dist/esm/BubbleInput.native.mjs +49 -0
- package/dist/esm/BubbleInput.native.mjs.map +1 -0
- package/dist/esm/index.native.mjs +3 -0
- package/dist/esm/index.native.mjs.map +1 -0
- package/dist/esm/useCheckbox.native.js +15 -113
- package/dist/esm/useCheckbox.native.js.map +2 -2
- package/dist/esm/useCheckbox.native.mjs +64 -0
- package/dist/esm/useCheckbox.native.mjs.map +1 -0
- package/dist/esm/utils.native.mjs +8 -0
- package/dist/esm/utils.native.mjs.map +1 -0
- package/dist/jsx/BubbleInput.native.js +18 -71
- package/dist/jsx/BubbleInput.native.js.map +1 -1
- package/dist/jsx/useCheckbox.native.js +15 -113
- package/dist/jsx/useCheckbox.native.js.map +2 -2
- package/package.json +10 -10
|
@@ -26,65 +26,8 @@ __export(BubbleInput_exports, {
|
|
|
26
26
|
BubbleInput: () => BubbleInput
|
|
27
27
|
});
|
|
28
28
|
module.exports = __toCommonJS(BubbleInput_exports);
|
|
29
|
-
var import_jsx_runtime = require("react/jsx-runtime"), import_use_previous = require("@tamagui/use-previous"), React = __toESM(require("react")), import_utils = require("./utils")
|
|
30
|
-
|
|
31
|
-
return key in obj ? Object.defineProperty(obj, key, {
|
|
32
|
-
value,
|
|
33
|
-
enumerable: !0,
|
|
34
|
-
configurable: !0,
|
|
35
|
-
writable: !0
|
|
36
|
-
}) : obj[key] = value, obj;
|
|
37
|
-
}
|
|
38
|
-
function _object_spread(target) {
|
|
39
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
40
|
-
var source = arguments[i] != null ? arguments[i] : {}, ownKeys2 = Object.keys(source);
|
|
41
|
-
typeof Object.getOwnPropertySymbols == "function" && (ownKeys2 = ownKeys2.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
42
|
-
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
43
|
-
}))), ownKeys2.forEach(function(key) {
|
|
44
|
-
_define_property(target, key, source[key]);
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
return target;
|
|
48
|
-
}
|
|
49
|
-
function ownKeys(object, enumerableOnly) {
|
|
50
|
-
var keys = Object.keys(object);
|
|
51
|
-
if (Object.getOwnPropertySymbols) {
|
|
52
|
-
var symbols = Object.getOwnPropertySymbols(object);
|
|
53
|
-
enumerableOnly && (symbols = symbols.filter(function(sym) {
|
|
54
|
-
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
55
|
-
})), keys.push.apply(keys, symbols);
|
|
56
|
-
}
|
|
57
|
-
return keys;
|
|
58
|
-
}
|
|
59
|
-
function _object_spread_props(target, source) {
|
|
60
|
-
return source = source ?? {}, Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function(key) {
|
|
61
|
-
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
62
|
-
}), target;
|
|
63
|
-
}
|
|
64
|
-
function _object_without_properties(source, excluded) {
|
|
65
|
-
if (source == null) return {};
|
|
66
|
-
var target = _object_without_properties_loose(source, excluded), key, i;
|
|
67
|
-
if (Object.getOwnPropertySymbols) {
|
|
68
|
-
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
|
69
|
-
for (i = 0; i < sourceSymbolKeys.length; i++)
|
|
70
|
-
key = sourceSymbolKeys[i], !(excluded.indexOf(key) >= 0) && Object.prototype.propertyIsEnumerable.call(source, key) && (target[key] = source[key]);
|
|
71
|
-
}
|
|
72
|
-
return target;
|
|
73
|
-
}
|
|
74
|
-
function _object_without_properties_loose(source, excluded) {
|
|
75
|
-
if (source == null) return {};
|
|
76
|
-
var target = {}, sourceKeys = Object.keys(source), key, i;
|
|
77
|
-
for (i = 0; i < sourceKeys.length; i++)
|
|
78
|
-
key = sourceKeys[i], !(excluded.indexOf(key) >= 0) && (target[key] = source[key]);
|
|
79
|
-
return target;
|
|
80
|
-
}
|
|
81
|
-
var BubbleInput = function(props) {
|
|
82
|
-
var checked = props.checked, _props_bubbles = props.bubbles, bubbles = _props_bubbles === void 0 ? !0 : _props_bubbles, control = props.control, isHidden = props.isHidden, inputProps = _object_without_properties(props, [
|
|
83
|
-
"checked",
|
|
84
|
-
"bubbles",
|
|
85
|
-
"control",
|
|
86
|
-
"isHidden"
|
|
87
|
-
]), ref = React.useRef(null), prevChecked = (0, import_use_previous.usePrevious)(checked);
|
|
29
|
+
var import_jsx_runtime = require("react/jsx-runtime"), import_use_previous = require("@tamagui/use-previous"), React = __toESM(require("react")), import_utils = require("./utils"), BubbleInput = function(props) {
|
|
30
|
+
var { checked, bubbles = !0, control, isHidden, ...inputProps } = props, ref = React.useRef(null), prevChecked = (0, import_use_previous.usePrevious)(checked);
|
|
88
31
|
return React.useEffect(function() {
|
|
89
32
|
var input = ref.current, inputProto = window.HTMLInputElement.prototype, descriptor = Object.getOwnPropertyDescriptor(inputProto, "checked"), setChecked = descriptor.set;
|
|
90
33
|
if (prevChecked !== checked && setChecked) {
|
|
@@ -97,24 +40,27 @@ var BubbleInput = function(props) {
|
|
|
97
40
|
prevChecked,
|
|
98
41
|
checked,
|
|
99
42
|
bubbles
|
|
100
|
-
]), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input",
|
|
43
|
+
]), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", {
|
|
101
44
|
type: "checkbox",
|
|
102
|
-
defaultChecked: (0, import_utils.isIndeterminate)(checked) ? !1 : checked
|
|
103
|
-
|
|
45
|
+
defaultChecked: (0, import_utils.isIndeterminate)(checked) ? !1 : checked,
|
|
46
|
+
...inputProps,
|
|
104
47
|
tabIndex: -1,
|
|
105
48
|
ref,
|
|
106
49
|
"aria-hidden": isHidden,
|
|
107
|
-
style:
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
50
|
+
style: {
|
|
51
|
+
...isHidden ? {
|
|
52
|
+
// ...controlSize,
|
|
53
|
+
position: "absolute",
|
|
54
|
+
pointerEvents: "none",
|
|
55
|
+
opacity: 0,
|
|
56
|
+
margin: 0
|
|
57
|
+
} : {
|
|
58
|
+
appearance: "auto",
|
|
59
|
+
accentColor: "var(--color6)"
|
|
60
|
+
},
|
|
61
|
+
...props.style
|
|
62
|
+
}
|
|
63
|
+
});
|
|
118
64
|
};
|
|
119
65
|
// Annotate the CommonJS export names for ESM import in node:
|
|
120
66
|
0 && (module.exports = {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/Users/n8/tamagui/code/ui/checkbox-headless/src/BubbleInput.tsx"],
|
|
4
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;uDAAA,sBAA4B,kCAC5B,QAAuB,2BAGvB,eAAgC
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;uDAAA,sBAA4B,kCAC5B,QAAuB,2BAGvB,eAAgC,oBAUnBA,cAAc,SAACC,OAAAA;AAC1B,MAAM,EAAEC,SAASC,UAAU,IAAMC,SAASC,UAAU,GAAGC,WAAAA,IAAeL,OAChEM,MAAMC,MAAMC,OAAyB,IAAA,GACrCC,kBAAcC,iCAAYT,OAAAA;AAGhCM,eAAMI,UAAU,WAAA;AACd,QAAMC,QAAQN,IAAIO,SACZC,aAAaC,OAAOC,iBAAiBC,WACrCC,aAAaC,OAAOC,yBACxBN,YACA,SAAA,GAEIO,aAAaH,WAAWI;AAE9B,QAAIb,gBAAgBR,WAAWoB,YAAY;AACzC,UAAME,QAAQ,IAAIC,MAAM,SAAS;QAAEtB;MAAQ,CAAA;AAC3CU,YAAMa,oBAAgBC,8BAAgBzB,OAAAA,GACtCoB,WAAWM,KAAKf,WAAOc,8BAAgBzB,OAAAA,IAAW,KAAQA,OAAAA,GAC1DW,MAAMgB,cAAcL,KAAAA;IACtB;EACF,GAAG;IAACd;IAAaR;IAASC;GAAQ,GAGhC,uCAAA2B,KAACjB,SAAAA;IACCkB,MAAK;IACLC,oBAAgBL,8BAAgBzB,OAAAA,IAAW,KAAQA;IAClD,GAAGI;IACJ2B,UAAU;IACV1B;IACA2B,eAAa7B;IACb8B,OAAO;MACL,GAAI9B,WACA;;QAEE+B,UAAU;QACVC,eAAe;QACfC,SAAS;QACTC,QAAQ;MACV,IACA;QACEC,YAAY;QACZC,aAAa;MACf;MAEJ,GAAGxC,MAAMkC;IACX;;AAGN;",
|
|
5
5
|
"names": ["BubbleInput", "props", "checked", "bubbles", "control", "isHidden", "inputProps", "ref", "React", "useRef", "prevChecked", "usePrevious", "useEffect", "input", "current", "inputProto", "window", "HTMLInputElement", "prototype", "descriptor", "Object", "getOwnPropertyDescriptor", "setChecked", "set", "event", "Event", "indeterminate", "isIndeterminate", "call", "dispatchEvent", "_jsx", "type", "defaultChecked", "tabIndex", "aria-hidden", "style", "position", "pointerEvents", "opacity", "margin", "appearance", "accentColor"]
|
|
6
6
|
}
|
|
@@ -27,107 +27,8 @@ __export(useCheckbox_exports, {
|
|
|
27
27
|
});
|
|
28
28
|
module.exports = __toCommonJS(useCheckbox_exports);
|
|
29
29
|
var import_jsx_runtime = require("react/jsx-runtime"), import_compose_refs = require("@tamagui/compose-refs"), import_constants = require("@tamagui/constants"), import_helpers = require("@tamagui/helpers"), import_label = require("@tamagui/label"), import_react = __toESM(require("react")), import_BubbleInput = require("./BubbleInput"), import_utils = require("./utils");
|
|
30
|
-
function _array_like_to_array(arr, len) {
|
|
31
|
-
(len == null || len > arr.length) && (len = arr.length);
|
|
32
|
-
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
33
|
-
return arr2;
|
|
34
|
-
}
|
|
35
|
-
function _array_with_holes(arr) {
|
|
36
|
-
if (Array.isArray(arr)) return arr;
|
|
37
|
-
}
|
|
38
|
-
function _define_property(obj, key, value) {
|
|
39
|
-
return key in obj ? Object.defineProperty(obj, key, {
|
|
40
|
-
value,
|
|
41
|
-
enumerable: !0,
|
|
42
|
-
configurable: !0,
|
|
43
|
-
writable: !0
|
|
44
|
-
}) : obj[key] = value, obj;
|
|
45
|
-
}
|
|
46
|
-
function _iterable_to_array_limit(arr, i) {
|
|
47
|
-
var _i = arr == null ? null : typeof Symbol < "u" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
48
|
-
if (_i != null) {
|
|
49
|
-
var _arr = [], _n = !0, _d = !1, _s, _e;
|
|
50
|
-
try {
|
|
51
|
-
for (_i = _i.call(arr); !(_n = (_s = _i.next()).done) && (_arr.push(_s.value), !(i && _arr.length === i)); _n = !0)
|
|
52
|
-
;
|
|
53
|
-
} catch (err) {
|
|
54
|
-
_d = !0, _e = err;
|
|
55
|
-
} finally {
|
|
56
|
-
try {
|
|
57
|
-
!_n && _i.return != null && _i.return();
|
|
58
|
-
} finally {
|
|
59
|
-
if (_d) throw _e;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
return _arr;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
function _non_iterable_rest() {
|
|
66
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
67
|
-
}
|
|
68
|
-
function _object_spread(target) {
|
|
69
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
70
|
-
var source = arguments[i] != null ? arguments[i] : {}, ownKeys2 = Object.keys(source);
|
|
71
|
-
typeof Object.getOwnPropertySymbols == "function" && (ownKeys2 = ownKeys2.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
72
|
-
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
73
|
-
}))), ownKeys2.forEach(function(key) {
|
|
74
|
-
_define_property(target, key, source[key]);
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
return target;
|
|
78
|
-
}
|
|
79
|
-
function ownKeys(object, enumerableOnly) {
|
|
80
|
-
var keys = Object.keys(object);
|
|
81
|
-
if (Object.getOwnPropertySymbols) {
|
|
82
|
-
var symbols = Object.getOwnPropertySymbols(object);
|
|
83
|
-
enumerableOnly && (symbols = symbols.filter(function(sym) {
|
|
84
|
-
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
85
|
-
})), keys.push.apply(keys, symbols);
|
|
86
|
-
}
|
|
87
|
-
return keys;
|
|
88
|
-
}
|
|
89
|
-
function _object_spread_props(target, source) {
|
|
90
|
-
return source = source ?? {}, Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function(key) {
|
|
91
|
-
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
92
|
-
}), target;
|
|
93
|
-
}
|
|
94
|
-
function _object_without_properties(source, excluded) {
|
|
95
|
-
if (source == null) return {};
|
|
96
|
-
var target = _object_without_properties_loose(source, excluded), key, i;
|
|
97
|
-
if (Object.getOwnPropertySymbols) {
|
|
98
|
-
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
|
99
|
-
for (i = 0; i < sourceSymbolKeys.length; i++)
|
|
100
|
-
key = sourceSymbolKeys[i], !(excluded.indexOf(key) >= 0) && Object.prototype.propertyIsEnumerable.call(source, key) && (target[key] = source[key]);
|
|
101
|
-
}
|
|
102
|
-
return target;
|
|
103
|
-
}
|
|
104
|
-
function _object_without_properties_loose(source, excluded) {
|
|
105
|
-
if (source == null) return {};
|
|
106
|
-
var target = {}, sourceKeys = Object.keys(source), key, i;
|
|
107
|
-
for (i = 0; i < sourceKeys.length; i++)
|
|
108
|
-
key = sourceKeys[i], !(excluded.indexOf(key) >= 0) && (target[key] = source[key]);
|
|
109
|
-
return target;
|
|
110
|
-
}
|
|
111
|
-
function _sliced_to_array(arr, i) {
|
|
112
|
-
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
113
|
-
}
|
|
114
|
-
function _unsupported_iterable_to_array(o, minLen) {
|
|
115
|
-
if (o) {
|
|
116
|
-
if (typeof o == "string") return _array_like_to_array(o, minLen);
|
|
117
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
118
|
-
if (n === "Object" && o.constructor && (n = o.constructor.name), n === "Map" || n === "Set") return Array.from(n);
|
|
119
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
30
|
function useCheckbox(props, param, ref) {
|
|
123
|
-
var
|
|
124
|
-
"labelledBy",
|
|
125
|
-
"name",
|
|
126
|
-
"required",
|
|
127
|
-
"disabled",
|
|
128
|
-
"value",
|
|
129
|
-
"onCheckedChange"
|
|
130
|
-
]), _React_useState = _sliced_to_array(import_react.default.useState(null), 2), button = _React_useState[0], setButton = _React_useState[1], composedRefs = (0, import_compose_refs.useComposedRefs)(ref, function(node) {
|
|
31
|
+
var [checked, setChecked] = param, { labelledBy: ariaLabelledby, name, required, disabled, value = "on", onCheckedChange, ...checkboxProps } = props, [button, setButton] = import_react.default.useState(null), composedRefs = (0, import_compose_refs.useComposedRefs)(ref, function(node) {
|
|
131
32
|
return setButton(node);
|
|
132
33
|
}), hasConsumerStoppedPropagationRef = import_react.default.useRef(!1), isFormControl = import_constants.isWeb ? button ? !!button.closest("form") : !0 : !1, labelId = (0, import_label.useLabelContext)(button), labelledBy = ariaLabelledby || labelId;
|
|
133
34
|
return {
|
|
@@ -142,26 +43,27 @@ function useCheckbox(props, param, ref) {
|
|
|
142
43
|
disabled
|
|
143
44
|
}) : null,
|
|
144
45
|
checkboxRef: composedRefs,
|
|
145
|
-
checkboxProps:
|
|
46
|
+
checkboxProps: {
|
|
146
47
|
role: "checkbox",
|
|
147
48
|
"aria-labelledby": labelledBy,
|
|
148
|
-
"aria-checked": (0, import_utils.isIndeterminate)(checked) ? "mixed" : checked
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
49
|
+
"aria-checked": (0, import_utils.isIndeterminate)(checked) ? "mixed" : checked,
|
|
50
|
+
...checkboxProps,
|
|
51
|
+
...import_constants.isWeb && {
|
|
52
|
+
type: "button",
|
|
53
|
+
value,
|
|
54
|
+
"data-state": (0, import_utils.getState)(checked),
|
|
55
|
+
"data-disabled": disabled ? "" : void 0,
|
|
56
|
+
disabled,
|
|
57
|
+
onKeyDown: (0, import_helpers.composeEventHandlers)(props.onKeyDown, function(event) {
|
|
58
|
+
event.key === "Enter" && event.preventDefault();
|
|
59
|
+
})
|
|
60
|
+
},
|
|
159
61
|
onPress: (0, import_helpers.composeEventHandlers)(props.onPress, function(event) {
|
|
160
62
|
setChecked(function(prevChecked) {
|
|
161
63
|
return (0, import_utils.isIndeterminate)(prevChecked) ? !0 : !prevChecked;
|
|
162
64
|
}), isFormControl && "isPropagationStopped" in event && (hasConsumerStoppedPropagationRef.current = event.isPropagationStopped(), hasConsumerStoppedPropagationRef.current || event.stopPropagation());
|
|
163
65
|
})
|
|
164
|
-
}
|
|
66
|
+
}
|
|
165
67
|
};
|
|
166
68
|
}
|
|
167
69
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/Users/n8/tamagui/code/ui/checkbox-headless/src/useCheckbox.tsx"],
|
|
4
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;uDAAA,sBAAgC,kCAChC,mBAAsB,+BAEtB,iBAAqC,6BACrC,eAAgC,2BAChC,eAAkB,2BAGlB,qBAA4B,0BAC5B,eAA0C
|
|
5
|
-
"names": ["useCheckbox", "props", "ref", "checked", "setChecked", "
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;uDAAA,sBAAgC,kCAChC,mBAAsB,+BAEtB,iBAAqC,6BACrC,eAAgC,2BAChC,eAAkB,2BAGlB,qBAA4B,0BAC5B,eAA0C;AAyBnC,SAASA,YACdC,OACA,OAIAC,KAAiB;MAJjB,CAACC,SAASC,UAAAA,IAAV,OAMM,EACJC,YAAYC,gBACZC,MACAC,UACAC,UACAC,QAAQ,MACRC,iBACA,GAAGC,cAAAA,IACDX,OACE,CAACY,QAAQC,SAAAA,IAAaC,aAAAA,QAAMC,SAAmC,IAAA,GAC/DC,mBAAeC,qCAAgBhB,KAAK,SAACiB,MAAAA;WAASL,UAAUK,IAAAA;MACxDC,mCAAmCL,aAAAA,QAAMM,OAAO,EAAA,GAEhDC,gBAAgBC,yBAASV,SAASW,EAAQX,OAAOY,QAAQ,MAAA,IAAW,KAAQ,IAE5EC,cAAUC,8BAAgBd,MAAAA,GAC1BR,aAAaC,kBAAkBoB;AAErC,SAAO;IACLE,aACEL,0BAASD,gBACP,uCAAAO,KAACC,gCAAAA;MACCC,UAAQ;MACRC,SAASnB;MACToB,SAAS,CAACb,iCAAiCc;MAC3C3B;MACAG;MACAP;MACAK;MACAC;SAEA;IACN0B,aAAalB;IACbL,eAAe;MACbwB,MAAM;MACN,mBAAmB/B;MACnB,oBAAgBgC,8BAAgBlC,OAAAA,IAAW,UAAUA;MACrD,GAAGS;MACH,GAAIW,0BAAS;QACXe,MAAM;QACN5B;QACA,kBAAc6B,uBAASpC,OAAAA;QACvB,iBAAiBM,WAAW,KAAK+B;QACjC/B;QACAgC,eAAWC,qCACRzC,MAA6CwC,WAC9C,SAACE,OAAAA;AAEC,UAAIA,MAAMC,QAAQ,WAASD,MAAME,eAAc;QACjD,CAAA;MAEJ;MACAC,aAASJ,qCACPzC,MAAM6C,SACN,SAACH,OAAAA;AACCvC,mBAAW,SAAC2C,aAAAA;qBACVV,8BAAgBU,WAAAA,IAAe,KAAO,CAACA;YAErCzB,iBAAiB,0BAA0BqB,UAC7CvB,iCAAiCc,UAAUS,MAAMK,qBAAoB,GAIhE5B,iCAAiCc,WAASS,MAAMM,gBAAe;MAExE,CAAA;IAEJ;EACF;AACF;",
|
|
5
|
+
"names": ["useCheckbox", "props", "ref", "checked", "setChecked", "labelledBy", "ariaLabelledby", "name", "required", "disabled", "value", "onCheckedChange", "checkboxProps", "button", "setButton", "React", "useState", "composedRefs", "useComposedRefs", "node", "hasConsumerStoppedPropagationRef", "useRef", "isFormControl", "isWeb", "Boolean", "closest", "labelId", "useLabelContext", "bubbleInput", "_jsx", "BubbleInput", "isHidden", "control", "bubbles", "current", "checkboxRef", "role", "isIndeterminate", "type", "getState", "undefined", "onKeyDown", "composeEventHandlers", "event", "key", "preventDefault", "onPress", "prevChecked", "isPropagationStopped", "stopPropagation"]
|
|
6
6
|
}
|
|
@@ -2,64 +2,8 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { usePrevious } from "@tamagui/use-previous";
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
import { isIndeterminate } from "./utils";
|
|
5
|
-
function _define_property(obj, key, value) {
|
|
6
|
-
return key in obj ? Object.defineProperty(obj, key, {
|
|
7
|
-
value,
|
|
8
|
-
enumerable: !0,
|
|
9
|
-
configurable: !0,
|
|
10
|
-
writable: !0
|
|
11
|
-
}) : obj[key] = value, obj;
|
|
12
|
-
}
|
|
13
|
-
function _object_spread(target) {
|
|
14
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
15
|
-
var source = arguments[i] != null ? arguments[i] : {}, ownKeys2 = Object.keys(source);
|
|
16
|
-
typeof Object.getOwnPropertySymbols == "function" && (ownKeys2 = ownKeys2.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
17
|
-
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
18
|
-
}))), ownKeys2.forEach(function(key) {
|
|
19
|
-
_define_property(target, key, source[key]);
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
return target;
|
|
23
|
-
}
|
|
24
|
-
function ownKeys(object, enumerableOnly) {
|
|
25
|
-
var keys = Object.keys(object);
|
|
26
|
-
if (Object.getOwnPropertySymbols) {
|
|
27
|
-
var symbols = Object.getOwnPropertySymbols(object);
|
|
28
|
-
enumerableOnly && (symbols = symbols.filter(function(sym) {
|
|
29
|
-
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
30
|
-
})), keys.push.apply(keys, symbols);
|
|
31
|
-
}
|
|
32
|
-
return keys;
|
|
33
|
-
}
|
|
34
|
-
function _object_spread_props(target, source) {
|
|
35
|
-
return source = source ?? {}, Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function(key) {
|
|
36
|
-
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
37
|
-
}), target;
|
|
38
|
-
}
|
|
39
|
-
function _object_without_properties(source, excluded) {
|
|
40
|
-
if (source == null) return {};
|
|
41
|
-
var target = _object_without_properties_loose(source, excluded), key, i;
|
|
42
|
-
if (Object.getOwnPropertySymbols) {
|
|
43
|
-
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
|
44
|
-
for (i = 0; i < sourceSymbolKeys.length; i++)
|
|
45
|
-
key = sourceSymbolKeys[i], !(excluded.indexOf(key) >= 0) && Object.prototype.propertyIsEnumerable.call(source, key) && (target[key] = source[key]);
|
|
46
|
-
}
|
|
47
|
-
return target;
|
|
48
|
-
}
|
|
49
|
-
function _object_without_properties_loose(source, excluded) {
|
|
50
|
-
if (source == null) return {};
|
|
51
|
-
var target = {}, sourceKeys = Object.keys(source), key, i;
|
|
52
|
-
for (i = 0; i < sourceKeys.length; i++)
|
|
53
|
-
key = sourceKeys[i], !(excluded.indexOf(key) >= 0) && (target[key] = source[key]);
|
|
54
|
-
return target;
|
|
55
|
-
}
|
|
56
5
|
var BubbleInput = function(props) {
|
|
57
|
-
var
|
|
58
|
-
"checked",
|
|
59
|
-
"bubbles",
|
|
60
|
-
"control",
|
|
61
|
-
"isHidden"
|
|
62
|
-
]), ref = React.useRef(null), prevChecked = usePrevious(checked);
|
|
6
|
+
var { checked, bubbles = !0, control, isHidden, ...inputProps } = props, ref = React.useRef(null), prevChecked = usePrevious(checked);
|
|
63
7
|
return React.useEffect(function() {
|
|
64
8
|
var input = ref.current, inputProto = window.HTMLInputElement.prototype, descriptor = Object.getOwnPropertyDescriptor(inputProto, "checked"), setChecked = descriptor.set;
|
|
65
9
|
if (prevChecked !== checked && setChecked) {
|
|
@@ -72,24 +16,27 @@ var BubbleInput = function(props) {
|
|
|
72
16
|
prevChecked,
|
|
73
17
|
checked,
|
|
74
18
|
bubbles
|
|
75
|
-
]), /* @__PURE__ */ _jsx("input",
|
|
19
|
+
]), /* @__PURE__ */ _jsx("input", {
|
|
76
20
|
type: "checkbox",
|
|
77
|
-
defaultChecked: isIndeterminate(checked) ? !1 : checked
|
|
78
|
-
|
|
21
|
+
defaultChecked: isIndeterminate(checked) ? !1 : checked,
|
|
22
|
+
...inputProps,
|
|
79
23
|
tabIndex: -1,
|
|
80
24
|
ref,
|
|
81
25
|
"aria-hidden": isHidden,
|
|
82
|
-
style:
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
26
|
+
style: {
|
|
27
|
+
...isHidden ? {
|
|
28
|
+
// ...controlSize,
|
|
29
|
+
position: "absolute",
|
|
30
|
+
pointerEvents: "none",
|
|
31
|
+
opacity: 0,
|
|
32
|
+
margin: 0
|
|
33
|
+
} : {
|
|
34
|
+
appearance: "auto",
|
|
35
|
+
accentColor: "var(--color6)"
|
|
36
|
+
},
|
|
37
|
+
...props.style
|
|
38
|
+
}
|
|
39
|
+
});
|
|
93
40
|
};
|
|
94
41
|
export {
|
|
95
42
|
BubbleInput
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/Users/n8/tamagui/code/ui/checkbox-headless/src/BubbleInput.tsx"],
|
|
4
|
-
"mappings": ";AAAA,SAASA,mBAAmB;AAC5B,YAAYC,WAAW;AAGvB,SAASC,uBAAuB
|
|
4
|
+
"mappings": ";AAAA,SAASA,mBAAmB;AAC5B,YAAYC,WAAW;AAGvB,SAASC,uBAAuB;AAUzB,IAAMC,cAAc,SAACC,OAAAA;AAC1B,MAAM,EAAEC,SAASC,UAAU,IAAMC,SAASC,UAAU,GAAGC,WAAAA,IAAeL,OAChEM,MAAMT,MAAMU,OAAyB,IAAA,GACrCC,cAAcZ,YAAYK,OAAAA;AAGhCJ,eAAMY,UAAU,WAAA;AACd,QAAMC,QAAQJ,IAAIK,SACZC,aAAaC,OAAOC,iBAAiBC,WACrCC,aAAaC,OAAOC,yBACxBN,YACA,SAAA,GAEIO,aAAaH,WAAWI;AAE9B,QAAIZ,gBAAgBP,WAAWkB,YAAY;AACzC,UAAME,QAAQ,IAAIC,MAAM,SAAS;QAAEpB;MAAQ,CAAA;AAC3CQ,YAAMa,gBAAgBzB,gBAAgBG,OAAAA,GACtCkB,WAAWK,KAAKd,OAAOZ,gBAAgBG,OAAAA,IAAW,KAAQA,OAAAA,GAC1DS,MAAMe,cAAcJ,KAAAA;IACtB;EACF,GAAG;IAACb;IAAaP;IAASC;GAAQ,GAGhC,qBAACQ,SAAAA;IACCgB,MAAK;IACLC,gBAAgB7B,gBAAgBG,OAAAA,IAAW,KAAQA;IAClD,GAAGI;IACJuB,UAAU;IACVtB;IACAuB,eAAazB;IACb0B,OAAO;MACL,GAAI1B,WACA;;QAEE2B,UAAU;QACVC,eAAe;QACfC,SAAS;QACTC,QAAQ;MACV,IACA;QACEC,YAAY;QACZC,aAAa;MACf;MAEJ,GAAGpC,MAAM8B;IACX;;AAGN;",
|
|
5
5
|
"names": ["usePrevious", "React", "isIndeterminate", "BubbleInput", "props", "checked", "bubbles", "control", "isHidden", "inputProps", "ref", "useRef", "prevChecked", "useEffect", "input", "current", "inputProto", "window", "HTMLInputElement", "prototype", "descriptor", "Object", "getOwnPropertyDescriptor", "setChecked", "set", "event", "Event", "indeterminate", "call", "dispatchEvent", "type", "defaultChecked", "tabIndex", "aria-hidden", "style", "position", "pointerEvents", "opacity", "margin", "appearance", "accentColor"]
|
|
6
6
|
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { usePrevious } from "@tamagui/use-previous";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { isIndeterminate } from "./utils.mjs";
|
|
5
|
+
var BubbleInput = function (props) {
|
|
6
|
+
var {
|
|
7
|
+
checked,
|
|
8
|
+
bubbles = !0,
|
|
9
|
+
control,
|
|
10
|
+
isHidden,
|
|
11
|
+
...inputProps
|
|
12
|
+
} = props,
|
|
13
|
+
ref = React.useRef(null),
|
|
14
|
+
prevChecked = usePrevious(checked);
|
|
15
|
+
return React.useEffect(function () {
|
|
16
|
+
var input = ref.current,
|
|
17
|
+
inputProto = window.HTMLInputElement.prototype,
|
|
18
|
+
descriptor = Object.getOwnPropertyDescriptor(inputProto, "checked"),
|
|
19
|
+
setChecked = descriptor.set;
|
|
20
|
+
if (prevChecked !== checked && setChecked) {
|
|
21
|
+
var event = new Event("click", {
|
|
22
|
+
bubbles
|
|
23
|
+
});
|
|
24
|
+
input.indeterminate = isIndeterminate(checked), setChecked.call(input, isIndeterminate(checked) ? !1 : checked), input.dispatchEvent(event);
|
|
25
|
+
}
|
|
26
|
+
}, [prevChecked, checked, bubbles]), /* @__PURE__ */_jsx("input", {
|
|
27
|
+
type: "checkbox",
|
|
28
|
+
defaultChecked: isIndeterminate(checked) ? !1 : checked,
|
|
29
|
+
...inputProps,
|
|
30
|
+
tabIndex: -1,
|
|
31
|
+
ref,
|
|
32
|
+
"aria-hidden": isHidden,
|
|
33
|
+
style: {
|
|
34
|
+
...(isHidden ? {
|
|
35
|
+
// ...controlSize,
|
|
36
|
+
position: "absolute",
|
|
37
|
+
pointerEvents: "none",
|
|
38
|
+
opacity: 0,
|
|
39
|
+
margin: 0
|
|
40
|
+
} : {
|
|
41
|
+
appearance: "auto",
|
|
42
|
+
accentColor: "var(--color6)"
|
|
43
|
+
}),
|
|
44
|
+
...props.style
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
};
|
|
48
|
+
export { BubbleInput };
|
|
49
|
+
//# sourceMappingURL=BubbleInput.native.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["jsx","_jsx","usePrevious","React","isIndeterminate","BubbleInput","props","checked","bubbles","control","isHidden","inputProps","ref","useRef","prevChecked","useEffect","input","current","inputProto","window","HTMLInputElement","prototype","descriptor","Object","getOwnPropertyDescriptor","setChecked","set","event","Event","indeterminate","call","dispatchEvent","type","defaultChecked","tabIndex","style","position","pointerEvents","opacity","margin","appearance","accentColor"],"sources":["../../src/BubbleInput.tsx"],"sourcesContent":[null],"mappings":"AAAA,SAASA,GAAA,IAAAC,IAAA,QAAmB;AAC5B,SAAAC,WAAY,QAAW;AAGvB,YAASC,KAAA;AAkCL,SAAAC,eAAA;AAxBG,IAAAC,WAAM,YAAAA,CAAeC,KAA4B;EACtD;MAAMC,OAAE;MAAAC,OAAS,KAAU;MAAAC,OAAM;MAAAC,QAAS;MAAA,GAAUC;IAAG,IAAWL,KAAI;IAAAM,GAChE,GAAAT,KAAM,CAAAU,MAAM,KAAyB;IAAIC,WACzC,GAAAZ,WAAc,CAAAK,OAAY;EAGhC,OAAAJ,KAAA,CAAMY,SAAA,CAAU,YAAM;IACpB,IAAAC,KAAM,GAAAJ,GAAQ,CAAAK,OAAI;MAAAC,UACZ,GAAAC,MAAa,CAAAC,gBAAO,CAAAC,SAAiB;MAAAC,UAKrC,GAAAC,MAJa,CAAAC,wBAAO,CAAAN,UAAA;MAAAO,UAAA,GAAAH,UAAA,CAAAI,GAAA;IAAA,IACxBZ,WAAA,KAAAP,OAAA,IAAAkB,UAAA;MACA,IAAAE,KAAA,OAAAC,KAAA;QAE4BpB;MAE9B,EAAI;MACFQ,KAAA,CAAMa,aAAY,GAAAzB,eAAiB,CAAAG,OAAS,GAAAkB,UAAA,CAAAK,IAAA,CAAAd,KAAA,EAAAZ,eAAA,CAAAG,OAAA,SAAAA,OAAA,GAAAS,KAAA,CAAAe,aAAA,CAAAJ,KAAA;IAC5C;EAEyB,GAC3B,CACFb,WAAI,EAGDP,OAAA,EAAAC,OAAA,IACC,eAAKP,IAAA;IAAA+B,IACL;IAAmDC,cAC/C,EAAA7B,eAAA,CAAAG,OAAA,SAAAA,OAAA;IAAA,GACJI,UAAU;IAAAuB,QACV;IAAAtB,GACA;IAAa,aACN,EAAAF,QAAA;IAAAyB,KACL,EAAI;MACA,IAAAzB,QAAA;QAAA;QAEY0B,QACV,YAAe;QAAAC,aACN;QAAAC,OACT,GAAQ;QACVC,MACA;MAAA,IACE;QAAYC,UACZ,QAAa;QACfC,WAAA;MAAA;MAGN,GAAAnC,KAAA,CAAA6B;IAAA;EACF;AAEJ","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA,cAAc;AACd,cAAc","ignoreList":[]}
|
|
@@ -6,107 +6,8 @@ import { useLabelContext } from "@tamagui/label";
|
|
|
6
6
|
import React from "react";
|
|
7
7
|
import { BubbleInput } from "./BubbleInput";
|
|
8
8
|
import { getState, isIndeterminate } from "./utils";
|
|
9
|
-
function _array_like_to_array(arr, len) {
|
|
10
|
-
(len == null || len > arr.length) && (len = arr.length);
|
|
11
|
-
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
12
|
-
return arr2;
|
|
13
|
-
}
|
|
14
|
-
function _array_with_holes(arr) {
|
|
15
|
-
if (Array.isArray(arr)) return arr;
|
|
16
|
-
}
|
|
17
|
-
function _define_property(obj, key, value) {
|
|
18
|
-
return key in obj ? Object.defineProperty(obj, key, {
|
|
19
|
-
value,
|
|
20
|
-
enumerable: !0,
|
|
21
|
-
configurable: !0,
|
|
22
|
-
writable: !0
|
|
23
|
-
}) : obj[key] = value, obj;
|
|
24
|
-
}
|
|
25
|
-
function _iterable_to_array_limit(arr, i) {
|
|
26
|
-
var _i = arr == null ? null : typeof Symbol < "u" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
27
|
-
if (_i != null) {
|
|
28
|
-
var _arr = [], _n = !0, _d = !1, _s, _e;
|
|
29
|
-
try {
|
|
30
|
-
for (_i = _i.call(arr); !(_n = (_s = _i.next()).done) && (_arr.push(_s.value), !(i && _arr.length === i)); _n = !0)
|
|
31
|
-
;
|
|
32
|
-
} catch (err) {
|
|
33
|
-
_d = !0, _e = err;
|
|
34
|
-
} finally {
|
|
35
|
-
try {
|
|
36
|
-
!_n && _i.return != null && _i.return();
|
|
37
|
-
} finally {
|
|
38
|
-
if (_d) throw _e;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
return _arr;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
function _non_iterable_rest() {
|
|
45
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
46
|
-
}
|
|
47
|
-
function _object_spread(target) {
|
|
48
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
49
|
-
var source = arguments[i] != null ? arguments[i] : {}, ownKeys2 = Object.keys(source);
|
|
50
|
-
typeof Object.getOwnPropertySymbols == "function" && (ownKeys2 = ownKeys2.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
51
|
-
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
52
|
-
}))), ownKeys2.forEach(function(key) {
|
|
53
|
-
_define_property(target, key, source[key]);
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
return target;
|
|
57
|
-
}
|
|
58
|
-
function ownKeys(object, enumerableOnly) {
|
|
59
|
-
var keys = Object.keys(object);
|
|
60
|
-
if (Object.getOwnPropertySymbols) {
|
|
61
|
-
var symbols = Object.getOwnPropertySymbols(object);
|
|
62
|
-
enumerableOnly && (symbols = symbols.filter(function(sym) {
|
|
63
|
-
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
64
|
-
})), keys.push.apply(keys, symbols);
|
|
65
|
-
}
|
|
66
|
-
return keys;
|
|
67
|
-
}
|
|
68
|
-
function _object_spread_props(target, source) {
|
|
69
|
-
return source = source ?? {}, Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function(key) {
|
|
70
|
-
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
71
|
-
}), target;
|
|
72
|
-
}
|
|
73
|
-
function _object_without_properties(source, excluded) {
|
|
74
|
-
if (source == null) return {};
|
|
75
|
-
var target = _object_without_properties_loose(source, excluded), key, i;
|
|
76
|
-
if (Object.getOwnPropertySymbols) {
|
|
77
|
-
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
|
78
|
-
for (i = 0; i < sourceSymbolKeys.length; i++)
|
|
79
|
-
key = sourceSymbolKeys[i], !(excluded.indexOf(key) >= 0) && Object.prototype.propertyIsEnumerable.call(source, key) && (target[key] = source[key]);
|
|
80
|
-
}
|
|
81
|
-
return target;
|
|
82
|
-
}
|
|
83
|
-
function _object_without_properties_loose(source, excluded) {
|
|
84
|
-
if (source == null) return {};
|
|
85
|
-
var target = {}, sourceKeys = Object.keys(source), key, i;
|
|
86
|
-
for (i = 0; i < sourceKeys.length; i++)
|
|
87
|
-
key = sourceKeys[i], !(excluded.indexOf(key) >= 0) && (target[key] = source[key]);
|
|
88
|
-
return target;
|
|
89
|
-
}
|
|
90
|
-
function _sliced_to_array(arr, i) {
|
|
91
|
-
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
92
|
-
}
|
|
93
|
-
function _unsupported_iterable_to_array(o, minLen) {
|
|
94
|
-
if (o) {
|
|
95
|
-
if (typeof o == "string") return _array_like_to_array(o, minLen);
|
|
96
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
97
|
-
if (n === "Object" && o.constructor && (n = o.constructor.name), n === "Map" || n === "Set") return Array.from(n);
|
|
98
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
9
|
function useCheckbox(props, param, ref) {
|
|
102
|
-
var
|
|
103
|
-
"labelledBy",
|
|
104
|
-
"name",
|
|
105
|
-
"required",
|
|
106
|
-
"disabled",
|
|
107
|
-
"value",
|
|
108
|
-
"onCheckedChange"
|
|
109
|
-
]), _React_useState = _sliced_to_array(React.useState(null), 2), button = _React_useState[0], setButton = _React_useState[1], composedRefs = useComposedRefs(ref, function(node) {
|
|
10
|
+
var [checked, setChecked] = param, { labelledBy: ariaLabelledby, name, required, disabled, value = "on", onCheckedChange, ...checkboxProps } = props, [button, setButton] = React.useState(null), composedRefs = useComposedRefs(ref, function(node) {
|
|
110
11
|
return setButton(node);
|
|
111
12
|
}), hasConsumerStoppedPropagationRef = React.useRef(!1), isFormControl = isWeb ? button ? !!button.closest("form") : !0 : !1, labelId = useLabelContext(button), labelledBy = ariaLabelledby || labelId;
|
|
112
13
|
return {
|
|
@@ -121,26 +22,27 @@ function useCheckbox(props, param, ref) {
|
|
|
121
22
|
disabled
|
|
122
23
|
}) : null,
|
|
123
24
|
checkboxRef: composedRefs,
|
|
124
|
-
checkboxProps:
|
|
25
|
+
checkboxProps: {
|
|
125
26
|
role: "checkbox",
|
|
126
27
|
"aria-labelledby": labelledBy,
|
|
127
|
-
"aria-checked": isIndeterminate(checked) ? "mixed" : checked
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
28
|
+
"aria-checked": isIndeterminate(checked) ? "mixed" : checked,
|
|
29
|
+
...checkboxProps,
|
|
30
|
+
...isWeb && {
|
|
31
|
+
type: "button",
|
|
32
|
+
value,
|
|
33
|
+
"data-state": getState(checked),
|
|
34
|
+
"data-disabled": disabled ? "" : void 0,
|
|
35
|
+
disabled,
|
|
36
|
+
onKeyDown: composeEventHandlers(props.onKeyDown, function(event) {
|
|
37
|
+
event.key === "Enter" && event.preventDefault();
|
|
38
|
+
})
|
|
39
|
+
},
|
|
138
40
|
onPress: composeEventHandlers(props.onPress, function(event) {
|
|
139
41
|
setChecked(function(prevChecked) {
|
|
140
42
|
return isIndeterminate(prevChecked) ? !0 : !prevChecked;
|
|
141
43
|
}), isFormControl && "isPropagationStopped" in event && (hasConsumerStoppedPropagationRef.current = event.isPropagationStopped(), hasConsumerStoppedPropagationRef.current || event.stopPropagation());
|
|
142
44
|
})
|
|
143
|
-
}
|
|
45
|
+
}
|
|
144
46
|
};
|
|
145
47
|
}
|
|
146
48
|
export {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/Users/n8/tamagui/code/ui/checkbox-headless/src/useCheckbox.tsx"],
|
|
4
|
-
"mappings": ";AAAA,SAASA,uBAAuB;AAChC,SAASC,aAAa;AAEtB,SAASC,4BAA4B;AACrC,SAASC,uBAAuB;AAChC,OAAOC,WAAW;AAGlB,SAASC,mBAAmB;AAC5B,SAASC,UAAUC,uBAAuB
|
|
5
|
-
"names": ["useComposedRefs", "isWeb", "composeEventHandlers", "useLabelContext", "React", "BubbleInput", "getState", "isIndeterminate", "useCheckbox", "props", "ref", "checked", "setChecked", "
|
|
4
|
+
"mappings": ";AAAA,SAASA,uBAAuB;AAChC,SAASC,aAAa;AAEtB,SAASC,4BAA4B;AACrC,SAASC,uBAAuB;AAChC,OAAOC,WAAW;AAGlB,SAASC,mBAAmB;AAC5B,SAASC,UAAUC,uBAAuB;AAyBnC,SAASC,YACdC,OACA,OAIAC,KAAiB;MAJjB,CAACC,SAASC,UAAAA,IAAV,OAMM,EACJC,YAAYC,gBACZC,MACAC,UACAC,UACAC,QAAQ,MACRC,iBACA,GAAGC,cAAAA,IACDX,OACE,CAACY,QAAQC,SAAAA,IAAalB,MAAMmB,SAAmC,IAAA,GAC/DC,eAAexB,gBAAgBU,KAAK,SAACe,MAAAA;WAASH,UAAUG,IAAAA;MACxDC,mCAAmCtB,MAAMuB,OAAO,EAAA,GAEhDC,gBAAgB3B,QAASoB,SAASQ,EAAQR,OAAOS,QAAQ,MAAA,IAAW,KAAQ,IAE5EC,UAAU5B,gBAAgBkB,MAAAA,GAC1BR,aAAaC,kBAAkBiB;AAErC,SAAO;IACLC,aACE/B,SAAS2B,gBACP,qBAACvB,aAAAA;MACC4B,UAAQ;MACRC,SAASb;MACTc,SAAS,CAACT,iCAAiCU;MAC3CrB;MACAG;MACAP;MACAK;MACAC;SAEA;IACNoB,aAAab;IACbJ,eAAe;MACbkB,MAAM;MACN,mBAAmBzB;MACnB,gBAAgBN,gBAAgBI,OAAAA,IAAW,UAAUA;MACrD,GAAGS;MACH,GAAInB,SAAS;QACXsC,MAAM;QACNrB;QACA,cAAcZ,SAASK,OAAAA;QACvB,iBAAiBM,WAAW,KAAKuB;QACjCvB;QACAwB,WAAWvC,qBACRO,MAA6CgC,WAC9C,SAACC,OAAAA;AAEC,UAAIA,MAAMC,QAAQ,WAASD,MAAME,eAAc;QACjD,CAAA;MAEJ;MACAC,SAAS3C,qBACPO,MAAMoC,SACN,SAACH,OAAAA;AACC9B,mBAAW,SAACkC,aAAAA;iBACVvC,gBAAgBuC,WAAAA,IAAe,KAAO,CAACA;YAErClB,iBAAiB,0BAA0Bc,UAC7ChB,iCAAiCU,UAAUM,MAAMK,qBAAoB,GAIhErB,iCAAiCU,WAASM,MAAMM,gBAAe;MAExE,CAAA;IAEJ;EACF;AACF;",
|
|
5
|
+
"names": ["useComposedRefs", "isWeb", "composeEventHandlers", "useLabelContext", "React", "BubbleInput", "getState", "isIndeterminate", "useCheckbox", "props", "ref", "checked", "setChecked", "labelledBy", "ariaLabelledby", "name", "required", "disabled", "value", "onCheckedChange", "checkboxProps", "button", "setButton", "useState", "composedRefs", "node", "hasConsumerStoppedPropagationRef", "useRef", "isFormControl", "Boolean", "closest", "labelId", "bubbleInput", "isHidden", "control", "bubbles", "current", "checkboxRef", "role", "type", "undefined", "onKeyDown", "event", "key", "preventDefault", "onPress", "prevChecked", "isPropagationStopped", "stopPropagation"]
|
|
6
6
|
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useComposedRefs } from "@tamagui/compose-refs";
|
|
3
|
+
import { isWeb } from "@tamagui/constants";
|
|
4
|
+
import { composeEventHandlers } from "@tamagui/helpers";
|
|
5
|
+
import { useLabelContext } from "@tamagui/label";
|
|
6
|
+
import React from "react";
|
|
7
|
+
import { BubbleInput } from "./BubbleInput.mjs";
|
|
8
|
+
import { getState, isIndeterminate } from "./utils.mjs";
|
|
9
|
+
function useCheckbox(props, param, ref) {
|
|
10
|
+
var [checked, setChecked] = param,
|
|
11
|
+
{
|
|
12
|
+
labelledBy: ariaLabelledby,
|
|
13
|
+
name,
|
|
14
|
+
required,
|
|
15
|
+
disabled,
|
|
16
|
+
value = "on",
|
|
17
|
+
onCheckedChange,
|
|
18
|
+
...checkboxProps
|
|
19
|
+
} = props,
|
|
20
|
+
[button, setButton] = React.useState(null),
|
|
21
|
+
composedRefs = useComposedRefs(ref, function (node) {
|
|
22
|
+
return setButton(node);
|
|
23
|
+
}),
|
|
24
|
+
hasConsumerStoppedPropagationRef = React.useRef(!1),
|
|
25
|
+
isFormControl = isWeb ? button ? !!button.closest("form") : !0 : !1,
|
|
26
|
+
labelId = useLabelContext(button),
|
|
27
|
+
labelledBy = ariaLabelledby || labelId;
|
|
28
|
+
return {
|
|
29
|
+
bubbleInput: isWeb && isFormControl ? /* @__PURE__ */_jsx(BubbleInput, {
|
|
30
|
+
isHidden: !0,
|
|
31
|
+
control: button,
|
|
32
|
+
bubbles: !hasConsumerStoppedPropagationRef.current,
|
|
33
|
+
name,
|
|
34
|
+
value,
|
|
35
|
+
checked,
|
|
36
|
+
required,
|
|
37
|
+
disabled
|
|
38
|
+
}) : null,
|
|
39
|
+
checkboxRef: composedRefs,
|
|
40
|
+
checkboxProps: {
|
|
41
|
+
role: "checkbox",
|
|
42
|
+
"aria-labelledby": labelledBy,
|
|
43
|
+
"aria-checked": isIndeterminate(checked) ? "mixed" : checked,
|
|
44
|
+
...checkboxProps,
|
|
45
|
+
...(isWeb && {
|
|
46
|
+
type: "button",
|
|
47
|
+
value,
|
|
48
|
+
"data-state": getState(checked),
|
|
49
|
+
"data-disabled": disabled ? "" : void 0,
|
|
50
|
+
disabled,
|
|
51
|
+
onKeyDown: composeEventHandlers(props.onKeyDown, function (event) {
|
|
52
|
+
event.key === "Enter" && event.preventDefault();
|
|
53
|
+
})
|
|
54
|
+
}),
|
|
55
|
+
onPress: composeEventHandlers(props.onPress, function (event) {
|
|
56
|
+
setChecked(function (prevChecked) {
|
|
57
|
+
return isIndeterminate(prevChecked) ? !0 : !prevChecked;
|
|
58
|
+
}), isFormControl && "isPropagationStopped" in event && (hasConsumerStoppedPropagationRef.current = event.isPropagationStopped(), hasConsumerStoppedPropagationRef.current || event.stopPropagation());
|
|
59
|
+
})
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
export { useCheckbox };
|
|
64
|
+
//# sourceMappingURL=useCheckbox.native.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["jsx","_jsx","useComposedRefs","isWeb","composeEventHandlers","useLabelContext","React","BubbleInput","getState","isIndeterminate","useCheckbox","props","param","ref","checked","setChecked","labelledBy","ariaLabelledby","name","required","disabled","value","onCheckedChange","checkboxProps","button","setButton","useState","composedRefs","node","hasConsumerStoppedPropagationRef","useRef","isFormControl","closest","labelId","bubbleInput","isHidden","control","bubbles","current","checkboxRef","role","type","onKeyDown","event","key","preventDefault","onPress","prevChecked","isPropagationStopped","stopPropagation"],"sources":["../../src/useCheckbox.tsx"],"sourcesContent":[null],"mappings":"AAAA,SAASA,GAAA,IAAAC,IAAA,2BAAuB;AAChC,SAASC,eAAa;AAEtB,SAASC,KAAA,4BAA4B;AACrC,SAASC,oBAAA,QAAuB;AAChC,SAAOC,eAAW;AAGlB,OAAAC,KAAS;AACT,SAASC,WAAU,2BAAuB;AAsDlC,SAAAC,QAAA,EAAAC,eAAA;AA7BD,SAASC,YACdC,KAAA,EACAC,KAAC,EAAAC,GAAS;EAMV,KAAAC,OAAM,EAAAC,UAAA,IAAAH,KAAA;IAAA;MAAAI,UAAA,EAAAC,cAAA;MAAAC,IAAA;MAAAC,QAAA;MAAAC,QAAA;MAAAC,KAAA;MAAAC,eAAA;MAAA,GAAAC;IAAA,IAAAZ,KAAA;IAAA,CAAAa,MAAA,EAAAC,SAAA,IAAAnB,KAAA,CAAAoB,QAAA;IAAAC,YAAA,GAAAzB,eAAA,CAAAW,GAAA,YAAAe,IAAA;MACJ,OAAAH,SAAY,CAAAG,IAAA;IAAA,EACZ;IAAAC,gCAAA,GAAAvB,KAAA,CAAAwB,MAAA;IAAAC,aAAA,GAAA5B,KAAA,GAAAqB,MAAA,KAAAA,MAAA,CAAAQ,OAAA;IAAAC,OAAA,GAAA5B,eAAA,CAAAmB,MAAA;IAAAR,UAAA,GAAAC,cAAA,IAAAgB,OAAA;EAAA,OACA;IACAC,WAAA,EAAA/B,KAAA,IAAA4B,aAAA,kBAAA9B,IAAA,CAAAM,WAAA;MACA4B,QAAQ;MACRC,OAAA,EAAAZ,MAAA;MACAa,OAAG,GAAAR,gCAAA,CAAAS,OAAA;MACDpB,IAAA;MAUJG,KAAO;MACLP,OAAA;MAEKK,QAAA;MAAAC;IAAA,KACC;IAAQmB,WACR,EAASZ,YAAA;IAAAJ,aACA,EAAC;MAAiCiB,IAC3C;MAAA,iBACA,EAAAxB,UAAA;MAAA,cACA,EAAAP,eAAA,CAAAK,OAAA,cAAAA,OAAA;MAAA,GACAS,aAAA;MAAA,IACApB,KAAA;QAAAsC,IAAA;QAEApB,KAAA;QACN,YAAa,EAAAb,QAAA,CAAAM,OAAA;QACb,eAAe,EAAAM,QAAA;QACbA,QAAM;QACNsB,SAAA,EAAAtC,oBAAmB,CAAAO,KAAA,CAAA+B,SAAA,YAAAC,KAAA;UACnBA,KAAA,CAAAC,GAAA,KAAgB,WAAAD,KAAgB,CAAAE,cAAW;QAC3C,CAAG;MACH;MAAaC,OACX,EAAM1C,oBAAA,CAAAO,KAAA,CAAAmC,OAAA,YAAAH,KAAA;QACN5B,UAAA,WAAAgC,WAAA;UACA,OAAAtC,eAAuB,CAAAsC,WAAO,UAAAA,WAAA;QAC9B,IAAAhB,aAAiB,0BAAgB,IAAAY,KAAA,KAAAd,gCAAA,CAAAS,OAAA,GAAAK,KAAA,CAAAK,oBAAA,IAAAnB,gCAAA,CAAAS,OAAA,IAAAK,KAAA,CAAAM,eAAA;MAAA;IACjC;EACW;AACqC;AAG5C,SAAgDvC,WAClD","ignoreList":[]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
function isIndeterminate(checked) {
|
|
2
|
+
return checked === "indeterminate";
|
|
3
|
+
}
|
|
4
|
+
function getState(checked) {
|
|
5
|
+
return isIndeterminate(checked) ? "indeterminate" : checked ? "checked" : "unchecked";
|
|
6
|
+
}
|
|
7
|
+
export { getState, isIndeterminate };
|
|
8
|
+
//# sourceMappingURL=utils.native.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["isIndeterminate","checked","getState"],"sources":["../../src/utils.tsx"],"sourcesContent":[null],"mappings":"AAEO,SAASA,gBAAgBC,OAAA,EAAoD;EAClF,OAAOA,OAAA,KAAY;AACrB;AAEO,SAASC,SAASD,OAAA,EAAuB;EAC9C,OAAOD,eAAA,CAAgBC,OAAO,IAAI,kBAAkBA,OAAA,GAAU,YAAY;AAC5E","ignoreList":[]}
|
|
@@ -2,64 +2,8 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { usePrevious } from "@tamagui/use-previous";
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
import { isIndeterminate } from "./utils";
|
|
5
|
-
function _define_property(obj, key, value) {
|
|
6
|
-
return key in obj ? Object.defineProperty(obj, key, {
|
|
7
|
-
value,
|
|
8
|
-
enumerable: !0,
|
|
9
|
-
configurable: !0,
|
|
10
|
-
writable: !0
|
|
11
|
-
}) : obj[key] = value, obj;
|
|
12
|
-
}
|
|
13
|
-
function _object_spread(target) {
|
|
14
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
15
|
-
var source = arguments[i] != null ? arguments[i] : {}, ownKeys2 = Object.keys(source);
|
|
16
|
-
typeof Object.getOwnPropertySymbols == "function" && (ownKeys2 = ownKeys2.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
17
|
-
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
18
|
-
}))), ownKeys2.forEach(function(key) {
|
|
19
|
-
_define_property(target, key, source[key]);
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
return target;
|
|
23
|
-
}
|
|
24
|
-
function ownKeys(object, enumerableOnly) {
|
|
25
|
-
var keys = Object.keys(object);
|
|
26
|
-
if (Object.getOwnPropertySymbols) {
|
|
27
|
-
var symbols = Object.getOwnPropertySymbols(object);
|
|
28
|
-
enumerableOnly && (symbols = symbols.filter(function(sym) {
|
|
29
|
-
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
30
|
-
})), keys.push.apply(keys, symbols);
|
|
31
|
-
}
|
|
32
|
-
return keys;
|
|
33
|
-
}
|
|
34
|
-
function _object_spread_props(target, source) {
|
|
35
|
-
return source = source ?? {}, Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function(key) {
|
|
36
|
-
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
37
|
-
}), target;
|
|
38
|
-
}
|
|
39
|
-
function _object_without_properties(source, excluded) {
|
|
40
|
-
if (source == null) return {};
|
|
41
|
-
var target = _object_without_properties_loose(source, excluded), key, i;
|
|
42
|
-
if (Object.getOwnPropertySymbols) {
|
|
43
|
-
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
|
44
|
-
for (i = 0; i < sourceSymbolKeys.length; i++)
|
|
45
|
-
key = sourceSymbolKeys[i], !(excluded.indexOf(key) >= 0) && Object.prototype.propertyIsEnumerable.call(source, key) && (target[key] = source[key]);
|
|
46
|
-
}
|
|
47
|
-
return target;
|
|
48
|
-
}
|
|
49
|
-
function _object_without_properties_loose(source, excluded) {
|
|
50
|
-
if (source == null) return {};
|
|
51
|
-
var target = {}, sourceKeys = Object.keys(source), key, i;
|
|
52
|
-
for (i = 0; i < sourceKeys.length; i++)
|
|
53
|
-
key = sourceKeys[i], !(excluded.indexOf(key) >= 0) && (target[key] = source[key]);
|
|
54
|
-
return target;
|
|
55
|
-
}
|
|
56
5
|
var BubbleInput = function(props) {
|
|
57
|
-
var
|
|
58
|
-
"checked",
|
|
59
|
-
"bubbles",
|
|
60
|
-
"control",
|
|
61
|
-
"isHidden"
|
|
62
|
-
]), ref = React.useRef(null), prevChecked = usePrevious(checked);
|
|
6
|
+
var { checked, bubbles = !0, control, isHidden, ...inputProps } = props, ref = React.useRef(null), prevChecked = usePrevious(checked);
|
|
63
7
|
return React.useEffect(function() {
|
|
64
8
|
var input = ref.current, inputProto = window.HTMLInputElement.prototype, descriptor = Object.getOwnPropertyDescriptor(inputProto, "checked"), setChecked = descriptor.set;
|
|
65
9
|
if (prevChecked !== checked && setChecked) {
|
|
@@ -72,24 +16,27 @@ var BubbleInput = function(props) {
|
|
|
72
16
|
prevChecked,
|
|
73
17
|
checked,
|
|
74
18
|
bubbles
|
|
75
|
-
]), /* @__PURE__ */ _jsx("input",
|
|
19
|
+
]), /* @__PURE__ */ _jsx("input", {
|
|
76
20
|
type: "checkbox",
|
|
77
|
-
defaultChecked: isIndeterminate(checked) ? !1 : checked
|
|
78
|
-
|
|
21
|
+
defaultChecked: isIndeterminate(checked) ? !1 : checked,
|
|
22
|
+
...inputProps,
|
|
79
23
|
tabIndex: -1,
|
|
80
24
|
ref,
|
|
81
25
|
"aria-hidden": isHidden,
|
|
82
|
-
style:
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
26
|
+
style: {
|
|
27
|
+
...isHidden ? {
|
|
28
|
+
// ...controlSize,
|
|
29
|
+
position: "absolute",
|
|
30
|
+
pointerEvents: "none",
|
|
31
|
+
opacity: 0,
|
|
32
|
+
margin: 0
|
|
33
|
+
} : {
|
|
34
|
+
appearance: "auto",
|
|
35
|
+
accentColor: "var(--color6)"
|
|
36
|
+
},
|
|
37
|
+
...props.style
|
|
38
|
+
}
|
|
39
|
+
});
|
|
93
40
|
};
|
|
94
41
|
export {
|
|
95
42
|
BubbleInput
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/Users/n8/tamagui/code/ui/checkbox-headless/src/BubbleInput.tsx"],
|
|
4
|
-
"mappings": ";AAAA,SAASA,mBAAmB;AAC5B,YAAYC,WAAW;AAGvB,SAASC,uBAAuB
|
|
4
|
+
"mappings": ";AAAA,SAASA,mBAAmB;AAC5B,YAAYC,WAAW;AAGvB,SAASC,uBAAuB;AAUzB,IAAMC,cAAc,SAACC,OAAAA;AAC1B,MAAM,EAAEC,SAASC,UAAU,IAAMC,SAASC,UAAU,GAAGC,WAAAA,IAAeL,OAChEM,MAAMT,MAAMU,OAAyB,IAAA,GACrCC,cAAcZ,YAAYK,OAAAA;AAGhCJ,eAAMY,UAAU,WAAA;AACd,QAAMC,QAAQJ,IAAIK,SACZC,aAAaC,OAAOC,iBAAiBC,WACrCC,aAAaC,OAAOC,yBACxBN,YACA,SAAA,GAEIO,aAAaH,WAAWI;AAE9B,QAAIZ,gBAAgBP,WAAWkB,YAAY;AACzC,UAAME,QAAQ,IAAIC,MAAM,SAAS;QAAEpB;MAAQ,CAAA;AAC3CQ,YAAMa,gBAAgBzB,gBAAgBG,OAAAA,GACtCkB,WAAWK,KAAKd,OAAOZ,gBAAgBG,OAAAA,IAAW,KAAQA,OAAAA,GAC1DS,MAAMe,cAAcJ,KAAAA;IACtB;EACF,GAAG;IAACb;IAAaP;IAASC;GAAQ,GAGhC,qBAACQ,SAAAA;IACCgB,MAAK;IACLC,gBAAgB7B,gBAAgBG,OAAAA,IAAW,KAAQA;IAClD,GAAGI;IACJuB,UAAU;IACVtB;IACAuB,eAAazB;IACb0B,OAAO;MACL,GAAI1B,WACA;;QAEE2B,UAAU;QACVC,eAAe;QACfC,SAAS;QACTC,QAAQ;MACV,IACA;QACEC,YAAY;QACZC,aAAa;MACf;MAEJ,GAAGpC,MAAM8B;IACX;;AAGN;",
|
|
5
5
|
"names": ["usePrevious", "React", "isIndeterminate", "BubbleInput", "props", "checked", "bubbles", "control", "isHidden", "inputProps", "ref", "useRef", "prevChecked", "useEffect", "input", "current", "inputProto", "window", "HTMLInputElement", "prototype", "descriptor", "Object", "getOwnPropertyDescriptor", "setChecked", "set", "event", "Event", "indeterminate", "call", "dispatchEvent", "type", "defaultChecked", "tabIndex", "aria-hidden", "style", "position", "pointerEvents", "opacity", "margin", "appearance", "accentColor"]
|
|
6
6
|
}
|
|
@@ -6,107 +6,8 @@ import { useLabelContext } from "@tamagui/label";
|
|
|
6
6
|
import React from "react";
|
|
7
7
|
import { BubbleInput } from "./BubbleInput";
|
|
8
8
|
import { getState, isIndeterminate } from "./utils";
|
|
9
|
-
function _array_like_to_array(arr, len) {
|
|
10
|
-
(len == null || len > arr.length) && (len = arr.length);
|
|
11
|
-
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
12
|
-
return arr2;
|
|
13
|
-
}
|
|
14
|
-
function _array_with_holes(arr) {
|
|
15
|
-
if (Array.isArray(arr)) return arr;
|
|
16
|
-
}
|
|
17
|
-
function _define_property(obj, key, value) {
|
|
18
|
-
return key in obj ? Object.defineProperty(obj, key, {
|
|
19
|
-
value,
|
|
20
|
-
enumerable: !0,
|
|
21
|
-
configurable: !0,
|
|
22
|
-
writable: !0
|
|
23
|
-
}) : obj[key] = value, obj;
|
|
24
|
-
}
|
|
25
|
-
function _iterable_to_array_limit(arr, i) {
|
|
26
|
-
var _i = arr == null ? null : typeof Symbol < "u" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
27
|
-
if (_i != null) {
|
|
28
|
-
var _arr = [], _n = !0, _d = !1, _s, _e;
|
|
29
|
-
try {
|
|
30
|
-
for (_i = _i.call(arr); !(_n = (_s = _i.next()).done) && (_arr.push(_s.value), !(i && _arr.length === i)); _n = !0)
|
|
31
|
-
;
|
|
32
|
-
} catch (err) {
|
|
33
|
-
_d = !0, _e = err;
|
|
34
|
-
} finally {
|
|
35
|
-
try {
|
|
36
|
-
!_n && _i.return != null && _i.return();
|
|
37
|
-
} finally {
|
|
38
|
-
if (_d) throw _e;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
return _arr;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
function _non_iterable_rest() {
|
|
45
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
46
|
-
}
|
|
47
|
-
function _object_spread(target) {
|
|
48
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
49
|
-
var source = arguments[i] != null ? arguments[i] : {}, ownKeys2 = Object.keys(source);
|
|
50
|
-
typeof Object.getOwnPropertySymbols == "function" && (ownKeys2 = ownKeys2.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
51
|
-
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
52
|
-
}))), ownKeys2.forEach(function(key) {
|
|
53
|
-
_define_property(target, key, source[key]);
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
return target;
|
|
57
|
-
}
|
|
58
|
-
function ownKeys(object, enumerableOnly) {
|
|
59
|
-
var keys = Object.keys(object);
|
|
60
|
-
if (Object.getOwnPropertySymbols) {
|
|
61
|
-
var symbols = Object.getOwnPropertySymbols(object);
|
|
62
|
-
enumerableOnly && (symbols = symbols.filter(function(sym) {
|
|
63
|
-
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
64
|
-
})), keys.push.apply(keys, symbols);
|
|
65
|
-
}
|
|
66
|
-
return keys;
|
|
67
|
-
}
|
|
68
|
-
function _object_spread_props(target, source) {
|
|
69
|
-
return source = source ?? {}, Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function(key) {
|
|
70
|
-
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
71
|
-
}), target;
|
|
72
|
-
}
|
|
73
|
-
function _object_without_properties(source, excluded) {
|
|
74
|
-
if (source == null) return {};
|
|
75
|
-
var target = _object_without_properties_loose(source, excluded), key, i;
|
|
76
|
-
if (Object.getOwnPropertySymbols) {
|
|
77
|
-
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
|
78
|
-
for (i = 0; i < sourceSymbolKeys.length; i++)
|
|
79
|
-
key = sourceSymbolKeys[i], !(excluded.indexOf(key) >= 0) && Object.prototype.propertyIsEnumerable.call(source, key) && (target[key] = source[key]);
|
|
80
|
-
}
|
|
81
|
-
return target;
|
|
82
|
-
}
|
|
83
|
-
function _object_without_properties_loose(source, excluded) {
|
|
84
|
-
if (source == null) return {};
|
|
85
|
-
var target = {}, sourceKeys = Object.keys(source), key, i;
|
|
86
|
-
for (i = 0; i < sourceKeys.length; i++)
|
|
87
|
-
key = sourceKeys[i], !(excluded.indexOf(key) >= 0) && (target[key] = source[key]);
|
|
88
|
-
return target;
|
|
89
|
-
}
|
|
90
|
-
function _sliced_to_array(arr, i) {
|
|
91
|
-
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
92
|
-
}
|
|
93
|
-
function _unsupported_iterable_to_array(o, minLen) {
|
|
94
|
-
if (o) {
|
|
95
|
-
if (typeof o == "string") return _array_like_to_array(o, minLen);
|
|
96
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
97
|
-
if (n === "Object" && o.constructor && (n = o.constructor.name), n === "Map" || n === "Set") return Array.from(n);
|
|
98
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
9
|
function useCheckbox(props, param, ref) {
|
|
102
|
-
var
|
|
103
|
-
"labelledBy",
|
|
104
|
-
"name",
|
|
105
|
-
"required",
|
|
106
|
-
"disabled",
|
|
107
|
-
"value",
|
|
108
|
-
"onCheckedChange"
|
|
109
|
-
]), _React_useState = _sliced_to_array(React.useState(null), 2), button = _React_useState[0], setButton = _React_useState[1], composedRefs = useComposedRefs(ref, function(node) {
|
|
10
|
+
var [checked, setChecked] = param, { labelledBy: ariaLabelledby, name, required, disabled, value = "on", onCheckedChange, ...checkboxProps } = props, [button, setButton] = React.useState(null), composedRefs = useComposedRefs(ref, function(node) {
|
|
110
11
|
return setButton(node);
|
|
111
12
|
}), hasConsumerStoppedPropagationRef = React.useRef(!1), isFormControl = isWeb ? button ? !!button.closest("form") : !0 : !1, labelId = useLabelContext(button), labelledBy = ariaLabelledby || labelId;
|
|
112
13
|
return {
|
|
@@ -121,26 +22,27 @@ function useCheckbox(props, param, ref) {
|
|
|
121
22
|
disabled
|
|
122
23
|
}) : null,
|
|
123
24
|
checkboxRef: composedRefs,
|
|
124
|
-
checkboxProps:
|
|
25
|
+
checkboxProps: {
|
|
125
26
|
role: "checkbox",
|
|
126
27
|
"aria-labelledby": labelledBy,
|
|
127
|
-
"aria-checked": isIndeterminate(checked) ? "mixed" : checked
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
28
|
+
"aria-checked": isIndeterminate(checked) ? "mixed" : checked,
|
|
29
|
+
...checkboxProps,
|
|
30
|
+
...isWeb && {
|
|
31
|
+
type: "button",
|
|
32
|
+
value,
|
|
33
|
+
"data-state": getState(checked),
|
|
34
|
+
"data-disabled": disabled ? "" : void 0,
|
|
35
|
+
disabled,
|
|
36
|
+
onKeyDown: composeEventHandlers(props.onKeyDown, function(event) {
|
|
37
|
+
event.key === "Enter" && event.preventDefault();
|
|
38
|
+
})
|
|
39
|
+
},
|
|
138
40
|
onPress: composeEventHandlers(props.onPress, function(event) {
|
|
139
41
|
setChecked(function(prevChecked) {
|
|
140
42
|
return isIndeterminate(prevChecked) ? !0 : !prevChecked;
|
|
141
43
|
}), isFormControl && "isPropagationStopped" in event && (hasConsumerStoppedPropagationRef.current = event.isPropagationStopped(), hasConsumerStoppedPropagationRef.current || event.stopPropagation());
|
|
142
44
|
})
|
|
143
|
-
}
|
|
45
|
+
}
|
|
144
46
|
};
|
|
145
47
|
}
|
|
146
48
|
export {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/Users/n8/tamagui/code/ui/checkbox-headless/src/useCheckbox.tsx"],
|
|
4
|
-
"mappings": ";AAAA,SAASA,uBAAuB;AAChC,SAASC,aAAa;AAEtB,SAASC,4BAA4B;AACrC,SAASC,uBAAuB;AAChC,OAAOC,WAAW;AAGlB,SAASC,mBAAmB;AAC5B,SAASC,UAAUC,uBAAuB
|
|
5
|
-
"names": ["useComposedRefs", "isWeb", "composeEventHandlers", "useLabelContext", "React", "BubbleInput", "getState", "isIndeterminate", "useCheckbox", "props", "ref", "checked", "setChecked", "
|
|
4
|
+
"mappings": ";AAAA,SAASA,uBAAuB;AAChC,SAASC,aAAa;AAEtB,SAASC,4BAA4B;AACrC,SAASC,uBAAuB;AAChC,OAAOC,WAAW;AAGlB,SAASC,mBAAmB;AAC5B,SAASC,UAAUC,uBAAuB;AAyBnC,SAASC,YACdC,OACA,OAIAC,KAAiB;MAJjB,CAACC,SAASC,UAAAA,IAAV,OAMM,EACJC,YAAYC,gBACZC,MACAC,UACAC,UACAC,QAAQ,MACRC,iBACA,GAAGC,cAAAA,IACDX,OACE,CAACY,QAAQC,SAAAA,IAAalB,MAAMmB,SAAmC,IAAA,GAC/DC,eAAexB,gBAAgBU,KAAK,SAACe,MAAAA;WAASH,UAAUG,IAAAA;MACxDC,mCAAmCtB,MAAMuB,OAAO,EAAA,GAEhDC,gBAAgB3B,QAASoB,SAASQ,EAAQR,OAAOS,QAAQ,MAAA,IAAW,KAAQ,IAE5EC,UAAU5B,gBAAgBkB,MAAAA,GAC1BR,aAAaC,kBAAkBiB;AAErC,SAAO;IACLC,aACE/B,SAAS2B,gBACP,qBAACvB,aAAAA;MACC4B,UAAQ;MACRC,SAASb;MACTc,SAAS,CAACT,iCAAiCU;MAC3CrB;MACAG;MACAP;MACAK;MACAC;SAEA;IACNoB,aAAab;IACbJ,eAAe;MACbkB,MAAM;MACN,mBAAmBzB;MACnB,gBAAgBN,gBAAgBI,OAAAA,IAAW,UAAUA;MACrD,GAAGS;MACH,GAAInB,SAAS;QACXsC,MAAM;QACNrB;QACA,cAAcZ,SAASK,OAAAA;QACvB,iBAAiBM,WAAW,KAAKuB;QACjCvB;QACAwB,WAAWvC,qBACRO,MAA6CgC,WAC9C,SAACC,OAAAA;AAEC,UAAIA,MAAMC,QAAQ,WAASD,MAAME,eAAc;QACjD,CAAA;MAEJ;MACAC,SAAS3C,qBACPO,MAAMoC,SACN,SAACH,OAAAA;AACC9B,mBAAW,SAACkC,aAAAA;iBACVvC,gBAAgBuC,WAAAA,IAAe,KAAO,CAACA;YAErClB,iBAAiB,0BAA0Bc,UAC7ChB,iCAAiCU,UAAUM,MAAMK,qBAAoB,GAIhErB,iCAAiCU,WAASM,MAAMM,gBAAe;MAExE,CAAA;IAEJ;EACF;AACF;",
|
|
5
|
+
"names": ["useComposedRefs", "isWeb", "composeEventHandlers", "useLabelContext", "React", "BubbleInput", "getState", "isIndeterminate", "useCheckbox", "props", "ref", "checked", "setChecked", "labelledBy", "ariaLabelledby", "name", "required", "disabled", "value", "onCheckedChange", "checkboxProps", "button", "setButton", "useState", "composedRefs", "node", "hasConsumerStoppedPropagationRef", "useRef", "isFormControl", "Boolean", "closest", "labelId", "bubbleInput", "isHidden", "control", "bubbles", "current", "checkboxRef", "role", "type", "undefined", "onKeyDown", "event", "key", "preventDefault", "onPress", "prevChecked", "isPropagationStopped", "stopPropagation"]
|
|
6
6
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/checkbox-headless",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.111.0",
|
|
4
4
|
"sideEffects": [
|
|
5
5
|
"*.css"
|
|
6
6
|
],
|
|
@@ -23,14 +23,14 @@
|
|
|
23
23
|
"clean:build": "tamagui-build clean:build"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@tamagui/compose-refs": "1.
|
|
27
|
-
"@tamagui/constants": "1.
|
|
28
|
-
"@tamagui/create-context": "1.
|
|
29
|
-
"@tamagui/focusable": "1.
|
|
30
|
-
"@tamagui/helpers": "1.
|
|
31
|
-
"@tamagui/label": "1.
|
|
32
|
-
"@tamagui/use-controllable-state": "1.
|
|
33
|
-
"@tamagui/use-previous": "1.
|
|
26
|
+
"@tamagui/compose-refs": "1.111.0",
|
|
27
|
+
"@tamagui/constants": "1.111.0",
|
|
28
|
+
"@tamagui/create-context": "1.111.0",
|
|
29
|
+
"@tamagui/focusable": "1.111.0",
|
|
30
|
+
"@tamagui/helpers": "1.111.0",
|
|
31
|
+
"@tamagui/label": "1.111.0",
|
|
32
|
+
"@tamagui/use-controllable-state": "1.111.0",
|
|
33
|
+
"@tamagui/use-previous": "1.111.0"
|
|
34
34
|
},
|
|
35
35
|
"exports": {
|
|
36
36
|
"./package.json": "./package.json",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
}
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"@tamagui/build": "1.
|
|
46
|
+
"@tamagui/build": "1.111.0",
|
|
47
47
|
"react": "^18.2.0 || ^19.0.0"
|
|
48
48
|
},
|
|
49
49
|
"publishConfig": {
|