@kth/style 0.0.12 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/README.md +28 -22
  2. package/dist/cjs/components/MenuPanel.d.ts +13 -0
  3. package/dist/cjs/index.d.ts +1 -5
  4. package/dist/cjs/index.js +63 -165
  5. package/dist/cjs/react.d.ts +1 -0
  6. package/dist/cjs/react.js +7 -0
  7. package/dist/esm/components/MenuPanel.d.ts +13 -0
  8. package/dist/esm/index.d.ts +1 -5
  9. package/dist/esm/index.js +63 -137
  10. package/dist/esm/react.d.ts +1 -0
  11. package/dist/esm/react.js +5 -0
  12. package/package.json +14 -14
  13. package/scss/components/a11y-nav.scss +31 -0
  14. package/scss/components/button.scss +20 -66
  15. package/scss/components/header.scss +40 -0
  16. package/scss/components/logotype.scss +28 -0
  17. package/scss/components/mega-menu.scss +33 -0
  18. package/scss/components/menu-item.scss +40 -0
  19. package/scss/components/menu-panel.scss +32 -0
  20. package/scss/components/search.scss +54 -0
  21. package/scss/components/visually-hidden.scss +11 -0
  22. package/scss/tokens/colors.scss +60 -0
  23. package/scss/tokens/icons.scss +69 -0
  24. package/scss/tokens/spacing.scss +31 -0
  25. package/scss/tokens/typography.scss +35 -0
  26. package/scss/utils/mixins.scss +19 -0
  27. package/scss/utils/prose.scss +88 -76
  28. package/scss/utils/reset.scss +59 -247
  29. package/dist/cjs/components/Button.d.ts +0 -20
  30. package/dist/cjs/components/Radio.d.ts +0 -20
  31. package/dist/cjs/components/Select.d.ts +0 -36
  32. package/dist/cjs/components/Tabs.d.ts +0 -34
  33. package/dist/cjs/icons/400/ArrowBack.d.ts +0 -3
  34. package/dist/cjs/icons/400/Check.d.ts +0 -3
  35. package/dist/cjs/icons/500/ArrowForward.d.ts +0 -3
  36. package/dist/cjs/stories/Button.stories.d.ts +0 -14
  37. package/dist/cjs/stories/ContentTabs.stories.d.ts +0 -13
  38. package/dist/cjs/stories/FilterTabs.stories.d.ts +0 -12
  39. package/dist/cjs/stories/InlineIcons.stories.d.ts +0 -9
  40. package/dist/cjs/stories/Select.stories.d.ts +0 -14
  41. package/dist/esm/components/Button.d.ts +0 -20
  42. package/dist/esm/components/Radio.d.ts +0 -20
  43. package/dist/esm/components/Select.d.ts +0 -36
  44. package/dist/esm/components/Tabs.d.ts +0 -34
  45. package/dist/esm/icons/400/ArrowBack.d.ts +0 -3
  46. package/dist/esm/icons/400/Check.d.ts +0 -3
  47. package/dist/esm/icons/500/ArrowForward.d.ts +0 -3
  48. package/dist/esm/stories/Button.stories.d.ts +0 -14
  49. package/dist/esm/stories/ContentTabs.stories.d.ts +0 -13
  50. package/dist/esm/stories/FilterTabs.stories.d.ts +0 -12
  51. package/dist/esm/stories/InlineIcons.stories.d.ts +0 -9
  52. package/dist/esm/stories/Select.stories.d.ts +0 -14
  53. package/scss/components/content-tabs.scss +0 -68
  54. package/scss/components/filter-tabs.scss +0 -31
  55. package/scss/components/form.scss +0 -48
  56. package/scss/components/inline-icon.scss +0 -7
  57. package/scss/globals.scss +0 -5
  58. package/scss/tokens/_colors.scss +0 -20
  59. package/scss/tokens/_spacing.en.md +0 -40
  60. package/scss/tokens/_spacing.scss +0 -81
  61. package/scss/tokens/_typography.scss +0 -71
  62. package/scss/tokens/index.scss +0 -6
  63. package/scss/utils/sizes.scss +0 -22
package/README.md CHANGED
@@ -1,24 +1,30 @@
1
1
  # @kth/style
2
2
 
3
- **WORK IN PROGRESS**. Styles and components used across KTH.
4
-
5
- ## Requirements
6
-
7
- - Sass
8
- - React
9
-
10
- ## Getting started
11
-
12
- 1. Install `@kth/style` from npm:
13
-
14
- ```
15
- npm i @kth/style
16
- ```
17
-
18
- 2. In your Sass file, import and include the sizes mixin:
19
-
20
- ```scss
21
- @use "node_modules/@kth/style/scss/utils" as sizes;
22
-
23
- @include utils.sizes;
24
- ```
3
+ Styles and components used across KTH.
4
+
5
+ Documentation available in the [KTH Style website](https://kthstyledemoref.z6.web.core.windows.net/style)
6
+
7
+ ## Structure
8
+
9
+ ```
10
+ @kth/style
11
+ ├── src/
12
+ │ ├── index.ts
13
+ │ ├── components
14
+ └── react-components
15
+ ├── scss/
16
+ ├── components
17
+ │ ├── tokens
18
+ │ └── utils
19
+ ├── assets
20
+ ├── ...
21
+ ├── package.json
22
+ └── rollup.config.mjs
23
+ ```
24
+
25
+ - `scss` contains all CSS. Those can be imported as they are
26
+ - `src` contains source for JavaScript components. Written in JavaScript
27
+ - `src/components` are the components that do not use React
28
+ - `src/react-components` are the React components
29
+ - `index.ts` and `react.ts` re-export the content in the respective `components` directories
30
+ - `assets` are static assets like the fonts and logotype. This is meant to be exposed by apps using KTH Style
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Close all <dialog>s (modal and non-modal) in a document
3
+ */
4
+ export declare function closeAllDialogs(): void;
5
+ /**
6
+ * Add mouse and keyboard event listeners to a menu panel (<dialog>)
7
+ * @param dialog A <dialog> element
8
+ */
9
+ export declare function addEventListeners(dialog: HTMLDialogElement): void;
10
+ export declare class MenuPanel {
11
+ static init(container: HTMLElement | null, items: NodeListOf<Element>): void;
12
+ static initModal(items: NodeListOf<Element>): void;
13
+ }
@@ -1,5 +1 @@
1
- export { Tab, ContentTabs, NavigationTabs } from "./components/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";
1
+ export { MenuPanel } from "./components/MenuPanel";
package/dist/cjs/index.js CHANGED
@@ -1,179 +1,77 @@
1
1
  'use strict';
2
2
 
3
- var React = require('react');
4
-
5
- function _interopNamespaceDefault(e) {
6
- var n = Object.create(null);
7
- if (e) {
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() {
7
+ document.querySelectorAll("dialog").forEach((dialog) => dialog.close());
32
8
  }
33
9
  /**
34
- * Sync state with URL hash or query parameter.
35
- * @param defaultValue Default state value
36
- * @param key Query parameter to use. Hash if empty
37
- * @param enableUrl Will sync with URL if true (this function behaves the same
38
- * as `React.useState` if false)
10
+ * Add mouse and keyboard event listeners to a menu panel (<dialog>)
11
+ * @param dialog A <dialog> element
39
12
  */
40
- function useUrlState(defaultValue = "", key = "", enableUrl = false) {
41
- const initialValue = (enableUrl && getValueFromUrl(key)) || defaultValue;
42
- const [value, _setValue] = React.useState(initialValue);
43
- React.useEffect(() => {
44
- function updateValue() {
45
- if (enableUrl) {
46
- _setValue(getValueFromUrl(key) || defaultValue);
47
- }
13
+ function addEventListeners(dialog) {
14
+ const closeButton = dialog.querySelector(".kth-button.close");
15
+ const backButton = dialog.querySelector(".kth-button.back");
16
+ dialog.addEventListener("keydown", (e) => {
17
+ if (e.key === "Escape") {
18
+ dialog.close();
48
19
  }
49
- window.addEventListener("popstate", updateValue);
50
- return () => {
51
- window.removeEventListener("popstate", updateValue);
52
- };
53
20
  });
54
- function setValue(value) {
55
- _setValue(value);
56
- const url = new URL(location.href);
57
- if (key !== "") {
58
- url.searchParams.set(key, value);
59
- }
60
- else {
61
- url.hash = "#" + value;
62
- }
63
- if (enableUrl) {
64
- history.pushState(undefined, "", url);
65
- }
21
+ if (closeButton instanceof HTMLButtonElement) {
22
+ closeButton.addEventListener("click", () => {
23
+ closeAllDialogs();
24
+ });
25
+ }
26
+ if (backButton instanceof HTMLButtonElement) {
27
+ backButton.addEventListener("click", () => {
28
+ dialog.close();
29
+ });
66
30
  }
67
- return [value, setValue];
68
31
  }
69
- function handleKeyDown(event, index, tabs, setActiveTab) {
70
- event.preventDefault();
71
- switch (event.key) {
72
- case "ArrowLeft":
73
- case "ArrowUp":
74
- if (index > 0) {
75
- setActiveTab(tabs[index - 1].props.id);
76
- }
77
- break;
78
- case "ArrowRight":
79
- case "ArrowDown":
80
- if (index < tabs.length - 1) {
81
- setActiveTab(tabs[index + 1].props.id);
32
+ class MenuPanel {
33
+ static init(container, items) {
34
+ if (!container)
35
+ return;
36
+ for (const item of items) {
37
+ if (!(item instanceof HTMLElement))
38
+ continue;
39
+ const dialog = item.nextElementSibling;
40
+ if (!(dialog instanceof HTMLDialogElement))
41
+ continue;
42
+ addEventListeners(dialog);
43
+ item.addEventListener("click", (e) => {
44
+ e.preventDefault();
45
+ if (!dialog.open) {
46
+ closeAllDialogs();
47
+ dialog.show();
48
+ }
49
+ else {
50
+ closeAllDialogs();
51
+ }
52
+ });
53
+ }
54
+ container.addEventListener("focusout", function (e) {
55
+ const target = e.relatedTarget;
56
+ if (target && target instanceof Node && !container.contains(target)) {
57
+ closeAllDialogs();
82
58
  }
83
- break;
84
- case "Home":
85
- setActiveTab(tabs[0].props.id);
86
- break;
87
- case "End":
88
- setActiveTab(tabs[tabs.length - 1].props.id);
89
- break;
59
+ });
90
60
  }
91
- }
92
- function useFocus(element) {
93
- element?.scrollIntoView({ block: "nearest", inline: "nearest" });
94
- element?.focus();
95
- }
96
- /**
97
- * Highly customizable Tabs component made for testing purposes.
98
- * You should use {@link NavigationTabs} or {@link ContentTabs} instead.
99
- */
100
- function GenericTabs({ classPrefix, children, id, defaultValue, url = "none", }) {
101
- const ref = React.useRef(null);
102
- const [activeTab, setActiveTab] = useUrlState(defaultValue, url === "query" ? id : "", url === "query" || url === "hash");
103
- let activeTabIndex = children.findIndex((c) => c.props.id === activeTab);
104
- if (activeTabIndex === -1) {
105
- activeTabIndex = 0;
61
+ static initModal(items) {
62
+ for (const item of items) {
63
+ if (!(item instanceof HTMLElement))
64
+ continue;
65
+ const dialog = item.nextElementSibling;
66
+ if (!(dialog instanceof HTMLDialogElement))
67
+ continue;
68
+ addEventListeners(dialog);
69
+ item.addEventListener("click", (e) => {
70
+ e.preventDefault();
71
+ dialog.showModal();
72
+ });
73
+ }
106
74
  }
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
- }
128
-
129
- function Select({ name, label, description, value, onChange, children, error, }) {
130
- const id = `select-${name}`;
131
- return (React.createElement("div", { className: "kth-select" },
132
- React.createElement("label", { htmlFor: id }, label),
133
- description && React.createElement("p", { id: `${id}-description` }, description),
134
- React.createElement("select", { id: id, "aria-describedby": description && `${id}-description`, name: name, value: value, onChange: (e) => onChange(e.target.value), "aria-invalid": error !== undefined ? "true" : "false" }, children),
135
- error && (React.createElement("p", { className: "kth-select__error", role: "alert" }, error))));
136
- }
137
- function OptionGroup({ label, children }) {
138
- return React.createElement("optgroup", { label: label }, children);
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));
154
- }
155
- function BackButton({ children, onClick }) {
156
- return (React.createElement("button", { onClick: onClick, className: "kth-button tertiary" },
157
- React.createElement(SvgArrowBack, null),
158
- children));
159
75
  }
160
- function ForwardButton({ children, onClick }) {
161
- return (React.createElement("button", { onClick: onClick, className: "kth-button primary" },
162
- children,
163
- React.createElement(SvgArrowForward, null)));
164
- }
165
-
166
- const SvgCheck = (props) => (React__namespace.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: "1.25em", height: "1.25em", viewBox: "0 0 20 20", ...props },
167
- React__namespace.createElement("path", { fill: "currentColor", d: "M8.23 14.063 4.707 10.52 5.75 9.479l2.48 2.459 6.02-6L15.292 7l-7.063 7.063Z" })));
168
76
 
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;
77
+ exports.MenuPanel = MenuPanel;
@@ -0,0 +1 @@
1
+ export default function hello(): string;
@@ -0,0 +1,7 @@
1
+ 'use strict';
2
+
3
+ function hello() {
4
+ return "world";
5
+ }
6
+
7
+ module.exports = hello;
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Close all <dialog>s (modal and non-modal) in a document
3
+ */
4
+ export declare function closeAllDialogs(): void;
5
+ /**
6
+ * Add mouse and keyboard event listeners to a menu panel (<dialog>)
7
+ * @param dialog A <dialog> element
8
+ */
9
+ export declare function addEventListeners(dialog: HTMLDialogElement): void;
10
+ export declare class MenuPanel {
11
+ static init(container: HTMLElement | null, items: NodeListOf<Element>): void;
12
+ static initModal(items: NodeListOf<Element>): void;
13
+ }
@@ -1,5 +1 @@
1
- export { Tab, ContentTabs, NavigationTabs } from "./components/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";
1
+ export { MenuPanel } from "./components/MenuPanel";
package/dist/esm/index.js CHANGED
@@ -1,149 +1,75 @@
1
- import * as React from 'react';
2
- import React__default from 'react';
3
-
4
- function getValueFromUrl(key) {
5
- const url = new URL(location.href);
6
- if (key) {
7
- return url.searchParams.get(key);
8
- }
9
- else {
10
- return url.hash === "" ? null : url.hash.slice(1);
11
- }
1
+ /**
2
+ * Close all <dialog>s (modal and non-modal) in a document
3
+ */
4
+ function closeAllDialogs() {
5
+ document.querySelectorAll("dialog").forEach((dialog) => dialog.close());
12
6
  }
13
7
  /**
14
- * Sync state with URL hash or query parameter.
15
- * @param defaultValue Default state value
16
- * @param key Query parameter to use. Hash if empty
17
- * @param enableUrl Will sync with URL if true (this function behaves the same
18
- * as `React.useState` if false)
8
+ * Add mouse and keyboard event listeners to a menu panel (<dialog>)
9
+ * @param dialog A <dialog> element
19
10
  */
20
- function useUrlState(defaultValue = "", key = "", enableUrl = false) {
21
- const initialValue = (enableUrl && getValueFromUrl(key)) || defaultValue;
22
- const [value, _setValue] = React__default.useState(initialValue);
23
- React__default.useEffect(() => {
24
- function updateValue() {
25
- if (enableUrl) {
26
- _setValue(getValueFromUrl(key) || defaultValue);
27
- }
11
+ function addEventListeners(dialog) {
12
+ const closeButton = dialog.querySelector(".kth-button.close");
13
+ const backButton = dialog.querySelector(".kth-button.back");
14
+ dialog.addEventListener("keydown", (e) => {
15
+ if (e.key === "Escape") {
16
+ dialog.close();
28
17
  }
29
- window.addEventListener("popstate", updateValue);
30
- return () => {
31
- window.removeEventListener("popstate", updateValue);
32
- };
33
18
  });
34
- function setValue(value) {
35
- _setValue(value);
36
- const url = new URL(location.href);
37
- if (key !== "") {
38
- url.searchParams.set(key, value);
39
- }
40
- else {
41
- url.hash = "#" + value;
42
- }
43
- if (enableUrl) {
44
- history.pushState(undefined, "", url);
45
- }
19
+ if (closeButton instanceof HTMLButtonElement) {
20
+ closeButton.addEventListener("click", () => {
21
+ closeAllDialogs();
22
+ });
23
+ }
24
+ if (backButton instanceof HTMLButtonElement) {
25
+ backButton.addEventListener("click", () => {
26
+ dialog.close();
27
+ });
46
28
  }
47
- return [value, setValue];
48
29
  }
49
- function handleKeyDown(event, index, tabs, setActiveTab) {
50
- event.preventDefault();
51
- switch (event.key) {
52
- case "ArrowLeft":
53
- case "ArrowUp":
54
- if (index > 0) {
55
- setActiveTab(tabs[index - 1].props.id);
56
- }
57
- break;
58
- case "ArrowRight":
59
- case "ArrowDown":
60
- if (index < tabs.length - 1) {
61
- setActiveTab(tabs[index + 1].props.id);
30
+ class MenuPanel {
31
+ static init(container, items) {
32
+ if (!container)
33
+ return;
34
+ for (const item of items) {
35
+ if (!(item instanceof HTMLElement))
36
+ continue;
37
+ const dialog = item.nextElementSibling;
38
+ if (!(dialog instanceof HTMLDialogElement))
39
+ continue;
40
+ addEventListeners(dialog);
41
+ item.addEventListener("click", (e) => {
42
+ e.preventDefault();
43
+ if (!dialog.open) {
44
+ closeAllDialogs();
45
+ dialog.show();
46
+ }
47
+ else {
48
+ closeAllDialogs();
49
+ }
50
+ });
51
+ }
52
+ container.addEventListener("focusout", function (e) {
53
+ const target = e.relatedTarget;
54
+ if (target && target instanceof Node && !container.contains(target)) {
55
+ closeAllDialogs();
62
56
  }
63
- break;
64
- case "Home":
65
- setActiveTab(tabs[0].props.id);
66
- break;
67
- case "End":
68
- setActiveTab(tabs[tabs.length - 1].props.id);
69
- break;
57
+ });
70
58
  }
71
- }
72
- function useFocus(element) {
73
- element?.scrollIntoView({ block: "nearest", inline: "nearest" });
74
- element?.focus();
75
- }
76
- /**
77
- * Highly customizable Tabs component made for testing purposes.
78
- * You should use {@link NavigationTabs} or {@link ContentTabs} instead.
79
- */
80
- function GenericTabs({ classPrefix, children, id, defaultValue, url = "none", }) {
81
- const ref = React__default.useRef(null);
82
- const [activeTab, setActiveTab] = useUrlState(defaultValue, url === "query" ? id : "", url === "query" || url === "hash");
83
- let activeTabIndex = children.findIndex((c) => c.props.id === activeTab);
84
- if (activeTabIndex === -1) {
85
- activeTabIndex = 0;
59
+ static initModal(items) {
60
+ for (const item of items) {
61
+ if (!(item instanceof HTMLElement))
62
+ continue;
63
+ const dialog = item.nextElementSibling;
64
+ if (!(dialog instanceof HTMLDialogElement))
65
+ continue;
66
+ addEventListeners(dialog);
67
+ item.addEventListener("click", (e) => {
68
+ e.preventDefault();
69
+ dialog.showModal();
70
+ });
71
+ }
86
72
  }
87
- useFocus(ref.current?.querySelector(`#${activeTab}-tab`));
88
- return (React__default.createElement(React__default.Fragment, null,
89
- React__default.createElement("div", { ref: ref, className: `${classPrefix}`, id: id },
90
- React__default.createElement("ul", { className: `${classPrefix}__tablist`, role: "tablist" }, children.map((child, index) => (React__default.createElement("li", { role: "presentation", className: `${classPrefix}__tab-element` },
91
- React__default.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) => {
92
- handleKeyDown(event, index, children, setActiveTab);
93
- }, onClick: (event) => {
94
- event.preventDefault();
95
- setActiveTab(child.props.id);
96
- } }, child.props.title)))))),
97
- children.map((child, index) => (React__default.createElement("div", { className: `${classPrefix}__tabpanel`, role: "tabpanel", "aria-labelledby": `${child.props.id}-tab`, id: child.props.id, key: index, hidden: index !== activeTabIndex }, child)))));
98
- }
99
- function NavigationTabs({ id, children, url = "query", defaultValue, }) {
100
- return (React__default.createElement(GenericTabs, { id: id, children: children, url: url, defaultValue: defaultValue, classPrefix: "kth-navigation-tabs" }));
101
- }
102
- function ContentTabs({ id, children, url = "hash", defaultValue, }) {
103
- return (React__default.createElement(GenericTabs, { id: id, children: children, url: url, defaultValue: defaultValue, classPrefix: "kth-content-tabs" }));
104
- }
105
- function Tab({ children }) {
106
- return React__default.createElement(React__default.Fragment, null, children);
107
- }
108
-
109
- function Select({ name, label, description, value, onChange, children, error, }) {
110
- const id = `select-${name}`;
111
- return (React__default.createElement("div", { className: "kth-select" },
112
- React__default.createElement("label", { htmlFor: id }, label),
113
- description && React__default.createElement("p", { id: `${id}-description` }, description),
114
- React__default.createElement("select", { id: id, "aria-describedby": description && `${id}-description`, name: name, value: value, onChange: (e) => onChange(e.target.value), "aria-invalid": error !== undefined ? "true" : "false" }, children),
115
- error && (React__default.createElement("p", { className: "kth-select__error", role: "alert" }, error))));
116
- }
117
- function OptionGroup({ label, children }) {
118
- return React__default.createElement("optgroup", { label: label }, children);
119
- }
120
- function Option({ value, children, disabled }) {
121
- return (React__default.createElement("option", { value: value, disabled: disabled }, children));
122
73
  }
123
74
 
124
- const SvgArrowBack = (props) => (React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: "1.25em", height: "1.25em", viewBox: "0 0 20 20", ...props },
125
- React.createElement("path", { fill: "currentColor", d: "m10 16-6-6 6-6 1.063 1.063L6.875 9.25H16v1.5H6.875l4.188 4.188L10 16Z" })));
126
-
127
- const SvgArrowForward = (props) => (React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: "1.25em", height: "1.25em", viewBox: "0 0 20 20", ...props },
128
- React.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" })));
129
-
130
- /** A button with just text */
131
- function Button({ children, onClick, appearance }) {
132
- const className = ["kth-button", appearance].join(" ");
133
- return (React__default.createElement("button", { onClick: onClick, className: className }, children));
134
- }
135
- function BackButton({ children, onClick }) {
136
- return (React__default.createElement("button", { onClick: onClick, className: "kth-button tertiary" },
137
- React__default.createElement(SvgArrowBack, null),
138
- children));
139
- }
140
- function ForwardButton({ children, onClick }) {
141
- return (React__default.createElement("button", { onClick: onClick, className: "kth-button primary" },
142
- children,
143
- React__default.createElement(SvgArrowForward, null)));
144
- }
145
-
146
- const SvgCheck = (props) => (React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: "1.25em", height: "1.25em", viewBox: "0 0 20 20", ...props },
147
- React.createElement("path", { fill: "currentColor", d: "M8.23 14.063 4.707 10.52 5.75 9.479l2.48 2.459 6.02-6L15.292 7l-7.063 7.063Z" })));
148
-
149
- export { BackButton, Button, ContentTabs, ForwardButton, SvgArrowBack as IconArrowBack, SvgCheck as IconCheck, NavigationTabs, Option, OptionGroup, Select, Tab };
75
+ export { MenuPanel };
@@ -0,0 +1 @@
1
+ export default function hello(): string;
@@ -0,0 +1,5 @@
1
+ function hello() {
2
+ return "world";
3
+ }
4
+
5
+ export { hello as default };
package/package.json CHANGED
@@ -1,14 +1,23 @@
1
1
  {
2
2
  "name": "@kth/style",
3
- "version": "0.0.12",
3
+ "version": "0.2.0",
4
4
  "main": "dist/cjs/index.js",
5
5
  "module": "dist/esm/index.js",
6
+ "exports": {
7
+ ".": {
8
+ "import": "./dist/esm/index.js",
9
+ "require": "./dist/cjs/index.js"
10
+ },
11
+ "./react": {
12
+ "import": "./dist/esm/react.js",
13
+ "require": "./dist/cjs/react.js"
14
+ },
15
+ "./scss/*": "./scss/*"
16
+ },
6
17
  "scripts": {
7
18
  "clean": "rm -rf dist",
8
- "dev": "storybook dev -p 6006",
9
- "build": "npm run clean && npm run build:components && npm run build:storybook",
19
+ "build": "npm run clean && npm run build:components",
10
20
  "build:components": "rollup -c",
11
- "build:storybook": "storybook build -o ../../apps/style-web/public/storybook",
12
21
  "test": "npm run test:lint",
13
22
  "test:lint": "eslint src --ext ts,tsx --report-unused-disable-directives --max-warnings 0"
14
23
  },
@@ -20,13 +29,6 @@
20
29
  "@rollup/plugin-commonjs": "^24.1.0",
21
30
  "@rollup/plugin-node-resolve": "^15.0.2",
22
31
  "@rollup/plugin-typescript": "^11.1.0",
23
- "@storybook/addon-essentials": "^7.0.6",
24
- "@storybook/addon-interactions": "^7.0.6",
25
- "@storybook/addon-links": "^7.0.6",
26
- "@storybook/blocks": "^7.0.6",
27
- "@storybook/react": "^7.0.6",
28
- "@storybook/react-vite": "^7.0.6",
29
- "@storybook/testing-library": "^0.0.14-next.2",
30
32
  "@types/react": "^18.0.28",
31
33
  "@types/react-dom": "^18.0.11",
32
34
  "@typescript-eslint/eslint-plugin": "^5.57.1",
@@ -35,17 +37,15 @@
35
37
  "eslint": "^8.38.0",
36
38
  "eslint-plugin-react-hooks": "^4.6.0",
37
39
  "eslint-plugin-react-refresh": "^0.3.4",
38
- "eslint-plugin-storybook": "^0.6.11",
39
40
  "prop-types": "^15.8.1",
40
41
  "react": "^18.2.0",
41
42
  "react-dom": "^18.2.0",
42
43
  "rollup": "^3.21.4",
43
- "storybook": "^7.0.6",
44
44
  "typescript": "^5.0.2",
45
45
  "vite": "^4.3.0"
46
46
  },
47
47
  "peerDependencies": {
48
48
  "react": "*"
49
49
  },
50
- "gitHead": "6774939491027282851d19e5ae9022183f98cfe5"
50
+ "gitHead": "2ef5d86944a2cd3c4eee7011c4b71983e11f309f"
51
51
  }