@maggioli-design-system/mds-accordion-timer 3.6.0 → 3.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/dist/cjs/{index-ab2aee76.js → index-2cfccbaa.js} +48 -21
  2. package/dist/cjs/loader.cjs.js +1 -1
  3. package/dist/cjs/mds-accordion-timer.cjs.entry.js +99 -99
  4. package/dist/cjs/mds-accordion-timer.cjs.js +2 -2
  5. package/dist/collection/collection-manifest.json +1 -1
  6. package/dist/collection/common/aria.js +18 -18
  7. package/dist/collection/common/keyboard-manager.js +38 -38
  8. package/dist/collection/common/unit.js +7 -7
  9. package/dist/collection/components/mds-accordion-timer/mds-accordion-timer.js +173 -173
  10. package/dist/collection/components/mds-accordion-timer/test/mds-accordion-timer.e2e.js +7 -7
  11. package/dist/collection/components/mds-accordion-timer/test/mds-accordion-timer.stories.js +8 -8
  12. package/dist/collection/dictionary/autocomplete.js +56 -56
  13. package/dist/collection/dictionary/button.js +19 -19
  14. package/dist/collection/dictionary/color.js +14 -14
  15. package/dist/collection/dictionary/floating-ui.js +14 -14
  16. package/dist/collection/dictionary/input.js +31 -15
  17. package/dist/collection/dictionary/loading.js +2 -2
  18. package/dist/collection/dictionary/typography.js +46 -46
  19. package/dist/collection/dictionary/variant.js +54 -54
  20. package/dist/collection/fixtures/cities.js +107 -107
  21. package/dist/components/mds-accordion-timer.d.ts +2 -2
  22. package/dist/components/mds-accordion-timer.js +115 -115
  23. package/dist/documentation.json +2 -2
  24. package/dist/esm/{index-1e1d02d3.js → index-df0a164e.js} +48 -21
  25. package/dist/esm/loader.js +2 -2
  26. package/dist/esm/mds-accordion-timer.entry.js +99 -99
  27. package/dist/esm/mds-accordion-timer.js +3 -3
  28. package/dist/esm-es5/index-df0a164e.js +1 -0
  29. package/dist/esm-es5/loader.js +1 -1
  30. package/dist/esm-es5/mds-accordion-timer.entry.js +1 -1
  31. package/dist/esm-es5/mds-accordion-timer.js +1 -1
  32. package/dist/mds-accordion-timer/mds-accordion-timer.esm.js +1 -1
  33. package/dist/mds-accordion-timer/mds-accordion-timer.js +15 -15
  34. package/dist/mds-accordion-timer/{p-b86c017a.system.entry.js → p-09cc1589.system.entry.js} +1 -1
  35. package/dist/mds-accordion-timer/p-0da95646.system.js +2 -0
  36. package/dist/mds-accordion-timer/p-36be1c3e.js +2 -0
  37. package/dist/mds-accordion-timer/{p-ee10fd98.system.js → p-8dd76b31.system.js} +1 -1
  38. package/{www/build/p-57415df8.entry.js → dist/mds-accordion-timer/p-e57978cc.entry.js} +1 -1
  39. package/dist/stats.json +30 -30
  40. package/dist/types/common/keyboard-manager.d.ts +9 -9
  41. package/dist/types/components/mds-accordion-timer/mds-accordion-timer.d.ts +33 -33
  42. package/dist/types/components/mds-accordion-timer/test/mds-accordion-timer.stories.d.ts +8 -8
  43. package/dist/types/dictionary/input.d.ts +2 -1
  44. package/dist/types/interface/input-value.d.ts +1 -1
  45. package/dist/types/stencil-public-runtime.d.ts +8 -0
  46. package/documentation.json +14 -4
  47. package/package.json +4 -4
  48. package/src/components/mds-accordion-timer/mds-accordion-timer.css +1 -1
  49. package/src/dictionary/input.ts +18 -0
  50. package/src/fixtures/icons.json +3 -0
  51. package/src/fixtures/iconsauce.json +3 -0
  52. package/www/build/mds-accordion-timer.esm.js +1 -1
  53. package/www/build/mds-accordion-timer.js +15 -15
  54. package/www/build/{p-b86c017a.system.entry.js → p-09cc1589.system.entry.js} +1 -1
  55. package/www/build/p-0da95646.system.js +2 -0
  56. package/www/build/p-36be1c3e.js +2 -0
  57. package/www/build/{p-ee10fd98.system.js → p-8dd76b31.system.js} +1 -1
  58. package/{dist/mds-accordion-timer/p-57415df8.entry.js → www/build/p-e57978cc.entry.js} +1 -1
  59. package/dist/esm-es5/index-1e1d02d3.js +0 -1
  60. package/dist/mds-accordion-timer/p-6584787f.system.js +0 -2
  61. package/dist/mds-accordion-timer/p-70e86e8e.js +0 -2
  62. package/www/build/p-6584787f.system.js +0 -2
  63. package/www/build/p-70e86e8e.js +0 -2
@@ -48,6 +48,13 @@ const uniqueTime = (key, measureText) => {
48
48
  }
49
49
  };
50
50
  const HYDRATED_CSS = '{visibility:hidden}[hydrated]{visibility:inherit}';
51
+ /**
52
+ * Constant for styles to be globally applied to `slot-fb` elements for pseudo-slot behavior.
53
+ *
54
+ * Two cascading rules must be used instead of a `:not()` selector due to Stencil browser
55
+ * support as of Stencil v4.
56
+ */
57
+ const SLOT_FB_CSS = 'slot-fb{display:contents}slot-fb[hidden]{display:none}';
51
58
  const isDef = (v) => v != null;
52
59
  /**
53
60
  * Check whether a value is a 'complex type', defined here as an object or a
@@ -250,6 +257,10 @@ const addStyle = (styleContainerNode, cmpMeta, mode) => {
250
257
  }
251
258
  styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
252
259
  }
260
+ // Add styles for `slot-fb` elements if we're using slots outside the Shadow DOM
261
+ if (cmpMeta.$flags$ & 4 /* CMP_FLAGS.hasSlotRelocation */) {
262
+ styleElm.innerHTML += SLOT_FB_CSS;
263
+ }
253
264
  if (appliedStyles) {
254
265
  appliedStyles.add(scopeId);
255
266
  }
@@ -936,10 +947,10 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
936
947
  */
937
948
  const proxyComponent = (Cstr, cmpMeta, flags) => {
938
949
  var _a;
950
+ const prototype = Cstr.prototype;
939
951
  if (cmpMeta.$members$) {
940
952
  // It's better to have a const than two Object.entries()
941
953
  const members = Object.entries(cmpMeta.$members$);
942
- const prototype = Cstr.prototype;
943
954
  members.map(([memberName, [memberFlags]]) => {
944
955
  if ((memberFlags & 31 /* MEMBER_FLAGS.Prop */ ||
945
956
  ((flags & 2 /* PROXY_FLAGS.proxyState */) && memberFlags & 32 /* MEMBER_FLAGS.State */))) {
@@ -962,6 +973,7 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
962
973
  const attrNameToPropName = new Map();
963
974
  prototype.attributeChangedCallback = function (attrName, oldValue, newValue) {
964
975
  plt.jmp(() => {
976
+ var _a;
965
977
  const propName = attrNameToPropName.get(attrName);
966
978
  // In a web component lifecycle the attributeChangedCallback runs prior to connectedCallback
967
979
  // in the case where an attribute was set inline.
@@ -1017,11 +1029,12 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
1017
1029
  // 1. The instance is ready
1018
1030
  // 2. The watchers are ready
1019
1031
  // 3. The value has changed
1020
- if (!(flags & 8 /* HOST_FLAGS.isConstructingInstance */) &&
1032
+ if (flags &&
1033
+ !(flags & 8 /* HOST_FLAGS.isConstructingInstance */) &&
1021
1034
  flags & 128 /* HOST_FLAGS.isWatchReady */ &&
1022
1035
  newValue !== oldValue) {
1023
1036
  const instance = hostRef.$lazyInstance$ ;
1024
- const entry = cmpMeta.$watchers$[attrName];
1037
+ const entry = (_a = cmpMeta.$watchers$) === null || _a === void 0 ? void 0 : _a[attrName];
1025
1038
  entry === null || entry === void 0 ? void 0 : entry.forEach((callbackName) => {
1026
1039
  if (instance[callbackName] != null) {
1027
1040
  instance[callbackName].call(instance, newValue, oldValue, attrName);
@@ -1216,12 +1229,13 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
1216
1229
  const customElements = win.customElements;
1217
1230
  const head = doc.head;
1218
1231
  const metaCharset = /*@__PURE__*/ head.querySelector('meta[charset]');
1219
- const visibilityStyle = /*@__PURE__*/ doc.createElement('style');
1232
+ const dataStyles = /*@__PURE__*/ doc.createElement('style');
1220
1233
  const deferredConnectedCallbacks = [];
1221
1234
  let appLoadFallback;
1222
1235
  let isBootstrapping = true;
1223
1236
  Object.assign(plt, options);
1224
1237
  plt.$resourcesUrl$ = new URL(options.resourcesUrl || './', doc.baseURI).href;
1238
+ let hasSlotRelocation = false;
1225
1239
  lazyBundles.map((lazyBundle) => {
1226
1240
  lazyBundle[1].map((compactMeta) => {
1227
1241
  const cmpMeta = {
@@ -1230,6 +1244,11 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
1230
1244
  $members$: compactMeta[2],
1231
1245
  $listeners$: compactMeta[3],
1232
1246
  };
1247
+ // Check if we are using slots outside the shadow DOM in this component.
1248
+ // We'll use this information later to add styles for `slot-fb` elements
1249
+ if (cmpMeta.$flags$ & 4 /* CMP_FLAGS.hasSlotRelocation */) {
1250
+ hasSlotRelocation = true;
1251
+ }
1233
1252
  {
1234
1253
  cmpMeta.$members$ = compactMeta[2];
1235
1254
  }
@@ -1283,15 +1302,23 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
1283
1302
  }
1284
1303
  });
1285
1304
  });
1305
+ // Add styles for `slot-fb` elements if any of our components are using slots outside the Shadow DOM
1306
+ if (hasSlotRelocation) {
1307
+ dataStyles.innerHTML += SLOT_FB_CSS;
1308
+ }
1309
+ // Add hydration styles
1286
1310
  {
1287
- visibilityStyle.innerHTML = cmpTags + HYDRATED_CSS;
1288
- visibilityStyle.setAttribute('data-styles', '');
1311
+ dataStyles.innerHTML += cmpTags + HYDRATED_CSS;
1312
+ }
1313
+ // If we have styles, add them to the DOM
1314
+ if (dataStyles.innerHTML.length) {
1315
+ dataStyles.setAttribute('data-styles', '');
1316
+ head.insertBefore(dataStyles, metaCharset ? metaCharset.nextSibling : head.firstChild);
1289
1317
  // Apply CSP nonce to the style tag if it exists
1290
1318
  const nonce = (_a = plt.$nonce$) !== null && _a !== void 0 ? _a : queryNonceMetaTagContent(doc);
1291
1319
  if (nonce != null) {
1292
- visibilityStyle.setAttribute('nonce', nonce);
1320
+ dataStyles.setAttribute('nonce', nonce);
1293
1321
  }
1294
- head.insertBefore(visibilityStyle, metaCharset ? metaCharset.nextSibling : head.firstChild);
1295
1322
  }
1296
1323
  // Process deferred connectedCallbacks now all components have been registered
1297
1324
  isBootstrapping = false;
@@ -1398,19 +1425,19 @@ const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
1398
1425
  return module[exportName];
1399
1426
  }
1400
1427
 
1401
- if (!hmrVersionId || !BUILD.hotModuleReplacement) {
1402
- const processMod = importedModule => {
1403
- cmpModules.set(bundleId, importedModule);
1404
- return importedModule[exportName];
1405
- }
1406
- switch(bundleId) {
1407
-
1408
- case 'mds-accordion-timer.cjs':
1409
- return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(
1410
- /* webpackMode: "lazy" */
1411
- './mds-accordion-timer.cjs.entry.js')); }).then(processMod, consoleError);
1428
+ if (!hmrVersionId || !BUILD.hotModuleReplacement) {
1429
+ const processMod = importedModule => {
1430
+ cmpModules.set(bundleId, importedModule);
1431
+ return importedModule[exportName];
1432
+ }
1433
+ switch(bundleId) {
1434
+
1435
+ case 'mds-accordion-timer.cjs':
1436
+ return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(
1437
+ /* webpackMode: "lazy" */
1438
+ './mds-accordion-timer.cjs.entry.js')); }).then(processMod, consoleError);
1439
+ }
1412
1440
  }
1413
- }
1414
1441
  return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(
1415
1442
  /* @vite-ignore */
1416
1443
  /* webpackInclude: /\.entry\.js$/ */
@@ -1485,7 +1512,7 @@ const flush = () => {
1485
1512
  }
1486
1513
  }
1487
1514
  };
1488
- const nextTick = /*@__PURE__*/ (cb) => promiseResolve().then(cb);
1515
+ const nextTick = (cb) => promiseResolve().then(cb);
1489
1516
  const writeTask = /*@__PURE__*/ queueTask(queueDomWrites, true);
1490
1517
 
1491
1518
  exports.Host = Host;
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- const index = require('./index-ab2aee76.js');
5
+ const index = require('./index-2cfccbaa.js');
6
6
 
7
7
  const defineCustomElements = (win, options) => {
8
8
  if (typeof window === 'undefined') return undefined;
@@ -2,115 +2,115 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- const index = require('./index-ab2aee76.js');
5
+ const index = require('./index-2cfccbaa.js');
6
6
 
7
7
  const mdsAccordionTimerCss = ":host{--mds-accordion-timer-progress-bar-color:rgb(var(--tone-neutral-03));--mds-accordion-timer-progress-bar-background:rgb(var(--tone-neutral-08));--mds-accordion-timer-progress-bar-thickness:0.25rem;--mds-accordion-timer-duration:500ms;display:block}";
8
8
 
9
9
  const MdsAccordionTimer = class {
10
- constructor(hostRef) {
11
- index.registerInstance(this, hostRef);
12
- this.changeEvent = index.createEvent(this, "mdsAccordionTimerChange", 7);
13
- this.clearIntervals = () => {
14
- window.clearInterval(this.timer);
15
- window.clearInterval(this.timeChecker);
16
- this.timeChecker = 0;
17
- };
18
- this.progress = () => {
19
- return Math.abs(this.remainingTime() / this.duration - 1);
20
- };
21
- this.addTimeListener = () => {
22
- this.timeChecker = window.setInterval(() => {
23
- const progress = this.progress();
10
+ constructor(hostRef) {
11
+ index.registerInstance(this, hostRef);
12
+ this.changeEvent = index.createEvent(this, "mdsAccordionTimerChange", 7);
13
+ this.clearIntervals = () => {
14
+ window.clearInterval(this.timer);
15
+ window.clearInterval(this.timeChecker);
16
+ this.timeChecker = 0;
17
+ };
18
+ this.progress = () => {
19
+ return Math.abs(this.remainingTime() / this.duration - 1);
20
+ };
21
+ this.addTimeListener = () => {
22
+ this.timeChecker = window.setInterval(() => {
23
+ const progress = this.progress();
24
+ if (this.selectedItem !== undefined) {
25
+ this.selectedItem.progress = progress;
26
+ }
27
+ if (progress === 1) {
28
+ this.selectedItem.progress = 0;
29
+ this.startNext();
30
+ }
31
+ }, 100);
32
+ };
33
+ this.beginningTime = () => {
34
+ this.timeStarted = (new Date()).getTime();
35
+ return this.timeStarted;
36
+ };
37
+ this.remainingTime = () => {
38
+ const remainingTime = this.selectedItemDurationTime - ((new Date()).getTime() - this.timeStarted);
39
+ return remainingTime >= 0 ? remainingTime : 0;
40
+ };
41
+ this.setSelectedItem = (uuid) => {
42
+ this.children.forEach((item, key) => {
43
+ if (key === uuid) {
44
+ item.selected = true;
45
+ this.selectedItem = item;
46
+ this.changeEvent.emit();
47
+ }
48
+ else {
49
+ item.selected = false;
50
+ }
51
+ });
52
+ };
53
+ this.startNext = () => {
54
+ const nextUuid = this.selectedItem.uuid + 1 > this.children.length - 1 ? 0 : this.selectedItem.uuid + 1;
55
+ this.setSelectedItem(nextUuid);
56
+ this.startTimer();
57
+ };
58
+ this.startTimer = () => {
59
+ this.clearIntervals();
60
+ this.time = this.beginningTime();
61
+ this.selectedItemDurationTime = this.duration;
62
+ this.addTimeListener();
63
+ };
64
+ this.playTimer = () => {
65
+ this.beginningTime();
66
+ this.addTimeListener();
67
+ };
68
+ this.pauseTimer = () => {
69
+ this.clearIntervals();
70
+ this.selectedItemDurationTime = this.remainingTime();
71
+ };
72
+ this.stopTimer = () => {
73
+ this.clearIntervals();
74
+ };
75
+ this.time = 0;
76
+ this.duration = 10000;
77
+ }
78
+ componentDidLoad() {
79
+ this.children = this.element.querySelectorAll('mds-accordion-timer-item');
80
+ this.children.forEach((item, key) => {
81
+ item.uuid = key;
82
+ if (item.selected) {
83
+ this.selectedItem = item;
84
+ }
85
+ });
24
86
  if (this.selectedItem !== undefined) {
25
- this.selectedItem.progress = progress;
26
- }
27
- if (progress === 1) {
28
- this.selectedItem.progress = 0;
29
- this.startNext();
87
+ this.startTimer();
30
88
  }
31
- }, 100);
32
- };
33
- this.beginningTime = () => {
34
- this.timeStarted = (new Date()).getTime();
35
- return this.timeStarted;
36
- };
37
- this.remainingTime = () => {
38
- const remainingTime = this.selectedItemDurationTime - ((new Date()).getTime() - this.timeStarted);
39
- return remainingTime >= 0 ? remainingTime : 0;
40
- };
41
- this.setSelectedItem = (uuid) => {
42
- this.children.forEach((item, key) => {
43
- if (key === uuid) {
44
- item.selected = true;
45
- this.selectedItem = item;
46
- this.changeEvent.emit();
47
- }
48
- else {
49
- item.selected = false;
89
+ }
90
+ disconnectedCallback() {
91
+ this.stopTimer();
92
+ this.clearIntervals();
93
+ }
94
+ onClickActive(event) {
95
+ if (this.selectedItem) {
96
+ this.selectedItem.progress = 0;
50
97
  }
51
- });
52
- };
53
- this.startNext = () => {
54
- const nextUuid = this.selectedItem.uuid + 1 > this.children.length - 1 ? 0 : this.selectedItem.uuid + 1;
55
- this.setSelectedItem(nextUuid);
56
- this.startTimer();
57
- };
58
- this.startTimer = () => {
59
- this.clearIntervals();
60
- this.time = this.beginningTime();
61
- this.selectedItemDurationTime = this.duration;
62
- this.addTimeListener();
63
- };
64
- this.playTimer = () => {
65
- this.beginningTime();
66
- this.addTimeListener();
67
- };
68
- this.pauseTimer = () => {
69
- this.clearIntervals();
70
- this.selectedItemDurationTime = this.remainingTime();
71
- };
72
- this.stopTimer = () => {
73
- this.clearIntervals();
74
- };
75
- this.time = 0;
76
- this.duration = 10000;
77
- }
78
- componentDidLoad() {
79
- this.children = this.element.querySelectorAll('mds-accordion-timer-item');
80
- this.children.forEach((item, key) => {
81
- item.uuid = key;
82
- if (item.selected) {
83
- this.selectedItem = item;
84
- }
85
- });
86
- if (this.selectedItem !== undefined) {
87
- this.startTimer();
98
+ this.setSelectedItem(event.detail.uuid);
99
+ this.startTimer();
100
+ this.pauseTimer();
101
+ }
102
+ onMouseEnterSelect() {
103
+ this.pauseTimer();
88
104
  }
89
- }
90
- disconnectedCallback() {
91
- this.stopTimer();
92
- this.clearIntervals();
93
- }
94
- onClickActive(event) {
95
- if (this.selectedItem) {
96
- this.selectedItem.progress = 0;
105
+ onMouseLeaveSelect() {
106
+ if (this.timeChecker === 0) {
107
+ this.playTimer();
108
+ }
97
109
  }
98
- this.setSelectedItem(event.detail.uuid);
99
- this.startTimer();
100
- this.pauseTimer();
101
- }
102
- onMouseEnterSelect() {
103
- this.pauseTimer();
104
- }
105
- onMouseLeaveSelect() {
106
- if (this.timeChecker === 0) {
107
- this.playTimer();
110
+ render() {
111
+ return (index.h(index.Host, null, index.h("slot", null)));
108
112
  }
109
- }
110
- render() {
111
- return (index.h(index.Host, null, index.h("slot", null)));
112
- }
113
- get element() { return index.getElement(this); }
113
+ get element() { return index.getElement(this); }
114
114
  };
115
115
  MdsAccordionTimer.style = mdsAccordionTimerCss;
116
116
 
@@ -2,10 +2,10 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- const index = require('./index-ab2aee76.js');
5
+ const index = require('./index-2cfccbaa.js');
6
6
 
7
7
  /*
8
- Stencil Client Patch Browser v4.7.1 | MIT Licensed | https://stenciljs.com
8
+ Stencil Client Patch Browser v4.8.0 | MIT Licensed | https://stenciljs.com
9
9
  */
10
10
  const patchBrowser = () => {
11
11
  const importMeta = (typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.src || new URL('mds-accordion-timer.cjs.js', document.baseURI).href));
@@ -4,7 +4,7 @@
4
4
  ],
5
5
  "compiler": {
6
6
  "name": "@stencil/core",
7
- "version": "4.7.1",
7
+ "version": "4.8.0",
8
8
  "typescriptVersion": "5.2.2"
9
9
  },
10
10
  "collections": [],
@@ -1,29 +1,29 @@
1
1
  const hash = (s) => {
2
- let i, h;
3
- for (i = 0, h = 0; i < s.length; i++) {
4
- h = Math.imul(31, h) + s.charCodeAt(i) | 0;
5
- }
6
- return h.toString();
2
+ let i, h;
3
+ for (i = 0, h = 0; i < s.length; i++) {
4
+ h = Math.imul(31, h) + s.charCodeAt(i) | 0;
5
+ }
6
+ return h.toString();
7
7
  };
8
8
  const randomInt = (max) => Math.floor(Math.random() * max);
9
9
  const unslugName = (name) => {
10
- var _a, _b, _c;
11
- return (_c = (_b = (_a = name.split('/')) === null || _a === void 0 ? void 0 : _a.slice(-1).pop()) === null || _b === void 0 ? void 0 : _b.replace(/-/g, ' ')) !== null && _c !== void 0 ? _c : name;
10
+ var _a, _b, _c;
11
+ return (_c = (_b = (_a = name.split('/')) === null || _a === void 0 ? void 0 : _a.slice(-1).pop()) === null || _b === void 0 ? void 0 : _b.replace(/-/g, ' ')) !== null && _c !== void 0 ? _c : name;
12
12
  };
13
13
  const setAttributeIfEmpty = (element, attribute, value) => {
14
- var _a;
15
- if (element.hasAttribute(attribute)) {
16
- return (_a = element.getAttribute(attribute)) !== null && _a !== void 0 ? _a : '';
17
- }
18
- element.setAttribute(attribute, value);
19
- return value;
14
+ var _a;
15
+ if (element.hasAttribute(attribute)) {
16
+ return (_a = element.getAttribute(attribute)) !== null && _a !== void 0 ? _a : '';
17
+ }
18
+ element.setAttribute(attribute, value);
19
+ return value;
20
20
  };
21
21
  const hashValue = (value) => `${value}-${hash(value)}`;
22
22
  const hashRandomValue = (value) => {
23
- const randomValue = randomInt(1000000);
24
- if (value) {
25
- return `${value}-${hash(randomValue.toString())}`;
26
- }
27
- return hash(randomValue.toString());
23
+ const randomValue = randomInt(1000000);
24
+ if (value) {
25
+ return `${value}-${hash(randomValue.toString())}`;
26
+ }
27
+ return hash(randomValue.toString());
28
28
  };
29
29
  export { unslugName, setAttributeIfEmpty, hashRandomValue, hashValue, };
@@ -1,40 +1,40 @@
1
1
  export class KeyboardManager {
2
- constructor() {
3
- this.elements = [];
4
- this.handleClickBehaviorDispatchEvent = (event) => {
5
- if (event.code === 'Space' || event.code === 'Enter' || event.code === 'NumpadEnter') {
6
- event.target.click();
7
- }
8
- };
9
- this.handleEscapeBehaviorDispatchEvent = (event) => {
10
- if (event.code === 'Escape' && this.escapeCallback) {
11
- this.escapeCallback();
12
- }
13
- };
14
- this.addElement = (el, name = 'element') => {
15
- this.elements[name] = el;
16
- };
17
- this.attachClickBehavior = (name = 'element') => {
18
- if (this.elements[name]) {
19
- this.elements[name].addEventListener('keydown', this.handleClickBehaviorDispatchEvent);
20
- }
21
- };
22
- this.detachClickBehavior = (name = 'element') => {
23
- if (this.elements[name]) {
24
- this.elements[name].removeEventListener('keydown', this.handleClickBehaviorDispatchEvent);
25
- }
26
- };
27
- this.attachEscapeBehavior = (callBack) => {
28
- this.escapeCallback = callBack;
29
- if (window !== undefined) {
30
- window.addEventListener('keydown', this.handleEscapeBehaviorDispatchEvent.bind(this));
31
- }
32
- };
33
- this.detachEscapeBehavior = () => {
34
- this.escapeCallback = () => { return; };
35
- if (window !== undefined) {
36
- window.removeEventListener('keydown', this.handleEscapeBehaviorDispatchEvent.bind(this));
37
- }
38
- };
39
- }
2
+ constructor() {
3
+ this.elements = [];
4
+ this.handleClickBehaviorDispatchEvent = (event) => {
5
+ if (event.code === 'Space' || event.code === 'Enter' || event.code === 'NumpadEnter') {
6
+ event.target.click();
7
+ }
8
+ };
9
+ this.handleEscapeBehaviorDispatchEvent = (event) => {
10
+ if (event.code === 'Escape' && this.escapeCallback) {
11
+ this.escapeCallback();
12
+ }
13
+ };
14
+ this.addElement = (el, name = 'element') => {
15
+ this.elements[name] = el;
16
+ };
17
+ this.attachClickBehavior = (name = 'element') => {
18
+ if (this.elements[name]) {
19
+ this.elements[name].addEventListener('keydown', this.handleClickBehaviorDispatchEvent);
20
+ }
21
+ };
22
+ this.detachClickBehavior = (name = 'element') => {
23
+ if (this.elements[name]) {
24
+ this.elements[name].removeEventListener('keydown', this.handleClickBehaviorDispatchEvent);
25
+ }
26
+ };
27
+ this.attachEscapeBehavior = (callBack) => {
28
+ this.escapeCallback = callBack;
29
+ if (window !== undefined) {
30
+ window.addEventListener('keydown', this.handleEscapeBehaviorDispatchEvent.bind(this));
31
+ }
32
+ };
33
+ this.detachEscapeBehavior = () => {
34
+ this.escapeCallback = () => { return; };
35
+ if (window !== undefined) {
36
+ window.removeEventListener('keydown', this.handleEscapeBehaviorDispatchEvent.bind(this));
37
+ }
38
+ };
39
+ }
40
40
  }
@@ -1,10 +1,10 @@
1
1
  const cssDurationToMilliseconds = (duration, defaultValue = 1000) => {
2
- if (duration.includes('s')) {
3
- return Number(duration.replace('s', '')) * 1000;
4
- }
5
- if (duration.includes('ms')) {
6
- return Number(duration.replace('s', ''));
7
- }
8
- return defaultValue;
2
+ if (duration.includes('s')) {
3
+ return Number(duration.replace('s', '')) * 1000;
4
+ }
5
+ if (duration.includes('ms')) {
6
+ return Number(duration.replace('s', ''));
7
+ }
8
+ return defaultValue;
9
9
  };
10
10
  export { cssDurationToMilliseconds, };