@internetstiftelsen/styleguide 5.0.19 → 5.1.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.
Files changed (92) hide show
  1. package/dist/app.js +71 -0
  2. package/dist/assets/js/Events.js +43 -77
  3. package/dist/assets/js/RequestError.js +16 -31
  4. package/dist/assets/js/anchorScroll.js +22 -15
  5. package/dist/assets/js/charCounter.js +100 -142
  6. package/dist/assets/js/className.js +19 -20
  7. package/dist/assets/js/conditional.js +96 -152
  8. package/dist/assets/js/debounce.js +15 -22
  9. package/dist/assets/js/el.js +108 -159
  10. package/dist/assets/js/getCookieByName.js +13 -11
  11. package/dist/assets/js/hasCookieConsent.js +30 -40
  12. package/dist/assets/js/htmlTextLength.js +12 -10
  13. package/dist/assets/js/iconToggle.js +16 -20
  14. package/dist/assets/js/nodeAdded.js +40 -53
  15. package/dist/assets/js/objToQuery.js +25 -41
  16. package/dist/assets/js/offset.js +29 -25
  17. package/dist/assets/js/ot.js +10 -13
  18. package/dist/assets/js/parallax.js +23 -23
  19. package/dist/assets/js/queryToObj.js +16 -22
  20. package/dist/assets/js/readSpeakerHandling.js +26 -28
  21. package/dist/assets/js/request.js +43 -52
  22. package/dist/assets/js/responsivePosition.js +46 -74
  23. package/dist/assets/js/stringToNode.js +11 -10
  24. package/dist/assets/js/template.js +15 -21
  25. package/dist/assets/js/textToggle.js +19 -24
  26. package/dist/assets/js/track.js +14 -12
  27. package/dist/assets/js/uid.js +10 -6
  28. package/dist/assets/js/utmGenerator.js +27 -33
  29. package/dist/assets/js/validationMessage.js +18 -25
  30. package/dist/assets/js/youtube.js +134 -170
  31. package/dist/atoms/button/Button.js +42 -55
  32. package/dist/atoms/file/file.js +25 -29
  33. package/dist/atoms/file/filePreview.js +27 -31
  34. package/dist/atoms/grid-toggle/grid-toggle.js +6 -9
  35. package/dist/atoms/height-limiter/height-limiter.js +37 -50
  36. package/dist/atoms/password-toggle/password-toggle.js +9 -11
  37. package/dist/atoms/range/range.js +32 -39
  38. package/dist/atoms/textarea/rich-text.js +221 -251
  39. package/dist/atoms/tooltip/tooltip.js +13 -17
  40. package/dist/components.js +42 -77
  41. package/dist/focusTrap.js +66 -77
  42. package/dist/molecules/alert/alert.js +15 -20
  43. package/dist/molecules/context-menu/context-menu.js +11 -16
  44. package/dist/molecules/continue-video-guide/continue-video-guide.js +90 -101
  45. package/dist/molecules/cookie-disclaimer/cookie-disclaimer.js +24 -33
  46. package/dist/molecules/form/Form.js +242 -352
  47. package/dist/molecules/form/index.js +15 -14
  48. package/dist/molecules/glider/glider-course.js +62 -75
  49. package/dist/molecules/glider/glider-hero.js +88 -101
  50. package/dist/molecules/glider/glider.js +49 -45
  51. package/dist/molecules/modal/modal.js +256 -325
  52. package/dist/molecules/multi-select/multi-select.js +198 -304
  53. package/dist/molecules/natural-language-form/natural-language-form.js +32 -46
  54. package/dist/molecules/overview-navigation/overview-navigation.js +90 -141
  55. package/dist/molecules/share/share.js +15 -20
  56. package/dist/molecules/system-error/system-error.js +6 -9
  57. package/dist/organisms/accordion/accordion.js +44 -50
  58. package/dist/organisms/footer/footer.js +1 -1
  59. package/dist/organisms/haveibeenpwned/haveibeenpwned.js +17 -16
  60. package/dist/organisms/mailchimp/mailchimp.js +72 -89
  61. package/dist/organisms/map-box/map-box.js +3 -4
  62. package/dist/organisms/mega-menu/mega-menu.js +177 -212
  63. package/dist/organisms/podcast/podcast.js +192 -215
  64. package/dist/organisms/schedule/schedule-filter.js +9 -15
  65. package/dist/organisms/tabs/tabs.js +194 -253
  66. package/dist/organisms/timeline/openTimelineItem.js +38 -51
  67. package/dist/organisms/timeline/timeline.js +111 -128
  68. package/dist/organisms/video-guide/VideoGuidePlayback.js +210 -286
  69. package/dist/organisms/video-guide/VideoGuideSubtitles.js +57 -80
  70. package/dist/organisms/video-guide/VideoGuideTimeline.js +74 -108
  71. package/dist/organisms/video-guide/getCurrentCueIndex.js +11 -9
  72. package/dist/organisms/video-guide/video-guide.js +66 -103
  73. package/dist/utilities/tab-highlighting/tab-highlighting.js +14 -22
  74. package/dist/vendor/toggle/a11y.toggle-switcher.js +10 -16
  75. package/package.json +78 -99
  76. package/src/app.js +5 -5
  77. package/src/assets/js/anchorScroll.js +1 -1
  78. package/src/assets/js/offset.js +1 -1
  79. package/src/atoms/button/Button.js +1 -1
  80. package/src/atoms/icon/richtext-ordered-list.svg +1 -1
  81. package/src/atoms/icon/sprite.svg +6 -5
  82. package/src/molecules/glider/glider-course.js +0 -2
  83. package/src/molecules/glider/glider.js +2 -2
  84. package/src/organisms/accordion/accordion.js +1 -2
  85. package/src/organisms/timeline/timeline.js +2 -3
  86. package/dist/atoms/timeline/anchorScroll.js +0 -13
  87. package/dist/atoms/toggle-high-contrast/toggle-high-contrast.js +0 -12
  88. package/dist/molecules/glider/glider-single.js +0 -68
  89. package/dist/molecules/modal/modal-graph.js +0 -40
  90. package/dist/molecules/timeline-navigation/timeline-navigation.js +0 -34
  91. /package/src/atoms/icon/{heading-3.svg → richtext-heading-3.svg} +0 -0
  92. /package/src/molecules/alert/{_alert.scss → alert.scss} +0 -0
@@ -1,27 +1,51 @@
1
- 'use strict';
2
-
1
+ "use strict";
3
2
  Object.defineProperty(exports, "__esModule", {
4
- value: true
3
+ value: true
5
4
  });
6
- exports.close = exports.open = exports.clearQueue = undefined;
7
-
8
- var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
9
-
10
- var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
11
-
12
- exports.onOpen = onOpen;
13
- exports.onClose = onClose;
14
-
15
- var _focusTrap = require('../../focusTrap');
16
-
17
- var _focusTrap2 = _interopRequireDefault(_focusTrap);
18
-
19
- var _className = require('../../assets/js/className');
20
-
21
- var _className2 = _interopRequireDefault(_className);
22
-
23
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
24
-
5
+ function _export(target, all) {
6
+ for(var name in all)Object.defineProperty(target, name, {
7
+ enumerable: true,
8
+ get: all[name]
9
+ });
10
+ }
11
+ _export(exports, {
12
+ clearQueue: function() {
13
+ return clearQueue;
14
+ },
15
+ close: function() {
16
+ return close;
17
+ },
18
+ onClose: function() {
19
+ return onClose;
20
+ },
21
+ onOpen: function() {
22
+ return onOpen;
23
+ },
24
+ open: function() {
25
+ return open;
26
+ }
27
+ });
28
+ const _focusTrap = /*#__PURE__*/ _interop_require_default(require("../../focusTrap"));
29
+ const _className = /*#__PURE__*/ _interop_require_default(require("../../assets/js/className"));
30
+ function _extends() {
31
+ _extends = Object.assign || function(target) {
32
+ for(var i = 1; i < arguments.length; i++){
33
+ var source = arguments[i];
34
+ for(var key in source){
35
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
36
+ target[key] = source[key];
37
+ }
38
+ }
39
+ }
40
+ return target;
41
+ };
42
+ return _extends.apply(this, arguments);
43
+ }
44
+ function _interop_require_default(obj) {
45
+ return obj && obj.__esModule ? obj : {
46
+ default: obj
47
+ };
48
+ }
25
49
  /**
26
50
  * Modal action
27
51
  * @typedef {Object} ModalAction
@@ -34,369 +58,276 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
34
58
  * @property {string} key - action click handler key shortcut
35
59
  * @property {function} onClick - action click handler
36
60
  * @property {object} attrs – action element attributes
37
- */
38
-
39
- /**
61
+ */ /**
40
62
  * Modal content
41
63
  * @typedef {Object} ModalContent
42
64
  * @property {string} title - Modal title
43
65
  * @property {string} content - Modal content
44
66
  * @property {ModalAction[]} actions - Modal actions
45
- */
46
-
47
- /**
67
+ */ /**
48
68
  * Modal settings
49
69
  * @typedef {Object} ModalSettings
50
70
  * @property {boolean} replaceCurrent - Replace currently displayed modal
51
71
  * @property {boolean} skipIfCurrent - Skip if currently displaying modal
52
72
  * @property {function} onClose - onClose callback
53
73
  * @property {function} onOpen - onOpen callback
54
- */
55
-
56
- var queue = [];
57
- var globalOnCloseCallbacks = [];
58
- var globalOnOpenCallbacks = [];
59
- var active = null;
60
- var incrementId = 0;
61
- var modal = null;
62
- var modalContent = null;
63
- var modalActions = null;
64
- var modalClose = null;
65
- var keyHandlers = {};
66
-
74
+ */ const queue = [];
75
+ const globalOnCloseCallbacks = [];
76
+ const globalOnOpenCallbacks = [];
77
+ let active = null;
78
+ let incrementId = 0;
79
+ let modal = null;
80
+ let modalContent = null;
81
+ let modalActions = null;
82
+ let modalClose = null;
83
+ let keyHandlers = {};
67
84
  /**
68
85
  * Increase increment ID and return the latest
69
86
  *
70
87
  * @returns {number}
71
- */
72
- function getId() {
73
- incrementId += 1;
74
-
75
- return incrementId;
88
+ */ function getId() {
89
+ incrementId += 1;
90
+ return incrementId;
76
91
  }
77
-
78
92
  function objectToAttributes(obj) {
79
- return Object.entries(obj).filter(function (_ref) {
80
- var _ref2 = _slicedToArray(_ref, 2),
81
- value = _ref2[1];
82
-
83
- return value !== undefined;
84
- }).map(function (_ref3) {
85
- var _ref4 = _slicedToArray(_ref3, 2),
86
- key = _ref4[0],
87
- value = _ref4[1];
88
-
89
- return value !== null ? key + '=' + value : key;
90
- }).join(' ');
93
+ return Object.entries(obj).filter(([, value])=>value !== undefined).map(([key, value])=>value !== null ? `${key}=${value}` : key).join(' ');
91
94
  }
92
-
93
95
  /**
94
96
  * Create an action DOM node and append to modal actions container.
95
97
  *
96
98
  * @param {ModalAction} action
97
- */
98
- function addAction(action) {
99
- var icon = action.icon ? '\n\t\t<svg class="icon ' + (0, _className2.default)('a-button__icon') + '">\n\t\t\t<use xlink:href="#icon-' + action.icon + '"></use>\n\t\t</svg>\n\t' : '';
100
-
101
- var cls = (0, _className2.default)('a-button') + ' u-m-l-2';
102
-
103
- if (action.color) {
104
- cls += ' ' + (0, _className2.default)('a-button--' + action.color);
105
- }
106
-
107
- if (action.modifier) {
108
- cls += ' ' + (0, _className2.default)('m-modal__button-' + action.modifier);
109
- }
110
-
111
- if (action.icon) {
112
- cls += ' ' + (0, _className2.default)('a-button--icon');
113
- }
114
-
115
- var tag = action.url ? 'a' : 'button';
116
- var button = '\n\t\t<' + tag + ' ' + objectToAttributes(_extends({}, action.attrs, { href: action.url, target: action.target })) + ' class="' + cls + '">\n\t\t\t<span class="' + (0, _className2.default)('a-button__text') + '">' + action.text + '</span>\n\t\t\t' + icon + '\n\t\t</' + tag + '>\n\t';
117
-
118
- var dummy = document.createElement('div');
119
-
120
- dummy.innerHTML = button;
121
-
122
- var el = dummy.firstElementChild;
123
- modalActions.appendChild(el);
124
-
125
- if (action.onClick) {
126
- el.addEventListener('click', function (e) {
127
-
128
- action.onClick(e, modal, close);
129
- });
130
- }
99
+ */ function addAction(action) {
100
+ const icon = action.icon ? `
101
+ <svg class="icon ${(0, _className.default)('a-button__icon')}">
102
+ <use xlink:href="#icon-${action.icon}"></use>
103
+ </svg>
104
+ ` : '';
105
+ let cls = `${(0, _className.default)('a-button')} u-m-l-2`;
106
+ if (action.color) {
107
+ cls += ` ${(0, _className.default)(`a-button--${action.color}`)}`;
108
+ }
109
+ if (action.modifier) {
110
+ cls += ` ${(0, _className.default)(`m-modal__button-${action.modifier}`)}`;
111
+ }
112
+ if (action.icon) {
113
+ cls += ` ${(0, _className.default)('a-button--icon')}`;
114
+ }
115
+ const tag = action.url ? 'a' : 'button';
116
+ const button = `
117
+ <${tag} ${objectToAttributes(_extends({}, action.attrs, {
118
+ href: action.url,
119
+ target: action.target
120
+ }))} class="${cls}">
121
+ <span class="${(0, _className.default)('a-button__text')}">${action.text}</span>
122
+ ${icon}
123
+ </${tag}>
124
+ `;
125
+ const dummy = document.createElement('div');
126
+ dummy.innerHTML = button;
127
+ const el = dummy.firstElementChild;
128
+ modalActions.appendChild(el);
129
+ if (action.onClick) {
130
+ el.addEventListener('click', (e)=>{
131
+ action.onClick(e, modal, close);
132
+ });
133
+ }
131
134
  }
132
-
133
135
  function handleKeyUp(e) {
134
- Object.entries(keyHandlers).forEach(function (_ref5) {
135
- var _ref6 = _slicedToArray(_ref5, 2),
136
- key = _ref6[0],
137
- handler = _ref6[1];
138
-
139
- if (e.key.toLowerCase() === key) {
140
-
141
- handler(e, modal, close);
142
- }
143
- });
136
+ Object.entries(keyHandlers).forEach(([key, handler])=>{
137
+ if (e.key.toLowerCase() === key) {
138
+ handler(e, modal, close);
139
+ }
140
+ });
144
141
  }
145
-
146
- /**
147
- * Global onOpen handler
148
- *
149
- * @param {Function} cb
150
- * @returns {number}
151
- */
152
142
  function onOpen(cb) {
153
- var index = globalOnOpenCallbacks.push(cb) - 1;
154
-
155
- return function () {
156
- globalOnOpenCallbacks.splice(index, 1);
157
- };
143
+ const index = globalOnOpenCallbacks.push(cb) - 1;
144
+ return ()=>{
145
+ globalOnOpenCallbacks.splice(index, 1);
146
+ };
158
147
  }
159
-
160
148
  function dispatchOnOpenHandlers(el, id) {
161
- globalOnOpenCallbacks.forEach(function (cb) {
162
- return cb(el, id);
163
- });
149
+ globalOnOpenCallbacks.forEach((cb)=>cb(el, id));
164
150
  }
165
-
166
151
  /**
167
152
  * Display the active modal.
168
- */
169
- function display() {
170
- if (active.content.nodeName) {
171
- // Content is a custom modal
172
- active.el = active.content;
173
- } else {
174
- active.el = modal;
175
- modalContent.innerHTML = '\n\t\t\t<h1>' + active.content.title + '</h1>\n\t\t\t' + active.content.content + '\n\t\t';
176
-
177
- if (active.content.actions) {
178
- modalActions.innerHTML = '';
179
- active.content.actions.forEach(addAction);
180
-
181
- modalActions.classList.remove('u-hide');
182
- } else {
183
- modalActions.classList.add('u-hide');
184
- }
185
- }
186
-
187
- (0, _focusTrap2.default)(active.el);
188
-
189
- active.el.setAttribute('aria-hidden', 'false');
190
- active.el.setAttribute('data-a11y-toggle-open', 'true');
191
-
192
- if (active.settings.onOpen) {
193
- active.settings.onOpen(active.id, active.el);
194
- }
195
-
196
- dispatchOnOpenHandlers(active.el, active.id);
197
-
198
- setTimeout(function () {
199
- if (active.el.focusTrap) {
200
- active.el.focusTrap.activate();
201
- }
202
- }, 1);
203
-
204
- // Just to make sure
205
- keyHandlers = {};
206
-
207
- if (active.content.actions) {
208
- active.content.actions.forEach(function (action) {
209
- if (action.key && action.onClick) {
210
- keyHandlers[action.key] = action.onClick;
211
- }
212
- });
213
- }
214
-
215
- document.addEventListener('keyup', handleKeyUp);
153
+ */ function display() {
154
+ if (active.content.nodeName) {
155
+ // Content is a custom modal
156
+ active.el = active.content;
157
+ } else {
158
+ active.el = modal;
159
+ modalContent.innerHTML = `
160
+ <h1>${active.content.title}</h1>
161
+ ${active.content.content}
162
+ `;
163
+ if (active.content.actions) {
164
+ modalActions.innerHTML = '';
165
+ active.content.actions.forEach(addAction);
166
+ modalActions.classList.remove('u-hide');
167
+ } else {
168
+ modalActions.classList.add('u-hide');
169
+ }
170
+ }
171
+ (0, _focusTrap.default)(active.el);
172
+ active.el.setAttribute('aria-hidden', 'false');
173
+ active.el.setAttribute('data-a11y-toggle-open', 'true');
174
+ if (active.settings.onOpen) {
175
+ active.settings.onOpen(active.id, active.el);
176
+ }
177
+ dispatchOnOpenHandlers(active.el, active.id);
178
+ setTimeout(()=>{
179
+ if (active.el.focusTrap) {
180
+ active.el.focusTrap.activate();
181
+ }
182
+ }, 1);
183
+ // Just to make sure
184
+ keyHandlers = {};
185
+ if (active.content.actions) {
186
+ active.content.actions.forEach((action)=>{
187
+ if (action.key && action.onClick) {
188
+ keyHandlers[action.key] = action.onClick;
189
+ }
190
+ });
191
+ }
192
+ document.addEventListener('keyup', handleKeyUp);
216
193
  }
217
-
218
194
  /**
219
195
  * Dispatch the next modal in queue.
220
- */
221
- function dispatch() {
222
- if (!modal || active || !queue.length) {
223
- return;
224
- }
225
-
226
- active = queue.shift();
227
-
228
- display();
196
+ */ function dispatch() {
197
+ if (!modal || active || !queue.length) {
198
+ return;
199
+ }
200
+ active = queue.shift();
201
+ display();
229
202
  }
230
-
231
- /**
232
- * Global onClose handler
233
- *
234
- * @param {Function} cb
235
- * @returns {number}
236
- */
237
203
  function onClose(cb) {
238
- var index = globalOnCloseCallbacks.push(cb) - 1;
239
-
240
- return function () {
241
- globalOnCloseCallbacks.splice(index, 1);
242
- };
204
+ const index = globalOnCloseCallbacks.push(cb) - 1;
205
+ return ()=>{
206
+ globalOnCloseCallbacks.splice(index, 1);
207
+ };
243
208
  }
244
-
245
209
  function dispatchOnCloseHandlers(el, id) {
246
- globalOnCloseCallbacks.forEach(function (cb) {
247
- return cb(el, id);
248
- });
210
+ globalOnCloseCallbacks.forEach((cb)=>cb(el, id));
249
211
  }
250
-
251
212
  /**
252
213
  * Close currently active modal
253
214
  * and dispatch next in queue.
254
- */
255
- function close() {
256
- if (active) {
257
- active.el.setAttribute('aria-hidden', 'true');
258
- active.el.removeAttribute('data-a11y-toggle-open');
259
-
260
- if (active.settings.onClose) {
261
- active.settings.onClose(active.id);
262
- }
263
-
264
- dispatchOnCloseHandlers(active.el, active.id);
265
-
266
- document.removeEventListener('keyup', handleKeyUp);
267
-
268
- if (active.el.focusTrap) {
269
- active.el.focusTrap.deactivate();
270
- }
271
-
272
- keyHandlers = {};
273
- active = null;
274
- }
275
-
276
- setTimeout(function () {
277
- dispatch();
278
- }, 1);
215
+ */ function close() {
216
+ if (active) {
217
+ active.el.setAttribute('aria-hidden', 'true');
218
+ active.el.removeAttribute('data-a11y-toggle-open');
219
+ if (active.settings.onClose) {
220
+ active.settings.onClose(active.id);
221
+ }
222
+ dispatchOnCloseHandlers(active.el, active.id);
223
+ document.removeEventListener('keyup', handleKeyUp);
224
+ if (active.el.focusTrap) {
225
+ active.el.focusTrap.deactivate();
226
+ }
227
+ keyHandlers = {};
228
+ active = null;
229
+ }
230
+ setTimeout(()=>{
231
+ dispatch();
232
+ }, 1);
279
233
  }
280
-
281
234
  /**
282
235
  * Create the modal skeleton and add it to the DOM.
283
236
  * Done once and cached.
284
- */
285
- function createModal() {
286
- if (modal) {
287
- return;
288
- }
289
-
290
- var id = 'iisModal';
291
- var dummy = document.createElement('div');
292
-
293
- dummy.innerHTML = '\n\t\t<div id="' + id + '" class="' + (0, _className2.default)('m-modal m-modal--has-overlay') + '" data-container="true" aria-hidden="true" aria-labelledby="' + id + '-close">\n\t\t\t<div class="' + (0, _className2.default)('m-modal__container') + '">\n\t\t\t\t<button type="button" class="' + (0, _className2.default)('a-button a-button--standalone-icon a-button--transparent') + '" data-modal-close aria-expanded="false" data-a11y-toggle="' + id + '" aria-controls="' + id + '" id="' + id + '-close">\n\t\t\t\t\t<span class="' + (0, _className2.default)('a-button__text') + ' u-visuallyhidden">St\xE4ng</span>\n\t\t\t\t\t<svg class="icon ' + (0, _className2.default)('a-button__icon') + '">\n\t\t\t\t\t\t<use xlink:href="#icon-close"></use>\n\t\t\t\t\t</svg>\n\t\t\t\t</button>\n\t\t\t\t<div class="' + (0, _className2.default)('m-modal__content') + '" data-modal-content></div>\n\t\t\t\t<div class="' + (0, _className2.default)('m-modal__buttons') + ' u-m-t-2 u-hide" data-modal-actions></div>\n\t\t\t</div>\n\t\t</div>\n\t';
294
-
295
- modal = dummy.firstElementChild;
296
- modalContent = modal.querySelector('[data-modal-content]');
297
- modalActions = modal.querySelector('[data-modal-actions]');
298
- modalClose = modal.querySelector('[data-modal-close]');
299
-
300
- document.body.appendChild(modal);
301
-
302
- modalClose.addEventListener('click', close);
303
-
304
- setTimeout(function () {
305
- dispatch();
306
- }, 1);
237
+ */ function createModal() {
238
+ if (modal) {
239
+ return;
240
+ }
241
+ const id = 'iisModal';
242
+ const dummy = document.createElement('div');
243
+ dummy.innerHTML = `
244
+ <div id="${id}" class="${(0, _className.default)('m-modal m-modal--has-overlay')}" data-container="true" aria-hidden="true" aria-labelledby="${id}-close">
245
+ <div class="${(0, _className.default)('m-modal__container')}">
246
+ <button type="button" class="${(0, _className.default)('a-button a-button--standalone-icon a-button--transparent')}" data-modal-close aria-expanded="false" data-a11y-toggle="${id}" aria-controls="${id}" id="${id}-close">
247
+ <span class="${(0, _className.default)('a-button__text')} u-visuallyhidden">Stäng</span>
248
+ <svg class="icon ${(0, _className.default)('a-button__icon')}">
249
+ <use xlink:href="#icon-close"></use>
250
+ </svg>
251
+ </button>
252
+ <div class="${(0, _className.default)('m-modal__content')}" data-modal-content></div>
253
+ <div class="${(0, _className.default)('m-modal__buttons')} u-m-t-2 u-hide" data-modal-actions></div>
254
+ </div>
255
+ </div>
256
+ `;
257
+ modal = dummy.firstElementChild;
258
+ modalContent = modal.querySelector('[data-modal-content]');
259
+ modalActions = modal.querySelector('[data-modal-actions]');
260
+ modalClose = modal.querySelector('[data-modal-close]');
261
+ document.body.appendChild(modal);
262
+ modalClose.addEventListener('click', close);
263
+ setTimeout(()=>{
264
+ dispatch();
265
+ }, 1);
307
266
  }
308
-
309
267
  /**
310
268
  * Clear the current modal queue
311
- */
312
- function clearQueue() {
313
- queue.length = 0;
269
+ */ function clearQueue() {
270
+ queue.length = 0;
314
271
  }
315
-
316
272
  /**
317
273
  * Open a modal.
318
274
  *
319
275
  * @param {ModalContent|HTMLElement} content
320
276
  * @param {ModalSettings} settings
321
- */
322
- function open(content) {
323
- var settings = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
324
-
325
- if (active && settings.skipIfCurrent) {
326
- return;
327
- }
328
-
329
- queue.push({
330
- id: getId(),
331
- content: content,
332
- settings: settings
333
- });
334
-
335
- if (settings.replaceCurrent) {
336
- close();
337
- } else {
338
- dispatch();
339
- }
277
+ */ function open(content, settings = {}) {
278
+ if (active && settings.skipIfCurrent) {
279
+ return;
280
+ }
281
+ queue.push({
282
+ id: getId(),
283
+ content,
284
+ settings
285
+ });
286
+ if (settings.replaceCurrent) {
287
+ close();
288
+ } else {
289
+ dispatch();
290
+ }
340
291
  }
341
-
342
292
  function delegate(e) {
343
- var openModal = e.target.closest('[data-modal-open]');
344
-
345
- if (openModal) {
346
- e.preventDefault();
347
- e.stopPropagation();
348
-
349
- var id = openModal.getAttribute('data-modal-open');
350
- var modalEl = document.getElementById(id);
351
- document.querySelector('body').classList.add('prevent-scroll');
352
-
353
- if (modalEl) {
354
- open(modalEl, {
355
- replaceCurrent: openModal.hasAttribute('data-modal-replace'),
356
- skipIfCurrent: openModal.hasAttribute('data-modal-skip')
357
- });
358
-
359
- [].forEach.call(document.querySelectorAll('[aria-controls="' + id + '"]'), function (el) {
360
- el.setAttribute('aria-expanded', 'true');
361
- });
362
- }
363
-
364
- return false;
365
- }
366
-
367
- var closeModal = e.target.closest('[data-modal-close]');
368
-
369
- if (closeModal) {
370
- e.preventDefault();
371
- e.stopPropagation();
372
-
373
- var _id = closeModal.getAttribute('data-modal-close') || active && active.el.id;
374
- document.querySelector('body').classList.remove('prevent-scroll');
375
-
376
- if (active && active.el.id === _id) {
377
- close();
378
-
379
- [].forEach.call(document.querySelectorAll('[aria-controls="' + _id + '"]'), function (el) {
380
- el.setAttribute('aria-expanded', 'false');
381
- });
382
- }
383
-
384
- return false;
385
- }
386
-
387
- return true;
293
+ const openModal = e.target.closest('[data-modal-open]');
294
+ if (openModal) {
295
+ e.preventDefault();
296
+ e.stopPropagation();
297
+ const id = openModal.getAttribute('data-modal-open');
298
+ const modalEl = document.getElementById(id);
299
+ document.querySelector('body').classList.add('prevent-scroll');
300
+ if (modalEl) {
301
+ open(modalEl, {
302
+ replaceCurrent: openModal.hasAttribute('data-modal-replace'),
303
+ skipIfCurrent: openModal.hasAttribute('data-modal-skip')
304
+ });
305
+ [].forEach.call(document.querySelectorAll(`[aria-controls="${id}"]`), (el)=>{
306
+ el.setAttribute('aria-expanded', 'true');
307
+ });
308
+ }
309
+ return false;
310
+ }
311
+ const closeModal = e.target.closest('[data-modal-close]');
312
+ if (closeModal) {
313
+ e.preventDefault();
314
+ e.stopPropagation();
315
+ const id = closeModal.getAttribute('data-modal-close') || active && active.el.id;
316
+ document.querySelector('body').classList.remove('prevent-scroll');
317
+ if (active && active.el.id === id) {
318
+ close();
319
+ [].forEach.call(document.querySelectorAll(`[aria-controls="${id}"]`), (el)=>{
320
+ el.setAttribute('aria-expanded', 'false');
321
+ });
322
+ }
323
+ return false;
324
+ }
325
+ return true;
388
326
  }
389
-
390
327
  /**
391
328
  * Attach global listeners
392
- */
393
- function attach() {
394
- document.body.addEventListener('click', delegate);
329
+ */ function attach() {
330
+ document.body.addEventListener('click', delegate);
395
331
  }
396
-
397
332
  createModal();
398
333
  attach();
399
-
400
- exports.clearQueue = clearQueue;
401
- exports.open = open;
402
- exports.close = close;