@hanzogui/tabs 3.0.2 → 7.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 (55) hide show
  1. package/package.json +21 -21
  2. package/src/Tabs.tsx +1 -1
  3. package/src/createTabs.tsx +11 -6
  4. package/types/StyledContext.d.ts +1 -1
  5. package/types/Tabs.d.ts +11 -11
  6. package/types/createTabs.d.ts +136 -136
  7. package/types/index.d.ts +167 -167
  8. package/dist/cjs/StyledContext.cjs +0 -31
  9. package/dist/cjs/StyledContext.native.js +0 -34
  10. package/dist/cjs/StyledContext.native.js.map +0 -1
  11. package/dist/cjs/Tabs.cjs +0 -81
  12. package/dist/cjs/Tabs.native.js +0 -84
  13. package/dist/cjs/Tabs.native.js.map +0 -1
  14. package/dist/cjs/createTabs.cjs +0 -262
  15. package/dist/cjs/createTabs.native.js +0 -280
  16. package/dist/cjs/createTabs.native.js.map +0 -1
  17. package/dist/cjs/index.cjs +0 -35
  18. package/dist/cjs/index.native.js +0 -38
  19. package/dist/cjs/index.native.js.map +0 -1
  20. package/dist/esm/StyledContext.mjs +0 -7
  21. package/dist/esm/StyledContext.mjs.map +0 -1
  22. package/dist/esm/StyledContext.native.js +0 -7
  23. package/dist/esm/StyledContext.native.js.map +0 -1
  24. package/dist/esm/Tabs.mjs +0 -56
  25. package/dist/esm/Tabs.mjs.map +0 -1
  26. package/dist/esm/Tabs.native.js +0 -56
  27. package/dist/esm/Tabs.native.js.map +0 -1
  28. package/dist/esm/createTabs.mjs +0 -228
  29. package/dist/esm/createTabs.mjs.map +0 -1
  30. package/dist/esm/createTabs.native.js +0 -243
  31. package/dist/esm/createTabs.native.js.map +0 -1
  32. package/dist/esm/index.js +0 -11
  33. package/dist/esm/index.js.map +0 -1
  34. package/dist/esm/index.mjs +0 -11
  35. package/dist/esm/index.mjs.map +0 -1
  36. package/dist/esm/index.native.js +0 -11
  37. package/dist/esm/index.native.js.map +0 -1
  38. package/dist/jsx/StyledContext.mjs +0 -7
  39. package/dist/jsx/StyledContext.mjs.map +0 -1
  40. package/dist/jsx/StyledContext.native.js +0 -34
  41. package/dist/jsx/StyledContext.native.js.map +0 -1
  42. package/dist/jsx/Tabs.mjs +0 -56
  43. package/dist/jsx/Tabs.mjs.map +0 -1
  44. package/dist/jsx/Tabs.native.js +0 -84
  45. package/dist/jsx/Tabs.native.js.map +0 -1
  46. package/dist/jsx/createTabs.mjs +0 -228
  47. package/dist/jsx/createTabs.mjs.map +0 -1
  48. package/dist/jsx/createTabs.native.js +0 -280
  49. package/dist/jsx/createTabs.native.js.map +0 -1
  50. package/dist/jsx/index.js +0 -11
  51. package/dist/jsx/index.js.map +0 -1
  52. package/dist/jsx/index.mjs +0 -11
  53. package/dist/jsx/index.mjs.map +0 -1
  54. package/dist/jsx/index.native.js +0 -38
  55. package/dist/jsx/index.native.js.map +0 -1
@@ -1,31 +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 __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 StyledContext_exports = {};
22
- __export(StyledContext_exports, {
23
- TabsProvider: () => TabsProvider,
24
- useTabsContext: () => useTabsContext
25
- });
26
- module.exports = __toCommonJS(StyledContext_exports);
27
- var import_gui_core = require("@hanzogui/core");
28
- const {
29
- Provider: TabsProvider,
30
- useStyledContext: useTabsContext
31
- } = (0, import_gui_core.createStyledContext)();
@@ -1,34 +0,0 @@
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 StyledContext_exports = {};
24
- __export(StyledContext_exports, {
25
- TabsProvider: () => TabsProvider,
26
- useTabsContext: () => useTabsContext
27
- });
28
- module.exports = __toCommonJS(StyledContext_exports);
29
- var import_gui_core = require("@hanzogui/core"),
30
- {
31
- Provider: TabsProvider,
32
- useStyledContext: useTabsContext
33
- } = (0, import_gui_core.createStyledContext)();
34
- //# sourceMappingURL=StyledContext.native.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","StyledContext_exports","__export","TabsProvider","useTabsContext","module","exports","import_gui_core","require","Provider","useStyledContext","createStyledContext"],"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,eAAkB,GAAAC,OAAA,kBAAc;EAAkB;IAAAC,QAAA,EAAAN,YACvD;IAAAO,gBAAA,EAAAN;EAAA,CAAsC,OAAAG,eAAA,CAAAI,mBAAA","ignoreList":[]}
package/dist/cjs/Tabs.cjs DELETED
@@ -1,81 +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 __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 Tabs_exports = {};
22
- __export(Tabs_exports, {
23
- DefaultTabsContentFrame: () => DefaultTabsContentFrame,
24
- DefaultTabsFrame: () => DefaultTabsFrame,
25
- DefaultTabsTabFrame: () => DefaultTabsTabFrame
26
- });
27
- module.exports = __toCommonJS(Tabs_exports);
28
- var import_gui_core = require("@hanzogui/core"),
29
- import_gui_get_button_sized = require("@hanzogui/get-button-sized"),
30
- import_gui_stacks = require("@hanzogui/stacks");
31
- const TABS_NAME = "Tabs",
32
- DefaultTabsFrame = (0, import_gui_core.styled)(import_gui_stacks.SizableStack, {
33
- name: TABS_NAME
34
- }),
35
- TRIGGER_NAME = "TabsTrigger",
36
- DefaultTabsTabFrame = (0, import_gui_core.styled)(import_gui_core.View, {
37
- name: TRIGGER_NAME,
38
- role: "tab",
39
- variants: {
40
- size: {
41
- "...size": import_gui_get_button_sized.getButtonSized
42
- },
43
- disabled: {
44
- true: {
45
- pointerEvents: "none"
46
- }
47
- },
48
- unstyled: {
49
- false: {
50
- borderWidth: 0,
51
- backgroundColor: "$background",
52
- userSelect: "none",
53
- justifyContent: "center",
54
- alignItems: "center",
55
- flexWrap: "nowrap",
56
- flexDirection: "row",
57
- cursor: "pointer",
58
- pressStyle: {
59
- backgroundColor: "$backgroundPress"
60
- },
61
- focusVisibleStyle: {
62
- outlineColor: "$outlineColor",
63
- outlineWidth: 2,
64
- outlineStyle: "solid",
65
- zIndex: 10
66
- }
67
- }
68
- }
69
- },
70
- defaultVariants: {
71
- unstyled: process.env.HANZO_GUI_HEADLESS === "1"
72
- }
73
- }, {
74
- accept: {
75
- activeStyle: "style"
76
- }
77
- }),
78
- CONTENT_NAME = "TabsContent",
79
- DefaultTabsContentFrame = (0, import_gui_core.styled)(import_gui_stacks.ThemeableStack, {
80
- name: CONTENT_NAME
81
- });
@@ -1,84 +0,0 @@
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 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_gui_core = require("@hanzogui/core"),
31
- import_gui_get_button_sized = require("@hanzogui/get-button-sized"),
32
- import_gui_stacks = require("@hanzogui/stacks"),
33
- TABS_NAME = "Tabs",
34
- DefaultTabsFrame = (0, import_gui_core.styled)(import_gui_stacks.SizableStack, {
35
- name: TABS_NAME
36
- }),
37
- TRIGGER_NAME = "TabsTrigger",
38
- DefaultTabsTabFrame = (0, import_gui_core.styled)(import_gui_core.View, {
39
- name: TRIGGER_NAME,
40
- role: "tab",
41
- variants: {
42
- size: {
43
- "...size": import_gui_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.HANZO_GUI_HEADLESS === "1"
74
- }
75
- }, {
76
- accept: {
77
- activeStyle: "style"
78
- }
79
- }),
80
- CONTENT_NAME = "TabsContent",
81
- DefaultTabsContentFrame = (0, import_gui_core.styled)(import_gui_stacks.ThemeableStack, {
82
- name: CONTENT_NAME
83
- });
84
- //# sourceMappingURL=Tabs.native.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","Tabs_exports","__export","DefaultTabsContentFrame","DefaultTabsFrame","DefaultTabsTabFrame","module","exports","import_gui_core","require","import_gui_get_button_sized","import_gui_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","HANZO_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;AAI7B,IAAAO,eAAkB,GAAAC,OACL;EAAmBC,2BAAO,GAAAD,OAAA,8BAAc;EAAAE,iBAAA,GAAAF,OAAA;EAAAG,SAAA;EAAAR,gBAAA,OAAAI,eAAA,CAAAK,MAAA,EAAAF,iBAAA,CAAAG,YAAA;IACnDC,IAAA,EAAMH;EACR,CAAC;EAEKI,YAAA,GAAe;EAERX,mBAAA,OAAsBG,eAAA,CAAAK,MAAA,EAAAL,eAAA,CAAAS,IAAA;IACjCF,IAAA,EAAAC,YAAA;IACAE,IAAA;IAAAC,QACQ;MACNC,IAAA,EAAM;QAEN,SAAU,EAAAV,2BAAA,CAAAW;MAAA;MACFC,QACJ;QACFC,IAAA;UAEAC,aAAU;QAAA;MACF;MACWC,QACjB;QACFC,KAAA;UAEAC,WAAU;UACRC,eAAO;UAAAC,UACL,QAAa;UAAAC,cACb,UAAiB;UAAAC,UACjB,UAAY;UAAAC,QACZ,UAAgB;UAAAC,aAChB,EAAY;UAAAC,MACZ,WAAU;UAAAC,UACV;YACAP,eAAQ;UAAA;UAEIQ,iBACV;YACFC,YAAA;YAEAC,YAAA;YAAmBC,YACjB,SAAc;YAAAC,MACd;UAAc;QACA;MACN;IACV;IACFC,eACF;MACFhB,QAAA,EAAAiB,OAAA,CAAAC,GAAA,CAAAC,kBAAA;IAAA;EAEiB;IAC8BC,MAC/C;MACFC,WAAA;IACA;EAAA;EACEC,YAAQ;EAAA5C,uBAAA,OAAAK,eAAA,CAAAK,MAAA,EAAAF,iBAAA,CAAAqC,cAAA;IAAAjC,IACN,EAAAgC;EAAa","ignoreList":[]}
@@ -1,262 +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,
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 createTabs_exports = {};
33
- __export(createTabs_exports, {
34
- createTabs: () => createTabs
35
- });
36
- module.exports = __toCommonJS(createTabs_exports);
37
- var import_gui_compose_refs = require("@hanzogui/compose-refs"),
38
- import_gui_constants = require("@hanzogui/constants"),
39
- import_gui_group = require("@hanzogui/group"),
40
- import_gui_helpers = require("@hanzogui/helpers"),
41
- import_gui_roving_focus = require("@hanzogui/roving-focus"),
42
- import_gui_sizable_context = require("@hanzogui/sizable-context"),
43
- import_gui_use_controllable_state = require("@hanzogui/use-controllable-state"),
44
- import_gui_use_direction = require("@hanzogui/use-direction"),
45
- import_gui_web = require("@hanzogui/web"),
46
- React = __toESM(require("react"), 1),
47
- import_StyledContext = require("./StyledContext.cjs"),
48
- import_Tabs = require("./Tabs.cjs"),
49
- import_jsx_runtime = require("react/jsx-runtime");
50
- function createTabs(createProps) {
51
- const {
52
- ContentFrame = import_Tabs.DefaultTabsContentFrame,
53
- TabFrame = import_Tabs.DefaultTabsTabFrame,
54
- TabsFrame = import_Tabs.DefaultTabsFrame
55
- } = createProps,
56
- TABS_CONTEXT = "TabsContext",
57
- TAB_LIST_NAME = "TabsList",
58
- TabsList = React.forwardRef((props, forwardedRef) => {
59
- const {
60
- __scopeTabs,
61
- loop = !0,
62
- children,
63
- ...listProps
64
- } = props,
65
- context = (0, import_StyledContext.useTabsContext)(__scopeTabs);
66
- return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_gui_roving_focus.RovingFocusGroup, {
67
- __scopeRovingFocusGroup: __scopeTabs || TABS_CONTEXT,
68
- orientation: context.orientation,
69
- dir: context.dir,
70
- loop,
71
- asChild: !0,
72
- children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_gui_group.Group, {
73
- role: "tablist",
74
- componentName: TAB_LIST_NAME,
75
- "aria-orientation": context.orientation,
76
- ref: forwardedRef,
77
- orientation: context.orientation,
78
- ...listProps,
79
- children
80
- })
81
- });
82
- });
83
- TabsList.displayName = TAB_LIST_NAME;
84
- const TRIGGER_NAME = "TabsTrigger",
85
- TabsTrigger = TabFrame.styleable((props, forwardedRef) => {
86
- const {
87
- __scopeTabs,
88
- value,
89
- disabled = !1,
90
- onInteraction,
91
- activeStyle,
92
- activeTheme,
93
- unstyled = !1,
94
- ...triggerProps
95
- } = props,
96
- context = (0, import_StyledContext.useTabsContext)(__scopeTabs),
97
- triggerId = makeTriggerId(context.baseId, value),
98
- contentId = makeContentId(context.baseId, value),
99
- isSelected = value === context.value,
100
- [layout, setLayout] = React.useState(null),
101
- triggerRef = React.useRef(null),
102
- groupItemProps = (0, import_gui_group.useGroupItem)({
103
- disabled: !!disabled
104
- });
105
- return React.useEffect(() => (context.registerTrigger(), () => context.unregisterTrigger()), []), React.useEffect(() => {
106
- if (!triggerRef.current || !import_gui_constants.isWeb) return;
107
- const el = triggerRef.current;
108
- function getTriggerSize() {
109
- el && setLayout({
110
- width: el.offsetWidth,
111
- height: el.offsetHeight,
112
- x: el.offsetLeft,
113
- y: el.offsetTop
114
- });
115
- }
116
- getTriggerSize();
117
- const observer = new ResizeObserver(getTriggerSize);
118
- return observer.observe(el), () => {
119
- observer.unobserve(el);
120
- };
121
- }, [context.triggersCount]), React.useEffect(() => {
122
- isSelected && layout && onInteraction?.("select", layout);
123
- }, [isSelected, value, layout]), /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_gui_roving_focus.RovingFocusGroup.Item, {
124
- __scopeRovingFocusGroup: __scopeTabs || TABS_CONTEXT,
125
- asChild: !0,
126
- focusable: !disabled,
127
- active: isSelected,
128
- children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(TabFrame, {
129
- onMouseEnter: (0, import_gui_helpers.composeEventHandlers)(props.onMouseEnter, () => {
130
- layout && onInteraction?.("hover", layout);
131
- }),
132
- onMouseLeave: (0, import_gui_helpers.composeEventHandlers)(props.onMouseLeave, () => {
133
- onInteraction?.("hover", null);
134
- }),
135
- role: "tab",
136
- "aria-selected": isSelected,
137
- "aria-controls": contentId,
138
- "data-state": isSelected ? "active" : "inactive",
139
- "data-disabled": disabled ? "" : void 0,
140
- id: triggerId,
141
- theme: activeTheme ?? null,
142
- unstyled,
143
- ...(!unstyled && {
144
- size: context.size
145
- }),
146
- ...(isSelected && {
147
- ...(!unstyled && !activeStyle && {
148
- backgroundColor: "$backgroundActive"
149
- }),
150
- ...activeStyle
151
- }),
152
- ...groupItemProps,
153
- disabled: disabled ?? groupItemProps.disabled,
154
- ...triggerProps,
155
- ref: (0, import_gui_compose_refs.composeRefs)(forwardedRef, triggerRef),
156
- onPress: (0, import_gui_helpers.composeEventHandlers)(props.onPress ?? void 0, event => {
157
- const webChecks = !import_gui_constants.isWeb || event.button === 0 && event.ctrlKey === !1;
158
- !disabled && !isSelected && webChecks && context.onChange(value);
159
- }),
160
- ...(import_gui_constants.isWeb && {
161
- onKeyDown: (0, import_gui_helpers.composeEventHandlers)(props.onKeyDown, event => {
162
- [" ", "Enter"].includes(event.key) && (context.onChange(value), event.preventDefault());
163
- }),
164
- onFocus: (0, import_gui_helpers.composeEventHandlers)(props.onFocus, event => {
165
- layout && onInteraction?.("focus", layout);
166
- const isAutomaticActivation = context.activationMode !== "manual";
167
- !isSelected && !disabled && isAutomaticActivation && context.onChange(value);
168
- }),
169
- onBlur: (0, import_gui_helpers.composeEventHandlers)(props.onBlur, () => {
170
- onInteraction?.("focus", null);
171
- })
172
- })
173
- })
174
- });
175
- });
176
- TabsTrigger.displayName = TRIGGER_NAME;
177
- const TabsContent = ContentFrame.styleable(function (props, forwardedRef) {
178
- const {
179
- __scopeTabs,
180
- value,
181
- forceMount,
182
- children,
183
- ...contentProps
184
- } = props,
185
- context = (0, import_StyledContext.useTabsContext)(__scopeTabs),
186
- isSelected = value === context.value,
187
- show = forceMount || isSelected,
188
- triggerId = makeTriggerId(context.baseId, value),
189
- contentId = makeContentId(context.baseId, value);
190
- return show ? /* @__PURE__ */(0, import_jsx_runtime.jsx)(ContentFrame, {
191
- "data-state": isSelected ? "active" : "inactive",
192
- "data-orientation": context.orientation,
193
- role: "tabpanel",
194
- "aria-labelledby": triggerId,
195
- hidden: !show,
196
- id: contentId,
197
- tabIndex: 0,
198
- ...contentProps,
199
- ref: forwardedRef,
200
- children
201
- }, value) : null;
202
- }),
203
- TabsComponent = TabsFrame.styleable(function (props, forwardedRef) {
204
- const {
205
- __scopeTabs,
206
- value: valueProp,
207
- onValueChange,
208
- defaultValue,
209
- orientation = "horizontal",
210
- dir,
211
- activationMode = "manual",
212
- size = "$true",
213
- ...tabsProps
214
- } = props,
215
- direction = (0, import_gui_use_direction.useDirection)(dir),
216
- [value, setValue] = (0, import_gui_use_controllable_state.useControllableState)({
217
- prop: valueProp,
218
- onChange: onValueChange,
219
- defaultProp: defaultValue ?? ""
220
- }),
221
- [triggersCount, setTriggersCount] = React.useState(0),
222
- registerTrigger = (0, import_gui_web.useEvent)(() => setTriggersCount(v => v + 1)),
223
- unregisterTrigger = (0, import_gui_web.useEvent)(() => setTriggersCount(v => v - 1));
224
- return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_gui_sizable_context.SizableContext.Provider, {
225
- size,
226
- children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_StyledContext.TabsProvider, {
227
- scope: __scopeTabs,
228
- baseId: React.useId(),
229
- value,
230
- onChange: setValue,
231
- orientation,
232
- dir: direction,
233
- activationMode,
234
- size,
235
- registerTrigger,
236
- triggersCount,
237
- unregisterTrigger,
238
- children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(TabsFrame, {
239
- direction,
240
- "data-orientation": orientation,
241
- ...tabsProps,
242
- ref: forwardedRef
243
- })
244
- })
245
- });
246
- });
247
- return (0, import_gui_helpers.withStaticProperties)(TabsComponent, {
248
- List: TabsList,
249
- /**
250
- * @deprecated Use Tabs.Tab instead
251
- */
252
- Trigger: TabsTrigger,
253
- Tab: TabsTrigger,
254
- Content: TabsContent
255
- });
256
- }
257
- function makeTriggerId(baseId, value) {
258
- return `${baseId}-trigger-${value}`;
259
- }
260
- function makeContentId(baseId, value) {
261
- return `${baseId}-content-${value}`;
262
- }