@hanzogui/checkbox 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.
Files changed (58) hide show
  1. package/LICENSE +21 -0
  2. package/dist/cjs/Checkbox.cjs +111 -0
  3. package/dist/cjs/Checkbox.native.js +117 -0
  4. package/dist/cjs/Checkbox.native.js.map +1 -0
  5. package/dist/cjs/CheckboxStyledContext.cjs +33 -0
  6. package/dist/cjs/CheckboxStyledContext.native.js +36 -0
  7. package/dist/cjs/CheckboxStyledContext.native.js.map +1 -0
  8. package/dist/cjs/createCheckbox.cjs +184 -0
  9. package/dist/cjs/createCheckbox.native.js +209 -0
  10. package/dist/cjs/createCheckbox.native.js.map +1 -0
  11. package/dist/cjs/index.cjs +35 -0
  12. package/dist/cjs/index.native.js +38 -0
  13. package/dist/cjs/index.native.js.map +1 -0
  14. package/dist/esm/Checkbox.mjs +87 -0
  15. package/dist/esm/Checkbox.mjs.map +1 -0
  16. package/dist/esm/Checkbox.native.js +90 -0
  17. package/dist/esm/Checkbox.native.js.map +1 -0
  18. package/dist/esm/CheckboxStyledContext.mjs +10 -0
  19. package/dist/esm/CheckboxStyledContext.mjs.map +1 -0
  20. package/dist/esm/CheckboxStyledContext.native.js +10 -0
  21. package/dist/esm/CheckboxStyledContext.native.js.map +1 -0
  22. package/dist/esm/createCheckbox.mjs +148 -0
  23. package/dist/esm/createCheckbox.mjs.map +1 -0
  24. package/dist/esm/createCheckbox.native.js +171 -0
  25. package/dist/esm/createCheckbox.native.js.map +1 -0
  26. package/dist/esm/index.js +11 -0
  27. package/dist/esm/index.js.map +1 -0
  28. package/dist/esm/index.mjs +11 -0
  29. package/dist/esm/index.mjs.map +1 -0
  30. package/dist/esm/index.native.js +11 -0
  31. package/dist/esm/index.native.js.map +1 -0
  32. package/dist/jsx/Checkbox.mjs +87 -0
  33. package/dist/jsx/Checkbox.mjs.map +1 -0
  34. package/dist/jsx/Checkbox.native.js +117 -0
  35. package/dist/jsx/Checkbox.native.js.map +1 -0
  36. package/dist/jsx/CheckboxStyledContext.mjs +10 -0
  37. package/dist/jsx/CheckboxStyledContext.mjs.map +1 -0
  38. package/dist/jsx/CheckboxStyledContext.native.js +36 -0
  39. package/dist/jsx/CheckboxStyledContext.native.js.map +1 -0
  40. package/dist/jsx/createCheckbox.mjs +148 -0
  41. package/dist/jsx/createCheckbox.mjs.map +1 -0
  42. package/dist/jsx/createCheckbox.native.js +209 -0
  43. package/dist/jsx/createCheckbox.native.js.map +1 -0
  44. package/dist/jsx/index.js +11 -0
  45. package/dist/jsx/index.js.map +1 -0
  46. package/dist/jsx/index.mjs +11 -0
  47. package/dist/jsx/index.mjs.map +1 -0
  48. package/dist/jsx/index.native.js +38 -0
  49. package/dist/jsx/index.native.js.map +1 -0
  50. package/package.json +63 -0
  51. package/src/Checkbox.tsx +122 -0
  52. package/src/CheckboxStyledContext.tsx +16 -0
  53. package/src/createCheckbox.tsx +280 -0
  54. package/src/index.ts +12 -0
  55. package/types/Checkbox.d.ts +39 -0
  56. package/types/CheckboxStyledContext.d.ts +9 -0
  57. package/types/createCheckbox.d.ts +196 -0
  58. package/types/index.d.ts +324 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2021 Radix
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,111 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all) __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);
21
+ var Checkbox_exports = {};
22
+ __export(Checkbox_exports, {
23
+ CheckboxFrame: () => CheckboxFrame,
24
+ CheckboxIndicatorFrame: () => CheckboxIndicatorFrame
25
+ });
26
+ module.exports = __toCommonJS(Checkbox_exports);
27
+ var import_gui_core = require("@hanzo/gui-core"),
28
+ import_gui_get_token = require("@hanzo/gui-get-token"),
29
+ import_gui_stacks = require("@hanzo/gui-stacks"),
30
+ import_CheckboxStyledContext = require("./CheckboxStyledContext.cjs");
31
+ const INDICATOR_NAME = "CheckboxIndicator",
32
+ CheckboxIndicatorFrame = (0, import_gui_core.styled)(import_gui_stacks.YStack, {
33
+ // use Checkbox for easier themes
34
+ name: INDICATOR_NAME,
35
+ context: import_CheckboxStyledContext.CheckboxStyledContext,
36
+ variants: {
37
+ unstyled: {
38
+ false: {}
39
+ }
40
+ },
41
+ defaultVariants: {
42
+ unstyled: process.env.HANZO_GUI_HEADLESS === "1"
43
+ }
44
+ }, {
45
+ accept: {
46
+ activeStyle: "style"
47
+ }
48
+ }),
49
+ CHECKBOX_NAME = "Checkbox",
50
+ CheckboxFrame = (0, import_gui_core.styled)(import_gui_stacks.YStack, {
51
+ name: CHECKBOX_NAME,
52
+ render: "button",
53
+ context: import_CheckboxStyledContext.CheckboxStyledContext,
54
+ variants: {
55
+ unstyled: {
56
+ false: {
57
+ size: "$true",
58
+ backgroundColor: "$background",
59
+ alignItems: "center",
60
+ justifyContent: "center",
61
+ borderWidth: 1,
62
+ borderColor: "$borderColor",
63
+ hoverStyle: {
64
+ borderColor: "$borderColorHover"
65
+ },
66
+ pressStyle: {
67
+ backgroundColor: "$backgroundPress",
68
+ borderColor: "$borderColorPress"
69
+ },
70
+ focusStyle: {
71
+ borderColor: "$borderColorFocus"
72
+ },
73
+ focusVisibleStyle: {
74
+ outlineStyle: "solid",
75
+ outlineWidth: 2,
76
+ outlineColor: "$outlineColor"
77
+ }
78
+ }
79
+ },
80
+ disabled: {
81
+ true: {
82
+ pointerEvents: "none",
83
+ userSelect: "none",
84
+ cursor: "not-allowed",
85
+ hoverStyle: {
86
+ borderColor: "$borderColor",
87
+ backgroundColor: "$background"
88
+ },
89
+ pressStyle: {
90
+ borderColor: "$borderColor",
91
+ backgroundColor: "$background"
92
+ },
93
+ focusStyle: {
94
+ outlineWidth: 0
95
+ }
96
+ }
97
+ },
98
+ size: {
99
+ "...size": val => ({
100
+ borderRadius: (0, import_gui_core.getVariableValue)((0, import_gui_get_token.getSize)(val)) / 8
101
+ })
102
+ }
103
+ },
104
+ defaultVariants: {
105
+ unstyled: process.env.HANZO_GUI_HEADLESS === "1"
106
+ }
107
+ }, {
108
+ accept: {
109
+ activeStyle: "style"
110
+ }
111
+ });
@@ -0,0 +1,117 @@
1
+ "use strict";
2
+
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __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 __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
21
+ value: !0
22
+ }), mod);
23
+ var Checkbox_exports = {};
24
+ __export(Checkbox_exports, {
25
+ CheckboxFrame: () => CheckboxFrame,
26
+ CheckboxIndicatorFrame: () => CheckboxIndicatorFrame
27
+ });
28
+ module.exports = __toCommonJS(Checkbox_exports);
29
+ var import_gui_core = require("@hanzo/gui-core"),
30
+ import_gui_get_token = require("@hanzo/gui-get-token"),
31
+ import_gui_stacks = require("@hanzo/gui-stacks"),
32
+ import_CheckboxStyledContext = require("./CheckboxStyledContext.native.js"),
33
+ INDICATOR_NAME = "CheckboxIndicator",
34
+ CheckboxIndicatorFrame = (0, import_gui_core.styled)(import_gui_stacks.YStack, {
35
+ // use Checkbox for easier themes
36
+ name: INDICATOR_NAME,
37
+ context: import_CheckboxStyledContext.CheckboxStyledContext,
38
+ variants: {
39
+ unstyled: {
40
+ false: {}
41
+ }
42
+ },
43
+ defaultVariants: {
44
+ unstyled: process.env.HANZO_GUI_HEADLESS === "1"
45
+ }
46
+ }, {
47
+ accept: {
48
+ activeStyle: "style"
49
+ }
50
+ }),
51
+ CHECKBOX_NAME = "Checkbox",
52
+ CheckboxFrame = (0, import_gui_core.styled)(import_gui_stacks.YStack, {
53
+ name: CHECKBOX_NAME,
54
+ render: "button",
55
+ context: import_CheckboxStyledContext.CheckboxStyledContext,
56
+ variants: {
57
+ unstyled: {
58
+ false: {
59
+ size: "$true",
60
+ backgroundColor: "$background",
61
+ alignItems: "center",
62
+ justifyContent: "center",
63
+ borderWidth: 1,
64
+ borderColor: "$borderColor",
65
+ hoverStyle: {
66
+ borderColor: "$borderColorHover"
67
+ },
68
+ pressStyle: {
69
+ backgroundColor: "$backgroundPress",
70
+ borderColor: "$borderColorPress"
71
+ },
72
+ focusStyle: {
73
+ borderColor: "$borderColorFocus"
74
+ },
75
+ focusVisibleStyle: {
76
+ outlineStyle: "solid",
77
+ outlineWidth: 2,
78
+ outlineColor: "$outlineColor"
79
+ }
80
+ }
81
+ },
82
+ disabled: {
83
+ true: {
84
+ pointerEvents: "none",
85
+ userSelect: "none",
86
+ cursor: "not-allowed",
87
+ hoverStyle: {
88
+ borderColor: "$borderColor",
89
+ backgroundColor: "$background"
90
+ },
91
+ pressStyle: {
92
+ borderColor: "$borderColor",
93
+ backgroundColor: "$background"
94
+ },
95
+ focusStyle: {
96
+ outlineWidth: 0
97
+ }
98
+ }
99
+ },
100
+ size: {
101
+ "...size": function (val) {
102
+ var radiusToken = (0, import_gui_core.getVariableValue)((0, import_gui_get_token.getSize)(val)) / 8;
103
+ return {
104
+ borderRadius: radiusToken
105
+ };
106
+ }
107
+ }
108
+ },
109
+ defaultVariants: {
110
+ unstyled: process.env.HANZO_GUI_HEADLESS === "1"
111
+ }
112
+ }, {
113
+ accept: {
114
+ activeStyle: "style"
115
+ }
116
+ });
117
+ //# sourceMappingURL=Checkbox.native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","Checkbox_exports","__export","CheckboxFrame","CheckboxIndicatorFrame","module","exports","import_gui_core","require","import_gui_get_token","import_gui_stacks","import_CheckboxStyledContext","INDICATOR_NAME","styled","YStack","name","context","CheckboxStyledContext","variants","unstyled","false","defaultVariants","process","env","HANZO_GUI_HEADLESS","accept","activeStyle","CHECKBOX_NAME","render","size","backgroundColor","alignItems","justifyContent","borderWidth","borderColor","hoverStyle","pressStyle","focusStyle","focusVisibleStyle","outlineStyle","outlineWidth","outlineColor","disabled","true","pointerEvents","userSelect","cursor","...size","val","radiusToken","getVariableValue","getSize","borderRadius"],"sources":["../../src/Checkbox.tsx"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,gBAAA;AAAAC,QAAA,CAAAD,gBAAA;EAAAE,aAAA,EAAAA,CAAA,KAAAA,aAAA;EAAAC,sBAAA,EAAAA,CAAA,KAAAA;AAAA;AAGAC,MAAA,CAAAC,OAAA,GAAAV,YAAyC,CAAAK,gBAAA;AASzC,IAAAM,eAAM,GAAAC,OAAiB,kBAEV;EAAAC,oBAAA,GAAyBD,OAAA;EAAAE,iBAAA,GAAAF,OAAA;EAAAG,4BAAA,GAAAH,OAAA;EAAAI,cAAA;EAAAR,sBAAA,OAAAG,eAAA,CAAAM,MAAA,EAAAH,iBAAA,CAAAI,MAAA;IACpC;IACAC,IAAA,EAAAH,cAAA;IAAAI,OAAA,EAAAL,4BAAA,CAAAM,qBAAA;IAAAC,QAEQ;MACNC,QAAA,EAAS;QACTC,KAAA,GAAU;MAAA;IACE;IACAC,eACV;MACFF,QAAA,EAAAG,OAAA,CAAAC,GAAA,CAAAC,kBAAA;IAAA;EACiB;IAC8BC,MAC/C;MACFC,WAAA;IACA;EAAA;EACEC,aAAQ;EAAAxB,aAAA,OAAAI,eAAA,CAAAM,MAAA,EAAAH,iBAAA,CAAAI,MAAA;IAAAC,IACN,EAAAY,aAAa;IAAAC,MACf;IACFZ,OAAA,EAAAL,4BAAA,CAAAM,qBAAA;IACFC,QAMM;MAGJC,QAAA;QACAC,KAAA;UACES,IAAM;UACNC,eAAQ;UAERC,UAAS;UACTC,cAAU;UACRC,WAAU;UACRC,WAAO;UAAAC,UACC;YACND,WAAA;UAAiB;UACLE,UACZ;YACAN,eAAa;YACbI,WAAA,EAAa;UAAA;UAEDG,UACV;YACFH,WAAA;UAAA;UAEYI,iBACV;YAAiBC,YACjB,SAAa;YACfC,YAAA;YAEAC,YAAY;UAAA;QACG;MACf;MAEmBC,QACjB;QAAcC,IAAA,EACd;UAAcC,aACd,QAAc;UAAAC,UAChB;UACFC,MAAA;UACFX,UAAA;YAEAD,WAAU;YACRJ,eAAM;UAAA;UACWM,UACf;YACAF,WAAQ;YAERJ,eAAY;UAAA;UACGO,UACb;YACFG,YAAA;UAAA;QAEY;MACG;MACIX,IAAA,EACnB;QAAA,SAEA,WAAAkB,CAAYC,GAAA;UAAA,IACVC,WAAA,GAAc,IAAA1C,eAAA,CAAA2C,gBAAA,MAAAzC,oBAAA,CAAA0C,OAAA,EAAAH,GAAA;UAAA,OAChB;YACFI,YAAA,EAAAH;UACF;QAEA;MAAM;IAGK;IAD8C5B,eAGrD;MAAAF,QAEJ,EAAAG,OAAA,CAAAC,GAAA,CAAAC,kBAAA;IAAA;EACF;IAEiBC,MACf;MACFC,WAAA;IACF;EAAA,EACA","ignoreList":[]}
@@ -0,0 +1,33 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all) __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);
21
+ var CheckboxStyledContext_exports = {};
22
+ __export(CheckboxStyledContext_exports, {
23
+ CheckboxStyledContext: () => CheckboxStyledContext
24
+ });
25
+ module.exports = __toCommonJS(CheckboxStyledContext_exports);
26
+ var import_gui_core = require("@hanzo/gui-core");
27
+ const CheckboxStyledContext = (0, import_gui_core.createStyledContext)({
28
+ size: "$true",
29
+ scaleIcon: 1,
30
+ unstyled: process.env.HANZO_GUI_HEADLESS === "1",
31
+ active: !1,
32
+ disabled: !1
33
+ });
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __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 __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
21
+ value: !0
22
+ }), mod);
23
+ var CheckboxStyledContext_exports = {};
24
+ __export(CheckboxStyledContext_exports, {
25
+ CheckboxStyledContext: () => CheckboxStyledContext
26
+ });
27
+ module.exports = __toCommonJS(CheckboxStyledContext_exports);
28
+ var import_gui_core = require("@hanzo/gui-core"),
29
+ CheckboxStyledContext = (0, import_gui_core.createStyledContext)({
30
+ size: "$true",
31
+ scaleIcon: 1,
32
+ unstyled: process.env.HANZO_GUI_HEADLESS === "1",
33
+ active: !1,
34
+ disabled: !1
35
+ });
36
+ //# sourceMappingURL=CheckboxStyledContext.native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","CheckboxStyledContext_exports","__export","CheckboxStyledContext","module","exports","import_gui_core","require","createStyledContext","size","scaleIcon","unstyled","process","env","HANZO_GUI_HEADLESS","active","disabled"],"sources":["../../src/CheckboxStyledContext.tsx"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,6BAAA;AAAAC,QAAA,CAAAD,6BAAA;EAAAE,qBAAA,EAAAA,CAAA,KAAAA;AAAA;AACAC,MAAA,CAAAC,OAAA,GAAAT,YAAoC,CAAAK,6BAAA;AAE7B,IAAAK,eAAM,GAAAC,OAAA,kBAAwB;EAAAJ,qBAMlC,OAAAG,eAAA,CAAAE,mBAAA;IACDC,IAAA,EAAM;IACNC,SAAA,EAAW;IACXC,QAAA,EAAUC,OAAA,CAAQC,GAAA,CAAIC,kBAAA,KAAuB;IAC7CC,MAAA,EAAQ;IACRC,QAAA,EAAU;EACZ,CAAC","ignoreList":[]}
@@ -0,0 +1,184 @@
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 createCheckbox_exports = {};
33
+ __export(createCheckbox_exports, {
34
+ CheckboxContext: () => CheckboxContext,
35
+ createCheckbox: () => createCheckbox
36
+ });
37
+ module.exports = __toCommonJS(createCheckbox_exports);
38
+ var import_gui_checkbox_headless = require("@hanzo/gui-checkbox-headless"),
39
+ import_gui_core = require("@hanzo/gui-core"),
40
+ import_gui_focusable = require("@hanzo/gui-focusable"),
41
+ import_gui_font_size = require("@hanzo/gui-font-size"),
42
+ import_gui_get_token = require("@hanzo/gui-get-token"),
43
+ import_gui_helpers = require("@hanzo/gui-helpers"),
44
+ import_gui_use_controllable_state = require("@hanzo/gui-use-controllable-state"),
45
+ import_react = __toESM(require("react"), 1),
46
+ import_Checkbox = require("./Checkbox.cjs"),
47
+ import_CheckboxStyledContext = require("./CheckboxStyledContext.cjs"),
48
+ import_jsx_runtime = require("react/jsx-runtime");
49
+ const CheckboxContext = import_react.default.createContext({
50
+ checked: !1,
51
+ disabled: !1
52
+ }),
53
+ ensureContext = x => {
54
+ x.context || (x.context = CheckboxContext);
55
+ };
56
+ function createCheckbox(createProps) {
57
+ const {
58
+ Frame = import_Checkbox.CheckboxFrame,
59
+ Indicator = import_Checkbox.CheckboxIndicatorFrame
60
+ } = createProps;
61
+ ensureContext(Frame), ensureContext(Indicator);
62
+ const FrameComponent = Frame.styleable(function (_props, forwardedRef) {
63
+ const {
64
+ scaleSize = 0.45,
65
+ sizeAdjust = 0,
66
+ scaleIcon,
67
+ checked: checkedProp,
68
+ defaultChecked,
69
+ onCheckedChange,
70
+ native,
71
+ unstyled = !1,
72
+ activeStyle,
73
+ activeTheme,
74
+ ...props
75
+ } = _props,
76
+ propsActive = (0, import_gui_core.useProps)(props),
77
+ styledContext = import_react.default.useContext(import_CheckboxStyledContext.CheckboxStyledContext.context);
78
+ let adjustedSize = 0,
79
+ size = 0;
80
+ unstyled || (adjustedSize = (0, import_gui_core.getVariableValue)((0, import_gui_get_token.getSize)(propsActive.size ?? styledContext?.size ?? "$true", {
81
+ shift: sizeAdjust
82
+ })), size = scaleSize ? Math.round(adjustedSize * scaleSize) : adjustedSize);
83
+ const [checked = !1, setChecked] = (0, import_gui_use_controllable_state.useControllableState)({
84
+ prop: checkedProp,
85
+ defaultProp: defaultChecked,
86
+ onChange: onCheckedChange
87
+ }),
88
+ {
89
+ checkboxProps,
90
+ checkboxRef,
91
+ bubbleInput
92
+ } = (0, import_gui_checkbox_headless.useCheckbox)(
93
+ // @ts-ignore
94
+ propsActive, [checked, setChecked], forwardedRef);
95
+ if ((0, import_gui_core.shouldRenderNativePlatform)(native) === "web") return /* @__PURE__ */(0, import_jsx_runtime.jsx)("input", {
96
+ type: "checkbox",
97
+ defaultChecked: (0, import_gui_checkbox_headless.isIndeterminate)(checked) ? !1 : checked,
98
+ tabIndex: -1,
99
+ ref: checkboxRef,
100
+ disabled: checkboxProps.disabled,
101
+ style: {
102
+ appearance: "auto",
103
+ accentColor: "var(--color6)",
104
+ ...checkboxProps.style
105
+ }
106
+ });
107
+ const memoizedContext = (0, import_react.useMemo)(() => ({
108
+ checked,
109
+ disabled: checkboxProps.disabled
110
+ }), [checked, checkboxProps.disabled]),
111
+ isActive = !!checked,
112
+ disabled = checkboxProps.disabled;
113
+ return /* @__PURE__ */(0, import_jsx_runtime.jsx)(CheckboxContext.Provider, {
114
+ value: memoizedContext,
115
+ children: /* @__PURE__ */(0, import_jsx_runtime.jsxs)(import_CheckboxStyledContext.CheckboxStyledContext.Provider, {
116
+ size: propsActive.size ?? styledContext?.size ?? "$true",
117
+ scaleIcon: scaleIcon ?? styledContext?.scaleIcon ?? 1,
118
+ unstyled,
119
+ active: isActive,
120
+ disabled,
121
+ children: [/* @__PURE__ */(0, import_jsx_runtime.jsx)(Frame, {
122
+ render: "button",
123
+ ref: checkboxRef,
124
+ unstyled,
125
+ theme: activeTheme ?? null,
126
+ ...(import_gui_core.isWeb && {
127
+ type: "button"
128
+ }),
129
+ ...(!unstyled && {
130
+ width: size,
131
+ height: size,
132
+ size
133
+ }),
134
+ checked,
135
+ disabled,
136
+ ...checkboxProps,
137
+ ...props,
138
+ ...(isActive && {
139
+ ...(!unstyled && !activeStyle && {
140
+ backgroundColor: "$backgroundActive"
141
+ }),
142
+ ...activeStyle
143
+ }),
144
+ children: propsActive.children
145
+ }), bubbleInput]
146
+ })
147
+ });
148
+ }),
149
+ IndicatorComponent = Indicator.styleable((props, forwardedRef) => {
150
+ const {
151
+ children: childrenProp,
152
+ forceMount,
153
+ disablePassStyles,
154
+ unstyled = !1,
155
+ activeStyle,
156
+ ...indicatorProps
157
+ } = props,
158
+ styledContext = import_CheckboxStyledContext.CheckboxStyledContext.useStyledContext(),
159
+ {
160
+ active
161
+ } = styledContext;
162
+ let children = childrenProp;
163
+ if (!unstyled) {
164
+ const iconSize = (typeof styledContext.size == "number" ? styledContext.size * 0.65 : (0, import_gui_font_size.getFontSize)(styledContext.size)) * styledContext.scaleIcon,
165
+ theme = (0, import_gui_core.useTheme)(),
166
+ getThemedIcon = (0, import_gui_helpers.useGetThemedIcon)({
167
+ size: iconSize,
168
+ color: theme.color
169
+ });
170
+ children = import_react.default.Children.toArray(childrenProp).map(child => disablePassStyles || !import_react.default.isValidElement(child) ? child : getThemedIcon(child));
171
+ }
172
+ const context = import_react.default.useContext(CheckboxContext);
173
+ return forceMount || (0, import_gui_checkbox_headless.isIndeterminate)(context.checked) || context.checked === !0 ? /* @__PURE__ */(0, import_jsx_runtime.jsx)(Indicator, {
174
+ pointerEvents: "none",
175
+ ...indicatorProps,
176
+ ...(active && activeStyle),
177
+ ref: forwardedRef,
178
+ children
179
+ }) : null;
180
+ });
181
+ return (0, import_gui_core.withStaticProperties)(FrameComponent, {
182
+ Indicator: IndicatorComponent
183
+ });
184
+ }