@tamagui/checkbox-headless 2.7.7 → 3.0.0-beta.643.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/dist/cjs/BubbleInput.cjs +58 -71
  2. package/dist/cjs/BubbleInput.native.cjs +77 -0
  3. package/dist/cjs/BubbleInput.native.js +58 -70
  4. package/dist/cjs/BubbleInput.native.js.map +1 -1
  5. package/dist/cjs/index.cjs +10 -11
  6. package/dist/cjs/index.native.cjs +22 -0
  7. package/dist/cjs/index.native.js +10 -10
  8. package/dist/cjs/index.native.js.map +1 -1
  9. package/dist/cjs/useCheckbox.cjs +64 -80
  10. package/dist/cjs/useCheckbox.native.cjs +95 -0
  11. package/dist/cjs/useCheckbox.native.js +71 -86
  12. package/dist/cjs/useCheckbox.native.js.map +1 -1
  13. package/dist/cjs/utils.cjs +18 -19
  14. package/dist/cjs/utils.native.cjs +35 -0
  15. package/dist/cjs/utils.native.js +18 -18
  16. package/dist/cjs/utils.native.js.map +1 -1
  17. package/dist/esm/BubbleInput.mjs +42 -45
  18. package/dist/esm/BubbleInput.mjs.map +1 -1
  19. package/dist/esm/BubbleInput.native.js +43 -46
  20. package/dist/esm/BubbleInput.native.js.map +1 -1
  21. package/dist/esm/index.js +3 -3
  22. package/dist/esm/index.mjs +3 -3
  23. package/dist/esm/index.native.js +3 -3
  24. package/dist/esm/useCheckbox.mjs +48 -54
  25. package/dist/esm/useCheckbox.mjs.map +1 -1
  26. package/dist/esm/useCheckbox.native.js +56 -62
  27. package/dist/esm/useCheckbox.native.js.map +1 -1
  28. package/dist/esm/utils.mjs +3 -2
  29. package/dist/esm/utils.mjs.map +1 -1
  30. package/dist/esm/utils.native.js +3 -2
  31. package/dist/esm/utils.native.js.map +1 -1
  32. package/dist/jsx/BubbleInput.mjs +42 -45
  33. package/dist/jsx/BubbleInput.mjs.map +1 -1
  34. package/dist/jsx/BubbleInput.native.cjs +77 -0
  35. package/dist/jsx/BubbleInput.native.js +58 -70
  36. package/dist/jsx/BubbleInput.native.js.map +1 -1
  37. package/dist/jsx/index.js +3 -3
  38. package/dist/jsx/index.mjs +3 -3
  39. package/dist/jsx/index.native.cjs +22 -0
  40. package/dist/jsx/index.native.js +10 -10
  41. package/dist/jsx/index.native.js.map +1 -1
  42. package/dist/jsx/useCheckbox.mjs +48 -54
  43. package/dist/jsx/useCheckbox.mjs.map +1 -1
  44. package/dist/jsx/useCheckbox.native.cjs +95 -0
  45. package/dist/jsx/useCheckbox.native.js +71 -86
  46. package/dist/jsx/useCheckbox.native.js.map +1 -1
  47. package/dist/jsx/utils.mjs +3 -2
  48. package/dist/jsx/utils.mjs.map +1 -1
  49. package/dist/jsx/utils.native.cjs +35 -0
  50. package/dist/jsx/utils.native.js +18 -18
  51. package/dist/jsx/utils.native.js.map +1 -1
  52. package/package.json +12 -12
  53. package/types/BubbleInput.d.ts +1 -1
  54. package/types/BubbleInput.d.ts.map +1 -1
  55. package/types/useCheckbox.d.ts +4 -4
  56. package/types/utils.d.ts +1 -1
  57. package/dist/esm/index.js.map +0 -1
  58. package/dist/esm/index.mjs.map +0 -1
  59. package/dist/esm/index.native.js.map +0 -1
  60. package/dist/jsx/index.js.map +0 -1
  61. package/dist/jsx/index.mjs.map +0 -1
@@ -1 +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":[]}
1
+ {"version":3,"file":"utils.native.js","names":[],"sources":["esm/utils.native.js"],"sourcesContent":["function isIndeterminate(checked) {\n return checked === \"indeterminate\";\n}\nfunction getState(checked) {\n return isIndeterminate(checked) ? \"indeterminate\" : checked ? \"checked\" : \"unchecked\";\n}\nexport {\n getState,\n isIndeterminate\n};\n//# sourceMappingURL=utils.js.map\n"],"mappings":";AAAA,SAAS,gBAAgB,SAAS;CAChC,OAAO,YAAY;AACrB;AACA,SAAS,SAAS,SAAS;CACzB,OAAO,gBAAgB,OAAO,IAAI,kBAAkB,UAAU,YAAY;AAC5E"}
@@ -2,51 +2,48 @@ import { usePrevious } from "@tamagui/use-previous";
2
2
  import * as React from "react";
3
3
  import { isIndeterminate } from "./utils.mjs";
4
4
  import { jsx } from "react/jsx-runtime";
5
- const BubbleInput = props => {
6
- const {
7
- checked,
8
- bubbles = true,
9
- control,
10
- isHidden,
11
- ...inputProps
12
- } = props;
13
- const ref = React.useRef(null);
14
- const prevChecked = usePrevious(checked);
15
- React.useEffect(() => {
16
- const input = ref.current;
17
- const inputProto = window.HTMLInputElement.prototype;
18
- const descriptor = Object.getOwnPropertyDescriptor(inputProto, "checked");
19
- const setChecked = descriptor.set;
20
- if (prevChecked !== checked && setChecked) {
21
- const event = new Event("click", {
22
- bubbles
23
- });
24
- input.indeterminate = isIndeterminate(checked);
25
- setChecked.call(input, isIndeterminate(checked) ? false : checked);
26
- input.dispatchEvent(event);
27
- }
28
- }, [prevChecked, checked, bubbles]);
29
- return /* @__PURE__ */jsx("input", {
30
- type: "checkbox",
31
- defaultChecked: isIndeterminate(checked) ? false : checked,
32
- ...inputProps,
33
- tabIndex: -1,
34
- ref,
35
- "aria-hidden": isHidden,
36
- style: {
37
- ...(isHidden ? {
38
- // ...controlSize,
39
- position: "absolute",
40
- pointerEvents: "none",
41
- opacity: 0,
42
- margin: 0
43
- } : {
44
- appearance: "auto",
45
- accentColor: "var(--color6)"
46
- }),
47
- ...props.style
48
- }
49
- });
5
+
6
+ const BubbleInput = (props) => {
7
+ const { checked, bubbles = true, control, isHidden, ...inputProps } = props;
8
+ const ref = React.useRef(null);
9
+ const prevChecked = usePrevious(checked);
10
+ React.useEffect(() => {
11
+ const input = ref.current;
12
+ const inputProto = window.HTMLInputElement.prototype;
13
+ const descriptor = Object.getOwnPropertyDescriptor(inputProto, "checked");
14
+ const setChecked = descriptor.set;
15
+ if (prevChecked !== checked && setChecked) {
16
+ const event = new Event("click", { bubbles });
17
+ input.indeterminate = isIndeterminate(checked);
18
+ setChecked.call(input, isIndeterminate(checked) ? false : checked);
19
+ input.dispatchEvent(event);
20
+ }
21
+ }, [
22
+ prevChecked,
23
+ checked,
24
+ bubbles
25
+ ]);
26
+ return /* @__PURE__ */ jsx("input", {
27
+ type: "checkbox",
28
+ defaultChecked: isIndeterminate(checked) ? false : checked,
29
+ ...inputProps,
30
+ tabIndex: -1,
31
+ ref,
32
+ "aria-hidden": isHidden,
33
+ style: {
34
+ ...isHidden ? {
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
+ });
50
46
  };
47
+
51
48
  export { BubbleInput };
52
49
  //# sourceMappingURL=BubbleInput.mjs.map
@@ -1 +1 @@
1
- {"version":3,"names":["usePrevious","React","isIndeterminate","jsx","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,WAAA,QAAmB;AAC5B,YAAYC,KAAA,MAAW;AAGvB,SAASC,eAAA,QAAuB;AAkC5B,SAAAC,GAAA;AAxBG,MAAMC,WAAA,GAAeC,KAAA,IAA4B;EACtD,MAAM;IAAEC,OAAA;IAASC,OAAA,GAAU;IAAMC,OAAA;IAASC,QAAA;IAAU,GAAGC;EAAW,IAAIL,KAAA;EACtE,MAAMM,GAAA,GAAMV,KAAA,CAAMW,MAAA,CAAyB,IAAI;EAC/C,MAAMC,WAAA,GAAcb,WAAA,CAAYM,OAAO;EAGvCL,KAAA,CAAMa,SAAA,CAAU,MAAM;IACpB,MAAMC,KAAA,GAAQJ,GAAA,CAAIK,OAAA;IAClB,MAAMC,UAAA,GAAaC,MAAA,CAAOC,gBAAA,CAAiBC,SAAA;IAC3C,MAAMC,UAAA,GAAaC,MAAA,CAAOC,wBAAA,CACxBN,UAAA,EACA,SACF;IACA,MAAMO,UAAA,GAAaH,UAAA,CAAWI,GAAA;IAE9B,IAAIZ,WAAA,KAAgBP,OAAA,IAAWkB,UAAA,EAAY;MACzC,MAAME,KAAA,GAAQ,IAAIC,KAAA,CAAM,SAAS;QAAEpB;MAAQ,CAAC;MAC5CQ,KAAA,CAAMa,aAAA,GAAgB1B,eAAA,CAAgBI,OAAO;MAC7CkB,UAAA,CAAWK,IAAA,CAAKd,KAAA,EAAOb,eAAA,CAAgBI,OAAO,IAAI,QAAQA,OAAO;MACjES,KAAA,CAAMe,aAAA,CAAcJ,KAAK;IAC3B;EACF,GAAG,CAACb,WAAA,EAAaP,OAAA,EAASC,OAAO,CAAC;EAElC,OACE,eAAAJ,GAAA,CAAC;IACC4B,IAAA,EAAK;IACLC,cAAA,EAAgB9B,eAAA,CAAgBI,OAAO,IAAI,QAAQA,OAAA;IAClD,GAAGI,UAAA;IACJuB,QAAA,EAAU;IACVtB,GAAA;IACA,eAAaF,QAAA;IACbyB,KAAA,EAAO;MACL,IAAIzB,QAAA,GACA;QAAA;QAEE0B,QAAA,EAAU;QACVC,aAAA,EAAe;QACfC,OAAA,EAAS;QACTC,MAAA,EAAQ;MACV,IACA;QACEC,UAAA,EAAY;QACZC,WAAA,EAAa;MACf;MAEJ,GAAGnC,KAAA,CAAM6B;IACX;EAAA,CACF;AAEJ","ignoreList":[]}
1
+ {"version":3,"file":"BubbleInput.js","names":[],"sources":["jsx/BubbleInput.js"],"sourcesContent":["import { usePrevious } from \"@tamagui/use-previous\";\nimport * as React from \"react\";\nimport { isIndeterminate } from \"./utils\";\nimport { jsx } from \"react/jsx-runtime\";\nconst BubbleInput = (props) => {\n const { checked, bubbles = true, control, isHidden, ...inputProps } = props;\n const ref = React.useRef(null);\n const prevChecked = usePrevious(checked);\n React.useEffect(() => {\n const input = ref.current;\n const inputProto = window.HTMLInputElement.prototype;\n const descriptor = Object.getOwnPropertyDescriptor(\n inputProto,\n \"checked\"\n );\n const setChecked = descriptor.set;\n if (prevChecked !== checked && setChecked) {\n const event = new Event(\"click\", { bubbles });\n input.indeterminate = isIndeterminate(checked);\n setChecked.call(input, isIndeterminate(checked) ? false : checked);\n input.dispatchEvent(event);\n }\n }, [prevChecked, checked, bubbles]);\n return /* @__PURE__ */ jsx(\n \"input\",\n {\n type: \"checkbox\",\n defaultChecked: isIndeterminate(checked) ? false : checked,\n ...inputProps,\n tabIndex: -1,\n ref,\n \"aria-hidden\": isHidden,\n style: {\n ...isHidden ? {\n // ...controlSize,\n position: \"absolute\",\n pointerEvents: \"none\",\n opacity: 0,\n margin: 0\n } : {\n appearance: \"auto\",\n accentColor: \"var(--color6)\"\n },\n ...props.style\n }\n }\n );\n};\nexport {\n BubbleInput\n};\n//# sourceMappingURL=BubbleInput.js.map\n"],"mappings":";;;;;;AAIA,MAAM,eAAe,UAAU;CAC7B,MAAM,EAAE,SAAS,UAAU,MAAM,SAAS,UAAU,GAAG,eAAe;CACtE,MAAM,MAAM,MAAM,OAAO,IAAI;CAC7B,MAAM,cAAc,YAAY,OAAO;CACvC,MAAM,gBAAgB;EACpB,MAAM,QAAQ,IAAI;EAClB,MAAM,aAAa,OAAO,iBAAiB;EAC3C,MAAM,aAAa,OAAO,yBACxB,YACA,SACF;EACA,MAAM,aAAa,WAAW;EAC9B,IAAI,gBAAgB,WAAW,YAAY;GACzC,MAAM,QAAQ,IAAI,MAAM,SAAS,EAAE,QAAQ,CAAC;GAC5C,MAAM,gBAAgB,gBAAgB,OAAO;GAC7C,WAAW,KAAK,OAAO,gBAAgB,OAAO,IAAI,QAAQ,OAAO;GACjE,MAAM,cAAc,KAAK;EAC3B;CACF,GAAG;EAAC;EAAa;EAAS;CAAO,CAAC;CAClC,OAAuB,oBACrB,SACA;EACE,MAAM;EACN,gBAAgB,gBAAgB,OAAO,IAAI,QAAQ;EACnD,GAAG;EACH,UAAU,CAAC;EACX;EACA,eAAe;EACf,OAAO;GACL,GAAG,WAAW;IAEZ,UAAU;IACV,eAAe;IACf,SAAS;IACT,QAAQ;GACV,IAAI;IACF,YAAY;IACZ,aAAa;GACf;GACA,GAAG,MAAM;EACX;CACF,CACF;AACF"}
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+
3
+
4
+ var __create = Object.create;
5
+ var __defProp = Object.defineProperty;
6
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
7
+ var __getOwnPropNames = Object.getOwnPropertyNames;
8
+ var __getProtoOf = Object.getPrototypeOf;
9
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
10
+ var __export = (target, all) => {
11
+ for (var name in all) __defProp(target, name, {
12
+ get: all[name],
13
+ enumerable: true
14
+ });
15
+ };
16
+ var __copyProps = (to, from, except, desc) => {
17
+ if (from && typeof from === "object" || typeof from === "function") {
18
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
19
+ get: () => from[key],
20
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
21
+ });
22
+ }
23
+ return to;
24
+ };
25
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
26
+ value: mod,
27
+ enumerable: true
28
+ }) : target, mod));
29
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
+ var BubbleInput_exports = {};
31
+ __export(BubbleInput_exports, { BubbleInput: () => BubbleInput });
32
+ module.exports = __toCommonJS(BubbleInput_exports);
33
+ var import_jsx_runtime = require("react/jsx-runtime");
34
+ var import_use_previous = require("@tamagui/use-previous");
35
+ var React = __toESM(require("react"), 1);
36
+ var import_utils = require("./utils.native.js");
37
+ var BubbleInput = function(props) {
38
+ var { checked, bubbles = true, control, isHidden, ...inputProps } = props;
39
+ var ref = React.useRef(null);
40
+ var prevChecked = (0, import_use_previous.usePrevious)(checked);
41
+ React.useEffect(function() {
42
+ var input = ref.current;
43
+ var inputProto = window.HTMLInputElement.prototype;
44
+ var descriptor = Object.getOwnPropertyDescriptor(inputProto, "checked");
45
+ var setChecked = descriptor.set;
46
+ if (prevChecked !== checked && setChecked) {
47
+ var event = new Event("click", { bubbles });
48
+ input.indeterminate = (0, import_utils.isIndeterminate)(checked);
49
+ setChecked.call(input, (0, import_utils.isIndeterminate)(checked) ? false : checked);
50
+ input.dispatchEvent(event);
51
+ }
52
+ }, [
53
+ prevChecked,
54
+ checked,
55
+ bubbles
56
+ ]);
57
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", {
58
+ type: "checkbox",
59
+ defaultChecked: (0, import_utils.isIndeterminate)(checked) ? false : checked,
60
+ ...inputProps,
61
+ tabIndex: -1,
62
+ ref,
63
+ "aria-hidden": isHidden,
64
+ style: {
65
+ ...isHidden ? {
66
+ position: "absolute",
67
+ pointerEvents: "none",
68
+ opacity: 0,
69
+ margin: 0
70
+ } : {
71
+ appearance: "auto",
72
+ accentColor: "var(--color6)"
73
+ },
74
+ ...props.style
75
+ }
76
+ });
77
+ };
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
 
3
+
3
4
  var __create = Object.create;
4
5
  var __defProp = Object.defineProperty;
5
6
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -7,85 +8,72 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
7
8
  var __getProtoOf = Object.getPrototypeOf;
8
9
  var __hasOwnProp = Object.prototype.hasOwnProperty;
9
10
  var __export = (target, all) => {
10
- for (var name in all) __defProp(target, name, {
11
- get: all[name],
12
- enumerable: true
13
- });
11
+ for (var name in all) __defProp(target, name, {
12
+ get: all[name],
13
+ enumerable: true
14
+ });
14
15
  };
15
16
  var __copyProps = (to, from, except, desc) => {
16
- if (from && typeof from === "object" || typeof from === "function") {
17
- for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
18
- get: () => from[key],
19
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
20
- });
21
- }
22
- return to;
17
+ if (from && typeof from === "object" || typeof from === "function") {
18
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
19
+ get: () => from[key],
20
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
21
+ });
22
+ }
23
+ return to;
23
24
  };
24
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
25
- // If the importer is in node compatibility mode or this is not an ESM
26
- // file that has been converted to a CommonJS file using a Babel-
27
- // compatible transform (i.e. "__esModule" has not been set), then set
28
- // "default" to the CommonJS "module.exports" for node compatibility.
29
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
30
- value: mod,
31
- enumerable: true
25
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
26
+ value: mod,
27
+ enumerable: true
32
28
  }) : target, mod));
33
- var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
34
- value: true
35
- }), mod);
29
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
36
30
  var BubbleInput_exports = {};
37
- __export(BubbleInput_exports, {
38
- BubbleInput: () => BubbleInput
39
- });
31
+ __export(BubbleInput_exports, { BubbleInput: () => BubbleInput });
40
32
  module.exports = __toCommonJS(BubbleInput_exports);
41
33
  var import_jsx_runtime = require("react/jsx-runtime");
42
34
  var import_use_previous = require("@tamagui/use-previous");
43
35
  var React = __toESM(require("react"), 1);
44
36
  var import_utils = require("./utils.native.js");
45
- var BubbleInput = function (props) {
46
- var {
47
- checked,
48
- bubbles = true,
49
- control,
50
- isHidden,
51
- ...inputProps
52
- } = props;
53
- var ref = React.useRef(null);
54
- var prevChecked = (0, import_use_previous.usePrevious)(checked);
55
- React.useEffect(function () {
56
- var input = ref.current;
57
- var inputProto = window.HTMLInputElement.prototype;
58
- var descriptor = Object.getOwnPropertyDescriptor(inputProto, "checked");
59
- var setChecked = descriptor.set;
60
- if (prevChecked !== checked && setChecked) {
61
- var event = new Event("click", {
62
- bubbles
63
- });
64
- input.indeterminate = (0, import_utils.isIndeterminate)(checked);
65
- setChecked.call(input, (0, import_utils.isIndeterminate)(checked) ? false : checked);
66
- input.dispatchEvent(event);
67
- }
68
- }, [prevChecked, checked, bubbles]);
69
- return /* @__PURE__ */(0, import_jsx_runtime.jsx)("input", {
70
- type: "checkbox",
71
- defaultChecked: (0, import_utils.isIndeterminate)(checked) ? false : checked,
72
- ...inputProps,
73
- tabIndex: -1,
74
- ref,
75
- "aria-hidden": isHidden,
76
- style: {
77
- ...(isHidden ? {
78
- // ...controlSize,
79
- position: "absolute",
80
- pointerEvents: "none",
81
- opacity: 0,
82
- margin: 0
83
- } : {
84
- appearance: "auto",
85
- accentColor: "var(--color6)"
86
- }),
87
- ...props.style
88
- }
89
- });
37
+ var BubbleInput = function(props) {
38
+ var { checked, bubbles = true, control, isHidden, ...inputProps } = props;
39
+ var ref = React.useRef(null);
40
+ var prevChecked = (0, import_use_previous.usePrevious)(checked);
41
+ React.useEffect(function() {
42
+ var input = ref.current;
43
+ var inputProto = window.HTMLInputElement.prototype;
44
+ var descriptor = Object.getOwnPropertyDescriptor(inputProto, "checked");
45
+ var setChecked = descriptor.set;
46
+ if (prevChecked !== checked && setChecked) {
47
+ var event = new Event("click", { bubbles });
48
+ input.indeterminate = (0, import_utils.isIndeterminate)(checked);
49
+ setChecked.call(input, (0, import_utils.isIndeterminate)(checked) ? false : checked);
50
+ input.dispatchEvent(event);
51
+ }
52
+ }, [
53
+ prevChecked,
54
+ checked,
55
+ bubbles
56
+ ]);
57
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", {
58
+ type: "checkbox",
59
+ defaultChecked: (0, import_utils.isIndeterminate)(checked) ? false : checked,
60
+ ...inputProps,
61
+ tabIndex: -1,
62
+ ref,
63
+ "aria-hidden": isHidden,
64
+ style: {
65
+ ...isHidden ? {
66
+ position: "absolute",
67
+ pointerEvents: "none",
68
+ opacity: 0,
69
+ margin: 0
70
+ } : {
71
+ appearance: "auto",
72
+ accentColor: "var(--color6)"
73
+ },
74
+ ...props.style
75
+ }
76
+ });
90
77
  };
78
+
91
79
  //# sourceMappingURL=BubbleInput.native.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["__create","Object","create","__defProp","defineProperty","__getOwnPropDesc","getOwnPropertyDescriptor","__getOwnPropNames","getOwnPropertyNames","__getProtoOf","getPrototypeOf","__hasOwnProp","prototype","hasOwnProperty","__export","target","all","name","get","enumerable","__copyProps","to","from","except","desc","key","call","__toESM","mod","isNodeMode","__esModule","value","__toCommonJS","BubbleInput_exports","BubbleInput","module","exports","import_jsx_runtime","require","import_use_previous","React","import_utils","props","checked","bubbles","control","isHidden","inputProps","ref","useRef","prevChecked","usePrevious","useEffect","input","current","inputProto","window","HTMLInputElement","descriptor","setChecked","set","event","Event"],"sources":["../../src/BubbleInput.tsx"],"sourcesContent":[null],"mappings":"AAAA,YAAS;;AACT,IAAAA,QAAY,GAAAC,MAAA,CAAAC,MAAW;AAGvB,IAAAC,SAAS,GAAAF,MAAA,CAAAG,cAAuB;AAkC5B,IAAAC,gBAAA,GAAAJ,MAAA,CAAAK,wBAAA;AAxBG,IAAAC,iBAAqB,GAAAN,MAAA,CAA4BO,mBAAA;AACtD,IAAAC,YAAQ,GAASR,MAAA,CAAAS,cAAgB;AACjC,IAAAC,YAAY,GAAAV,MAAM,CAAAW,SAA6B,CAAAC,cAAA;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,YAAA,CAAAC,mBAAA;AAAA,IAAAI,kBAED,GAAAC,OAAA;AAAA,IAAAC,mBAAA,GAAAD,OAAA;AAAA,IAAAE,KAAA,GAEEb,OAAA,CAAUW,OAAA;AAAA,IAAAG,YACV,GAAAH,OAAe;AAAA,IAAAJ,WACf,YAAAA,CAASQ,KAAA;EAAA;IAAAC,OACT;IAAAC,OAAQ;IAAAC,OAAA;IAAAC,QAAA;IAAA,GAAAC;EAAA,IAAAL,KAAA;EAAA,IAAAM,GACV,GACAR,KAAA,CAAAS,MAAA;EAAA,IAAAC,WACE,KAAY,EAAAX,mBAAA,CAAAY,WAAA,EAAAR,OAAA;EAAAH,KAAA,CAAAY,SACZ,aAAa;IAAA,IACfC,KAAA,GAAAL,GAAA,CAAAM,OAAA;IAAA,IAEJC,UAAS,GAAAC,MAAA,CAAAC,gBAAA,CAAA7C,SAAA;IAAA,IACX8C,UAAA,GAAAzD,MAAA,CAAAK,wBAAA,CAAAiD,UAAA;IAAA,IAAAI,UAAA,GAAAD,UAAA,CAAAE,GAAA;IACF,IAAAV,WAAA,KAAAP,OAAA,IAAAgB,UAAA;MAEJ,IAAAE,KAAA,OAAAC,KAAA","ignoreList":[]}
1
+ {"version":3,"file":"BubbleInput.native.js","names":[],"sources":["jsx/BubbleInput.native.js"],"sourcesContent":["\"use strict\";\nvar __create = Object.create;\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __getProtoOf = Object.getPrototypeOf;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(\n // If the importer is in node compatibility mode or this is not an ESM\n // file that has been converted to a CommonJS file using a Babel-\n // compatible transform (i.e. \"__esModule\" has not been set), then set\n // \"default\" to the CommonJS \"module.exports\" for node compatibility.\n isNodeMode || !mod || !mod.__esModule ? __defProp(target, \"default\", { value: mod, enumerable: true }) : target,\n mod\n));\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\nvar BubbleInput_exports = {};\n__export(BubbleInput_exports, {\n BubbleInput: () => BubbleInput\n});\nmodule.exports = __toCommonJS(BubbleInput_exports);\nvar import_jsx_runtime = require(\"react/jsx-runtime\");\nvar import_use_previous = require(\"@tamagui/use-previous\");\nvar React = __toESM(require(\"react\"), 1);\nvar import_utils = require(\"./utils\");\nvar BubbleInput = function(props) {\n var { checked, bubbles = true, control, isHidden, ...inputProps } = props;\n var ref = React.useRef(null);\n var prevChecked = (0, import_use_previous.usePrevious)(checked);\n React.useEffect(function() {\n var input = ref.current;\n var inputProto = window.HTMLInputElement.prototype;\n var descriptor = Object.getOwnPropertyDescriptor(inputProto, \"checked\");\n var setChecked = descriptor.set;\n if (prevChecked !== checked && setChecked) {\n var event = new Event(\"click\", {\n bubbles\n });\n input.indeterminate = (0, import_utils.isIndeterminate)(checked);\n setChecked.call(input, (0, import_utils.isIndeterminate)(checked) ? false : checked);\n input.dispatchEvent(event);\n }\n }, [\n prevChecked,\n checked,\n bubbles\n ]);\n return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(\"input\", {\n type: \"checkbox\",\n defaultChecked: (0, import_utils.isIndeterminate)(checked) ? false : checked,\n ...inputProps,\n tabIndex: -1,\n ref,\n \"aria-hidden\": isHidden,\n style: {\n ...isHidden ? {\n // ...controlSize,\n position: \"absolute\",\n pointerEvents: \"none\",\n opacity: 0,\n margin: 0\n } : {\n appearance: \"auto\",\n accentColor: \"var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I,eAAe,QAAQ,mBAAS;AACpC,IAAI,cAAc,SAAS,OAAO;CAChC,IAAI,EAAE,SAAS,UAAU,MAAM,SAAS,UAAU,GAAG,eAAe;CACpE,IAAI,MAAM,MAAM,OAAO,IAAI;CAC3B,IAAI,eAAe,GAAG,oBAAoB,aAAa,OAAO;CAC9D,MAAM,UAAU,WAAW;EACzB,IAAI,QAAQ,IAAI;EAChB,IAAI,aAAa,OAAO,iBAAiB;EACzC,IAAI,aAAa,OAAO,yBAAyB,YAAY,SAAS;EACtE,IAAI,aAAa,WAAW;EAC5B,IAAI,gBAAgB,WAAW,YAAY;GACzC,IAAI,QAAQ,IAAI,MAAM,SAAS,EAC7B,QACF,CAAC;GACD,MAAM,iBAAiB,GAAG,aAAa,iBAAiB,OAAO;GAC/D,WAAW,KAAK,QAAQ,GAAG,aAAa,iBAAiB,OAAO,IAAI,QAAQ,OAAO;GACnF,MAAM,cAAc,KAAK;EAC3B;CACF,GAAG;EACD;EACA;EACA;CACF,CAAC;CACD,OAAuB,iBAAC,GAAG,mBAAmB,KAAK,SAAS;EAC1D,MAAM;EACN,iBAAiB,GAAG,aAAa,iBAAiB,OAAO,IAAI,QAAQ;EACrE,GAAG;EACH,UAAU,CAAC;EACX;EACA,eAAe;EACf,OAAO;GACL,GAAG,WAAW;IAEZ,UAAU;IACV,eAAe;IACf,SAAS;IACT,QAAQ;GACV,IAAI;IACF,YAAY;IACZ,aAAa;GACf;GACA,GAAG,MAAM;EACX;CACF,CAAC;AACH"}
package/dist/jsx/index.js CHANGED
@@ -1,3 +1,3 @@
1
- export * from "./useCheckbox.mjs";
2
- export * from "./utils.mjs";
3
- //# sourceMappingURL=index.js.map
1
+ export * from "./useCheckbox.mjs"
2
+
3
+ export * from "./utils.mjs"
@@ -1,3 +1,3 @@
1
- export * from "./useCheckbox.mjs";
2
- export * from "./utils.mjs";
3
- //# sourceMappingURL=index.mjs.map
1
+ export * from "./useCheckbox.mjs"
2
+
3
+ export * from "./utils.mjs"
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+
3
+
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from === "object" || typeof from === "function") {
10
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
11
+ get: () => from[key],
12
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
13
+ });
14
+ }
15
+ return to;
16
+ };
17
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var index_exports = {};
20
+ module.exports = __toCommonJS(index_exports);
21
+ __reExport(index_exports, require("./useCheckbox.native.js"), module.exports);
22
+ __reExport(index_exports, require("./utils.native.js"), module.exports);
@@ -1,24 +1,24 @@
1
1
  "use strict";
2
2
 
3
+
3
4
  var __defProp = Object.defineProperty;
4
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
8
  var __copyProps = (to, from, except, desc) => {
8
- if (from && typeof from === "object" || typeof from === "function") {
9
- for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
10
- get: () => from[key],
11
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
12
- });
13
- }
14
- return to;
9
+ if (from && typeof from === "object" || typeof from === "function") {
10
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
11
+ get: () => from[key],
12
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
13
+ });
14
+ }
15
+ return to;
15
16
  };
16
17
  var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
17
- var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
18
- value: true
19
- }), mod);
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
19
  var index_exports = {};
21
20
  module.exports = __toCommonJS(index_exports);
22
21
  __reExport(index_exports, require("./useCheckbox.native.js"), module.exports);
23
22
  __reExport(index_exports, require("./utils.native.js"), module.exports);
23
+
24
24
  //# sourceMappingURL=index.native.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["__defProp","Object","defineProperty"],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA;;AACA,IAAAA,SAAA,GAAcC,MAAA,CAAAC,cAAA","ignoreList":[]}
1
+ {"version":3,"file":"index.native.js","names":[],"sources":["jsx/index.native.js"],"sourcesContent":["\"use strict\";\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, \"default\"), secondTarget && __copyProps(secondTarget, mod, \"default\"));\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\nvar index_exports = {};\nmodule.exports = __toCommonJS(index_exports);\n__reExport(index_exports, require(\"./useCheckbox\"), module.exports);\n__reExport(index_exports, require(\"./utils\"), module.exports);\n//# sourceMappingURL=index.js.map\n"],"mappings":";;;;AACA,IAAI,YAAY,OAAO;AACvB,IAAI,mBAAmB,OAAO;AAC9B,IAAI,oBAAoB,OAAO;AAC/B,IAAI,eAAe,OAAO,UAAU;AACpC,IAAI,eAAe,IAAI,MAAM,QAAQ,SAAS;CAC5C,IAAI,QAAQ,OAAO,SAAS,YAAY,OAAO,SAAS,YAAY;EAClE,KAAK,IAAI,OAAO,kBAAkB,IAAI,GACpC,IAAI,CAAC,aAAa,KAAK,IAAI,GAAG,KAAK,QAAQ,QACzC,UAAU,IAAI,KAAK;GAAE,WAAW,KAAK;GAAM,YAAY,EAAE,OAAO,iBAAiB,MAAM,GAAG,MAAM,KAAK;EAAW,CAAC;CACvH;CACA,OAAO;AACT;AACA,IAAI,cAAc,QAAQ,KAAK,kBAAkB,YAAY,QAAQ,KAAK,SAAS,GAAG,gBAAgB,YAAY,cAAc,KAAK,SAAS;AAC9I,IAAI,gBAAgB,QAAQ,YAAY,UAAU,CAAC,GAAG,cAAc,EAAE,OAAO,KAAK,CAAC,GAAG,GAAG;AACzF,IAAI,gBAAgB,CAAC;AACrB,OAAO,UAAU,aAAa,aAAa;AAC3C,WAAW,eAAe,QAAQ,yBAAe,GAAG,OAAO,OAAO;AAClE,WAAW,eAAe,QAAQ,mBAAS,GAAG,OAAO,OAAO"}
@@ -6,61 +6,55 @@ import React, { useMemo } from "react";
6
6
  import { BubbleInput } from "./BubbleInput.mjs";
7
7
  import { getState, isIndeterminate } from "./utils.mjs";
8
8
  import { jsx } from "react/jsx-runtime";
9
+
9
10
  function useCheckbox(props, [checked, setChecked], ref) {
10
- const {
11
- labelledBy: ariaLabelledby,
12
- name,
13
- required,
14
- disabled,
15
- value = "on",
16
- onCheckedChange,
17
- ...checkboxProps
18
- } = props;
19
- const [button, setButton] = React.useState(null);
20
- const composedRefs = useComposedRefs(ref, setButton);
21
- const hasConsumerStoppedPropagationRef = React.useRef(false);
22
- const isFormControl = isWeb ? button ? Boolean(button.closest("form")) : true : false;
23
- const labelId = useLabelContext(button);
24
- const labelledBy = ariaLabelledby || labelId;
25
- const parentKeyDown = props.onKeyDown;
26
- const handleKeyDown = useMemo(() => composeEventHandlers(parentKeyDown, event => {
27
- if (event.key === "Enter") event.preventDefault();
28
- }), [parentKeyDown]);
29
- const handlePress = useMemo(() => composeEventHandlers(props.onPress, event => {
30
- setChecked(prevChecked => isIndeterminate(prevChecked) ? true : !prevChecked);
31
- if (isFormControl && "isPropagationStopped" in event) {
32
- hasConsumerStoppedPropagationRef.current = event.isPropagationStopped();
33
- if (!hasConsumerStoppedPropagationRef.current) event.stopPropagation();
34
- }
35
- }), [isFormControl]);
36
- return {
37
- bubbleInput: isWeb && isFormControl ? /* @__PURE__ */jsx(BubbleInput, {
38
- isHidden: true,
39
- control: button,
40
- bubbles: !hasConsumerStoppedPropagationRef.current,
41
- name,
42
- value,
43
- checked,
44
- required,
45
- disabled
46
- }) : null,
47
- checkboxRef: composedRefs,
48
- checkboxProps: {
49
- role: "checkbox",
50
- "aria-labelledby": labelledBy,
51
- "aria-checked": isIndeterminate(checked) ? "mixed" : checked,
52
- ...checkboxProps,
53
- ...(isWeb && {
54
- type: "button",
55
- value,
56
- "data-state": getState(checked),
57
- "data-disabled": disabled ? "" : void 0,
58
- disabled,
59
- onKeyDown: disabled ? void 0 : handleKeyDown
60
- }),
61
- onPress: disabled ? void 0 : handlePress
62
- }
63
- };
11
+ const { labelledBy: ariaLabelledby, name, required, disabled, value = "on", onCheckedChange, ...checkboxProps } = props;
12
+ const [button, setButton] = React.useState(null);
13
+ const composedRefs = useComposedRefs(ref, setButton);
14
+ const hasConsumerStoppedPropagationRef = React.useRef(false);
15
+ const isFormControl = isWeb ? button ? Boolean(button.closest("form")) : true : false;
16
+ const labelId = useLabelContext(button);
17
+ const labelledBy = ariaLabelledby || labelId;
18
+ const parentKeyDown = props.onKeyDown;
19
+ const handleKeyDown = useMemo(() => composeEventHandlers(parentKeyDown, (event) => {
20
+ if (event.key === "Enter") event.preventDefault();
21
+ }), [parentKeyDown]);
22
+ const handlePress = useMemo(() => composeEventHandlers(props.onPress, (event) => {
23
+ setChecked((prevChecked) => isIndeterminate(prevChecked) ? true : !prevChecked);
24
+ if (isFormControl && "isPropagationStopped" in event) {
25
+ hasConsumerStoppedPropagationRef.current = event.isPropagationStopped();
26
+ if (!hasConsumerStoppedPropagationRef.current) event.stopPropagation();
27
+ }
28
+ }), [isFormControl]);
29
+ return {
30
+ bubbleInput: isWeb && isFormControl ? /* @__PURE__ */ jsx(BubbleInput, {
31
+ isHidden: true,
32
+ control: button,
33
+ bubbles: !hasConsumerStoppedPropagationRef.current,
34
+ name,
35
+ value,
36
+ checked,
37
+ required,
38
+ disabled
39
+ }) : null,
40
+ checkboxRef: composedRefs,
41
+ checkboxProps: {
42
+ role: "checkbox",
43
+ "aria-labelledby": labelledBy,
44
+ "aria-checked": isIndeterminate(checked) ? "mixed" : checked,
45
+ ...checkboxProps,
46
+ ...isWeb && {
47
+ type: "button",
48
+ value,
49
+ "data-state": getState(checked),
50
+ "data-disabled": disabled ? "" : void 0,
51
+ disabled,
52
+ onKeyDown: disabled ? void 0 : handleKeyDown
53
+ },
54
+ onPress: disabled ? void 0 : handlePress
55
+ }
56
+ };
64
57
  }
58
+
65
59
  export { useCheckbox };
66
60
  //# sourceMappingURL=useCheckbox.mjs.map
@@ -1 +1 @@
1
- {"version":3,"names":["useComposedRefs","isWeb","composeEventHandlers","useLabelContext","React","useMemo","BubbleInput","getState","isIndeterminate","jsx","useCheckbox","props","checked","setChecked","ref","labelledBy","ariaLabelledby","name","required","disabled","value","onCheckedChange","checkboxProps","button","setButton","useState","composedRefs","hasConsumerStoppedPropagationRef","useRef","isFormControl","Boolean","closest","labelId","parentKeyDown","onKeyDown","handleKeyDown","event","key","preventDefault","handlePress","onPress","prevChecked","current","isPropagationStopped","stopPropagation","bubbleInput","isHidden","control","bubbles","checkboxRef","role","type"],"sources":["../../src/useCheckbox.tsx"],"sourcesContent":[null],"mappings":"AAAA,SAASA,eAAA,QAAuB;AAChC,SAASC,KAAA,QAAa;AAEtB,SAASC,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;IAChF,IAAIZ,aAAA,IAAiB,0BAA0BO,KAAA,EAAO;MACpDT,gCAAA,CAAiCe,OAAA,GAAUN,KAAA,CAAMO,oBAAA,CAAqB;MAItE,IAAI,CAAChB,gCAAA,CAAiCe,OAAA,EAASN,KAAA,CAAMQ,eAAA,CAAgB;IACvE;EACF,CAAC,GACH,CAACf,aAAa,CAChB;EAEA,OAAO;IACLgB,WAAA,EACE5C,KAAA,IAAS4B,aAAA,GACP,eAAApB,GAAA,CAACH,WAAA;MACCwC,QAAA,EAAQ;MACRC,OAAA,EAASxB,MAAA;MACTyB,OAAA,EAAS,CAACrB,gCAAA,CAAiCe,OAAA;MAC3CzB,IAAA;MACAG,KAAA;MACAR,OAAA;MACAM,QAAA;MACAC;IAAA,CACF,IACE;IACN8B,WAAA,EAAavB,YAAA;IACbJ,aAAA,EAAe;MACb4B,IAAA,EAAM;MACN,mBAAmBnC,UAAA;MACnB,gBAAgBP,eAAA,CAAgBI,OAAO,IAAI,UAAUA,OAAA;MACrD,GAAGU,aAAA;MACH,IAAIrB,KAAA,IAAS;QACXkD,IAAA,EAAM;QACN/B,KAAA;QACA,cAAcb,QAAA,CAASK,OAAO;QAC9B,iBAAiBO,QAAA,GAAW,KAAK;QACjCA,QAAA;QACAe,SAAA,EAAWf,QAAA,GAAW,SAAYgB;MACpC;MACAK,OAAA,EAASrB,QAAA,GAAW,SAAYoB;IAClC;EACF;AACF","ignoreList":[]}
1
+ {"version":3,"file":"useCheckbox.js","names":[],"sources":["jsx/useCheckbox.js"],"sourcesContent":["import { useComposedRefs } from \"@tamagui/compose-refs\";\nimport { isWeb } from \"@tamagui/constants\";\nimport { composeEventHandlers } from \"@tamagui/helpers\";\nimport { useLabelContext } from \"@tamagui/label\";\nimport React, { useMemo } from \"react\";\nimport { BubbleInput } from \"./BubbleInput\";\nimport { getState, isIndeterminate } from \"./utils\";\nimport { jsx } from \"react/jsx-runtime\";\nfunction useCheckbox(props, [checked, setChecked], ref) {\n const {\n labelledBy: ariaLabelledby,\n name,\n required,\n disabled,\n value = \"on\",\n onCheckedChange,\n ...checkboxProps\n } = props;\n const [button, setButton] = React.useState(null);\n const composedRefs = useComposedRefs(ref, setButton);\n const hasConsumerStoppedPropagationRef = React.useRef(false);\n const isFormControl = isWeb ? button ? Boolean(button.closest(\"form\")) : true : false;\n const labelId = useLabelContext(button);\n const labelledBy = ariaLabelledby || labelId;\n const parentKeyDown = props.onKeyDown;\n const handleKeyDown = useMemo(\n () => composeEventHandlers(parentKeyDown, (event) => {\n if (event.key === \"Enter\") event.preventDefault();\n }),\n [parentKeyDown]\n );\n const handlePress = useMemo(\n () => composeEventHandlers(props.onPress, (event) => {\n setChecked((prevChecked) => isIndeterminate(prevChecked) ? true : !prevChecked);\n if (isFormControl && \"isPropagationStopped\" in event) {\n hasConsumerStoppedPropagationRef.current = event.isPropagationStopped();\n if (!hasConsumerStoppedPropagationRef.current) event.stopPropagation();\n }\n }),\n [isFormControl]\n );\n return {\n bubbleInput: isWeb && isFormControl ? /* @__PURE__ */ jsx(\n BubbleInput,\n {\n isHidden: true,\n control: button,\n bubbles: !hasConsumerStoppedPropagationRef.current,\n name,\n value,\n checked,\n required,\n disabled\n }\n ) : null,\n checkboxRef: composedRefs,\n checkboxProps: {\n role: \"checkbox\",\n \"aria-labelledby\": labelledBy,\n \"aria-checked\": isIndeterminate(checked) ? \"mixed\" : checked,\n ...checkboxProps,\n ...isWeb && {\n type: \"button\",\n value,\n \"data-state\": getState(checked),\n \"data-disabled\": disabled ? \"\" : void 0,\n disabled,\n onKeyDown: disabled ? void 0 : handleKeyDown\n },\n onPress: disabled ? void 0 : handlePress\n }\n };\n}\nexport {\n useCheckbox\n};\n//# sourceMappingURL=useCheckbox.js.map\n"],"mappings":";;;;;;;;;;AAQA,SAAS,YAAY,OAAO,CAAC,SAAS,aAAa,KAAK;CACtD,MAAM,EACJ,YAAY,gBACZ,MACA,UACA,UACA,QAAQ,MACR,iBACA,GAAG,kBACD;CACJ,MAAM,CAAC,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