@kth/style 0.0.12 → 0.1.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.
- package/dist/cjs/components/Button.d.ts +4 -4
- package/dist/cjs/components/ModalNavigationPanel.d.ts +4 -0
- package/dist/cjs/components/NavigationPanel.d.ts +7 -0
- package/dist/cjs/components/Radio.d.ts +2 -2
- package/dist/cjs/components/Select.d.ts +3 -5
- package/dist/cjs/components/Tabs.d.ts +1 -34
- package/dist/cjs/components/react/PersonalMenuPanel.d.ts +19 -0
- package/dist/cjs/components/react/Tabs.d.ts +34 -0
- package/dist/cjs/icons/400/ArrowBack.d.ts +2 -1
- package/dist/cjs/icons/400/Check.d.ts +2 -1
- package/dist/cjs/icons/500/ArrowForward.d.ts +2 -1
- package/dist/cjs/index.d.ts +3 -5
- package/dist/cjs/index.js +128 -157
- package/dist/cjs/react.d.ts +5 -0
- package/dist/cjs/react.js +179 -0
- package/dist/cjs/stories/ContentTabs.stories.d.ts +1 -2
- package/dist/esm/components/Button.d.ts +4 -4
- package/dist/esm/components/ModalNavigationPanel.d.ts +4 -0
- package/dist/esm/components/NavigationPanel.d.ts +7 -0
- package/dist/esm/components/Radio.d.ts +2 -2
- package/dist/esm/components/Select.d.ts +3 -5
- package/dist/esm/components/Tabs.d.ts +1 -34
- package/dist/esm/components/react/PersonalMenuPanel.d.ts +19 -0
- package/dist/esm/components/react/Tabs.d.ts +34 -0
- package/dist/esm/icons/400/ArrowBack.d.ts +2 -1
- package/dist/esm/icons/400/Check.d.ts +2 -1
- package/dist/esm/icons/500/ArrowForward.d.ts +2 -1
- package/dist/esm/index.d.ts +3 -5
- package/dist/esm/index.js +126 -129
- package/dist/esm/react.d.ts +5 -0
- package/dist/esm/react.js +149 -0
- package/dist/esm/stories/ContentTabs.stories.d.ts +1 -2
- package/package.json +14 -4
- package/scss/components/button.scss +41 -51
- package/scss/components/checkbox.scss +63 -0
- package/scss/components/details.scss +40 -0
- package/scss/components/fieldset.scss +60 -0
- package/scss/components/form-control.scss +25 -0
- package/scss/components/header-menu-item.scss +38 -0
- package/scss/components/input.scss +21 -0
- package/scss/components/main-header.scss +105 -0
- package/scss/components/search.scss +52 -0
- package/scss/components/select.scss +46 -0
- package/scss/tokens/colors.scss +63 -0
- package/scss/tokens/icons.scss +68 -0
- package/scss/tokens/{_spacing.scss → spacing.scss} +15 -0
- package/scss/tokens/typography.scss +35 -0
- package/scss/utils/mixins.scss +14 -0
- package/scss/utils/prose.scss +83 -76
- package/scss/utils/reset.scss +53 -255
- package/scss/components/content-tabs.scss +0 -68
- package/scss/components/filter-tabs.scss +0 -31
- package/scss/components/form.scss +0 -48
- package/scss/components/inline-icon.scss +0 -7
- package/scss/globals.scss +0 -5
- package/scss/tokens/_colors.scss +0 -20
- package/scss/tokens/_spacing.en.md +0 -40
- package/scss/tokens/_typography.scss +0 -71
- package/scss/tokens/index.scss +0 -6
- package/scss/utils/sizes.scss +0 -22
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import React from "react";
|
|
2
2
|
interface ButtonProps {
|
|
3
3
|
/** The label of the button */
|
|
4
4
|
children?: string;
|
|
@@ -14,7 +14,7 @@ interface IconButtonProps {
|
|
|
14
14
|
onClick?: () => void;
|
|
15
15
|
}
|
|
16
16
|
/** A button with just text */
|
|
17
|
-
export declare function Button({ children, onClick, appearance }: ButtonProps): JSX.Element;
|
|
18
|
-
export declare function BackButton({ children, onClick }: IconButtonProps): JSX.Element;
|
|
19
|
-
export declare function ForwardButton({ children, onClick }: IconButtonProps): JSX.Element;
|
|
17
|
+
export declare function Button({ children, onClick, appearance }: ButtonProps): React.JSX.Element;
|
|
18
|
+
export declare function BackButton({ children, onClick }: IconButtonProps): React.JSX.Element;
|
|
19
|
+
export declare function ForwardButton({ children, onClick }: IconButtonProps): React.JSX.Element;
|
|
20
20
|
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Add open/close functionality to a set of navigation panels
|
|
3
|
+
*
|
|
4
|
+
* @param container The element containing all the menus
|
|
5
|
+
* @param items A list of all menu elements
|
|
6
|
+
*/
|
|
7
|
+
export declare function setNavigationPanels(container: HTMLElement | null, items: NodeListOf<Element>): void;
|
|
@@ -14,7 +14,7 @@ interface RadioProps {
|
|
|
14
14
|
label: string;
|
|
15
15
|
}
|
|
16
16
|
/** Implemented as fancy radio buttons */
|
|
17
|
-
export declare function FilterTabs({ children, value, onChange }: RadioGroupProps): JSX.Element;
|
|
17
|
+
export declare function FilterTabs({ children, value, onChange }: RadioGroupProps): React.JSX.Element;
|
|
18
18
|
/** A single radio button */
|
|
19
|
-
export declare function Radio({ value, label }: RadioProps): JSX.Element;
|
|
19
|
+
export declare function Radio({ value, label }: RadioProps): React.JSX.Element;
|
|
20
20
|
export {};
|
|
@@ -23,14 +23,12 @@ interface OptionProps {
|
|
|
23
23
|
value: string;
|
|
24
24
|
/** Human-readable label for the option */
|
|
25
25
|
children: string;
|
|
26
|
-
/** True if the option should be disabled */
|
|
27
|
-
disabled?: boolean;
|
|
28
26
|
}
|
|
29
27
|
interface OptionGroupProps {
|
|
30
28
|
label: string;
|
|
31
29
|
children: React.ReactNode;
|
|
32
30
|
}
|
|
33
|
-
export declare function Select({ name, label, description, value, onChange, children, error, }: SelectProps): JSX.Element;
|
|
34
|
-
export declare function OptionGroup({ label, children }: OptionGroupProps): JSX.Element;
|
|
35
|
-
export declare function Option({ value, children
|
|
31
|
+
export declare function Select({ name, label, description, value, onChange, children, error, }: SelectProps): React.JSX.Element;
|
|
32
|
+
export declare function OptionGroup({ label, children }: OptionGroupProps): React.JSX.Element;
|
|
33
|
+
export declare function Option({ value, children }: OptionProps): React.JSX.Element;
|
|
36
34
|
export {};
|
|
@@ -1,34 +1 @@
|
|
|
1
|
-
|
|
2
|
-
interface TabProps {
|
|
3
|
-
children?: React.ReactNode;
|
|
4
|
-
id: string;
|
|
5
|
-
title: string;
|
|
6
|
-
}
|
|
7
|
-
interface GenericTabsProps {
|
|
8
|
-
classPrefix: string;
|
|
9
|
-
children: React.ReactElement<TabProps>[];
|
|
10
|
-
id: string;
|
|
11
|
-
defaultValue?: string;
|
|
12
|
-
url: "query" | "hash" | "none";
|
|
13
|
-
}
|
|
14
|
-
interface NavigationTabsProps {
|
|
15
|
-
id: string;
|
|
16
|
-
children: React.ReactElement<TabProps>[];
|
|
17
|
-
url?: "query" | "none";
|
|
18
|
-
defaultValue?: string;
|
|
19
|
-
}
|
|
20
|
-
interface ContentTabsProps {
|
|
21
|
-
id: string;
|
|
22
|
-
children: React.ReactElement<TabProps>[];
|
|
23
|
-
url?: "hash" | "none";
|
|
24
|
-
defaultValue?: string;
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Highly customizable Tabs component made for testing purposes.
|
|
28
|
-
* You should use {@link NavigationTabs} or {@link ContentTabs} instead.
|
|
29
|
-
*/
|
|
30
|
-
export declare function GenericTabs({ classPrefix, children, id, defaultValue, url, }: GenericTabsProps): JSX.Element;
|
|
31
|
-
export declare function NavigationTabs({ id, children, url, defaultValue, }: NavigationTabsProps): JSX.Element;
|
|
32
|
-
export declare function ContentTabs({ id, children, url, defaultValue, }: ContentTabsProps): JSX.Element;
|
|
33
|
-
export declare function Tab({ children }: TabProps): JSX.Element;
|
|
34
|
-
export {};
|
|
1
|
+
export declare function initTabs(container: Element): void;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
/**
|
|
3
|
+
* A panel with a button that opens it.
|
|
4
|
+
*
|
|
5
|
+
* - `children` is mounted the first time the dialog is opened. It is _not_
|
|
6
|
+
* unmounted after the dialog is closed.
|
|
7
|
+
*/
|
|
8
|
+
export declare function PersonalMenuPanel({ label, children }: {
|
|
9
|
+
label: any;
|
|
10
|
+
children: any;
|
|
11
|
+
}): React.JSX.Element;
|
|
12
|
+
interface PersonalMenuPanelGroupProps {
|
|
13
|
+
children: React.ReactElement;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Contains all <PersonalMenuPanel /> components in a menu
|
|
17
|
+
*/
|
|
18
|
+
export declare function PersonalMenuPanelGroup({ children, }: PersonalMenuPanelGroupProps): React.JSX.Element;
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
interface TabProps {
|
|
3
|
+
children?: React.ReactNode;
|
|
4
|
+
id: string;
|
|
5
|
+
title: string;
|
|
6
|
+
}
|
|
7
|
+
interface GenericTabsProps {
|
|
8
|
+
classPrefix: string;
|
|
9
|
+
children: React.ReactElement<TabProps>[];
|
|
10
|
+
id: string;
|
|
11
|
+
defaultValue?: string;
|
|
12
|
+
url: "query" | "hash" | "none";
|
|
13
|
+
}
|
|
14
|
+
interface NavigationTabsProps {
|
|
15
|
+
id: string;
|
|
16
|
+
children: React.ReactElement<TabProps>[];
|
|
17
|
+
url?: "query" | "none";
|
|
18
|
+
defaultValue?: string;
|
|
19
|
+
}
|
|
20
|
+
interface ContentTabsProps {
|
|
21
|
+
id: string;
|
|
22
|
+
children: React.ReactElement<TabProps>[];
|
|
23
|
+
url?: "hash" | "none";
|
|
24
|
+
defaultValue?: string;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Highly customizable Tabs component made for testing purposes.
|
|
28
|
+
* You should use {@link NavigationTabs} or {@link ContentTabs} instead.
|
|
29
|
+
*/
|
|
30
|
+
export declare function GenericTabs({ classPrefix, children, id, defaultValue, url, }: GenericTabsProps): React.JSX.Element;
|
|
31
|
+
export declare function NavigationTabs({ id, children, url, defaultValue, }: NavigationTabsProps): React.JSX.Element;
|
|
32
|
+
export declare function ContentTabs({ id, children, url, defaultValue, }: ContentTabsProps): React.JSX.Element;
|
|
33
|
+
export declare function Tab({ children }: TabProps): React.JSX.Element;
|
|
34
|
+
export {};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import * as React from "react";
|
|
1
2
|
import type { SVGProps } from "react";
|
|
2
|
-
declare const SvgArrowForward: (props: SVGProps<SVGSVGElement>) => JSX.Element;
|
|
3
|
+
declare const SvgArrowForward: (props: SVGProps<SVGSVGElement>) => React.JSX.Element;
|
|
3
4
|
export default SvgArrowForward;
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
4
|
-
export { default as IconArrowBack } from "./icons/400/ArrowBack";
|
|
5
|
-
export { default as IconCheck } from "./icons/400/Check";
|
|
1
|
+
export { setNavigationPanels } from "./components/NavigationPanel";
|
|
2
|
+
export { setModalNavigationPanels } from "./components/ModalNavigationPanel";
|
|
3
|
+
export { initTabs } from "./components/Tabs";
|
package/dist/cjs/index.js
CHANGED
|
@@ -1,179 +1,150 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
Object.keys(e).forEach(function (k) {
|
|
9
|
-
if (k !== 'default') {
|
|
10
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
11
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
12
|
-
enumerable: true,
|
|
13
|
-
get: function () { return e[k]; }
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
n.default = e;
|
|
19
|
-
return Object.freeze(n);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
|
|
23
|
-
|
|
24
|
-
function getValueFromUrl(key) {
|
|
25
|
-
const url = new URL(location.href);
|
|
26
|
-
if (key) {
|
|
27
|
-
return url.searchParams.get(key);
|
|
28
|
-
}
|
|
29
|
-
else {
|
|
30
|
-
return url.hash === "" ? null : url.hash.slice(1);
|
|
31
|
-
}
|
|
3
|
+
/**
|
|
4
|
+
* Close all <dialog>s (modal and non-modal) in a document
|
|
5
|
+
*/
|
|
6
|
+
function closeAllDialogs$1() {
|
|
7
|
+
document.querySelectorAll("dialog").forEach((dialog) => dialog.close());
|
|
32
8
|
}
|
|
33
9
|
/**
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
* @param
|
|
37
|
-
* @param
|
|
38
|
-
* as `React.useState` if false)
|
|
10
|
+
* Add open/close functionality to a set of navigation panels
|
|
11
|
+
*
|
|
12
|
+
* @param container The element containing all the menus
|
|
13
|
+
* @param items A list of all menu elements
|
|
39
14
|
*/
|
|
40
|
-
function
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
window.addEventListener("popstate", updateValue);
|
|
50
|
-
return () => {
|
|
51
|
-
window.removeEventListener("popstate", updateValue);
|
|
52
|
-
};
|
|
53
|
-
});
|
|
54
|
-
function setValue(value) {
|
|
55
|
-
_setValue(value);
|
|
56
|
-
const url = new URL(location.href);
|
|
57
|
-
if (key !== "") {
|
|
58
|
-
url.searchParams.set(key, value);
|
|
15
|
+
function setNavigationPanels(container, items) {
|
|
16
|
+
if (!container) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
for (const item of items) {
|
|
20
|
+
if (!(item instanceof HTMLElement)) {
|
|
21
|
+
continue;
|
|
59
22
|
}
|
|
60
|
-
|
|
61
|
-
|
|
23
|
+
const dialog = item.nextElementSibling;
|
|
24
|
+
if (!(dialog instanceof HTMLDialogElement)) {
|
|
25
|
+
continue;
|
|
62
26
|
}
|
|
63
|
-
|
|
64
|
-
|
|
27
|
+
dialog.addEventListener("keydown", (e) => {
|
|
28
|
+
if (e.key === "Escape") {
|
|
29
|
+
closeAllDialogs$1();
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
const closeButton = dialog.querySelector(".close");
|
|
33
|
+
if (closeButton instanceof HTMLButtonElement) {
|
|
34
|
+
closeButton.addEventListener("click", () => {
|
|
35
|
+
closeAllDialogs$1();
|
|
36
|
+
});
|
|
65
37
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
switch (event.key) {
|
|
72
|
-
case "ArrowLeft":
|
|
73
|
-
case "ArrowUp":
|
|
74
|
-
if (index > 0) {
|
|
75
|
-
setActiveTab(tabs[index - 1].props.id);
|
|
38
|
+
item.addEventListener("click", (e) => {
|
|
39
|
+
e.preventDefault();
|
|
40
|
+
if (!dialog.open) {
|
|
41
|
+
closeAllDialogs$1();
|
|
42
|
+
dialog.show();
|
|
76
43
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
case "ArrowDown":
|
|
80
|
-
if (index < tabs.length - 1) {
|
|
81
|
-
setActiveTab(tabs[index + 1].props.id);
|
|
44
|
+
else {
|
|
45
|
+
closeAllDialogs$1();
|
|
82
46
|
}
|
|
83
|
-
|
|
84
|
-
case "Home":
|
|
85
|
-
setActiveTab(tabs[0].props.id);
|
|
86
|
-
break;
|
|
87
|
-
case "End":
|
|
88
|
-
setActiveTab(tabs[tabs.length - 1].props.id);
|
|
89
|
-
break;
|
|
47
|
+
});
|
|
90
48
|
}
|
|
49
|
+
container.addEventListener("focusout", function (e) {
|
|
50
|
+
const target = e.relatedTarget;
|
|
51
|
+
if (target && target instanceof Node && !container.contains(target)) {
|
|
52
|
+
closeAllDialogs$1();
|
|
53
|
+
}
|
|
54
|
+
});
|
|
91
55
|
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Close all <dialog>s (modal and non-modal) in a document
|
|
59
|
+
*/
|
|
60
|
+
function closeAllDialogs() {
|
|
61
|
+
document.querySelectorAll("dialog").forEach((dialog) => dialog.close());
|
|
95
62
|
}
|
|
96
63
|
/**
|
|
97
|
-
*
|
|
98
|
-
* You should use {@link NavigationTabs} or {@link ContentTabs} instead.
|
|
64
|
+
* Add open/close functionality to a set of navigation panels
|
|
99
65
|
*/
|
|
100
|
-
function
|
|
101
|
-
const
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
66
|
+
function setModalNavigationPanels(items) {
|
|
67
|
+
for (const item of items) {
|
|
68
|
+
if (!(item instanceof HTMLElement)) {
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
const dialog = item.nextElementSibling;
|
|
72
|
+
if (!(dialog instanceof HTMLDialogElement)) {
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
dialog.addEventListener("keydown", (e) => {
|
|
76
|
+
e.stopPropagation();
|
|
77
|
+
if (e.key === "Escape") {
|
|
78
|
+
dialog.close();
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
const closeButton = dialog.querySelector(".close");
|
|
82
|
+
if (closeButton instanceof HTMLButtonElement) {
|
|
83
|
+
closeButton.addEventListener("click", () => {
|
|
84
|
+
closeAllDialogs();
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
item.addEventListener("click", (e) => {
|
|
88
|
+
e.preventDefault();
|
|
89
|
+
// closeAllDialogs();
|
|
90
|
+
dialog.showModal();
|
|
91
|
+
});
|
|
106
92
|
}
|
|
107
|
-
useFocus(ref.current?.querySelector(`#${activeTab}-tab`));
|
|
108
|
-
return (React.createElement(React.Fragment, null,
|
|
109
|
-
React.createElement("div", { ref: ref, className: `${classPrefix}`, id: id },
|
|
110
|
-
React.createElement("ul", { className: `${classPrefix}__tablist`, role: "tablist" }, children.map((child, index) => (React.createElement("li", { role: "presentation", className: `${classPrefix}__tab-element` },
|
|
111
|
-
React.createElement("button", { key: child.props.id, role: "tab", "aria-selected": index === activeTabIndex, "aria-controls": child.props.id, id: `${child.props.id}-tab`, className: `${classPrefix}__tab`, tabIndex: index === activeTabIndex ? 0 : -1, onKeyDown: (event) => {
|
|
112
|
-
handleKeyDown(event, index, children, setActiveTab);
|
|
113
|
-
}, onClick: (event) => {
|
|
114
|
-
event.preventDefault();
|
|
115
|
-
setActiveTab(child.props.id);
|
|
116
|
-
} }, child.props.title)))))),
|
|
117
|
-
children.map((child, index) => (React.createElement("div", { className: `${classPrefix}__tabpanel`, role: "tabpanel", "aria-labelledby": `${child.props.id}-tab`, id: child.props.id, key: index, hidden: index !== activeTabIndex }, child)))));
|
|
118
|
-
}
|
|
119
|
-
function NavigationTabs({ id, children, url = "query", defaultValue, }) {
|
|
120
|
-
return (React.createElement(GenericTabs, { id: id, children: children, url: url, defaultValue: defaultValue, classPrefix: "kth-navigation-tabs" }));
|
|
121
|
-
}
|
|
122
|
-
function ContentTabs({ id, children, url = "hash", defaultValue, }) {
|
|
123
|
-
return (React.createElement(GenericTabs, { id: id, children: children, url: url, defaultValue: defaultValue, classPrefix: "kth-content-tabs" }));
|
|
124
|
-
}
|
|
125
|
-
function Tab({ children }) {
|
|
126
|
-
return React.createElement(React.Fragment, null, children);
|
|
127
93
|
}
|
|
128
94
|
|
|
129
|
-
function
|
|
130
|
-
const
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
return
|
|
139
|
-
}
|
|
140
|
-
function Option({ value, children, disabled }) {
|
|
141
|
-
return (React.createElement("option", { value: value, disabled: disabled }, children));
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
const SvgArrowBack = (props) => (React__namespace.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: "1.25em", height: "1.25em", viewBox: "0 0 20 20", ...props },
|
|
145
|
-
React__namespace.createElement("path", { fill: "currentColor", d: "m10 16-6-6 6-6 1.063 1.063L6.875 9.25H16v1.5H6.875l4.188 4.188L10 16Z" })));
|
|
146
|
-
|
|
147
|
-
const SvgArrowForward = (props) => (React__namespace.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: "1.25em", height: "1.25em", viewBox: "0 0 20 20", ...props },
|
|
148
|
-
React__namespace.createElement("path", { fill: "currentColor", d: "m10 16.075-1.227-1.227 3.983-3.983h-8.83v-1.73h8.83L8.773 5.152 10 3.925 16.075 10 10 16.075Z" })));
|
|
149
|
-
|
|
150
|
-
/** A button with just text */
|
|
151
|
-
function Button({ children, onClick, appearance }) {
|
|
152
|
-
const className = ["kth-button", appearance].join(" ");
|
|
153
|
-
return (React.createElement("button", { onClick: onClick, className: className }, children));
|
|
95
|
+
function getPanel(tab) {
|
|
96
|
+
const panelId = tab.getAttribute("aria-controls");
|
|
97
|
+
if (!panelId) {
|
|
98
|
+
throw new Error();
|
|
99
|
+
}
|
|
100
|
+
const panel = document.getElementById(panelId);
|
|
101
|
+
if (!(panel instanceof HTMLElement)) {
|
|
102
|
+
throw new Error();
|
|
103
|
+
}
|
|
104
|
+
return panel;
|
|
154
105
|
}
|
|
155
|
-
function
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
106
|
+
function closeAllTabs(tabs) {
|
|
107
|
+
for (const tab of tabs) {
|
|
108
|
+
if (tab instanceof HTMLElement) {
|
|
109
|
+
tab.ariaSelected = "false";
|
|
110
|
+
const panel = getPanel(tab);
|
|
111
|
+
if (panel) {
|
|
112
|
+
panel.hidden = true;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
159
116
|
}
|
|
160
|
-
function
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
117
|
+
function initTabs(container) {
|
|
118
|
+
if (!(container instanceof HTMLElement)) {
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
const tablist = container.querySelector("[role=tablist]");
|
|
122
|
+
if (!tablist) {
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
const tabs = tablist.querySelectorAll("[role=tab]");
|
|
126
|
+
function openTab(tab) {
|
|
127
|
+
const panel = getPanel(tab);
|
|
128
|
+
if (!panel) {
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
tab.ariaSelected = "true";
|
|
132
|
+
panel.hidden = false;
|
|
133
|
+
}
|
|
134
|
+
for (const tab of tabs) {
|
|
135
|
+
if (tab instanceof HTMLElement) {
|
|
136
|
+
tab.addEventListener("click", () => {
|
|
137
|
+
closeAllTabs(tabs);
|
|
138
|
+
openTab(tab);
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
if (tabs[0] instanceof HTMLElement) {
|
|
143
|
+
closeAllTabs(tabs);
|
|
144
|
+
openTab(tabs[0]);
|
|
145
|
+
}
|
|
164
146
|
}
|
|
165
147
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
exports.BackButton = BackButton;
|
|
170
|
-
exports.Button = Button;
|
|
171
|
-
exports.ContentTabs = ContentTabs;
|
|
172
|
-
exports.ForwardButton = ForwardButton;
|
|
173
|
-
exports.IconArrowBack = SvgArrowBack;
|
|
174
|
-
exports.IconCheck = SvgCheck;
|
|
175
|
-
exports.NavigationTabs = NavigationTabs;
|
|
176
|
-
exports.Option = Option;
|
|
177
|
-
exports.OptionGroup = OptionGroup;
|
|
178
|
-
exports.Select = Select;
|
|
179
|
-
exports.Tab = Tab;
|
|
148
|
+
exports.initTabs = initTabs;
|
|
149
|
+
exports.setModalNavigationPanels = setModalNavigationPanels;
|
|
150
|
+
exports.setNavigationPanels = setNavigationPanels;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { Tab, ContentTabs, NavigationTabs } from "./components/react/Tabs";
|
|
2
|
+
export { Select, Option, OptionGroup } from "./components/Select";
|
|
3
|
+
export { BackButton, Button, ForwardButton } from "./components/Button";
|
|
4
|
+
export { default as IconArrowBack } from "./icons/400/ArrowBack";
|
|
5
|
+
export { default as IconCheck } from "./icons/400/Check";
|