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.
Files changed (134) hide show
  1. package/docs/_global.foot.njk +1 -1
  2. package/docs/_macro.example-render.njk +62 -18
  3. package/docs/ds/_ds.example.botones-primary-lg.njk +265 -0
  4. package/docs/ds/_ds.example.dropdowns-variaciones.njk +37 -0
  5. package/docs/ds/_ds.example.listbox-variaciones.njk +137 -0
  6. package/docs/ds/_ds.example.tabs.njk +44 -0
  7. package/docs/ds/_ds.example.textos.njk +5 -0
  8. package/docs/ds/_ds.section.botones.njk +5 -0
  9. package/docs/ds/_ds.section.textos.njk +11 -1
  10. package/docs/index.html +19 -0
  11. package/docs/pagina-prueba.html +2 -2
  12. package/package.json +3 -3
  13. package/src/css/component.text.css +33 -26
  14. package/src/js/aria/linksList.js +42 -0
  15. package/src/js/aria/treeitem.js +9 -2
  16. package/src/js/aria/utils.js +80 -15
  17. package/src/js/desy-html.js +249 -196
  18. package/src/js/filters/filter-caller.js +4 -2
  19. package/src/js/filters/filter-escape-ltgt.js +7 -0
  20. package/src/js/filters/filter-quotes.js +50 -0
  21. package/src/js/filters/filter-version.js +8 -0
  22. package/src/js/filters/index.js +7 -1
  23. package/src/js/index.js +2 -0
  24. package/src/templates/components/accordion/_examples.accordion.njk +107 -107
  25. package/src/templates/components/accordion/_template.accordion.njk +5 -5
  26. package/src/templates/components/accordion-history/_examples.accordion-history.njk +119 -119
  27. package/src/templates/components/accordion-history/_template.accordion-history.njk +11 -11
  28. package/src/templates/components/alert/_examples.alert.njk +2 -2
  29. package/src/templates/components/breadcrumbs/_examples.breadcrumbs.njk +4 -4
  30. package/src/templates/components/breadcrumbs/_template.breadcrumbs.njk +4 -4
  31. package/src/templates/components/button/_examples.button.njk +28 -21
  32. package/src/templates/components/button/_styles.button.css +7 -0
  33. package/src/templates/components/button/_template.button.njk +2 -2
  34. package/src/templates/components/button-loader/_examples.button-loader.njk +25 -18
  35. package/src/templates/components/button-loader/_styles.button-loader.css +6 -0
  36. package/src/templates/components/button-loader/_template.button-loader.njk +2 -2
  37. package/src/templates/components/card/_examples.card.njk +3 -3
  38. package/src/templates/components/card/_template.card.njk +4 -4
  39. package/src/templates/components/character-count/_examples.character-count.njk +2 -2
  40. package/src/templates/components/checkboxes/_examples.checkboxes.njk +6 -6
  41. package/src/templates/components/checkboxes/_template.checkboxes.njk +2 -2
  42. package/src/templates/components/collapsible/_examples.collapsible.njk +4 -4
  43. package/src/templates/components/collapsible/_template.collapsible.njk +1 -1
  44. package/src/templates/components/date-input/_template.date-input.njk +1 -1
  45. package/src/templates/components/datepicker/_examples.datepicker.njk +45 -62
  46. package/src/templates/components/datepicker/_styles.datepicker.css +4 -0
  47. package/src/templates/components/datepicker/_template.datepicker.njk +10 -2
  48. package/src/templates/components/description-list/_examples.description-list.njk +3 -3
  49. package/src/templates/components/description-list/_template.description-list.njk +2 -2
  50. package/src/templates/components/details/_examples.details.njk +3 -3
  51. package/src/templates/components/details/_template.details.njk +1 -1
  52. package/src/templates/components/dialog/_examples.dialog.njk +4 -4
  53. package/src/templates/components/dropdown/_examples.dropdown.njk +38 -16
  54. package/src/templates/components/dropdown/_styles.dropdown.css +7 -0
  55. package/src/templates/components/dropdown/_template.dropdown.njk +1 -1
  56. package/src/templates/components/error-message/_examples.error-message.njk +1 -1
  57. package/src/templates/components/error-message/_template.error-message.njk +1 -1
  58. package/src/templates/components/error-summary/_template.error-summary.njk +2 -2
  59. package/src/templates/components/fieldset/_examples.fieldset.njk +3 -3
  60. package/src/templates/components/fieldset/_template.fieldset.njk +7 -7
  61. package/src/templates/components/footer/_examples.footer.njk +32 -32
  62. package/src/templates/components/footer/_template.footer.njk +6 -6
  63. package/src/templates/components/header/_examples.header.njk +14 -8
  64. package/src/templates/components/header/_template.header.header__navigation.njk +2 -2
  65. package/src/templates/components/header/_template.header.header__offcanvasButton.njk +1 -1
  66. package/src/templates/components/header/_template.header.header__subnav.njk +1 -1
  67. package/src/templates/components/header/_template.header.njk +2 -2
  68. package/src/templates/components/header-advanced/_examples.header-advanced.njk +14 -8
  69. package/src/templates/components/header-advanced/_template.header-advanced.njk +3 -3
  70. package/src/templates/components/header-mini/_examples.header-mini.njk +3 -3
  71. package/src/templates/components/header-mini/_template.header-mini.njk +2 -2
  72. package/src/templates/components/hint/_examples.hint.njk +1 -1
  73. package/src/templates/components/hint/_template.hint.njk +1 -1
  74. package/src/templates/components/input/_examples.input.njk +7 -7
  75. package/src/templates/components/input-group/_examples.input-group.njk +1 -1
  76. package/src/templates/components/input-group/_template.input-group.njk +1 -1
  77. package/src/templates/components/item/_examples.item.njk +23 -23
  78. package/src/templates/components/item/_template.item.njk +9 -9
  79. package/src/templates/components/label/_examples.label.njk +2 -2
  80. package/src/templates/components/label/_template.label.njk +1 -1
  81. package/src/templates/components/links-list/_examples.links-list.njk +54 -34
  82. package/src/templates/components/links-list/_template.links-list.njk +15 -15
  83. package/src/templates/components/listbox/_examples.listbox.njk +52 -17
  84. package/src/templates/components/listbox/_styles.listbox.css +7 -0
  85. package/src/templates/components/listbox/_template.listbox.njk +5 -5
  86. package/src/templates/components/media-object/_examples.media-object.njk +5 -5
  87. package/src/templates/components/menu-horizontal/_examples.menu-horizontal.njk +16 -16
  88. package/src/templates/components/menu-horizontal/_template.menu-horizontal.njk +2 -2
  89. package/src/templates/components/menu-navigation/_examples.menu-navigation.njk +93 -9
  90. package/src/templates/components/menu-navigation/_styles.menu-navigation.css +7 -0
  91. package/src/templates/components/menu-navigation/_template.menu-navigation.njk +4 -4
  92. package/src/templates/components/menu-vertical/_examples.menu-vertical.njk +8 -8
  93. package/src/templates/components/menu-vertical/_template.menu-vertical.njk +9 -9
  94. package/src/templates/components/menubar/_examples.menubar.njk +169 -15
  95. package/src/templates/components/menubar/_styles.menubar.css +8 -1
  96. package/src/templates/components/menubar/_template.menubar.njk +7 -7
  97. package/src/templates/components/modal/_examples.modal.njk +18 -18
  98. package/src/templates/components/modal/_template.modal.njk +8 -8
  99. package/src/templates/components/nav/_examples.nav.njk +7 -7
  100. package/src/templates/components/nav/_template.nav.njk +2 -2
  101. package/src/templates/components/notification/_examples.notification.njk +9 -9
  102. package/src/templates/components/notification/_template.notification.njk +11 -11
  103. package/src/templates/components/pagination/_examples.pagination.njk +6 -6
  104. package/src/templates/components/pagination/_template.pagination.njk +3 -3
  105. package/src/templates/components/pill/_examples.pill.njk +8 -8
  106. package/src/templates/components/pill/_template.pill.njk +3 -3
  107. package/src/templates/components/radios/_examples.radios.njk +2 -2
  108. package/src/templates/components/radios/_template.radios.njk +1 -1
  109. package/src/templates/components/select/_examples.select.njk +1 -1
  110. package/src/templates/components/skip-link/_examples.skip-link.njk +1 -1
  111. package/src/templates/components/skip-link/_template.skip-link.njk +1 -1
  112. package/src/templates/components/status/_examples.status.njk +1 -1
  113. package/src/templates/components/status/_template.status.njk +1 -1
  114. package/src/templates/components/status-item/_examples.status-item.njk +15 -15
  115. package/src/templates/components/status-item/_template.status-item.njk +3 -3
  116. package/src/templates/components/table/_examples.table.njk +3 -3
  117. package/src/templates/components/table/_template.table.njk +2 -2
  118. package/src/templates/components/table-advanced/_examples.table-advanced.njk +96 -6
  119. package/src/templates/components/table-advanced/_template.table-advanced.njk +8 -8
  120. package/src/templates/components/table-advanced/params.table-advanced.yaml +4 -0
  121. package/src/templates/components/tabs/_examples.tabs.njk +57 -14
  122. package/src/templates/components/tabs/_styles.tabs.css +31 -8
  123. package/src/templates/components/tabs/_template.tabs.njk +8 -8
  124. package/src/templates/components/tabs/params.tabs.yaml +4 -0
  125. package/src/templates/components/textarea/_examples.textarea.njk +2 -2
  126. package/src/templates/components/toggle/_examples.toggle.njk +29 -29
  127. package/src/templates/components/toggle/_template.toggle.njk +2 -2
  128. package/src/templates/components/tooltip/_examples.tooltip.njk +11 -11
  129. package/src/templates/components/tooltip/_template.tooltip.njk +3 -3
  130. package/src/templates/components/tree/_examples.tree.njk +112 -47
  131. package/src/templates/components/tree/_template.tree.njk +6 -6
  132. package/src/templates/includes/_test-include.njk +2 -2
  133. package/src/templates/pages/_page.footer.njk +1 -1
  134. package/src/templates/pages/_template.logged-selector-subheader.njk +1 -1
@@ -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) if (modules.hasOwnProperty(item)) {
134
- const moduleValue = modules[item].getAttribute('data-module');
135
-
136
- if (moduleValue == 'c-listbox'){
137
- const buttonListbox = modules[item].querySelector('[data-module = "c-listbox-button"]');
138
- const tooltip = modules[item].querySelector('[data-module = "c-listbox-tooltip"]');
139
- const list = modules[item].querySelector('[data-module = "c-listbox-list"]');
140
- if(buttonListbox && tooltip) {
141
- const listbox = new aria.Listbox(list);
142
- const hideOnClick = {
143
- name: 'hideOnClick',
144
- defaultValue: true,
145
- fn(instance) {
146
- return {
147
- onCreate() {
148
- buttonListbox.addEventListener("click", (event) => {
149
- if(!buttonListbox.classList.contains('open')){
150
- instance.show();
151
- list.focus()
152
- buttonListbox.classList.add('open');
153
- } else {
154
- list.blur();
155
- instance.hide();
156
- }
157
- });
158
- },
159
- };
160
- },
161
- };
162
- const hideOnPopperBlur = {
163
- /* https://atomiks.github.io/tippyjs/v6/plugins/#hideonpopperblur */
164
- name: 'hideOnPopperBlur',
165
- defaultValue: true,
166
- fn(instance) {
167
- return {
168
- onCreate() {
169
- instance.popper.addEventListener('focusout', (event) => {
170
- if (
171
- instance.props.hideOnPopperBlur &&
172
- event.relatedTarget &&
173
- !instance.popper.contains(event.relatedTarget)
174
- ) {
175
- instance.hide();
176
- }
177
- });
178
- },
179
- };
180
- },
181
- };
182
- const hideOnEscOrEnter = {
183
- /* https://atomiks.github.io/tippyjs/v6/plugins/#hideonesc */
184
- name: 'hideOnEsc',
185
- defaultValue: true,
186
- fn({hide}) {
187
- function onKeyDown(event) {
188
- if ((event.keyCode === 27)||(event.keyCode === 13)) {
189
- hide();
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
- return {
194
- onShow() {
195
- document.addEventListener('keydown', onKeyDown);
196
- },
197
- onHide() {
198
- document.removeEventListener('keydown', onKeyDown);
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
- listbox.setHandleFocusChange(function(evt){
231
- if ((!list.hasAttribute('aria-multiselectable')) && (buttonListbox.getAttribute('data-change')=='change')){
232
- buttonListbox.firstElementChild.innerHTML = evt.innerHTML;
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
- const getMultiSelectable = buttonListbox.getAttribute('aria-labelledby');
237
- const allowMultiple = getMultiSelectable.includes('is-multiselectable-label');
253
+ const getMultiSelectable = buttonListbox.getAttribute('aria-labelledby');
254
+ const allowMultiple = getMultiSelectable.includes('is-multiselectable-label');
238
255
 
239
- if(!allowMultiple) {
240
- list.addEventListener("click", (event) => {
241
- buttonListbox.click();
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) if (modules.hasOwnProperty(item)) {
281
- const moduleValue = modules[item].getAttribute('data-module');
282
-
283
-
284
- if (moduleValue == 'c-tooltip'){
285
- const tooltipButton = modules[item].querySelector('[data-module = "c-tooltip-button"]');
286
- const ariaContent = tooltipButton.matches('[data-type = "c-tooltip-button-complex"]') ? 'describedby' : 'labelledby';
287
- const tooltipTooltip = modules[item].querySelector('[data-module = "c-tooltip-tooltip"]');
288
- if(tooltipButton && tooltipTooltip) {
289
- const hideOnPopperBlur = {
290
- /* https://atomiks.github.io/tippyjs/v6/plugins/#hideonpopperblur */
291
- name: 'hideOnPopperBlur',
292
- defaultValue: true,
293
- fn(instance) {
294
- return {
295
- onCreate() {
296
- instance.popper.addEventListener('focusout', (event) => {
297
- if (
298
- instance.props.hideOnPopperBlur &&
299
- event.relatedTarget &&
300
- !instance.popper.contains(event.relatedTarget)
301
- ) {
302
- instance.hide();
303
- }
304
- });
305
- },
306
- };
307
- },
308
- };
309
- const hideOnEsc = {
310
- /* https://atomiks.github.io/tippyjs/v6/plugins/#hideonesc */
311
- name: 'hideOnEsc',
312
- defaultValue: true,
313
- fn({hide}) {
314
- function onKeyDown(event) {
315
- if (event.keyCode === 27) {
316
- hide();
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
- return {
321
- onShow() {
322
- document.addEventListener('keydown', onKeyDown);
323
- },
324
- onHide() {
325
- document.removeEventListener('keydown', onKeyDown);
326
- }
327
- };
328
- }
329
- };
330
-
331
- // https://atomiks.github.io/tippyjs/v6/all-props/
332
- tippy(tooltipButton, {
333
- placement: 'top',
334
- inlinePositioning: true,
335
- content: tooltipTooltip,
336
- allowHTML: true, // Make sure you are sanitizing any user data if rendering HTML to prevent XSS attacks.
337
- trigger: 'mouseenter focus',
338
- hideOnClick: false,
339
- theme: '',
340
- plugins: [hideOnEsc,hideOnPopperBlur],
341
- role: 'tooltip',
342
- interactive: true,
343
- aria: {
344
- content: ariaContent
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) if (modules.hasOwnProperty(item)) {
357
- const moduleValue = modules[item].getAttribute('data-module');
383
+ for (const item in modules)
384
+ if (modules.hasOwnProperty(item)) {
385
+ const moduleValue = modules[item].getAttribute('data-module');
358
386
 
359
- if (moduleValue == 'c-tree'){
360
- const tree = new aria.Tree(modules[item]);
361
- tree.init();
362
- }
387
+ if (moduleValue == 'c-tree') {
388
+ const tree = new aria.Tree(modules[item]);
389
+ tree.init();
390
+ }
363
391
 
364
- if (moduleValue == 'c-tree__item'){
365
- modules[item].addEventListener('click', function (event) {
366
- event.stopPropagation();
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 inputInitialValue = inputElement.value;
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
- if(datepickerSelect != undefined) {
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-12";
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
- inputElement.value = inputInitialValue;
469
- datepickerCalendar.tentative ="";
470
- datepickerCalendar.value = datepickerInitialValue;
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-12";
566
+ datepickerCalendar.max = selectedValue + "-12-31";
514
567
  datepickerCalendar.focusedDate = datepickerCalendar.min;
515
568
  });
516
569
  }
@@ -1,6 +1,8 @@
1
1
  function filtercaller (params) {
2
- delete params.caller;
3
- return params
2
+ const newParams = {};
3
+ for(var k in params) newParams[k]=params[k];
4
+ delete newParams.caller;
5
+ return newParams;
4
6
  }
5
7
 
6
8
  export default filtercaller;
@@ -0,0 +1,7 @@
1
+ function filterescapeltgt(str) {
2
+ if (typeof str !== 'string' && typeof str !== 'object') return str;
3
+ if (typeof str !== 'string') str = JSON.stringify(str);
4
+ return str.replace(/</g, '&lt;').replace(/>/g, '&gt;');
5
+ }
6
+
7
+ export default filterescapeltgt;
@@ -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;
@@ -0,0 +1,8 @@
1
+
2
+ import { readFileSync } from 'fs';
3
+ import { join } from 'path';
4
+
5
+ export default function() {
6
+ const pkg = JSON.parse(readFileSync(join(process.cwd(), 'package.json'), 'utf8'));
7
+ return pkg.version;
8
+ }
@@ -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
  };