@oslokommune/punkt-react 20.2.0 → 20.2.2
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/CHANGELOG.md +21 -0
- package/dist/components/header/HeaderGlobal.js +148 -146
- package/dist/components/header/HeaderService.js +2 -2
- package/dist/components/header/types.d.ts +26 -93
- package/dist/components/header-menu/HeaderMenu.js +108 -106
- package/dist/components/interfaces.d.ts +3 -2
- package/dist/components/tabs/TabItem.d.ts +2 -10
- package/dist/components/tabs/TabItem.js +62 -60
- package/dist/components/tabs/Tabs.d.ts +4 -23
- package/dist/components/tabs/Tabs.js +38 -43
- package/dist/punkt-react.cjs +1 -1
- package/dist/shared-strings/index.d.ts +1 -1
- package/dist/shared-strings/nb.d.ts +1 -0
- package/dist/shared-strings/nb.js +2 -1
- package/dist/shared-strings/resolve.d.ts +9 -0
- package/dist/shared-strings/resolve.js +9 -1
- package/dist/shared-types/header-footer.d.ts +0 -44
- package/dist/shared-types/header.d.ts +214 -10
- package/dist/shared-types/header.js +26 -0
- package/dist/shared-types/index.d.ts +5 -3
- package/dist/shared-types/index.js +24 -22
- package/dist/shared-types/tabs.d.ts +66 -0
- package/dist/shared-types/tabs.js +12 -0
- package/package.json +2 -2
- package/src/components/header/HeaderGlobal.test.tsx +82 -0
- package/src/components/header/HeaderGlobal.tsx +35 -16
- package/src/components/header/HeaderService.tsx +12 -12
- package/src/components/header/types.ts +37 -97
- package/src/components/header-menu/HeaderMenu.test.tsx +14 -0
- package/src/components/header-menu/HeaderMenu.tsx +7 -2
- package/src/components/interfaces.ts +3 -2
- package/src/components/tabs/TabItem.tsx +18 -12
- package/src/components/tabs/Tabs.test.tsx +22 -0
- package/src/components/tabs/Tabs.tsx +10 -43
|
@@ -1,197 +1,199 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import "../../shared-types/index.js";
|
|
3
3
|
import { DEFAULT_HEADER_FOOTER_URL as e } from "../../shared-types/header-footer.js";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
4
|
+
import { resolveOverride as t } from "../../shared-strings/resolve.js";
|
|
5
|
+
import { deriveSocialIcon as n, mapOdsIcon as r } from "../../shared-utils/header-footer/icon-map.js";
|
|
6
|
+
import { fetchHeaderFooterData as i } from "../../shared-utils/header-footer/fetch-header-footer-data.js";
|
|
7
|
+
import { selectLocaleData as a } from "../../shared-utils/header-footer/select-megamenu.js";
|
|
8
|
+
import { useElementWidth as o } from "../../hooks/useElementWidth.js";
|
|
9
|
+
import { usePktStrings as s } from "../../hooks/usePktStrings.js";
|
|
10
|
+
import { PktAccordion as c } from "../accordion/Accordion.js";
|
|
11
|
+
import { PktAccordionItem as l } from "../accordion/AccordionItem.js";
|
|
12
|
+
import { PktIcon as u } from "../icon/Icon.js";
|
|
13
|
+
import { PktStringsContext as d } from "../strings/PktStringsProvider.js";
|
|
14
|
+
import { useCallback as f, useContext as p, useEffect as m, useMemo as h, useRef as g, useState as _ } from "react";
|
|
15
|
+
import { Fragment as v, jsx as y, jsxs as b } from "react/jsx-runtime";
|
|
14
16
|
// src/components/header-menu/HeaderMenu.tsx
|
|
15
|
-
var
|
|
16
|
-
let
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}, [
|
|
20
|
-
|
|
21
|
-
}, [
|
|
22
|
-
let
|
|
23
|
-
|
|
24
|
-
}, [
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}, [
|
|
28
|
-
if (
|
|
17
|
+
var x = ({ dataUrl: n = e, data: r, locale: c = "nb-NO", open: l = !1, mobileBreakpoint: u = 768, className: x, onDataLoaded: S, onDataError: D, ref: k, strings: A, ...j }) => {
|
|
18
|
+
let M = s(["header"], A).header, N = p(d), [P, F] = _("loading"), [I, L] = _(void 0), R = r ? "ready" : P, z = g(S), B = g(D);
|
|
19
|
+
m(() => {
|
|
20
|
+
z.current = S;
|
|
21
|
+
}, [S]), m(() => {
|
|
22
|
+
B.current = D;
|
|
23
|
+
}, [D]);
|
|
24
|
+
let V = g(null), H = f((e) => {
|
|
25
|
+
V.current = e, typeof k == "function" ? k(e) : k && (k.current = e);
|
|
26
|
+
}, [k]), U = o(V) < u;
|
|
27
|
+
m(() => {
|
|
28
|
+
r && z.current?.(r);
|
|
29
|
+
}, [r]), m(() => {
|
|
30
|
+
if (r) return;
|
|
29
31
|
let e = new AbortController();
|
|
30
|
-
return
|
|
31
|
-
e.signal.aborted || (
|
|
32
|
+
return i(n, e.signal).then((t) => {
|
|
33
|
+
e.signal.aborted || (L(t), F("ready"), z.current?.(t));
|
|
32
34
|
}).catch((e) => {
|
|
33
|
-
e.name !== "AbortError" && (
|
|
35
|
+
e.name !== "AbortError" && (F("error"), B.current?.(e));
|
|
34
36
|
}), () => e.abort();
|
|
35
|
-
}, [
|
|
36
|
-
let
|
|
37
|
+
}, [r, n]);
|
|
38
|
+
let W = r ?? I, G = h(() => a(W, c), [W, c]), K = [
|
|
37
39
|
"pkt-header-menu",
|
|
38
|
-
|
|
39
|
-
|
|
40
|
+
l && "pkt-header-menu--open",
|
|
41
|
+
x
|
|
40
42
|
].filter(Boolean).join(" ");
|
|
41
|
-
if (
|
|
42
|
-
...
|
|
43
|
-
ref:
|
|
44
|
-
className:
|
|
43
|
+
if (R === "loading") return /* @__PURE__ */ y("nav", {
|
|
44
|
+
...j,
|
|
45
|
+
ref: H,
|
|
46
|
+
className: K,
|
|
45
47
|
"aria-busy": "true",
|
|
46
|
-
children: /* @__PURE__ */
|
|
48
|
+
children: /* @__PURE__ */ y("p", {
|
|
47
49
|
className: "pkt-header-menu__loading",
|
|
48
|
-
children:
|
|
50
|
+
children: M.menuLoading
|
|
49
51
|
})
|
|
50
52
|
});
|
|
51
|
-
if (
|
|
52
|
-
...
|
|
53
|
-
ref:
|
|
54
|
-
className:
|
|
55
|
-
"aria-hidden": !
|
|
56
|
-
children: /* @__PURE__ */
|
|
53
|
+
if (R === "error" || !G) return /* @__PURE__ */ y("nav", {
|
|
54
|
+
...j,
|
|
55
|
+
ref: H,
|
|
56
|
+
className: K,
|
|
57
|
+
"aria-hidden": !l,
|
|
58
|
+
children: /* @__PURE__ */ y("p", {
|
|
57
59
|
className: "pkt-header-menu__error",
|
|
58
|
-
children:
|
|
60
|
+
children: M.menuLoadError
|
|
59
61
|
})
|
|
60
62
|
});
|
|
61
|
-
let { megamenu:
|
|
62
|
-
return /* @__PURE__ */
|
|
63
|
-
...
|
|
64
|
-
ref:
|
|
65
|
-
className:
|
|
66
|
-
"aria-label":
|
|
63
|
+
let { megamenu: q, i18n: J } = G, Y = t("header", "navAriaLabel", N, A) ?? (J?.navAriaLabel || M.navAriaLabel);
|
|
64
|
+
return /* @__PURE__ */ b("nav", {
|
|
65
|
+
...j,
|
|
66
|
+
ref: H,
|
|
67
|
+
className: K,
|
|
68
|
+
"aria-label": Y,
|
|
67
69
|
children: [
|
|
68
|
-
|
|
69
|
-
services:
|
|
70
|
-
sections:
|
|
71
|
-
}) : /* @__PURE__ */
|
|
72
|
-
/* @__PURE__ */
|
|
73
|
-
/* @__PURE__ */
|
|
74
|
-
buttons:
|
|
70
|
+
U ? /* @__PURE__ */ y(C, {
|
|
71
|
+
services: q.services,
|
|
72
|
+
sections: q.sections
|
|
73
|
+
}) : /* @__PURE__ */ b(v, { children: [
|
|
74
|
+
/* @__PURE__ */ y(w, { services: q.services }),
|
|
75
|
+
/* @__PURE__ */ y(T, {
|
|
76
|
+
buttons: q.buttons,
|
|
75
77
|
mobile: !1
|
|
76
78
|
}),
|
|
77
|
-
/* @__PURE__ */
|
|
79
|
+
/* @__PURE__ */ y(E, { sections: q.sections })
|
|
78
80
|
] }),
|
|
79
|
-
/* @__PURE__ */
|
|
80
|
-
buttons:
|
|
81
|
+
/* @__PURE__ */ y(T, {
|
|
82
|
+
buttons: q.buttons,
|
|
81
83
|
mobile: !0
|
|
82
84
|
}),
|
|
83
|
-
/* @__PURE__ */
|
|
84
|
-
links:
|
|
85
|
-
some:
|
|
85
|
+
/* @__PURE__ */ y(O, {
|
|
86
|
+
links: q.links,
|
|
87
|
+
some: q.some
|
|
86
88
|
})
|
|
87
89
|
]
|
|
88
90
|
});
|
|
89
|
-
},
|
|
91
|
+
}, S = ({ services: e }) => /* @__PURE__ */ y("ul", {
|
|
90
92
|
className: "pkt-header-menu__services-list",
|
|
91
|
-
children: e.links.map((e) => /* @__PURE__ */
|
|
93
|
+
children: e.links.map((e) => /* @__PURE__ */ y("li", {
|
|
92
94
|
className: "pkt-header-menu__service",
|
|
93
|
-
children: /* @__PURE__ */
|
|
95
|
+
children: /* @__PURE__ */ b("a", {
|
|
94
96
|
className: "pkt-header-menu__service-link",
|
|
95
97
|
href: e.url,
|
|
96
|
-
children: [/* @__PURE__ */
|
|
98
|
+
children: [/* @__PURE__ */ y(u, {
|
|
97
99
|
className: "pkt-header-menu__service-icon",
|
|
98
|
-
name:
|
|
100
|
+
name: r(e.icon),
|
|
99
101
|
"aria-hidden": "true"
|
|
100
|
-
}), /* @__PURE__ */
|
|
102
|
+
}), /* @__PURE__ */ y("span", {
|
|
101
103
|
className: "pkt-header-menu__service-text",
|
|
102
104
|
children: e.text
|
|
103
105
|
})]
|
|
104
106
|
})
|
|
105
107
|
}, e.url))
|
|
106
|
-
}),
|
|
108
|
+
}), C = ({ services: e, sections: t }) => /* @__PURE__ */ y("div", {
|
|
107
109
|
className: "pkt-header-menu__sections",
|
|
108
|
-
children: /* @__PURE__ */
|
|
110
|
+
children: /* @__PURE__ */ b(c, {
|
|
109
111
|
className: "pkt-header-menu__sections-inner",
|
|
110
112
|
skin: "plus-minus",
|
|
111
113
|
name: "header-menu-accordion",
|
|
112
|
-
children: [/* @__PURE__ */
|
|
114
|
+
children: [/* @__PURE__ */ y(l, {
|
|
113
115
|
className: "pkt-header-menu__section",
|
|
114
116
|
skin: "plus-minus",
|
|
115
117
|
id: "pkt-header-menu-services",
|
|
116
118
|
title: e.title,
|
|
117
|
-
children: /* @__PURE__ */
|
|
118
|
-
}), t.map((e, t) => /* @__PURE__ */
|
|
119
|
+
children: /* @__PURE__ */ y(S, { services: e })
|
|
120
|
+
}), t.map((e, t) => /* @__PURE__ */ y(l, {
|
|
119
121
|
className: "pkt-header-menu__section",
|
|
120
122
|
skin: "plus-minus",
|
|
121
123
|
id: `pkt-header-menu-section-${t}`,
|
|
122
124
|
title: e.title,
|
|
123
|
-
children: /* @__PURE__ */
|
|
125
|
+
children: /* @__PURE__ */ y(D, { links: e.links })
|
|
124
126
|
}, e.title))]
|
|
125
127
|
})
|
|
126
|
-
}),
|
|
128
|
+
}), w = ({ services: e }) => /* @__PURE__ */ b("div", {
|
|
127
129
|
className: "pkt-header-menu__services",
|
|
128
|
-
children: [/* @__PURE__ */
|
|
130
|
+
children: [/* @__PURE__ */ y("h2", {
|
|
129
131
|
className: "pkt-header-menu__services-title",
|
|
130
132
|
children: e.title
|
|
131
|
-
}), /* @__PURE__ */
|
|
132
|
-
}),
|
|
133
|
+
}), /* @__PURE__ */ y(S, { services: e })]
|
|
134
|
+
}), T = ({ buttons: e, mobile: t }) => {
|
|
133
135
|
if (!e || e.length === 0) return null;
|
|
134
|
-
let
|
|
135
|
-
return /* @__PURE__ */
|
|
136
|
-
className:
|
|
137
|
-
children: e.map((e) => /* @__PURE__ */
|
|
136
|
+
let n = ["pkt-header-menu__buttons", t && "pkt-header-menu__buttons--mobile"].filter(Boolean).join(" ");
|
|
137
|
+
return /* @__PURE__ */ y("div", {
|
|
138
|
+
className: n,
|
|
139
|
+
children: e.map((e) => /* @__PURE__ */ b("a", {
|
|
138
140
|
className: "pkt-btn pkt-btn--secondary pkt-btn--icon-right pkt-btn--small",
|
|
139
141
|
href: e.url,
|
|
140
|
-
children: [/* @__PURE__ */
|
|
142
|
+
children: [/* @__PURE__ */ y(u, {
|
|
141
143
|
className: "pkt-btn__icon",
|
|
142
|
-
name: e.iconName ?
|
|
144
|
+
name: e.iconName ? r(e.iconName) : "user",
|
|
143
145
|
"aria-hidden": "true"
|
|
144
|
-
}), /* @__PURE__ */
|
|
146
|
+
}), /* @__PURE__ */ y("span", {
|
|
145
147
|
className: "pkt-btn__text",
|
|
146
148
|
children: e.text
|
|
147
149
|
})]
|
|
148
150
|
}, e.url))
|
|
149
151
|
});
|
|
150
|
-
},
|
|
152
|
+
}, E = ({ sections: e }) => !e || e.length === 0 ? null : /* @__PURE__ */ y("div", {
|
|
151
153
|
className: "pkt-header-menu__sections",
|
|
152
|
-
children: /* @__PURE__ */
|
|
154
|
+
children: /* @__PURE__ */ y("div", {
|
|
153
155
|
className: "pkt-header-menu__sections-inner",
|
|
154
|
-
children: e.map((e) => /* @__PURE__ */
|
|
156
|
+
children: e.map((e) => /* @__PURE__ */ b("div", {
|
|
155
157
|
className: "pkt-header-menu__section",
|
|
156
|
-
children: [/* @__PURE__ */
|
|
158
|
+
children: [/* @__PURE__ */ y("h2", {
|
|
157
159
|
className: "pkt-header-menu__section-title",
|
|
158
160
|
children: e.title
|
|
159
|
-
}), /* @__PURE__ */
|
|
161
|
+
}), /* @__PURE__ */ y(D, { links: e.links })]
|
|
160
162
|
}, e.title))
|
|
161
163
|
})
|
|
162
|
-
}),
|
|
164
|
+
}), D = ({ links: e }) => /* @__PURE__ */ y("ul", {
|
|
163
165
|
className: "pkt-header-menu__section-list",
|
|
164
|
-
children: e.map((e) => /* @__PURE__ */
|
|
166
|
+
children: e.map((e) => /* @__PURE__ */ y("li", { children: /* @__PURE__ */ y("a", {
|
|
165
167
|
className: "pkt-header-menu__section-link",
|
|
166
168
|
href: e.url,
|
|
167
169
|
children: e.text
|
|
168
170
|
}) }, e.url))
|
|
169
|
-
}),
|
|
171
|
+
}), O = ({ links: e, some: t }) => {
|
|
170
172
|
let n = e && e.length > 0, r = t && t.length > 0;
|
|
171
|
-
return !n && !r ? null : /* @__PURE__ */
|
|
173
|
+
return !n && !r ? null : /* @__PURE__ */ b("div", {
|
|
172
174
|
className: "pkt-header-menu__footer",
|
|
173
|
-
children: [n && /* @__PURE__ */
|
|
175
|
+
children: [n && /* @__PURE__ */ y("ul", {
|
|
174
176
|
className: "pkt-header-menu__footer-list",
|
|
175
|
-
children: e.map((e) => /* @__PURE__ */
|
|
177
|
+
children: e.map((e) => /* @__PURE__ */ y("li", { children: /* @__PURE__ */ y("a", {
|
|
176
178
|
className: "pkt-header-menu__footer-link",
|
|
177
179
|
href: e.url,
|
|
178
180
|
children: e.text
|
|
179
181
|
}) }, e.url))
|
|
180
|
-
}), r && /* @__PURE__ */
|
|
182
|
+
}), r && /* @__PURE__ */ y("ul", {
|
|
181
183
|
className: "pkt-header-menu__footer-list pkt-header-menu__footer-list--social",
|
|
182
|
-
children: t.map((e) => /* @__PURE__ */
|
|
184
|
+
children: t.map((e) => /* @__PURE__ */ y(k, { entry: e }, e.url))
|
|
183
185
|
})]
|
|
184
186
|
});
|
|
185
|
-
},
|
|
186
|
-
let
|
|
187
|
-
return /* @__PURE__ */
|
|
187
|
+
}, k = ({ entry: e }) => {
|
|
188
|
+
let t = n(e.url, e.text);
|
|
189
|
+
return /* @__PURE__ */ y("li", { children: /* @__PURE__ */ y("a", {
|
|
188
190
|
className: "pkt-header-menu__social-link",
|
|
189
191
|
href: e.url,
|
|
190
192
|
"aria-label": e.text,
|
|
191
|
-
children:
|
|
192
|
-
name:
|
|
193
|
+
children: t ? /* @__PURE__ */ y(u, {
|
|
194
|
+
name: t,
|
|
193
195
|
"aria-hidden": "true"
|
|
194
|
-
}) : /* @__PURE__ */
|
|
196
|
+
}) : /* @__PURE__ */ y("span", { children: e.text })
|
|
195
197
|
}) });
|
|
196
198
|
};
|
|
197
|
-
export {
|
|
199
|
+
export { x as PktHeaderMenu };
|
|
@@ -12,7 +12,7 @@ export type { IPktDatepicker } from './datepicker/Datepicker';
|
|
|
12
12
|
export type { IPktFileUpload } from './fileupload/FileUpload';
|
|
13
13
|
export type { IPktFooter } from './footer/Footer';
|
|
14
14
|
export type { IPktFooterSimple } from './footerSimple/FooterSimple';
|
|
15
|
-
export type { IPktHeader } from './header/Header';
|
|
15
|
+
export type { IPktHeader, IPktHeaderGlobal, IPktHeaderProps } from './header/Header';
|
|
16
16
|
export type { IPktHeaderMenu } from './header-menu/HeaderMenu';
|
|
17
17
|
export type { IPktHeaderService } from './header/HeaderService';
|
|
18
18
|
export type { IPktInputWrapper } from './inputwrapper/InputWrapper';
|
|
@@ -25,7 +25,8 @@ export type { IPktRadioButton } from './radio/RadioButton';
|
|
|
25
25
|
export type { IPktRadioGroup } from './radiogroup/RadioGroup';
|
|
26
26
|
export type { IPktStep } from './stepper/Step';
|
|
27
27
|
export type { IPktStepper } from './stepper/Stepper';
|
|
28
|
-
export type { IPktTab } from './tabs/Tabs';
|
|
28
|
+
export type { IPktTab, IPktTabs } from './tabs/Tabs';
|
|
29
|
+
export type { IPktTabItem } from './tabs/TabItem';
|
|
29
30
|
export type { IPktTag } from './tag/Tag';
|
|
30
31
|
export type { IPktTextarea } from './textarea/Textarea';
|
|
31
32
|
export type { IPktTextinput } from './textinput/Textinput';
|
|
@@ -1,15 +1,7 @@
|
|
|
1
1
|
import { MouseEvent, ReactNode } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
export interface IPktTabItem {
|
|
2
|
+
import { IPktTabItemBase } from '../../shared-types';
|
|
3
|
+
export interface IPktTabItem extends IPktTabItemBase {
|
|
4
4
|
children: ReactNode;
|
|
5
|
-
active?: boolean;
|
|
6
|
-
disabled?: boolean;
|
|
7
|
-
href?: string;
|
|
8
5
|
onClick?: (event: MouseEvent) => void;
|
|
9
|
-
icon?: string;
|
|
10
|
-
controls?: string;
|
|
11
|
-
tag?: string;
|
|
12
|
-
tagSkin?: TTagSkin;
|
|
13
|
-
index?: number;
|
|
14
6
|
}
|
|
15
7
|
export declare const PktTabItem: import('react').ForwardRefExoticComponent<IPktTabItem & import('react').RefAttributes<HTMLButtonElement | HTMLAnchorElement>>;
|
|
@@ -1,79 +1,81 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
2
|
+
import { TAB_ITEM_DEFAULTS as e } from "../../shared-types/tabs.js";
|
|
3
|
+
import { PktIcon as t } from "../icon/Icon.js";
|
|
4
|
+
import "../../shared-types/index.js";
|
|
5
|
+
import { syncTabPanel as n, tabIdFor as r } from "../../shared-utils/tabs/panels.js";
|
|
6
|
+
import { PktTag as i } from "../tag/Tag.js";
|
|
7
|
+
import { useTabsContext as a } from "./Tabs.js";
|
|
8
|
+
import { forwardRef as o, useEffect as s, useRef as c } from "react";
|
|
9
|
+
import { Fragment as l, jsx as u, jsxs as d } from "react/jsx-runtime";
|
|
8
10
|
// src/components/tabs/TabItem.tsx
|
|
9
|
-
var
|
|
10
|
-
let { arrowNav:
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
var f = o(({ children: o, active: f = e.active, disabled: p = e.disabled, href: m, onClick: h, icon: g, controls: _, tag: v, tagSkin: y = e.tagSkin, index: b = e.index }, x) => {
|
|
12
|
+
let { arrowNav: S, togglePanels: C, selectedIndex: w, setSelectedIndex: T, fallbackFocusIndex: E, reportTab: D, registerTabRef: O, handleKeyPress: k, selectTab: A } = a(), j = !p && (C && w !== null ? w === b : !!f), M = j || E === b, N = C && _ ? r(_) : void 0, P = !S && j ? m ? "page" : "true" : void 0, F = c(null);
|
|
13
|
+
s(() => {
|
|
14
|
+
C && f && !p && T(b);
|
|
13
15
|
}, [
|
|
14
|
-
|
|
15
|
-
d,
|
|
16
|
+
C,
|
|
16
17
|
f,
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
18
|
+
p,
|
|
19
|
+
b,
|
|
20
|
+
T
|
|
21
|
+
]), s(() => (D(b, {
|
|
22
|
+
active: j,
|
|
23
|
+
disabled: p
|
|
24
|
+
}), () => D(b, null)), [
|
|
25
|
+
b,
|
|
26
|
+
j,
|
|
27
|
+
p,
|
|
28
|
+
D
|
|
29
|
+
]), s(() => {
|
|
30
|
+
C && _ && F.current && n(F.current, _, j, S);
|
|
29
31
|
}, [
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
C,
|
|
33
|
+
_,
|
|
34
|
+
j,
|
|
35
|
+
S
|
|
34
36
|
]);
|
|
35
|
-
let
|
|
36
|
-
id:
|
|
37
|
-
"aria-selected":
|
|
38
|
-
"aria-current":
|
|
39
|
-
"aria-controls":
|
|
40
|
-
role:
|
|
37
|
+
let I = {
|
|
38
|
+
id: N,
|
|
39
|
+
"aria-selected": S ? j : void 0,
|
|
40
|
+
"aria-current": P,
|
|
41
|
+
"aria-controls": _,
|
|
42
|
+
role: S ? "tab" : void 0,
|
|
41
43
|
onKeyDown: (e) => {
|
|
42
|
-
|
|
44
|
+
p && (e.key === "Enter" || e.key === " " || e.key === "Spacebar") ? (e.preventDefault(), e.stopPropagation()) : k(b, e);
|
|
43
45
|
},
|
|
44
46
|
onClick: (e) => {
|
|
45
|
-
|
|
47
|
+
p ? (e.preventDefault(), e.stopPropagation()) : (A(b), h?.(e));
|
|
46
48
|
},
|
|
47
|
-
tabIndex:
|
|
49
|
+
tabIndex: p ? -1 : M || !S ? void 0 : -1,
|
|
48
50
|
ref: (e) => {
|
|
49
|
-
|
|
51
|
+
F.current = e, O(b, e), typeof x == "function" ? x(e) : x && (x.current = e);
|
|
50
52
|
}
|
|
51
|
-
},
|
|
52
|
-
|
|
53
|
-
name:
|
|
54
|
-
className: `pkt-icon--small ${
|
|
53
|
+
}, L = /* @__PURE__ */ d(l, { children: [
|
|
54
|
+
g && /* @__PURE__ */ u(t, {
|
|
55
|
+
name: g,
|
|
56
|
+
className: `pkt-icon--small ${g === "check" ? "pkt-tabs__status-icon" : ""}`
|
|
55
57
|
}),
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
skin:
|
|
58
|
+
o,
|
|
59
|
+
v && /* @__PURE__ */ u(i, {
|
|
60
|
+
skin: y,
|
|
59
61
|
size: "small",
|
|
60
|
-
children:
|
|
62
|
+
children: v
|
|
61
63
|
})
|
|
62
64
|
] });
|
|
63
|
-
return
|
|
64
|
-
...
|
|
65
|
-
href:
|
|
66
|
-
"aria-disabled":
|
|
67
|
-
className: `pkt-tabs__link ${
|
|
68
|
-
children:
|
|
69
|
-
}) : /* @__PURE__ */
|
|
70
|
-
...
|
|
65
|
+
return m ? /* @__PURE__ */ u("a", {
|
|
66
|
+
...I,
|
|
67
|
+
href: p ? void 0 : m,
|
|
68
|
+
"aria-disabled": p || void 0,
|
|
69
|
+
className: `pkt-tabs__link ${j ? "active" : ""} ${p ? "pkt-tabs__item--disabled" : ""}`,
|
|
70
|
+
children: L
|
|
71
|
+
}) : /* @__PURE__ */ u("button", {
|
|
72
|
+
...I,
|
|
71
73
|
type: "button",
|
|
72
|
-
disabled:
|
|
73
|
-
"aria-disabled":
|
|
74
|
-
className: `pkt-tabs__button pkt-link-button ${
|
|
75
|
-
children:
|
|
74
|
+
disabled: p,
|
|
75
|
+
"aria-disabled": p || void 0,
|
|
76
|
+
className: `pkt-tabs__button pkt-link-button ${j ? "active" : ""} ${p ? "pkt-tabs__item--disabled" : ""}`,
|
|
77
|
+
children: L
|
|
76
78
|
});
|
|
77
79
|
});
|
|
78
|
-
|
|
79
|
-
export {
|
|
80
|
+
f.displayName = "PktTabItem";
|
|
81
|
+
export { f as PktTabItem };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { KeyboardEvent, ReactNode } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { IPktTab, IPktTabsBase } from '../../shared-types';
|
|
3
3
|
type TTabState = {
|
|
4
4
|
active: boolean;
|
|
5
5
|
disabled: boolean;
|
|
@@ -11,32 +11,13 @@ interface ITabsContext {
|
|
|
11
11
|
setSelectedIndex: (index: number) => void;
|
|
12
12
|
fallbackFocusIndex: number | null;
|
|
13
13
|
reportTab: (index: number, state: TTabState | null) => void;
|
|
14
|
-
registerTabRef: (index: number, el: HTMLAnchorElement | HTMLButtonElement | null
|
|
14
|
+
registerTabRef: (index: number, el: HTMLAnchorElement | HTMLButtonElement | null) => void;
|
|
15
15
|
handleKeyPress: (index: number, event: KeyboardEvent<HTMLAnchorElement | HTMLButtonElement>) => void;
|
|
16
16
|
selectTab: (index: number) => void;
|
|
17
17
|
}
|
|
18
18
|
export declare const useTabsContext: () => ITabsContext;
|
|
19
|
-
export
|
|
20
|
-
|
|
21
|
-
href?: string;
|
|
22
|
-
action?: (index: number) => void;
|
|
23
|
-
disabled?: boolean;
|
|
24
|
-
icon?: string;
|
|
25
|
-
controls?: string;
|
|
26
|
-
tag?: {
|
|
27
|
-
text: string;
|
|
28
|
-
skin: TTagSkin | undefined;
|
|
29
|
-
};
|
|
30
|
-
active?: boolean;
|
|
31
|
-
}
|
|
32
|
-
export interface IPktTabs {
|
|
33
|
-
arrowNav?: boolean;
|
|
34
|
-
disableArrowNav?: boolean;
|
|
35
|
-
separatorIconName?: string;
|
|
36
|
-
separatorIconPath?: string;
|
|
37
|
-
togglePanels?: boolean;
|
|
38
|
-
ariaLabel?: string;
|
|
39
|
-
ariaLabelledBy?: string;
|
|
19
|
+
export type { IPktTab };
|
|
20
|
+
export interface IPktTabs extends IPktTabsBase {
|
|
40
21
|
tabs?: IPktTab[];
|
|
41
22
|
onTabSelected?: (index: number) => void;
|
|
42
23
|
children?: ReactNode;
|