@mattilsynet/design 0.3.8 → 0.5.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/mtds/alert/alert.d.ts +3 -1
- package/mtds/alert/alert.js +12 -0
- package/mtds/alert/alert.js.map +1 -0
- package/mtds/alert/alert.stories.d.ts +1 -1
- package/mtds/avatar/avatar.d.ts +1 -1
- package/mtds/avatar/avatar.js +12 -0
- package/mtds/avatar/avatar.js.map +1 -0
- package/mtds/avatar/avatar.stories.d.ts +1 -1
- package/mtds/badge/badge.d.ts +6 -6
- package/mtds/badge/badge.js +11 -0
- package/mtds/badge/badge.js.map +1 -0
- package/mtds/badge/badge.stories.d.ts +1 -1
- package/mtds/breadcrumbs/breadcrumbs.js +29 -0
- package/mtds/breadcrumbs/breadcrumbs.js.map +1 -0
- package/mtds/breadcrumbs/breadcrumbs.stories.d.ts +1 -1
- package/mtds/button/button.d.ts +5 -1
- package/mtds/button/button.js +12 -0
- package/mtds/button/button.js.map +1 -0
- package/mtds/button/button.stories.d.ts +2 -1
- package/mtds/card/card.d.ts +1 -1
- package/mtds/card/card.js +12 -0
- package/mtds/card/card.js.map +1 -0
- package/mtds/card/card.stories.d.ts +2 -2
- package/mtds/chip/chip.d.ts +10 -2
- package/mtds/chip/chip.js +12 -0
- package/mtds/chip/chip.js.map +1 -0
- package/mtds/chip/chip.stories.d.ts +3 -1
- package/mtds/details/details.d.ts +3 -2
- package/mtds/details/details.js +18 -0
- package/mtds/details/details.js.map +1 -0
- package/mtds/dialog/dialog.d.ts +2 -0
- package/mtds/dialog/dialog.js +25 -0
- package/mtds/dialog/dialog.js.map +1 -0
- package/mtds/divider/divider.d.ts +6 -2
- package/mtds/divider/divider.js +22 -0
- package/mtds/divider/divider.js.map +1 -0
- package/mtds/errorsummary/errorsummary.js +27 -0
- package/mtds/errorsummary/errorsummary.js.map +1 -0
- package/mtds/errorsummary/errorsummary.stories.d.ts +1 -1
- package/mtds/external/@u-elements/u-details/dist/u-details.js +91 -0
- package/mtds/external/@u-elements/u-details/dist/u-details.js.map +1 -0
- package/mtds/external/@u-elements/u-tabs/dist/u-tabs.js +185 -0
- package/mtds/external/@u-elements/u-tabs/dist/u-tabs.js.map +1 -0
- package/mtds/external/clsx/dist/clsx.js +18 -0
- package/mtds/external/clsx/dist/clsx.js.map +1 -0
- package/mtds/field/field-observer.js +33 -30
- package/mtds/field/field-observer.js.map +1 -1
- package/mtds/field/field.d.ts +21 -0
- package/mtds/field/field.js +44 -0
- package/mtds/field/field.js.map +1 -0
- package/mtds/field/field.stories.d.ts +2 -1
- package/mtds/fieldset/fieldset-observer.js +9 -10
- package/mtds/fieldset/fieldset-observer.js.map +1 -1
- package/mtds/fieldset/fieldset.js +20 -0
- package/mtds/fieldset/fieldset.js.map +1 -0
- package/mtds/fieldset/fieldset.stories.d.ts +1 -0
- package/mtds/heading/heading.d.ts +3 -1
- package/mtds/heading/heading.js +11 -0
- package/mtds/heading/heading.js.map +1 -0
- package/mtds/heading/heading.stories.d.ts +3 -1
- package/mtds/index.d.ts +3 -1
- package/mtds/index.iife.js +4 -1
- package/mtds/index.iife.js.map +1 -1
- package/mtds/index.js +20 -18
- package/mtds/index.js.map +1 -1
- package/mtds/input/input.d.ts +2 -0
- package/mtds/input/input.js +19 -0
- package/mtds/input/input.js.map +1 -0
- package/mtds/input/input.stories.d.ts +2 -1
- package/mtds/layout/layout-observer.js +12 -15
- package/mtds/layout/layout-observer.js.map +1 -1
- package/mtds/layout/layout.d.ts +18 -0
- package/mtds/layout/layout.js +14 -0
- package/mtds/layout/layout.js.map +1 -0
- package/mtds/layout/layout.stories.d.ts +4 -3
- package/mtds/link/link.js +11 -0
- package/mtds/link/link.js.map +1 -0
- package/mtds/link/link.stories.d.ts +1 -0
- package/mtds/logo/logo-observer.d.ts +2 -0
- package/mtds/logo/logo-observer.js +23 -0
- package/mtds/logo/logo-observer.js.map +1 -0
- package/mtds/logo/logo.d.ts +10 -0
- package/mtds/logo/logo.js +12 -0
- package/mtds/logo/logo.js.map +1 -0
- package/mtds/logo/logo.stories.d.ts +10 -2
- package/mtds/pagination/pagination-helper.d.ts +13 -0
- package/mtds/pagination/pagination-helper.js +16 -0
- package/mtds/pagination/pagination-helper.js.map +1 -0
- package/mtds/pagination/pagination.d.ts +2 -13
- package/mtds/pagination/pagination.js +18 -17
- package/mtds/pagination/pagination.js.map +1 -1
- package/mtds/pagination/pagination.stories.d.ts +1 -0
- package/mtds/popover/popover-observer.js +15 -11
- package/mtds/popover/popover-observer.js.map +1 -1
- package/mtds/popover/popover.d.ts +8 -0
- package/mtds/popover/popover.js +19 -0
- package/mtds/popover/popover.js.map +1 -0
- package/mtds/popover/popover.stories.d.ts +1 -0
- package/mtds/react-types.d.ts +9 -1
- package/mtds/react.d.ts +13 -0
- package/mtds/react.js +57 -0
- package/mtds/react.js.map +1 -0
- package/mtds/skeleton/skeleton.d.ts +10 -0
- package/mtds/skeleton/skeleton.js +12 -0
- package/mtds/skeleton/skeleton.js.map +1 -0
- package/mtds/skeleton/skeleton.stories.d.ts +1 -0
- package/mtds/spinner/spinner.d.ts +6 -0
- package/mtds/spinner/spinner.js +13 -0
- package/mtds/spinner/spinner.js.map +1 -0
- package/mtds/spinner/spinner.stories.d.ts +2 -1
- package/mtds/styles.css +1 -1
- package/mtds/styles.json +33 -31
- package/mtds/styles.module.css.js +70 -68
- package/mtds/styles.module.css.js.map +1 -1
- package/mtds/table/table-observer.js +19 -16
- package/mtds/table/table-observer.js.map +1 -1
- package/mtds/table/table.d.ts +12 -0
- package/mtds/table/table.js +11 -0
- package/mtds/table/table.js.map +1 -0
- package/mtds/table/table.stories.d.ts +2 -1
- package/mtds/tabs/tabs.d.ts +10 -0
- package/mtds/tabs/tabs.js +28 -0
- package/mtds/tabs/tabs.js.map +1 -0
- package/mtds/tabs/tabs.stories.d.ts +1 -0
- package/mtds/tag/tag.d.ts +6 -0
- package/mtds/tag/tag.js +11 -0
- package/mtds/tag/tag.js.map +1 -0
- package/mtds/tag/tag.stories.d.ts +2 -1
- package/mtds/tooltip/tooltip-observer.js +22 -16
- package/mtds/tooltip/tooltip-observer.js.map +1 -1
- package/mtds/tooltip/tooltip.stories.d.ts +11 -0
- package/mtds/utils.js +19 -19
- package/mtds/validation/validation.d.ts +2 -0
- package/mtds/validation/validation.js +13 -0
- package/mtds/validation/validation.js.map +1 -0
- package/mtds/validation/validation.stories.d.ts +1 -0
- package/package.json +26 -22
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
var m = typeof window < "u" && typeof window.document < "u" && typeof window.navigator < "u", k = m && /android/i.test(navigator.userAgent), y;
|
|
2
|
+
m && // @ts-expect-error Typescript has not implemented userAgentData yet https://stackoverflow.com/a/71392474
|
|
3
|
+
/^Mac/i.test(((y = navigator.userAgentData) == null ? void 0 : y.platform) || navigator.platform);
|
|
4
|
+
var T = `${k ? "data" : "aria"}-labelledby`, E = ":host(:not([hidden])) { display: block }", h = typeof HTMLElement > "u" ? class {
|
|
5
|
+
} : HTMLElement;
|
|
6
|
+
function a(t, e, s) {
|
|
7
|
+
var n;
|
|
8
|
+
return s === void 0 ? (n = t.getAttribute(e)) != null ? n : null : (s === null ? t.removeAttribute(e) : t.getAttribute(e) !== s && t.setAttribute(e, s), null);
|
|
9
|
+
}
|
|
10
|
+
var L = (t, e, s) => {
|
|
11
|
+
for (const n of s[0].split(","))
|
|
12
|
+
s[0] = n, Element.prototype[`${t}EventListener`].apply(e, s);
|
|
13
|
+
}, S = (t, ...e) => L("add", t, e), C = (t, ...e) => L("remove", t, e), b = (t, e) => t.attachShadow({ mode: "open" }).append(
|
|
14
|
+
x("slot"),
|
|
15
|
+
// Unnamed slot does automatically render all top element nodes
|
|
16
|
+
x("style", e)
|
|
17
|
+
), o = /* @__PURE__ */ new WeakMap(), A = (t, e) => {
|
|
18
|
+
if (e === void 0) return o.get(t);
|
|
19
|
+
try {
|
|
20
|
+
o.get(t).disconnect(), o.delete(t);
|
|
21
|
+
} catch {
|
|
22
|
+
}
|
|
23
|
+
if (e) {
|
|
24
|
+
const s = new MutationObserver(
|
|
25
|
+
(n) => t.handleEvent({ type: "mutation", detail: n })
|
|
26
|
+
);
|
|
27
|
+
s.observe(t, e), o.set(t, s);
|
|
28
|
+
}
|
|
29
|
+
}, M = (t) => {
|
|
30
|
+
const e = "key" in t && (t.key === " " || t.key === "Enter");
|
|
31
|
+
return e && t.preventDefault(), e && t.target instanceof HTMLElement && t.target.click(), e;
|
|
32
|
+
}, w = (t) => {
|
|
33
|
+
var e;
|
|
34
|
+
const s = ((e = t.getRootNode) == null ? void 0 : e.call(t)) || t.ownerDocument;
|
|
35
|
+
return s instanceof Document || s instanceof ShadowRoot ? s : document;
|
|
36
|
+
}, D = 0, I = (t) => t ? (t.id || (t.id = `:${t.nodeName.toLowerCase()}${(++D).toString(32)}`), t.id) : "", x = (t, e, s) => {
|
|
37
|
+
const n = document.createElement(t);
|
|
38
|
+
return e && (n.textContent = e), n;
|
|
39
|
+
}, f = {
|
|
40
|
+
define: (t, e) => !m || window.customElements.get(t) || window.customElements.define(t, e)
|
|
41
|
+
}, c = "aria-controls", l = "aria-selected", R = class extends h {
|
|
42
|
+
constructor() {
|
|
43
|
+
super(), b(this, E);
|
|
44
|
+
}
|
|
45
|
+
get tabList() {
|
|
46
|
+
return d("u-tablist", this)[0] || null;
|
|
47
|
+
}
|
|
48
|
+
get selectedIndex() {
|
|
49
|
+
return u(this.tabs);
|
|
50
|
+
}
|
|
51
|
+
set selectedIndex(t) {
|
|
52
|
+
p(this.tabs[t]);
|
|
53
|
+
}
|
|
54
|
+
get tabs() {
|
|
55
|
+
return d("u-tab", this);
|
|
56
|
+
}
|
|
57
|
+
get panels() {
|
|
58
|
+
return d("u-tabpanel", this);
|
|
59
|
+
}
|
|
60
|
+
}, _ = class extends h {
|
|
61
|
+
constructor() {
|
|
62
|
+
super(), b(this, E);
|
|
63
|
+
}
|
|
64
|
+
connectedCallback() {
|
|
65
|
+
a(this, "role", "tablist"), S(this, "click,keydown", this), A(this, { childList: !0 }), this.tabs.length && this.handleEvent();
|
|
66
|
+
}
|
|
67
|
+
disconnectedCallback() {
|
|
68
|
+
C(this, "click,keydown", this), A(this, !1);
|
|
69
|
+
}
|
|
70
|
+
handleEvent(t) {
|
|
71
|
+
if (!t || t.type === "mutation") {
|
|
72
|
+
const i = this.tabs[Math.max(this.selectedIndex, 0)];
|
|
73
|
+
return i == null ? void 0 : i.setAttribute(l, "true");
|
|
74
|
+
}
|
|
75
|
+
const { key: e } = t, s = [...this.tabs], n = s.findIndex((i) => i.contains(t.target));
|
|
76
|
+
let r = n;
|
|
77
|
+
if (!(t.defaultPrevented || n === -1) && (t.type === "click" && p(s[n]), t.type === "keydown" && !M(t))) {
|
|
78
|
+
if (e === "ArrowDown" || e === "ArrowRight")
|
|
79
|
+
r = (n + 1) % s.length;
|
|
80
|
+
else if (e === "ArrowUp" || e === "ArrowLeft")
|
|
81
|
+
r = (n || s.length) - 1;
|
|
82
|
+
else if (e === "End") r = s.length - 1;
|
|
83
|
+
else if (e === "Home") r = 0;
|
|
84
|
+
else if (e === "Tab") r = u(s);
|
|
85
|
+
else return;
|
|
86
|
+
setTimeout(() => {
|
|
87
|
+
s[n].tabIndex = -1, s[r].tabIndex = 0;
|
|
88
|
+
}), e !== "Tab" && (t.preventDefault(), s[r].focus());
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
get tabsElement() {
|
|
92
|
+
return this.closest("u-tabs");
|
|
93
|
+
}
|
|
94
|
+
get tabs() {
|
|
95
|
+
return this.querySelectorAll("u-tab");
|
|
96
|
+
}
|
|
97
|
+
get selectedIndex() {
|
|
98
|
+
return u(this.tabs);
|
|
99
|
+
}
|
|
100
|
+
set selectedIndex(t) {
|
|
101
|
+
p(this.tabs[t]);
|
|
102
|
+
}
|
|
103
|
+
}, v = !1, H = class extends h {
|
|
104
|
+
// Using ES2015 syntax for backwards compatibility
|
|
105
|
+
static get observedAttributes() {
|
|
106
|
+
return ["id", l, c];
|
|
107
|
+
}
|
|
108
|
+
constructor() {
|
|
109
|
+
super(), b(
|
|
110
|
+
this,
|
|
111
|
+
":host(:not([hidden])) { cursor: pointer; display: inline-block }"
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
connectedCallback() {
|
|
115
|
+
a(this, "role", "tab"), this.tabIndex = this.selected ? 0 : -1;
|
|
116
|
+
}
|
|
117
|
+
attributeChangedCallback() {
|
|
118
|
+
if (!v && this.selected && this.tabList) {
|
|
119
|
+
v = !0;
|
|
120
|
+
const t = [...this.tabList.querySelectorAll("u-tab")], e = d("u-tabpanel", this.tabsElement || this), s = g(this, e[t.indexOf(this)]);
|
|
121
|
+
s && a(s, T, I(this)), t.forEach((n, r) => {
|
|
122
|
+
const i = g(n, e[r]);
|
|
123
|
+
n.tabIndex = n === this ? 0 : -1, a(n, l, `${n === this}`), i && (i.hidden = i !== s), i && a(n, c, i.id);
|
|
124
|
+
}), v = !1;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
get tabsElement() {
|
|
128
|
+
return this.closest("u-tabs");
|
|
129
|
+
}
|
|
130
|
+
get tabList() {
|
|
131
|
+
const t = this.parentElement;
|
|
132
|
+
return (t == null ? void 0 : t.nodeName) === "U-TABLIST" ? t : null;
|
|
133
|
+
}
|
|
134
|
+
get selected() {
|
|
135
|
+
return a(this, l) === "true";
|
|
136
|
+
}
|
|
137
|
+
set selected(t) {
|
|
138
|
+
a(this, l, `${!!t}`);
|
|
139
|
+
}
|
|
140
|
+
/** Retrieves the ordinal position of an tab in a tablist. */
|
|
141
|
+
get index() {
|
|
142
|
+
const t = this.tabList;
|
|
143
|
+
return t ? [...t.querySelectorAll("u-tab")].indexOf(this) : 0;
|
|
144
|
+
}
|
|
145
|
+
get panel() {
|
|
146
|
+
return g(this);
|
|
147
|
+
}
|
|
148
|
+
}, $ = class extends h {
|
|
149
|
+
// Using ES2015 syntax for backwards compatibility
|
|
150
|
+
static get observedAttributes() {
|
|
151
|
+
return ["hidden"];
|
|
152
|
+
}
|
|
153
|
+
constructor() {
|
|
154
|
+
super(), b(this, E);
|
|
155
|
+
}
|
|
156
|
+
connectedCallback() {
|
|
157
|
+
a(this, "role", "tabpanel"), this.hidden = u(this.tabs) === -1, this.attributeChangedCallback();
|
|
158
|
+
}
|
|
159
|
+
attributeChangedCallback() {
|
|
160
|
+
this.hidden || N(this.firstChild) ? a(this, "tabindex", null) : this.tabIndex = 0;
|
|
161
|
+
}
|
|
162
|
+
get tabsElement() {
|
|
163
|
+
return this.closest("u-tabs");
|
|
164
|
+
}
|
|
165
|
+
get tabs() {
|
|
166
|
+
const t = `u-tab[${c}="${this.id}"]`;
|
|
167
|
+
return w(this).querySelectorAll(t);
|
|
168
|
+
}
|
|
169
|
+
}, d = (t, e) => e.querySelectorAll(`${t}:not(:scope u-tabpanel ${t})`), g = (t, e) => {
|
|
170
|
+
const s = a(t, c) || I(e), n = w(t).getElementById(s);
|
|
171
|
+
return (n == null ? void 0 : n.nodeName) === "U-TABPANEL" ? n : null;
|
|
172
|
+
}, u = (t) => [...t].findIndex((e) => a(e, l) === "true"), p = (t) => t && a(t, "aria-selected", "true"), N = (t) => t instanceof Element && !t.matches(':disabled,[tabindex^="-"]') && t.matches(
|
|
173
|
+
'[contenteditable],[controls],[href],[tabindex],input:not([type="hidden"]),select,textarea,button,summary,iframe'
|
|
174
|
+
);
|
|
175
|
+
f.define("u-tabs", R);
|
|
176
|
+
f.define("u-tablist", _);
|
|
177
|
+
f.define("u-tab", H);
|
|
178
|
+
f.define("u-tabpanel", $);
|
|
179
|
+
export {
|
|
180
|
+
H as UHTMLTabElement,
|
|
181
|
+
_ as UHTMLTabListElement,
|
|
182
|
+
$ as UHTMLTabPanelElement,
|
|
183
|
+
R as UHTMLTabsElement
|
|
184
|
+
};
|
|
185
|
+
//# sourceMappingURL=u-tabs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"u-tabs.js","sources":["../../../../../node_modules/@u-elements/u-tabs/dist/u-tabs.js"],"sourcesContent":["// ../utils.ts\nvar IS_BROWSER = typeof window !== \"undefined\" && typeof window.document !== \"undefined\" && typeof window.navigator !== \"undefined\";\nvar IS_ANDROID = IS_BROWSER && /android/i.test(navigator.userAgent);\nvar _a;\nIS_BROWSER && // @ts-expect-error Typescript has not implemented userAgentData yet https://stackoverflow.com/a/71392474\n/^Mac/i.test(((_a = navigator.userAgentData) == null ? void 0 : _a.platform) || navigator.platform);\nvar SAFE_LABELLEDBY = `${IS_ANDROID ? \"data\" : \"aria\"}-labelledby`;\nvar DISPLAY_BLOCK = \":host(:not([hidden])) { display: block }\";\nvar UHTMLElement = typeof HTMLElement === \"undefined\" ? class {\n} : HTMLElement;\nfunction attr(el, name, value) {\n var _a2;\n if (value === void 0) return (_a2 = el.getAttribute(name)) != null ? _a2 : null;\n if (value === null) el.removeAttribute(name);\n else if (el.getAttribute(name) !== value) el.setAttribute(name, value);\n return null;\n}\nvar events = (action, element, rest) => {\n for (const type of rest[0].split(\",\")) {\n rest[0] = type;\n Element.prototype[`${action}EventListener`].apply(element, rest);\n }\n};\nvar on = (element, ...rest) => events(\"add\", element, rest);\nvar off = (element, ...rest) => events(\"remove\", element, rest);\nvar attachStyle = (element, css) => element.attachShadow({ mode: \"open\" }).append(\n createElement(\"slot\"),\n // Unnamed slot does automatically render all top element nodes\n createElement(\"style\", css)\n);\nvar observers = /* @__PURE__ */ new WeakMap();\nvar mutationObserver = (element, options) => {\n if (options === void 0) return observers.get(element);\n try {\n observers.get(element).disconnect();\n observers.delete(element);\n } catch (err) {\n }\n if (options) {\n const observer = new MutationObserver(\n (detail) => element.handleEvent({ type: \"mutation\", detail })\n );\n observer.observe(element, options);\n observers.set(element, observer);\n }\n};\nvar asButton = (event) => {\n const isClick = \"key\" in event && (event.key === \" \" || event.key === \"Enter\");\n if (isClick) event.preventDefault();\n if (isClick && event.target instanceof HTMLElement) event.target.click();\n return isClick;\n};\nvar getRoot = (node) => {\n var _a2;\n const root = ((_a2 = node.getRootNode) == null ? void 0 : _a2.call(node)) || node.ownerDocument;\n return root instanceof Document || root instanceof ShadowRoot ? root : document;\n};\nvar id = 0;\nvar useId = (el) => {\n if (!el) return \"\";\n if (!el.id) el.id = `:${el.nodeName.toLowerCase()}${(++id).toString(32)}`;\n return el.id;\n};\nvar createElement = (tagName, text, attrs) => {\n const el = document.createElement(tagName);\n if (text) el.textContent = text;\n return el;\n};\nvar customElements = {\n define: (name, instance) => !IS_BROWSER || window.customElements.get(name) || window.customElements.define(name, instance)\n};\n\n// u-tabs.ts\nvar ARIA_CONTROLS = \"aria-controls\";\nvar ARIA_SELECTED = \"aria-selected\";\nvar UHTMLTabsElement = class extends UHTMLElement {\n constructor() {\n super();\n attachStyle(this, DISPLAY_BLOCK);\n }\n get tabList() {\n return queryWithoutNested(\"u-tablist\", this)[0] || null;\n }\n get selectedIndex() {\n return getSelectedIndex(this.tabs);\n }\n set selectedIndex(index) {\n setSelected(this.tabs[index]);\n }\n get tabs() {\n return queryWithoutNested(\"u-tab\", this);\n }\n get panels() {\n return queryWithoutNested(\"u-tabpanel\", this);\n }\n};\nvar UHTMLTabListElement = class extends UHTMLElement {\n constructor() {\n super();\n attachStyle(this, DISPLAY_BLOCK);\n }\n connectedCallback() {\n attr(this, \"role\", \"tablist\");\n on(this, \"click,keydown\", this);\n mutationObserver(this, { childList: true });\n if (this.tabs.length) this.handleEvent();\n }\n disconnectedCallback() {\n off(this, \"click,keydown\", this);\n mutationObserver(this, false);\n }\n handleEvent(event) {\n if (!event || event.type === \"mutation\") {\n const tab = this.tabs[Math.max(this.selectedIndex, 0)];\n return tab == null ? void 0 : tab.setAttribute(ARIA_SELECTED, \"true\");\n }\n const { key } = event;\n const tabs = [...this.tabs];\n const prev = tabs.findIndex((tab) => tab.contains(event.target));\n let next = prev;\n if (event.defaultPrevented || prev === -1) return;\n if (event.type === \"click\") setSelected(tabs[prev]);\n if (event.type === \"keydown\" && !asButton(event)) {\n if (key === \"ArrowDown\" || key === \"ArrowRight\")\n next = (prev + 1) % tabs.length;\n else if (key === \"ArrowUp\" || key === \"ArrowLeft\")\n next = (prev || tabs.length) - 1;\n else if (key === \"End\") next = tabs.length - 1;\n else if (key === \"Home\") next = 0;\n else if (key === \"Tab\") next = getSelectedIndex(tabs);\n else return;\n setTimeout(() => {\n tabs[prev].tabIndex = -1;\n tabs[next].tabIndex = 0;\n });\n if (key !== \"Tab\") {\n event.preventDefault();\n tabs[next].focus();\n }\n }\n }\n get tabsElement() {\n return this.closest(\"u-tabs\");\n }\n get tabs() {\n return this.querySelectorAll(\"u-tab\");\n }\n get selectedIndex() {\n return getSelectedIndex(this.tabs);\n }\n set selectedIndex(index) {\n setSelected(this.tabs[index]);\n }\n};\nvar SKIP_ATTR_CHANGE = false;\nvar UHTMLTabElement = class extends UHTMLElement {\n // Using ES2015 syntax for backwards compatibility\n static get observedAttributes() {\n return [\"id\", ARIA_SELECTED, ARIA_CONTROLS];\n }\n constructor() {\n super();\n attachStyle(\n this,\n \":host(:not([hidden])) { cursor: pointer; display: inline-block }\"\n );\n }\n connectedCallback() {\n attr(this, \"role\", \"tab\");\n this.tabIndex = this.selected ? 0 : -1;\n }\n attributeChangedCallback() {\n if (!SKIP_ATTR_CHANGE && this.selected && this.tabList) {\n SKIP_ATTR_CHANGE = true;\n const tabs = [...this.tabList.querySelectorAll(\"u-tab\")];\n const panels = queryWithoutNested(\"u-tabpanel\", this.tabsElement || this);\n const nextPanel = getPanel(this, panels[tabs.indexOf(this)]);\n if (nextPanel) attr(nextPanel, SAFE_LABELLEDBY, useId(this));\n tabs.forEach((tab, index) => {\n const panel = getPanel(tab, panels[index]);\n tab.tabIndex = tab === this ? 0 : -1;\n attr(tab, ARIA_SELECTED, `${tab === this}`);\n if (panel) panel.hidden = panel !== nextPanel;\n if (panel) attr(tab, ARIA_CONTROLS, panel.id);\n });\n SKIP_ATTR_CHANGE = false;\n }\n }\n get tabsElement() {\n return this.closest(\"u-tabs\");\n }\n get tabList() {\n const tablist = this.parentElement;\n return (tablist == null ? void 0 : tablist.nodeName) === \"U-TABLIST\" ? tablist : null;\n }\n get selected() {\n return attr(this, ARIA_SELECTED) === \"true\";\n }\n set selected(value) {\n attr(this, ARIA_SELECTED, `${!!value}`);\n }\n /** Retrieves the ordinal position of an tab in a tablist. */\n get index() {\n const tabList = this.tabList;\n return tabList ? [...tabList.querySelectorAll(\"u-tab\")].indexOf(this) : 0;\n }\n get panel() {\n return getPanel(this);\n }\n};\nvar UHTMLTabPanelElement = class extends UHTMLElement {\n // Using ES2015 syntax for backwards compatibility\n static get observedAttributes() {\n return [\"hidden\"];\n }\n constructor() {\n super();\n attachStyle(this, DISPLAY_BLOCK);\n }\n connectedCallback() {\n attr(this, \"role\", \"tabpanel\");\n this.hidden = getSelectedIndex(this.tabs) === -1;\n this.attributeChangedCallback();\n }\n attributeChangedCallback() {\n if (this.hidden || isFocusable(this.firstChild))\n attr(this, \"tabindex\", null);\n else this.tabIndex = 0;\n }\n get tabsElement() {\n return this.closest(\"u-tabs\");\n }\n get tabs() {\n const css = `u-tab[${ARIA_CONTROLS}=\"${this.id}\"]`;\n return getRoot(this).querySelectorAll(css);\n }\n};\nvar queryWithoutNested = (tag, self) => self.querySelectorAll(`${tag}:not(:scope u-tabpanel ${tag})`);\nvar getPanel = (tab, panel) => {\n const id2 = attr(tab, ARIA_CONTROLS) || useId(panel);\n const el = getRoot(tab).getElementById(id2);\n return (el == null ? void 0 : el.nodeName) === \"U-TABPANEL\" ? el : null;\n};\nvar getSelectedIndex = (tabs) => [...tabs].findIndex((tab) => attr(tab, ARIA_SELECTED) === \"true\");\nvar setSelected = (tab) => tab && attr(tab, \"aria-selected\", \"true\");\nvar isFocusable = (el) => el instanceof Element && !el.matches(':disabled,[tabindex^=\"-\"]') && el.matches(\n `[contenteditable],[controls],[href],[tabindex],input:not([type=\"hidden\"]),select,textarea,button,summary,iframe`\n);\ncustomElements.define(\"u-tabs\", UHTMLTabsElement);\ncustomElements.define(\"u-tablist\", UHTMLTabListElement);\ncustomElements.define(\"u-tab\", UHTMLTabElement);\ncustomElements.define(\"u-tabpanel\", UHTMLTabPanelElement);\n\nexport { UHTMLTabElement, UHTMLTabListElement, UHTMLTabPanelElement, UHTMLTabsElement };\n"],"names":["IS_BROWSER","IS_ANDROID","_a","SAFE_LABELLEDBY","DISPLAY_BLOCK","UHTMLElement","attr","el","name","value","_a2","events","action","element","rest","type","on","off","attachStyle","css","createElement","observers","mutationObserver","options","observer","detail","asButton","event","isClick","getRoot","node","root","id","useId","tagName","text","attrs","customElements","instance","ARIA_CONTROLS","ARIA_SELECTED","UHTMLTabsElement","queryWithoutNested","getSelectedIndex","index","setSelected","UHTMLTabListElement","tab","key","tabs","prev","next","SKIP_ATTR_CHANGE","UHTMLTabElement","panels","nextPanel","getPanel","panel","tablist","tabList","UHTMLTabPanelElement","isFocusable","tag","self","id2"],"mappings":"AACA,IAAIA,IAAa,OAAO,SAAW,OAAe,OAAO,OAAO,WAAa,OAAe,OAAO,OAAO,YAAc,KACpHC,IAAaD,KAAc,WAAW,KAAK,UAAU,SAAS,GAC9DE;AACJF;AACA,QAAQ,OAAOE,IAAK,UAAU,kBAAkB,OAAO,SAASA,EAAG,aAAa,UAAU,QAAQ;AAClG,IAAIC,IAAkB,GAAGF,IAAa,SAAS,MAAM,eACjDG,IAAgB,4CAChBC,IAAe,OAAO,cAAgB,MAAc,MAAM;AAC9D,IAAI;AACJ,SAASC,EAAKC,GAAIC,GAAMC,GAAO;AAC7B,MAAIC;AACJ,SAAID,MAAU,UAAgBC,IAAMH,EAAG,aAAaC,CAAI,MAAM,OAAOE,IAAM,QACvED,MAAU,OAAMF,EAAG,gBAAgBC,CAAI,IAClCD,EAAG,aAAaC,CAAI,MAAMC,KAAOF,EAAG,aAAaC,GAAMC,CAAK,GAC9D;AACT;AACA,IAAIE,IAAS,CAACC,GAAQC,GAASC,MAAS;AACtC,aAAWC,KAAQD,EAAK,CAAC,EAAE,MAAM,GAAG;AAClC,IAAAA,EAAK,CAAC,I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AMO,IAAM1D,EAAKyC,GAAKR,CAAa,KAAKN,EAAMwB,CAAK,GAC7ClD,IAAKsB,EAAQkB,CAAG,EAAE,eAAeiB,CAAG;AAC1C,UAAQzD,KAAM,OAAO,SAASA,EAAG,cAAc,eAAeA,IAAK;AACrE,GACIoC,IAAmB,CAACM,MAAS,CAAC,GAAGA,CAAI,EAAE,UAAU,CAACF,MAAQzC,EAAKyC,GAAKP,CAAa,MAAM,MAAM,GAC7FK,IAAc,CAACE,MAAQA,KAAOzC,EAAKyC,GAAK,iBAAiB,MAAM,GAC/Dc,IAAc,CAACtD,MAAOA,aAAc,WAAW,CAACA,EAAG,QAAQ,2BAA2B,KAAKA,EAAG;AAAA,EAChG;AACF;AACA8B,EAAe,OAAO,UAAUI,CAAgB;AAChDJ,EAAe,OAAO,aAAaS,CAAmB;AACtDT,EAAe,OAAO,SAASgB,CAAe;AAC9ChB,EAAe,OAAO,cAAcuB,CAAoB;","x_google_ignoreList":[0]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
function a(r) {
|
|
2
|
+
var n, f, t = "";
|
|
3
|
+
if (typeof r == "string" || typeof r == "number") t += r;
|
|
4
|
+
else if (typeof r == "object") if (Array.isArray(r)) {
|
|
5
|
+
var o = r.length;
|
|
6
|
+
for (n = 0; n < o; n++) r[n] && (f = a(r[n])) && (t && (t += " "), t += f);
|
|
7
|
+
} else for (f in r) r[f] && (t && (t += " "), t += f);
|
|
8
|
+
return t;
|
|
9
|
+
}
|
|
10
|
+
function i() {
|
|
11
|
+
for (var r, n, f = 0, t = "", o = arguments.length; f < o; f++) (r = arguments[f]) && (n = a(r)) && (t && (t += " "), t += n);
|
|
12
|
+
return t;
|
|
13
|
+
}
|
|
14
|
+
export {
|
|
15
|
+
i as clsx,
|
|
16
|
+
i as default
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=clsx.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clsx.js","sources":["../../../../node_modules/clsx/dist/clsx.mjs"],"sourcesContent":["function r(e){var t,f,n=\"\";if(\"string\"==typeof e||\"number\"==typeof e)n+=e;else if(\"object\"==typeof e)if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(f=r(e[t]))&&(n&&(n+=\" \"),n+=f)}else for(f in e)e[f]&&(n&&(n+=\" \"),n+=f);return n}export function clsx(){for(var e,t,f=0,n=\"\",o=arguments.length;f<o;f++)(e=arguments[f])&&(t=r(e))&&(n&&(n+=\" \"),n+=t);return n}export default clsx;"],"names":["r","e","t","n","clsx"],"mappings":"AAAA,SAASA,EAAEC,GAAE;AAAC,MAAIC,GAAE,GAAEC,IAAE;AAAG,MAAa,OAAOF,KAAjB,YAA8B,OAAOA,KAAjB,SAAmB,CAAAE,KAAGF;AAAA,WAAoB,OAAOA,KAAjB,SAAmB,KAAG,MAAM,QAAQA,CAAC,GAAE;AAAC,QAAI,IAAEA,EAAE;AAAO,SAAIC,IAAE,GAAEA,IAAE,GAAEA,IAAI,CAAAD,EAAEC,CAAC,MAAI,IAAEF,EAAEC,EAAEC,CAAC,CAAC,OAAKC,MAAIA,KAAG,MAAKA,KAAG;AAAA,EAAE,MAAM,MAAI,KAAKF,EAAE,CAAAA,EAAE,CAAC,MAAIE,MAAIA,KAAG,MAAKA,KAAG;AAAG,SAAOA;AAAC;AAAQ,SAASC,IAAM;AAAC,WAAQH,GAAEC,GAAE,IAAE,GAAEC,IAAE,IAAG,IAAE,UAAU,QAAO,IAAE,GAAE,IAAI,EAACF,IAAE,UAAU,CAAC,OAAKC,IAAEF,EAAEC,CAAC,OAAKE,MAAIA,KAAG,MAAKA,KAAGD;AAAG,SAAOC;AAAC;","x_google_ignoreList":[0]}
|
|
@@ -1,45 +1,48 @@
|
|
|
1
1
|
import m from "../styles.module.css.js";
|
|
2
|
-
import { onMutation as v, on as
|
|
3
|
-
const c = m.field.split(" ")[0],
|
|
4
|
-
function
|
|
5
|
-
for (const
|
|
6
|
-
const
|
|
7
|
-
let o = null,
|
|
8
|
-
for (const
|
|
9
|
-
|
|
2
|
+
import { onMutation as v, on as d, QUICK_EVENT as p, isInputLike as S, attr as l, off as u, useId as r } from "../utils.js";
|
|
3
|
+
const c = m.field.split(" ")[0], _ = "--mtds-text-count-over", y = "--mtds-text-count-under", I = m.validation.split(" "), P = I[0];
|
|
4
|
+
function x(t) {
|
|
5
|
+
for (const n of t) {
|
|
6
|
+
const s = [], i = [];
|
|
7
|
+
let o = null, a = !0;
|
|
8
|
+
for (const e of n.getElementsByTagName("*"))
|
|
9
|
+
e instanceof HTMLLabelElement ? s.push(e) : S(e) ? o = e : e.classList.contains(P) ? (a = l(e, "data-color") === "success", i.unshift(r(e))) : e instanceof HTMLParagraphElement && i.push(r(e));
|
|
10
10
|
if (o) {
|
|
11
|
-
for (const
|
|
12
|
-
|
|
11
|
+
for (const e of s) e.htmlFor = r(o);
|
|
12
|
+
b(o), l(o, "aria-describedby", i.join(" ")), l(o, "aria-invalid", `${!a}`);
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
|
-
function
|
|
17
|
-
|
|
16
|
+
function E({ target: t }) {
|
|
17
|
+
S(t) && b(t);
|
|
18
18
|
}
|
|
19
|
-
function
|
|
20
|
-
var
|
|
21
|
-
const
|
|
22
|
-
if (
|
|
23
|
-
const
|
|
24
|
-
if (h !==
|
|
25
|
-
|
|
26
|
-
for (const
|
|
19
|
+
function b(t) {
|
|
20
|
+
var i, o;
|
|
21
|
+
const n = t == null ? void 0 : t.nextElementSibling, s = n && l(n, "data-count");
|
|
22
|
+
if (n && s) {
|
|
23
|
+
const a = Number(s) - t.value.length, e = a < 0, h = l(n, "aria-live") === "polite", f = window.getComputedStyle(n || t), C = ((i = f.getPropertyValue(_)) == null ? void 0 : i.slice(1, -1)) || "", L = ((o = f.getPropertyValue(y)) == null ? void 0 : o.slice(1, -1)) || "";
|
|
24
|
+
if (h !== e) {
|
|
25
|
+
l(n, "aria-live", e ? "polite" : "off");
|
|
26
|
+
for (const T of I) n.classList.toggle(T, e);
|
|
27
27
|
}
|
|
28
|
-
|
|
28
|
+
n.textContent = (e ? C : L).replace(
|
|
29
|
+
"%d",
|
|
30
|
+
`${Math.abs(a)}`
|
|
31
|
+
);
|
|
29
32
|
}
|
|
30
33
|
}
|
|
31
|
-
function
|
|
32
|
-
var
|
|
33
|
-
(
|
|
34
|
-
}
|
|
35
|
-
function R(t) {
|
|
36
|
-
v(t, c, P), u(t, "input", S, p), u(t, "invalid", E, !0);
|
|
34
|
+
function g(t) {
|
|
35
|
+
var n, s;
|
|
36
|
+
(s = (n = t.target) == null ? void 0 : n.closest) != null && s.call(n, `.${c}`) && t.preventDefault();
|
|
37
37
|
}
|
|
38
38
|
function V(t) {
|
|
39
|
-
v(t, c,
|
|
39
|
+
v(t, c, x), d(t, "input", E, p), d(t, "invalid", g, !0);
|
|
40
|
+
}
|
|
41
|
+
function A(t) {
|
|
42
|
+
v(t, c, !1), u(t, "input", E, p), u(t, "invalid", g, !0);
|
|
40
43
|
}
|
|
41
44
|
export {
|
|
42
|
-
|
|
43
|
-
|
|
45
|
+
V as observe,
|
|
46
|
+
A as unobserve
|
|
44
47
|
};
|
|
45
48
|
//# sourceMappingURL=field-observer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"field-observer.js","sources":["../../designsystem/field/field-observer.ts"],"sourcesContent":["import styles from
|
|
1
|
+
{"version":3,"file":"field-observer.js","sources":["../../designsystem/field/field-observer.ts"],"sourcesContent":["import styles from \"../styles.module.css\";\nimport {\n QUICK_EVENT,\n attr,\n isInputLike,\n off,\n on,\n onMutation,\n useId,\n} from \"../utils\";\n\nconst CSS_FIELD = styles.field.split(\" \")[0];\nconst CSS_PROPERTY_OVER = \"--mtds-text-count-over\";\nconst CSS_PROPERTY_UNDER = \"--mtds-text-count-under\";\nconst CSS_VALIDATIONS = styles.validation.split(\" \");\nconst CSS_VALIDATION = CSS_VALIDATIONS[0];\n\nfunction renderAria(fields: HTMLCollectionOf<Element>) {\n for (const field of fields) {\n const labels: HTMLLabelElement[] = [];\n const descs: string[] = [];\n let input: HTMLInputElement | null = null;\n let valid = true;\n\n for (const el of field.getElementsByTagName(\"*\")) {\n if (el instanceof HTMLLabelElement) labels.push(el);\n else if (isInputLike(el)) input = el;\n else if (el.classList.contains(CSS_VALIDATION)) {\n // Must be before instanceof HTMLParagraphElement since validation can also be a <p>\n valid = attr(el, \"data-color\") === \"success\";\n descs.unshift(useId(el));\n } else if (el instanceof HTMLParagraphElement) descs.push(useId(el));\n }\n\n if (input) {\n for (const label of labels) label.htmlFor = useId(input);\n renderCounter(input);\n attr(input, \"aria-describedby\", descs.join(\" \"));\n attr(input, \"aria-invalid\", `${!valid}`);\n }\n }\n}\nfunction handleInput({ target }: Event) {\n if (isInputLike(target)) renderCounter(target);\n}\n\nfunction renderCounter(input: HTMLInputElement) {\n const el = input?.nextElementSibling;\n const limit = el && attr(el, \"data-count\");\n\n if (el && limit) {\n const remainder = Number(limit) - input.value.length;\n const nextInvalid = remainder < 0;\n const prevInvalid = attr(el, \"aria-live\") === \"polite\";\n const style = window.getComputedStyle(el || input);\n const over = style.getPropertyValue(CSS_PROPERTY_OVER)?.slice(1, -1) || \"\"; // slice to trim quotes\n const under =\n style.getPropertyValue(CSS_PROPERTY_UNDER)?.slice(1, -1) || \"\"; // slice to trim quotes\n\n if (prevInvalid !== nextInvalid) {\n attr(el, \"aria-live\", nextInvalid ? \"polite\" : \"off\");\n for (const css of CSS_VALIDATIONS) el.classList.toggle(css, nextInvalid);\n }\n el.textContent = (nextInvalid ? over : under).replace(\n \"%d\",\n `${Math.abs(remainder)}`\n );\n }\n}\n\n// Prevent browsers from showing default validation bubbles\nfunction handleInvalid(event: Event) {\n if ((event.target as Element)?.closest?.(`.${CSS_FIELD}`))\n event.preventDefault();\n}\n\nexport function observe(el: Element) {\n onMutation(el, CSS_FIELD, renderAria);\n on(el, \"input\", handleInput, QUICK_EVENT);\n on(el, \"invalid\", handleInvalid, true); // Use capture as invalid does noe buttle\n}\n\nexport function unobserve(el: Element) {\n onMutation(el, CSS_FIELD, false);\n off(el, \"input\", handleInput, QUICK_EVENT);\n off(el, \"invalid\", handleInvalid, true);\n}\n"],"names":["CSS_FIELD","styles","CSS_PROPERTY_OVER","CSS_PROPERTY_UNDER","CSS_VALIDATIONS","CSS_VALIDATION","renderAria","fields","field","labels","descs","input","valid","el","isInputLike","attr","useId","label","renderCounter","handleInput","target","limit","remainder","nextInvalid","prevInvalid","style","over","_a","under","_b","css","handleInvalid","event","observe","onMutation","on","QUICK_EVENT","unobserve","off"],"mappings":";;AAWA,MAAMA,IAAYC,EAAO,MAAM,MAAM,GAAG,EAAE,CAAC,GACrCC,IAAoB,0BACpBC,IAAqB,2BACrBC,IAAkBH,EAAO,WAAW,MAAM,GAAG,GAC7CI,IAAiBD,EAAgB,CAAC;AAExC,SAASE,EAAWC,GAAmC;AACrD,aAAWC,KAASD,GAAQ;AAC1B,UAAME,IAA6B,CAAC,GAC9BC,IAAkB,CAAC;AACzB,QAAIC,IAAiC,MACjCC,IAAQ;AAEZ,eAAWC,KAAML,EAAM,qBAAqB,GAAG;AAC7C,MAAIK,aAAc,mBAAyBJ,EAAA,KAAKI,CAAE,IACzCC,EAAYD,CAAE,IAAWF,IAAAE,IACzBA,EAAG,UAAU,SAASR,CAAc,KAEnCO,IAAAG,EAAKF,GAAI,YAAY,MAAM,WAC7BH,EAAA,QAAQM,EAAMH,CAAE,CAAC,KACdA,aAAc,0BAA4B,KAAKG,EAAMH,CAAE,CAAC;AAGrE,QAAIF,GAAO;AACT,iBAAWM,KAASR,EAAc,CAAAQ,EAAA,UAAUD,EAAML,CAAK;AACvD,MAAAO,EAAcP,CAAK,GACnBI,EAAKJ,GAAO,oBAAoBD,EAAM,KAAK,GAAG,CAAC,GAC/CK,EAAKJ,GAAO,gBAAgB,GAAG,CAACC,CAAK,EAAE;AAAA,IAAA;AAAA,EACzC;AAEJ;AACA,SAASO,EAAY,EAAE,QAAA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AAAzB,GAAI,SAASM,GAAaiB,CAAW,GACrCE,EAAAzB,GAAI,WAAWkB,GAAe,EAAI;AACxC;"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { JSX } from 'react';
|
|
2
|
+
import { InputProps } from '../input/input';
|
|
3
|
+
import { PolymorphicComponentPropWithRef } from '../react-types';
|
|
4
|
+
type FieldBaseProps = InputProps & {
|
|
5
|
+
"data-size"?: string;
|
|
6
|
+
className?: InputProps["className"];
|
|
7
|
+
style?: InputProps["style"];
|
|
8
|
+
label?: React.ReactNode;
|
|
9
|
+
description?: React.ReactNode;
|
|
10
|
+
prefix?: string;
|
|
11
|
+
suffix?: string;
|
|
12
|
+
error?: React.ReactNode;
|
|
13
|
+
count?: number;
|
|
14
|
+
};
|
|
15
|
+
export type FieldProps<As extends React.ElementType = "div"> = PolymorphicComponentPropWithRef<As, FieldBaseProps>;
|
|
16
|
+
type FieldComponent = <As extends React.ElementType = "div">(props: FieldProps<As>) => JSX.Element;
|
|
17
|
+
export declare const FieldComp: FieldComponent;
|
|
18
|
+
export declare const Field: FieldComponent & {
|
|
19
|
+
Affixes: React.ForwardRefExoticComponent<Omit<FieldProps<"div">, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
20
|
+
};
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { jsx as i, jsxs as v } from "react/jsx-runtime";
|
|
2
|
+
import { clsx as u } from "../external/clsx/dist/clsx.js";
|
|
3
|
+
import { forwardRef as x } from "react";
|
|
4
|
+
import a from "../styles.module.css.js";
|
|
5
|
+
const g = x(function c({
|
|
6
|
+
"data-size": e,
|
|
7
|
+
as: n,
|
|
8
|
+
className: s,
|
|
9
|
+
count: o,
|
|
10
|
+
description: r,
|
|
11
|
+
error: d,
|
|
12
|
+
label: f,
|
|
13
|
+
prefix: t,
|
|
14
|
+
style: j,
|
|
15
|
+
suffix: l,
|
|
16
|
+
...m
|
|
17
|
+
}, p) {
|
|
18
|
+
const A = n || "div";
|
|
19
|
+
if (!n)
|
|
20
|
+
return /* @__PURE__ */ i("div", { className: u(a.field, s), ref: p, ...m });
|
|
21
|
+
const N = !!l || !!t, h = /* @__PURE__ */ i(A, { className: a.input, "aria-invalid": !!d, ref: p, ...m });
|
|
22
|
+
return /* @__PURE__ */ v(c, { className: s, "data-size": e, style: j, children: [
|
|
23
|
+
!!f && /* @__PURE__ */ i("label", { children: f }),
|
|
24
|
+
!!r && /* @__PURE__ */ i("p", { children: r }),
|
|
25
|
+
N ? /* @__PURE__ */ v(F, { children: [
|
|
26
|
+
!!t && /* @__PURE__ */ i("span", { children: t }),
|
|
27
|
+
h,
|
|
28
|
+
!!l && /* @__PURE__ */ i("span", { children: l })
|
|
29
|
+
] }) : h,
|
|
30
|
+
!!d && /* @__PURE__ */ i("div", { className: a.validation, children: d }),
|
|
31
|
+
!!o && /* @__PURE__ */ i("p", { "data-count": o })
|
|
32
|
+
] });
|
|
33
|
+
}), F = x(
|
|
34
|
+
function({ className: e, ...n }, s) {
|
|
35
|
+
return /* @__PURE__ */ i("div", { className: u(a.affixes, e), ref: s, ...n });
|
|
36
|
+
}
|
|
37
|
+
), C = Object.assign(g, {
|
|
38
|
+
Affixes: F
|
|
39
|
+
});
|
|
40
|
+
export {
|
|
41
|
+
C as Field,
|
|
42
|
+
g as FieldComp
|
|
43
|
+
};
|
|
44
|
+
//# sourceMappingURL=field.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"field.js","sources":["../../designsystem/field/field.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport { type JSX, forwardRef } from \"react\";\nimport type { InputProps } from \"../input/input\";\nimport type {\n\tPolymorphicComponentPropWithRef,\n\tPolymorphicRef,\n} from \"../react-types\";\nimport styles from \"../styles.module.css\";\n\ntype FieldBaseProps = InputProps & {\n\t\"data-size\"?: string;\n\tclassName?: InputProps[\"className\"];\n\tstyle?: InputProps[\"style\"];\n\tlabel?: React.ReactNode;\n\tdescription?: React.ReactNode;\n\tprefix?: string;\n\tsuffix?: string;\n\terror?: React.ReactNode;\n\tcount?: number;\n};\n\nexport type FieldProps<As extends React.ElementType = \"div\"> =\n\tPolymorphicComponentPropWithRef<As, FieldBaseProps>;\n\ntype FieldComponent = <As extends React.ElementType = \"div\">(\n\tprops: FieldProps<As>,\n) => JSX.Element;\n\nexport const FieldComp: FieldComponent = forwardRef<null>(function Field<\n\tAs extends React.ElementType = \"div\",\n>(\n\t{\n\t\t\"data-size\": size,\n\t\tas,\n\t\tclassName,\n\t\tcount,\n\t\tdescription,\n\t\terror,\n\t\tlabel,\n\t\tprefix,\n\t\tstyle,\n\t\tsuffix,\n\t\t...rest\n\t}: FieldProps<As>,\n\tref?: PolymorphicRef<As>,\n) {\n\tconst Tag = as || \"div\";\n\n\tif (!as)\n\t\treturn (\n\t\t\t<div className={clsx(styles.field, className)} ref={ref} {...rest} />\n\t\t);\n\n\tconst affixes = !!suffix || !!prefix;\n\tconst input = (\n\t\t<Tag className={styles.input} aria-invalid={!!error} ref={ref} {...rest} />\n\t);\n\n\treturn (\n\t\t<Field className={className} data-size={size} style={style}>\n\t\t\t{!!label && <label>{label}</label>}\n\t\t\t{!!description && <p>{description}</p>}\n\t\t\t{affixes ? (\n\t\t\t\t<FieldAffixes>\n\t\t\t\t\t{!!prefix && <span>{prefix}</span>}\n\t\t\t\t\t{input}\n\t\t\t\t\t{!!suffix && <span>{suffix}</span>}\n\t\t\t\t</FieldAffixes>\n\t\t\t) : (\n\t\t\t\tinput\n\t\t\t)}\n\t\t\t{!!error && <div className={styles.validation}>{error}</div>}\n\t\t\t{!!count && <p data-count={count} />}\n\t\t</Field>\n\t);\n}) as FieldComponent; // Needed to tell Typescript this does not return ReactNode but acutally JSX.Element\n\nconst FieldAffixes = forwardRef<HTMLDivElement, FieldProps>(\n\tfunction FieldAffixes({ className, ...rest }, ref) {\n\t\treturn (\n\t\t\t<div className={clsx(styles.affixes, className)} ref={ref} {...rest} />\n\t\t);\n\t},\n);\n\nexport const Field = Object.assign(FieldComp, {\n\tAffixes: FieldAffixes,\n});\n"],"names":["FieldComp","forwardRef","Field","size","as","className","count","description","error","label","prefix","style","suffix","rest","ref","Tag","jsx","clsx","styles","affixes","input","FieldAffixes"],"mappings":";;;;AA4Ba,MAAAA,IAA4BC,EAAiB,SAASC,EAGlE;AAAA,EACC,aAAaC;AAAA,EACb,IAAAC;AAAA,EACA,WAAAC;AAAA,EACA,OAAAC;AAAA,EACA,aAAAC;AAAA,EACA,OAAAC;AAAA,EACA,OAAAC;AAAA,EACA,QAAAC;AAAA,EACA,OAAAC;AAAA,EACA,QAAAC;AAAA,EACA,GAAGC;AACJ,GACAC,GACC;AACD,QAAMC,IAAMX,KAAM;AAElB,MAAI,CAACA;AAEH,WAAA,gBAAAY,EAAC,OAAI,EAAA,WAAWC,EAAKC,EAAO,OAAOb,CAAS,GAAG,KAAAS,GAAW,GAAGD,EAAM,CAAA;AAGrE,QAAMM,IAAU,CAAC,CAACP,KAAU,CAAC,CAACF,GACxBU,IACL,gBAAAJ,EAACD,GAAI,EAAA,WAAWG,EAAO,OAAO,gBAAc,CAAC,CAACV,GAAO,KAAAM,GAAW,GAAGD,EAAM,CAAA;AAG1E,2BACEX,GAAA,EAAM,WAAAG,GAAsB,aAAWF,GAAM,OAAAQ,GAC5C,UAAA;AAAA,IAAA,CAAC,CAACF,KAAU,gBAAAO,EAAA,SAAA,EAAO,UAAMP,GAAA;AAAA,IACzB,CAAC,CAACF,KAAe,gBAAAS,EAAC,OAAG,UAAYT,GAAA;AAAA,IACjCY,sBACCE,GACC,EAAA,UAAA;AAAA,MAAA,CAAC,CAACX,KAAW,gBAAAM,EAAA,QAAA,EAAM,UAAON,GAAA;AAAA,MAC1BU;AAAA,MACA,CAAC,CAACR,KAAU,gBAAAI,EAAC,UAAM,UAAOJ,EAAA,CAAA;AAAA,IAAA,EAAA,CAC5B,IAEAQ;AAAA,IAEA,CAAC,CAACZ,KAAS,gBAAAQ,EAAC,SAAI,WAAWE,EAAO,YAAa,UAAMV,GAAA;AAAA,IACrD,CAAC,CAACF,KAAU,gBAAAU,EAAA,KAAA,EAAE,cAAYV,EAAO,CAAA;AAAA,EAAA,GACnC;AAEF,CAAC,GAEKe,IAAepB;AAAA,EACpB,SAAsB,EAAE,WAAAI,GAAW,GAAGQ,EAAA,GAAQC,GAAK;AAEjD,WAAA,gBAAAE,EAAC,OAAI,EAAA,WAAWC,EAAKC,EAAO,SAASb,CAAS,GAAG,KAAAS,GAAW,GAAGD,EAAM,CAAA;AAAA,EAAA;AAGxE,GAEaX,IAAQ,OAAO,OAAOF,GAAW;AAAA,EAC7C,SAASqB;AACV,CAAC;"}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { StoryObj } from '@storybook/react';
|
|
2
2
|
declare const meta: {
|
|
3
3
|
title: string;
|
|
4
|
-
decorators: ((Story: import('@storybook/csf').PartialStoryFn<import('@storybook/react').ReactRenderer, {
|
|
4
|
+
decorators: ((Story: import('@storybook/core/csf').PartialStoryFn<import('@storybook/react').ReactRenderer, {
|
|
5
5
|
[x: string]: any;
|
|
6
6
|
}>) => import("react/jsx-runtime").JSX.Element)[];
|
|
7
7
|
};
|
|
8
8
|
export default meta;
|
|
9
9
|
type Story = StoryObj<typeof meta>;
|
|
10
10
|
export declare const Default: Story;
|
|
11
|
+
export declare const React: Story;
|
|
11
12
|
export declare const Required: Story;
|
|
12
13
|
export declare const Toggles: Story;
|
|
13
14
|
export declare const WithValidation: Story;
|
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
import n from "../styles.module.css.js";
|
|
2
|
-
import { onMutation as a, useId as
|
|
3
|
-
const
|
|
2
|
+
import { onMutation as a, useId as f, attr as e, isInputLike as c } from "../utils.js";
|
|
3
|
+
const l = n.fieldset.split(" ")[0], p = n.validation.split(" ")[0];
|
|
4
4
|
function d(s) {
|
|
5
|
-
for (const
|
|
5
|
+
for (const r of s) {
|
|
6
6
|
const i = [];
|
|
7
|
-
let o =
|
|
8
|
-
for (const t of
|
|
9
|
-
t.classList.contains(p) ? o =
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
e(t, "aria-describedby", o), e(t, "aria-invalid", "true");
|
|
7
|
+
let o = null;
|
|
8
|
+
for (const t of r.getElementsByTagName("*"))
|
|
9
|
+
t.classList.contains(p) ? o = f(t) : c(t) && i.push(t);
|
|
10
|
+
for (const t of i)
|
|
11
|
+
e(t, "aria-describedby", o), e(t, "aria-invalid", `${!!o}`);
|
|
13
12
|
}
|
|
14
13
|
}
|
|
15
|
-
const I = (s) => a(s,
|
|
14
|
+
const I = (s) => a(s, l, d), v = (s) => a(s, l, !1);
|
|
16
15
|
export {
|
|
17
16
|
I as observe,
|
|
18
17
|
v as unobserve
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fieldset-observer.js","sources":["../../designsystem/fieldset/fieldset-observer.ts"],"sourcesContent":["import styles from
|
|
1
|
+
{"version":3,"file":"fieldset-observer.js","sources":["../../designsystem/fieldset/fieldset-observer.ts"],"sourcesContent":["import styles from \"../styles.module.css\";\nimport { attr, isInputLike, onMutation, useId } from \"../utils\";\nconst CSS_FIELDSET = styles.fieldset.split(\" \")[0];\nconst CSS_VALIDATION = styles.validation.split(\" \")[0];\n\nfunction process(fieldsets: HTMLCollectionOf<Element>) {\n for (const fieldset of fieldsets) {\n const inputs: HTMLInputElement[] = [];\n let validationId: string | null = null;\n\n for (const el of fieldset.getElementsByTagName(\"*\")) {\n if (el.classList.contains(CSS_VALIDATION)) validationId = useId(el);\n else if (isInputLike(el)) inputs.push(el);\n }\n\n for (const input of inputs) {\n attr(input, \"aria-describedby\", validationId);\n attr(input, \"aria-invalid\", `${!!validationId}`);\n }\n }\n}\n\nexport const observe = (el: Element) => onMutation(el, CSS_FIELDSET, process);\nexport const unobserve = (el: Element) => onMutation(el, CSS_FIELDSET, false);\n"],"names":["CSS_FIELDSET","styles","CSS_VALIDATION","process","fieldsets","fieldset","inputs","validationId","el","useId","isInputLike","input","attr","observe","onMutation","unobserve"],"mappings":";;AAEA,MAAMA,IAAeC,EAAO,SAAS,MAAM,GAAG,EAAE,CAAC,GAC3CC,IAAiBD,EAAO,WAAW,MAAM,GAAG,EAAE,CAAC;AAErD,SAASE,EAAQC,GAAsC;AACrD,aAAWC,KAAYD,GAAW;AAChC,UAAME,IAA6B,CAAC;AACpC,QAAIC,IAA8B;AAElC,eAAWC,KAAMH,EAAS,qBAAqB,GAAG;AAChD,MAAIG,EAAG,UAAU,SAASN,CAAc,IAAGK,IAAeE,EAAMD,CAAE,IACzDE,EAAYF,CAAE,KAAGF,EAAO,KAAKE,CAAE;AAG1C,eAAWG,KAASL;AACb,MAAAM,EAAAD,GAAO,oBAAoBJ,CAAY,GAC5CK,EAAKD,GAAO,gBAAgB,GAAG,CAAC,CAACJ,CAAY,EAAE;AAAA,EACjD;AAEJ;AAEO,MAAMM,IAAU,CAACL,MAAgBM,EAAWN,GAAIR,GAAcG,CAAO,GAC/DY,IAAY,CAACP,MAAgBM,EAAWN,GAAIR,GAAc,EAAK;"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { jsx as o } from "react/jsx-runtime";
|
|
2
|
+
import { clsx as s } from "../external/clsx/dist/clsx.js";
|
|
3
|
+
import { forwardRef as f } from "react";
|
|
4
|
+
import i from "../styles.module.css.js";
|
|
5
|
+
const n = f(
|
|
6
|
+
function({ className: e, ...r }, t) {
|
|
7
|
+
return /* @__PURE__ */ o(
|
|
8
|
+
"fieldset",
|
|
9
|
+
{
|
|
10
|
+
className: s(i.fieldset, e),
|
|
11
|
+
ref: t,
|
|
12
|
+
...r
|
|
13
|
+
}
|
|
14
|
+
);
|
|
15
|
+
}
|
|
16
|
+
);
|
|
17
|
+
export {
|
|
18
|
+
n as Fieldset
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=fieldset.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fieldset.js","sources":["../../designsystem/fieldset/fieldset.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport { forwardRef } from \"react\";\nimport styles from \"../styles.module.css\";\n\nexport type FieldsetProps = React.ComponentPropsWithoutRef<\"fieldset\">;\n\nexport const Fieldset = forwardRef<HTMLFieldSetElement, FieldsetProps>(\n\tfunction Fieldset({ className, ...rest }, ref) {\n\t\treturn (\n\t\t\t<fieldset\n\t\t\t\tclassName={clsx(styles.fieldset, className)}\n\t\t\t\tref={ref}\n\t\t\t\t{...rest}\n\t\t\t/>\n\t\t);\n\t},\n);\n"],"names":["Fieldset","forwardRef","className","rest","ref","jsx","clsx","styles"],"mappings":";;;;AAMO,MAAMA,IAAWC;AAAA,EACvB,SAAkB,EAAE,WAAAC,GAAW,GAAGC,EAAA,GAAQC,GAAK;AAE7C,WAAA,gBAAAC;AAAA,MAAC;AAAA,MAAA;AAAA,QACA,WAAWC,EAAKC,EAAO,UAAUL,CAAS;AAAA,QAC1C,KAAAE;AAAA,QACC,GAAGD;AAAA,MAAA;AAAA,IACL;AAAA,EAAA;AAGH;"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { JSX } from 'react';
|
|
2
2
|
import { PolymorphicComponentPropWithRef } from '../react-types';
|
|
3
|
-
export type HeadingProps<As extends React.ElementType = "h2"> = PolymorphicComponentPropWithRef<As
|
|
3
|
+
export type HeadingProps<As extends React.ElementType = "h2"> = PolymorphicComponentPropWithRef<As, {
|
|
4
|
+
"data-size"?: "2xs" | "xs" | "sm" | "md" | "lg" | "xl" | "2xl";
|
|
5
|
+
}>;
|
|
4
6
|
type HeadingComponent = <As extends React.ElementType = "h2">(props: HeadingProps<As>) => JSX.Element;
|
|
5
7
|
export declare const Heading: HeadingComponent;
|
|
6
8
|
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { jsx as a } from "react/jsx-runtime";
|
|
2
|
+
import { clsx as e } from "../external/clsx/dist/clsx.js";
|
|
3
|
+
import { forwardRef as i } from "react";
|
|
4
|
+
import n from "../styles.module.css.js";
|
|
5
|
+
const l = i(function({ as: o, className: r, ...t }, m) {
|
|
6
|
+
return /* @__PURE__ */ a(o || "h2", { className: e(n.heading, r), ref: m, ...t });
|
|
7
|
+
});
|
|
8
|
+
export {
|
|
9
|
+
l as Heading
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=heading.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"heading.js","sources":["../../designsystem/heading/heading.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport { type JSX, forwardRef } from \"react\";\nimport type {\n\tPolymorphicComponentPropWithRef,\n\tPolymorphicRef,\n} from \"../react-types\";\nimport styles from \"../styles.module.css\";\n\nexport type HeadingProps<As extends React.ElementType = \"h2\"> =\n\tPolymorphicComponentPropWithRef<\n\t\tAs,\n\t\t{\n\t\t\t\"data-size\"?: \"2xs\" | \"xs\" | \"sm\" | \"md\" | \"lg\" | \"xl\" | \"2xl\";\n\t\t}\n\t>;\n\ntype HeadingComponent = <As extends React.ElementType = \"h2\">(\n\tprops: HeadingProps<As>,\n) => JSX.Element;\n\nexport const Heading: HeadingComponent = forwardRef<null>(function Heading<\n\tAs extends React.ElementType = \"h2\",\n>({ as, className, ...rest }: HeadingProps<As>, ref?: PolymorphicRef<As>) {\n\tconst Tag = as || \"h2\";\n\n\treturn (\n\t\t<Tag className={clsx(styles.heading, className)} ref={ref} {...rest} />\n\t);\n}) as HeadingComponent; // Needed to tell Typescript this does not return ReactNode but acutally JSX.Element\n"],"names":["Heading","forwardRef","as","className","rest","ref","jsx","clsx","styles"],"mappings":";;;;AAoBa,MAAAA,IAA4BC,EAAiB,SAExD,EAAE,IAAAC,GAAI,WAAAC,GAAW,GAAGC,EAAK,GAAqBC,GAA0B;AAIxE,SAAA,gBAAAC,EAHWJ,KAAM,MAGZ,EAAA,WAAWK,EAAKC,EAAO,SAASL,CAAS,GAAG,KAAAE,GAAW,GAAGD,EAAM,CAAA;AAEvE,CAAC;"}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { StoryObj } from '@storybook/react';
|
|
2
2
|
declare const meta: {
|
|
3
3
|
title: string;
|
|
4
|
-
decorators: ((Story: import('@storybook/csf').PartialStoryFn<import('@storybook/react').ReactRenderer, {
|
|
4
|
+
decorators: ((Story: import('@storybook/core/csf').PartialStoryFn<import('@storybook/react').ReactRenderer, {
|
|
5
5
|
[x: string]: any;
|
|
6
6
|
}>) => import("react/jsx-runtime").JSX.Element)[];
|
|
7
7
|
};
|
|
8
8
|
export default meta;
|
|
9
9
|
type Story = StoryObj<typeof meta>;
|
|
10
10
|
export declare const Default: Story;
|
|
11
|
+
export declare const React: Story;
|
|
11
12
|
export declare const Center: Story;
|
|
13
|
+
export declare const Stack: Story;
|
package/mtds/index.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
export { pagination } from './pagination/pagination';
|
|
2
1
|
export declare const styles: {
|
|
3
2
|
alert: string;
|
|
4
3
|
avatar: string;
|
|
@@ -6,6 +5,7 @@ badge: string;
|
|
|
6
5
|
breadcrumbs: string;
|
|
7
6
|
button: string;
|
|
8
7
|
card: string;
|
|
8
|
+
group: string;
|
|
9
9
|
chip: string;
|
|
10
10
|
details: string;
|
|
11
11
|
dialog: string;
|
|
@@ -16,6 +16,7 @@ affixes: string;
|
|
|
16
16
|
count: string;
|
|
17
17
|
fieldset: string;
|
|
18
18
|
heading: string;
|
|
19
|
+
stack: string;
|
|
19
20
|
input: string;
|
|
20
21
|
grid: string;
|
|
21
22
|
flex: string;
|
|
@@ -32,5 +33,6 @@ tag: string;
|
|
|
32
33
|
validation: string;
|
|
33
34
|
body: string;
|
|
34
35
|
};
|
|
36
|
+
export { pagination } from './pagination/pagination-helper';
|
|
35
37
|
export declare function observe(el: Element): void;
|
|
36
38
|
export declare function unobserve(el: Element): void;
|