@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.
- package/dist/cjs/BubbleInput.cjs +58 -71
- package/dist/cjs/BubbleInput.native.cjs +77 -0
- package/dist/cjs/BubbleInput.native.js +58 -70
- package/dist/cjs/BubbleInput.native.js.map +1 -1
- package/dist/cjs/index.cjs +10 -11
- package/dist/cjs/index.native.cjs +22 -0
- package/dist/cjs/index.native.js +10 -10
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/cjs/useCheckbox.cjs +64 -80
- package/dist/cjs/useCheckbox.native.cjs +95 -0
- package/dist/cjs/useCheckbox.native.js +71 -86
- package/dist/cjs/useCheckbox.native.js.map +1 -1
- package/dist/cjs/utils.cjs +18 -19
- package/dist/cjs/utils.native.cjs +35 -0
- package/dist/cjs/utils.native.js +18 -18
- package/dist/cjs/utils.native.js.map +1 -1
- package/dist/esm/BubbleInput.mjs +42 -45
- package/dist/esm/BubbleInput.mjs.map +1 -1
- package/dist/esm/BubbleInput.native.js +43 -46
- package/dist/esm/BubbleInput.native.js.map +1 -1
- package/dist/esm/index.js +3 -3
- package/dist/esm/index.mjs +3 -3
- package/dist/esm/index.native.js +3 -3
- package/dist/esm/useCheckbox.mjs +48 -54
- package/dist/esm/useCheckbox.mjs.map +1 -1
- package/dist/esm/useCheckbox.native.js +56 -62
- package/dist/esm/useCheckbox.native.js.map +1 -1
- package/dist/esm/utils.mjs +3 -2
- package/dist/esm/utils.mjs.map +1 -1
- package/dist/esm/utils.native.js +3 -2
- package/dist/esm/utils.native.js.map +1 -1
- package/dist/jsx/BubbleInput.mjs +42 -45
- package/dist/jsx/BubbleInput.mjs.map +1 -1
- package/dist/jsx/BubbleInput.native.cjs +77 -0
- package/dist/jsx/BubbleInput.native.js +58 -70
- package/dist/jsx/BubbleInput.native.js.map +1 -1
- package/dist/jsx/index.js +3 -3
- package/dist/jsx/index.mjs +3 -3
- package/dist/jsx/index.native.cjs +22 -0
- package/dist/jsx/index.native.js +10 -10
- package/dist/jsx/index.native.js.map +1 -1
- package/dist/jsx/useCheckbox.mjs +48 -54
- package/dist/jsx/useCheckbox.mjs.map +1 -1
- package/dist/jsx/useCheckbox.native.cjs +95 -0
- package/dist/jsx/useCheckbox.native.js +71 -86
- package/dist/jsx/useCheckbox.native.js.map +1 -1
- package/dist/jsx/utils.mjs +3 -2
- package/dist/jsx/utils.mjs.map +1 -1
- package/dist/jsx/utils.native.cjs +35 -0
- package/dist/jsx/utils.native.js +18 -18
- package/dist/jsx/utils.native.js.map +1 -1
- package/package.json +12 -12
- package/types/BubbleInput.d.ts +1 -1
- package/types/BubbleInput.d.ts.map +1 -1
- package/types/useCheckbox.d.ts +4 -4
- package/types/utils.d.ts +1 -1
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/index.mjs.map +0 -1
- package/dist/esm/index.native.js.map +0 -1
- package/dist/jsx/index.js.map +0 -1
- package/dist/jsx/index.mjs.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"utils.native.js","names":[],"sources":["cjs/utils.native.js"],"sourcesContent":["\"use strict\";\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\nvar utils_exports = {};\n__export(utils_exports, {\n getState: () => getState,\n isIndeterminate: () => isIndeterminate\n});\nmodule.exports = __toCommonJS(utils_exports);\nfunction isIndeterminate(checked) {\n return checked === \"indeterminate\";\n}\nfunction getState(checked) {\n return isIndeterminate(checked) ? \"indeterminate\" : checked ? \"checked\" : \"unchecked\";\n}\n//# sourceMappingURL=utils.js.map\n"],"mappings":";;;;AACA,IAAI,YAAY,OAAO;AACvB,IAAI,mBAAmB,OAAO;AAC9B,IAAI,oBAAoB,OAAO;AAC/B,IAAI,eAAe,OAAO,UAAU;AACpC,IAAI,YAAY,QAAQ,QAAQ;CAC9B,KAAK,IAAI,QAAQ,KACf,UAAU,QAAQ,MAAM;EAAE,KAAK,IAAI;EAAO,YAAY;CAAK,CAAC;AAChE;AACA,IAAI,eAAe,IAAI,MAAM,QAAQ,SAAS;CAC5C,IAAI,QAAQ,OAAO,SAAS,YAAY,OAAO,SAAS,YAAY;EAClE,KAAK,IAAI,OAAO,kBAAkB,IAAI,GACpC,IAAI,CAAC,aAAa,KAAK,IAAI,GAAG,KAAK,QAAQ,QACzC,UAAU,IAAI,KAAK;GAAE,WAAW,KAAK;GAAM,YAAY,EAAE,OAAO,iBAAiB,MAAM,GAAG,MAAM,KAAK;EAAW,CAAC;CACvH;CACA,OAAO;AACT;AACA,IAAI,gBAAgB,QAAQ,YAAY,UAAU,CAAC,GAAG,cAAc,EAAE,OAAO,KAAK,CAAC,GAAG,GAAG;AACzF,IAAI,gBAAgB,CAAC;AACrB,SAAS,eAAe;CACtB,gBAAgB;CAChB,uBAAuB;AACzB,CAAC;AACD,OAAO,UAAU,aAAa,aAAa;AAC3C,SAAS,gBAAgB,SAAS;CAChC,OAAO,YAAY;AACrB;AACA,SAAS,SAAS,SAAS;CACzB,OAAO,gBAAgB,OAAO,IAAI,kBAAkB,UAAU,YAAY;AAC5E"}
|
package/dist/esm/BubbleInput.mjs
CHANGED
|
@@ -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
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
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":["
|
|
1
|
+
{"version":3,"file":"BubbleInput.js","names":[],"sources":["esm/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"}
|
|
@@ -1,52 +1,49 @@
|
|
|
1
|
-
import { jsx
|
|
1
|
+
import { 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.native.js";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}),
|
|
47
|
-
...props.style
|
|
48
|
-
}
|
|
49
|
-
});
|
|
5
|
+
|
|
6
|
+
var BubbleInput = function(props) {
|
|
7
|
+
var { checked, bubbles = true, control, isHidden, ...inputProps } = props;
|
|
8
|
+
var ref = React.useRef(null);
|
|
9
|
+
var prevChecked = usePrevious(checked);
|
|
10
|
+
React.useEffect(function() {
|
|
11
|
+
var input = ref.current;
|
|
12
|
+
var inputProto = window.HTMLInputElement.prototype;
|
|
13
|
+
var descriptor = Object.getOwnPropertyDescriptor(inputProto, "checked");
|
|
14
|
+
var setChecked = descriptor.set;
|
|
15
|
+
if (prevChecked !== checked && setChecked) {
|
|
16
|
+
var 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.native.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"file":"BubbleInput.native.js","names":[],"sources":["esm/BubbleInput.native.js"],"sourcesContent":["import { jsx as _jsx } from \"react/jsx-runtime\";\nimport { usePrevious } from \"@tamagui/use-previous\";\nimport * as React from \"react\";\nimport { isIndeterminate } from \"./utils\";\nvar BubbleInput = function(props) {\n var { checked, bubbles = true, control, isHidden, ...inputProps } = props;\n var ref = React.useRef(null);\n var prevChecked = 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 = isIndeterminate(checked);\n setChecked.call(input, isIndeterminate(checked) ? false : checked);\n input.dispatchEvent(event);\n }\n }, [\n prevChecked,\n checked,\n bubbles\n ]);\n return /* @__PURE__ */ _jsx(\"input\", {\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};\nexport {\n BubbleInput\n};\n//# sourceMappingURL=BubbleInput.js.map\n"],"mappings":";;;;;;AAIA,IAAI,cAAc,SAAS,OAAO;CAChC,IAAI,EAAE,SAAS,UAAU,MAAM,SAAS,UAAU,GAAG,eAAe;CACpE,IAAI,MAAM,MAAM,OAAO,IAAI;CAC3B,IAAI,cAAc,YAAY,OAAO;CACrC,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,gBAAgB,gBAAgB,OAAO;GAC7C,WAAW,KAAK,OAAO,gBAAgB,OAAO,IAAI,QAAQ,OAAO;GACjE,MAAM,cAAc,KAAK;EAC3B;CACF,GAAG;EACD;EACA;EACA;CACF,CAAC;CACD,OAAuB,oBAAK,SAAS;EACnC,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,CAAC;AACH"}
|
package/dist/esm/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from "./useCheckbox.mjs"
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
export * from "./useCheckbox.mjs"
|
|
2
|
+
|
|
3
|
+
export * from "./utils.mjs"
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from "./useCheckbox.mjs"
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
export * from "./useCheckbox.mjs"
|
|
2
|
+
|
|
3
|
+
export * from "./utils.mjs"
|
package/dist/esm/index.native.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from "./useCheckbox.native.js"
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
export * from "./useCheckbox.native.js"
|
|
2
|
+
|
|
3
|
+
export * from "./utils.native.js"
|
package/dist/esm/useCheckbox.mjs
CHANGED
|
@@ -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
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
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":["
|
|
1
|
+
{"version":3,"file":"useCheckbox.js","names":[],"sources":["esm/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,QAAQ,aAAa,MAAM,SAAS,IAAI;CAC/C,MAAM,eAAe,gBAAgB,KAAK,SAAS;CACnD,MAAM,mCAAmC,MAAM,OAAO,KAAK;CAC3D,MAAM,gBAAgB,QAAQ,SAAS,QAAQ,OAAO,QAAQ,MAAM,CAAC,IAAI,OAAO;CAChF,MAAM,UAAU,gBAAgB,MAAM;CACtC,MAAM,aAAa,kBAAkB;CACrC,MAAM,gBAAgB,MAAM;CAC5B,MAAM,gBAAgB,cACd,qBAAqB,gBAAgB,UAAU;EACnD,IAAI,MAAM,QAAQ,SAAS,MAAM,eAAe;CAClD,CAAC,GACD,CAAC,aAAa,CAChB;CACA,MAAM,cAAc,cACZ,qBAAqB,MAAM,UAAU,UAAU;EACnD,YAAY,gBAAgB,gBAAgB,WAAW,IAAI,OAAO,CAAC,WAAW;EAC9E,IAAI,iBAAiB,0BAA0B,OAAO;GACpD,iCAAiC,UAAU,MAAM,qBAAqB;GACtE,IAAI,CAAC,iCAAiC,SAAS,MAAM,gBAAgB;EACvE;CACF,CAAC,GACD,CAAC,aAAa,CAChB;CACA,OAAO;EACL,aAAa,SAAS,gBAAgC,oBACpD,aACA;GACE,UAAU;GACV,SAAS;GACT,SAAS,CAAC,iCAAiC;GAC3C;GACA;GACA;GACA;GACA;EACF,CACF,IAAI;EACJ,aAAa;EACb,eAAe;GACb,MAAM;GACN,mBAAmB;GACnB,gBAAgB,gBAAgB,OAAO,IAAI,UAAU;GACrD,GAAG;GACH,GAAG,SAAS;IACV,MAAM;IACN;IACA,cAAc,SAAS,OAAO;IAC9B,iBAAiB,WAAW,KAAK,KAAK;IACtC;IACA,WAAW,WAAW,KAAK,IAAI;GACjC;GACA,SAAS,WAAW,KAAK,IAAI;EAC/B;CACF;AACF"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsx
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useComposedRefs } from "@tamagui/compose-refs";
|
|
3
3
|
import { isWeb } from "@tamagui/constants";
|
|
4
4
|
import { composeEventHandlers } from "@tamagui/helpers";
|
|
@@ -6,68 +6,62 @@ import { useLabelContext } from "@tamagui/label";
|
|
|
6
6
|
import React, { useMemo } from "react";
|
|
7
7
|
import { BubbleInput } from "./BubbleInput.native.js";
|
|
8
8
|
import { getState, isIndeterminate } from "./utils.native.js";
|
|
9
|
+
|
|
9
10
|
function useCheckbox(props, param, ref) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
"data-state": getState(checked),
|
|
64
|
-
"data-disabled": disabled ? "" : void 0,
|
|
65
|
-
disabled,
|
|
66
|
-
onKeyDown: disabled ? void 0 : handleKeyDown
|
|
67
|
-
}),
|
|
68
|
-
onPress: disabled ? void 0 : handlePress
|
|
69
|
-
}
|
|
70
|
-
};
|
|
11
|
+
var [checked, setChecked] = param;
|
|
12
|
+
var { labelledBy: ariaLabelledby, name, required, disabled, value = "on", onCheckedChange, ...checkboxProps } = props;
|
|
13
|
+
var [button, setButton] = React.useState(null);
|
|
14
|
+
var composedRefs = useComposedRefs(ref, setButton);
|
|
15
|
+
var hasConsumerStoppedPropagationRef = React.useRef(false);
|
|
16
|
+
var isFormControl = isWeb ? button ? Boolean(button.closest("form")) : true : false;
|
|
17
|
+
var labelId = useLabelContext(button);
|
|
18
|
+
var labelledBy = ariaLabelledby || labelId;
|
|
19
|
+
var parentKeyDown = props.onKeyDown;
|
|
20
|
+
var handleKeyDown = useMemo(function() {
|
|
21
|
+
return composeEventHandlers(parentKeyDown, function(event) {
|
|
22
|
+
if (event.key === "Enter") event.preventDefault();
|
|
23
|
+
});
|
|
24
|
+
}, [parentKeyDown]);
|
|
25
|
+
var handlePress = useMemo(function() {
|
|
26
|
+
return composeEventHandlers(props.onPress, function(event) {
|
|
27
|
+
setChecked(function(prevChecked) {
|
|
28
|
+
return isIndeterminate(prevChecked) ? true : !prevChecked;
|
|
29
|
+
});
|
|
30
|
+
if (isFormControl && "isPropagationStopped" in event) {
|
|
31
|
+
hasConsumerStoppedPropagationRef.current = event.isPropagationStopped();
|
|
32
|
+
if (!hasConsumerStoppedPropagationRef.current) event.stopPropagation();
|
|
33
|
+
}
|
|
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
|
+
};
|
|
71
64
|
}
|
|
65
|
+
|
|
72
66
|
export { useCheckbox };
|
|
73
67
|
//# sourceMappingURL=useCheckbox.native.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"file":"useCheckbox.native.js","names":[],"sources":["esm/useCheckbox.native.js"],"sourcesContent":["import { jsx as _jsx } from \"react/jsx-runtime\";\nimport { 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\";\nfunction useCheckbox(props, param, ref) {\n var [checked, setChecked] = param;\n var { labelledBy: ariaLabelledby, name, required, disabled, value = \"on\", onCheckedChange, ...checkboxProps } = props;\n var [button, setButton] = React.useState(null);\n var composedRefs = useComposedRefs(ref, setButton);\n var hasConsumerStoppedPropagationRef = React.useRef(false);\n var isFormControl = isWeb ? button ? Boolean(button.closest(\"form\")) : true : false;\n var labelId = useLabelContext(button);\n var labelledBy = ariaLabelledby || labelId;\n var parentKeyDown = props.onKeyDown;\n var handleKeyDown = useMemo(function() {\n return composeEventHandlers(parentKeyDown, function(event) {\n if (event.key === \"Enter\") event.preventDefault();\n });\n }, [\n parentKeyDown\n ]);\n var handlePress = useMemo(function() {\n return composeEventHandlers(props.onPress, function(event) {\n setChecked(function(prevChecked) {\n return isIndeterminate(prevChecked) ? true : !prevChecked;\n });\n if (isFormControl && \"isPropagationStopped\" in event) {\n hasConsumerStoppedPropagationRef.current = event.isPropagationStopped();\n if (!hasConsumerStoppedPropagationRef.current) event.stopPropagation();\n }\n });\n }, [\n isFormControl\n ]);\n return {\n bubbleInput: isWeb && isFormControl ? /* @__PURE__ */ _jsx(BubbleInput, {\n isHidden: true,\n control: button,\n bubbles: !hasConsumerStoppedPropagationRef.current,\n name,\n value,\n checked,\n required,\n disabled\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,OAAO,KAAK;CACtC,IAAI,CAAC,SAAS,cAAc;CAC5B,IAAI,EAAE,YAAY,gBAAgB,MAAM,UAAU,UAAU,QAAQ,MAAM,iBAAiB,GAAG,kBAAkB;CAChH,IAAI,CAAC,QAAQ,aAAa,MAAM,SAAS,IAAI;CAC7C,IAAI,eAAe,gBAAgB,KAAK,SAAS;CACjD,IAAI,mCAAmC,MAAM,OAAO,KAAK;CACzD,IAAI,gBAAgB,QAAQ,SAAS,QAAQ,OAAO,QAAQ,MAAM,CAAC,IAAI,OAAO;CAC9E,IAAI,UAAU,gBAAgB,MAAM;CACpC,IAAI,aAAa,kBAAkB;CACnC,IAAI,gBAAgB,MAAM;CAC1B,IAAI,gBAAgB,QAAQ,WAAW;EACrC,OAAO,qBAAqB,eAAe,SAAS,OAAO;GACzD,IAAI,MAAM,QAAQ,SAAS,MAAM,eAAe;EAClD,CAAC;CACH,GAAG,CACD,aACF,CAAC;CACD,IAAI,cAAc,QAAQ,WAAW;EACnC,OAAO,qBAAqB,MAAM,SAAS,SAAS,OAAO;GACzD,WAAW,SAAS,aAAa;IAC/B,OAAO,gBAAgB,WAAW,IAAI,OAAO,CAAC;GAChD,CAAC;GACD,IAAI,iBAAiB,0BAA0B,OAAO;IACpD,iCAAiC,UAAU,MAAM,qBAAqB;IACtE,IAAI,CAAC,iCAAiC,SAAS,MAAM,gBAAgB;GACvE;EACF,CAAC;CACH,GAAG,CACD,aACF,CAAC;CACD,OAAO;EACL,aAAa,SAAS,gBAAgC,oBAAK,aAAa;GACtE,UAAU;GACV,SAAS;GACT,SAAS,CAAC,iCAAiC;GAC3C;GACA;GACA;GACA;GACA;EACF,CAAC,IAAI;EACL,aAAa;EACb,eAAe;GACb,MAAM;GACN,mBAAmB;GACnB,gBAAgB,gBAAgB,OAAO,IAAI,UAAU;GACrD,GAAG;GACH,GAAG,SAAS;IACV,MAAM;IACN;IACA,cAAc,SAAS,OAAO;IAC9B,iBAAiB,WAAW,KAAK,KAAK;IACtC;IACA,WAAW,WAAW,KAAK,IAAI;GACjC;GACA,SAAS,WAAW,KAAK,IAAI;EAC/B;CACF;AACF"}
|
package/dist/esm/utils.mjs
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
function isIndeterminate(checked) {
|
|
2
|
-
|
|
2
|
+
return checked === "indeterminate";
|
|
3
3
|
}
|
|
4
4
|
function getState(checked) {
|
|
5
|
-
|
|
5
|
+
return isIndeterminate(checked) ? "indeterminate" : checked ? "checked" : "unchecked";
|
|
6
6
|
}
|
|
7
|
+
|
|
7
8
|
export { getState, isIndeterminate };
|
|
8
9
|
//# sourceMappingURL=utils.mjs.map
|
package/dist/esm/utils.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"utils.js","names":[],"sources":["esm/utils.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"}
|
package/dist/esm/utils.native.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
function isIndeterminate(checked) {
|
|
2
|
-
|
|
2
|
+
return checked === "indeterminate";
|
|
3
3
|
}
|
|
4
4
|
function getState(checked) {
|
|
5
|
-
|
|
5
|
+
return isIndeterminate(checked) ? "indeterminate" : checked ? "checked" : "unchecked";
|
|
6
6
|
}
|
|
7
|
+
|
|
7
8
|
export { getState, isIndeterminate };
|
|
8
9
|
//# sourceMappingURL=utils.native.js.map
|