desy-html 11.2.0 → 12.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/docs/_global.foot.njk +1 -1
- package/docs/_macro.example-render.njk +62 -18
- package/docs/ds/_ds.section.textos.njk +1 -1
- package/docs/index.html +10 -0
- package/docs/pagina-prueba.html +2 -2
- package/package.json +2 -2
- package/src/css/component.text.css +0 -1
- package/src/js/aria/utils.js +80 -15
- package/src/js/desy-html.js +239 -196
- package/src/js/filters/filter-caller.js +4 -2
- package/src/js/filters/filter-escape-ltgt.js +7 -0
- package/src/js/filters/filter-quotes.js +50 -0
- package/src/js/filters/filter-version.js +8 -0
- package/src/js/filters/index.js +7 -1
- package/src/templates/components/accordion/_examples.accordion.njk +107 -107
- package/src/templates/components/accordion/_template.accordion.njk +5 -5
- package/src/templates/components/accordion-history/_examples.accordion-history.njk +119 -119
- package/src/templates/components/accordion-history/_template.accordion-history.njk +11 -11
- package/src/templates/components/alert/_examples.alert.njk +2 -2
- package/src/templates/components/breadcrumbs/_examples.breadcrumbs.njk +4 -4
- package/src/templates/components/breadcrumbs/_template.breadcrumbs.njk +4 -4
- package/src/templates/components/button/_examples.button.njk +19 -19
- package/src/templates/components/button/_template.button.njk +2 -2
- package/src/templates/components/button-loader/_examples.button-loader.njk +17 -17
- package/src/templates/components/button-loader/_template.button-loader.njk +2 -2
- package/src/templates/components/card/_examples.card.njk +3 -3
- package/src/templates/components/card/_template.card.njk +4 -4
- package/src/templates/components/character-count/_examples.character-count.njk +2 -2
- package/src/templates/components/checkboxes/_examples.checkboxes.njk +6 -6
- package/src/templates/components/checkboxes/_template.checkboxes.njk +2 -2
- package/src/templates/components/collapsible/_examples.collapsible.njk +4 -4
- package/src/templates/components/collapsible/_template.collapsible.njk +1 -1
- package/src/templates/components/date-input/_template.date-input.njk +1 -1
- package/src/templates/components/datepicker/_examples.datepicker.njk +45 -62
- package/src/templates/components/datepicker/_styles.datepicker.css +4 -0
- package/src/templates/components/datepicker/_template.datepicker.njk +10 -2
- package/src/templates/components/description-list/_examples.description-list.njk +3 -3
- package/src/templates/components/description-list/_template.description-list.njk +2 -2
- package/src/templates/components/details/_examples.details.njk +3 -3
- package/src/templates/components/details/_template.details.njk +1 -1
- package/src/templates/components/dialog/_examples.dialog.njk +4 -4
- package/src/templates/components/dropdown/_examples.dropdown.njk +31 -17
- package/src/templates/components/dropdown/_template.dropdown.njk +1 -1
- package/src/templates/components/error-message/_examples.error-message.njk +1 -1
- package/src/templates/components/error-message/_template.error-message.njk +1 -1
- package/src/templates/components/error-summary/_template.error-summary.njk +2 -2
- package/src/templates/components/fieldset/_examples.fieldset.njk +3 -3
- package/src/templates/components/fieldset/_template.fieldset.njk +7 -7
- package/src/templates/components/footer/_examples.footer.njk +32 -32
- package/src/templates/components/footer/_template.footer.njk +6 -6
- package/src/templates/components/header/_examples.header.njk +14 -8
- package/src/templates/components/header/_template.header.header__navigation.njk +2 -2
- package/src/templates/components/header/_template.header.header__offcanvasButton.njk +1 -1
- package/src/templates/components/header/_template.header.header__subnav.njk +1 -1
- package/src/templates/components/header/_template.header.njk +2 -2
- package/src/templates/components/header-advanced/_examples.header-advanced.njk +14 -8
- package/src/templates/components/header-advanced/_template.header-advanced.njk +3 -3
- package/src/templates/components/header-mini/_examples.header-mini.njk +3 -3
- package/src/templates/components/header-mini/_template.header-mini.njk +2 -2
- package/src/templates/components/hint/_examples.hint.njk +1 -1
- package/src/templates/components/hint/_template.hint.njk +1 -1
- package/src/templates/components/input/_examples.input.njk +7 -7
- package/src/templates/components/input-group/_examples.input-group.njk +1 -1
- package/src/templates/components/input-group/_template.input-group.njk +1 -1
- package/src/templates/components/item/_examples.item.njk +23 -23
- package/src/templates/components/item/_template.item.njk +9 -9
- package/src/templates/components/label/_examples.label.njk +2 -2
- package/src/templates/components/label/_template.label.njk +1 -1
- package/src/templates/components/links-list/_examples.links-list.njk +29 -32
- package/src/templates/components/links-list/_template.links-list.njk +11 -11
- package/src/templates/components/listbox/_examples.listbox.njk +16 -16
- package/src/templates/components/listbox/_template.listbox.njk +3 -3
- package/src/templates/components/media-object/_examples.media-object.njk +5 -5
- package/src/templates/components/menu-horizontal/_examples.menu-horizontal.njk +16 -16
- package/src/templates/components/menu-horizontal/_template.menu-horizontal.njk +2 -2
- package/src/templates/components/menu-navigation/_examples.menu-navigation.njk +6 -6
- package/src/templates/components/menu-navigation/_template.menu-navigation.njk +4 -4
- package/src/templates/components/menu-vertical/_examples.menu-vertical.njk +8 -8
- package/src/templates/components/menu-vertical/_template.menu-vertical.njk +9 -9
- package/src/templates/components/menubar/_examples.menubar.njk +16 -16
- package/src/templates/components/menubar/_template.menubar.njk +7 -7
- package/src/templates/components/modal/_examples.modal.njk +18 -18
- package/src/templates/components/modal/_template.modal.njk +8 -8
- package/src/templates/components/nav/_examples.nav.njk +7 -7
- package/src/templates/components/nav/_template.nav.njk +2 -2
- package/src/templates/components/notification/_examples.notification.njk +9 -9
- package/src/templates/components/notification/_template.notification.njk +11 -11
- package/src/templates/components/pagination/_examples.pagination.njk +6 -6
- package/src/templates/components/pagination/_template.pagination.njk +3 -3
- package/src/templates/components/pill/_examples.pill.njk +8 -8
- package/src/templates/components/pill/_template.pill.njk +3 -3
- package/src/templates/components/radios/_examples.radios.njk +2 -2
- package/src/templates/components/radios/_template.radios.njk +1 -1
- package/src/templates/components/select/_examples.select.njk +1 -1
- package/src/templates/components/skip-link/_examples.skip-link.njk +1 -1
- package/src/templates/components/skip-link/_template.skip-link.njk +1 -1
- package/src/templates/components/status/_examples.status.njk +1 -1
- package/src/templates/components/status/_template.status.njk +1 -1
- package/src/templates/components/status-item/_examples.status-item.njk +15 -15
- package/src/templates/components/status-item/_template.status-item.njk +3 -3
- package/src/templates/components/table/_examples.table.njk +3 -3
- package/src/templates/components/table/_template.table.njk +2 -2
- package/src/templates/components/table-advanced/_examples.table-advanced.njk +7 -7
- package/src/templates/components/table-advanced/_template.table-advanced.njk +5 -5
- package/src/templates/components/tabs/_examples.tabs.njk +19 -19
- package/src/templates/components/tabs/_styles.tabs.css +2 -2
- package/src/templates/components/tabs/_template.tabs.njk +7 -7
- package/src/templates/components/textarea/_examples.textarea.njk +2 -2
- package/src/templates/components/toggle/_examples.toggle.njk +29 -29
- package/src/templates/components/toggle/_template.toggle.njk +2 -2
- package/src/templates/components/tooltip/_examples.tooltip.njk +11 -11
- package/src/templates/components/tooltip/_template.tooltip.njk +3 -3
- package/src/templates/components/tree/_examples.tree.njk +12 -60
- package/src/templates/components/tree/_template.tree.njk +4 -4
- package/src/templates/includes/_test-include.njk +2 -2
- package/src/templates/pages/_page.footer.njk +1 -1
- package/src/templates/pages/_template.logged-selector-subheader.njk +1 -1
package/src/js/desy-html.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { utils } from './aria/utils.js';
|
|
1
|
+
import { utils, formatDateToDDMMYYYY, convertToISOFormat } from './aria/utils.js';
|
|
2
2
|
import { accordion } from './aria/accordion.js';
|
|
3
3
|
import { dataGrid } from './aria/dataGrid.js';
|
|
4
4
|
import { dialog } from './aria/dialog.js';
|
|
@@ -58,6 +58,10 @@ export function dropdownComponent(aria) {
|
|
|
58
58
|
if (moduleValue == 'c-dropdown'){
|
|
59
59
|
const buttonDropdown = modules[item].querySelector('[data-module = "c-dropdown-button"]');
|
|
60
60
|
const tooltip = modules[item].querySelector('[data-module = "c-dropdown-tooltip"]');
|
|
61
|
+
const roleCustom = buttonDropdown.getAttribute('data-role');
|
|
62
|
+
const ariaLabel = buttonDropdown.getAttribute('data-aria-label');
|
|
63
|
+
const ariaModal = buttonDropdown.getAttribute('data-aria-modal');
|
|
64
|
+
const ariaHasPopup = buttonDropdown.getAttribute('data-aria-haspopup');
|
|
61
65
|
if(buttonDropdown && tooltip) {
|
|
62
66
|
const hideOnPopperBlur = {
|
|
63
67
|
/* https://atomiks.github.io/tippyjs/v6/plugins/#hideonpopperblur */
|
|
@@ -114,12 +118,23 @@ export function dropdownComponent(aria) {
|
|
|
114
118
|
offset: [0, -10],
|
|
115
119
|
theme: '',
|
|
116
120
|
plugins: [hideOnEsc,hideOnPopperBlur],
|
|
117
|
-
role: false,
|
|
121
|
+
role: roleCustom ? roleCustom : false,
|
|
118
122
|
aria: {
|
|
119
123
|
content: 'auto'
|
|
120
124
|
},
|
|
125
|
+
onCreate(instance) {
|
|
126
|
+
if(ariaHasPopup){
|
|
127
|
+
instance.reference.setAttribute('aria-haspopup', ariaHasPopup);
|
|
128
|
+
}
|
|
129
|
+
},
|
|
121
130
|
onShown(instance) {
|
|
122
131
|
aria.Utils.focusFirstDescendant(tooltip);
|
|
132
|
+
if(ariaLabel){
|
|
133
|
+
instance.popper.firstElementChild.setAttribute('aria-label', ariaLabel);
|
|
134
|
+
}
|
|
135
|
+
if(ariaModal){
|
|
136
|
+
instance.popper.firstElementChild.setAttribute('aria-modal', ariaModal);
|
|
137
|
+
}
|
|
123
138
|
}
|
|
124
139
|
});
|
|
125
140
|
}
|
|
@@ -131,120 +146,121 @@ export function listboxComponent(aria) {
|
|
|
131
146
|
listbox(aria);
|
|
132
147
|
const modules = document.querySelectorAll('[data-module]');
|
|
133
148
|
let activeButton;
|
|
134
|
-
for (const item in modules)
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
149
|
+
for (const item in modules)
|
|
150
|
+
if (modules.hasOwnProperty(item)) {
|
|
151
|
+
const moduleValue = modules[item].getAttribute('data-module');
|
|
152
|
+
|
|
153
|
+
if (moduleValue == 'c-listbox') {
|
|
154
|
+
const buttonListbox = modules[item].querySelector('[data-module = "c-listbox-button"]');
|
|
155
|
+
const tooltip = modules[item].querySelector('[data-module = "c-listbox-tooltip"]');
|
|
156
|
+
const list = modules[item].querySelector('[data-module = "c-listbox-list"]');
|
|
157
|
+
if (buttonListbox && tooltip) {
|
|
158
|
+
const listbox = new aria.Listbox(list);
|
|
159
|
+
const hideOnClick = {
|
|
160
|
+
name: 'hideOnClick',
|
|
161
|
+
defaultValue: true,
|
|
162
|
+
fn(instance) {
|
|
163
|
+
return {
|
|
164
|
+
onCreate() {
|
|
165
|
+
buttonListbox.addEventListener("click", (event) => {
|
|
166
|
+
if (!buttonListbox.classList.contains('open')) {
|
|
167
|
+
instance.show();
|
|
168
|
+
list.focus()
|
|
169
|
+
buttonListbox.classList.add('open');
|
|
170
|
+
} else {
|
|
171
|
+
list.blur();
|
|
172
|
+
instance.hide();
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
},
|
|
176
|
+
};
|
|
177
|
+
},
|
|
178
|
+
};
|
|
179
|
+
const hideOnPopperBlur = {
|
|
180
|
+
/* https://atomiks.github.io/tippyjs/v6/plugins/#hideonpopperblur */
|
|
181
|
+
name: 'hideOnPopperBlur',
|
|
182
|
+
defaultValue: true,
|
|
183
|
+
fn(instance) {
|
|
184
|
+
return {
|
|
185
|
+
onCreate() {
|
|
186
|
+
instance.popper.addEventListener('focusout', (event) => {
|
|
187
|
+
if (
|
|
188
|
+
instance.props.hideOnPopperBlur &&
|
|
189
|
+
event.relatedTarget &&
|
|
190
|
+
!instance.popper.contains(event.relatedTarget)
|
|
191
|
+
) {
|
|
192
|
+
instance.hide();
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
},
|
|
196
|
+
};
|
|
197
|
+
},
|
|
198
|
+
};
|
|
199
|
+
const hideOnEscOrEnter = {
|
|
200
|
+
/* https://atomiks.github.io/tippyjs/v6/plugins/#hideonesc */
|
|
201
|
+
name: 'hideOnEsc',
|
|
202
|
+
defaultValue: true,
|
|
203
|
+
fn({ hide }) {
|
|
204
|
+
function onKeyDown(event) {
|
|
205
|
+
if ((event.keyCode === 27) || (event.keyCode === 13)) {
|
|
206
|
+
hide();
|
|
207
|
+
}
|
|
191
208
|
}
|
|
192
|
-
}
|
|
193
209
|
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
210
|
+
return {
|
|
211
|
+
onShow() {
|
|
212
|
+
document.addEventListener('keydown', onKeyDown);
|
|
213
|
+
},
|
|
214
|
+
onHide() {
|
|
215
|
+
document.removeEventListener('keydown', onKeyDown);
|
|
216
|
+
}
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
// https://atomiks.github.io/tippyjs/v6/all-props/
|
|
222
|
+
tippy(buttonListbox, {
|
|
223
|
+
placement: 'bottom-start',
|
|
224
|
+
inlinePositioning: true,
|
|
225
|
+
content: tooltip,
|
|
226
|
+
allowHTML: true, // Make sure you are sanitizing any user data if rendering HTML to prevent XSS attacks.
|
|
227
|
+
trigger: 'manual',
|
|
228
|
+
interactive: true,
|
|
229
|
+
arrow: false,
|
|
230
|
+
offset: [0, -10],
|
|
231
|
+
theme: '',
|
|
232
|
+
plugins: [hideOnEscOrEnter, hideOnPopperBlur, hideOnClick],
|
|
233
|
+
role: false,
|
|
234
|
+
aria: {
|
|
235
|
+
content: 'auto'
|
|
236
|
+
},
|
|
237
|
+
onMount(instance) {
|
|
238
|
+
if (list.querySelectorAll('[aria-selected="true"]')[0]) {
|
|
239
|
+
listbox.focusItem(list.querySelectorAll('[aria-selected="true"]')[0]);
|
|
200
240
|
}
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
// https://atomiks.github.io/tippyjs/v6/all-props/
|
|
206
|
-
tippy(buttonListbox, {
|
|
207
|
-
placement: 'bottom-start',
|
|
208
|
-
inlinePositioning: true,
|
|
209
|
-
content: tooltip,
|
|
210
|
-
allowHTML: true, // Make sure you are sanitizing any user data if rendering HTML to prevent XSS attacks.
|
|
211
|
-
trigger: 'manual',
|
|
212
|
-
interactive: true,
|
|
213
|
-
arrow: false,
|
|
214
|
-
offset: [0, -10],
|
|
215
|
-
theme: '',
|
|
216
|
-
plugins: [hideOnEscOrEnter,hideOnPopperBlur, hideOnClick],
|
|
217
|
-
role: false,
|
|
218
|
-
aria: {
|
|
219
|
-
content: 'auto'
|
|
220
|
-
},
|
|
221
|
-
onMount(instance) {
|
|
222
|
-
if (list.querySelectorAll('[aria-selected="true"]')[0]) {
|
|
223
|
-
listbox.focusItem(list.querySelectorAll('[aria-selected="true"]')[0]);
|
|
241
|
+
},
|
|
242
|
+
onHidden(instance) {
|
|
243
|
+
buttonListbox.classList.remove('open');
|
|
224
244
|
}
|
|
225
|
-
}
|
|
226
|
-
onHidden(instance){
|
|
227
|
-
buttonListbox.classList.remove('open');
|
|
228
|
-
}
|
|
229
|
-
});
|
|
245
|
+
});
|
|
230
246
|
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
247
|
+
listbox.setHandleFocusChange(function(evt) {
|
|
248
|
+
if ((!list.hasAttribute('aria-multiselectable')) && (buttonListbox.getAttribute('data-change') == 'change')) {
|
|
249
|
+
buttonListbox.firstElementChild.innerHTML = evt.innerHTML;
|
|
250
|
+
}
|
|
251
|
+
});
|
|
236
252
|
|
|
237
|
-
|
|
238
|
-
|
|
253
|
+
const getMultiSelectable = buttonListbox.getAttribute('aria-labelledby');
|
|
254
|
+
const allowMultiple = getMultiSelectable.includes('is-multiselectable-label');
|
|
239
255
|
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
256
|
+
if (!allowMultiple) {
|
|
257
|
+
list.addEventListener("click", (event) => {
|
|
258
|
+
buttonListbox.click();
|
|
259
|
+
})
|
|
260
|
+
}
|
|
244
261
|
}
|
|
245
262
|
}
|
|
246
263
|
}
|
|
247
|
-
}
|
|
248
264
|
}
|
|
249
265
|
|
|
250
266
|
export function linksListComponent(aria) {
|
|
@@ -287,96 +303,98 @@ export function tabsComponent(aria) {
|
|
|
287
303
|
|
|
288
304
|
export function tooltipComponent(aria) {
|
|
289
305
|
const modules = document.querySelectorAll('[data-module]');
|
|
290
|
-
for (const item in modules)
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
306
|
+
for (const item in modules)
|
|
307
|
+
if (modules.hasOwnProperty(item)) {
|
|
308
|
+
const moduleValue = modules[item].getAttribute('data-module');
|
|
309
|
+
|
|
310
|
+
|
|
311
|
+
if (moduleValue == 'c-tooltip') {
|
|
312
|
+
const tooltipButton = modules[item].querySelector('[data-module = "c-tooltip-button"]');
|
|
313
|
+
const ariaContent = tooltipButton.matches('[data-type = "c-tooltip-button-complex"]') ? 'describedby' : 'labelledby';
|
|
314
|
+
const tooltipTooltip = modules[item].querySelector('[data-module = "c-tooltip-tooltip"]');
|
|
315
|
+
if (tooltipButton && tooltipTooltip) {
|
|
316
|
+
const hideOnPopperBlur = {
|
|
317
|
+
/* https://atomiks.github.io/tippyjs/v6/plugins/#hideonpopperblur */
|
|
318
|
+
name: 'hideOnPopperBlur',
|
|
319
|
+
defaultValue: true,
|
|
320
|
+
fn(instance) {
|
|
321
|
+
return {
|
|
322
|
+
onCreate() {
|
|
323
|
+
instance.popper.addEventListener('focusout', (event) => {
|
|
324
|
+
if (
|
|
325
|
+
instance.props.hideOnPopperBlur &&
|
|
326
|
+
event.relatedTarget &&
|
|
327
|
+
!instance.popper.contains(event.relatedTarget)
|
|
328
|
+
) {
|
|
329
|
+
instance.hide();
|
|
330
|
+
}
|
|
331
|
+
});
|
|
332
|
+
},
|
|
333
|
+
};
|
|
334
|
+
},
|
|
335
|
+
};
|
|
336
|
+
const hideOnEsc = {
|
|
337
|
+
/* https://atomiks.github.io/tippyjs/v6/plugins/#hideonesc */
|
|
338
|
+
name: 'hideOnEsc',
|
|
339
|
+
defaultValue: true,
|
|
340
|
+
fn({ hide }) {
|
|
341
|
+
function onKeyDown(event) {
|
|
342
|
+
if (event.keyCode === 27) {
|
|
343
|
+
hide();
|
|
344
|
+
}
|
|
327
345
|
}
|
|
328
|
-
}
|
|
329
346
|
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
347
|
+
return {
|
|
348
|
+
onShow() {
|
|
349
|
+
document.addEventListener('keydown', onKeyDown);
|
|
350
|
+
},
|
|
351
|
+
onHide() {
|
|
352
|
+
document.removeEventListener('keydown', onKeyDown);
|
|
353
|
+
}
|
|
354
|
+
};
|
|
355
|
+
}
|
|
356
|
+
};
|
|
357
|
+
|
|
358
|
+
// https://atomiks.github.io/tippyjs/v6/all-props/
|
|
359
|
+
tippy(tooltipButton, {
|
|
360
|
+
placement: 'top',
|
|
361
|
+
inlinePositioning: true,
|
|
362
|
+
content: tooltipTooltip,
|
|
363
|
+
allowHTML: true, // Make sure you are sanitizing any user data if rendering HTML to prevent XSS attacks.
|
|
364
|
+
trigger: 'mouseenter focus',
|
|
365
|
+
hideOnClick: false,
|
|
366
|
+
theme: '',
|
|
367
|
+
plugins: [hideOnEsc, hideOnPopperBlur],
|
|
368
|
+
role: 'tooltip',
|
|
369
|
+
interactive: true,
|
|
370
|
+
aria: {
|
|
371
|
+
content: ariaContent
|
|
372
|
+
}
|
|
373
|
+
});
|
|
374
|
+
}
|
|
357
375
|
}
|
|
358
376
|
}
|
|
359
|
-
}
|
|
360
377
|
}
|
|
361
378
|
|
|
362
379
|
export function treeComponent(aria) {
|
|
363
380
|
Treeitem(aria);
|
|
364
381
|
Tree(aria);
|
|
365
382
|
const modules = document.querySelectorAll('[data-module]');
|
|
366
|
-
for (const item in modules)
|
|
367
|
-
|
|
383
|
+
for (const item in modules)
|
|
384
|
+
if (modules.hasOwnProperty(item)) {
|
|
385
|
+
const moduleValue = modules[item].getAttribute('data-module');
|
|
368
386
|
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
387
|
+
if (moduleValue == 'c-tree') {
|
|
388
|
+
const tree = new aria.Tree(modules[item]);
|
|
389
|
+
tree.init();
|
|
390
|
+
}
|
|
373
391
|
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
392
|
+
if (moduleValue == 'c-tree__item') {
|
|
393
|
+
modules[item].addEventListener('click', function(event) {
|
|
394
|
+
event.stopPropagation();
|
|
395
|
+
});
|
|
396
|
+
}
|
|
378
397
|
}
|
|
379
|
-
}
|
|
380
398
|
}
|
|
381
399
|
|
|
382
400
|
export function notificationComponent(aria) {
|
|
@@ -450,39 +468,64 @@ export function DatepickerComponent(aria) {
|
|
|
450
468
|
let datepickerCalendar = null;
|
|
451
469
|
let isOpen = false;
|
|
452
470
|
|
|
471
|
+
// Variable to store the initial value only when the calendar opens
|
|
472
|
+
let storedInitialValue = '';
|
|
473
|
+
let storedInitialFormat = ''; // 'iso' or 'dd-mm-yyyy'
|
|
474
|
+
|
|
453
475
|
const focusCalendar = () => {
|
|
454
|
-
const
|
|
476
|
+
const datepickerSelect = module.querySelector(':is(select)');
|
|
477
|
+
const datepickerCalendar = module.querySelector(':is(calendar-date, calendar-multi, calendar-range)');
|
|
478
|
+
|
|
479
|
+
// Store the initial value only when the calendar opens
|
|
480
|
+
if (!storedInitialValue) {
|
|
481
|
+
storedInitialValue = datepickerCalendar === null ? "" : datepickerCalendar.value;
|
|
482
|
+
// Detect initial format
|
|
483
|
+
storedInitialFormat = storedInitialValue.includes('-') &&
|
|
484
|
+
storedInitialValue.split('-')[0].length === 4 ? 'iso' : 'dd-mm-yyyy';
|
|
485
|
+
}
|
|
486
|
+
|
|
455
487
|
requestAnimationFrame(() => {
|
|
456
|
-
const datepickerSelect = module.querySelector(':is(select)');
|
|
457
|
-
const datepickerCalendar = module.querySelector(':is(calendar-date, calendar-multi, calendar-range)');
|
|
458
|
-
const datepickerInitialValue = datepickerCalendar.value;
|
|
459
488
|
if (datepickerCalendar != undefined) {
|
|
460
489
|
datepickerCalendar.focus();
|
|
461
490
|
datepickerCalendar.addEventListener('change', (e) => {
|
|
462
|
-
inputElement.value = e.target.value;
|
|
491
|
+
inputElement.value = formatDateToDDMMYYYY(e.target.value);
|
|
463
492
|
});
|
|
464
493
|
}
|
|
465
|
-
|
|
494
|
+
|
|
495
|
+
if (datepickerSelect != undefined) {
|
|
466
496
|
datepickerSelect.addEventListener('change', function() {
|
|
467
497
|
const selectedValue = this.value;
|
|
468
498
|
datepickerCalendar.min = selectedValue + "-01-01";
|
|
469
|
-
datepickerCalendar.max = selectedValue + "-31
|
|
499
|
+
datepickerCalendar.max = selectedValue + "-12-31";
|
|
470
500
|
datepickerCalendar.focusedDate = datepickerCalendar.min;
|
|
471
501
|
});
|
|
472
502
|
datepickerSelect.focus();
|
|
473
503
|
}
|
|
504
|
+
|
|
474
505
|
const datepickerCancel = module.querySelector('#' + dropdownId + '-cancel');
|
|
475
506
|
const datepickerSubmit = module.querySelector('#' + dropdownId + '-submit');
|
|
507
|
+
|
|
476
508
|
if (datepickerCancel != undefined) {
|
|
477
509
|
datepickerCancel.onclick = function() {
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
510
|
+
// Restore values according to original format
|
|
511
|
+
if (storedInitialFormat === 'iso') {
|
|
512
|
+
datepickerCalendar.value = storedInitialValue;
|
|
513
|
+
inputElement.value = formatDateToDDMMYYYY(storedInitialValue);
|
|
514
|
+
} else {
|
|
515
|
+
datepickerCalendar.value = convertToISOFormat(storedInitialValue);
|
|
516
|
+
inputElement.value = storedInitialValue;
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
datepickerCalendar.tentative = "";
|
|
481
520
|
closeDropdown();
|
|
482
521
|
}
|
|
483
522
|
}
|
|
523
|
+
|
|
484
524
|
if (datepickerSubmit != undefined) {
|
|
485
525
|
datepickerSubmit.onclick = function() {
|
|
526
|
+
// On submit, clear stored value for next opening
|
|
527
|
+
storedInitialValue = '';
|
|
528
|
+
storedInitialFormat = '';
|
|
486
529
|
closeDropdown();
|
|
487
530
|
}
|
|
488
531
|
}
|
|
@@ -503,7 +546,7 @@ export function DatepickerComponent(aria) {
|
|
|
503
546
|
if (currentExpandedValue !== isOpen) {
|
|
504
547
|
const datepickerTimeout = setTimeout(focusCalendar, 500);
|
|
505
548
|
isOpen = currentExpandedValue;
|
|
506
|
-
if(!isOpen) {
|
|
549
|
+
if (!isOpen) {
|
|
507
550
|
clearTimeout(datepickerTimeout);
|
|
508
551
|
closeDropdown();
|
|
509
552
|
}
|
|
@@ -516,11 +559,11 @@ export function DatepickerComponent(aria) {
|
|
|
516
559
|
} else {
|
|
517
560
|
const datepickerSelect = module.querySelector(':is(select)');
|
|
518
561
|
const datepickerCalendar = module.querySelector(':is(calendar-date, calendar-multi, calendar-range)');
|
|
519
|
-
if(datepickerSelect != undefined) {
|
|
562
|
+
if (datepickerSelect != undefined) {
|
|
520
563
|
datepickerSelect.addEventListener('change', function() {
|
|
521
564
|
const selectedValue = this.value;
|
|
522
565
|
datepickerCalendar.min = selectedValue + "-01-01";
|
|
523
|
-
datepickerCalendar.max = selectedValue + "-31
|
|
566
|
+
datepickerCalendar.max = selectedValue + "-12-31";
|
|
524
567
|
datepickerCalendar.focusedDate = datepickerCalendar.min;
|
|
525
568
|
});
|
|
526
569
|
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
function filterquotes(str) {
|
|
2
|
+
if (typeof str !== 'string') return str;
|
|
3
|
+
|
|
4
|
+
// State to track if we are inside an HTML tag
|
|
5
|
+
let inTag = false;
|
|
6
|
+
let result = '';
|
|
7
|
+
let currentQuote = null;
|
|
8
|
+
|
|
9
|
+
for (let i = 0; i < str.length; i++) {
|
|
10
|
+
const char = str[i];
|
|
11
|
+
|
|
12
|
+
if (char === '<') {
|
|
13
|
+
inTag = true;
|
|
14
|
+
result += char;
|
|
15
|
+
continue;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
if (char === '>') {
|
|
19
|
+
inTag = false;
|
|
20
|
+
result += char;
|
|
21
|
+
continue;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (inTag) {
|
|
25
|
+
// If we find a quote inside a tag
|
|
26
|
+
if (char === "'" || char === '"') {
|
|
27
|
+
if (currentQuote === null) {
|
|
28
|
+
// Starting an attribute value
|
|
29
|
+
currentQuote = char;
|
|
30
|
+
result += '"'; // Always use double quotes
|
|
31
|
+
} else if (currentQuote === char) {
|
|
32
|
+
// Closing the attribute value
|
|
33
|
+
currentQuote = null;
|
|
34
|
+
result += '"';
|
|
35
|
+
} else {
|
|
36
|
+
// It's a quote inside the attribute value
|
|
37
|
+
result += char;
|
|
38
|
+
}
|
|
39
|
+
} else {
|
|
40
|
+
result += char;
|
|
41
|
+
}
|
|
42
|
+
} else {
|
|
43
|
+
result += char;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return result;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export default filterquotes;
|
package/src/js/filters/index.js
CHANGED
|
@@ -5,9 +5,15 @@
|
|
|
5
5
|
import highlight from './highlight.js';
|
|
6
6
|
import filtercaller from './filter-caller.js';
|
|
7
7
|
import filterslugify from './filter-slugify.js';
|
|
8
|
+
import filterquotes from './filter-quotes.js';
|
|
9
|
+
import filterescapeltgt from './filter-escape-ltgt.js'
|
|
10
|
+
import filterversion from './filter-version.js'
|
|
8
11
|
|
|
9
12
|
export const SOURCE_NUNJUCKS_FILTERS = {
|
|
10
13
|
highlight,
|
|
11
14
|
filtercaller,
|
|
12
|
-
filterslugify
|
|
15
|
+
filterslugify,
|
|
16
|
+
filterquotes,
|
|
17
|
+
filterescapeltgt,
|
|
18
|
+
filterversion
|
|
13
19
|
};
|