@postenbring/hedwig-react 0.0.0-FPfHEZ66-tabs-component-20231214140156
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/accordion/accordion-item-content.d.mts +9 -0
- package/dist/accordion/accordion-item-content.d.ts +9 -0
- package/dist/accordion/accordion-item-content.js +97 -0
- package/dist/accordion/accordion-item-content.mjs +8 -0
- package/dist/accordion/accordion-item-trigger.d.mts +9 -0
- package/dist/accordion/accordion-item-trigger.d.ts +9 -0
- package/dist/accordion/accordion-item-trigger.js +121 -0
- package/dist/accordion/accordion-item-trigger.mjs +8 -0
- package/dist/accordion/accordion-item.d.mts +15 -0
- package/dist/accordion/accordion-item.d.ts +15 -0
- package/dist/accordion/accordion-item.js +115 -0
- package/dist/accordion/accordion-item.mjs +8 -0
- package/dist/accordion/accordion.d.mts +28 -0
- package/dist/accordion/accordion.d.ts +28 -0
- package/dist/accordion/accordion.js +92 -0
- package/dist/accordion/accordion.mjs +8 -0
- package/dist/accordion/index.d.mts +6 -0
- package/dist/accordion/index.d.ts +6 -0
- package/dist/accordion/index.js +227 -0
- package/dist/accordion/index.mjs +21 -0
- package/dist/badge/badge.d.mts +28 -0
- package/dist/badge/badge.d.ts +28 -0
- package/dist/badge/badge.js +109 -0
- package/dist/badge/badge.mjs +13 -0
- package/dist/badge/index.d.mts +3 -0
- package/dist/badge/index.d.ts +3 -0
- package/dist/badge/index.js +115 -0
- package/dist/badge/index.mjs +14 -0
- package/dist/box/box.d.mts +36 -0
- package/dist/box/box.d.ts +36 -0
- package/dist/box/box.js +130 -0
- package/dist/box/box.mjs +9 -0
- package/dist/box/index.d.mts +3 -0
- package/dist/box/index.d.ts +3 -0
- package/dist/box/index.js +136 -0
- package/dist/box/index.mjs +10 -0
- package/dist/breadcrumb/breadcrumb.d.mts +43 -0
- package/dist/breadcrumb/breadcrumb.d.ts +43 -0
- package/dist/breadcrumb/breadcrumb.js +52 -0
- package/dist/breadcrumb/breadcrumb.mjs +7 -0
- package/dist/breadcrumb/index.d.mts +3 -0
- package/dist/breadcrumb/index.d.ts +3 -0
- package/dist/breadcrumb/index.js +58 -0
- package/dist/breadcrumb/index.mjs +8 -0
- package/dist/button/button.d.mts +37 -0
- package/dist/button/button.d.ts +37 -0
- package/dist/button/button.js +124 -0
- package/dist/button/button.mjs +11 -0
- package/dist/button/index.d.mts +3 -0
- package/dist/button/index.d.ts +3 -0
- package/dist/button/index.js +130 -0
- package/dist/button/index.mjs +12 -0
- package/dist/chunk-2QSL2PSS.mjs +63 -0
- package/dist/chunk-2V6SWZ5G.mjs +16 -0
- package/dist/chunk-3VUAKZB2.mjs +48 -0
- package/dist/chunk-5OAMKZDX.mjs +6 -0
- package/dist/chunk-6XSKLHN6.mjs +49 -0
- package/dist/chunk-74UG2OYZ.mjs +111 -0
- package/dist/chunk-7SCOBRDZ.mjs +5 -0
- package/dist/chunk-AJBQ2EJU.mjs +5 -0
- package/dist/chunk-BRBGRJ2I.mjs +18 -0
- package/dist/chunk-ENRMC5K7.mjs +75 -0
- package/dist/chunk-FSBY3NKV.mjs +47 -0
- package/dist/chunk-FUJQIYOF.mjs +37 -0
- package/dist/chunk-GMGUONH5.mjs +34 -0
- package/dist/chunk-HMESGVY5.mjs +21 -0
- package/dist/chunk-IEY4EQ4E.mjs +5 -0
- package/dist/chunk-J7U4Z726.mjs +39 -0
- package/dist/chunk-L7DYK6OS.mjs +58 -0
- package/dist/chunk-LNPO2XQW.mjs +5 -0
- package/dist/chunk-LZSDIT5D.mjs +5 -0
- package/dist/chunk-MNSMCSAR.mjs +59 -0
- package/dist/chunk-Q2HYT3Z7.mjs +16 -0
- package/dist/chunk-QV33ZHNO.mjs +60 -0
- package/dist/chunk-RXUPE4MM.mjs +82 -0
- package/dist/chunk-RY53CJI7.mjs +53 -0
- package/dist/chunk-TES7CVGU.mjs +34 -0
- package/dist/chunk-TFY7NZMU.mjs +5 -0
- package/dist/chunk-VX6MSLLO.mjs +5 -0
- package/dist/chunk-X4D24ZRP.mjs +63 -0
- package/dist/chunk-XJ44O3HY.mjs +58 -0
- package/dist/chunk-YFBW5ZRC.mjs +18 -0
- package/dist/chunk-YRAMCYSB.mjs +5 -0
- package/dist/dropdown/dropdown.d.mts +15 -0
- package/dist/dropdown/dropdown.d.ts +15 -0
- package/dist/dropdown/dropdown.js +95 -0
- package/dist/dropdown/dropdown.mjs +7 -0
- package/dist/dropdown/index.d.mts +3 -0
- package/dist/dropdown/index.d.ts +3 -0
- package/dist/dropdown/index.js +101 -0
- package/dist/dropdown/index.mjs +8 -0
- package/dist/index.d.mts +21 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.js +944 -0
- package/dist/index.mjs +114 -0
- package/dist/input/index.d.mts +3 -0
- package/dist/input/index.d.ts +3 -0
- package/dist/input/index.js +121 -0
- package/dist/input/index.mjs +13 -0
- package/dist/input/input.d.mts +13 -0
- package/dist/input/input.d.ts +13 -0
- package/dist/input/input.js +115 -0
- package/dist/input/input.mjs +7 -0
- package/dist/link/index.d.mts +3 -0
- package/dist/link/index.d.ts +3 -0
- package/dist/link/index.js +87 -0
- package/dist/link/index.mjs +8 -0
- package/dist/link/link.d.mts +18 -0
- package/dist/link/link.d.ts +18 -0
- package/dist/link/link.js +81 -0
- package/dist/link/link.mjs +7 -0
- package/dist/list/description-list.d.mts +32 -0
- package/dist/list/description-list.d.ts +32 -0
- package/dist/list/description-list.js +98 -0
- package/dist/list/description-list.mjs +13 -0
- package/dist/list/index.d.mts +5 -0
- package/dist/list/index.d.ts +5 -0
- package/dist/list/index.js +159 -0
- package/dist/list/index.mjs +22 -0
- package/dist/list/link-list.d.mts +13 -0
- package/dist/list/link-list.d.ts +13 -0
- package/dist/list/link-list.js +108 -0
- package/dist/list/link-list.mjs +8 -0
- package/dist/list/list.d.mts +25 -0
- package/dist/list/list.d.ts +25 -0
- package/dist/list/list.js +101 -0
- package/dist/list/list.mjs +9 -0
- package/dist/message/index.d.mts +16 -0
- package/dist/message/index.d.ts +16 -0
- package/dist/message/index.js +197 -0
- package/dist/message/index.mjs +14 -0
- package/dist/message/message.d.mts +18 -0
- package/dist/message/message.d.ts +18 -0
- package/dist/message/message.js +183 -0
- package/dist/message/message.mjs +12 -0
- package/dist/modal/index.d.mts +9 -0
- package/dist/modal/index.d.ts +9 -0
- package/dist/modal/index.js +218 -0
- package/dist/modal/index.mjs +13 -0
- package/dist/modal/modal.d.mts +13 -0
- package/dist/modal/modal.d.ts +13 -0
- package/dist/modal/modal.js +206 -0
- package/dist/modal/modal.mjs +11 -0
- package/dist/tabs/index.d.mts +4 -0
- package/dist/tabs/index.d.ts +4 -0
- package/dist/tabs/index.js +202 -0
- package/dist/tabs/index.mjs +17 -0
- package/dist/tabs/tabs.d.mts +49 -0
- package/dist/tabs/tabs.d.ts +49 -0
- package/dist/tabs/tabs.js +196 -0
- package/dist/tabs/tabs.mjs +16 -0
- package/dist/utils-BfZsjuFH.d.mts +17 -0
- package/dist/utils-BfZsjuFH.d.ts +17 -0
- package/package.json +34 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import "../chunk-TFY7NZMU.mjs";
|
|
2
|
+
import {
|
|
3
|
+
Tab,
|
|
4
|
+
TabContent,
|
|
5
|
+
TabContents,
|
|
6
|
+
TabList,
|
|
7
|
+
Tabs
|
|
8
|
+
} from "../chunk-74UG2OYZ.mjs";
|
|
9
|
+
import "../chunk-FSBY3NKV.mjs";
|
|
10
|
+
import "../chunk-FUJQIYOF.mjs";
|
|
11
|
+
export {
|
|
12
|
+
Tab,
|
|
13
|
+
TabContent,
|
|
14
|
+
TabContents,
|
|
15
|
+
TabList,
|
|
16
|
+
Tabs
|
|
17
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
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 TabsProps extends HTMLAttributes<HTMLElement> {
|
|
6
|
+
children: ReactElement<TabListProps> | ReactElement<TabContentsProps>;
|
|
7
|
+
/**
|
|
8
|
+
* Define which tab to use as default
|
|
9
|
+
*/
|
|
10
|
+
defaultTab: string;
|
|
11
|
+
}
|
|
12
|
+
declare const Tabs: OverridableComponent<TabsProps, HTMLDivElement>;
|
|
13
|
+
interface TabListProps extends HTMLAttributes<HTMLDivElement> {
|
|
14
|
+
children: ReactElement<TabProps> | ReactElement<TabProps>[];
|
|
15
|
+
/**
|
|
16
|
+
* Direction of the tabs. Can either be vertical or horizontal.
|
|
17
|
+
* Horizontal breaks on window width with fallback back to vertical
|
|
18
|
+
*/
|
|
19
|
+
direction?: "vertical" | "horizontal";
|
|
20
|
+
}
|
|
21
|
+
declare function TabList({ children, direction, className, ...rest }: TabListProps): react_jsx_runtime.JSX.Element;
|
|
22
|
+
declare namespace TabList {
|
|
23
|
+
var displayName: string;
|
|
24
|
+
}
|
|
25
|
+
interface TabProps extends HTMLAttributes<HTMLButtonElement> {
|
|
26
|
+
children: ReactElement<HTMLElement> | string;
|
|
27
|
+
/**
|
|
28
|
+
* Identifier for the tab
|
|
29
|
+
*/
|
|
30
|
+
tabId: string;
|
|
31
|
+
}
|
|
32
|
+
declare const Tab: OverridableComponent<TabProps, HTMLButtonElement>;
|
|
33
|
+
interface TabContentsProps extends HTMLAttributes<HTMLDivElement> {
|
|
34
|
+
children: ReactElement<TabContentProps> | ReactElement<TabContentProps>[];
|
|
35
|
+
}
|
|
36
|
+
declare function TabContents({ children, ...rest }: TabContentsProps): react_jsx_runtime.JSX.Element;
|
|
37
|
+
declare namespace TabContents {
|
|
38
|
+
var displayName: string;
|
|
39
|
+
}
|
|
40
|
+
interface TabContentProps extends HTMLAttributes<HTMLElement> {
|
|
41
|
+
children: ReactElement<HTMLElement> | ReactElement<HTMLElement>[] | string;
|
|
42
|
+
/**
|
|
43
|
+
* Content for the referenced tabId
|
|
44
|
+
*/
|
|
45
|
+
forTabId: string;
|
|
46
|
+
}
|
|
47
|
+
declare const TabContent: OverridableComponent<TabContentProps, HTMLElement>;
|
|
48
|
+
|
|
49
|
+
export { Tab, TabContent, type TabContentProps, TabContents, type TabContentsProps, TabList, type TabListProps, type TabProps, Tabs, type TabsProps };
|
|
@@ -0,0 +1,49 @@
|
|
|
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 TabsProps extends HTMLAttributes<HTMLElement> {
|
|
6
|
+
children: ReactElement<TabListProps> | ReactElement<TabContentsProps>;
|
|
7
|
+
/**
|
|
8
|
+
* Define which tab to use as default
|
|
9
|
+
*/
|
|
10
|
+
defaultTab: string;
|
|
11
|
+
}
|
|
12
|
+
declare const Tabs: OverridableComponent<TabsProps, HTMLDivElement>;
|
|
13
|
+
interface TabListProps extends HTMLAttributes<HTMLDivElement> {
|
|
14
|
+
children: ReactElement<TabProps> | ReactElement<TabProps>[];
|
|
15
|
+
/**
|
|
16
|
+
* Direction of the tabs. Can either be vertical or horizontal.
|
|
17
|
+
* Horizontal breaks on window width with fallback back to vertical
|
|
18
|
+
*/
|
|
19
|
+
direction?: "vertical" | "horizontal";
|
|
20
|
+
}
|
|
21
|
+
declare function TabList({ children, direction, className, ...rest }: TabListProps): react_jsx_runtime.JSX.Element;
|
|
22
|
+
declare namespace TabList {
|
|
23
|
+
var displayName: string;
|
|
24
|
+
}
|
|
25
|
+
interface TabProps extends HTMLAttributes<HTMLButtonElement> {
|
|
26
|
+
children: ReactElement<HTMLElement> | string;
|
|
27
|
+
/**
|
|
28
|
+
* Identifier for the tab
|
|
29
|
+
*/
|
|
30
|
+
tabId: string;
|
|
31
|
+
}
|
|
32
|
+
declare const Tab: OverridableComponent<TabProps, HTMLButtonElement>;
|
|
33
|
+
interface TabContentsProps extends HTMLAttributes<HTMLDivElement> {
|
|
34
|
+
children: ReactElement<TabContentProps> | ReactElement<TabContentProps>[];
|
|
35
|
+
}
|
|
36
|
+
declare function TabContents({ children, ...rest }: TabContentsProps): react_jsx_runtime.JSX.Element;
|
|
37
|
+
declare namespace TabContents {
|
|
38
|
+
var displayName: string;
|
|
39
|
+
}
|
|
40
|
+
interface TabContentProps extends HTMLAttributes<HTMLElement> {
|
|
41
|
+
children: ReactElement<HTMLElement> | ReactElement<HTMLElement>[] | string;
|
|
42
|
+
/**
|
|
43
|
+
* Content for the referenced tabId
|
|
44
|
+
*/
|
|
45
|
+
forTabId: string;
|
|
46
|
+
}
|
|
47
|
+
declare const TabContent: OverridableComponent<TabContentProps, HTMLElement>;
|
|
48
|
+
|
|
49
|
+
export { Tab, TabContent, type TabContentProps, TabContents, type TabContentsProps, TabList, type TabListProps, type TabProps, Tabs, type TabsProps };
|
|
@@ -0,0 +1,196 @@
|
|
|
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.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_react3 = require("react");
|
|
70
|
+
var import_typed_classname = require("@postenbring/hedwig-css/typed-classname/index.mjs");
|
|
71
|
+
|
|
72
|
+
// src/utils.ts
|
|
73
|
+
var React = __toESM(require("react"));
|
|
74
|
+
var import_react = require("react");
|
|
75
|
+
function useResize(ref) {
|
|
76
|
+
const [width, setWidth] = (0, import_react.useState)(0);
|
|
77
|
+
const [height, setHeight] = (0, import_react.useState)(0);
|
|
78
|
+
const handleResize = (0, import_react.useCallback)(() => {
|
|
79
|
+
var _a, _b, _c, _d;
|
|
80
|
+
if ((ref == null ? void 0 : ref.current) !== null) {
|
|
81
|
+
setWidth((_b = (_a = ref == null ? void 0 : ref.current) == null ? void 0 : _a.offsetWidth) != null ? _b : 0);
|
|
82
|
+
setHeight((_d = (_c = ref == null ? void 0 : ref.current) == null ? void 0 : _c.offsetHeight) != null ? _d : 0);
|
|
83
|
+
}
|
|
84
|
+
}, [ref]);
|
|
85
|
+
(0, import_react.useEffect)(() => {
|
|
86
|
+
window.addEventListener("load", handleResize);
|
|
87
|
+
window.addEventListener("resize", handleResize);
|
|
88
|
+
return () => {
|
|
89
|
+
window.removeEventListener("load", handleResize);
|
|
90
|
+
window.removeEventListener("resize", handleResize);
|
|
91
|
+
};
|
|
92
|
+
}, [ref, handleResize]);
|
|
93
|
+
(0, import_react.useEffect)(() => {
|
|
94
|
+
handleResize();
|
|
95
|
+
}, []);
|
|
96
|
+
return { width, height };
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// src/tabs/context.ts
|
|
100
|
+
var import_react2 = require("react");
|
|
101
|
+
var TabsContext = (0, import_react2.createContext)({
|
|
102
|
+
activeTabId: void 0,
|
|
103
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars -- Added default section, without handling
|
|
104
|
+
toggleActiveTabId: (tabId) => {
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
// src/tabs/tabs.tsx
|
|
109
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
110
|
+
var Tabs = (0, import_react3.forwardRef)(
|
|
111
|
+
(_a, ref) => {
|
|
112
|
+
var _b = _a, { as: Component = "div", defaultTab, children } = _b, rest = __objRest(_b, ["as", "defaultTab", "children"]);
|
|
113
|
+
const [activeTabId, toggleActiveTabId] = (0, import_react3.useState)(defaultTab);
|
|
114
|
+
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)(TabsContext.Provider, { value: { activeTabId, toggleActiveTabId }, children }) }));
|
|
115
|
+
}
|
|
116
|
+
);
|
|
117
|
+
Tabs.displayName = "Tabs";
|
|
118
|
+
function TabList(_a) {
|
|
119
|
+
var _b = _a, { children, direction = "horizontal", className } = _b, rest = __objRest(_b, ["children", "direction", "className"]);
|
|
120
|
+
const tabsListRef = (0, import_react3.useRef)(null);
|
|
121
|
+
const { width: tabsWidth } = useResize(tabsListRef);
|
|
122
|
+
const { innerWidth } = window;
|
|
123
|
+
const wideEnough = innerWidth >= tabsWidth;
|
|
124
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
125
|
+
"div",
|
|
126
|
+
__spreadProps(__spreadValues({
|
|
127
|
+
className: (0, import_typed_classname.clsx)(
|
|
128
|
+
"hds-tabs--list",
|
|
129
|
+
direction === "horizontal" ? {
|
|
130
|
+
[`hds-tabs--list-horizontal`]: wideEnough,
|
|
131
|
+
"hds-tabs--list-vertical": !wideEnough
|
|
132
|
+
} : {
|
|
133
|
+
"hds-tabs--list-vertical": true
|
|
134
|
+
},
|
|
135
|
+
className
|
|
136
|
+
),
|
|
137
|
+
ref: tabsListRef,
|
|
138
|
+
role: "tablist"
|
|
139
|
+
}, rest), {
|
|
140
|
+
children
|
|
141
|
+
})
|
|
142
|
+
);
|
|
143
|
+
}
|
|
144
|
+
TabList.displayName = "TabList";
|
|
145
|
+
var Tab = (0, import_react3.forwardRef)(
|
|
146
|
+
(_a, ref) => {
|
|
147
|
+
var _b = _a, { as: Component = "button", children, tabId, className, onClick } = _b, rest = __objRest(_b, ["as", "children", "tabId", "className", "onClick"]);
|
|
148
|
+
const context = (0, import_react3.useContext)(TabsContext);
|
|
149
|
+
const toggleTab = (e) => {
|
|
150
|
+
e.preventDefault();
|
|
151
|
+
context.toggleActiveTabId(tabId);
|
|
152
|
+
onClick && onClick(e);
|
|
153
|
+
};
|
|
154
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
155
|
+
Component,
|
|
156
|
+
__spreadProps(__spreadValues({
|
|
157
|
+
className: (0, import_typed_classname.clsx)(
|
|
158
|
+
"hds-tabs--tab",
|
|
159
|
+
{ "hds-tabs--tab-active": context.activeTabId === tabId },
|
|
160
|
+
className
|
|
161
|
+
),
|
|
162
|
+
"data-tabid": tabId,
|
|
163
|
+
onClick: toggleTab,
|
|
164
|
+
ref,
|
|
165
|
+
role: "tab"
|
|
166
|
+
}, rest), {
|
|
167
|
+
children
|
|
168
|
+
})
|
|
169
|
+
);
|
|
170
|
+
}
|
|
171
|
+
);
|
|
172
|
+
Tab.displayName = "Tab";
|
|
173
|
+
function TabContents(_a) {
|
|
174
|
+
var _b = _a, { children } = _b, rest = __objRest(_b, ["children"]);
|
|
175
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", __spreadProps(__spreadValues({ className: (0, import_typed_classname.clsx)("hds-tabs--contents") }, rest), { children }));
|
|
176
|
+
}
|
|
177
|
+
TabContents.displayName = "TabContents";
|
|
178
|
+
var TabContent = (0, import_react3.forwardRef)(
|
|
179
|
+
(_a, ref) => {
|
|
180
|
+
var _b = _a, { as: Component = "div", forTabId, children } = _b, rest = __objRest(_b, ["as", "forTabId", "children"]);
|
|
181
|
+
const context = (0, import_react3.useContext)(TabsContext);
|
|
182
|
+
if (context.activeTabId === forTabId) {
|
|
183
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, __spreadProps(__spreadValues({}, rest), { ref, children }));
|
|
184
|
+
}
|
|
185
|
+
return null;
|
|
186
|
+
}
|
|
187
|
+
);
|
|
188
|
+
TabContent.displayName = "TabContent";
|
|
189
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
190
|
+
0 && (module.exports = {
|
|
191
|
+
Tab,
|
|
192
|
+
TabContent,
|
|
193
|
+
TabContents,
|
|
194
|
+
TabList,
|
|
195
|
+
Tabs
|
|
196
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { RefAttributes, FC, ElementType, ComponentPropsWithRef } from 'react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* OverridableComponent makes the `as` prop available,
|
|
5
|
+
* to be used to override the html element being used for a component
|
|
6
|
+
*
|
|
7
|
+
* Taken from digdir design system: https://github.com/digdir/designsystem/blob/main/packages/react/src/types/OverridableComponent.ts
|
|
8
|
+
*/
|
|
9
|
+
type OverridableComponent<ComponentProps, Element extends HTMLElement> = {
|
|
10
|
+
(props: ComponentProps & RefAttributes<Element>): ReturnType<FC>;
|
|
11
|
+
<As extends ElementType>(props: {
|
|
12
|
+
/** Override html element */
|
|
13
|
+
as?: As;
|
|
14
|
+
} & ComponentProps & Omit<ComponentPropsWithRef<As>, keyof ComponentProps>): ReturnType<FC>;
|
|
15
|
+
} & Pick<FC, "displayName">;
|
|
16
|
+
|
|
17
|
+
export type { OverridableComponent as O };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { RefAttributes, FC, ElementType, ComponentPropsWithRef } from 'react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* OverridableComponent makes the `as` prop available,
|
|
5
|
+
* to be used to override the html element being used for a component
|
|
6
|
+
*
|
|
7
|
+
* Taken from digdir design system: https://github.com/digdir/designsystem/blob/main/packages/react/src/types/OverridableComponent.ts
|
|
8
|
+
*/
|
|
9
|
+
type OverridableComponent<ComponentProps, Element extends HTMLElement> = {
|
|
10
|
+
(props: ComponentProps & RefAttributes<Element>): ReturnType<FC>;
|
|
11
|
+
<As extends ElementType>(props: {
|
|
12
|
+
/** Override html element */
|
|
13
|
+
as?: As;
|
|
14
|
+
} & ComponentProps & Omit<ComponentPropsWithRef<As>, keyof ComponentProps>): ReturnType<FC>;
|
|
15
|
+
} & Pick<FC, "displayName">;
|
|
16
|
+
|
|
17
|
+
export type { OverridableComponent as O };
|
package/package.json
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@postenbring/hedwig-react",
|
|
3
|
+
"version": "0.0.0-FPfHEZ66-tabs-component-20231214140156",
|
|
4
|
+
"main": "./dist/index.js",
|
|
5
|
+
"module": "./dist/index.mjs",
|
|
6
|
+
"types": "./dist/index.d.ts",
|
|
7
|
+
"sideEffects": true,
|
|
8
|
+
"license": "MIT",
|
|
9
|
+
"files": [
|
|
10
|
+
"dist/**"
|
|
11
|
+
],
|
|
12
|
+
"devDependencies": {
|
|
13
|
+
"@types/react": "^18.2.43",
|
|
14
|
+
"@types/react-dom": "^18.2.15",
|
|
15
|
+
"react": "^18.2.0",
|
|
16
|
+
"tsup": "^8.0.1",
|
|
17
|
+
"typescript": "^5.3.3",
|
|
18
|
+
"eslint-config-custom": "0.0.1",
|
|
19
|
+
"hedwig-tsconfig": "0.0.0"
|
|
20
|
+
},
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"@postenbring/hedwig-css": "0.0.0-FPfHEZ66-tabs-component-20231214140156"
|
|
23
|
+
},
|
|
24
|
+
"publishConfig": {
|
|
25
|
+
"access": "public"
|
|
26
|
+
},
|
|
27
|
+
"scripts": {
|
|
28
|
+
"build": "tsup --format esm,cjs --dts --external react",
|
|
29
|
+
"dev": "tsup --format esm,cjs --watch --dts --external react",
|
|
30
|
+
"lint": "eslint src/",
|
|
31
|
+
"typecheck": "tsc --noEmit",
|
|
32
|
+
"clean": "rm -rf .turbo node_modules dist"
|
|
33
|
+
}
|
|
34
|
+
}
|