@postenbring/hedwig-react 0.0.16 → 0.0.17
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/chunk-4RBJ5GJR.mjs +37 -0
- package/dist/chunk-4ZM45P62.mjs +13 -0
- package/dist/chunk-BKXVC23Y.mjs +5 -0
- package/dist/chunk-FSBY3NKV.mjs +47 -0
- package/dist/chunk-NVMNXQ5Q.mjs +79 -0
- package/dist/{chunk-FFQBRM3W.mjs → chunk-QV33ZHNO.mjs} +3 -21
- package/dist/{chunk-5CZXT7I6.mjs → chunk-YFBW5ZRC.mjs} +1 -1
- package/dist/chunk-ZLCNSHLT.mjs +31 -0
- package/dist/index.d.mts +3 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +162 -4
- package/dist/index.mjs +21 -2
- package/dist/modal/index.js +5 -4
- package/dist/modal/index.mjs +3 -2
- package/dist/modal/modal.js +5 -4
- package/dist/modal/modal.mjs +2 -1
- package/dist/tabs/index.d.mts +6 -0
- package/dist/tabs/index.d.ts +6 -0
- package/dist/tabs/index.js +227 -0
- package/dist/tabs/index.mjs +22 -0
- package/dist/tabs/tabs-content.d.mts +21 -0
- package/dist/tabs/tabs-content.d.ts +21 -0
- package/dist/tabs/tabs-content.js +94 -0
- package/dist/tabs/tabs-content.mjs +10 -0
- package/dist/tabs/tabs-list.d.mts +26 -0
- package/dist/tabs/tabs-list.d.ts +26 -0
- package/dist/tabs/tabs-list.js +170 -0
- package/dist/tabs/tabs-list.mjs +11 -0
- package/dist/tabs/tabs.d.mts +16 -0
- package/dist/tabs/tabs.d.ts +16 -0
- package/dist/tabs/tabs.js +87 -0
- package/dist/tabs/tabs.mjs +8 -0
- package/package.json +2 -2
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __defProps = Object.defineProperties;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
7
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
9
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
10
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
11
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
12
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
13
|
+
var __spreadValues = (a, b) => {
|
|
14
|
+
for (var prop in b || (b = {}))
|
|
15
|
+
if (__hasOwnProp.call(b, prop))
|
|
16
|
+
__defNormalProp(a, prop, b[prop]);
|
|
17
|
+
if (__getOwnPropSymbols)
|
|
18
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
19
|
+
if (__propIsEnum.call(b, prop))
|
|
20
|
+
__defNormalProp(a, prop, b[prop]);
|
|
21
|
+
}
|
|
22
|
+
return a;
|
|
23
|
+
};
|
|
24
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
25
|
+
var __objRest = (source, exclude) => {
|
|
26
|
+
var target = {};
|
|
27
|
+
for (var prop in source)
|
|
28
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
29
|
+
target[prop] = source[prop];
|
|
30
|
+
if (source != null && __getOwnPropSymbols)
|
|
31
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
32
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
33
|
+
target[prop] = source[prop];
|
|
34
|
+
}
|
|
35
|
+
return target;
|
|
36
|
+
};
|
|
37
|
+
var __export = (target, all) => {
|
|
38
|
+
for (var name in all)
|
|
39
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
40
|
+
};
|
|
41
|
+
var __copyProps = (to, from, except, desc) => {
|
|
42
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
43
|
+
for (let key of __getOwnPropNames(from))
|
|
44
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
45
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
46
|
+
}
|
|
47
|
+
return to;
|
|
48
|
+
};
|
|
49
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
50
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
51
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
52
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
53
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
54
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
55
|
+
mod
|
|
56
|
+
));
|
|
57
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
58
|
+
|
|
59
|
+
// src/tabs/index.tsx
|
|
60
|
+
var tabs_exports = {};
|
|
61
|
+
__export(tabs_exports, {
|
|
62
|
+
Tab: () => Tab,
|
|
63
|
+
TabContent: () => TabContent,
|
|
64
|
+
TabContents: () => TabContents,
|
|
65
|
+
TabList: () => TabList,
|
|
66
|
+
Tabs: () => Tabs
|
|
67
|
+
});
|
|
68
|
+
module.exports = __toCommonJS(tabs_exports);
|
|
69
|
+
var import_fonts = require("@postenbring/hedwig-css/dist/fonts.css");
|
|
70
|
+
var import_tokens = require("@postenbring/hedwig-css/dist/tokens.css");
|
|
71
|
+
var import_body = require("@postenbring/hedwig-css/dist/body.css");
|
|
72
|
+
var import_tabs = require("@postenbring/hedwig-css/dist/tabs.css");
|
|
73
|
+
|
|
74
|
+
// src/tabs/tabs.tsx
|
|
75
|
+
var import_react2 = require("react");
|
|
76
|
+
var import_typed_classname = require("@postenbring/hedwig-css/typed-classname/index.mjs");
|
|
77
|
+
|
|
78
|
+
// src/tabs/context.ts
|
|
79
|
+
var import_react = require("react");
|
|
80
|
+
var TabsContext = (0, import_react.createContext)({
|
|
81
|
+
mounted: false,
|
|
82
|
+
activeTabId: void 0,
|
|
83
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars -- Added default section, without handling
|
|
84
|
+
toggleActiveTabId: (tabId) => {
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
// src/tabs/tabs.tsx
|
|
89
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
90
|
+
var Tabs = (0, import_react2.forwardRef)(
|
|
91
|
+
(_a, ref) => {
|
|
92
|
+
var _b = _a, { as: Component = "div", defaultTab, children } = _b, rest = __objRest(_b, ["as", "defaultTab", "children"]);
|
|
93
|
+
const [activeTabId, setActiveTabId] = (0, import_react2.useState)(defaultTab);
|
|
94
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, __spreadProps(__spreadValues({ className: (0, import_typed_classname.clsx)("hds-tabs"), ref }, rest), { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
95
|
+
TabsContext.Provider,
|
|
96
|
+
{
|
|
97
|
+
value: { activeTabId, toggleActiveTabId: setActiveTabId, mounted: true },
|
|
98
|
+
children
|
|
99
|
+
}
|
|
100
|
+
) }));
|
|
101
|
+
}
|
|
102
|
+
);
|
|
103
|
+
Tabs.displayName = "Tabs";
|
|
104
|
+
|
|
105
|
+
// src/tabs/tabs-list.tsx
|
|
106
|
+
var import_react4 = require("react");
|
|
107
|
+
var import_typed_classname2 = require("@postenbring/hedwig-css/typed-classname/index.mjs");
|
|
108
|
+
|
|
109
|
+
// src/utils.ts
|
|
110
|
+
var React = __toESM(require("react"));
|
|
111
|
+
var import_react3 = require("react");
|
|
112
|
+
function useResize(ref) {
|
|
113
|
+
const [width, setWidth] = (0, import_react3.useState)(0);
|
|
114
|
+
const [height, setHeight] = (0, import_react3.useState)(0);
|
|
115
|
+
const handleResize = (0, import_react3.useCallback)(() => {
|
|
116
|
+
var _a, _b, _c, _d;
|
|
117
|
+
if ((ref == null ? void 0 : ref.current) !== null) {
|
|
118
|
+
setWidth((_b = (_a = ref == null ? void 0 : ref.current) == null ? void 0 : _a.offsetWidth) != null ? _b : 0);
|
|
119
|
+
setHeight((_d = (_c = ref == null ? void 0 : ref.current) == null ? void 0 : _c.offsetHeight) != null ? _d : 0);
|
|
120
|
+
}
|
|
121
|
+
}, [ref]);
|
|
122
|
+
(0, import_react3.useEffect)(() => {
|
|
123
|
+
window.addEventListener("load", handleResize);
|
|
124
|
+
window.addEventListener("resize", handleResize);
|
|
125
|
+
return () => {
|
|
126
|
+
window.removeEventListener("load", handleResize);
|
|
127
|
+
window.removeEventListener("resize", handleResize);
|
|
128
|
+
};
|
|
129
|
+
}, [ref, handleResize]);
|
|
130
|
+
(0, import_react3.useEffect)(() => {
|
|
131
|
+
handleResize();
|
|
132
|
+
}, []);
|
|
133
|
+
return { width, height };
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// src/tabs/tabs-list.tsx
|
|
137
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
138
|
+
function TabList(_a) {
|
|
139
|
+
var _b = _a, { children, direction = "horizontal", className } = _b, rest = __objRest(_b, ["children", "direction", "className"]);
|
|
140
|
+
const tabsListRef = (0, import_react4.useRef)(null);
|
|
141
|
+
const { width: tabsWidth } = useResize(tabsListRef);
|
|
142
|
+
const { innerWidth } = window;
|
|
143
|
+
const wideEnough = innerWidth >= tabsWidth;
|
|
144
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
145
|
+
"div",
|
|
146
|
+
__spreadProps(__spreadValues({
|
|
147
|
+
className: (0, import_typed_classname2.clsx)(
|
|
148
|
+
"hds-tabs--list",
|
|
149
|
+
direction === "horizontal" ? {
|
|
150
|
+
[`hds-tabs--list-horizontal`]: wideEnough,
|
|
151
|
+
"hds-tabs--list-vertical": !wideEnough
|
|
152
|
+
} : {
|
|
153
|
+
"hds-tabs--list-vertical": true
|
|
154
|
+
},
|
|
155
|
+
className
|
|
156
|
+
),
|
|
157
|
+
ref: tabsListRef,
|
|
158
|
+
role: "tablist"
|
|
159
|
+
}, rest), {
|
|
160
|
+
children
|
|
161
|
+
})
|
|
162
|
+
);
|
|
163
|
+
}
|
|
164
|
+
TabList.displayName = "TabList";
|
|
165
|
+
var Tab = (0, import_react4.forwardRef)(
|
|
166
|
+
(_a, ref) => {
|
|
167
|
+
var _b = _a, { as: Component = "button", children, tabId, className, onClick } = _b, rest = __objRest(_b, ["as", "children", "tabId", "className", "onClick"]);
|
|
168
|
+
const context = (0, import_react4.useContext)(TabsContext);
|
|
169
|
+
if (!context.mounted) {
|
|
170
|
+
throw new Error("Context required. Did you use <TabContent/> outside of <Tabs/>?");
|
|
171
|
+
}
|
|
172
|
+
const toggleTab = (e) => {
|
|
173
|
+
e.preventDefault();
|
|
174
|
+
context.toggleActiveTabId(tabId);
|
|
175
|
+
onClick && onClick(e);
|
|
176
|
+
};
|
|
177
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
178
|
+
Component,
|
|
179
|
+
__spreadProps(__spreadValues({
|
|
180
|
+
className: (0, import_typed_classname2.clsx)(
|
|
181
|
+
"hds-tabs--tab",
|
|
182
|
+
{ "hds-tabs--tab-active": context.activeTabId === tabId },
|
|
183
|
+
className
|
|
184
|
+
),
|
|
185
|
+
"data-tabid": tabId,
|
|
186
|
+
onClick: toggleTab,
|
|
187
|
+
ref,
|
|
188
|
+
role: "tab"
|
|
189
|
+
}, rest), {
|
|
190
|
+
children
|
|
191
|
+
})
|
|
192
|
+
);
|
|
193
|
+
}
|
|
194
|
+
);
|
|
195
|
+
Tab.displayName = "Tab";
|
|
196
|
+
|
|
197
|
+
// src/tabs/tabs-content.tsx
|
|
198
|
+
var import_react5 = require("react");
|
|
199
|
+
var import_typed_classname3 = require("@postenbring/hedwig-css/typed-classname/index.mjs");
|
|
200
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
201
|
+
function TabContents(_a) {
|
|
202
|
+
var _b = _a, { children } = _b, rest = __objRest(_b, ["children"]);
|
|
203
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", __spreadProps(__spreadValues({ className: (0, import_typed_classname3.clsx)("hds-tabs--contents") }, rest), { children }));
|
|
204
|
+
}
|
|
205
|
+
TabContents.displayName = "TabContents";
|
|
206
|
+
var TabContent = (0, import_react5.forwardRef)(
|
|
207
|
+
(_a, ref) => {
|
|
208
|
+
var _b = _a, { as: Component = "div", forTabId, children } = _b, rest = __objRest(_b, ["as", "forTabId", "children"]);
|
|
209
|
+
const context = (0, import_react5.useContext)(TabsContext);
|
|
210
|
+
if (!context.mounted) {
|
|
211
|
+
throw new Error("Context required. Did you use <TabContent/> outside of <Tabs/>?");
|
|
212
|
+
}
|
|
213
|
+
if (context.activeTabId === forTabId) {
|
|
214
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Component, __spreadProps(__spreadValues({}, rest), { ref, children }));
|
|
215
|
+
}
|
|
216
|
+
return null;
|
|
217
|
+
}
|
|
218
|
+
);
|
|
219
|
+
TabContent.displayName = "TabContent";
|
|
220
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
221
|
+
0 && (module.exports = {
|
|
222
|
+
Tab,
|
|
223
|
+
TabContent,
|
|
224
|
+
TabContents,
|
|
225
|
+
TabList,
|
|
226
|
+
Tabs
|
|
227
|
+
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import "../chunk-BKXVC23Y.mjs";
|
|
2
|
+
import {
|
|
3
|
+
TabContent,
|
|
4
|
+
TabContents
|
|
5
|
+
} from "../chunk-4RBJ5GJR.mjs";
|
|
6
|
+
import {
|
|
7
|
+
Tab,
|
|
8
|
+
TabList
|
|
9
|
+
} from "../chunk-NVMNXQ5Q.mjs";
|
|
10
|
+
import "../chunk-FSBY3NKV.mjs";
|
|
11
|
+
import {
|
|
12
|
+
Tabs
|
|
13
|
+
} from "../chunk-ZLCNSHLT.mjs";
|
|
14
|
+
import "../chunk-4ZM45P62.mjs";
|
|
15
|
+
import "../chunk-FUJQIYOF.mjs";
|
|
16
|
+
export {
|
|
17
|
+
Tab,
|
|
18
|
+
TabContent,
|
|
19
|
+
TabContents,
|
|
20
|
+
TabList,
|
|
21
|
+
Tabs
|
|
22
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { HTMLAttributes, ReactElement } from 'react';
|
|
3
|
+
import { O as OverridableComponent } from '../utils-BfZsjuFH.mjs';
|
|
4
|
+
|
|
5
|
+
interface TabContentsProps extends HTMLAttributes<HTMLDivElement> {
|
|
6
|
+
children: ReactElement<TabContentProps> | ReactElement<TabContentProps>[];
|
|
7
|
+
}
|
|
8
|
+
declare function TabContents({ children, ...rest }: TabContentsProps): react_jsx_runtime.JSX.Element;
|
|
9
|
+
declare namespace TabContents {
|
|
10
|
+
var displayName: string;
|
|
11
|
+
}
|
|
12
|
+
interface TabContentProps extends HTMLAttributes<HTMLElement> {
|
|
13
|
+
children: ReactElement<HTMLElement> | ReactElement<HTMLElement>[] | string;
|
|
14
|
+
/**
|
|
15
|
+
* Content for the referenced tabId
|
|
16
|
+
*/
|
|
17
|
+
forTabId: string;
|
|
18
|
+
}
|
|
19
|
+
declare const TabContent: OverridableComponent<TabContentProps, HTMLElement>;
|
|
20
|
+
|
|
21
|
+
export { TabContent, type TabContentProps, TabContents, type TabContentsProps };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { HTMLAttributes, ReactElement } from 'react';
|
|
3
|
+
import { O as OverridableComponent } from '../utils-BfZsjuFH.js';
|
|
4
|
+
|
|
5
|
+
interface TabContentsProps extends HTMLAttributes<HTMLDivElement> {
|
|
6
|
+
children: ReactElement<TabContentProps> | ReactElement<TabContentProps>[];
|
|
7
|
+
}
|
|
8
|
+
declare function TabContents({ children, ...rest }: TabContentsProps): react_jsx_runtime.JSX.Element;
|
|
9
|
+
declare namespace TabContents {
|
|
10
|
+
var displayName: string;
|
|
11
|
+
}
|
|
12
|
+
interface TabContentProps extends HTMLAttributes<HTMLElement> {
|
|
13
|
+
children: ReactElement<HTMLElement> | ReactElement<HTMLElement>[] | string;
|
|
14
|
+
/**
|
|
15
|
+
* Content for the referenced tabId
|
|
16
|
+
*/
|
|
17
|
+
forTabId: string;
|
|
18
|
+
}
|
|
19
|
+
declare const TabContent: OverridableComponent<TabContentProps, HTMLElement>;
|
|
20
|
+
|
|
21
|
+
export { TabContent, type TabContentProps, TabContents, type TabContentsProps };
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defProps = Object.defineProperties;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
10
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
11
|
+
var __spreadValues = (a, b) => {
|
|
12
|
+
for (var prop in b || (b = {}))
|
|
13
|
+
if (__hasOwnProp.call(b, prop))
|
|
14
|
+
__defNormalProp(a, prop, b[prop]);
|
|
15
|
+
if (__getOwnPropSymbols)
|
|
16
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
17
|
+
if (__propIsEnum.call(b, prop))
|
|
18
|
+
__defNormalProp(a, prop, b[prop]);
|
|
19
|
+
}
|
|
20
|
+
return a;
|
|
21
|
+
};
|
|
22
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
23
|
+
var __objRest = (source, exclude) => {
|
|
24
|
+
var target = {};
|
|
25
|
+
for (var prop in source)
|
|
26
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
27
|
+
target[prop] = source[prop];
|
|
28
|
+
if (source != null && __getOwnPropSymbols)
|
|
29
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
30
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
31
|
+
target[prop] = source[prop];
|
|
32
|
+
}
|
|
33
|
+
return target;
|
|
34
|
+
};
|
|
35
|
+
var __export = (target, all) => {
|
|
36
|
+
for (var name in all)
|
|
37
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
38
|
+
};
|
|
39
|
+
var __copyProps = (to, from, except, desc) => {
|
|
40
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
41
|
+
for (let key of __getOwnPropNames(from))
|
|
42
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
43
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
44
|
+
}
|
|
45
|
+
return to;
|
|
46
|
+
};
|
|
47
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
48
|
+
|
|
49
|
+
// src/tabs/tabs-content.tsx
|
|
50
|
+
var tabs_content_exports = {};
|
|
51
|
+
__export(tabs_content_exports, {
|
|
52
|
+
TabContent: () => TabContent,
|
|
53
|
+
TabContents: () => TabContents
|
|
54
|
+
});
|
|
55
|
+
module.exports = __toCommonJS(tabs_content_exports);
|
|
56
|
+
var import_react2 = require("react");
|
|
57
|
+
var import_typed_classname = require("@postenbring/hedwig-css/typed-classname/index.mjs");
|
|
58
|
+
|
|
59
|
+
// src/tabs/context.ts
|
|
60
|
+
var import_react = require("react");
|
|
61
|
+
var TabsContext = (0, import_react.createContext)({
|
|
62
|
+
mounted: false,
|
|
63
|
+
activeTabId: void 0,
|
|
64
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars -- Added default section, without handling
|
|
65
|
+
toggleActiveTabId: (tabId) => {
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
// src/tabs/tabs-content.tsx
|
|
70
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
71
|
+
function TabContents(_a) {
|
|
72
|
+
var _b = _a, { children } = _b, rest = __objRest(_b, ["children"]);
|
|
73
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", __spreadProps(__spreadValues({ className: (0, import_typed_classname.clsx)("hds-tabs--contents") }, rest), { children }));
|
|
74
|
+
}
|
|
75
|
+
TabContents.displayName = "TabContents";
|
|
76
|
+
var TabContent = (0, import_react2.forwardRef)(
|
|
77
|
+
(_a, ref) => {
|
|
78
|
+
var _b = _a, { as: Component = "div", forTabId, children } = _b, rest = __objRest(_b, ["as", "forTabId", "children"]);
|
|
79
|
+
const context = (0, import_react2.useContext)(TabsContext);
|
|
80
|
+
if (!context.mounted) {
|
|
81
|
+
throw new Error("Context required. Did you use <TabContent/> outside of <Tabs/>?");
|
|
82
|
+
}
|
|
83
|
+
if (context.activeTabId === forTabId) {
|
|
84
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, __spreadProps(__spreadValues({}, rest), { ref, children }));
|
|
85
|
+
}
|
|
86
|
+
return null;
|
|
87
|
+
}
|
|
88
|
+
);
|
|
89
|
+
TabContent.displayName = "TabContent";
|
|
90
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
91
|
+
0 && (module.exports = {
|
|
92
|
+
TabContent,
|
|
93
|
+
TabContents
|
|
94
|
+
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { HTMLAttributes, ReactElement } from 'react';
|
|
3
|
+
import { O as OverridableComponent } from '../utils-BfZsjuFH.mjs';
|
|
4
|
+
|
|
5
|
+
interface TabListProps extends HTMLAttributes<HTMLDivElement> {
|
|
6
|
+
children: ReactElement<TabProps> | ReactElement<TabProps>[];
|
|
7
|
+
/**
|
|
8
|
+
* Direction of the tabs. Can either be vertical or horizontal.
|
|
9
|
+
* Horizontal breaks on window width with fallback back to vertical
|
|
10
|
+
*/
|
|
11
|
+
direction?: "vertical" | "horizontal";
|
|
12
|
+
}
|
|
13
|
+
declare function TabList({ children, direction, className, ...rest }: TabListProps): react_jsx_runtime.JSX.Element;
|
|
14
|
+
declare namespace TabList {
|
|
15
|
+
var displayName: string;
|
|
16
|
+
}
|
|
17
|
+
interface TabProps extends HTMLAttributes<HTMLButtonElement> {
|
|
18
|
+
children: ReactElement<HTMLElement> | string;
|
|
19
|
+
/**
|
|
20
|
+
* Identifier for the tab
|
|
21
|
+
*/
|
|
22
|
+
tabId: string;
|
|
23
|
+
}
|
|
24
|
+
declare const Tab: OverridableComponent<TabProps, HTMLButtonElement>;
|
|
25
|
+
|
|
26
|
+
export { Tab, TabList, type TabListProps, type TabProps };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { HTMLAttributes, ReactElement } from 'react';
|
|
3
|
+
import { O as OverridableComponent } from '../utils-BfZsjuFH.js';
|
|
4
|
+
|
|
5
|
+
interface TabListProps extends HTMLAttributes<HTMLDivElement> {
|
|
6
|
+
children: ReactElement<TabProps> | ReactElement<TabProps>[];
|
|
7
|
+
/**
|
|
8
|
+
* Direction of the tabs. Can either be vertical or horizontal.
|
|
9
|
+
* Horizontal breaks on window width with fallback back to vertical
|
|
10
|
+
*/
|
|
11
|
+
direction?: "vertical" | "horizontal";
|
|
12
|
+
}
|
|
13
|
+
declare function TabList({ children, direction, className, ...rest }: TabListProps): react_jsx_runtime.JSX.Element;
|
|
14
|
+
declare namespace TabList {
|
|
15
|
+
var displayName: string;
|
|
16
|
+
}
|
|
17
|
+
interface TabProps extends HTMLAttributes<HTMLButtonElement> {
|
|
18
|
+
children: ReactElement<HTMLElement> | string;
|
|
19
|
+
/**
|
|
20
|
+
* Identifier for the tab
|
|
21
|
+
*/
|
|
22
|
+
tabId: string;
|
|
23
|
+
}
|
|
24
|
+
declare const Tab: OverridableComponent<TabProps, HTMLButtonElement>;
|
|
25
|
+
|
|
26
|
+
export { Tab, TabList, type TabListProps, type TabProps };
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __defProps = Object.defineProperties;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
7
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
9
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
10
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
11
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
12
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
13
|
+
var __spreadValues = (a, b) => {
|
|
14
|
+
for (var prop in b || (b = {}))
|
|
15
|
+
if (__hasOwnProp.call(b, prop))
|
|
16
|
+
__defNormalProp(a, prop, b[prop]);
|
|
17
|
+
if (__getOwnPropSymbols)
|
|
18
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
19
|
+
if (__propIsEnum.call(b, prop))
|
|
20
|
+
__defNormalProp(a, prop, b[prop]);
|
|
21
|
+
}
|
|
22
|
+
return a;
|
|
23
|
+
};
|
|
24
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
25
|
+
var __objRest = (source, exclude) => {
|
|
26
|
+
var target = {};
|
|
27
|
+
for (var prop in source)
|
|
28
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
29
|
+
target[prop] = source[prop];
|
|
30
|
+
if (source != null && __getOwnPropSymbols)
|
|
31
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
32
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
33
|
+
target[prop] = source[prop];
|
|
34
|
+
}
|
|
35
|
+
return target;
|
|
36
|
+
};
|
|
37
|
+
var __export = (target, all) => {
|
|
38
|
+
for (var name in all)
|
|
39
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
40
|
+
};
|
|
41
|
+
var __copyProps = (to, from, except, desc) => {
|
|
42
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
43
|
+
for (let key of __getOwnPropNames(from))
|
|
44
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
45
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
46
|
+
}
|
|
47
|
+
return to;
|
|
48
|
+
};
|
|
49
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
50
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
51
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
52
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
53
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
54
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
55
|
+
mod
|
|
56
|
+
));
|
|
57
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
58
|
+
|
|
59
|
+
// src/tabs/tabs-list.tsx
|
|
60
|
+
var tabs_list_exports = {};
|
|
61
|
+
__export(tabs_list_exports, {
|
|
62
|
+
Tab: () => Tab,
|
|
63
|
+
TabList: () => TabList
|
|
64
|
+
});
|
|
65
|
+
module.exports = __toCommonJS(tabs_list_exports);
|
|
66
|
+
var import_react3 = require("react");
|
|
67
|
+
var import_typed_classname = require("@postenbring/hedwig-css/typed-classname/index.mjs");
|
|
68
|
+
|
|
69
|
+
// src/utils.ts
|
|
70
|
+
var React = __toESM(require("react"));
|
|
71
|
+
var import_react = require("react");
|
|
72
|
+
function useResize(ref) {
|
|
73
|
+
const [width, setWidth] = (0, import_react.useState)(0);
|
|
74
|
+
const [height, setHeight] = (0, import_react.useState)(0);
|
|
75
|
+
const handleResize = (0, import_react.useCallback)(() => {
|
|
76
|
+
var _a, _b, _c, _d;
|
|
77
|
+
if ((ref == null ? void 0 : ref.current) !== null) {
|
|
78
|
+
setWidth((_b = (_a = ref == null ? void 0 : ref.current) == null ? void 0 : _a.offsetWidth) != null ? _b : 0);
|
|
79
|
+
setHeight((_d = (_c = ref == null ? void 0 : ref.current) == null ? void 0 : _c.offsetHeight) != null ? _d : 0);
|
|
80
|
+
}
|
|
81
|
+
}, [ref]);
|
|
82
|
+
(0, import_react.useEffect)(() => {
|
|
83
|
+
window.addEventListener("load", handleResize);
|
|
84
|
+
window.addEventListener("resize", handleResize);
|
|
85
|
+
return () => {
|
|
86
|
+
window.removeEventListener("load", handleResize);
|
|
87
|
+
window.removeEventListener("resize", handleResize);
|
|
88
|
+
};
|
|
89
|
+
}, [ref, handleResize]);
|
|
90
|
+
(0, import_react.useEffect)(() => {
|
|
91
|
+
handleResize();
|
|
92
|
+
}, []);
|
|
93
|
+
return { width, height };
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// src/tabs/context.ts
|
|
97
|
+
var import_react2 = require("react");
|
|
98
|
+
var TabsContext = (0, import_react2.createContext)({
|
|
99
|
+
mounted: false,
|
|
100
|
+
activeTabId: void 0,
|
|
101
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars -- Added default section, without handling
|
|
102
|
+
toggleActiveTabId: (tabId) => {
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
// src/tabs/tabs-list.tsx
|
|
107
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
108
|
+
function TabList(_a) {
|
|
109
|
+
var _b = _a, { children, direction = "horizontal", className } = _b, rest = __objRest(_b, ["children", "direction", "className"]);
|
|
110
|
+
const tabsListRef = (0, import_react3.useRef)(null);
|
|
111
|
+
const { width: tabsWidth } = useResize(tabsListRef);
|
|
112
|
+
const { innerWidth } = window;
|
|
113
|
+
const wideEnough = innerWidth >= tabsWidth;
|
|
114
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
115
|
+
"div",
|
|
116
|
+
__spreadProps(__spreadValues({
|
|
117
|
+
className: (0, import_typed_classname.clsx)(
|
|
118
|
+
"hds-tabs--list",
|
|
119
|
+
direction === "horizontal" ? {
|
|
120
|
+
[`hds-tabs--list-horizontal`]: wideEnough,
|
|
121
|
+
"hds-tabs--list-vertical": !wideEnough
|
|
122
|
+
} : {
|
|
123
|
+
"hds-tabs--list-vertical": true
|
|
124
|
+
},
|
|
125
|
+
className
|
|
126
|
+
),
|
|
127
|
+
ref: tabsListRef,
|
|
128
|
+
role: "tablist"
|
|
129
|
+
}, rest), {
|
|
130
|
+
children
|
|
131
|
+
})
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
TabList.displayName = "TabList";
|
|
135
|
+
var Tab = (0, import_react3.forwardRef)(
|
|
136
|
+
(_a, ref) => {
|
|
137
|
+
var _b = _a, { as: Component = "button", children, tabId, className, onClick } = _b, rest = __objRest(_b, ["as", "children", "tabId", "className", "onClick"]);
|
|
138
|
+
const context = (0, import_react3.useContext)(TabsContext);
|
|
139
|
+
if (!context.mounted) {
|
|
140
|
+
throw new Error("Context required. Did you use <TabContent/> outside of <Tabs/>?");
|
|
141
|
+
}
|
|
142
|
+
const toggleTab = (e) => {
|
|
143
|
+
e.preventDefault();
|
|
144
|
+
context.toggleActiveTabId(tabId);
|
|
145
|
+
onClick && onClick(e);
|
|
146
|
+
};
|
|
147
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
148
|
+
Component,
|
|
149
|
+
__spreadProps(__spreadValues({
|
|
150
|
+
className: (0, import_typed_classname.clsx)(
|
|
151
|
+
"hds-tabs--tab",
|
|
152
|
+
{ "hds-tabs--tab-active": context.activeTabId === tabId },
|
|
153
|
+
className
|
|
154
|
+
),
|
|
155
|
+
"data-tabid": tabId,
|
|
156
|
+
onClick: toggleTab,
|
|
157
|
+
ref,
|
|
158
|
+
role: "tab"
|
|
159
|
+
}, rest), {
|
|
160
|
+
children
|
|
161
|
+
})
|
|
162
|
+
);
|
|
163
|
+
}
|
|
164
|
+
);
|
|
165
|
+
Tab.displayName = "Tab";
|
|
166
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
167
|
+
0 && (module.exports = {
|
|
168
|
+
Tab,
|
|
169
|
+
TabList
|
|
170
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { HTMLAttributes, ReactElement } from 'react';
|
|
2
|
+
import { O as OverridableComponent } from '../utils-BfZsjuFH.mjs';
|
|
3
|
+
import { TabContentsProps } from './tabs-content.mjs';
|
|
4
|
+
import { TabListProps } from './tabs-list.mjs';
|
|
5
|
+
import 'react/jsx-runtime';
|
|
6
|
+
|
|
7
|
+
interface TabsProps extends HTMLAttributes<HTMLElement> {
|
|
8
|
+
children: ReactElement<TabListProps | TabContentsProps>[] | ReactElement;
|
|
9
|
+
/**
|
|
10
|
+
* Define which tab to use as default. Must be one of the <Tab/>s identifier.
|
|
11
|
+
*/
|
|
12
|
+
defaultTab: string;
|
|
13
|
+
}
|
|
14
|
+
declare const Tabs: OverridableComponent<TabsProps, HTMLDivElement>;
|
|
15
|
+
|
|
16
|
+
export { Tabs, type TabsProps };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { HTMLAttributes, ReactElement } from 'react';
|
|
2
|
+
import { O as OverridableComponent } from '../utils-BfZsjuFH.js';
|
|
3
|
+
import { TabContentsProps } from './tabs-content.js';
|
|
4
|
+
import { TabListProps } from './tabs-list.js';
|
|
5
|
+
import 'react/jsx-runtime';
|
|
6
|
+
|
|
7
|
+
interface TabsProps extends HTMLAttributes<HTMLElement> {
|
|
8
|
+
children: ReactElement<TabListProps | TabContentsProps>[] | ReactElement;
|
|
9
|
+
/**
|
|
10
|
+
* Define which tab to use as default. Must be one of the <Tab/>s identifier.
|
|
11
|
+
*/
|
|
12
|
+
defaultTab: string;
|
|
13
|
+
}
|
|
14
|
+
declare const Tabs: OverridableComponent<TabsProps, HTMLDivElement>;
|
|
15
|
+
|
|
16
|
+
export { Tabs, type TabsProps };
|