desy-html 11.2.0 → 12.0.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.
- 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 +14 -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/docs/_global.foot.njk
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{% from "components/footer/_macro.footer.njk" import componentFooter %}
|
|
2
2
|
{{ componentFooter({
|
|
3
3
|
"meta": {
|
|
4
|
-
"html":
|
|
4
|
+
"html": "Creado por <a href='https://sda.aragon.es/' class='c-link c-link--neutral'>SDA Servicios Digitales de Aragón</a>"
|
|
5
5
|
},
|
|
6
6
|
"classes": "lg:mt-48"
|
|
7
7
|
}) }}
|
|
@@ -117,29 +117,72 @@ import componentTree %}
|
|
|
117
117
|
|
|
118
118
|
<div>
|
|
119
119
|
<h1 class="c-h1">{{ exampleComponent | capitalize }}</h1>
|
|
120
|
-
{%
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
120
|
+
{% from "_macro.load-component-params.njk" import loadComponentParams %}
|
|
121
|
+
<div class="sr-only">
|
|
122
|
+
<h2 class="mb-sm font-bold">Parámetros Nunjucks del componente<span class="sr-only">: "{{ exampleComponent | capitalize }}". Versión: {{ '' | filterversion }}</span></h2>
|
|
123
|
+
<p>Los parámetros de Nunjucks para este componente están dentro de la siguiente etiqueta code en formato yaml.</p>
|
|
124
|
+
<pre>
|
|
125
|
+
<code class="language-yaml hljs text-sm">{{ loadComponentParams(exampleComponent) | filterescapeltgt }}</code>
|
|
126
|
+
</pre>
|
|
127
|
+
</div>
|
|
128
|
+
<div aria-hidden="true">
|
|
129
|
+
{% call componentDetails({
|
|
130
|
+
"summary": {
|
|
131
|
+
"html": "Mostrar parámetros",
|
|
132
|
+
"classes": "c-link text-sm"
|
|
133
|
+
}
|
|
134
|
+
}) %}
|
|
135
|
+
<div class="c-markup">
|
|
136
|
+
<div class="py-base">
|
|
137
|
+
<h2 class="mb-sm font-bold">Parámetros Nunjucks del componente<span class="sr-only">: "{{ exampleComponent | capitalize }}"</span></h2>
|
|
130
138
|
<pre>
|
|
131
139
|
<code class="language-yaml hljs text-sm">{{ loadComponentParams(exampleComponent) | highlight("yaml") | safe }}
|
|
132
140
|
</code>
|
|
133
141
|
</pre>
|
|
142
|
+
</div>
|
|
134
143
|
</div>
|
|
135
|
-
|
|
136
|
-
|
|
144
|
+
{% endcall %}
|
|
145
|
+
</div>
|
|
137
146
|
</div>
|
|
138
147
|
{% for example in examples %}
|
|
139
|
-
<
|
|
148
|
+
<article class="grid grid-cols-1 gap-x-xl mt-xl">
|
|
140
149
|
<div class="pt-xl">
|
|
141
150
|
<h3 id="{{ example.name |filterslugify }}" class="c-h3 group">{{ example.name | capitalize }} <a href="#{{ example.name |filterslugify }}" class="hidden font-semibold text-neutral-base underline group-hover:inline-block">#</a></h3>
|
|
142
151
|
<p class="c-paragraph-base mb-0">{{ example.description | safe }}</p>
|
|
152
|
+
<div class="sr-only">
|
|
153
|
+
<h4>Ejemplo: "{{ example.name | capitalize }}", de código HTML, para maquetar el componente: "{{ exampleComponent | replace("-", " ") | title }}", versión: {{ '' | filterversion }}, del sistema de diseño DESY</h4>
|
|
154
|
+
<p>Para compilar el css del siguiente código deberás instalar Tailwind CSS y usar el archivo tailwind.config.js del proyecto: <a href="https://bitbucket.org/sdaragon/desy-html/src/master/">desy-html</a>.</p>
|
|
155
|
+
<p>Para que funcione el comportamiento del siguiente código deberás importar el archivo index.js y todos los archivos javascript de la carpeta /src/js y /src/js/aria del proyecto: <a href="https://bitbucket.org/sdaragon/desy-html/src/master/">desy-html</a>.</p>
|
|
156
|
+
<p>Usar sólo el código que está dentro de la siguiente etiqueta <code>.</p>
|
|
157
|
+
<pre><code class="language-html hljs text-sm" data-desy-html-version="{{ '' | filterversion }}">
|
|
158
|
+
{{- getHTMLCodeFromExample(exampleComponent, example.data, 'component') -}}
|
|
159
|
+
</code>
|
|
160
|
+
</pre>
|
|
161
|
+
</div>
|
|
162
|
+
{% if example.data.caller %}
|
|
163
|
+
{% from "_macro.render-caller.njk" import renderCaller %}
|
|
164
|
+
{% set callerHtml %}{{ renderCaller(example.data.caller) }}{% endset %}
|
|
165
|
+
{% set callerNunjucks %}
|
|
166
|
+
{% raw %}{%{% endraw %} from "components/{{ exampleComponent }}/_macro.{{ exampleComponent }}.njk" import component{{ exampleComponent | replace("-", " ") | title | replace(" ","") }}{% raw %} %}{% endraw %}
|
|
167
|
+
{% raw %}{% {% endraw %}call component{{ exampleComponent | replace("-", " ") | title | replace(" ","") }} {% endset %}
|
|
168
|
+
<div class="sr-only">
|
|
169
|
+
<h4>Ejemplo: "{{ example.name | capitalize }}", de código Nunjucks, para maquetar el componente: "{{ exampleComponent | replace("-", " ") | title }}", versión: {{ '' | filterversion }}, del sistema de diseño DESY</h4>
|
|
170
|
+
<p>Pegar en la página: pagina-prueba.html del proyecto: <a href="https://bitbucket.org/sdaragon/desy-html-starter/src/master/">desy-html-starter</a>.</p>
|
|
171
|
+
<p>Usar sólo el código que está dentro de la siguiente etiqueta <code>.</p>
|
|
172
|
+
<pre><code class="language-js hljs text-sm" data-desy-html-version="{{ '' | filterversion }}">
|
|
173
|
+
{{ callerNunjucks | safe }}({{ example.data | filtercaller | filterescapeltgt | dump(2) | safe }}){% raw %} %}{% endraw %}
|
|
174
|
+
{{ callerHtml }}
|
|
175
|
+
{% raw %}{%{% endraw %} endcall {% raw %} %}{% endraw %}</code></pre>
|
|
176
|
+
|
|
177
|
+
</div>
|
|
178
|
+
{% else %}
|
|
179
|
+
<div class="sr-only">
|
|
180
|
+
<h4>Ejemplo: "{{ example.name | capitalize }}", de código Nunjucks, para maquetar el componente: "{{ exampleComponent | replace("-", " ") | title }}", versión: {{ '' | filterversion }}, del sistema de diseño DESY</h4>
|
|
181
|
+
<p>Pegar en la página: pagina-prueba.html del proyecto: <a href="https://bitbucket.org/sdaragon/desy-html-starter/src/master/">desy-html-starter</a>.</p>
|
|
182
|
+
<p>Usar sólo el código que está dentro de la siguiente etiqueta <code>.</p>
|
|
183
|
+
<pre><code class="language-njk hljs text-sm" data-desy-html-version="{{ '' | filterversion }}">{{- getNunjucksCodeFromExample(exampleComponent, example.data, 'component') | filterescapeltgt | safe -}}</code></pre>
|
|
184
|
+
</div>
|
|
185
|
+
{% endif %}
|
|
143
186
|
</div>
|
|
144
187
|
<div class="pt-base lg:pt-lg">
|
|
145
188
|
<div class="p-base border border-neutral-base">
|
|
@@ -260,13 +303,13 @@ import componentTree %}
|
|
|
260
303
|
<div class="pt-base lg:pt-lg mb-base">
|
|
261
304
|
{% set htmlContent %}
|
|
262
305
|
{{ componentButton({
|
|
263
|
-
"
|
|
306
|
+
"html": 'Copiar código<span class="sr-only"> HTML</span>',
|
|
264
307
|
"classes": "c-button--sm c-button--transparent mb-sm",
|
|
265
308
|
"attributes": {
|
|
266
309
|
"data-module": "c-button-copy"
|
|
267
310
|
}
|
|
268
311
|
}) }}
|
|
269
|
-
<pre class="hljs"><code class="language-html hljs text-sm">
|
|
312
|
+
<pre class="hljs" aria-hidden="true"><code class="language-html hljs text-sm">
|
|
270
313
|
{{- getHTMLCodeFromExample(exampleComponent, example.data, 'component') | highlight("html") | safe -}}
|
|
271
314
|
</code>
|
|
272
315
|
</pre>
|
|
@@ -279,7 +322,7 @@ import componentTree %}
|
|
|
279
322
|
{% raw %}{%{% endraw %} from "components/{{ exampleComponent }}/_macro.{{ exampleComponent }}.njk" import component{{ exampleComponent | replace("-", " ") | title | replace(" ","") }}{% raw %} %}{% endraw %}
|
|
280
323
|
{% raw %}{% {% endraw %}call component{{ exampleComponent | replace("-", " ") | title | replace(" ","") }} {% endset %}
|
|
281
324
|
{{ componentButton({
|
|
282
|
-
"
|
|
325
|
+
"html": 'Copiar código<span class="sr-only"> Nunjucks</span>',
|
|
283
326
|
"classes": "c-button--sm c-button--transparent mb-sm",
|
|
284
327
|
"attributes": {
|
|
285
328
|
"data-module": "c-button-copy"
|
|
@@ -291,7 +334,7 @@ import componentTree %}
|
|
|
291
334
|
{% raw %}{%{% endraw %} endcall {% raw %} %}{% endraw %}</code></pre>
|
|
292
335
|
{% else %}
|
|
293
336
|
{{ componentButton({
|
|
294
|
-
"
|
|
337
|
+
"html": 'Copiar código<span class="sr-only"> Nunjucks</span>',
|
|
295
338
|
"classes": "c-button--sm c-button--transparent mb-sm",
|
|
296
339
|
"attributes": {
|
|
297
340
|
"data-module": "c-button-copy"
|
|
@@ -307,6 +350,7 @@ import componentTree %}
|
|
|
307
350
|
}
|
|
308
351
|
}) %}
|
|
309
352
|
{{ componentTabs({
|
|
353
|
+
"headingLevel": 4,
|
|
310
354
|
"tablistAriaLabel": "Ejemplos de código de: " + example.name | capitalize,
|
|
311
355
|
"idPrefix": "tab-" + loop.index,
|
|
312
356
|
"classes": "c-tabs--scroll",
|
|
@@ -327,6 +371,6 @@ import componentTree %}
|
|
|
327
371
|
}) }}
|
|
328
372
|
{% endcall %}
|
|
329
373
|
</div>
|
|
330
|
-
</
|
|
374
|
+
</article>
|
|
331
375
|
{% endfor %}
|
|
332
376
|
{% endmacro %}
|
|
@@ -215,7 +215,7 @@
|
|
|
215
215
|
<p>Esto es un <a href="#" class="c-link c-link--no-underline">enlace</a> sin subrayado (sólo en hover).</p>
|
|
216
216
|
</dt>
|
|
217
217
|
<dd class="col-span-2 lg:col-span-2">
|
|
218
|
-
<p class="text-neutral-dark text-sm"><code>.c-link.c-link--no-underline</code> - <code>normal</code> - <code>no-underline</code> - <code>text-
|
|
218
|
+
<p class="text-neutral-dark text-sm"><code>.c-link.c-link--no-underline</code> - <code>normal</code> - <code>no-underline</code> - <code>text-primary-base</code> - hover: <code>primary-dark.underline</code></p>
|
|
219
219
|
</dd>
|
|
220
220
|
</dl>
|
|
221
221
|
</li>
|
package/docs/index.html
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
<div class="prose pb-xl">
|
|
8
8
|
<div class="pb-lg"></div>
|
|
9
9
|
<h1>desy-html</h1>
|
|
10
|
+
<p>Versión: {{ '' | filterversion }}</p>
|
|
10
11
|
<p>desy-html es una librería NPM que sirve para construir la interfaz de usuario de las aplicaciones web del Gobierno de Aragón. Utiliza <a href="https://gulpjs.com/">Gulp</a>, <a href="https://postcss.org/">PostCSS</a>, <a href="https://tailwindcss.com/">Tailwind CSS</a> y <a href="https://mozilla.github.io/nunjucks/">Nunjucks</a> para renderizar componentes HTML+CSS+JS. Es útil para crear aplicaciones web ligeras o maquetas html.</p>
|
|
11
12
|
<p>Si necesitas una librería con más potencia para construir tu aplicación web, te recomendamos mejor, que uses su versión traducida a Angular: <a href="https://bitbucket.org/sdaragon/desy-angular">desy-angular librería NPM</a>, <a href="https://desy.aragon.es/desy-angular">Ejemplos de desy-angular</a></p>
|
|
12
13
|
<p>Mira ejemplos de componentes y plantillas de página en la documentación: <a href="https://desy.aragon.es/">https://desy.aragon.es/</a></p>
|
|
@@ -38,6 +39,19 @@
|
|
|
38
39
|
|
|
39
40
|
<h2>Changelog (English)</h2>
|
|
40
41
|
<p>What's new in the latest version of desy-html</p>
|
|
42
|
+
<h3>v.12.0.1</h3>
|
|
43
|
+
<ul class="text-sm">
|
|
44
|
+
<li>Minor fixes.</li>
|
|
45
|
+
</ul>
|
|
46
|
+
<h3>v.12.0.0</h3>
|
|
47
|
+
<ul class="text-sm">
|
|
48
|
+
<li>Datepicker now uses Spanish date format: DD-MM-AAAA.</li>
|
|
49
|
+
<li>Dropdowns that has no menu, now has the correct arias using data attributes.</li>
|
|
50
|
+
<li>Accesibility fixes in Header mini, Datepicker, Dropdown, Tooltip and Links list.</li>
|
|
51
|
+
<li>Docs examples in Nunjucks have single quotes in attributes instead of escaped double quotes.</li>
|
|
52
|
+
<li>Docs improvements for AI and robots.</li>
|
|
53
|
+
<li>Validation fixes.</li>
|
|
54
|
+
</ul>
|
|
41
55
|
<h3>v.11.2.0</h3>
|
|
42
56
|
<ul class="text-sm">
|
|
43
57
|
<li>Added global function to Links list and Tree navigation to activate items.</li>
|
package/docs/pagina-prueba.html
CHANGED
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"text": "Ejemplo de modal"
|
|
48
48
|
},
|
|
49
49
|
"description": {
|
|
50
|
-
"html":
|
|
50
|
+
"html": ""
|
|
51
51
|
},
|
|
52
52
|
"itemsPrimary": [
|
|
53
53
|
{
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
],
|
|
58
58
|
"itemsSecondary": [
|
|
59
59
|
{
|
|
60
|
-
"html":
|
|
60
|
+
"html": "Cancelar <span class='sr-only'>y cerrar la ventana modal</span>",
|
|
61
61
|
"attributes": {
|
|
62
62
|
"onclick": "closeDialog(this)"
|
|
63
63
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "desy-html",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "12.0.1",
|
|
4
4
|
"description": "desy-html contains the code you need to start building a user interface for Gobierno de Aragón government webapps.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": {
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"autoprefixer": "^10.4.19",
|
|
39
39
|
"hex-rgb": "^5.0.0",
|
|
40
40
|
"highlight.js": "^11.9.0",
|
|
41
|
-
"postcss": "^8.
|
|
41
|
+
"postcss": "^8.5.0",
|
|
42
42
|
"postcss-cli": "^10.1.0",
|
|
43
43
|
"postcss-import": "^15.1.0",
|
|
44
44
|
"tailwindcss": "^3.4.15"
|
package/src/js/aria/utils.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
1
|
export function utils(aria) {
|
|
3
2
|
/**
|
|
4
3
|
* @namespace aria
|
|
@@ -29,7 +28,7 @@ export function utils(aria) {
|
|
|
29
28
|
|
|
30
29
|
|
|
31
30
|
// Polyfill src https://developer.mozilla.org/en-US/docs/Web/API/Element/matches
|
|
32
|
-
aria.Utils.matches = function
|
|
31
|
+
aria.Utils.matches = function(element, selector) {
|
|
33
32
|
if (!Element.prototype.matches) {
|
|
34
33
|
Element.prototype.matches =
|
|
35
34
|
Element.prototype.matchesSelector ||
|
|
@@ -37,7 +36,7 @@ export function utils(aria) {
|
|
|
37
36
|
Element.prototype.msMatchesSelector ||
|
|
38
37
|
Element.prototype.oMatchesSelector ||
|
|
39
38
|
Element.prototype.webkitMatchesSelector ||
|
|
40
|
-
function
|
|
39
|
+
function(s) {
|
|
41
40
|
var matches = element.parentNode.querySelectorAll(s);
|
|
42
41
|
var i = matches.length;
|
|
43
42
|
while (--i >= 0 && matches.item(i) !== this) {}
|
|
@@ -48,19 +47,19 @@ export function utils(aria) {
|
|
|
48
47
|
return element.matches(selector);
|
|
49
48
|
};
|
|
50
49
|
|
|
51
|
-
aria.Utils.remove = function
|
|
50
|
+
aria.Utils.remove = function(item) {
|
|
52
51
|
if (item.remove && typeof item.remove === 'function') {
|
|
53
52
|
return item.remove();
|
|
54
53
|
}
|
|
55
54
|
if (item.parentNode &&
|
|
56
|
-
|
|
57
|
-
|
|
55
|
+
item.parentNode.removeChild &&
|
|
56
|
+
typeof item.parentNode.removeChild === 'function') {
|
|
58
57
|
return item.parentNode.removeChild(item);
|
|
59
58
|
}
|
|
60
59
|
return false;
|
|
61
60
|
};
|
|
62
61
|
|
|
63
|
-
aria.Utils.isFocusable = function
|
|
62
|
+
aria.Utils.isFocusable = function(element) {
|
|
64
63
|
if (element.tabIndex > 0 || (element.tabIndex === 0 && element.getAttribute('tabIndex') !== null)) {
|
|
65
64
|
return true;
|
|
66
65
|
}
|
|
@@ -83,7 +82,7 @@ export function utils(aria) {
|
|
|
83
82
|
}
|
|
84
83
|
};
|
|
85
84
|
|
|
86
|
-
aria.Utils.getAncestorBySelector = function
|
|
85
|
+
aria.Utils.getAncestorBySelector = function(element, selector) {
|
|
87
86
|
if (!aria.Utils.matches(element, selector + ' ' + element.tagName)) {
|
|
88
87
|
// Element is not inside an element that matches selector
|
|
89
88
|
return null;
|
|
@@ -95,8 +94,7 @@ export function utils(aria) {
|
|
|
95
94
|
while (ancestor === null) {
|
|
96
95
|
if (aria.Utils.matches(currentNode.parentNode, selector)) {
|
|
97
96
|
ancestor = currentNode.parentNode;
|
|
98
|
-
}
|
|
99
|
-
else {
|
|
97
|
+
} else {
|
|
100
98
|
currentNode = currentNode.parentNode;
|
|
101
99
|
}
|
|
102
100
|
}
|
|
@@ -104,25 +102,92 @@ export function utils(aria) {
|
|
|
104
102
|
return ancestor;
|
|
105
103
|
};
|
|
106
104
|
|
|
107
|
-
aria.Utils.hasClass = function
|
|
105
|
+
aria.Utils.hasClass = function(element, className) {
|
|
108
106
|
return (new RegExp('(\\s|^)' + className + '(\\s|$)')).test(element.className);
|
|
109
107
|
};
|
|
110
108
|
|
|
111
|
-
aria.Utils.addClass = function
|
|
109
|
+
aria.Utils.addClass = function(element, className) {
|
|
112
110
|
if (!aria.Utils.hasClass(element, className)) {
|
|
113
111
|
element.className += ' ' + className;
|
|
114
112
|
}
|
|
115
113
|
};
|
|
116
114
|
|
|
117
|
-
aria.Utils.removeClass = function
|
|
115
|
+
aria.Utils.removeClass = function(element, className) {
|
|
118
116
|
var classRegex = new RegExp('(\\s|^)' + className + '(\\s|$)');
|
|
119
117
|
element.className = element.className.replace(classRegex, ' ').trim();
|
|
120
118
|
};
|
|
121
119
|
|
|
122
|
-
aria.Utils.bindMethods = function
|
|
120
|
+
aria.Utils.bindMethods = function(object /* , ...methodNames */ ) {
|
|
123
121
|
var methodNames = Array.prototype.slice.call(arguments, 1);
|
|
124
|
-
methodNames.forEach(function
|
|
122
|
+
methodNames.forEach(function(method) {
|
|
125
123
|
object[method] = object[method].bind(object);
|
|
126
124
|
});
|
|
127
125
|
};
|
|
128
126
|
}
|
|
127
|
+
|
|
128
|
+
// Function to convert ISO date(s) to DD-MM-YYYY format
|
|
129
|
+
export function formatDateToDDMMYYYY(isoDate) {
|
|
130
|
+
if (!isoDate) return '';
|
|
131
|
+
try {
|
|
132
|
+
// Case 1: Multiple dates separated by space
|
|
133
|
+
if (isoDate.includes(' ')) {
|
|
134
|
+
return isoDate
|
|
135
|
+
.split(' ')
|
|
136
|
+
.map(date => formatSingleDate(date))
|
|
137
|
+
.join(' ');
|
|
138
|
+
}
|
|
139
|
+
// Case 2: Date range separated by /
|
|
140
|
+
if (isoDate.includes('/')) {
|
|
141
|
+
const [startDate, endDate] = isoDate.split('/');
|
|
142
|
+
return `${formatSingleDate(startDate)}/${formatSingleDate(endDate)}`;
|
|
143
|
+
}
|
|
144
|
+
// Case 3: Single date
|
|
145
|
+
return formatSingleDate(isoDate);
|
|
146
|
+
} catch (error) {
|
|
147
|
+
console.error('Error formatting date:', error);
|
|
148
|
+
return '';
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
// Helper function to format a single date
|
|
153
|
+
export function formatSingleDate(isoDate) {
|
|
154
|
+
const date = new Date(isoDate);
|
|
155
|
+
if (isNaN(date.getTime())) {
|
|
156
|
+
return '';
|
|
157
|
+
}
|
|
158
|
+
const day = String(date.getDate()).padStart(2, '0');
|
|
159
|
+
const month = String(date.getMonth() + 1).padStart(2, '0');
|
|
160
|
+
const year = date.getFullYear();
|
|
161
|
+
return `${day}-${month}-${year}`;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// Function to convert DD-MM-YYYY format to ISO
|
|
165
|
+
export function convertToISOFormat(ddmmyyyyDate) {
|
|
166
|
+
if (!ddmmyyyyDate) return '';
|
|
167
|
+
try {
|
|
168
|
+
// For multiple dates
|
|
169
|
+
if (ddmmyyyyDate.includes(' ')) {
|
|
170
|
+
return ddmmyyyyDate
|
|
171
|
+
.split(' ')
|
|
172
|
+
.map(date => convertSingleDateToISO(date))
|
|
173
|
+
.join(' ');
|
|
174
|
+
}
|
|
175
|
+
// For date ranges
|
|
176
|
+
if (ddmmyyyyDate.includes('/')) {
|
|
177
|
+
const [startDate, endDate] = ddmmyyyyDate.split('/');
|
|
178
|
+
return `${convertSingleDateToISO(startDate)}/${convertSingleDateToISO(endDate)}`;
|
|
179
|
+
}
|
|
180
|
+
// For single date
|
|
181
|
+
return convertSingleDateToISO(ddmmyyyyDate);
|
|
182
|
+
} catch (error) {
|
|
183
|
+
console.error('Error converting to ISO format:', error);
|
|
184
|
+
return '';
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
// Helper function to convert a single date to ISO
|
|
189
|
+
function convertSingleDateToISO(ddmmyyyyDate) {
|
|
190
|
+
if (!ddmmyyyyDate) return '';
|
|
191
|
+
const [day, month, year] = ddmmyyyyDate.split('-');
|
|
192
|
+
return `${year}-${month}-${day}`;
|
|
193
|
+
}
|