@tamagui/checkbox-headless 1.114.4 → 1.115.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 +82 -0
- package/dist/cjs/index.cjs +19 -0
- package/dist/cjs/useCheckbox.cjs +93 -0
- package/dist/cjs/{utils.js → utils.cjs} +16 -11
- package/package.json +12 -11
- package/dist/cjs/BubbleInput.js +0 -65
- package/dist/cjs/index.js +0 -16
- package/dist/cjs/useCheckbox.js +0 -83
- /package/dist/cjs/{BubbleInput.js.map → BubbleInput.cjs.map} +0 -0
- /package/dist/cjs/{index.js.map → index.cjs.map} +0 -0
- /package/dist/cjs/{useCheckbox.js.map → useCheckbox.cjs.map} +0 -0
- /package/dist/cjs/{utils.js.map → utils.cjs.map} +0 -0
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf,
|
|
6
|
+
__hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all) __defProp(target, name, {
|
|
9
|
+
get: all[name],
|
|
10
|
+
enumerable: !0
|
|
11
|
+
});
|
|
12
|
+
},
|
|
13
|
+
__copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
|
|
15
|
+
get: () => from[key],
|
|
16
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
|
+
});
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
26
|
+
value: mod,
|
|
27
|
+
enumerable: !0
|
|
28
|
+
}) : target, mod)),
|
|
29
|
+
__toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
30
|
+
value: !0
|
|
31
|
+
}), mod);
|
|
32
|
+
var BubbleInput_exports = {};
|
|
33
|
+
__export(BubbleInput_exports, {
|
|
34
|
+
BubbleInput: () => BubbleInput
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(BubbleInput_exports);
|
|
37
|
+
var import_use_previous = require("@tamagui/use-previous"),
|
|
38
|
+
React = __toESM(require("react")),
|
|
39
|
+
import_utils = require("./utils.cjs"),
|
|
40
|
+
import_jsx_runtime = require("react/jsx-runtime");
|
|
41
|
+
const BubbleInput = props => {
|
|
42
|
+
const {
|
|
43
|
+
checked,
|
|
44
|
+
bubbles = !0,
|
|
45
|
+
control,
|
|
46
|
+
isHidden,
|
|
47
|
+
...inputProps
|
|
48
|
+
} = props,
|
|
49
|
+
ref = React.useRef(null),
|
|
50
|
+
prevChecked = (0, import_use_previous.usePrevious)(checked);
|
|
51
|
+
return React.useEffect(() => {
|
|
52
|
+
const input = ref.current,
|
|
53
|
+
inputProto = window.HTMLInputElement.prototype,
|
|
54
|
+
setChecked = Object.getOwnPropertyDescriptor(inputProto, "checked").set;
|
|
55
|
+
if (prevChecked !== checked && setChecked) {
|
|
56
|
+
const event = new Event("click", {
|
|
57
|
+
bubbles
|
|
58
|
+
});
|
|
59
|
+
input.indeterminate = (0, import_utils.isIndeterminate)(checked), setChecked.call(input, (0, import_utils.isIndeterminate)(checked) ? !1 : checked), input.dispatchEvent(event);
|
|
60
|
+
}
|
|
61
|
+
}, [prevChecked, checked, bubbles]), /* @__PURE__ */(0, import_jsx_runtime.jsx)("input", {
|
|
62
|
+
type: "checkbox",
|
|
63
|
+
defaultChecked: (0, import_utils.isIndeterminate)(checked) ? !1 : checked,
|
|
64
|
+
...inputProps,
|
|
65
|
+
tabIndex: -1,
|
|
66
|
+
ref,
|
|
67
|
+
"aria-hidden": isHidden,
|
|
68
|
+
style: {
|
|
69
|
+
...(isHidden ? {
|
|
70
|
+
// ...controlSize,
|
|
71
|
+
position: "absolute",
|
|
72
|
+
pointerEvents: "none",
|
|
73
|
+
opacity: 0,
|
|
74
|
+
margin: 0
|
|
75
|
+
} : {
|
|
76
|
+
appearance: "auto",
|
|
77
|
+
accentColor: "var(--color6)"
|
|
78
|
+
}),
|
|
79
|
+
...props.style
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
|
6
|
+
if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
|
|
7
|
+
get: () => from[key],
|
|
8
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
9
|
+
});
|
|
10
|
+
return to;
|
|
11
|
+
},
|
|
12
|
+
__reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
13
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
14
|
+
value: !0
|
|
15
|
+
}), mod);
|
|
16
|
+
var src_exports = {};
|
|
17
|
+
module.exports = __toCommonJS(src_exports);
|
|
18
|
+
__reExport(src_exports, require("./useCheckbox.cjs"), module.exports);
|
|
19
|
+
__reExport(src_exports, require("./utils.cjs"), module.exports);
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf,
|
|
6
|
+
__hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all) __defProp(target, name, {
|
|
9
|
+
get: all[name],
|
|
10
|
+
enumerable: !0
|
|
11
|
+
});
|
|
12
|
+
},
|
|
13
|
+
__copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
|
|
15
|
+
get: () => from[key],
|
|
16
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
|
+
});
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
26
|
+
value: mod,
|
|
27
|
+
enumerable: !0
|
|
28
|
+
}) : target, mod)),
|
|
29
|
+
__toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
30
|
+
value: !0
|
|
31
|
+
}), mod);
|
|
32
|
+
var useCheckbox_exports = {};
|
|
33
|
+
__export(useCheckbox_exports, {
|
|
34
|
+
useCheckbox: () => useCheckbox
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(useCheckbox_exports);
|
|
37
|
+
var import_compose_refs = require("@tamagui/compose-refs"),
|
|
38
|
+
import_constants = require("@tamagui/constants"),
|
|
39
|
+
import_helpers = require("@tamagui/helpers"),
|
|
40
|
+
import_label = require("@tamagui/label"),
|
|
41
|
+
import_react = __toESM(require("react")),
|
|
42
|
+
import_BubbleInput = require("./BubbleInput.cjs"),
|
|
43
|
+
import_utils = require("./utils.cjs"),
|
|
44
|
+
import_jsx_runtime = require("react/jsx-runtime");
|
|
45
|
+
function useCheckbox(props, [checked, setChecked], ref) {
|
|
46
|
+
const {
|
|
47
|
+
labelledBy: ariaLabelledby,
|
|
48
|
+
name,
|
|
49
|
+
required,
|
|
50
|
+
disabled,
|
|
51
|
+
value = "on",
|
|
52
|
+
onCheckedChange,
|
|
53
|
+
...checkboxProps
|
|
54
|
+
} = props,
|
|
55
|
+
[button, setButton] = import_react.default.useState(null),
|
|
56
|
+
composedRefs = (0, import_compose_refs.useComposedRefs)(ref, node => setButton(node)),
|
|
57
|
+
hasConsumerStoppedPropagationRef = import_react.default.useRef(!1),
|
|
58
|
+
isFormControl = import_constants.isWeb ? button ? !!button.closest("form") : !0 : !1,
|
|
59
|
+
labelId = (0, import_label.useLabelContext)(button),
|
|
60
|
+
labelledBy = ariaLabelledby || labelId;
|
|
61
|
+
return {
|
|
62
|
+
bubbleInput: import_constants.isWeb && isFormControl ? /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_BubbleInput.BubbleInput, {
|
|
63
|
+
isHidden: !0,
|
|
64
|
+
control: button,
|
|
65
|
+
bubbles: !hasConsumerStoppedPropagationRef.current,
|
|
66
|
+
name,
|
|
67
|
+
value,
|
|
68
|
+
checked,
|
|
69
|
+
required,
|
|
70
|
+
disabled
|
|
71
|
+
}) : null,
|
|
72
|
+
checkboxRef: composedRefs,
|
|
73
|
+
checkboxProps: {
|
|
74
|
+
role: "checkbox",
|
|
75
|
+
"aria-labelledby": labelledBy,
|
|
76
|
+
"aria-checked": (0, import_utils.isIndeterminate)(checked) ? "mixed" : checked,
|
|
77
|
+
...checkboxProps,
|
|
78
|
+
...(import_constants.isWeb && {
|
|
79
|
+
type: "button",
|
|
80
|
+
value,
|
|
81
|
+
"data-state": (0, import_utils.getState)(checked),
|
|
82
|
+
"data-disabled": disabled ? "" : void 0,
|
|
83
|
+
disabled,
|
|
84
|
+
onKeyDown: (0, import_helpers.composeEventHandlers)(props.onKeyDown, event => {
|
|
85
|
+
event.key === "Enter" && event.preventDefault();
|
|
86
|
+
})
|
|
87
|
+
}),
|
|
88
|
+
onPress: (0, import_helpers.composeEventHandlers)(props.onPress, event => {
|
|
89
|
+
setChecked(prevChecked => (0, import_utils.isIndeterminate)(prevChecked) ? !0 : !prevChecked), isFormControl && "isPropagationStopped" in event && (hasConsumerStoppedPropagationRef.current = event.isPropagationStopped(), hasConsumerStoppedPropagationRef.current || event.stopPropagation());
|
|
90
|
+
})
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
}
|
|
@@ -3,15 +3,21 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
3
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
5
|
var __export = (target, all) => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
6
|
+
for (var name in all) __defProp(target, name, {
|
|
7
|
+
get: all[name],
|
|
8
|
+
enumerable: !0
|
|
9
|
+
});
|
|
10
|
+
},
|
|
11
|
+
__copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
|
|
13
|
+
get: () => from[key],
|
|
14
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
15
|
+
});
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
19
|
+
value: !0
|
|
20
|
+
}), mod);
|
|
15
21
|
var utils_exports = {};
|
|
16
22
|
__export(utils_exports, {
|
|
17
23
|
getState: () => getState,
|
|
@@ -23,5 +29,4 @@ function isIndeterminate(checked) {
|
|
|
23
29
|
}
|
|
24
30
|
function getState(checked) {
|
|
25
31
|
return isIndeterminate(checked) ? "indeterminate" : checked ? "checked" : "unchecked";
|
|
26
|
-
}
|
|
27
|
-
//# sourceMappingURL=utils.js.map
|
|
32
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/checkbox-headless",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.115.0",
|
|
4
4
|
"sideEffects": [
|
|
5
5
|
"*.css"
|
|
6
6
|
],
|
|
@@ -23,14 +23,14 @@
|
|
|
23
23
|
"clean:build": "tamagui-build clean:build"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@tamagui/compose-refs": "1.
|
|
27
|
-
"@tamagui/constants": "1.
|
|
28
|
-
"@tamagui/create-context": "1.
|
|
29
|
-
"@tamagui/focusable": "1.
|
|
30
|
-
"@tamagui/helpers": "1.
|
|
31
|
-
"@tamagui/label": "1.
|
|
32
|
-
"@tamagui/use-controllable-state": "1.
|
|
33
|
-
"@tamagui/use-previous": "1.
|
|
26
|
+
"@tamagui/compose-refs": "1.115.0",
|
|
27
|
+
"@tamagui/constants": "1.115.0",
|
|
28
|
+
"@tamagui/create-context": "1.115.0",
|
|
29
|
+
"@tamagui/focusable": "1.115.0",
|
|
30
|
+
"@tamagui/helpers": "1.115.0",
|
|
31
|
+
"@tamagui/label": "1.115.0",
|
|
32
|
+
"@tamagui/use-controllable-state": "1.115.0",
|
|
33
|
+
"@tamagui/use-previous": "1.115.0"
|
|
34
34
|
},
|
|
35
35
|
"exports": {
|
|
36
36
|
"./package.json": "./package.json",
|
|
@@ -39,11 +39,12 @@
|
|
|
39
39
|
"react-native": "./dist/cjs/index.native.js",
|
|
40
40
|
"types": "./types/index.d.ts",
|
|
41
41
|
"import": "./dist/esm/index.mjs",
|
|
42
|
-
"require": "./dist/cjs/index.
|
|
42
|
+
"require": "./dist/cjs/index.cjs",
|
|
43
|
+
"default": "./dist/cjs/index.native.js"
|
|
43
44
|
}
|
|
44
45
|
},
|
|
45
46
|
"devDependencies": {
|
|
46
|
-
"@tamagui/build": "1.
|
|
47
|
+
"@tamagui/build": "1.115.0",
|
|
47
48
|
"react": "^18.2.0 || ^19.0.0"
|
|
48
49
|
},
|
|
49
50
|
"publishConfig": {
|
package/dist/cjs/BubbleInput.js
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: !0 });
|
|
9
|
-
}, __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from == "object" || typeof from == "function")
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
13
|
-
return to;
|
|
14
|
-
};
|
|
15
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
16
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
17
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
18
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
19
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
20
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
|
|
21
|
-
mod
|
|
22
|
-
)), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
23
|
-
var BubbleInput_exports = {};
|
|
24
|
-
__export(BubbleInput_exports, {
|
|
25
|
-
BubbleInput: () => BubbleInput
|
|
26
|
-
});
|
|
27
|
-
module.exports = __toCommonJS(BubbleInput_exports);
|
|
28
|
-
var import_use_previous = require("@tamagui/use-previous"), React = __toESM(require("react")), import_utils = require("./utils"), import_jsx_runtime = require("react/jsx-runtime");
|
|
29
|
-
const BubbleInput = (props) => {
|
|
30
|
-
const { checked, bubbles = !0, control, isHidden, ...inputProps } = props, ref = React.useRef(null), prevChecked = (0, import_use_previous.usePrevious)(checked);
|
|
31
|
-
return React.useEffect(() => {
|
|
32
|
-
const input = ref.current, inputProto = window.HTMLInputElement.prototype, setChecked = Object.getOwnPropertyDescriptor(
|
|
33
|
-
inputProto,
|
|
34
|
-
"checked"
|
|
35
|
-
).set;
|
|
36
|
-
if (prevChecked !== checked && setChecked) {
|
|
37
|
-
const event = new Event("click", { bubbles });
|
|
38
|
-
input.indeterminate = (0, import_utils.isIndeterminate)(checked), setChecked.call(input, (0, import_utils.isIndeterminate)(checked) ? !1 : checked), input.dispatchEvent(event);
|
|
39
|
-
}
|
|
40
|
-
}, [prevChecked, checked, bubbles]), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
41
|
-
"input",
|
|
42
|
-
{
|
|
43
|
-
type: "checkbox",
|
|
44
|
-
defaultChecked: (0, import_utils.isIndeterminate)(checked) ? !1 : checked,
|
|
45
|
-
...inputProps,
|
|
46
|
-
tabIndex: -1,
|
|
47
|
-
ref,
|
|
48
|
-
"aria-hidden": isHidden,
|
|
49
|
-
style: {
|
|
50
|
-
...isHidden ? {
|
|
51
|
-
// ...controlSize,
|
|
52
|
-
position: "absolute",
|
|
53
|
-
pointerEvents: "none",
|
|
54
|
-
opacity: 0,
|
|
55
|
-
margin: 0
|
|
56
|
-
} : {
|
|
57
|
-
appearance: "auto",
|
|
58
|
-
accentColor: "var(--color6)"
|
|
59
|
-
},
|
|
60
|
-
...props.style
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
);
|
|
64
|
-
};
|
|
65
|
-
//# sourceMappingURL=BubbleInput.js.map
|
package/dist/cjs/index.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __copyProps = (to, from, except, desc) => {
|
|
6
|
-
if (from && typeof from == "object" || typeof from == "function")
|
|
7
|
-
for (let key of __getOwnPropNames(from))
|
|
8
|
-
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
9
|
-
return to;
|
|
10
|
-
}, __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
11
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
12
|
-
var src_exports = {};
|
|
13
|
-
module.exports = __toCommonJS(src_exports);
|
|
14
|
-
__reExport(src_exports, require("./useCheckbox"), module.exports);
|
|
15
|
-
__reExport(src_exports, require("./utils"), module.exports);
|
|
16
|
-
//# sourceMappingURL=index.js.map
|
package/dist/cjs/useCheckbox.js
DELETED
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: !0 });
|
|
9
|
-
}, __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from == "object" || typeof from == "function")
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
13
|
-
return to;
|
|
14
|
-
};
|
|
15
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
16
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
17
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
18
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
19
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
20
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
|
|
21
|
-
mod
|
|
22
|
-
)), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
23
|
-
var useCheckbox_exports = {};
|
|
24
|
-
__export(useCheckbox_exports, {
|
|
25
|
-
useCheckbox: () => useCheckbox
|
|
26
|
-
});
|
|
27
|
-
module.exports = __toCommonJS(useCheckbox_exports);
|
|
28
|
-
var import_compose_refs = require("@tamagui/compose-refs"), import_constants = require("@tamagui/constants"), import_helpers = require("@tamagui/helpers"), import_label = require("@tamagui/label"), import_react = __toESM(require("react")), import_BubbleInput = require("./BubbleInput"), import_utils = require("./utils"), import_jsx_runtime = require("react/jsx-runtime");
|
|
29
|
-
function useCheckbox(props, [checked, setChecked], ref) {
|
|
30
|
-
const {
|
|
31
|
-
labelledBy: ariaLabelledby,
|
|
32
|
-
name,
|
|
33
|
-
required,
|
|
34
|
-
disabled,
|
|
35
|
-
value = "on",
|
|
36
|
-
onCheckedChange,
|
|
37
|
-
...checkboxProps
|
|
38
|
-
} = props, [button, setButton] = import_react.default.useState(null), composedRefs = (0, import_compose_refs.useComposedRefs)(ref, (node) => setButton(node)), hasConsumerStoppedPropagationRef = import_react.default.useRef(!1), isFormControl = import_constants.isWeb ? button ? !!button.closest("form") : !0 : !1, labelId = (0, import_label.useLabelContext)(button), labelledBy = ariaLabelledby || labelId;
|
|
39
|
-
return {
|
|
40
|
-
bubbleInput: import_constants.isWeb && isFormControl ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
41
|
-
import_BubbleInput.BubbleInput,
|
|
42
|
-
{
|
|
43
|
-
isHidden: !0,
|
|
44
|
-
control: button,
|
|
45
|
-
bubbles: !hasConsumerStoppedPropagationRef.current,
|
|
46
|
-
name,
|
|
47
|
-
value,
|
|
48
|
-
checked,
|
|
49
|
-
required,
|
|
50
|
-
disabled
|
|
51
|
-
}
|
|
52
|
-
) : null,
|
|
53
|
-
checkboxRef: composedRefs,
|
|
54
|
-
checkboxProps: {
|
|
55
|
-
role: "checkbox",
|
|
56
|
-
"aria-labelledby": labelledBy,
|
|
57
|
-
"aria-checked": (0, import_utils.isIndeterminate)(checked) ? "mixed" : checked,
|
|
58
|
-
...checkboxProps,
|
|
59
|
-
...import_constants.isWeb && {
|
|
60
|
-
type: "button",
|
|
61
|
-
value,
|
|
62
|
-
"data-state": (0, import_utils.getState)(checked),
|
|
63
|
-
"data-disabled": disabled ? "" : void 0,
|
|
64
|
-
disabled,
|
|
65
|
-
onKeyDown: (0, import_helpers.composeEventHandlers)(
|
|
66
|
-
props.onKeyDown,
|
|
67
|
-
(event) => {
|
|
68
|
-
event.key === "Enter" && event.preventDefault();
|
|
69
|
-
}
|
|
70
|
-
)
|
|
71
|
-
},
|
|
72
|
-
onPress: (0, import_helpers.composeEventHandlers)(
|
|
73
|
-
props.onPress,
|
|
74
|
-
(event) => {
|
|
75
|
-
setChecked(
|
|
76
|
-
(prevChecked) => (0, import_utils.isIndeterminate)(prevChecked) ? !0 : !prevChecked
|
|
77
|
-
), isFormControl && "isPropagationStopped" in event && (hasConsumerStoppedPropagationRef.current = event.isPropagationStopped(), hasConsumerStoppedPropagationRef.current || event.stopPropagation());
|
|
78
|
-
}
|
|
79
|
-
)
|
|
80
|
-
}
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
//# sourceMappingURL=useCheckbox.js.map
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|