@tamagui/checkbox-headless 2.0.0-rc.8 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/BubbleInput.cjs +47 -41
- package/dist/cjs/BubbleInput.native.js +74 -69
- package/dist/cjs/BubbleInput.native.js.map +1 -1
- package/dist/cjs/index.cjs +7 -5
- package/dist/cjs/index.native.js +7 -5
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/cjs/useCheckbox.cjs +58 -52
- package/dist/cjs/useCheckbox.native.js +65 -59
- package/dist/cjs/useCheckbox.native.js.map +1 -1
- package/dist/cjs/utils.cjs +12 -10
- package/dist/cjs/utils.native.js +12 -10
- package/dist/cjs/utils.native.js.map +1 -1
- package/dist/esm/BubbleInput.mjs +19 -15
- package/dist/esm/BubbleInput.mjs.map +1 -1
- package/dist/esm/BubbleInput.native.js +19 -16
- package/dist/esm/BubbleInput.native.js.map +1 -1
- package/dist/esm/index.js +2 -2
- package/dist/esm/index.js.map +1 -6
- package/dist/esm/useCheckbox.mjs +26 -22
- package/dist/esm/useCheckbox.mjs.map +1 -1
- package/dist/esm/useCheckbox.native.js +33 -29
- package/dist/esm/useCheckbox.native.js.map +1 -1
- package/dist/jsx/BubbleInput.mjs +19 -15
- package/dist/jsx/BubbleInput.mjs.map +1 -1
- package/dist/jsx/BubbleInput.native.js +74 -69
- package/dist/jsx/BubbleInput.native.js.map +1 -1
- package/dist/jsx/index.js +2 -2
- package/dist/jsx/index.js.map +1 -6
- package/dist/jsx/index.native.js +7 -5
- package/dist/jsx/useCheckbox.mjs +26 -22
- package/dist/jsx/useCheckbox.mjs.map +1 -1
- package/dist/jsx/useCheckbox.native.js +65 -59
- package/dist/jsx/useCheckbox.native.js.map +1 -1
- package/dist/jsx/utils.native.js +12 -10
- package/package.json +16 -20
- package/dist/cjs/BubbleInput.js +0 -65
- package/dist/cjs/BubbleInput.js.map +0 -6
- package/dist/cjs/index.js +0 -16
- package/dist/cjs/index.js.map +0 -6
- package/dist/cjs/useCheckbox.js +0 -81
- package/dist/cjs/useCheckbox.js.map +0 -6
- package/dist/cjs/utils.js +0 -27
- package/dist/cjs/utils.js.map +0 -6
- package/dist/esm/BubbleInput.js +0 -44
- package/dist/esm/BubbleInput.js.map +0 -6
- package/dist/esm/useCheckbox.js +0 -64
- package/dist/esm/useCheckbox.js.map +0 -6
- package/dist/esm/utils.js +0 -11
- package/dist/esm/utils.js.map +0 -6
- package/dist/jsx/BubbleInput.js +0 -44
- package/dist/jsx/BubbleInput.js.map +0 -6
- package/dist/jsx/useCheckbox.js +0 -64
- package/dist/jsx/useCheckbox.js.map +0 -6
- package/dist/jsx/utils.js +0 -11
- package/dist/jsx/utils.js.map +0 -6
package/dist/cjs/BubbleInput.cjs
CHANGED
|
@@ -2,65 +2,71 @@ var __create = Object.create;
|
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf
|
|
6
|
-
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
7
|
var __export = (target, all) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
for (var name in all) __defProp(target, name, {
|
|
9
|
+
get: all[name],
|
|
10
|
+
enumerable: true
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
15
16
|
get: () => from[key],
|
|
16
17
|
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
18
|
});
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
20
22
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
23
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
24
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
25
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
26
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
27
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
28
|
+
value: mod,
|
|
29
|
+
enumerable: true
|
|
30
|
+
}) : target, mod));
|
|
31
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
32
|
+
value: true
|
|
33
|
+
}), mod);
|
|
32
34
|
var BubbleInput_exports = {};
|
|
33
35
|
__export(BubbleInput_exports, {
|
|
34
36
|
BubbleInput: () => BubbleInput
|
|
35
37
|
});
|
|
36
38
|
module.exports = __toCommonJS(BubbleInput_exports);
|
|
37
|
-
var import_use_previous = require("@tamagui/use-previous")
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
var import_use_previous = require("@tamagui/use-previous");
|
|
40
|
+
var React = __toESM(require("react"), 1);
|
|
41
|
+
var import_utils = require("./utils.cjs");
|
|
42
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
41
43
|
const BubbleInput = props => {
|
|
42
44
|
const {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
const input = ref.current
|
|
53
|
-
|
|
54
|
-
|
|
45
|
+
checked,
|
|
46
|
+
bubbles = true,
|
|
47
|
+
control,
|
|
48
|
+
isHidden,
|
|
49
|
+
...inputProps
|
|
50
|
+
} = props;
|
|
51
|
+
const ref = React.useRef(null);
|
|
52
|
+
const prevChecked = (0, import_use_previous.usePrevious)(checked);
|
|
53
|
+
React.useEffect(() => {
|
|
54
|
+
const input = ref.current;
|
|
55
|
+
const inputProto = window.HTMLInputElement.prototype;
|
|
56
|
+
const descriptor = Object.getOwnPropertyDescriptor(inputProto, "checked");
|
|
57
|
+
const setChecked = descriptor.set;
|
|
55
58
|
if (prevChecked !== checked && setChecked) {
|
|
56
59
|
const event = new Event("click", {
|
|
57
60
|
bubbles
|
|
58
61
|
});
|
|
59
|
-
input.indeterminate = (0, import_utils.isIndeterminate)(checked)
|
|
62
|
+
input.indeterminate = (0, import_utils.isIndeterminate)(checked);
|
|
63
|
+
setChecked.call(input, (0, import_utils.isIndeterminate)(checked) ? false : checked);
|
|
64
|
+
input.dispatchEvent(event);
|
|
60
65
|
}
|
|
61
|
-
}, [prevChecked, checked, bubbles])
|
|
66
|
+
}, [prevChecked, checked, bubbles]);
|
|
67
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)("input", {
|
|
62
68
|
type: "checkbox",
|
|
63
|
-
defaultChecked: (0, import_utils.isIndeterminate)(checked) ?
|
|
69
|
+
defaultChecked: (0, import_utils.isIndeterminate)(checked) ? false : checked,
|
|
64
70
|
...inputProps,
|
|
65
71
|
tabIndex: -1,
|
|
66
72
|
ref,
|
|
@@ -4,83 +4,88 @@ var __create = Object.create;
|
|
|
4
4
|
var __defProp = Object.defineProperty;
|
|
5
5
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
6
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
-
var __getProtoOf = Object.getPrototypeOf
|
|
8
|
-
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
9
|
var __export = (target, all) => {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
10
|
+
for (var name in all) __defProp(target, name, {
|
|
11
|
+
get: all[name],
|
|
12
|
+
enumerable: true
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
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, {
|
|
17
18
|
get: () => from[key],
|
|
18
19
|
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
19
20
|
});
|
|
20
|
-
|
|
21
|
-
|
|
21
|
+
}
|
|
22
|
+
return to;
|
|
23
|
+
};
|
|
22
24
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
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
|
|
32
|
+
}) : target, mod));
|
|
33
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
34
|
+
value: true
|
|
35
|
+
}), mod);
|
|
34
36
|
var BubbleInput_exports = {};
|
|
35
37
|
__export(BubbleInput_exports, {
|
|
36
38
|
BubbleInput: () => BubbleInput
|
|
37
39
|
});
|
|
38
40
|
module.exports = __toCommonJS(BubbleInput_exports);
|
|
39
|
-
var import_jsx_runtime = require("react/jsx-runtime")
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
41
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
42
|
+
var import_use_previous = require("@tamagui/use-previous");
|
|
43
|
+
var React = __toESM(require("react"), 1);
|
|
44
|
+
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
|
+
});
|
|
90
|
+
};
|
|
86
91
|
//# sourceMappingURL=BubbleInput.native.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","BubbleInput_exports","__export","BubbleInput","module","exports","import_jsx_runtime","require","import_use_previous","React","__toESM","import_utils","props","checked","bubbles","control","isHidden","inputProps","ref","useRef","prevChecked","usePrevious","useEffect","input","current","inputProto","window","HTMLInputElement","prototype","descriptor","Object","getOwnPropertyDescriptor","setChecked","set","event","Event","indeterminate","isIndeterminate","call","dispatchEvent","jsx","type","defaultChecked","tabIndex","style","position","pointerEvents","opacity","margin","appearance","accentColor"],"sources":["../../src/BubbleInput.tsx"],"sourcesContent":[null],"mappings":"
|
|
1
|
+
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","BubbleInput_exports","__export","BubbleInput","module","exports","import_jsx_runtime","require","import_use_previous","React","__toESM","import_utils","props","checked","bubbles","control","isHidden","inputProps","ref","useRef","prevChecked","usePrevious","useEffect","input","current","inputProto","window","HTMLInputElement","prototype","descriptor","Object","getOwnPropertyDescriptor","setChecked","set","event","Event","indeterminate","isIndeterminate","call","dispatchEvent","jsx","type","defaultChecked","tabIndex","style","position","pointerEvents","opacity","margin","appearance","accentColor"],"sources":["../../src/BubbleInput.tsx"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,mBAAA;AAAAC,QAAA,CAAAD,mBAAA;EAAAE,WAAA,EAAAA,CAAA,KAAAA;AAAA;AAAAC,MAAA,CAAAC,OAAA,GAAAT,YAA4B,CAAAK,mBAAA;AAC5B,IAAAK,kBAAuB,GAAAC,OAAA;AAGvB,IAAAC,mBAAgC,GAAAD,OAAA;AAkC5B,IAAAE,KAAA,GAAAC,OAAA,CAAAH,OAAA;AAxBG,IAAAI,YAAM,GAAAJ,OAAe,oBAA4B;AACtD,IAAAJ,WAAQ,YAAAA,CAASS,KAAU;EAC3B;IAAMC,OAAM;IAAAC,OAAM,GAAyB,IAAI;IAAAC,OAAA;IAAAC,QAAA;IAAA,GAAAC;EAAA,IAAAL,KAAA;EAC/C,IAAAM,GAAM,GAAAT,KAAA,CAAAU,MAAA,KAAc;EAGpB,IAAAC,WAAM,GAAU,IAAMZ,mBAAA,CAAAa,WAAA,EAAAR,OAAA;EACpBJ,KAAA,CAAAa,SAAM,CAAQ,YAAI;IAClB,IAAAC,KAAM,GAAAL,GAAA,CAAAM,OAAa;IACnB,IAAAC,UAAM,GAAAC,MAAa,CAAAC,gBAAO,CAAAC,SAAA;IAAA,IACxBC,UAAA,GAAAC,MAAA,CAAAC,wBAAA,CAAAN,UAAA;IAAA,IACAO,UAAA,GAAAH,UAAA,CAAAI,GAAA;IACF,IAAAb,WAAA,KAAAP,OAAA,IAAAmB,UAAA;MACA,IAAME,KAAA,OAAAC,KAAa,QAAW;QAE1BrB;MACF;MACAS,KAAA,CAAMa,aAAA,OAAgBzB,YAAA,CAAA0B,eAAA,EAAgBxB,OAAO;MAC7CmB,UAAA,CAAWM,IAAA,CAAKf,KAAA,MAAOZ,YAAA,CAAA0B,eAAA,EAAgBxB,OAAO,IAAI,QAAQA,OAAO;MACjEU,KAAA,CAAMgB,aAAA,CAAcL,KAAK;IAC3B;EACF,GAAG,CAEHd,WACE,EAACP,OAAA,EAAAC,OAAA;EACM,OACL,gBAAgB,GAAAR,kBAAA,CAAAkC,GAAA,SAAgB;IAAmBC,IAClD,EAAG;IAAAC,cACM,MAAA/B,YAAA,CAAA0B,eAAA,EAAAxB,OAAA,YAAAA,OAAA;IAAA,GACVI,UAAA;IAAA0B,QACA;IAAazB,GACb;IAAO,aACD,EAAAF,QACA;IAAA4B,KAAA;MAAA,IAAA5B,QAEE,GAAU;QAAA;QACK6B,QACf,YAAS;QAAAC,aACD;QACVC,OACA;QAAAC,MACE;MAAY,IACZ;QACFC,UAAA;QAEJC,WAAS;MACX;MAAA,GAAAtC,KAAA,CAAAgC;IACF;EAEJ","ignoreList":[]}
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -3,15 +3,17 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
3
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
5
|
var __copyProps = (to, from, except, desc) => {
|
|
6
|
-
|
|
6
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
7
8
|
get: () => from[key],
|
|
8
9
|
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
9
10
|
});
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
13
15
|
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
14
|
-
value:
|
|
16
|
+
value: true
|
|
15
17
|
}), mod);
|
|
16
18
|
var index_exports = {};
|
|
17
19
|
module.exports = __toCommonJS(index_exports);
|
package/dist/cjs/index.native.js
CHANGED
|
@@ -5,15 +5,17 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
7
|
var __copyProps = (to, from, except, desc) => {
|
|
8
|
-
|
|
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, {
|
|
9
10
|
get: () => from[key],
|
|
10
11
|
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
11
12
|
});
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
}
|
|
14
|
+
return to;
|
|
15
|
+
};
|
|
16
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
17
|
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
16
|
-
value:
|
|
18
|
+
value: true
|
|
17
19
|
}), mod);
|
|
18
20
|
var index_exports = {};
|
|
19
21
|
module.exports = __toCommonJS(index_exports);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","index_exports","module","exports","__reExport","require"],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"
|
|
1
|
+
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","index_exports","module","exports","__reExport","require"],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,aAAA;AAAAC,MAAA,CAAAC,OAAA,GAAAP,YAAc,CAAAK,aAAA;AACdG,UAAA,CAAAH,aAAA,EAAcI,OAAA,0BADd,GAAAH,MAAA,CAAAC,OAAA","ignoreList":[]}
|
package/dist/cjs/useCheckbox.cjs
CHANGED
|
@@ -2,72 +2,78 @@ var __create = Object.create;
|
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf
|
|
6
|
-
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
7
|
var __export = (target, all) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
for (var name in all) __defProp(target, name, {
|
|
9
|
+
get: all[name],
|
|
10
|
+
enumerable: true
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
15
16
|
get: () => from[key],
|
|
16
17
|
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
18
|
});
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
20
22
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
23
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
24
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
25
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
26
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
27
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
28
|
+
value: mod,
|
|
29
|
+
enumerable: true
|
|
30
|
+
}) : target, mod));
|
|
31
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
32
|
+
value: true
|
|
33
|
+
}), mod);
|
|
32
34
|
var useCheckbox_exports = {};
|
|
33
35
|
__export(useCheckbox_exports, {
|
|
34
36
|
useCheckbox: () => useCheckbox
|
|
35
37
|
});
|
|
36
38
|
module.exports = __toCommonJS(useCheckbox_exports);
|
|
37
|
-
var import_compose_refs = require("@tamagui/compose-refs")
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
39
|
+
var import_compose_refs = require("@tamagui/compose-refs");
|
|
40
|
+
var import_constants = require("@tamagui/constants");
|
|
41
|
+
var import_helpers = require("@tamagui/helpers");
|
|
42
|
+
var import_label = require("@tamagui/label");
|
|
43
|
+
var import_react = __toESM(require("react"), 1);
|
|
44
|
+
var import_BubbleInput = require("./BubbleInput.cjs");
|
|
45
|
+
var import_utils = require("./utils.cjs");
|
|
46
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
45
47
|
function useCheckbox(props, [checked, setChecked], ref) {
|
|
46
48
|
const {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
49
|
+
labelledBy: ariaLabelledby,
|
|
50
|
+
name,
|
|
51
|
+
required,
|
|
52
|
+
disabled,
|
|
53
|
+
value = "on",
|
|
54
|
+
onCheckedChange,
|
|
55
|
+
...checkboxProps
|
|
56
|
+
} = props;
|
|
57
|
+
const [button, setButton] = import_react.default.useState(null);
|
|
58
|
+
const composedRefs = (0, import_compose_refs.useComposedRefs)(ref, setButton);
|
|
59
|
+
const hasConsumerStoppedPropagationRef = import_react.default.useRef(false);
|
|
60
|
+
const isFormControl = import_constants.isWeb ? button ? Boolean(button.closest("form")) : true : false;
|
|
61
|
+
const labelId = (0, import_label.useLabelContext)(button);
|
|
62
|
+
const labelledBy = ariaLabelledby || labelId;
|
|
63
|
+
const parentKeyDown = props.onKeyDown;
|
|
64
|
+
const handleKeyDown = (0, import_react.useMemo)(() => (0, import_helpers.composeEventHandlers)(parentKeyDown, event => {
|
|
65
|
+
if (event.key === "Enter") event.preventDefault();
|
|
66
|
+
}), [parentKeyDown]);
|
|
67
|
+
const handlePress = (0, import_react.useMemo)(() => (0, import_helpers.composeEventHandlers)(props.onPress, event => {
|
|
68
|
+
setChecked(prevChecked => (0, import_utils.isIndeterminate)(prevChecked) ? true : !prevChecked);
|
|
69
|
+
if (isFormControl && "isPropagationStopped" in event) {
|
|
70
|
+
hasConsumerStoppedPropagationRef.current = event.isPropagationStopped();
|
|
71
|
+
if (!hasConsumerStoppedPropagationRef.current) event.stopPropagation();
|
|
72
|
+
}
|
|
73
|
+
}), [isFormControl]);
|
|
68
74
|
return {
|
|
69
75
|
bubbleInput: import_constants.isWeb && isFormControl ? /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_BubbleInput.BubbleInput, {
|
|
70
|
-
isHidden:
|
|
76
|
+
isHidden: true,
|
|
71
77
|
control: button,
|
|
72
78
|
bubbles: !hasConsumerStoppedPropagationRef.current,
|
|
73
79
|
name,
|
|
@@ -4,79 +4,85 @@ var __create = Object.create;
|
|
|
4
4
|
var __defProp = Object.defineProperty;
|
|
5
5
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
6
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
-
var __getProtoOf = Object.getPrototypeOf
|
|
8
|
-
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
9
|
var __export = (target, all) => {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
10
|
+
for (var name in all) __defProp(target, name, {
|
|
11
|
+
get: all[name],
|
|
12
|
+
enumerable: true
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
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, {
|
|
17
18
|
get: () => from[key],
|
|
18
19
|
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
19
20
|
});
|
|
20
|
-
|
|
21
|
-
|
|
21
|
+
}
|
|
22
|
+
return to;
|
|
23
|
+
};
|
|
22
24
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
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
|
|
32
|
+
}) : target, mod));
|
|
33
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
34
|
+
value: true
|
|
35
|
+
}), mod);
|
|
34
36
|
var useCheckbox_exports = {};
|
|
35
37
|
__export(useCheckbox_exports, {
|
|
36
38
|
useCheckbox: () => useCheckbox
|
|
37
39
|
});
|
|
38
40
|
module.exports = __toCommonJS(useCheckbox_exports);
|
|
39
|
-
var import_jsx_runtime = require("react/jsx-runtime")
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
41
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
42
|
+
var import_compose_refs = require("@tamagui/compose-refs");
|
|
43
|
+
var import_constants = require("@tamagui/constants");
|
|
44
|
+
var import_helpers = require("@tamagui/helpers");
|
|
45
|
+
var import_label = require("@tamagui/label");
|
|
46
|
+
var import_react = __toESM(require("react"), 1);
|
|
47
|
+
var import_BubbleInput = require("./BubbleInput.native.js");
|
|
48
|
+
var import_utils = require("./utils.native.js");
|
|
47
49
|
function useCheckbox(props, param, ref) {
|
|
48
|
-
var [checked, setChecked] = param
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}), isFormControl && "isPropagationStopped" in event && (hasConsumerStoppedPropagationRef.current = event.isPropagationStopped(), hasConsumerStoppedPropagationRef.current || event.stopPropagation());
|
|
50
|
+
var [checked, setChecked] = param;
|
|
51
|
+
var {
|
|
52
|
+
labelledBy: ariaLabelledby,
|
|
53
|
+
name,
|
|
54
|
+
required,
|
|
55
|
+
disabled,
|
|
56
|
+
value = "on",
|
|
57
|
+
onCheckedChange,
|
|
58
|
+
...checkboxProps
|
|
59
|
+
} = props;
|
|
60
|
+
var [button, setButton] = import_react.default.useState(null);
|
|
61
|
+
var composedRefs = (0, import_compose_refs.useComposedRefs)(ref, setButton);
|
|
62
|
+
var hasConsumerStoppedPropagationRef = import_react.default.useRef(false);
|
|
63
|
+
var isFormControl = import_constants.isWeb ? button ? Boolean(button.closest("form")) : true : false;
|
|
64
|
+
var labelId = (0, import_label.useLabelContext)(button);
|
|
65
|
+
var labelledBy = ariaLabelledby || labelId;
|
|
66
|
+
var parentKeyDown = props.onKeyDown;
|
|
67
|
+
var handleKeyDown = (0, import_react.useMemo)(function () {
|
|
68
|
+
return (0, import_helpers.composeEventHandlers)(parentKeyDown, function (event) {
|
|
69
|
+
if (event.key === "Enter") event.preventDefault();
|
|
70
|
+
});
|
|
71
|
+
}, [parentKeyDown]);
|
|
72
|
+
var handlePress = (0, import_react.useMemo)(function () {
|
|
73
|
+
return (0, import_helpers.composeEventHandlers)(props.onPress, function (event) {
|
|
74
|
+
setChecked(function (prevChecked) {
|
|
75
|
+
return (0, import_utils.isIndeterminate)(prevChecked) ? true : !prevChecked;
|
|
75
76
|
});
|
|
76
|
-
|
|
77
|
+
if (isFormControl && "isPropagationStopped" in event) {
|
|
78
|
+
hasConsumerStoppedPropagationRef.current = event.isPropagationStopped();
|
|
79
|
+
if (!hasConsumerStoppedPropagationRef.current) event.stopPropagation();
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
}, [isFormControl]);
|
|
77
83
|
return {
|
|
78
84
|
bubbleInput: import_constants.isWeb && isFormControl ? /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_BubbleInput.BubbleInput, {
|
|
79
|
-
isHidden:
|
|
85
|
+
isHidden: true,
|
|
80
86
|
control: button,
|
|
81
87
|
bubbles: !hasConsumerStoppedPropagationRef.current,
|
|
82
88
|
name,
|