desy-html 11.1.2 → 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.example.botones-primary-lg.njk +265 -0
- package/docs/ds/_ds.example.dropdowns-variaciones.njk +37 -0
- package/docs/ds/_ds.example.listbox-variaciones.njk +137 -0
- package/docs/ds/_ds.example.tabs.njk +44 -0
- package/docs/ds/_ds.example.textos.njk +5 -0
- package/docs/ds/_ds.section.botones.njk +5 -0
- package/docs/ds/_ds.section.textos.njk +11 -1
- package/docs/index.html +19 -0
- package/docs/pagina-prueba.html +2 -2
- package/package.json +3 -3
- package/src/css/component.text.css +33 -26
- package/src/js/aria/linksList.js +42 -0
- package/src/js/aria/treeitem.js +9 -2
- package/src/js/aria/utils.js +80 -15
- package/src/js/desy-html.js +249 -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/js/index.js +2 -0
- 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 +28 -21
- package/src/templates/components/button/_styles.button.css +7 -0
- package/src/templates/components/button/_template.button.njk +2 -2
- package/src/templates/components/button-loader/_examples.button-loader.njk +25 -18
- package/src/templates/components/button-loader/_styles.button-loader.css +6 -0
- 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 +38 -16
- package/src/templates/components/dropdown/_styles.dropdown.css +7 -0
- 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 +54 -34
- package/src/templates/components/links-list/_template.links-list.njk +15 -15
- package/src/templates/components/listbox/_examples.listbox.njk +52 -17
- package/src/templates/components/listbox/_styles.listbox.css +7 -0
- package/src/templates/components/listbox/_template.listbox.njk +5 -5
- 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 +93 -9
- package/src/templates/components/menu-navigation/_styles.menu-navigation.css +7 -0
- 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 +169 -15
- package/src/templates/components/menubar/_styles.menubar.css +8 -1
- 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 +96 -6
- package/src/templates/components/table-advanced/_template.table-advanced.njk +8 -8
- package/src/templates/components/table-advanced/params.table-advanced.yaml +4 -0
- package/src/templates/components/tabs/_examples.tabs.njk +57 -14
- package/src/templates/components/tabs/_styles.tabs.css +31 -8
- package/src/templates/components/tabs/_template.tabs.njk +8 -8
- package/src/templates/components/tabs/params.tabs.yaml +4 -0
- 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 +112 -47
- package/src/templates/components/tree/_template.tree.njk +6 -6
- 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';
|
|
@@ -8,6 +8,7 @@ import { PopupMenuAction } from './aria/PopupMenuAction.js';
|
|
|
8
8
|
import { MenubarItemAction } from './aria/MenubarItemAction.js';
|
|
9
9
|
import { MenubarAction } from './aria/MenubarAction.js';
|
|
10
10
|
import { listbox } from './aria/listbox.js';
|
|
11
|
+
import { LinksList } from './aria/linksList.js';
|
|
11
12
|
import { alert } from './aria/alert.js';
|
|
12
13
|
import { Treeitem } from './aria/treeitem.js';
|
|
13
14
|
import { Tree } from './aria/tree.js';
|
|
@@ -57,6 +58,10 @@ export function dropdownComponent(aria) {
|
|
|
57
58
|
if (moduleValue == 'c-dropdown'){
|
|
58
59
|
const buttonDropdown = modules[item].querySelector('[data-module = "c-dropdown-button"]');
|
|
59
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');
|
|
60
65
|
if(buttonDropdown && tooltip) {
|
|
61
66
|
const hideOnPopperBlur = {
|
|
62
67
|
/* https://atomiks.github.io/tippyjs/v6/plugins/#hideonpopperblur */
|
|
@@ -113,12 +118,23 @@ export function dropdownComponent(aria) {
|
|
|
113
118
|
offset: [0, -10],
|
|
114
119
|
theme: '',
|
|
115
120
|
plugins: [hideOnEsc,hideOnPopperBlur],
|
|
116
|
-
role: false,
|
|
121
|
+
role: roleCustom ? roleCustom : false,
|
|
117
122
|
aria: {
|
|
118
123
|
content: 'auto'
|
|
119
124
|
},
|
|
125
|
+
onCreate(instance) {
|
|
126
|
+
if(ariaHasPopup){
|
|
127
|
+
instance.reference.setAttribute('aria-haspopup', ariaHasPopup);
|
|
128
|
+
}
|
|
129
|
+
},
|
|
120
130
|
onShown(instance) {
|
|
121
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
|
+
}
|
|
122
138
|
}
|
|
123
139
|
});
|
|
124
140
|
}
|
|
@@ -130,120 +146,130 @@ export function listboxComponent(aria) {
|
|
|
130
146
|
listbox(aria);
|
|
131
147
|
const modules = document.querySelectorAll('[data-module]');
|
|
132
148
|
let activeButton;
|
|
133
|
-
for (const item in modules)
|
|
134
|
-
|
|
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
|
-
|
|
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
|
+
}
|
|
190
208
|
}
|
|
191
|
-
}
|
|
192
209
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
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]);
|
|
199
240
|
}
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
// https://atomiks.github.io/tippyjs/v6/all-props/
|
|
205
|
-
tippy(buttonListbox, {
|
|
206
|
-
placement: 'bottom-start',
|
|
207
|
-
inlinePositioning: true,
|
|
208
|
-
content: tooltip,
|
|
209
|
-
allowHTML: true, // Make sure you are sanitizing any user data if rendering HTML to prevent XSS attacks.
|
|
210
|
-
trigger: 'manual',
|
|
211
|
-
interactive: true,
|
|
212
|
-
arrow: false,
|
|
213
|
-
offset: [0, -10],
|
|
214
|
-
theme: '',
|
|
215
|
-
plugins: [hideOnEscOrEnter,hideOnPopperBlur, hideOnClick],
|
|
216
|
-
role: false,
|
|
217
|
-
aria: {
|
|
218
|
-
content: 'auto'
|
|
219
|
-
},
|
|
220
|
-
onMount(instance) {
|
|
221
|
-
if (list.querySelectorAll('[aria-selected="true"]')[0]) {
|
|
222
|
-
listbox.focusItem(list.querySelectorAll('[aria-selected="true"]')[0]);
|
|
241
|
+
},
|
|
242
|
+
onHidden(instance) {
|
|
243
|
+
buttonListbox.classList.remove('open');
|
|
223
244
|
}
|
|
224
|
-
}
|
|
225
|
-
onHidden(instance){
|
|
226
|
-
buttonListbox.classList.remove('open');
|
|
227
|
-
}
|
|
228
|
-
});
|
|
245
|
+
});
|
|
229
246
|
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
247
|
+
listbox.setHandleFocusChange(function(evt) {
|
|
248
|
+
if ((!list.hasAttribute('aria-multiselectable')) && (buttonListbox.getAttribute('data-change') == 'change')) {
|
|
249
|
+
buttonListbox.firstElementChild.innerHTML = evt.innerHTML;
|
|
250
|
+
}
|
|
251
|
+
});
|
|
235
252
|
|
|
236
|
-
|
|
237
|
-
|
|
253
|
+
const getMultiSelectable = buttonListbox.getAttribute('aria-labelledby');
|
|
254
|
+
const allowMultiple = getMultiSelectable.includes('is-multiselectable-label');
|
|
238
255
|
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
256
|
+
if (!allowMultiple) {
|
|
257
|
+
list.addEventListener("click", (event) => {
|
|
258
|
+
buttonListbox.click();
|
|
259
|
+
})
|
|
260
|
+
}
|
|
243
261
|
}
|
|
244
262
|
}
|
|
245
263
|
}
|
|
246
|
-
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
export function linksListComponent(aria) {
|
|
267
|
+
LinksList(aria);
|
|
268
|
+
|
|
269
|
+
const modules = document.querySelectorAll('[data-module="c-links-list"]');
|
|
270
|
+
[...modules].forEach((module) => {
|
|
271
|
+
aria.linksListInit(module);
|
|
272
|
+
});
|
|
247
273
|
}
|
|
248
274
|
|
|
249
275
|
export function menubarComponent(aria) {
|
|
@@ -277,96 +303,98 @@ export function tabsComponent(aria) {
|
|
|
277
303
|
|
|
278
304
|
export function tooltipComponent(aria) {
|
|
279
305
|
const modules = document.querySelectorAll('[data-module]');
|
|
280
|
-
for (const item in modules)
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
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
|
-
|
|
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
|
+
}
|
|
317
345
|
}
|
|
318
|
-
}
|
|
319
346
|
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
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
|
+
}
|
|
347
375
|
}
|
|
348
376
|
}
|
|
349
|
-
}
|
|
350
377
|
}
|
|
351
378
|
|
|
352
379
|
export function treeComponent(aria) {
|
|
353
380
|
Treeitem(aria);
|
|
354
381
|
Tree(aria);
|
|
355
382
|
const modules = document.querySelectorAll('[data-module]');
|
|
356
|
-
for (const item in modules)
|
|
357
|
-
|
|
383
|
+
for (const item in modules)
|
|
384
|
+
if (modules.hasOwnProperty(item)) {
|
|
385
|
+
const moduleValue = modules[item].getAttribute('data-module');
|
|
358
386
|
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
387
|
+
if (moduleValue == 'c-tree') {
|
|
388
|
+
const tree = new aria.Tree(modules[item]);
|
|
389
|
+
tree.init();
|
|
390
|
+
}
|
|
363
391
|
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
392
|
+
if (moduleValue == 'c-tree__item') {
|
|
393
|
+
modules[item].addEventListener('click', function(event) {
|
|
394
|
+
event.stopPropagation();
|
|
395
|
+
});
|
|
396
|
+
}
|
|
368
397
|
}
|
|
369
|
-
}
|
|
370
398
|
}
|
|
371
399
|
|
|
372
400
|
export function notificationComponent(aria) {
|
|
@@ -440,39 +468,64 @@ export function DatepickerComponent(aria) {
|
|
|
440
468
|
let datepickerCalendar = null;
|
|
441
469
|
let isOpen = false;
|
|
442
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
|
+
|
|
443
475
|
const focusCalendar = () => {
|
|
444
|
-
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
|
+
|
|
445
487
|
requestAnimationFrame(() => {
|
|
446
|
-
const datepickerSelect = module.querySelector(':is(select)');
|
|
447
|
-
const datepickerCalendar = module.querySelector(':is(calendar-date, calendar-multi, calendar-range)');
|
|
448
|
-
const datepickerInitialValue = datepickerCalendar.value;
|
|
449
488
|
if (datepickerCalendar != undefined) {
|
|
450
489
|
datepickerCalendar.focus();
|
|
451
490
|
datepickerCalendar.addEventListener('change', (e) => {
|
|
452
|
-
inputElement.value = e.target.value;
|
|
491
|
+
inputElement.value = formatDateToDDMMYYYY(e.target.value);
|
|
453
492
|
});
|
|
454
493
|
}
|
|
455
|
-
|
|
494
|
+
|
|
495
|
+
if (datepickerSelect != undefined) {
|
|
456
496
|
datepickerSelect.addEventListener('change', function() {
|
|
457
497
|
const selectedValue = this.value;
|
|
458
498
|
datepickerCalendar.min = selectedValue + "-01-01";
|
|
459
|
-
datepickerCalendar.max = selectedValue + "-31
|
|
499
|
+
datepickerCalendar.max = selectedValue + "-12-31";
|
|
460
500
|
datepickerCalendar.focusedDate = datepickerCalendar.min;
|
|
461
501
|
});
|
|
462
502
|
datepickerSelect.focus();
|
|
463
503
|
}
|
|
504
|
+
|
|
464
505
|
const datepickerCancel = module.querySelector('#' + dropdownId + '-cancel');
|
|
465
506
|
const datepickerSubmit = module.querySelector('#' + dropdownId + '-submit');
|
|
507
|
+
|
|
466
508
|
if (datepickerCancel != undefined) {
|
|
467
509
|
datepickerCancel.onclick = function() {
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
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 = "";
|
|
471
520
|
closeDropdown();
|
|
472
521
|
}
|
|
473
522
|
}
|
|
523
|
+
|
|
474
524
|
if (datepickerSubmit != undefined) {
|
|
475
525
|
datepickerSubmit.onclick = function() {
|
|
526
|
+
// On submit, clear stored value for next opening
|
|
527
|
+
storedInitialValue = '';
|
|
528
|
+
storedInitialFormat = '';
|
|
476
529
|
closeDropdown();
|
|
477
530
|
}
|
|
478
531
|
}
|
|
@@ -493,7 +546,7 @@ export function DatepickerComponent(aria) {
|
|
|
493
546
|
if (currentExpandedValue !== isOpen) {
|
|
494
547
|
const datepickerTimeout = setTimeout(focusCalendar, 500);
|
|
495
548
|
isOpen = currentExpandedValue;
|
|
496
|
-
if(!isOpen) {
|
|
549
|
+
if (!isOpen) {
|
|
497
550
|
clearTimeout(datepickerTimeout);
|
|
498
551
|
closeDropdown();
|
|
499
552
|
}
|
|
@@ -506,11 +559,11 @@ export function DatepickerComponent(aria) {
|
|
|
506
559
|
} else {
|
|
507
560
|
const datepickerSelect = module.querySelector(':is(select)');
|
|
508
561
|
const datepickerCalendar = module.querySelector(':is(calendar-date, calendar-multi, calendar-range)');
|
|
509
|
-
if(datepickerSelect != undefined) {
|
|
562
|
+
if (datepickerSelect != undefined) {
|
|
510
563
|
datepickerSelect.addEventListener('change', function() {
|
|
511
564
|
const selectedValue = this.value;
|
|
512
565
|
datepickerCalendar.min = selectedValue + "-01-01";
|
|
513
|
-
datepickerCalendar.max = selectedValue + "-31
|
|
566
|
+
datepickerCalendar.max = selectedValue + "-12-31";
|
|
514
567
|
datepickerCalendar.focusedDate = datepickerCalendar.min;
|
|
515
568
|
});
|
|
516
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
|
};
|