@hanzogui/tabs 7.0.0 → 7.3.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 (59) hide show
  1. package/LICENSE +42 -21
  2. package/dist/cjs/StyledContext.cjs +33 -0
  3. package/dist/cjs/StyledContext.native.js +36 -0
  4. package/dist/cjs/StyledContext.native.js.map +1 -0
  5. package/dist/cjs/Tabs.cjs +83 -0
  6. package/dist/cjs/Tabs.native.js +86 -0
  7. package/dist/cjs/Tabs.native.js.map +1 -0
  8. package/dist/cjs/createTabs.cjs +293 -0
  9. package/dist/cjs/createTabs.native.js +308 -0
  10. package/dist/cjs/createTabs.native.js.map +1 -0
  11. package/dist/cjs/index.cjs +37 -0
  12. package/dist/cjs/index.native.js +40 -0
  13. package/dist/cjs/index.native.js.map +1 -0
  14. package/dist/esm/StyledContext.mjs +7 -0
  15. package/dist/esm/StyledContext.mjs.map +1 -0
  16. package/dist/esm/StyledContext.native.js +7 -0
  17. package/dist/esm/StyledContext.native.js.map +1 -0
  18. package/dist/esm/Tabs.mjs +56 -0
  19. package/dist/esm/Tabs.mjs.map +1 -0
  20. package/dist/esm/Tabs.native.js +56 -0
  21. package/dist/esm/Tabs.native.js.map +1 -0
  22. package/dist/esm/createTabs.mjs +257 -0
  23. package/dist/esm/createTabs.mjs.map +1 -0
  24. package/dist/esm/createTabs.native.js +269 -0
  25. package/dist/esm/createTabs.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/StyledContext.mjs +7 -0
  33. package/dist/jsx/StyledContext.mjs.map +1 -0
  34. package/dist/jsx/StyledContext.native.js +36 -0
  35. package/dist/jsx/StyledContext.native.js.map +1 -0
  36. package/dist/jsx/Tabs.mjs +56 -0
  37. package/dist/jsx/Tabs.mjs.map +1 -0
  38. package/dist/jsx/Tabs.native.js +86 -0
  39. package/dist/jsx/Tabs.native.js.map +1 -0
  40. package/dist/jsx/createTabs.mjs +257 -0
  41. package/dist/jsx/createTabs.mjs.map +1 -0
  42. package/dist/jsx/createTabs.native.js +308 -0
  43. package/dist/jsx/createTabs.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 +40 -0
  49. package/dist/jsx/index.native.js.map +1 -0
  50. package/package.json +24 -22
  51. package/src/Tabs.tsx +1 -1
  52. package/src/createTabs.tsx +5 -5
  53. package/types/StyledContext.d.ts.map +1 -0
  54. package/types/Tabs.d.ts +5 -5
  55. package/types/Tabs.d.ts.map +1 -0
  56. package/types/createTabs.d.ts +73 -73
  57. package/types/createTabs.d.ts.map +1 -0
  58. package/types/index.d.ts +83 -83
  59. package/types/index.d.ts.map +1 -0
package/LICENSE CHANGED
@@ -1,21 +1,42 @@
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.
1
+ BSD 3-Clause License
2
+
3
+ Copyright (c) 2026-present, Hanzo AI, Inc.
4
+
5
+ Portions of this software are derived from upstream code originally licensed under
6
+ the MIT License, with the following copyright notices retained per its terms:
7
+
8
+ Copyright (c) 2020 Nate Wienert
9
+ Copyright (c) 2015-present, Nicolas Gallagher.
10
+ Copyright (c) 2015-present, Facebook, Inc.
11
+ Copyright (c) 2021 Radix
12
+ Copyright (c) 2017 Carmelo Pullara
13
+ Copyright (c) 2018 Framer B.V.
14
+ Copyright (c) 2022 WorkOS
15
+
16
+ All rights reserved.
17
+
18
+ Redistribution and use in source and binary forms, with or without
19
+ modification, are permitted provided that the following conditions are met:
20
+
21
+ 1. Redistributions of source code must retain the above copyright notice, this
22
+ list of conditions and the following disclaimer.
23
+
24
+ 2. Redistributions in binary form must reproduce the above copyright notice,
25
+ this list of conditions and the following disclaimer in the documentation
26
+ and/or other materials provided with the distribution.
27
+
28
+ 3. Neither the name of the copyright holder nor the names of its contributors
29
+ may be used to endorse or promote products derived from this software
30
+ without specific prior written permission.
31
+
32
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
33
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
34
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
35
+ ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
36
+ LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
37
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
38
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
39
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
40
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
41
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
42
+ POSSIBILITY OF SUCH DAMAGE.
@@ -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: true
9
+ });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
14
+ get: () => from[key],
15
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
16
+ });
17
+ }
18
+ return to;
19
+ };
20
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
21
+ value: true
22
+ }), mod);
23
+ var StyledContext_exports = {};
24
+ __export(StyledContext_exports, {
25
+ TabsProvider: () => TabsProvider,
26
+ useTabsContext: () => useTabsContext
27
+ });
28
+ module.exports = __toCommonJS(StyledContext_exports);
29
+ var import_core = require("@hanzogui/core");
30
+ const {
31
+ Provider: TabsProvider,
32
+ useStyledContext: useTabsContext
33
+ } = (0, import_core.createStyledContext)();
@@ -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: 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, {
16
+ get: () => from[key],
17
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
18
+ });
19
+ }
20
+ return to;
21
+ };
22
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
23
+ value: true
24
+ }), mod);
25
+ var StyledContext_exports = {};
26
+ __export(StyledContext_exports, {
27
+ TabsProvider: () => TabsProvider,
28
+ useTabsContext: () => useTabsContext
29
+ });
30
+ module.exports = __toCommonJS(StyledContext_exports);
31
+ var import_core = require("@hanzogui/core");
32
+ var {
33
+ Provider: TabsProvider,
34
+ useStyledContext: useTabsContext
35
+ } = (0, import_core.createStyledContext)();
36
+ //# sourceMappingURL=StyledContext.native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","StyledContext_exports","__export","TabsProvider","useTabsContext","module","exports","import_core","require"],"sources":["../../src/StyledContext.tsx"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,qBAAA;AAAAC,QAAA,CAAAD,qBAAA;EAAAE,YAAA,EAAAA,CAAA,KAAAA,YAAA;EAAAC,cAAA,EAAAA,CAAA,KAAAA;AAAA;AACAC,MAAA,CAAAC,OAAA,GAAAV,YAAoC,CAAAK,qBAAA;AAgB7B,IAAAM,WAAQ,GAAUC,OAAA,iBAAc","ignoreList":[]}
@@ -0,0 +1,83 @@
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: true
9
+ });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
14
+ get: () => from[key],
15
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
16
+ });
17
+ }
18
+ return to;
19
+ };
20
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
21
+ value: true
22
+ }), mod);
23
+ var Tabs_exports = {};
24
+ __export(Tabs_exports, {
25
+ DefaultTabsContentFrame: () => DefaultTabsContentFrame,
26
+ DefaultTabsFrame: () => DefaultTabsFrame,
27
+ DefaultTabsTabFrame: () => DefaultTabsTabFrame
28
+ });
29
+ module.exports = __toCommonJS(Tabs_exports);
30
+ var import_core = require("@hanzogui/core");
31
+ var import_get_button_sized = require("@hanzogui/get-button-sized");
32
+ var import_stacks = require("@hanzogui/stacks");
33
+ const TABS_NAME = "Tabs";
34
+ const DefaultTabsFrame = (0, import_core.styled)(import_stacks.SizableStack, {
35
+ name: TABS_NAME
36
+ });
37
+ const TRIGGER_NAME = "TabsTrigger";
38
+ const DefaultTabsTabFrame = (0, import_core.styled)(import_core.View, {
39
+ name: TRIGGER_NAME,
40
+ role: "tab",
41
+ variants: {
42
+ size: {
43
+ "...size": import_get_button_sized.getButtonSized
44
+ },
45
+ disabled: {
46
+ true: {
47
+ pointerEvents: "none"
48
+ }
49
+ },
50
+ unstyled: {
51
+ false: {
52
+ borderWidth: 0,
53
+ backgroundColor: "$background",
54
+ userSelect: "none",
55
+ justifyContent: "center",
56
+ alignItems: "center",
57
+ flexWrap: "nowrap",
58
+ flexDirection: "row",
59
+ cursor: "pointer",
60
+ pressStyle: {
61
+ backgroundColor: "$backgroundPress"
62
+ },
63
+ focusVisibleStyle: {
64
+ outlineColor: "$outlineColor",
65
+ outlineWidth: 2,
66
+ outlineStyle: "solid",
67
+ zIndex: 10
68
+ }
69
+ }
70
+ }
71
+ },
72
+ defaultVariants: {
73
+ unstyled: process.env.GUI_HEADLESS === "1"
74
+ }
75
+ }, {
76
+ accept: {
77
+ activeStyle: "style"
78
+ }
79
+ });
80
+ const CONTENT_NAME = "TabsContent";
81
+ const DefaultTabsContentFrame = (0, import_core.styled)(import_stacks.ThemeableStack, {
82
+ name: CONTENT_NAME
83
+ });
@@ -0,0 +1,86 @@
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: 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, {
16
+ get: () => from[key],
17
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
18
+ });
19
+ }
20
+ return to;
21
+ };
22
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
23
+ value: true
24
+ }), mod);
25
+ var Tabs_exports = {};
26
+ __export(Tabs_exports, {
27
+ DefaultTabsContentFrame: () => DefaultTabsContentFrame,
28
+ DefaultTabsFrame: () => DefaultTabsFrame,
29
+ DefaultTabsTabFrame: () => DefaultTabsTabFrame
30
+ });
31
+ module.exports = __toCommonJS(Tabs_exports);
32
+ var import_core = require("@hanzogui/core");
33
+ var import_get_button_sized = require("@hanzogui/get-button-sized");
34
+ var import_stacks = require("@hanzogui/stacks");
35
+ var TABS_NAME = "Tabs";
36
+ var DefaultTabsFrame = (0, import_core.styled)(import_stacks.SizableStack, {
37
+ name: TABS_NAME
38
+ });
39
+ var TRIGGER_NAME = "TabsTrigger";
40
+ var DefaultTabsTabFrame = (0, import_core.styled)(import_core.View, {
41
+ name: TRIGGER_NAME,
42
+ role: "tab",
43
+ variants: {
44
+ size: {
45
+ "...size": import_get_button_sized.getButtonSized
46
+ },
47
+ disabled: {
48
+ true: {
49
+ pointerEvents: "none"
50
+ }
51
+ },
52
+ unstyled: {
53
+ false: {
54
+ borderWidth: 0,
55
+ backgroundColor: "$background",
56
+ userSelect: "none",
57
+ justifyContent: "center",
58
+ alignItems: "center",
59
+ flexWrap: "nowrap",
60
+ flexDirection: "row",
61
+ cursor: "pointer",
62
+ pressStyle: {
63
+ backgroundColor: "$backgroundPress"
64
+ },
65
+ focusVisibleStyle: {
66
+ outlineColor: "$outlineColor",
67
+ outlineWidth: 2,
68
+ outlineStyle: "solid",
69
+ zIndex: 10
70
+ }
71
+ }
72
+ }
73
+ },
74
+ defaultVariants: {
75
+ unstyled: process.env.GUI_HEADLESS === "1"
76
+ }
77
+ }, {
78
+ accept: {
79
+ activeStyle: "style"
80
+ }
81
+ });
82
+ var CONTENT_NAME = "TabsContent";
83
+ var DefaultTabsContentFrame = (0, import_core.styled)(import_stacks.ThemeableStack, {
84
+ name: CONTENT_NAME
85
+ });
86
+ //# sourceMappingURL=Tabs.native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","Tabs_exports","__export","DefaultTabsContentFrame","DefaultTabsFrame","DefaultTabsTabFrame","module","exports","import_core","require","import_get_button_sized","import_stacks","TABS_NAME","styled","SizableStack","name","TRIGGER_NAME","View","role","variants","size","getButtonSized","disabled","true","pointerEvents","unstyled","false","borderWidth","backgroundColor","userSelect","justifyContent","alignItems","flexWrap","flexDirection","cursor","pressStyle","focusVisibleStyle","outlineColor","outlineWidth","outlineStyle","zIndex","defaultVariants","process","env","GUI_HEADLESS","accept","activeStyle","CONTENT_NAME","ThemeableStack"],"sources":["../../src/Tabs.tsx"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,YAAA;AAAAC,QAAA,CAAAD,YAAA;EAAAE,uBAAA,EAAAA,CAAA,KAAAA,uBAAA;EAAAC,gBAAA,EAAAA,CAAA,KAAAA,gBAAA;EAAAC,mBAAA,EAAAA,CAAA,KAAAA;AAAA;AAAAC,MAAA,CAAAC,OAAA,GAAAX,YAA6B,CAAAK,YAAA;AAC7B,IAAAO,WAAA,GAAAC,OAAA,iBAA+B;AAC/B,IAAAC,uBAA6C,GAAAD,OAAA;AAE7C,IAAAE,aAAM,GAAYF,OAAA;AACX,IAAAG,SAAM;AAAwC,IACnDR,gBAAM,OAAAI,WAAA,CAAAK,MAAA,EAAAF,aAAA,CAAAG,YAAA;EACPC,IAAA,EAAAH;AAED;AAEO,IAAAI,YAAM,gBAAsB;AAAA,IACjCX,mBAAA,OAAAG,WAAA,CAAAK,MAAA,EAAAL,WAAA,CAAAS,IAAA;EACAF,IAAA,EAAAC,YAAA;EAAAE,IACE,OAAM;EAAAC,QACA;IAENC,IAAA;MACE,SAAM,EAAAV,uBAAA,CAAAW;IAAA;IACOC,QACb;MAEAC,IAAA;QACEC,aAAM;MAAA;IACW;IACjBC,QACF;MAEAC,KAAA;QACEC,WAAO;QAAAC,eACQ;QAAAC,UACb;QAAiBC,cACL;QAAAC,UACZ,UAAgB;QAAAC,QAChB,UAAY;QAAAC,aACF;QAAAC,MACV,WAAe;QAAAC,UACP;UAERP,eAAY;QAAA;QACOQ,iBACnB;UAEAC,YAAA,iBAAmB;UAAAC,YACjB;UAAcC,YACd,SAAc;UAAAC,MACd;QAAc;MACN;IACV;EACF;EACFC,eACF;IAEAhB,QAAA,EAAAiB,OAAiB,CAAAC,GAAA,CAAAC,YAAA;EAAA;AACwB;EAE3CC,MAAA;IACAC,WAAA;EAAA;AACU;AACO,IACfC,YAAA;AAAA,IACF5C,uBAAA,OAAAK,WAAA,CAAAK,MAAA,EAAAF,aAAA,CAAAqC,cAAA;EACFjC,IAAA,EAAAgC;AAEA","ignoreList":[]}
@@ -0,0 +1,293 @@
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
+ 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: 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, {
16
+ get: () => from[key],
17
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
18
+ });
19
+ }
20
+ return to;
21
+ };
22
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
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);
34
+ var createTabs_exports = {};
35
+ __export(createTabs_exports, {
36
+ createTabs: () => createTabs
37
+ });
38
+ module.exports = __toCommonJS(createTabs_exports);
39
+ var import_compose_refs = require("@hanzogui/compose-refs");
40
+ var import_constants = require("@hanzogui/constants");
41
+ var import_group = require("@hanzogui/group");
42
+ var import_helpers = require("@hanzogui/helpers");
43
+ var import_roving_focus = require("@hanzogui/roving-focus");
44
+ var import_sizable_context = require("@hanzogui/sizable-context");
45
+ var import_use_controllable_state = require("@hanzogui/use-controllable-state");
46
+ var import_use_direction = require("@hanzogui/use-direction");
47
+ var import_web = require("@hanzogui/web");
48
+ var React = __toESM(require("react"), 1);
49
+ var import_StyledContext = require("./StyledContext.cjs");
50
+ var import_Tabs = require("./Tabs.cjs");
51
+ var import_jsx_runtime = require("react/jsx-runtime");
52
+ function createTabs(createProps) {
53
+ const {
54
+ ContentFrame = import_Tabs.DefaultTabsContentFrame,
55
+ TabFrame = import_Tabs.DefaultTabsTabFrame,
56
+ TabsFrame = import_Tabs.DefaultTabsFrame
57
+ } = createProps;
58
+ const TABS_CONTEXT = "TabsContext";
59
+ const TAB_LIST_NAME = "TabsList";
60
+ const TabsList = React.forwardRef((props, forwardedRef) => {
61
+ const {
62
+ __scopeTabs,
63
+ loop = true,
64
+ children,
65
+ ...listProps
66
+ } = props;
67
+ const context = (0, import_StyledContext.useTabsContext)(__scopeTabs);
68
+ return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_roving_focus.RovingFocusGroup, {
69
+ __scopeRovingFocusGroup: __scopeTabs || TABS_CONTEXT,
70
+ orientation: context.orientation,
71
+ dir: context.dir,
72
+ loop,
73
+ asChild: true,
74
+ children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_group.Group, {
75
+ role: "tablist",
76
+ componentName: TAB_LIST_NAME,
77
+ "aria-orientation": context.orientation,
78
+ ref: forwardedRef,
79
+ orientation: context.orientation,
80
+ ...listProps,
81
+ children
82
+ })
83
+ });
84
+ });
85
+ TabsList.displayName = TAB_LIST_NAME;
86
+ const TRIGGER_NAME = "TabsTrigger";
87
+ const TabsTrigger = TabFrame.styleable((props, forwardedRef) => {
88
+ const {
89
+ __scopeTabs,
90
+ value,
91
+ disabled = false,
92
+ onInteraction,
93
+ activeStyle,
94
+ activeTheme,
95
+ unstyled = false,
96
+ ...triggerProps
97
+ } = props;
98
+ const context = (0, import_StyledContext.useTabsContext)(__scopeTabs);
99
+ const triggerId = makeTriggerId(context.baseId, value);
100
+ const contentId = makeContentId(context.baseId, value);
101
+ const isSelected = value === context.value;
102
+ const [layout, setLayout] = React.useState(null);
103
+ const triggerRef = React.useRef(null);
104
+ const groupItemProps = (0, import_group.useGroupItem)({
105
+ disabled: !!disabled
106
+ });
107
+ React.useEffect(() => {
108
+ context.registerTrigger();
109
+ return () => context.unregisterTrigger();
110
+ }, []);
111
+ React.useEffect(() => {
112
+ if (!triggerRef.current || !import_constants.isWeb) return;
113
+ const el = triggerRef.current;
114
+ function getTriggerSize() {
115
+ if (!el) return;
116
+ setLayout({
117
+ width: el.offsetWidth,
118
+ height: el.offsetHeight,
119
+ x: el.offsetLeft,
120
+ y: el.offsetTop
121
+ });
122
+ }
123
+ getTriggerSize();
124
+ const observer = new ResizeObserver(getTriggerSize);
125
+ observer.observe(el);
126
+ return () => {
127
+ observer.disconnect();
128
+ };
129
+ }, [context.triggersCount]);
130
+ React.useEffect(() => {
131
+ if (isSelected && layout) {
132
+ onInteraction?.("select", layout);
133
+ }
134
+ }, [isSelected, value, layout]);
135
+ return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_roving_focus.RovingFocusGroup.Item, {
136
+ __scopeRovingFocusGroup: __scopeTabs || TABS_CONTEXT,
137
+ asChild: true,
138
+ focusable: !disabled,
139
+ active: isSelected,
140
+ children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(TabFrame, {
141
+ ...(!import_constants.isWeb && {
142
+ onLayout: event => {
143
+ setLayout(event.nativeEvent.layout);
144
+ }
145
+ }),
146
+ onMouseEnter: (0, import_helpers.composeEventHandlers)(props.onMouseEnter, () => {
147
+ if (layout) {
148
+ onInteraction?.("hover", layout);
149
+ }
150
+ }),
151
+ onMouseLeave: (0, import_helpers.composeEventHandlers)(props.onMouseLeave, () => {
152
+ onInteraction?.("hover", null);
153
+ }),
154
+ role: "tab",
155
+ "aria-selected": isSelected,
156
+ "aria-controls": contentId,
157
+ "data-state": isSelected ? "active" : "inactive",
158
+ "data-disabled": disabled ? "" : void 0,
159
+ id: triggerId,
160
+ theme: activeTheme ?? null,
161
+ unstyled,
162
+ ...(!unstyled && {
163
+ size: context.size
164
+ }),
165
+ ...(isSelected && {
166
+ ...(!unstyled && !activeStyle && {
167
+ backgroundColor: "$backgroundActive"
168
+ }),
169
+ ...activeStyle
170
+ }),
171
+ ...groupItemProps,
172
+ disabled: disabled ?? groupItemProps.disabled,
173
+ ...triggerProps,
174
+ ref: (0, import_compose_refs.composeRefs)(forwardedRef, triggerRef),
175
+ onPress: (0, import_helpers.composeEventHandlers)(props.onPress ?? void 0, event => {
176
+ const webChecks = !import_constants.isWeb || event.button === 0 && event.ctrlKey === false;
177
+ if (!disabled && !isSelected && webChecks) {
178
+ context.onChange(value);
179
+ }
180
+ }),
181
+ ...(import_constants.isWeb && {
182
+ onKeyDown: (0, import_helpers.composeEventHandlers)(props.onKeyDown, event => {
183
+ if ([" ", "Enter"].includes(event.key)) {
184
+ context.onChange(value);
185
+ event.preventDefault();
186
+ }
187
+ }),
188
+ onFocus: (0, import_helpers.composeEventHandlers)(props.onFocus, event => {
189
+ if (layout) {
190
+ onInteraction?.("focus", layout);
191
+ }
192
+ const isAutomaticActivation = context.activationMode !== "manual";
193
+ if (!isSelected && !disabled && isAutomaticActivation) {
194
+ context.onChange(value);
195
+ }
196
+ }),
197
+ onBlur: (0, import_helpers.composeEventHandlers)(props.onBlur, () => {
198
+ onInteraction?.("focus", null);
199
+ })
200
+ })
201
+ })
202
+ });
203
+ });
204
+ TabsTrigger.displayName = TRIGGER_NAME;
205
+ const TabsContent = ContentFrame.styleable(function TabsContent2(props, forwardedRef) {
206
+ const {
207
+ __scopeTabs,
208
+ value,
209
+ forceMount,
210
+ children,
211
+ ...contentProps
212
+ } = props;
213
+ const context = (0, import_StyledContext.useTabsContext)(__scopeTabs);
214
+ const isSelected = value === context.value;
215
+ const show = forceMount || isSelected;
216
+ const triggerId = makeTriggerId(context.baseId, value);
217
+ const contentId = makeContentId(context.baseId, value);
218
+ if (!show) {
219
+ return null;
220
+ }
221
+ return /* @__PURE__ */(0, import_jsx_runtime.jsx)(ContentFrame, {
222
+ "data-state": isSelected ? "active" : "inactive",
223
+ "data-orientation": context.orientation,
224
+ role: "tabpanel",
225
+ "aria-labelledby": triggerId,
226
+ hidden: !show,
227
+ id: contentId,
228
+ tabIndex: 0,
229
+ ...contentProps,
230
+ ref: forwardedRef,
231
+ children
232
+ }, value);
233
+ });
234
+ const TabsComponent = TabsFrame.styleable(function Tabs(props, forwardedRef) {
235
+ const {
236
+ __scopeTabs,
237
+ value: valueProp,
238
+ onValueChange,
239
+ defaultValue,
240
+ orientation = "horizontal",
241
+ dir,
242
+ activationMode = "manual",
243
+ size = "$true",
244
+ ...tabsProps
245
+ } = props;
246
+ const direction = (0, import_use_direction.useDirection)(dir);
247
+ const [value, setValue] = (0, import_use_controllable_state.useControllableState)({
248
+ prop: valueProp,
249
+ onChange: onValueChange,
250
+ defaultProp: defaultValue ?? ""
251
+ });
252
+ const [triggersCount, setTriggersCount] = React.useState(0);
253
+ const registerTrigger = (0, import_web.useEvent)(() => setTriggersCount(v => v + 1));
254
+ const unregisterTrigger = (0, import_web.useEvent)(() => setTriggersCount(v => v - 1));
255
+ return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_sizable_context.SizableContext.Provider, {
256
+ size,
257
+ children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_StyledContext.TabsProvider, {
258
+ scope: __scopeTabs,
259
+ baseId: React.useId(),
260
+ value,
261
+ onChange: setValue,
262
+ orientation,
263
+ dir: direction,
264
+ activationMode,
265
+ size,
266
+ registerTrigger,
267
+ triggersCount,
268
+ unregisterTrigger,
269
+ children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(TabsFrame, {
270
+ direction,
271
+ "data-orientation": orientation,
272
+ ...tabsProps,
273
+ ref: forwardedRef
274
+ })
275
+ })
276
+ });
277
+ });
278
+ return (0, import_helpers.withStaticProperties)(TabsComponent, {
279
+ List: TabsList,
280
+ /**
281
+ * @deprecated Use Tabs.Tab instead
282
+ */
283
+ Trigger: TabsTrigger,
284
+ Tab: TabsTrigger,
285
+ Content: TabsContent
286
+ });
287
+ }
288
+ function makeTriggerId(baseId, value) {
289
+ return `${baseId}-trigger-${value}`;
290
+ }
291
+ function makeContentId(baseId, value) {
292
+ return `${baseId}-content-${value}`;
293
+ }