@tamagui/checkbox-headless 1.89.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/LICENSE +21 -0
- package/dist/cjs/BubbleInput.js +65 -0
- package/dist/cjs/BubbleInput.js.map +6 -0
- package/dist/cjs/BubbleInput.native.js +70 -0
- package/dist/cjs/BubbleInput.native.js.map +6 -0
- package/dist/cjs/index.js +16 -0
- package/dist/cjs/index.js.map +6 -0
- package/dist/cjs/index.native.js +22 -0
- package/dist/cjs/index.native.js.map +6 -0
- package/dist/cjs/useCheckbox.js +83 -0
- package/dist/cjs/useCheckbox.js.map +6 -0
- package/dist/cjs/useCheckbox.native.js +88 -0
- package/dist/cjs/useCheckbox.native.js.map +6 -0
- package/dist/cjs/utils.js +27 -0
- package/dist/cjs/utils.js.map +6 -0
- package/dist/cjs/utils.native.js +33 -0
- package/dist/cjs/utils.native.js.map +6 -0
- package/dist/esm/BubbleInput.js +44 -0
- package/dist/esm/BubbleInput.js.map +6 -0
- package/dist/esm/BubbleInput.mjs +47 -0
- package/dist/esm/BubbleInput.native.js +44 -0
- package/dist/esm/BubbleInput.native.js.map +6 -0
- package/dist/esm/index.js +3 -0
- package/dist/esm/index.js.map +6 -0
- package/dist/esm/index.mjs +2 -0
- package/dist/esm/index.native.js +3 -0
- package/dist/esm/index.native.js.map +6 -0
- package/dist/esm/useCheckbox.js +66 -0
- package/dist/esm/useCheckbox.js.map +6 -0
- package/dist/esm/useCheckbox.mjs +58 -0
- package/dist/esm/useCheckbox.native.js +66 -0
- package/dist/esm/useCheckbox.native.js.map +6 -0
- package/dist/esm/utils.js +11 -0
- package/dist/esm/utils.js.map +6 -0
- package/dist/esm/utils.mjs +7 -0
- package/dist/esm/utils.native.js +11 -0
- package/dist/esm/utils.native.js.map +6 -0
- package/dist/jsx/BubbleInput.js +44 -0
- package/dist/jsx/BubbleInput.js.map +6 -0
- package/dist/jsx/BubbleInput.mjs +47 -0
- package/dist/jsx/BubbleInput.native.js +44 -0
- package/dist/jsx/BubbleInput.native.js.map +6 -0
- package/dist/jsx/index.js +3 -0
- package/dist/jsx/index.js.map +6 -0
- package/dist/jsx/index.mjs +2 -0
- package/dist/jsx/index.native.js +3 -0
- package/dist/jsx/index.native.js.map +6 -0
- package/dist/jsx/useCheckbox.js +66 -0
- package/dist/jsx/useCheckbox.js.map +6 -0
- package/dist/jsx/useCheckbox.mjs +58 -0
- package/dist/jsx/useCheckbox.native.js +66 -0
- package/dist/jsx/useCheckbox.native.js.map +6 -0
- package/dist/jsx/utils.js +11 -0
- package/dist/jsx/utils.js.map +6 -0
- package/dist/jsx/utils.mjs +7 -0
- package/dist/jsx/utils.native.js +11 -0
- package/dist/jsx/utils.native.js.map +6 -0
- package/package.json +55 -0
- package/src/BubbleInput.tsx +64 -0
- package/src/index.ts +2 -0
- package/src/useCheckbox.tsx +112 -0
- package/src/utils.tsx +9 -0
- package/types/BubbleInput.d.ts +10 -0
- package/types/BubbleInput.d.ts.map +1 -0
- package/types/index.d.ts +3 -0
- package/types/index.d.ts.map +1 -0
- package/types/useCheckbox.d.ts +43 -0
- package/types/useCheckbox.d.ts.map +1 -0
- package/types/utils.d.ts +4 -0
- package/types/utils.d.ts.map +1 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021 Radix
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: !0 });
|
|
9
|
+
}, __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from == "object" || typeof from == "function")
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
13
|
+
return to;
|
|
14
|
+
};
|
|
15
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
16
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
17
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
18
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
19
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
|
|
21
|
+
mod
|
|
22
|
+
)), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
23
|
+
var BubbleInput_exports = {};
|
|
24
|
+
__export(BubbleInput_exports, {
|
|
25
|
+
BubbleInput: () => BubbleInput
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(BubbleInput_exports);
|
|
28
|
+
var import_use_previous = require("@tamagui/use-previous"), React = __toESM(require("react")), import_utils = require("./utils"), import_jsx_runtime = require("react/jsx-runtime");
|
|
29
|
+
const BubbleInput = (props) => {
|
|
30
|
+
const { checked, bubbles = !0, control, isHidden, ...inputProps } = props, ref = React.useRef(null), prevChecked = (0, import_use_previous.usePrevious)(checked);
|
|
31
|
+
return React.useEffect(() => {
|
|
32
|
+
const input = ref.current, inputProto = window.HTMLInputElement.prototype, setChecked = Object.getOwnPropertyDescriptor(
|
|
33
|
+
inputProto,
|
|
34
|
+
"checked"
|
|
35
|
+
).set;
|
|
36
|
+
if (prevChecked !== checked && setChecked) {
|
|
37
|
+
const event = new Event("click", { bubbles });
|
|
38
|
+
input.indeterminate = (0, import_utils.isIndeterminate)(checked), setChecked.call(input, (0, import_utils.isIndeterminate)(checked) ? !1 : checked), input.dispatchEvent(event);
|
|
39
|
+
}
|
|
40
|
+
}, [prevChecked, checked, bubbles]), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
41
|
+
"input",
|
|
42
|
+
{
|
|
43
|
+
type: "checkbox",
|
|
44
|
+
defaultChecked: (0, import_utils.isIndeterminate)(checked) ? !1 : checked,
|
|
45
|
+
...inputProps,
|
|
46
|
+
tabIndex: -1,
|
|
47
|
+
ref,
|
|
48
|
+
"aria-hidden": isHidden,
|
|
49
|
+
style: {
|
|
50
|
+
...isHidden ? {
|
|
51
|
+
// ...controlSize,
|
|
52
|
+
position: "absolute",
|
|
53
|
+
pointerEvents: "none",
|
|
54
|
+
opacity: 0,
|
|
55
|
+
margin: 0
|
|
56
|
+
} : {
|
|
57
|
+
appearance: "auto",
|
|
58
|
+
accentColor: "var(--color6)"
|
|
59
|
+
},
|
|
60
|
+
...props.style
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
);
|
|
64
|
+
};
|
|
65
|
+
//# sourceMappingURL=BubbleInput.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/BubbleInput.tsx"],
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0BAA4B,kCAC5B,QAAuB,2BAGvB,eAAgC,oBAkC5B;AAxBG,MAAM,cAAc,CAAC,UAA4B;AACtD,QAAM,EAAE,SAAS,UAAU,IAAM,SAAS,UAAU,GAAG,WAAW,IAAI,OAChE,MAAM,MAAM,OAAyB,IAAI,GACzC,kBAAc,iCAAY,OAAO;AAGvC,eAAM,UAAU,MAAM;AACpB,UAAM,QAAQ,IAAI,SACZ,aAAa,OAAO,iBAAiB,WAKrC,aAJa,OAAO;AAAA,MACxB;AAAA,MACA;AAAA,IACF,EAC8B;AAE9B,QAAI,gBAAgB,WAAW,YAAY;AACzC,YAAM,QAAQ,IAAI,MAAM,SAAS,EAAE,QAAQ,CAAC;AAC5C,YAAM,oBAAgB,8BAAgB,OAAO,GAC7C,WAAW,KAAK,WAAO,8BAAgB,OAAO,IAAI,KAAQ,OAAO,GACjE,MAAM,cAAc,KAAK;AAAA,IAC3B;AAAA,EACF,GAAG,CAAC,aAAa,SAAS,OAAO,CAAC,GAGhC;AAAA,IAAC;AAAA;AAAA,MACC,MAAK;AAAA,MACL,oBAAgB,8BAAgB,OAAO,IAAI,KAAQ;AAAA,MAClD,GAAG;AAAA,MACJ,UAAU;AAAA,MACV;AAAA,MACA,eAAa;AAAA,MACb,OAAO;AAAA,QACL,GAAI,WACA;AAAA;AAAA,UAEE,UAAU;AAAA,UACV,eAAe;AAAA,UACf,SAAS;AAAA,UACT,QAAQ;AAAA,QACV,IACA;AAAA,UACE,YAAY;AAAA,UACZ,aAAa;AAAA,QACf;AAAA,QAEJ,GAAG,MAAM;AAAA,MACX;AAAA;AAAA,EACF;AAEJ;",
|
|
5
|
+
"names": []
|
|
6
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: !0 });
|
|
10
|
+
}, __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from == "object" || typeof from == "function")
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
return to;
|
|
15
|
+
};
|
|
16
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
17
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
18
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
19
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
20
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
|
|
22
|
+
mod
|
|
23
|
+
)), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
24
|
+
var BubbleInput_exports = {};
|
|
25
|
+
__export(BubbleInput_exports, {
|
|
26
|
+
BubbleInput: () => BubbleInput
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(BubbleInput_exports);
|
|
29
|
+
var import_use_previous = require("@tamagui/use-previous"), React = __toESM(require("react")), import_utils = require("./utils"), import_jsx_runtime = require("react/jsx-runtime");
|
|
30
|
+
const BubbleInput = (props) => {
|
|
31
|
+
const { checked, bubbles = !0, control, isHidden, ...inputProps } = props, ref = React.useRef(null), prevChecked = (0, import_use_previous.usePrevious)(checked);
|
|
32
|
+
return React.useEffect(() => {
|
|
33
|
+
const input = ref.current, inputProto = window.HTMLInputElement.prototype, setChecked = Object.getOwnPropertyDescriptor(
|
|
34
|
+
inputProto,
|
|
35
|
+
"checked"
|
|
36
|
+
).set;
|
|
37
|
+
if (prevChecked !== checked && setChecked) {
|
|
38
|
+
const event = new Event("click", { bubbles });
|
|
39
|
+
input.indeterminate = (0, import_utils.isIndeterminate)(checked), setChecked.call(input, (0, import_utils.isIndeterminate)(checked) ? !1 : checked), input.dispatchEvent(event);
|
|
40
|
+
}
|
|
41
|
+
}, [prevChecked, checked, bubbles]), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
42
|
+
"input",
|
|
43
|
+
{
|
|
44
|
+
type: "checkbox",
|
|
45
|
+
defaultChecked: (0, import_utils.isIndeterminate)(checked) ? !1 : checked,
|
|
46
|
+
...inputProps,
|
|
47
|
+
tabIndex: -1,
|
|
48
|
+
ref,
|
|
49
|
+
"aria-hidden": isHidden,
|
|
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
|
+
}
|
|
64
|
+
);
|
|
65
|
+
};
|
|
66
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
67
|
+
0 && (module.exports = {
|
|
68
|
+
BubbleInput
|
|
69
|
+
});
|
|
70
|
+
//# sourceMappingURL=BubbleInput.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/BubbleInput.tsx"],
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0BAA4B,kCAC5B,QAAuB,2BAGvB,eAAgC,oBAkC5B;AAxBG,MAAM,cAAc,CAAC,UAA4B;AACtD,QAAM,EAAE,SAAS,UAAU,IAAM,SAAS,UAAU,GAAG,WAAW,IAAI,OAChE,MAAM,MAAM,OAAyB,IAAI,GACzC,kBAAc,iCAAY,OAAO;AAGvC,eAAM,UAAU,MAAM;AACpB,UAAM,QAAQ,IAAI,SACZ,aAAa,OAAO,iBAAiB,WAKrC,aAJa,OAAO;AAAA,MACxB;AAAA,MACA;AAAA,IACF,EAC8B;AAE9B,QAAI,gBAAgB,WAAW,YAAY;AACzC,YAAM,QAAQ,IAAI,MAAM,SAAS,EAAE,QAAQ,CAAC;AAC5C,YAAM,oBAAgB,8BAAgB,OAAO,GAC7C,WAAW,KAAK,WAAO,8BAAgB,OAAO,IAAI,KAAQ,OAAO,GACjE,MAAM,cAAc,KAAK;AAAA,IAC3B;AAAA,EACF,GAAG,CAAC,aAAa,SAAS,OAAO,CAAC,GAGhC;AAAA,IAAC;AAAA;AAAA,MACC,MAAK;AAAA,MACL,oBAAgB,8BAAgB,OAAO,IAAI,KAAQ;AAAA,MAClD,GAAG;AAAA,MACJ,UAAU;AAAA,MACV;AAAA,MACA,eAAa;AAAA,MACb,OAAO;AAAA,QACL,GAAI,WACA;AAAA;AAAA,UAEE,UAAU;AAAA,UACV,eAAe;AAAA,UACf,SAAS;AAAA,UACT,QAAQ;AAAA,QACV,IACA;AAAA,UACE,YAAY;AAAA,UACZ,aAAa;AAAA,QACf;AAAA,QAEJ,GAAG,MAAM;AAAA,MACX;AAAA;AAAA,EACF;AAEJ;",
|
|
5
|
+
"names": []
|
|
6
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
|
6
|
+
if (from && typeof from == "object" || typeof from == "function")
|
|
7
|
+
for (let key of __getOwnPropNames(from))
|
|
8
|
+
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
9
|
+
return to;
|
|
10
|
+
}, __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
11
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
12
|
+
var src_exports = {};
|
|
13
|
+
module.exports = __toCommonJS(src_exports);
|
|
14
|
+
__reExport(src_exports, require("./useCheckbox"), module.exports);
|
|
15
|
+
__reExport(src_exports, require("./utils"), module.exports);
|
|
16
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from == "object" || typeof from == "function")
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
+
return to;
|
|
11
|
+
}, __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
12
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
13
|
+
var src_exports = {};
|
|
14
|
+
module.exports = __toCommonJS(src_exports);
|
|
15
|
+
__reExport(src_exports, require("./useCheckbox"), module.exports);
|
|
16
|
+
__reExport(src_exports, require("./utils"), module.exports);
|
|
17
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
18
|
+
0 && (module.exports = {
|
|
19
|
+
...require("./useCheckbox"),
|
|
20
|
+
...require("./utils")
|
|
21
|
+
});
|
|
22
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: !0 });
|
|
9
|
+
}, __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from == "object" || typeof from == "function")
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
13
|
+
return to;
|
|
14
|
+
};
|
|
15
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
16
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
17
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
18
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
19
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
|
|
21
|
+
mod
|
|
22
|
+
)), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
23
|
+
var useCheckbox_exports = {};
|
|
24
|
+
__export(useCheckbox_exports, {
|
|
25
|
+
useCheckbox: () => useCheckbox
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(useCheckbox_exports);
|
|
28
|
+
var 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"), import_jsx_runtime = require("react/jsx-runtime");
|
|
29
|
+
function useCheckbox(props, [checked, setChecked], ref) {
|
|
30
|
+
const {
|
|
31
|
+
labelledBy: ariaLabelledby,
|
|
32
|
+
name,
|
|
33
|
+
required,
|
|
34
|
+
disabled,
|
|
35
|
+
value = "on",
|
|
36
|
+
onCheckedChange,
|
|
37
|
+
...checkboxProps
|
|
38
|
+
} = props, [button, setButton] = import_react.default.useState(null), composedRefs = (0, import_compose_refs.useComposedRefs)(ref, (node) => setButton(node)), 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;
|
|
39
|
+
return {
|
|
40
|
+
bubbleInput: import_constants.isWeb && isFormControl ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
41
|
+
import_BubbleInput.BubbleInput,
|
|
42
|
+
{
|
|
43
|
+
isHidden: !0,
|
|
44
|
+
control: button,
|
|
45
|
+
bubbles: !hasConsumerStoppedPropagationRef.current,
|
|
46
|
+
name,
|
|
47
|
+
value,
|
|
48
|
+
checked,
|
|
49
|
+
required,
|
|
50
|
+
disabled
|
|
51
|
+
}
|
|
52
|
+
) : null,
|
|
53
|
+
checkboxRef: composedRefs,
|
|
54
|
+
checkboxProps: {
|
|
55
|
+
role: "checkbox",
|
|
56
|
+
"aria-labelledby": labelledBy,
|
|
57
|
+
"aria-checked": (0, import_utils.isIndeterminate)(checked) ? "mixed" : checked,
|
|
58
|
+
...checkboxProps,
|
|
59
|
+
...import_constants.isWeb && {
|
|
60
|
+
type: "button",
|
|
61
|
+
value,
|
|
62
|
+
"data-state": (0, import_utils.getState)(checked),
|
|
63
|
+
"data-disabled": disabled ? "" : void 0,
|
|
64
|
+
disabled,
|
|
65
|
+
onKeyDown: (0, import_helpers.composeEventHandlers)(
|
|
66
|
+
props.onKeyDown,
|
|
67
|
+
(event) => {
|
|
68
|
+
event.key === "Enter" && event.preventDefault();
|
|
69
|
+
}
|
|
70
|
+
)
|
|
71
|
+
},
|
|
72
|
+
onPress: (0, import_helpers.composeEventHandlers)(
|
|
73
|
+
props.onPress,
|
|
74
|
+
(event) => {
|
|
75
|
+
setChecked(
|
|
76
|
+
(prevChecked) => (0, import_utils.isIndeterminate)(prevChecked) ? !0 : !prevChecked
|
|
77
|
+
), isFormControl && "isPropagationStopped" in event && (hasConsumerStoppedPropagationRef.current = event.isPropagationStopped(), hasConsumerStoppedPropagationRef.current || event.stopPropagation());
|
|
78
|
+
}
|
|
79
|
+
)
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=useCheckbox.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/useCheckbox.tsx"],
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0BAAgC,kCAChC,mBAAsB,+BAEtB,iBAAqC,6BACrC,eAAgC,2BAChC,eAAkB,2BAGlB,qBAA4B,0BAC5B,eAA0C,oBAsDlC;AA7BD,SAAS,YACd,OACA,CAAC,SAAS,UAAU,GAIpB,KACA;AACA,QAAM;AAAA,IACJ,YAAY;AAAA,IACZ;AAAA,IACA;AAAA,IACA;AAAA,IACA,QAAQ;AAAA,IACR;AAAA,IACA,GAAG;AAAA,EACL,IAAI,OACE,CAAC,QAAQ,SAAS,IAAI,aAAAA,QAAM,SAAmC,IAAI,GACnE,mBAAe,qCAAgB,KAAK,CAAC,SAAS,UAAU,IAAW,CAAC,GACpE,mCAAmC,aAAAA,QAAM,OAAO,EAAK,GAErD,gBAAgB,yBAAS,SAAS,EAAQ,OAAO,QAAQ,MAAM,IAAK,KAAQ,IAE5E,cAAU,8BAAgB,MAAM,GAChC,aAAa,kBAAkB;AAErC,SAAO;AAAA,IACL,aACE,0BAAS,gBACP;AAAA,MAAC;AAAA;AAAA,QACC,UAAQ;AAAA,QACR,SAAS;AAAA,QACT,SAAS,CAAC,iCAAiC;AAAA,QAC3C;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA;AAAA,IACF,IACE;AAAA,IACN,aAAa;AAAA,IACb,eAAe;AAAA,MACb,MAAM;AAAA,MACN,mBAAmB;AAAA,MACnB,oBAAgB,8BAAgB,OAAO,IAAI,UAAU;AAAA,MACrD,GAAG;AAAA,MACH,GAAI,0BAAS;AAAA,QACX,MAAM;AAAA,QACN;AAAA,QACA,kBAAc,uBAAS,OAAO;AAAA,QAC9B,iBAAiB,WAAW,KAAK;AAAA,QACjC;AAAA,QACA,eAAW;AAAA,UACR,MAA6C;AAAA,UAC9C,CAAC,UAAU;AAET,YAAI,MAAM,QAAQ,WAAS,MAAM,eAAe;AAAA,UAClD;AAAA,QACF;AAAA,MACF;AAAA,MACA,aAAS;AAAA,QACP,MAAM;AAAA,QACN,CAAC,UAAgC;AAC/B;AAAA,YAAW,CAAC,oBACV,8BAAgB,WAAW,IAAI,KAAO,CAAC;AAAA,UACzC,GACI,iBAAiB,0BAA0B,UAC7C,iCAAiC,UAAU,MAAM,qBAAqB,GAIjE,iCAAiC,WAAS,MAAM,gBAAgB;AAAA,QAEzE;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;",
|
|
5
|
+
"names": ["React"]
|
|
6
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: !0 });
|
|
10
|
+
}, __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from == "object" || typeof from == "function")
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
return to;
|
|
15
|
+
};
|
|
16
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
17
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
18
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
19
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
20
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
|
|
22
|
+
mod
|
|
23
|
+
)), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
24
|
+
var useCheckbox_exports = {};
|
|
25
|
+
__export(useCheckbox_exports, {
|
|
26
|
+
useCheckbox: () => useCheckbox
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(useCheckbox_exports);
|
|
29
|
+
var 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"), import_jsx_runtime = require("react/jsx-runtime");
|
|
30
|
+
function useCheckbox(props, [checked, setChecked], ref) {
|
|
31
|
+
const {
|
|
32
|
+
labelledBy: ariaLabelledby,
|
|
33
|
+
name,
|
|
34
|
+
required,
|
|
35
|
+
disabled,
|
|
36
|
+
value = "on",
|
|
37
|
+
onCheckedChange,
|
|
38
|
+
...checkboxProps
|
|
39
|
+
} = props, [button, setButton] = import_react.default.useState(null), composedRefs = (0, import_compose_refs.useComposedRefs)(ref, (node) => setButton(node)), 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;
|
|
40
|
+
return {
|
|
41
|
+
bubbleInput: import_constants.isWeb && isFormControl ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
42
|
+
import_BubbleInput.BubbleInput,
|
|
43
|
+
{
|
|
44
|
+
isHidden: !0,
|
|
45
|
+
control: button,
|
|
46
|
+
bubbles: !hasConsumerStoppedPropagationRef.current,
|
|
47
|
+
name,
|
|
48
|
+
value,
|
|
49
|
+
checked,
|
|
50
|
+
required,
|
|
51
|
+
disabled
|
|
52
|
+
}
|
|
53
|
+
) : null,
|
|
54
|
+
checkboxRef: composedRefs,
|
|
55
|
+
checkboxProps: {
|
|
56
|
+
role: "checkbox",
|
|
57
|
+
"aria-labelledby": labelledBy,
|
|
58
|
+
"aria-checked": (0, import_utils.isIndeterminate)(checked) ? "mixed" : checked,
|
|
59
|
+
...checkboxProps,
|
|
60
|
+
...import_constants.isWeb && {
|
|
61
|
+
type: "button",
|
|
62
|
+
value,
|
|
63
|
+
"data-state": (0, import_utils.getState)(checked),
|
|
64
|
+
"data-disabled": disabled ? "" : void 0,
|
|
65
|
+
disabled,
|
|
66
|
+
onKeyDown: (0, import_helpers.composeEventHandlers)(
|
|
67
|
+
props.onKeyDown,
|
|
68
|
+
(event) => {
|
|
69
|
+
event.key === "Enter" && event.preventDefault();
|
|
70
|
+
}
|
|
71
|
+
)
|
|
72
|
+
},
|
|
73
|
+
onPress: (0, import_helpers.composeEventHandlers)(
|
|
74
|
+
props.onPress,
|
|
75
|
+
(event) => {
|
|
76
|
+
setChecked(
|
|
77
|
+
(prevChecked) => (0, import_utils.isIndeterminate)(prevChecked) ? !0 : !prevChecked
|
|
78
|
+
), isFormControl && "isPropagationStopped" in event && (hasConsumerStoppedPropagationRef.current = event.isPropagationStopped(), hasConsumerStoppedPropagationRef.current || event.stopPropagation());
|
|
79
|
+
}
|
|
80
|
+
)
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
85
|
+
0 && (module.exports = {
|
|
86
|
+
useCheckbox
|
|
87
|
+
});
|
|
88
|
+
//# sourceMappingURL=useCheckbox.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/useCheckbox.tsx"],
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0BAAgC,kCAChC,mBAAsB,+BAEtB,iBAAqC,6BACrC,eAAgC,2BAChC,eAAkB,2BAGlB,qBAA4B,0BAC5B,eAA0C,oBAsDlC;AA7BD,SAAS,YACd,OACA,CAAC,SAAS,UAAU,GAIpB,KACA;AACA,QAAM;AAAA,IACJ,YAAY;AAAA,IACZ;AAAA,IACA;AAAA,IACA;AAAA,IACA,QAAQ;AAAA,IACR;AAAA,IACA,GAAG;AAAA,EACL,IAAI,OACE,CAAC,QAAQ,SAAS,IAAI,aAAAA,QAAM,SAAmC,IAAI,GACnE,mBAAe,qCAAgB,KAAK,CAAC,SAAS,UAAU,IAAW,CAAC,GACpE,mCAAmC,aAAAA,QAAM,OAAO,EAAK,GAErD,gBAAgB,yBAAS,SAAS,EAAQ,OAAO,QAAQ,MAAM,IAAK,KAAQ,IAE5E,cAAU,8BAAgB,MAAM,GAChC,aAAa,kBAAkB;AAErC,SAAO;AAAA,IACL,aACE,0BAAS,gBACP;AAAA,MAAC;AAAA;AAAA,QACC,UAAQ;AAAA,QACR,SAAS;AAAA,QACT,SAAS,CAAC,iCAAiC;AAAA,QAC3C;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA;AAAA,IACF,IACE;AAAA,IACN,aAAa;AAAA,IACb,eAAe;AAAA,MACb,MAAM;AAAA,MACN,mBAAmB;AAAA,MACnB,oBAAgB,8BAAgB,OAAO,IAAI,UAAU;AAAA,MACrD,GAAG;AAAA,MACH,GAAI,0BAAS;AAAA,QACX,MAAM;AAAA,QACN;AAAA,QACA,kBAAc,uBAAS,OAAO;AAAA,QAC9B,iBAAiB,WAAW,KAAK;AAAA,QACjC;AAAA,QACA,eAAW;AAAA,UACR,MAA6C;AAAA,UAC9C,CAAC,UAAU;AAET,YAAI,MAAM,QAAQ,WAAS,MAAM,eAAe;AAAA,UAClD;AAAA,QACF;AAAA,MACF;AAAA,MACA,aAAS;AAAA,QACP,MAAM;AAAA,QACN,CAAC,UAAgC;AAC/B;AAAA,YAAW,CAAC,oBACV,8BAAgB,WAAW,IAAI,KAAO,CAAC;AAAA,UACzC,GACI,iBAAiB,0BAA0B,UAC7C,iCAAiC,UAAU,MAAM,qBAAqB,GAIjE,iCAAiC,WAAS,MAAM,gBAAgB;AAAA,QAEzE;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;",
|
|
5
|
+
"names": ["React"]
|
|
6
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: !0 });
|
|
8
|
+
}, __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from == "object" || typeof from == "function")
|
|
10
|
+
for (let key of __getOwnPropNames(from))
|
|
11
|
+
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
15
|
+
var utils_exports = {};
|
|
16
|
+
__export(utils_exports, {
|
|
17
|
+
getState: () => getState,
|
|
18
|
+
isIndeterminate: () => isIndeterminate
|
|
19
|
+
});
|
|
20
|
+
module.exports = __toCommonJS(utils_exports);
|
|
21
|
+
function isIndeterminate(checked) {
|
|
22
|
+
return checked === "indeterminate";
|
|
23
|
+
}
|
|
24
|
+
function getState(checked) {
|
|
25
|
+
return isIndeterminate(checked) ? "indeterminate" : checked ? "checked" : "unchecked";
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: !0 });
|
|
9
|
+
}, __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from == "object" || typeof from == "function")
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
13
|
+
return to;
|
|
14
|
+
};
|
|
15
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
16
|
+
var utils_exports = {};
|
|
17
|
+
__export(utils_exports, {
|
|
18
|
+
getState: () => getState,
|
|
19
|
+
isIndeterminate: () => isIndeterminate
|
|
20
|
+
});
|
|
21
|
+
module.exports = __toCommonJS(utils_exports);
|
|
22
|
+
function isIndeterminate(checked) {
|
|
23
|
+
return checked === "indeterminate";
|
|
24
|
+
}
|
|
25
|
+
function getState(checked) {
|
|
26
|
+
return isIndeterminate(checked) ? "indeterminate" : checked ? "checked" : "unchecked";
|
|
27
|
+
}
|
|
28
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
29
|
+
0 && (module.exports = {
|
|
30
|
+
getState,
|
|
31
|
+
isIndeterminate
|
|
32
|
+
});
|
|
33
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { usePrevious } from "@tamagui/use-previous";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { isIndeterminate } from "./utils";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
const BubbleInput = (props) => {
|
|
6
|
+
const { checked, bubbles = !0, control, isHidden, ...inputProps } = props, ref = React.useRef(null), prevChecked = usePrevious(checked);
|
|
7
|
+
return React.useEffect(() => {
|
|
8
|
+
const input = ref.current, inputProto = window.HTMLInputElement.prototype, setChecked = Object.getOwnPropertyDescriptor(
|
|
9
|
+
inputProto,
|
|
10
|
+
"checked"
|
|
11
|
+
).set;
|
|
12
|
+
if (prevChecked !== checked && setChecked) {
|
|
13
|
+
const event = new Event("click", { bubbles });
|
|
14
|
+
input.indeterminate = isIndeterminate(checked), setChecked.call(input, isIndeterminate(checked) ? !1 : checked), input.dispatchEvent(event);
|
|
15
|
+
}
|
|
16
|
+
}, [prevChecked, checked, bubbles]), /* @__PURE__ */ jsx(
|
|
17
|
+
"input",
|
|
18
|
+
{
|
|
19
|
+
type: "checkbox",
|
|
20
|
+
defaultChecked: isIndeterminate(checked) ? !1 : checked,
|
|
21
|
+
...inputProps,
|
|
22
|
+
tabIndex: -1,
|
|
23
|
+
ref,
|
|
24
|
+
"aria-hidden": isHidden,
|
|
25
|
+
style: {
|
|
26
|
+
...isHidden ? {
|
|
27
|
+
// ...controlSize,
|
|
28
|
+
position: "absolute",
|
|
29
|
+
pointerEvents: "none",
|
|
30
|
+
opacity: 0,
|
|
31
|
+
margin: 0
|
|
32
|
+
} : {
|
|
33
|
+
appearance: "auto",
|
|
34
|
+
accentColor: "var(--color6)"
|
|
35
|
+
},
|
|
36
|
+
...props.style
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
);
|
|
40
|
+
};
|
|
41
|
+
export {
|
|
42
|
+
BubbleInput
|
|
43
|
+
};
|
|
44
|
+
//# sourceMappingURL=BubbleInput.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/BubbleInput.tsx"],
|
|
4
|
+
"mappings": "AAAA,SAAS,mBAAmB;AAC5B,YAAY,WAAW;AAGvB,SAAS,uBAAuB;AAkC5B;AAxBG,MAAM,cAAc,CAAC,UAA4B;AACtD,QAAM,EAAE,SAAS,UAAU,IAAM,SAAS,UAAU,GAAG,WAAW,IAAI,OAChE,MAAM,MAAM,OAAyB,IAAI,GACzC,cAAc,YAAY,OAAO;AAGvC,eAAM,UAAU,MAAM;AACpB,UAAM,QAAQ,IAAI,SACZ,aAAa,OAAO,iBAAiB,WAKrC,aAJa,OAAO;AAAA,MACxB;AAAA,MACA;AAAA,IACF,EAC8B;AAE9B,QAAI,gBAAgB,WAAW,YAAY;AACzC,YAAM,QAAQ,IAAI,MAAM,SAAS,EAAE,QAAQ,CAAC;AAC5C,YAAM,gBAAgB,gBAAgB,OAAO,GAC7C,WAAW,KAAK,OAAO,gBAAgB,OAAO,IAAI,KAAQ,OAAO,GACjE,MAAM,cAAc,KAAK;AAAA,IAC3B;AAAA,EACF,GAAG,CAAC,aAAa,SAAS,OAAO,CAAC,GAGhC;AAAA,IAAC;AAAA;AAAA,MACC,MAAK;AAAA,MACL,gBAAgB,gBAAgB,OAAO,IAAI,KAAQ;AAAA,MAClD,GAAG;AAAA,MACJ,UAAU;AAAA,MACV;AAAA,MACA,eAAa;AAAA,MACb,OAAO;AAAA,QACL,GAAI,WACA;AAAA;AAAA,UAEE,UAAU;AAAA,UACV,eAAe;AAAA,UACf,SAAS;AAAA,UACT,QAAQ;AAAA,QACV,IACA;AAAA,UACE,YAAY;AAAA,UACZ,aAAa;AAAA,QACf;AAAA,QAEJ,GAAG,MAAM;AAAA,MACX;AAAA;AAAA,EACF;AAEJ;",
|
|
5
|
+
"names": []
|
|
6
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { usePrevious } from "@tamagui/use-previous";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { isIndeterminate } from "./utils.mjs";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
const BubbleInput = props => {
|
|
6
|
+
const {
|
|
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(() => {
|
|
16
|
+
const input = ref.current,
|
|
17
|
+
inputProto = window.HTMLInputElement.prototype,
|
|
18
|
+
setChecked = Object.getOwnPropertyDescriptor(inputProto, "checked").set;
|
|
19
|
+
if (prevChecked !== checked && setChecked) {
|
|
20
|
+
const event = new Event("click", {
|
|
21
|
+
bubbles
|
|
22
|
+
});
|
|
23
|
+
input.indeterminate = isIndeterminate(checked), setChecked.call(input, isIndeterminate(checked) ? !1 : checked), input.dispatchEvent(event);
|
|
24
|
+
}
|
|
25
|
+
}, [prevChecked, checked, bubbles]), /* @__PURE__ */jsx("input", {
|
|
26
|
+
type: "checkbox",
|
|
27
|
+
defaultChecked: isIndeterminate(checked) ? !1 : checked,
|
|
28
|
+
...inputProps,
|
|
29
|
+
tabIndex: -1,
|
|
30
|
+
ref,
|
|
31
|
+
"aria-hidden": isHidden,
|
|
32
|
+
style: {
|
|
33
|
+
...(isHidden ? {
|
|
34
|
+
// ...controlSize,
|
|
35
|
+
position: "absolute",
|
|
36
|
+
pointerEvents: "none",
|
|
37
|
+
opacity: 0,
|
|
38
|
+
margin: 0
|
|
39
|
+
} : {
|
|
40
|
+
appearance: "auto",
|
|
41
|
+
accentColor: "var(--color6)"
|
|
42
|
+
}),
|
|
43
|
+
...props.style
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
};
|
|
47
|
+
export { BubbleInput };
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { usePrevious } from "@tamagui/use-previous";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { isIndeterminate } from "./utils";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
const BubbleInput = (props) => {
|
|
6
|
+
const { checked, bubbles = !0, control, isHidden, ...inputProps } = props, ref = React.useRef(null), prevChecked = usePrevious(checked);
|
|
7
|
+
return React.useEffect(() => {
|
|
8
|
+
const input = ref.current, inputProto = window.HTMLInputElement.prototype, setChecked = Object.getOwnPropertyDescriptor(
|
|
9
|
+
inputProto,
|
|
10
|
+
"checked"
|
|
11
|
+
).set;
|
|
12
|
+
if (prevChecked !== checked && setChecked) {
|
|
13
|
+
const event = new Event("click", { bubbles });
|
|
14
|
+
input.indeterminate = isIndeterminate(checked), setChecked.call(input, isIndeterminate(checked) ? !1 : checked), input.dispatchEvent(event);
|
|
15
|
+
}
|
|
16
|
+
}, [prevChecked, checked, bubbles]), /* @__PURE__ */ jsx(
|
|
17
|
+
"input",
|
|
18
|
+
{
|
|
19
|
+
type: "checkbox",
|
|
20
|
+
defaultChecked: isIndeterminate(checked) ? !1 : checked,
|
|
21
|
+
...inputProps,
|
|
22
|
+
tabIndex: -1,
|
|
23
|
+
ref,
|
|
24
|
+
"aria-hidden": isHidden,
|
|
25
|
+
style: {
|
|
26
|
+
...isHidden ? {
|
|
27
|
+
// ...controlSize,
|
|
28
|
+
position: "absolute",
|
|
29
|
+
pointerEvents: "none",
|
|
30
|
+
opacity: 0,
|
|
31
|
+
margin: 0
|
|
32
|
+
} : {
|
|
33
|
+
appearance: "auto",
|
|
34
|
+
accentColor: "var(--color6)"
|
|
35
|
+
},
|
|
36
|
+
...props.style
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
);
|
|
40
|
+
};
|
|
41
|
+
export {
|
|
42
|
+
BubbleInput
|
|
43
|
+
};
|
|
44
|
+
//# sourceMappingURL=BubbleInput.js.map
|