@mattilsynet/design 0.0.9 → 0.0.11

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/utils.js CHANGED
@@ -1,20 +1,26 @@
1
- const u = typeof window < "u" && typeof document < "u";
2
- let r = 0;
3
- const s = `${Date.now().toString(36)}${Math.random().toString(36).slice(2, 5)}`;
4
- function d(e) {
5
- return e.id || (e.id = `${s}${++r}`), e.id;
1
+ const d = typeof window < "u" && typeof document < "u";
2
+ let s = 0;
3
+ const c = `${Date.now().toString(36)}${Math.random().toString(36).slice(2, 5)}`;
4
+ function u(t) {
5
+ return t.id || (t.id = `${c}${++s}`), t.id;
6
6
  }
7
- function c(e) {
8
- const t = [], n = new MutationObserver((i) => {
9
- t[0] || requestAnimationFrame(o), t.push(...i);
7
+ function f(t) {
8
+ const e = [], n = new MutationObserver((r) => {
9
+ e[0] || requestAnimationFrame(o), e.push(...r);
10
10
  }), o = () => {
11
- e(t, n), t.length = 0;
11
+ t(e, n), e.length = 0;
12
12
  };
13
13
  return n;
14
14
  }
15
+ const i = (t, e, n) => {
16
+ for (const o of n[0].split(","))
17
+ n[0] = o, Element.prototype[`${t}EventListener`].apply(e, n);
18
+ }, p = (t, ...e) => i("add", t, e), a = (t, ...e) => i("remove", t, e);
15
19
  export {
16
- u as IS_BROWSER,
17
- c as createOptimizedMutationObserver,
18
- d as useId
20
+ d as IS_BROWSER,
21
+ f as createOptimizedMutationObserver,
22
+ a as off,
23
+ p as on,
24
+ u as useId
19
25
  };
20
26
  //# sourceMappingURL=utils.js.map
package/mtds/utils.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sources":["../designsystem/utils.ts"],"sourcesContent":["export const IS_BROWSER = typeof window !== 'undefined' && typeof document !== 'undefined';\n\n// Generate unique ID for element\nlet id = 0;\nconst UUID = `${Date.now().toString(36)}${Math.random().toString(36).slice(2, 5)}`;\nexport function useId (el: Element) {\n if (!el.id) el.id = `${UUID}${++id}`;\n\treturn el.id;\n};\n\n// Speed up MutationObserver by debouncing and only running when page is visible\nexport function createOptimizedMutationObserver(callback: MutationCallback) {\n const queue: MutationRecord[] = [];\n const observer = new MutationObserver((mutations) => {\n if (!queue[0]) requestAnimationFrame(process);\n queue.push(...mutations);\n });\n\n const process = () => {\n callback(queue, observer);\n queue.length = 0; // Reset queue\n };\n\n return observer;\n}\n\n"],"names":["IS_BROWSER","id","UUID","useId","el","createOptimizedMutationObserver","callback","queue","observer","mutations","process"],"mappings":"AAAO,MAAMA,IAAa,OAAO,SAAW,OAAe,OAAO,WAAa;AAG/E,IAAIC,IAAK;AACT,MAAMC,IAAO,GAAG,KAAK,IAAM,EAAA,SAAS,EAAE,CAAC,GAAG,KAAK,SAAS,SAAS,EAAE,EAAE,MAAM,GAAG,CAAC,CAAC;AACzE,SAASC,EAAOC,GAAa;AAC9B,SAACA,EAAG,OAAIA,EAAG,KAAK,GAAGF,CAAI,GAAG,EAAED,CAAE,KAC5BG,EAAG;AACX;AAGO,SAASC,EAAgCC,GAA4B;AAC1E,QAAMC,IAA0B,CAAC,GAC3BC,IAAW,IAAI,iBAAiB,CAACC,MAAc;AACnD,IAAKF,EAAM,CAAC,2BAAyBG,CAAO,GACtCH,EAAA,KAAK,GAAGE,CAAS;AAAA,EAAA,CACxB,GAEKC,IAAU,MAAM;AACpB,IAAAJ,EAASC,GAAOC,CAAQ,GACxBD,EAAM,SAAS;AAAA,EACjB;AAEO,SAAAC;AACT;"}
1
+ {"version":3,"file":"utils.js","sources":["../designsystem/utils.ts"],"sourcesContent":["export const IS_BROWSER = typeof window !== 'undefined' && typeof document !== 'undefined';\n\n/**\n * useId\n * @return A generated unique ID\n */\nlet id = 0;\nconst UUID = `${Date.now().toString(36)}${Math.random().toString(36).slice(2, 5)}`;\nexport function useId (el: Element) {\n if (!el.id) el.id = `${UUID}${++id}`;\n\treturn el.id;\n};\n\n/**\n * Speed up MutationObserver by debouncing and only running when page is visible\n * @return new MutaionObserver\n */\nexport function createOptimizedMutationObserver(callback: MutationCallback) {\n const queue: MutationRecord[] = [];\n const observer = new MutationObserver((mutations) => {\n if (!queue[0]) requestAnimationFrame(process);\n queue.push(...mutations);\n });\n\n const process = () => {\n callback(queue, observer);\n queue.length = 0; // Reset queue\n };\n\n return observer;\n}\n\n// Internal helper for on / off\nconst events = (\n\taction: \"add\" | \"remove\",\n\telement: Node | Window,\n\trest: Parameters<typeof Element.prototype.addEventListener>,\n): void => {\n\tfor (const type of rest[0].split(\",\")) {\n\t\trest[0] = type;\n\t\tElement.prototype[`${action}EventListener`].apply(element, rest);\n\t}\n};\n\n/**\n * on\n * @param element The Element to use as EventTarget\n * @param types A comma separated string of event types\n * @param listener An event listener function or listener object\n */\nexport const on = (\n\telement: Node | Window,\n\t...rest: Parameters<typeof Element.prototype.addEventListener>\n): void => events(\"add\", element, rest);\n\n/**\n * off\n * @param element The Element to use as EventTarget\n * @param types A comma separated string of event types\n * @param listener An event listener function or listener object\n */\nexport const off = (\n\telement: Node | Window,\n\t...rest: Parameters<typeof Element.prototype.removeEventListener>\n): void => events(\"remove\", element, rest);\n\n"],"names":["IS_BROWSER","id","UUID","useId","el","createOptimizedMutationObserver","callback","queue","observer","mutations","process","events","action","element","rest","type","on","off"],"mappings":"AAAO,MAAMA,IAAa,OAAO,SAAW,OAAe,OAAO,WAAa;AAM/E,IAAIC,IAAK;AACT,MAAMC,IAAO,GAAG,KAAK,IAAM,EAAA,SAAS,EAAE,CAAC,GAAG,KAAK,SAAS,SAAS,EAAE,EAAE,MAAM,GAAG,CAAC,CAAC;AACzE,SAASC,EAAOC,GAAa;AAC9B,SAACA,EAAG,OAAIA,EAAG,KAAK,GAAGF,CAAI,GAAG,EAAED,CAAE,KAC5BG,EAAG;AACX;AAMO,SAASC,EAAgCC,GAA4B;AAC1E,QAAMC,IAA0B,CAAC,GAC3BC,IAAW,IAAI,iBAAiB,CAACC,MAAc;AACnD,IAAKF,EAAM,CAAC,2BAAyBG,CAAO,GACtCH,EAAA,KAAK,GAAGE,CAAS;AAAA,EAAA,CACxB,GAEKC,IAAU,MAAM;AACpB,IAAAJ,EAASC,GAAOC,CAAQ,GACxBD,EAAM,SAAS;AAAA,EACjB;AAEO,SAAAC;AACT;AAGA,MAAMG,IAAS,CACdC,GACAC,GACAC,MACU;AACV,aAAWC,KAAQD,EAAK,CAAC,EAAE,MAAM,GAAG;AACnC,IAAAA,EAAK,CAAC,IAAIC,GACV,QAAQ,UAAU,GAAGH,CAAM,eAAe,EAAE,MAAMC,GAASC,CAAI;AAEjE,GAQaE,IAAK,CACjBH,MACGC,MACOH,EAAO,OAAOE,GAASC,CAAI,GAQzBG,IAAM,CAClBJ,MACGC,MACOH,EAAO,UAAUE,GAASC,CAAI;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mattilsynet/design",
3
- "version": "0.0.9",
3
+ "version": "0.0.11",
4
4
  "type": "module",
5
5
  "main": "./mtds/index.js",
6
6
  "types": "./mtds/index.d.ts",
@@ -15,9 +15,10 @@
15
15
  "./*.svg": "./mtds/*.svg",
16
16
  "./icons/*": "./mtds/icons/*",
17
17
  "./illustrations/*": "./mtds/illustrations/*",
18
+ "./index.iife.js": "./mtds/index.iife.js",
18
19
  "./package.json": "./package.json",
19
- "./styles.json": "./mtds/styles.json",
20
- "./styles.css": "./mtds/styles.css"
20
+ "./styles.css": "./mtds/styles.css",
21
+ "./styles.json": "./mtds/styles.json"
21
22
  },
22
23
  "scripts": {
23
24
  "start": "vite",