@digdir/designsystemet-web 0.0.1
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/README.md +21 -0
- package/dist/cjs/_virtual/rolldown_runtime.cjs +29 -0
- package/dist/cjs/breadcrumbs.cjs +50 -0
- package/dist/cjs/breadcrumbs.cjs.map +1 -0
- package/dist/cjs/clickdelegatefor.cjs +35 -0
- package/dist/cjs/clickdelegatefor.cjs.map +1 -0
- package/dist/cjs/details.cjs +21 -0
- package/dist/cjs/details.cjs.map +1 -0
- package/dist/cjs/dialog.cjs +18 -0
- package/dist/cjs/dialog.cjs.map +1 -0
- package/dist/cjs/error-summary.cjs +24 -0
- package/dist/cjs/error-summary.cjs.map +1 -0
- package/dist/cjs/field.cjs +115 -0
- package/dist/cjs/field.cjs.map +1 -0
- package/dist/cjs/index.cjs +37 -0
- package/dist/cjs/index.cjs.map +1 -0
- package/dist/cjs/pagination.cjs +72 -0
- package/dist/cjs/pagination.cjs.map +1 -0
- package/dist/cjs/popover.cjs +89 -0
- package/dist/cjs/popover.cjs.map +1 -0
- package/dist/cjs/suggestion.cjs +24 -0
- package/dist/cjs/suggestion.cjs.map +1 -0
- package/dist/cjs/tabs.cjs +21 -0
- package/dist/cjs/tabs.cjs.map +1 -0
- package/dist/cjs/toggle-group.cjs +29 -0
- package/dist/cjs/toggle-group.cjs.map +1 -0
- package/dist/cjs/tooltip.cjs +55 -0
- package/dist/cjs/tooltip.cjs.map +1 -0
- package/dist/cjs/utils.cjs +159 -0
- package/dist/cjs/utils.cjs.map +1 -0
- package/dist/esm/breadcrumbs.js +50 -0
- package/dist/esm/breadcrumbs.js.map +1 -0
- package/dist/esm/clickdelegatefor.js +35 -0
- package/dist/esm/clickdelegatefor.js.map +1 -0
- package/dist/esm/details.js +21 -0
- package/dist/esm/details.js.map +1 -0
- package/dist/esm/dialog.js +18 -0
- package/dist/esm/dialog.js.map +1 -0
- package/dist/esm/error-summary.js +24 -0
- package/dist/esm/error-summary.js.map +1 -0
- package/dist/esm/field.js +115 -0
- package/dist/esm/field.js.map +1 -0
- package/dist/esm/index.js +22 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/pagination.js +71 -0
- package/dist/esm/pagination.js.map +1 -0
- package/dist/esm/popover.js +88 -0
- package/dist/esm/popover.js.map +1 -0
- package/dist/esm/src/breadcrumbs.d.ts +16 -0
- package/dist/esm/src/breadcrumbs.d.ts.map +1 -0
- package/dist/esm/src/clickdelegatefor.d.ts +2 -0
- package/dist/esm/src/clickdelegatefor.d.ts.map +1 -0
- package/dist/esm/src/details.d.ts +2 -0
- package/dist/esm/src/details.d.ts.map +1 -0
- package/dist/esm/src/dialog.d.ts +2 -0
- package/dist/esm/src/dialog.d.ts.map +1 -0
- package/dist/esm/src/error-summary.d.ts +12 -0
- package/dist/esm/src/error-summary.d.ts.map +1 -0
- package/dist/esm/src/field.d.ts +15 -0
- package/dist/esm/src/field.d.ts.map +1 -0
- package/dist/esm/src/index.d.ts +14 -0
- package/dist/esm/src/index.d.ts.map +1 -0
- package/dist/esm/src/pagination.d.ts +27 -0
- package/dist/esm/src/pagination.d.ts.map +1 -0
- package/dist/esm/src/popover.d.ts +2 -0
- package/dist/esm/src/popover.d.ts.map +1 -0
- package/dist/esm/src/suggestion.d.ts +11 -0
- package/dist/esm/src/suggestion.d.ts.map +1 -0
- package/dist/esm/src/tabs.d.ts +18 -0
- package/dist/esm/src/tabs.d.ts.map +1 -0
- package/dist/esm/src/toggle-group.d.ts +2 -0
- package/dist/esm/src/toggle-group.d.ts.map +1 -0
- package/dist/esm/src/tooltip.d.ts +2 -0
- package/dist/esm/src/tooltip.d.ts.map +1 -0
- package/dist/esm/src/utils.d.ts +78 -0
- package/dist/esm/src/utils.d.ts.map +1 -0
- package/dist/esm/suggestion.js +23 -0
- package/dist/esm/suggestion.js.map +1 -0
- package/dist/esm/tabs.js +16 -0
- package/dist/esm/tabs.js.map +1 -0
- package/dist/esm/toggle-group.js +29 -0
- package/dist/esm/toggle-group.js.map +1 -0
- package/dist/esm/tooltip.js +55 -0
- package/dist/esm/tooltip.js.map +1 -0
- package/dist/esm/tsconfig.tsbuildinfo +1 -0
- package/dist/esm/utils.js +145 -0
- package/dist/esm/utils.js.map +1 -0
- package/package.json +47 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/utils.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW;;;CAAmC,CAAC;AAG5D,eAAO,MAAM,SAAS,eAC4C,CAAC;AAEnE,eAAO,MAAM,SAAS,eAGiD,CAAC;AAGxE,eAAO,MAAM,SAAS;;;CAGL,CAAC;AAElB,wBAAgB,QAAQ,CAAC,CAAC,SAAS,OAAO,EAAE,EAC1C,QAAQ,EAAE,CAAC,GAAG,IAAI,EAAE,CAAC,KAAK,IAAI,EAC9B,KAAK,EAAE,MAAM,IAII,MAAM,OAAO,EAAE,GAAG,MAAM,CAAC,UAI3C;AAED;;;;;;GAMG;AACH,eAAO,MAAM,IAAI,GACf,IAAI,OAAO,EACX,MAAM,MAAM,EACZ,QAAQ,MAAM,GAAG,IAAI,KACpB,MAAM,GAAG,IAKX,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,GAAI,IAAI,OAAO,EAAE,MAAM,MAAM,gBAEI,CAAC;AAElE;;;;;GAKG;AACH,eAAO,MAAM,EAAE,GACb,IAAI,IAAI,GAAG,MAAM,GAAG,UAAU,EAC9B,GAAG,MAAM,UAAU,CAAC,OAAO,OAAO,CAAC,SAAS,CAAC,gBAAgB,CAAC,KAC7D,CAAC,MAAM,IAAI,CAIb,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,GAAG,GACd,IAAI,IAAI,GAAG,MAAM,GAAG,UAAU,EAC9B,GAAG,MAAM,UAAU,CAAC,OAAO,OAAO,CAAC,SAAS,CAAC,mBAAmB,CAAC,KAChE,IAGF,CAAC;AAGF,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,mBAAmB,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,MAAM,IAAI,CAAC,CAAC,CAAC;KACtD;CACF;AAED;;;;;GAKG;AACH,eAAO,MAAM,WAAW,GAAI,KAAK,MAAM,EAAE,OAAO,MAAM,KAAK,CAAC,MAAM,IAAI,CAAC,SAWtE,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,UAAU,GACrB,IAAI,IAAI,EACR,UAAU,CAAC,QAAQ,EAAE,gBAAgB,KAAK,IAAI,EAC9C,SAAS,oBAAoB,GAAG;IAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,KAAK,CAAA;CAAE,eAmB9D,CAAC;AAyBF;;;;;;;GAOG;AACH,eAAO,MAAM,GAAG,GAAI,OAAO,SAAS,MAAM,qBAAqB,EAC7D,SAAS,OAAO,EAChB,QAAQ,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,GAAG,IAAI,KAC3C,qBAAqB,CAAC,OAAO,CAI/B,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,cAAc;mBACV,MAAM,YAAY,wBAAwB;CAI1D,CAAC;AAQF,wBAAgB,KAAK,CAAC,EAAE,CAAC,EAAE,OAAO,GAAG,IAAI,UAGxC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { QUICK_EVENT, customElements, off, on } from "./utils.js";
|
|
2
|
+
import { UHTMLComboboxElement } from "@u-elements/u-combobox";
|
|
3
|
+
|
|
4
|
+
//#region src/suggestion.ts
|
|
5
|
+
var DSSuggestionElement = class extends UHTMLComboboxElement {
|
|
6
|
+
connectedCallback() {
|
|
7
|
+
super.connectedCallback();
|
|
8
|
+
on(this, "toggle", polyfillToggleSource, QUICK_EVENT);
|
|
9
|
+
}
|
|
10
|
+
disconnectedCallback() {
|
|
11
|
+
super.disconnectedCallback();
|
|
12
|
+
off(this, "toggle", polyfillToggleSource, QUICK_EVENT);
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
customElements.define("ds-suggestion", DSSuggestionElement);
|
|
16
|
+
function polyfillToggleSource({ target: el, newState }) {
|
|
17
|
+
const detail = newState === "open" && el instanceof Element && el.id && document.querySelector(`input[list="${el.id}"]`);
|
|
18
|
+
if (detail) el.dispatchEvent(new CustomEvent("ds-toggle-source", { detail }));
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
//#endregion
|
|
22
|
+
export { DSSuggestionElement };
|
|
23
|
+
//# sourceMappingURL=suggestion.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"suggestion.js","names":[],"sources":["../../src/suggestion.ts"],"sourcesContent":["import { UHTMLComboboxElement } from '@u-elements/u-combobox';\r\nimport { customElements, off, on, QUICK_EVENT } from './utils';\r\n\r\ndeclare global {\r\n interface HTMLElementTagNameMap {\r\n 'ds-suggestion': DSSuggestionElement;\r\n }\r\n}\r\n\r\nexport class DSSuggestionElement extends UHTMLComboboxElement {\r\n connectedCallback() {\r\n super.connectedCallback();\r\n on(this, 'toggle', polyfillToggleSource, QUICK_EVENT);\r\n }\r\n disconnectedCallback() {\r\n super.disconnectedCallback();\r\n off(this, 'toggle', polyfillToggleSource, QUICK_EVENT);\r\n }\r\n}\r\n\r\ncustomElements.define('ds-suggestion', DSSuggestionElement);\r\n\r\n// Since showPopover({ source }) is not supported in all browsers yet:\r\nfunction polyfillToggleSource({ target: el, newState }: Partial<ToggleEvent>) {\r\n const id = newState === 'open' && el instanceof Element && el.id;\r\n const detail = id && document.querySelector(`input[list=\"${el.id}\"]`);\r\n\r\n if (detail) el.dispatchEvent(new CustomEvent('ds-toggle-source', { detail }));\r\n}\r\n"],"mappings":";;;;AASA,IAAa,sBAAb,cAAyC,qBAAqB;CAC5D,oBAAoB;AAClB,QAAM,mBAAmB;AACzB,KAAG,MAAM,UAAU,sBAAsB,YAAY;;CAEvD,uBAAuB;AACrB,QAAM,sBAAsB;AAC5B,MAAI,MAAM,UAAU,sBAAsB,YAAY;;;AAI1D,eAAe,OAAO,iBAAiB,oBAAoB;AAG3D,SAAS,qBAAqB,EAAE,QAAQ,IAAI,YAAkC;CAE5E,MAAM,SADK,aAAa,UAAU,cAAc,WAAW,GAAG,MACzC,SAAS,cAAc,eAAe,GAAG,GAAG,IAAI;AAErE,KAAI,OAAQ,IAAG,cAAc,IAAI,YAAY,oBAAoB,EAAE,QAAQ,CAAC,CAAC"}
|
package/dist/esm/tabs.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { customElements } from "./utils.js";
|
|
2
|
+
import * as UTabs from "@u-elements/u-tabs";
|
|
3
|
+
|
|
4
|
+
//#region src/tabs.ts
|
|
5
|
+
var DSTabsElement = class extends UTabs.UHTMLTabsElement {};
|
|
6
|
+
var DSTabListElement = class extends UTabs.UHTMLTabListElement {};
|
|
7
|
+
var DSTabElement = class extends UTabs.UHTMLTabElement {};
|
|
8
|
+
var DSTabPanelElement = class extends UTabs.UHTMLTabPanelElement {};
|
|
9
|
+
customElements.define("ds-tabs", DSTabsElement);
|
|
10
|
+
customElements.define("ds-tablist", DSTabListElement);
|
|
11
|
+
customElements.define("ds-tab", DSTabElement);
|
|
12
|
+
customElements.define("ds-tabpanel", DSTabPanelElement);
|
|
13
|
+
|
|
14
|
+
//#endregion
|
|
15
|
+
export { DSTabElement, DSTabListElement, DSTabPanelElement, DSTabsElement };
|
|
16
|
+
//# sourceMappingURL=tabs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tabs.js","names":[],"sources":["../../src/tabs.ts"],"sourcesContent":["import * as UTabs from '@u-elements/u-tabs';\r\nimport { customElements } from './utils';\r\n\r\ndeclare global {\r\n interface HTMLElementTagNameMap {\r\n 'ds-tabs': DSTabsElement;\r\n 'ds-tablist': DSTabListElement;\r\n 'ds-tab': DSTabElement;\r\n 'ds-tabpanel': DSTabPanelElement;\r\n }\r\n}\r\n\r\nexport class DSTabsElement extends UTabs.UHTMLTabsElement {}\r\nexport class DSTabListElement extends UTabs.UHTMLTabListElement {}\r\nexport class DSTabElement extends UTabs.UHTMLTabElement {}\r\nexport class DSTabPanelElement extends UTabs.UHTMLTabPanelElement {}\r\n\r\ncustomElements.define('ds-tabs', DSTabsElement);\r\ncustomElements.define('ds-tablist', DSTabListElement);\r\ncustomElements.define('ds-tab', DSTabElement);\r\ncustomElements.define('ds-tabpanel', DSTabPanelElement);\r\n"],"mappings":";;;;AAYA,IAAa,gBAAb,cAAmC,MAAM,iBAAiB;AAC1D,IAAa,mBAAb,cAAsC,MAAM,oBAAoB;AAChE,IAAa,eAAb,cAAkC,MAAM,gBAAgB;AACxD,IAAa,oBAAb,cAAuC,MAAM,qBAAqB;AAElE,eAAe,OAAO,WAAW,cAAc;AAC/C,eAAe,OAAO,cAAc,iBAAiB;AACrD,eAAe,OAAO,UAAU,aAAa;AAC7C,eAAe,OAAO,eAAe,kBAAkB"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { attr, on, onHotReload, onMutation } from "./utils.js";
|
|
2
|
+
|
|
3
|
+
//#region src/toggle-group.ts
|
|
4
|
+
const ATTR_TOGGLEGROUP = "data-toggle-group";
|
|
5
|
+
const SELECTOR_TOGGLEGROUP = `[${ATTR_TOGGLEGROUP}]`;
|
|
6
|
+
function handleAriaAttributes() {
|
|
7
|
+
for (const group of document.querySelectorAll(SELECTOR_TOGGLEGROUP)) attr(group, "aria-label", attr(group, ATTR_TOGGLEGROUP));
|
|
8
|
+
}
|
|
9
|
+
function handleKeydown(event) {
|
|
10
|
+
const group = event.target instanceof HTMLInputElement && event.target.closest(SELECTOR_TOGGLEGROUP);
|
|
11
|
+
if (!group) return;
|
|
12
|
+
if (event.key === "Enter") event.target.click();
|
|
13
|
+
if (event.key?.startsWith("Arrow")) {
|
|
14
|
+
event.preventDefault?.();
|
|
15
|
+
const inputs = group.getElementsByTagName("input");
|
|
16
|
+
const index = [...inputs].indexOf(event.target);
|
|
17
|
+
const move = event.key.match(/Arrow(Right|Down)/) ? 1 : -1;
|
|
18
|
+
inputs[(inputs.length + index + move) % inputs.length]?.focus();
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
onHotReload("toggle-group", () => [on(document, "keydown", handleKeydown), onMutation(document, handleAriaAttributes, {
|
|
22
|
+
attributeFilter: [ATTR_TOGGLEGROUP],
|
|
23
|
+
attributes: true,
|
|
24
|
+
childList: true,
|
|
25
|
+
subtree: true
|
|
26
|
+
})]);
|
|
27
|
+
|
|
28
|
+
//#endregion
|
|
29
|
+
//# sourceMappingURL=toggle-group.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toggle-group.js","names":[],"sources":["../../src/toggle-group.ts"],"sourcesContent":["import { attr, on, onHotReload, onMutation } from './utils';\r\n\r\nconst ATTR_TOGGLEGROUP = 'data-toggle-group';\r\nconst SELECTOR_TOGGLEGROUP = `[${ATTR_TOGGLEGROUP}]`;\r\n\r\nfunction handleAriaAttributes() {\r\n for (const group of document.querySelectorAll(SELECTOR_TOGGLEGROUP))\r\n attr(group, 'aria-label', attr(group, ATTR_TOGGLEGROUP));\r\n}\r\n\r\nfunction handleKeydown(event: Partial<KeyboardEvent>) {\r\n const group =\r\n event.target instanceof HTMLInputElement &&\r\n event.target.closest(SELECTOR_TOGGLEGROUP);\r\n\r\n if (!group) return;\r\n if (event.key === 'Enter') event.target.click(); // Forward Enter, but no need to listen for space key, as this is handled by the browser\r\n if (event.key?.startsWith('Arrow')) {\r\n event.preventDefault?.();\r\n const inputs = group.getElementsByTagName('input');\r\n const index = [...inputs].indexOf(event.target);\r\n const move = event.key.match(/Arrow(Right|Down)/) ? 1 : -1;\r\n inputs[(inputs.length + index + move) % inputs.length]?.focus();\r\n }\r\n}\r\n\r\nonHotReload('toggle-group', () => [\r\n on(document, 'keydown', handleKeydown),\r\n onMutation(document, handleAriaAttributes, {\r\n attributeFilter: [ATTR_TOGGLEGROUP],\r\n attributes: true,\r\n childList: true,\r\n subtree: true,\r\n }),\r\n]);\r\n"],"mappings":";;;AAEA,MAAM,mBAAmB;AACzB,MAAM,uBAAuB,IAAI,iBAAiB;AAElD,SAAS,uBAAuB;AAC9B,MAAK,MAAM,SAAS,SAAS,iBAAiB,qBAAqB,CACjE,MAAK,OAAO,cAAc,KAAK,OAAO,iBAAiB,CAAC;;AAG5D,SAAS,cAAc,OAA+B;CACpD,MAAM,QACJ,MAAM,kBAAkB,oBACxB,MAAM,OAAO,QAAQ,qBAAqB;AAE5C,KAAI,CAAC,MAAO;AACZ,KAAI,MAAM,QAAQ,QAAS,OAAM,OAAO,OAAO;AAC/C,KAAI,MAAM,KAAK,WAAW,QAAQ,EAAE;AAClC,QAAM,kBAAkB;EACxB,MAAM,SAAS,MAAM,qBAAqB,QAAQ;EAClD,MAAM,QAAQ,CAAC,GAAG,OAAO,CAAC,QAAQ,MAAM,OAAO;EAC/C,MAAM,OAAO,MAAM,IAAI,MAAM,oBAAoB,GAAG,IAAI;AACxD,UAAQ,OAAO,SAAS,QAAQ,QAAQ,OAAO,SAAS,OAAO;;;AAInE,YAAY,sBAAsB,CAChC,GAAG,UAAU,WAAW,cAAc,EACtC,WAAW,UAAU,sBAAsB;CACzC,iBAAiB,CAAC,iBAAiB;CACnC,YAAY;CACZ,WAAW;CACX,SAAS;CACV,CAAC,CACH,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { QUICK_EVENT, attr, attrRequiredWarning, on, onHotReload, onMutation, tag } from "./utils.js";
|
|
2
|
+
|
|
3
|
+
//#region src/tooltip.ts
|
|
4
|
+
let TIP;
|
|
5
|
+
let SOURCE;
|
|
6
|
+
let HOVER_TIMER = 0;
|
|
7
|
+
let SKIP_TIMER = 0;
|
|
8
|
+
const SELECTOR_TOOLTIP = "[data-tooltip-element]";
|
|
9
|
+
const SELECTOR_INTERACTIVE = "a,button,input,select,textarea,[tabindex]";
|
|
10
|
+
const DELAY_HOVER = 300;
|
|
11
|
+
const DELAY_SKIP = 300;
|
|
12
|
+
function handleAriaAttributes() {
|
|
13
|
+
for (const el of document.querySelectorAll("[data-tooltip]")) {
|
|
14
|
+
const hasText = el.textContent?.trim();
|
|
15
|
+
const tooltip = attr(el, "data-tooltip");
|
|
16
|
+
attr(el, hasText ? "aria-description" : "aria-label", tooltip);
|
|
17
|
+
if (!el.matches(SELECTOR_INTERACTIVE)) attrRequiredWarning(el, "tabindex=\"0\"");
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
function handleInterest({ type, target }) {
|
|
21
|
+
clearTimeout(HOVER_TIMER);
|
|
22
|
+
if (!TIP) TIP = document.querySelector(SELECTOR_TOOLTIP) || tag("div", { class: "ds-tooltip" });
|
|
23
|
+
if (!TIP || target === TIP) return;
|
|
24
|
+
if (type === "mouseover" && !SOURCE) {
|
|
25
|
+
HOVER_TIMER = setTimeout(handleInterest, DELAY_HOVER, { target });
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
const source = target?.closest?.("[data-tooltip]");
|
|
29
|
+
if (source === SOURCE) return;
|
|
30
|
+
if (!TIP.isConnected) document.body.appendChild(TIP);
|
|
31
|
+
if (!TIP.hasAttribute("popover")) attr(TIP, "popover", "manual");
|
|
32
|
+
if (!source) return TIP?.hidePopover();
|
|
33
|
+
clearTimeout(SKIP_TIMER);
|
|
34
|
+
TIP.textContent = attr(source, "data-tooltip");
|
|
35
|
+
TIP.showPopover();
|
|
36
|
+
TIP.dispatchEvent(new CustomEvent("ds-toggle-source", { detail: source }));
|
|
37
|
+
SOURCE = source;
|
|
38
|
+
}
|
|
39
|
+
function handleClose(event) {
|
|
40
|
+
if (!event) SOURCE = void 0;
|
|
41
|
+
else if (event.target === TIP && event.newState === "closed") SKIP_TIMER = setTimeout(handleClose, DELAY_SKIP);
|
|
42
|
+
}
|
|
43
|
+
onHotReload("tooltip", () => [
|
|
44
|
+
on(document, "blur focus mouseover", handleInterest, QUICK_EVENT),
|
|
45
|
+
on(document, "toggle", handleClose, QUICK_EVENT),
|
|
46
|
+
onMutation(document, handleAriaAttributes, {
|
|
47
|
+
attributeFilter: ["data-tooltip"],
|
|
48
|
+
attributes: true,
|
|
49
|
+
childList: true,
|
|
50
|
+
subtree: true
|
|
51
|
+
})
|
|
52
|
+
]);
|
|
53
|
+
|
|
54
|
+
//#endregion
|
|
55
|
+
//# sourceMappingURL=tooltip.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tooltip.js","names":[],"sources":["../../src/tooltip.ts"],"sourcesContent":["import {\r\n attr,\r\n attrRequiredWarning,\r\n on,\r\n onHotReload,\r\n onMutation,\r\n QUICK_EVENT,\r\n tag,\r\n} from './utils';\r\n\r\nlet TIP: HTMLElement;\r\nlet SOURCE: Element | undefined;\r\nlet HOVER_TIMER: number | ReturnType<typeof setTimeout> = 0;\r\nlet SKIP_TIMER: number | ReturnType<typeof setTimeout> = 0;\r\nconst SELECTOR_TOOLTIP = '[data-tooltip-element]';\r\nconst SELECTOR_INTERACTIVE = 'a,button,input,select,textarea,[tabindex]';\r\nconst DELAY_HOVER = 300;\r\nconst DELAY_SKIP = 300;\r\n\r\n// TODO: Document using data-tooltip-element to set custom tooltip element\r\n\r\nfunction handleAriaAttributes() {\r\n for (const el of document.querySelectorAll('[data-tooltip]')) {\r\n const hasText = el.textContent?.trim();\r\n const tooltip = attr(el, 'data-tooltip');\r\n\r\n attr(el, hasText ? 'aria-description' : 'aria-label', tooltip);\r\n if (!el.matches(SELECTOR_INTERACTIVE))\r\n attrRequiredWarning(el, 'tabindex=\"0\"');\r\n }\r\n}\r\n\r\nfunction handleInterest({ type, target }: Event) {\r\n clearTimeout(HOVER_TIMER);\r\n\r\n if (!TIP)\r\n TIP =\r\n document.querySelector<HTMLElement>(SELECTOR_TOOLTIP) ||\r\n tag('div', { class: 'ds-tooltip' });\r\n\r\n if (!TIP || target === TIP) return; // Allow tooltip to be hovered, following https://www.w3.org/TR/WCAG21/#content-on-hover-or-focus\r\n if (type === 'mouseover' && !SOURCE) {\r\n HOVER_TIMER = setTimeout(handleInterest, DELAY_HOVER, { target }); // Delay mouse showing tooltip if not already shown\r\n return;\r\n }\r\n\r\n const source = (target as Element)?.closest?.('[data-tooltip]');\r\n if (source === SOURCE) return; // No need to update\r\n if (!TIP.isConnected) document.body.appendChild(TIP); // Ensure connected\r\n if (!TIP.hasAttribute('popover')) attr(TIP, 'popover', 'manual'); // Ensure popover behavior\r\n if (!source) return TIP?.hidePopover(); // If no new anchor, cleanup previous autoUpdate\r\n\r\n clearTimeout(SKIP_TIMER);\r\n TIP.textContent = attr(source, 'data-tooltip');\r\n TIP.showPopover();\r\n TIP.dispatchEvent(new CustomEvent('ds-toggle-source', { detail: source })); // Since showPopover({ source }) is not supported in all browsers yet\r\n SOURCE = source;\r\n}\r\n\r\nfunction handleClose(event?: Partial<ToggleEvent>) {\r\n if (!event) SOURCE = undefined;\r\n else if (event.target === TIP && event.newState === 'closed')\r\n SKIP_TIMER = setTimeout(handleClose, DELAY_SKIP);\r\n}\r\n\r\nonHotReload('tooltip', () => [\r\n on(document, 'blur focus mouseover', handleInterest, QUICK_EVENT),\r\n on(document, 'toggle', handleClose, QUICK_EVENT),\r\n onMutation(document, handleAriaAttributes, {\r\n attributeFilter: ['data-tooltip'],\r\n attributes: true,\r\n childList: true,\r\n subtree: true,\r\n }),\r\n]);\r\n"],"mappings":";;;AAUA,IAAI;AACJ,IAAI;AACJ,IAAI,cAAsD;AAC1D,IAAI,aAAqD;AACzD,MAAM,mBAAmB;AACzB,MAAM,uBAAuB;AAC7B,MAAM,cAAc;AACpB,MAAM,aAAa;AAInB,SAAS,uBAAuB;AAC9B,MAAK,MAAM,MAAM,SAAS,iBAAiB,iBAAiB,EAAE;EAC5D,MAAM,UAAU,GAAG,aAAa,MAAM;EACtC,MAAM,UAAU,KAAK,IAAI,eAAe;AAExC,OAAK,IAAI,UAAU,qBAAqB,cAAc,QAAQ;AAC9D,MAAI,CAAC,GAAG,QAAQ,qBAAqB,CACnC,qBAAoB,IAAI,iBAAe;;;AAI7C,SAAS,eAAe,EAAE,MAAM,UAAiB;AAC/C,cAAa,YAAY;AAEzB,KAAI,CAAC,IACH,OACE,SAAS,cAA2B,iBAAiB,IACrD,IAAI,OAAO,EAAE,OAAO,cAAc,CAAC;AAEvC,KAAI,CAAC,OAAO,WAAW,IAAK;AAC5B,KAAI,SAAS,eAAe,CAAC,QAAQ;AACnC,gBAAc,WAAW,gBAAgB,aAAa,EAAE,QAAQ,CAAC;AACjE;;CAGF,MAAM,SAAU,QAAoB,UAAU,iBAAiB;AAC/D,KAAI,WAAW,OAAQ;AACvB,KAAI,CAAC,IAAI,YAAa,UAAS,KAAK,YAAY,IAAI;AACpD,KAAI,CAAC,IAAI,aAAa,UAAU,CAAE,MAAK,KAAK,WAAW,SAAS;AAChE,KAAI,CAAC,OAAQ,QAAO,KAAK,aAAa;AAEtC,cAAa,WAAW;AACxB,KAAI,cAAc,KAAK,QAAQ,eAAe;AAC9C,KAAI,aAAa;AACjB,KAAI,cAAc,IAAI,YAAY,oBAAoB,EAAE,QAAQ,QAAQ,CAAC,CAAC;AAC1E,UAAS;;AAGX,SAAS,YAAY,OAA8B;AACjD,KAAI,CAAC,MAAO,UAAS;UACZ,MAAM,WAAW,OAAO,MAAM,aAAa,SAClD,cAAa,WAAW,aAAa,WAAW;;AAGpD,YAAY,iBAAiB;CAC3B,GAAG,UAAU,wBAAwB,gBAAgB,YAAY;CACjE,GAAG,UAAU,UAAU,aAAa,YAAY;CAChD,WAAW,UAAU,sBAAsB;EACzC,iBAAiB,CAAC,eAAe;EACjC,YAAY;EACZ,WAAW;EACX,SAAS;EACV,CAAC;CACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"fileNames":["../../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es5.d.ts","../../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2015.d.ts","../../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2016.d.ts","../../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2017.d.ts","../../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2018.d.ts","../../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2019.d.ts","../../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2020.d.ts","../../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2021.d.ts","../../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2022.d.ts","../../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.dom.d.ts","../../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.dom.iterable.d.ts","../../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2015.core.d.ts","../../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2015.collection.d.ts","../../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2015.generator.d.ts","../../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2015.iterable.d.ts","../../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2015.promise.d.ts","../../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2015.proxy.d.ts","../../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2015.reflect.d.ts","../../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2015.symbol.d.ts","../../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2016.array.include.d.ts","../../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2016.intl.d.ts","../../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2017.arraybuffer.d.ts","../../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2017.date.d.ts","../../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2017.object.d.ts","../../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","../../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2017.string.d.ts","../../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2017.intl.d.ts","../../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","../../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts","../../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2018.asynciterable.d.ts","../../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2018.intl.d.ts","../../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2018.promise.d.ts","../../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2018.regexp.d.ts","../../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2019.array.d.ts","../../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2019.object.d.ts","../../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2019.string.d.ts","../../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2019.symbol.d.ts","../../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2019.intl.d.ts","../../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2020.bigint.d.ts","../../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2020.date.d.ts","../../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2020.promise.d.ts","../../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts","../../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2020.string.d.ts","../../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts","../../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2020.intl.d.ts","../../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2020.number.d.ts","../../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2021.promise.d.ts","../../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2021.string.d.ts","../../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2021.weakref.d.ts","../../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2021.intl.d.ts","../../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2022.array.d.ts","../../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2022.error.d.ts","../../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2022.intl.d.ts","../../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2022.object.d.ts","../../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2022.string.d.ts","../../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2022.regexp.d.ts","../../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.decorators.d.ts","../../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.decorators.legacy.d.ts","../../../../node_modules/.pnpm/tslib@2.8.1/node_modules/tslib/tslib.d.ts","../../../../node_modules/.pnpm/tslib@2.8.1/node_modules/tslib/modules/index.d.ts","../../src/utils.ts","../../src/breadcrumbs.ts","../../src/clickdelegatefor.ts","../../src/details.ts","../../src/dialog.ts","../../src/error-summary.ts","../../src/field.ts","../../../../node_modules/.pnpm/@types+react@19.2.8/node_modules/@types/react/global.d.ts","../../../../node_modules/.pnpm/csstype@3.2.3/node_modules/csstype/index.d.ts","../../../../node_modules/.pnpm/@types+react@19.2.8/node_modules/@types/react/index.d.ts","../../../../node_modules/.pnpm/@u-elements+u-datalist@1.0.14/node_modules/@u-elements/u-datalist/dist/u-datalist.d.ts","../../src/pagination.ts","../../../../node_modules/.pnpm/@u-elements+u-combobox@1.0.5/node_modules/@u-elements/u-combobox/dist/u-combobox.d.ts","../../src/suggestion.ts","../../../../node_modules/.pnpm/@u-elements+u-tabs@0.1.2/node_modules/@u-elements/u-tabs/dist/u-tabs.d.ts","../../src/tabs.ts","../../../../node_modules/.pnpm/@floating-ui+utils@0.2.10/node_modules/@floating-ui/utils/dist/floating-ui.utils.d.mts","../../../../node_modules/.pnpm/@floating-ui+core@1.7.3/node_modules/@floating-ui/core/dist/floating-ui.core.d.mts","../../../../node_modules/.pnpm/@floating-ui+utils@0.2.10/node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.d.mts","../../../../node_modules/.pnpm/@floating-ui+dom@1.7.4/node_modules/@floating-ui/dom/dist/floating-ui.dom.d.mts","../../src/popover.ts","../../src/toggle-group.ts","../../src/tooltip.ts","../../../../node_modules/.pnpm/invokers-polyfill@0.6.1/node_modules/invokers-polyfill/invoker.d.ts","../../src/index.ts"],"fileIdsList":[[78],[79,80],[69,70],[71],[60],[61,62],[61,62,63,64,65,66,67,68,72,73,75,77,82,83,84,85],[61,62,81],[61,62,74],[61,62,76],[61]],"fileInfos":[{"version":"c430d44666289dae81f30fa7b2edebf186ecc91a2d4c71266ea6ae76388792e1","affectsGlobalScope":true,"impliedFormat":1},{"version":"45b7ab580deca34ae9729e97c13cfd999df04416a79116c3bfb483804f85ded4","impliedFormat":1},{"version":"3facaf05f0c5fc569c5649dd359892c98a85557e3e0c847964caeb67076f4d75","impliedFormat":1},{"version":"e44bb8bbac7f10ecc786703fe0a6a4b952189f908707980ba8f3c8975a760962","impliedFormat":1},{"version":"5e1c4c362065a6b95ff952c0eab010f04dcd2c3494e813b493ecfd4fcb9fc0d8","impliedFormat":1},{"version":"68d73b4a11549f9c0b7d352d10e91e5dca8faa3322bfb77b661839c42b1ddec7","impliedFormat":1},{"version":"5efce4fc3c29ea84e8928f97adec086e3dc876365e0982cc8479a07954a3efd4","impliedFormat":1},{"version":"feecb1be483ed332fad555aff858affd90a48ab19ba7272ee084704eb7167569","impliedFormat":1},{"version":"ee7bad0c15b58988daa84371e0b89d313b762ab83cb5b31b8a2d1162e8eb41c2","impliedFormat":1},{"version":"080941d9f9ff9307f7e27a83bcd888b7c8270716c39af943532438932ec1d0b9","affectsGlobalScope":true,"impliedFormat":1},{"version":"2e80ee7a49e8ac312cc11b77f1475804bee36b3b2bc896bead8b6e1266befb43","affectsGlobalScope":true,"impliedFormat":1},{"version":"c57796738e7f83dbc4b8e65132f11a377649c00dd3eee333f672b8f0a6bea671","affectsGlobalScope":true,"impliedFormat":1},{"version":"dc2df20b1bcdc8c2d34af4926e2c3ab15ffe1160a63e58b7e09833f616efff44","affectsGlobalScope":true,"impliedFormat":1},{"version":"515d0b7b9bea2e31ea4ec968e9edd2c39d3eebf4a2d5cbd04e88639819ae3b71","affectsGlobalScope":true,"impliedFormat":1},{"version":"0559b1f683ac7505ae451f9a96ce4c3c92bdc71411651ca6ddb0e88baaaad6a3","affectsGlobalScope":true,"impliedFormat":1},{"version":"0dc1e7ceda9b8b9b455c3a2d67b0412feab00bd2f66656cd8850e8831b08b537","affectsGlobalScope":true,"impliedFormat":1},{"version":"ce691fb9e5c64efb9547083e4a34091bcbe5bdb41027e310ebba8f7d96a98671","affectsGlobalScope":true,"impliedFormat":1},{"version":"8d697a2a929a5fcb38b7a65594020fcef05ec1630804a33748829c5ff53640d0","affectsGlobalScope":true,"impliedFormat":1},{"version":"4ff2a353abf8a80ee399af572debb8faab2d33ad38c4b4474cff7f26e7653b8d","affectsGlobalScope":true,"impliedFormat":1},{"version":"fb0f136d372979348d59b3f5020b4cdb81b5504192b1cacff5d1fbba29378aa1","affectsGlobalScope":true,"impliedFormat":1},{"version":"d15bea3d62cbbdb9797079416b8ac375ae99162a7fba5de2c6c505446486ac0a","affectsGlobalScope":true,"impliedFormat":1},{"version":"68d18b664c9d32a7336a70235958b8997ebc1c3b8505f4f1ae2b7e7753b87618","affectsGlobalScope":true,"impliedFormat":1},{"version":"eb3d66c8327153d8fa7dd03f9c58d351107fe824c79e9b56b462935176cdf12a","affectsGlobalScope":true,"impliedFormat":1},{"version":"38f0219c9e23c915ef9790ab1d680440d95419ad264816fa15009a8851e79119","affectsGlobalScope":true,"impliedFormat":1},{"version":"69ab18c3b76cd9b1be3d188eaf8bba06112ebbe2f47f6c322b5105a6fbc45a2e","affectsGlobalScope":true,"impliedFormat":1},{"version":"a680117f487a4d2f30ea46f1b4b7f58bef1480456e18ba53ee85c2746eeca012","affectsGlobalScope":true,"impliedFormat":1},{"version":"2f11ff796926e0832f9ae148008138ad583bd181899ab7dd768a2666700b1893","affectsGlobalScope":true,"impliedFormat":1},{"version":"4de680d5bb41c17f7f68e0419412ca23c98d5749dcaaea1896172f06435891fc","affectsGlobalScope":true,"impliedFormat":1},{"version":"954296b30da6d508a104a3a0b5d96b76495c709785c1d11610908e63481ee667","affectsGlobalScope":true,"impliedFormat":1},{"version":"ac9538681b19688c8eae65811b329d3744af679e0bdfa5d842d0e32524c73e1c","affectsGlobalScope":true,"impliedFormat":1},{"version":"0a969edff4bd52585473d24995c5ef223f6652d6ef46193309b3921d65dd4376","affectsGlobalScope":true,"impliedFormat":1},{"version":"9e9fbd7030c440b33d021da145d3232984c8bb7916f277e8ffd3dc2e3eae2bdb","affectsGlobalScope":true,"impliedFormat":1},{"version":"811ec78f7fefcabbda4bfa93b3eb67d9ae166ef95f9bff989d964061cbf81a0c","affectsGlobalScope":true,"impliedFormat":1},{"version":"717937616a17072082152a2ef351cb51f98802fb4b2fdabd32399843875974ca","affectsGlobalScope":true,"impliedFormat":1},{"version":"d7e7d9b7b50e5f22c915b525acc5a49a7a6584cf8f62d0569e557c5cfc4b2ac2","affectsGlobalScope":true,"impliedFormat":1},{"version":"71c37f4c9543f31dfced6c7840e068c5a5aacb7b89111a4364b1d5276b852557","affectsGlobalScope":true,"impliedFormat":1},{"version":"576711e016cf4f1804676043e6a0a5414252560eb57de9faceee34d79798c850","affectsGlobalScope":true,"impliedFormat":1},{"version":"89c1b1281ba7b8a96efc676b11b264de7a8374c5ea1e6617f11880a13fc56dc6","affectsGlobalScope":true,"impliedFormat":1},{"version":"74f7fa2d027d5b33eb0471c8e82a6c87216223181ec31247c357a3e8e2fddc5b","affectsGlobalScope":true,"impliedFormat":1},{"version":"d6d7ae4d1f1f3772e2a3cde568ed08991a8ae34a080ff1151af28b7f798e22ca","affectsGlobalScope":true,"impliedFormat":1},{"version":"063600664504610fe3e99b717a1223f8b1900087fab0b4cad1496a114744f8df","affectsGlobalScope":true,"impliedFormat":1},{"version":"934019d7e3c81950f9a8426d093458b65d5aff2c7c1511233c0fd5b941e608ab","affectsGlobalScope":true,"impliedFormat":1},{"version":"52ada8e0b6e0482b728070b7639ee42e83a9b1c22d205992756fe020fd9f4a47","affectsGlobalScope":true,"impliedFormat":1},{"version":"3bdefe1bfd4d6dee0e26f928f93ccc128f1b64d5d501ff4a8cf3c6371200e5e6","affectsGlobalScope":true,"impliedFormat":1},{"version":"59fb2c069260b4ba00b5643b907ef5d5341b167e7d1dbf58dfd895658bda2867","affectsGlobalScope":true,"impliedFormat":1},{"version":"639e512c0dfc3fad96a84caad71b8834d66329a1f28dc95e3946c9b58176c73a","affectsGlobalScope":true,"impliedFormat":1},{"version":"368af93f74c9c932edd84c58883e736c9e3d53cec1fe24c0b0ff451f529ceab1","affectsGlobalScope":true,"impliedFormat":1},{"version":"af3dd424cf267428f30ccfc376f47a2c0114546b55c44d8c0f1d57d841e28d74","affectsGlobalScope":true,"impliedFormat":1},{"version":"995c005ab91a498455ea8dfb63aa9f83fa2ea793c3d8aa344be4a1678d06d399","affectsGlobalScope":true,"impliedFormat":1},{"version":"959d36cddf5e7d572a65045b876f2956c973a586da58e5d26cde519184fd9b8a","affectsGlobalScope":true,"impliedFormat":1},{"version":"965f36eae237dd74e6cca203a43e9ca801ce38824ead814728a2807b1910117d","affectsGlobalScope":true,"impliedFormat":1},{"version":"3925a6c820dcb1a06506c90b1577db1fdbf7705d65b62b99dce4be75c637e26b","affectsGlobalScope":true,"impliedFormat":1},{"version":"0a3d63ef2b853447ec4f749d3f368ce642264246e02911fcb1590d8c161b8005","affectsGlobalScope":true,"impliedFormat":1},{"version":"8cdf8847677ac7d20486e54dd3fcf09eda95812ac8ace44b4418da1bbbab6eb8","affectsGlobalScope":true,"impliedFormat":1},{"version":"8444af78980e3b20b49324f4a16ba35024fef3ee069a0eb67616ea6ca821c47a","affectsGlobalScope":true,"impliedFormat":1},{"version":"3287d9d085fbd618c3971944b65b4be57859f5415f495b33a6adc994edd2f004","affectsGlobalScope":true,"impliedFormat":1},{"version":"b4b67b1a91182421f5df999988c690f14d813b9850b40acd06ed44691f6727ad","affectsGlobalScope":true,"impliedFormat":1},{"version":"8e7f8264d0fb4c5339605a15daadb037bf238c10b654bb3eee14208f860a32ea","affectsGlobalScope":true,"impliedFormat":1},{"version":"782dec38049b92d4e85c1585fbea5474a219c6984a35b004963b00beb1aab538","affectsGlobalScope":true,"impliedFormat":1},{"version":"a6a5253138c5432c68a1510c70fe78a644fe2e632111ba778e1978010d6edfec","impliedFormat":1},{"version":"b8f34dd1757f68e03262b1ca3ddfa668a855b872f8bdd5224d6f993a7b37dc2c","impliedFormat":99},{"version":"a4245e17a477c335ec9b877176f6a428422cc54bea96ec9bcf89cee31fa36b5f","signature":"7ad24e205ecbbde2667cb8bf66ba4350b2d46158369449fd773b0ebed20a8c90","affectsGlobalScope":true},{"version":"e2d6b1fe755f6d2e72c96ffda7b37c7687209599de1a45aa5065ab1a1d2f2b4f","signature":"6955261a20ca609d3d777cedc63e0d234fb3ffbcc94e8595283eda1d2170234d","affectsGlobalScope":true},{"version":"00236392f996fb8d67d6e0c17c37cbb0b595b6ae607916013429f5d5376d307d","signature":"afee5b56478544e749176372d896c6cfe2bb74a0ad3365230dcbaab3f6a934fc"},{"version":"970278d1f0a488713e5b3c56fedd8648fcd1dc568727559de812fb3f2c9b5aa4","signature":"8e609bb71c20b858c77f0e9f90bb1319db8477b13f9f965f1a1e18524bf50881"},{"version":"e27b49f319d4c831e074f4be62419d88dfed8f449d51589e1d76d30103e3e430","signature":"8e609bb71c20b858c77f0e9f90bb1319db8477b13f9f965f1a1e18524bf50881"},{"version":"01020a2baf964cca323ba846abe284274a1419d14e458b8693f8a9110b3bdc27","signature":"10b5b4d8fac5855aa55cc4e9326adbf28abbda5df3dfa8e10fb7ca986e9918b6","affectsGlobalScope":true},{"version":"df27be11cc1114e23bb97220a6ad2569b5220dda85438250f27f07ef00bb021b","signature":"d561af4f124ef0a74fb164bfa123c82e8b7fe2d2e9eceab2a187e203091e457d","affectsGlobalScope":true},{"version":"170d4db14678c68178ee8a3d5a990d5afb759ecb6ec44dbd885c50f6da6204f6","affectsGlobalScope":true,"impliedFormat":1},{"version":"ac51dd7d31333793807a6abaa5ae168512b6131bd41d9c5b98477fc3b7800f9f","impliedFormat":1},{"version":"cf8db38686dfd74567ea692266fe44fbb32fa0e25fc0888ad6fc40e65873607e","impliedFormat":1},{"version":"3b70a6d2ea018ba90c7b25b357e6678ccb846fb93d1474eefec8618df86fd397","affectsGlobalScope":true,"impliedFormat":99},{"version":"aa3be9b373b22a603e67edaaa9e6332031e7068aac97ed1645e9d9df82d92176","signature":"c653c6ec2af00b4709cdbf05033989f0392eaebc3190c74be9370bd6e6f3e678","affectsGlobalScope":true},{"version":"5918bc2ff1c59c4c7c5f5a561a693a1397efd32b34536a843cdb01a685b1607f","affectsGlobalScope":true,"impliedFormat":99},{"version":"06f4ee73ce3dc4cd5048adaa9361c7ce53865b9cf00283fca6980dd4772e3c3b","signature":"a12ea9ac1b3d00c46d75df7cb8dfd46c37f8022cf8411cf6bc2aa837e7e76544","affectsGlobalScope":true},{"version":"4a6c1ac460b6f59557388099223757e5fd5066c746ae26fc4740d14ba6199336","affectsGlobalScope":true,"impliedFormat":99},{"version":"d2ae4be85f20bb37a33a95baf8df5d4a94b5118bc027566e34e5d04392034af4","signature":"c46f3c2c8ff3af40184e50303724c2f3e6d19e93f526a0ed03e7a18b15b01987","affectsGlobalScope":true},{"version":"2b4276dde46aa2faf0dd86119999c76b81e6488cd6b0d0fcf9fb985769cd11c0","impliedFormat":99},{"version":"88247402edb737af32da5c7f69ff80e66e831262065b7f0feb32ea8293260d22","impliedFormat":99},{"version":"5ecea63968444d55f7c3cf677cbec9525db9229953b34f06be0386a24b0fffd2","impliedFormat":99},{"version":"b50ee4bde16b52ecb08e2407dca49a5649b38e046e353485335aa024f6efb8ef","impliedFormat":99},{"version":"aa7e12fae278d26747915affc458404f66b000c9735dc462db1912618f94b5c8","signature":"8e609bb71c20b858c77f0e9f90bb1319db8477b13f9f965f1a1e18524bf50881"},{"version":"d2e69721ebdefc0a82e2608358cf72edf5b00d9decf7cd79cbd70bb171415fc0","signature":"8e609bb71c20b858c77f0e9f90bb1319db8477b13f9f965f1a1e18524bf50881"},{"version":"ce10e82ffe6b76d71aa9a3a964b0af042ab41f0c24345b795a62d21e1a3bc5ad","signature":"8e609bb71c20b858c77f0e9f90bb1319db8477b13f9f965f1a1e18524bf50881"},{"version":"3a746284f48a9eec87435891f3248afd1ad9baea2532d7c9ef1ded9c63a89692","affectsGlobalScope":true,"impliedFormat":99},{"version":"b05850086025ae89d2ab8d90e835962869865943f0da02aa5fbbc1ff4bed34bc","signature":"2cb18eae5cdd018f201d0d0de5beb6655cfbdd6414b44f8978c2c44d5efda517"}],"root":[[62,68],73,75,77,[82,84],86],"options":{"allowJs":true,"composite":true,"declaration":true,"declarationMap":true,"emitDeclarationOnly":true,"esModuleInterop":true,"importHelpers":true,"jsx":4,"module":99,"outDir":"./","skipLibCheck":true,"sourceMap":true,"strict":true,"target":9},"referencedMap":[[79,1],[81,2],[71,3],[74,4],[72,4],[76,4],[61,5],[63,6],[64,6],[65,6],[66,6],[67,6],[68,6],[86,7],[73,6],[82,8],[75,9],[77,10],[83,6],[84,6],[62,11]],"latestChangedDtsFile":"./src/index.d.ts","version":"5.9.3"}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
//#region src/utils.ts
|
|
2
|
+
const QUICK_EVENT = {
|
|
3
|
+
passive: true,
|
|
4
|
+
capture: true
|
|
5
|
+
};
|
|
6
|
+
const isBrowser = () => typeof window !== "undefined" && typeof document !== "undefined";
|
|
7
|
+
const isWindows = () => isBrowser() && /^Win/i.test(navigator.userAgentData?.platform || navigator.platform);
|
|
8
|
+
const DSElement = typeof HTMLElement === "undefined" ? class {} : HTMLElement;
|
|
9
|
+
function debounce(callback, delay) {
|
|
10
|
+
let timer;
|
|
11
|
+
return function(...args) {
|
|
12
|
+
clearTimeout(timer);
|
|
13
|
+
timer = setTimeout(() => callback.apply(this, args), delay);
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* attr
|
|
18
|
+
* @description Utility to quickly get, set and remove attributes
|
|
19
|
+
* @param el The Element to read/write attributes from
|
|
20
|
+
* @param name The attribute name to get, set or remove, or a object to set multiple attributes
|
|
21
|
+
* @param value A valid attribute value or null to remove attribute
|
|
22
|
+
*/
|
|
23
|
+
const attr = (el, name, value) => {
|
|
24
|
+
if (value === void 0) return el.getAttribute(name) ?? null;
|
|
25
|
+
if (value === null) el.removeAttribute(name);
|
|
26
|
+
else if (el.getAttribute(name) !== value) el.setAttribute(name, value);
|
|
27
|
+
return null;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* attrRequiredWarning
|
|
31
|
+
* @description Warn if element is missing attribute
|
|
32
|
+
* @param el The Element to read/write attributes from
|
|
33
|
+
* @param ...names The attribute name(s) check
|
|
34
|
+
*/
|
|
35
|
+
const attrRequiredWarning = (el, name) => el.hasAttribute(name) || console.warn(`Designsystemet: Missing a ${name} attribute`, el);
|
|
36
|
+
/**
|
|
37
|
+
* on
|
|
38
|
+
* @param el The Element to use as EventTarget
|
|
39
|
+
* @param types A space separated string of event types
|
|
40
|
+
* @param listener An event listener function or listener object
|
|
41
|
+
*/
|
|
42
|
+
const on = (el, ...rest) => {
|
|
43
|
+
const [types, ...options] = rest;
|
|
44
|
+
for (const type of types.split(" ")) el.addEventListener(type, ...options);
|
|
45
|
+
return () => off(el, ...rest);
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* off
|
|
49
|
+
* @param el The Element to use as EventTarget
|
|
50
|
+
* @param types A space separated string of event types
|
|
51
|
+
* @param listener An event listener function or listener object
|
|
52
|
+
*/
|
|
53
|
+
const off = (el, ...rest) => {
|
|
54
|
+
const [types, ...options] = rest;
|
|
55
|
+
for (const type of types.split(" ")) el.removeEventListener(type, ...options);
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* onHotReload
|
|
59
|
+
* @description Runs a callback when window is loaded in browser, and ensures cleanup when hot-reloading
|
|
60
|
+
* @param key The key to identify setup and corresponding cleanup
|
|
61
|
+
* @param callback The callback to run when the page is ready
|
|
62
|
+
*/
|
|
63
|
+
const onHotReload = (key, setup) => {
|
|
64
|
+
if (!isBrowser()) return;
|
|
65
|
+
if (!window._dsHotReloadCleanup) window._dsHotReloadCleanup = /* @__PURE__ */ new Map();
|
|
66
|
+
const run = () => {
|
|
67
|
+
window._dsHotReloadCleanup?.get(key)?.map((cleanup) => cleanup());
|
|
68
|
+
window._dsHotReloadCleanup?.set(key, setup());
|
|
69
|
+
};
|
|
70
|
+
if (document.readyState !== "complete") on(window, "load", run);
|
|
71
|
+
else document.fonts?.ready?.then(run) || setTimeout(run, 0);
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* Speed up MutationObserver by debouncing and only running when page is visible
|
|
75
|
+
* @return new MutaionObserver
|
|
76
|
+
*/
|
|
77
|
+
const onMutation = (el, callback, options) => {
|
|
78
|
+
let queue = 0;
|
|
79
|
+
const { debounce: ms = 200, ...opts } = options;
|
|
80
|
+
const onTimer = () => {
|
|
81
|
+
if (!isBrowser()) return cleanup();
|
|
82
|
+
callback(observer);
|
|
83
|
+
observer.takeRecords();
|
|
84
|
+
queue = 0;
|
|
85
|
+
};
|
|
86
|
+
const onFrame = ms ? debounce(onTimer, ms) : onTimer;
|
|
87
|
+
const cleanup = () => observer?.disconnect?.();
|
|
88
|
+
const observer = new MutationObserver(() => {
|
|
89
|
+
if (!queue) queue = requestAnimationFrame(onFrame);
|
|
90
|
+
});
|
|
91
|
+
observer.observe(el, opts);
|
|
92
|
+
onFrame();
|
|
93
|
+
return cleanup;
|
|
94
|
+
};
|
|
95
|
+
if (isBrowser()) {
|
|
96
|
+
let isSupported = false;
|
|
97
|
+
const dialog = document.createElement("dialog");
|
|
98
|
+
dialog.addEventListener("beforetoggle", (e) => {
|
|
99
|
+
isSupported = "source" in e;
|
|
100
|
+
});
|
|
101
|
+
dialog.show();
|
|
102
|
+
if (!isSupported) Object.defineProperty(ToggleEvent.prototype, "source", {
|
|
103
|
+
configurable: true,
|
|
104
|
+
enumerable: true,
|
|
105
|
+
get() {
|
|
106
|
+
const id = this.target.id;
|
|
107
|
+
const root = this.target.getRootNode();
|
|
108
|
+
const css = `[popovertarget="${id}"],[commandfor="${id}"]`;
|
|
109
|
+
return id ? root?.querySelector?.(css) : null;
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* tag
|
|
115
|
+
* @description creates element and assigns properties
|
|
116
|
+
* @param tagName The tagname of element to create
|
|
117
|
+
* @param attrs Optional attributes to add to the element
|
|
118
|
+
* @param text Optional text content to add to the element
|
|
119
|
+
* @return HTMLElement with props
|
|
120
|
+
*/
|
|
121
|
+
const tag = (tagName, attrs) => {
|
|
122
|
+
const el = document.createElement(tagName);
|
|
123
|
+
if (attrs) for (const [key, val] of Object.entries(attrs)) attr(el, key, val);
|
|
124
|
+
return el;
|
|
125
|
+
};
|
|
126
|
+
/**
|
|
127
|
+
* customElements.define
|
|
128
|
+
* @description Defines a customElement if running in browser and if not already registered
|
|
129
|
+
* Scoped/named "customElements.define" so @custom-elements-manifest/analyzer can find tag names
|
|
130
|
+
*/
|
|
131
|
+
const customElements = { define: (name, instance) => !isBrowser() || window.customElements.get(name) || window.customElements.define(name, instance) };
|
|
132
|
+
/**
|
|
133
|
+
* useId
|
|
134
|
+
* @return A generated unique ID
|
|
135
|
+
*/
|
|
136
|
+
let id = 0;
|
|
137
|
+
const hash = `${Date.now().toString(36)}${Math.random().toString(36).slice(2, 5)}`;
|
|
138
|
+
function useId(el) {
|
|
139
|
+
if (el && !el.id) el.id = `${hash}${++id}`;
|
|
140
|
+
return el?.id || "";
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
//#endregion
|
|
144
|
+
export { DSElement, QUICK_EVENT, attr, attrRequiredWarning, customElements, debounce, isBrowser, isWindows, off, on, onHotReload, onMutation, tag, useId };
|
|
145
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","names":[],"sources":["../../src/utils.ts"],"sourcesContent":["export const QUICK_EVENT = { passive: true, capture: true };\r\n\r\n// Using function instead of constant to support evnironments where DOM can be unloaded (like Vitest with jsdom)\r\nexport const isBrowser = () =>\r\n typeof window !== 'undefined' && typeof document !== 'undefined';\r\n\r\nexport const isWindows = () =>\r\n isBrowser() &&\r\n // @ts-expect-error Typescript has not implemented userAgentData yet https://stackoverflow.com/a/71392474\r\n /^Win/i.test(navigator.userAgentData?.platform || navigator.platform);\r\n\r\n// Make sure we have a HTMLElement to extend (for server side rendering)\r\nexport const DSElement =\r\n typeof HTMLElement === 'undefined'\r\n ? (class {} as typeof HTMLElement)\r\n : HTMLElement;\r\n\r\nexport function debounce<T extends unknown[]>(\r\n callback: (...args: T) => void,\r\n delay: number,\r\n) {\r\n let timer: ReturnType<typeof setTimeout>;\r\n\r\n return function (this: unknown, ...args: T) {\r\n clearTimeout(timer);\r\n timer = setTimeout(() => callback.apply(this, args), delay);\r\n };\r\n}\r\n\r\n/**\r\n * attr\r\n * @description Utility to quickly get, set and remove attributes\r\n * @param el The Element to read/write attributes from\r\n * @param name The attribute name to get, set or remove, or a object to set multiple attributes\r\n * @param value A valid attribute value or null to remove attribute\r\n */\r\nexport const attr = (\r\n el: Element,\r\n name: string,\r\n value?: string | null,\r\n): string | null => {\r\n if (value === undefined) return el.getAttribute(name) ?? null; // Fallback to null only if el is undefined\r\n if (value === null) el.removeAttribute(name);\r\n else if (el.getAttribute(name) !== value) el.setAttribute(name, value);\r\n return null;\r\n};\r\n\r\n/**\r\n * attrRequiredWarning\r\n * @description Warn if element is missing attribute\r\n * @param el The Element to read/write attributes from\r\n * @param ...names The attribute name(s) check\r\n */\r\nexport const attrRequiredWarning = (el: Element, name: string) =>\r\n el.hasAttribute(name) ||\r\n console.warn(`Designsystemet: Missing a ${name} attribute`, el);\r\n\r\n/**\r\n * on\r\n * @param el The Element to use as EventTarget\r\n * @param types A space separated string of event types\r\n * @param listener An event listener function or listener object\r\n */\r\nexport const on = (\r\n el: Node | Window | ShadowRoot,\r\n ...rest: Parameters<typeof Element.prototype.addEventListener>\r\n): (() => void) => {\r\n const [types, ...options] = rest;\r\n for (const type of types.split(' ')) el.addEventListener(type, ...options);\r\n return () => off(el, ...rest);\r\n};\r\n\r\n/**\r\n * off\r\n * @param el The Element to use as EventTarget\r\n * @param types A space separated string of event types\r\n * @param listener An event listener function or listener object\r\n */\r\nexport const off = (\r\n el: Node | Window | ShadowRoot,\r\n ...rest: Parameters<typeof Element.prototype.removeEventListener>\r\n): void => {\r\n const [types, ...options] = rest;\r\n for (const type of types.split(' ')) el.removeEventListener(type, ...options);\r\n};\r\n\r\n// Used to store cleanup functions for hot-reloading\r\ndeclare global {\r\n interface Window {\r\n _dsHotReloadCleanup?: Map<string, Array<() => void>>;\r\n }\r\n}\r\n\r\n/**\r\n * onHotReload\r\n * @description Runs a callback when window is loaded in browser, and ensures cleanup when hot-reloading\r\n * @param key The key to identify setup and corresponding cleanup\r\n * @param callback The callback to run when the page is ready\r\n */\r\nexport const onHotReload = (key: string, setup: () => Array<() => void>) => {\r\n if (!isBrowser()) return; // Skip if not in modern browser environment, but on each call as Vitest might have unloaded jsdom between tests\r\n if (!window._dsHotReloadCleanup) window._dsHotReloadCleanup = new Map(); // Hot reload cleanup support supporting all build tools\r\n\r\n const run = () => {\r\n window._dsHotReloadCleanup?.get(key)?.map((cleanup) => cleanup()); // Run previous cleanup\r\n window._dsHotReloadCleanup?.set(key, setup()); // Store new cleanup\r\n };\r\n\r\n if (document.readyState !== 'complete') on(window, 'load', run);\r\n else document.fonts?.ready?.then(run) || setTimeout(run, 0); // Prefer fonts ready promise if available, but fallback to setTimeout\r\n};\r\n\r\n/**\r\n * Speed up MutationObserver by debouncing and only running when page is visible\r\n * @return new MutaionObserver\r\n */\r\nexport const onMutation = (\r\n el: Node,\r\n callback: (observer: MutationObserver) => void,\r\n options: MutationObserverInit & { debounce?: number | false },\r\n) => {\r\n let queue = 0;\r\n const { debounce: ms = 200, ...opts } = options;\r\n const onTimer = () => {\r\n if (!isBrowser()) return cleanup(); // If using JSDOM, the document might have been removed\r\n callback(observer);\r\n observer.takeRecords(); // Clear records to avoid running callback multiple times\r\n queue = 0;\r\n };\r\n const onFrame = ms ? debounce(onTimer, ms) : onTimer; // Use both requestAnimationFrame and setTimeout to debounce and only run when visible\r\n const cleanup = () => observer?.disconnect?.();\r\n const observer = new MutationObserver(() => {\r\n if (!queue) queue = requestAnimationFrame(onFrame); // requestAnimationFrame only runs when page is not visible\r\n });\r\n\r\n observer.observe(el, opts);\r\n onFrame(); // Initial run\r\n return cleanup;\r\n};\r\n\r\n// Polyfill for ToggleEvent.source for browsers that do not support it yet\r\nif (isBrowser()) {\r\n let isSupported = false;\r\n const dialog = document.createElement('dialog');\r\n dialog.addEventListener('beforetoggle', (e) => {\r\n isSupported = 'source' in e;\r\n });\r\n dialog.show();\r\n\r\n if (!isSupported) {\r\n Object.defineProperty(ToggleEvent.prototype, 'source', {\r\n configurable: true,\r\n enumerable: true,\r\n get() {\r\n const id = this.target.id;\r\n const root = this.target.getRootNode(); // Support shadow DOM\r\n const css = `[popovertarget=\"${id}\"],[commandfor=\"${id}\"]`;\r\n return id ? root?.querySelector?.(css) : null;\r\n },\r\n });\r\n }\r\n}\r\n\r\n/**\r\n * tag\r\n * @description creates element and assigns properties\r\n * @param tagName The tagname of element to create\r\n * @param attrs Optional attributes to add to the element\r\n * @param text Optional text content to add to the element\r\n * @return HTMLElement with props\r\n */\r\nexport const tag = <TagName extends keyof HTMLElementTagNameMap>(\r\n tagName: TagName,\r\n attrs?: Record<string, string | null> | null,\r\n): HTMLElementTagNameMap[TagName] => {\r\n const el = document.createElement(tagName);\r\n if (attrs) for (const [key, val] of Object.entries(attrs)) attr(el, key, val);\r\n return el;\r\n};\r\n\r\n/**\r\n * customElements.define\r\n * @description Defines a customElement if running in browser and if not already registered\r\n * Scoped/named \"customElements.define\" so @custom-elements-manifest/analyzer can find tag names\r\n */\r\nexport const customElements = {\r\n define: (name: string, instance: CustomElementConstructor) =>\r\n !isBrowser() ||\r\n window.customElements.get(name) ||\r\n window.customElements.define(name, instance),\r\n};\r\n\r\n/**\r\n * useId\r\n * @return A generated unique ID\r\n */\r\nlet id = 0;\r\nconst hash = `${Date.now().toString(36)}${Math.random().toString(36).slice(2, 5)}`;\r\nexport function useId(el?: Element | null) {\r\n if (el && !el.id) el.id = `${hash}${++id}`;\r\n return el?.id || '';\r\n}\r\n"],"mappings":"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"}
|
package/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@digdir/designsystemet-web",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "0.0.1",
|
|
5
|
+
"description": "Javascript for Designsystemet",
|
|
6
|
+
"author": "Designsystemet team",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/digdir/designsystemet.git"
|
|
10
|
+
},
|
|
11
|
+
"homepage": "https://github.com/digdir/designsystemet/tree/main/packages/web",
|
|
12
|
+
"license": "MIT",
|
|
13
|
+
"main": "./dist/cjs/index.cjs",
|
|
14
|
+
"module": "./dist/esm/index.js",
|
|
15
|
+
"types": "./dist/esm/index.d.ts",
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"types": "./dist/esm/src/index.d.ts",
|
|
19
|
+
"import": "./dist/esm/index.js",
|
|
20
|
+
"require": "./dist/cjs/index.cjs"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"files": [
|
|
24
|
+
"dist/**"
|
|
25
|
+
],
|
|
26
|
+
"scripts": {
|
|
27
|
+
"start": "vite --config=./vite.config.ts --port=5174",
|
|
28
|
+
"build": "rimraf dist && tsc && rolldown -c"
|
|
29
|
+
},
|
|
30
|
+
"publishConfig": {
|
|
31
|
+
"access": "public"
|
|
32
|
+
},
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"@floating-ui/dom": "^1.7.4",
|
|
35
|
+
"@u-elements/u-combobox": "^1.0.5",
|
|
36
|
+
"@u-elements/u-datalist": "^1.0.14",
|
|
37
|
+
"@u-elements/u-progress": "^0.0.6",
|
|
38
|
+
"@u-elements/u-tabs": "^0.1.2",
|
|
39
|
+
"invokers-polyfill": "^0.6.1"
|
|
40
|
+
},
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"concurrently": "^9.2.1",
|
|
43
|
+
"rimraf": "^6.1.2",
|
|
44
|
+
"rolldown": "1.0.0-beta.60",
|
|
45
|
+
"rollup": "^4.54.0"
|
|
46
|
+
}
|
|
47
|
+
}
|