desy-html 8.13.1 → 9.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.
@@ -0,0 +1,347 @@
1
+ {% from "components/button/_macro.button.njk" import componentButton %}
2
+ {% from "components/select/_macro.select.njk" import componentSelect %}
3
+
4
+ {% macro headingYears(id='id') %}
5
+ <div slot="heading" class="order-first w-full flex justify-center">
6
+ {{ componentSelect({
7
+ "id": "select-years-" + id,
8
+ "name": "select-years-" + id,
9
+ "formGroup": {
10
+ "classes": "-mb-12"
11
+ },
12
+ "classes": "c-select--sm w-full",
13
+ "label": {
14
+ "text": "Selecciona año",
15
+ "classes": "text-sm"
16
+ },
17
+ "items": [
18
+ {
19
+ "value": 2024,
20
+ "text": "2024",
21
+ "selected": true
22
+ },
23
+ {
24
+ "value": 2025,
25
+ "text": "2025"
26
+ },
27
+ {
28
+ "value": 2026,
29
+ "text": "2026"
30
+ }
31
+ ]
32
+ }) }}
33
+ </div>
34
+ {% endmacro %}
35
+
36
+ {% set buttonLeft %}
37
+ <div slot="previous">
38
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" height="1em" width="1em" class="self-center my-1" focusable="false" role="img" aria-label="Mes anterior"><path d="M4.00001 7.97945C4.00001 7.63023 4.14967 7.3309 4.39911 7.13135L9.93669 2.19243C10.3358 1.8931 10.9345 1.94298 11.2338 2.34209C11.5331 2.74119 11.5331 3.28996 11.134 3.58929L6.24497 7.87967C6.19508 7.92956 6.19508 7.97945 6.24497 8.07922L11.134 12.3696C11.5331 12.7188 11.583 13.2676 11.2338 13.6667C10.8846 14.0658 10.3358 14.1157 9.93669 13.7665C9.93669 13.7665 9.93669 13.7665 9.8868 13.7166L4.34922 8.82754C4.14967 8.62799 4.00001 8.27877 4.00001 7.97945Z" fill="currentColor"></path></svg>
39
+ </div>
40
+ {% endset %}
41
+
42
+ {% set buttonRight %}
43
+ <div slot="next">
44
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" height="1em" width="1em" class="self-center my-1" focusable="false" role="img" aria-label="Mes siguiente"><path d="M11.4673 8.02055C11.4673 8.36977 11.3176 8.6691 11.0682 8.86865L5.53062 13.8076C5.13152 14.1069 4.53286 14.057 4.23353 13.6579C3.9342 13.2588 3.9342 12.71 4.33331 12.4107L9.22234 8.12033C9.27223 8.07044 9.27223 8.02055 9.22234 7.92078L4.33331 3.6304C3.9342 3.28118 3.88432 2.73241 4.23353 2.33331C4.58275 1.9342 5.13152 1.88432 5.53062 2.23353C5.53062 2.23353 5.53062 2.23353 5.58051 2.28342L11.1181 7.17246C11.3176 7.37201 11.4673 7.72123 11.4673 8.02055Z" fill="currentColor"></path></svg>
45
+ </div>
46
+ {% endset %}
47
+
48
+ {% set calendarDateExample %}
49
+ <calendar-date
50
+ min="2024-01-01"
51
+ max="2024-12-31"
52
+ locale="es-ES"
53
+ >
54
+ {{ buttonLeft | safe }}
55
+ {{ buttonRight | safe }}
56
+ <div class="flex flex-wrap justify-center gap-lg">
57
+ <calendar-month></calendar-month>
58
+ </div>
59
+ </calendar-date>
60
+ {% endset %}
61
+
62
+ {% macro calendarDateYearsExample(id='id') %}
63
+ <calendar-date
64
+ value="2024-01-10"
65
+ min="2024-01-01"
66
+ max="2024-12-31"
67
+ locale="es-ES"
68
+ >
69
+ {{ buttonLeft | safe }}
70
+ {{ buttonRight | safe }}
71
+ {{ headingYears(id) | safe }}
72
+ <div class="flex flex-wrap justify-center gap-lg">
73
+ <calendar-month></calendar-month>
74
+ </div>
75
+ </calendar-date>
76
+ {% endmacro %}
77
+
78
+ {% set calendarMultiExample %}
79
+ <calendar-multi
80
+ value="2024-01-10 2024-01-20"
81
+ min="2024-01-01"
82
+ max="2024-12-31"
83
+ locale="es-ES"
84
+ >
85
+ {{ buttonLeft | safe }}
86
+ {{ buttonRight | safe }}
87
+ <div class="flex flex-wrap justify-center gap-lg">
88
+ <calendar-month></calendar-month>
89
+ </div>
90
+ </calendar-multi>
91
+ {% endset %}
92
+
93
+ {% set calendarRangeExample %}
94
+ <calendar-range
95
+ value="2024-01-10/2024-01-20"
96
+ min="2024-01-01"
97
+ max="2024-12-31"
98
+ locale="es-ES"
99
+ >
100
+ {{ buttonLeft | safe }}
101
+ {{ buttonRight | safe }}
102
+ <div class="flex flex-wrap justify-center gap-lg">
103
+ <calendar-month></calendar-month>
104
+ </div>
105
+ </calendar-range>
106
+ {% endset %}
107
+
108
+ {% macro calendarRangeExample2(id='id') %}
109
+ <calendar-range
110
+ months="2"
111
+ value="2024-01-16/2024-02-04"
112
+ min="2024-01-01"
113
+ max="2024-12-31"
114
+ locale="es-ES"
115
+ >
116
+ {{ buttonLeft | safe }}
117
+ {{ buttonRight | safe }}
118
+ {{ headingYears(id) | safe }}
119
+ <div class="flex flex-wrap justify-center gap-lg">
120
+ <calendar-month></calendar-month>
121
+ <calendar-month offset="1"></calendar-month>
122
+ </div>
123
+ </calendar-range>
124
+ {% endmacro %}
125
+
126
+ {% set exampleComponent = "datepicker" %}
127
+ {% set examples = [
128
+ {
129
+ "name": "standalone fecha única",
130
+ "description": 'Usa el parámetro <code>standalone: true</code> para mostrar solo el calendario sin el input. Usa la documentación de la librería <a href="https://wicky.nillia.ms/cally/" class="c-link" title="Se abre en ventana nueva" target="_blank">Cally<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" height="0.8em" width="0.8em" class="inline-block mx-xs no-underline align-baseline" aria-hidden="true" focusable="false" role="img"><g><path fill="currentcolor" fill-rule="evenodd" d="M7.428571428571428 0.5714285714285714c-0.6311885714285713 0 -1.1428571428571428 0.5116742857142856 -1.1428571428571428 1.1428571428571428 0 0.6311771428571428 0.5116685714285714 1.1428571428571428 1.1428571428571428 1.1428571428571428h4.098057142857143L0.9061634285714285 13.477599999999999c-0.4463131428571428 0.4462857142857143 -0.4463131428571428 1.1699428571428572 0 1.6162285714285711 0.4463165714285714 0.4462857142857143 1.1699279999999999 0.4462857142857143 1.616248 0L13.142857142857142 4.473382857142857V8.571428571428571c0 0.6311771428571428 0.5116571428571428 1.1428571428571428 1.1428571428571428 1.1428571428571428s1.1428571428571428 -0.51168 1.1428571428571428 -1.1428571428571428v-6.857142857142857c0 -0.6311828571428572 -0.5116571428571428 -1.1428571428571428 -1.1428571428571428 -1.1428571428571428h-6.857142857142857Z" clip-rule="evenodd" stroke-width="1"></path></g></svg></a> para añadir el calendario como un caller de este componente.',
131
+ "data": {
132
+ "id": "datepicker-date",
133
+ "standalone": true,
134
+ "caller": calendarDateExample | safe
135
+ }
136
+ },
137
+ {
138
+ "name": "standalone fecha única y selector de año",
139
+ "description": 'Usa el parámetro <code>standalone: true</code> para mostrar solo el calendario sin el input. Usa la documentación de la librería <a href="https://wicky.nillia.ms/cally/" class="c-link" title="Se abre en ventana nueva" target="_blank">Cally<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" height="0.8em" width="0.8em" class="inline-block mx-xs no-underline align-baseline" aria-hidden="true" focusable="false" role="img"><g><path fill="currentcolor" fill-rule="evenodd" d="M7.428571428571428 0.5714285714285714c-0.6311885714285713 0 -1.1428571428571428 0.5116742857142856 -1.1428571428571428 1.1428571428571428 0 0.6311771428571428 0.5116685714285714 1.1428571428571428 1.1428571428571428 1.1428571428571428h4.098057142857143L0.9061634285714285 13.477599999999999c-0.4463131428571428 0.4462857142857143 -0.4463131428571428 1.1699428571428572 0 1.6162285714285711 0.4463165714285714 0.4462857142857143 1.1699279999999999 0.4462857142857143 1.616248 0L13.142857142857142 4.473382857142857V8.571428571428571c0 0.6311771428571428 0.5116571428571428 1.1428571428571428 1.1428571428571428 1.1428571428571428s1.1428571428571428 -0.51168 1.1428571428571428 -1.1428571428571428v-6.857142857142857c0 -0.6311828571428572 -0.5116571428571428 -1.1428571428571428 -1.1428571428571428 -1.1428571428571428h-6.857142857142857Z" clip-rule="evenodd" stroke-width="1"></path></g></svg></a> para añadir el calendario como un caller de este componente. En este ejemplo hemos personalizado el slot "header" del calendario de Cally para añadirle un componente Select como selector de año.',
140
+ "data": {
141
+ "id": "datepicker-years",
142
+ "standalone": true,
143
+ "caller": calendarDateYearsExample('datepicker-years') | safe
144
+ }
145
+ },
146
+ {
147
+ "name": "standalone fechas múltiples",
148
+ "description": 'Usa el parámetro <code>standalone: true</code> para mostrar solo el calendario sin el input. Usa la documentación de la librería <a href="https://wicky.nillia.ms/cally/" class="c-link" title="Se abre en ventana nueva" target="_blank">Cally<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" height="0.8em" width="0.8em" class="inline-block mx-xs no-underline align-baseline" aria-hidden="true" focusable="false" role="img"><g><path fill="currentcolor" fill-rule="evenodd" d="M7.428571428571428 0.5714285714285714c-0.6311885714285713 0 -1.1428571428571428 0.5116742857142856 -1.1428571428571428 1.1428571428571428 0 0.6311771428571428 0.5116685714285714 1.1428571428571428 1.1428571428571428 1.1428571428571428h4.098057142857143L0.9061634285714285 13.477599999999999c-0.4463131428571428 0.4462857142857143 -0.4463131428571428 1.1699428571428572 0 1.6162285714285711 0.4463165714285714 0.4462857142857143 1.1699279999999999 0.4462857142857143 1.616248 0L13.142857142857142 4.473382857142857V8.571428571428571c0 0.6311771428571428 0.5116571428571428 1.1428571428571428 1.1428571428571428 1.1428571428571428s1.1428571428571428 -0.51168 1.1428571428571428 -1.1428571428571428v-6.857142857142857c0 -0.6311828571428572 -0.5116571428571428 -1.1428571428571428 -1.1428571428571428 -1.1428571428571428h-6.857142857142857Z" clip-rule="evenodd" stroke-width="1"></path></g></svg></a> para añadir el calendario como un caller de este componente. En este ejemplo hemos usado el componente <code>&#x3C;calendar-multi&#x3E;</code> de Cally para se puedan seleccionar múltiples fechas.',
149
+ "data": {
150
+ "id": "datepicker-multi",
151
+ "standalone": true,
152
+ "caller": calendarMultiExample | safe
153
+ }
154
+ },
155
+ {
156
+ "name": "standalone rango de fechas",
157
+ "description": 'Usa el parámetro <code>standalone: true</code> para mostrar solo el calendario sin el input. Usa la documentación de la librería <a href="https://wicky.nillia.ms/cally/" class="c-link" title="Se abre en ventana nueva" target="_blank">Cally<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" height="0.8em" width="0.8em" class="inline-block mx-xs no-underline align-baseline" aria-hidden="true" focusable="false" role="img"><g><path fill="currentcolor" fill-rule="evenodd" d="M7.428571428571428 0.5714285714285714c-0.6311885714285713 0 -1.1428571428571428 0.5116742857142856 -1.1428571428571428 1.1428571428571428 0 0.6311771428571428 0.5116685714285714 1.1428571428571428 1.1428571428571428 1.1428571428571428h4.098057142857143L0.9061634285714285 13.477599999999999c-0.4463131428571428 0.4462857142857143 -0.4463131428571428 1.1699428571428572 0 1.6162285714285711 0.4463165714285714 0.4462857142857143 1.1699279999999999 0.4462857142857143 1.616248 0L13.142857142857142 4.473382857142857V8.571428571428571c0 0.6311771428571428 0.5116571428571428 1.1428571428571428 1.1428571428571428 1.1428571428571428s1.1428571428571428 -0.51168 1.1428571428571428 -1.1428571428571428v-6.857142857142857c0 -0.6311828571428572 -0.5116571428571428 -1.1428571428571428 -1.1428571428571428 -1.1428571428571428h-6.857142857142857Z" clip-rule="evenodd" stroke-width="1"></path></g></svg></a> para añadir el calendario como un caller de este componente. En este ejemplo hemos usado el componente <code>&#x3C;calendar-range&#x3E;</code> de Cally para que tenga un selector de rangos de fecha.',
158
+ "data": {
159
+ "id": "datepicker-range",
160
+ "standalone": true,
161
+ "caller": calendarRangeExample | safe
162
+ }
163
+ },
164
+ {
165
+ "name": "standalone rango de fechas 2 meses y selector de año",
166
+ "description": 'Usa el parámetro <code>standalone: true</code> para mostrar solo el calendario sin el input. Usa la documentación de la librería <a href="https://wicky.nillia.ms/cally/" class="c-link" title="Se abre en ventana nueva" target="_blank">Cally<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" height="0.8em" width="0.8em" class="inline-block mx-xs no-underline align-baseline" aria-hidden="true" focusable="false" role="img"><g><path fill="currentcolor" fill-rule="evenodd" d="M7.428571428571428 0.5714285714285714c-0.6311885714285713 0 -1.1428571428571428 0.5116742857142856 -1.1428571428571428 1.1428571428571428 0 0.6311771428571428 0.5116685714285714 1.1428571428571428 1.1428571428571428 1.1428571428571428h4.098057142857143L0.9061634285714285 13.477599999999999c-0.4463131428571428 0.4462857142857143 -0.4463131428571428 1.1699428571428572 0 1.6162285714285711 0.4463165714285714 0.4462857142857143 1.1699279999999999 0.4462857142857143 1.616248 0L13.142857142857142 4.473382857142857V8.571428571428571c0 0.6311771428571428 0.5116571428571428 1.1428571428571428 1.1428571428571428 1.1428571428571428s1.1428571428571428 -0.51168 1.1428571428571428 -1.1428571428571428v-6.857142857142857c0 -0.6311828571428572 -0.5116571428571428 -1.1428571428571428 -1.1428571428571428 -1.1428571428571428h-6.857142857142857Z" clip-rule="evenodd" stroke-width="1"></path></g></svg></a> para añadir el calendario como un caller de este componente. En este ejemplo hemos usado los componentes <code>&#x3C;calendar-range months="2"&#x3E;</code> y <code>&#x3C;calendar-month offset="1"&#x3E;</code> de Cally para que tenga un selector de rangos de fecha mostrando 2 meses.',
167
+ "data": {
168
+ "id": "datepicker-range2",
169
+ "standalone": true,
170
+ "caller": calendarRangeExample2('datepicker-range2') | safe
171
+ }
172
+ },
173
+ {
174
+ "name": "por defecto",
175
+ "data": {
176
+ "id": "datepicker-default",
177
+ "name": "test-name",
178
+ "label": {
179
+ "text": "Elige fecha de inicio"
180
+ },
181
+ "hint": {
182
+ "html": 'Usa el formato: <span aria-hidden="true">AAAA-MM-DD (año-mes-día)</span><span class="sr-only">año con 4 dígitos, guión simple, mes con dos dígitos, guión simple y día con dos dígitos</span>.'
183
+ },
184
+ "pattern": "(?:19|20)[0-9]{2}-(?:(?:0[1-9]|1[0-2])-(?:0[1-9]|1[0-9]|2[0-9])|(?:(?!02)(?:0[1-9]|1[0-2])-(?:30))|(?:(?:0[13578]|1[02])-31))",
185
+ "caller": calendarDateExample | safe
186
+ }
187
+ },
188
+ {
189
+ "name": "Fechas múltiples",
190
+ "data": {
191
+ "id": "datepicker-with-hint-text",
192
+ "name": "test-name",
193
+ "label": {
194
+ "text": "Elige tus días disponibles"
195
+ },
196
+ "hint": {
197
+ "html": 'Usa el formato: <span aria-hidden="true">AAAA-MM-DD (año-mes-día)</span><span class="sr-only">año con 4 dígitos, guión simple, mes con dos dígitos, guión simple y día con dos dígitos</span>. Separa tus fechas con un espacio.'
198
+ },
199
+ "value": "2024-01-10 2024-01-20",
200
+ "caller": calendarMultiExample | safe
201
+ }
202
+ },
203
+ {
204
+ "name": "Rango de fechas",
205
+ "data": {
206
+ "id": "datepicker-with-hint-text",
207
+ "name": "test-name",
208
+ "label": {
209
+ "text": "Elige tus días disponibles"
210
+ },
211
+ "hint": {
212
+ "html": 'Usa el formato: <span aria-hidden="true">AAAA-MM-DD (año-mes-día)</span><span class="sr-only">año con 4 dígitos, guión simple, mes con dos dígitos, guión simple y día con dos dígitos</span>. Separa la fecha inicial de la final con una barra /.'
213
+ },
214
+ "value": "2024-01-10/2024-01-20",
215
+ "caller": calendarRangeExample | safe
216
+ }
217
+ },
218
+ {
219
+ "name": "Rango de fechas 2 meses y selector de año",
220
+ "data": {
221
+ "id": "datepicker-with-hint-text",
222
+ "name": "test-name",
223
+ "label": {
224
+ "text": "Elige tus días disponibles"
225
+ },
226
+ "hint": {
227
+ "html": 'Usa el formato: <span aria-hidden="true">AAAA-MM-DD (año-mes-día)</span><span class="sr-only">año con 4 dígitos, guión simple, mes con dos dígitos, guión simple y día con dos dígitos</span>. Separa la fecha inicial de la final con una /.'
228
+ },
229
+ "value": "2024-01-16/2024-02-04",
230
+ "caller": calendarRangeExample2('datepicker-with-hint-text') | safe
231
+ }
232
+ },
233
+ {
234
+ "name": "con placeholder y label invisible",
235
+ "data": {
236
+ "id": "datepicker-with-placeholder",
237
+ "name": "test-name",
238
+ "label": {
239
+ "text": "Elige rango de fechas",
240
+ "classes": "sr-only"
241
+ },
242
+ "hint": {
243
+ "html": 'Usa el formato: <span aria-hidden="true">AAAA-MM-DD (año-mes-día)</span><span class="sr-only">año con 4 dígitos, guión simple, mes con dos dígitos, guión simple y día con dos dígitos</span>.',
244
+ "classes": "sr-only"
245
+ },
246
+ "placeholder": "Elige fecha de inicio. Ej.: AAAA-MM-DD",
247
+ "caller": calendarDateExample | safe
248
+ }
249
+ },
250
+ {
251
+ "name": "deshabilitado",
252
+ "data": {
253
+ "id": "datepicker-disabled",
254
+ "name": "test-name",
255
+ "label": {
256
+ "text": "Elige fecha de inicio"
257
+ },
258
+ "hint": {
259
+ "html": 'Usa el formato: <span aria-hidden="true">AAAA-MM-DD (año-mes-día)</span><span class="sr-only">año con 4 dígitos, guión simple, mes con dos dígitos, guión simple y día con dos dígitos</span>.'
260
+ },
261
+ "disabled": true,
262
+ "pattern": "(?:19|20)[0-9]{2}-(?:(?:0[1-9]|1[0-2])-(?:0[1-9]|1[0-9]|2[0-9])|(?:(?!02)(?:0[1-9]|1[0-2])-(?:30))|(?:(?:0[13578]|1[02])-31))",
263
+ "caller": calendarDateExample | safe
264
+ }
265
+ },
266
+ {
267
+ "name": "Con mensaje de error",
268
+ "data": {
269
+ "id": "datepicker-with-error-message",
270
+ "name": "test-name",
271
+ "label": {
272
+ "text": "Elige fecha de inicio"
273
+ },
274
+ "hint": {
275
+ "html": 'Usa el formato: <span aria-hidden="true">AAAA-MM-DD (año-mes-día)</span><span class="sr-only">año con 4 dígitos, guión simple, mes con dos dígitos, guión simple y día con dos dígitos</span>.'
276
+ },
277
+ "errorMessage": {
278
+ "text": "Error: Esto es un mensaje de error",
279
+ "classes": "mt-xs"
280
+ },
281
+ "pattern": "(?:19|20)[0-9]{2}-(?:(?:0[1-9]|1[0-2])-(?:0[1-9]|1[0-9]|2[0-9])|(?:(?!02)(?:0[1-9]|1[0-2])-(?:30))|(?:(?:0[13578]|1[02])-31))",
282
+ "caller": calendarDateExample | safe
283
+ }
284
+ },
285
+ {
286
+ "name": "peque",
287
+ "data": {
288
+ "id": "datepicker-small",
289
+ "name": "test-name",
290
+ "label": {
291
+ "text": "Elige fecha de inicio",
292
+ "classes": "text-sm"
293
+ },
294
+ "hint": {
295
+ "html": 'Usa el formato: <span aria-hidden="true">AAAA-MM-DD (año-mes-día)</span><span class="sr-only">año con 4 dígitos, guión simple, mes con dos dígitos, guión simple y día con dos dígitos</span>.',
296
+ "classes": "text-sm"
297
+ },
298
+ "classes": "c-input--sm",
299
+ "dropdownClasses": "c-dropdown--sm c-dropdown--transparent",
300
+ "pattern": "(?:19|20)[0-9]{2}-(?:(?:0[1-9]|1[0-2])-(?:0[1-9]|1[0-9]|2[0-9])|(?:(?!02)(?:0[1-9]|1[0-2])-(?:30))|(?:(?:0[13578]|1[02])-31))",
301
+ "caller": calendarDateExample | safe
302
+ }
303
+ },
304
+ {
305
+ "name": "Botón personalizado",
306
+ "description": "Añade parámetros del componente Botón para sustituir el icono del calendario con un botón junto al input.",
307
+ "data": {
308
+ "id": "datepicker-with-personalized-button",
309
+ "name": "test-name",
310
+ "label": {
311
+ "text": "Elige fecha de inicio"
312
+ },
313
+ "hint": {
314
+ "html": 'Usa el formato: <span aria-hidden="true">AAAA-MM-DD (año-mes-día)</span><span class="sr-only">año con 4 dígitos, guión simple, mes con dos dígitos, guión simple y día con dos dígitos</span>.'
315
+ },
316
+ "dropdown": {
317
+ "html": 'Seleccionar fecha<span class="sr-only"> con tabla de calendario</span>'
318
+ },
319
+ "classes": "flex-1",
320
+ "pattern": "(?:19|20)[0-9]{2}-(?:(?:0[1-9]|1[0-2])-(?:0[1-9]|1[0-9]|2[0-9])|(?:(?!02)(?:0[1-9]|1[0-2])-(?:30))|(?:(?:0[13578]|1[02])-31))",
321
+ "caller": calendarDateExample | safe
322
+ }
323
+ },
324
+ {
325
+ "name": "Botón personalizado pequeño",
326
+ "description": "Usamos los parámetros del componente Botón para personalizarlo, en este ejemplo botón peque.",
327
+ "data": {
328
+ "id": "datepicker-with-button-small",
329
+ "name": "test-name",
330
+ "label": {
331
+ "text": "Elige fecha de inicio",
332
+ "classes": "text-sm"
333
+ },
334
+ "hint": {
335
+ "html": 'Usa el formato: <span aria-hidden="true">AAAA-MM-DD (año-mes-día)</span><span class="sr-only">año con 4 dígitos, guión simple, mes con dos dígitos, guión simple y día con dos dígitos</span>.',
336
+ "classes": "text-sm"
337
+ },
338
+ "dropdown": {
339
+ "html": 'Seleccionar fecha<span class="sr-only"> con tabla de calendario</span>',
340
+ "classes": "c-dropdown--sm"
341
+ },
342
+ "classes": "flex-1 c-input--sm",
343
+ "pattern": "(?:19|20)[0-9]{2}-(?:(?:0[1-9]|1[0-2])-(?:0[1-9]|1[0-9]|2[0-9])|(?:(?!02)(?:0[1-9]|1[0-2])-(?:30))|(?:(?:0[13578]|1[02])-31))",
344
+ "caller": calendarDateExample | safe
345
+ }
346
+ }
347
+ ] %}
@@ -0,0 +1,3 @@
1
+ {% macro componentDatepicker(params) %}
2
+ {% include "./_template.datepicker.njk" %}
3
+ {% endmacro %}
@@ -0,0 +1,85 @@
1
+ /* ==========================================================================
2
+ _styles.datepicker.css
3
+ ========================================================================== */
4
+
5
+ @layer components {
6
+ .c-datepicker {
7
+ calendar-month {
8
+ --color-accent: theme(colors.primary.base);
9
+ --color-text-on-accent: theme(colors.white);
10
+
11
+ &::part(button){
12
+ @apply mx-px;
13
+ @apply rounded;
14
+
15
+ &:focus-visible {
16
+ @apply focus:bg-warning-base;
17
+ @apply focus:border-warning-base;
18
+ @apply focus:shadow-outline-black;
19
+ @apply focus:text-black;
20
+ @apply focus:outline-none;
21
+ }
22
+ }
23
+ }
24
+
25
+ calendar-date,
26
+ calendar-range,
27
+ calendar-multi {
28
+ &::part(header){
29
+ @apply flex;
30
+ @apply flex-wrap;
31
+ @apply gap-base;
32
+ }
33
+
34
+ &::part(next),
35
+ &::part(previous) {
36
+ @apply inline-flex;
37
+ @apply items-baseline;
38
+ @apply px-3;
39
+ @apply py-2;
40
+ @apply bg-white;
41
+ @apply border;
42
+ @apply border-primary-base;
43
+ @apply rounded;
44
+ @apply align-baseline;
45
+ @apply font-semibold;
46
+ @apply text-primary-base;
47
+ @apply transition-all;
48
+ @apply duration-100;
49
+ @apply ease-out;
50
+ @apply whitespace-nowrap;
51
+ @apply cursor-pointer;
52
+
53
+ @apply focus:bg-warning-base;
54
+ @apply focus:border-warning-base;
55
+ @apply focus:shadow-outline-black;
56
+ @apply focus:text-black;
57
+ @apply focus:outline-none;
58
+
59
+ &:hover:not(disabled),
60
+ &:active:not(disabled) {
61
+ @apply bg-neutral-light;
62
+ @apply border-primary-base;
63
+ @apply text-primary-base;
64
+ }
65
+
66
+ &:active:not(disabled) {
67
+ @apply relative;
68
+ @apply top-px;
69
+ }
70
+
71
+ &[disabled],
72
+ &[disabled]:hover,
73
+ &[disabled]:focus {
74
+ @apply bg-white;
75
+ @apply opacity-50;
76
+ @apply cursor-not-allowed;
77
+ }
78
+
79
+ @apply px-2;
80
+ @apply py-1;
81
+ @apply text-sm;
82
+ }
83
+ }
84
+ }
85
+ }
@@ -0,0 +1,124 @@
1
+ {% from "components/button/_macro.button.njk" import componentButton %}
2
+ {% from "components/dropdown/_macro.dropdown.njk" import componentDropdown %}
3
+ {% from "../error-message/_macro.error-message.njk" import componentErrorMessage -%}
4
+ {% from "../hint/_macro.hint.njk" import componentHint %}
5
+ {% from "../input/_macro.input.njk" import componentInput %}
6
+ {% from "../label/_macro.label.njk" import componentLabel %}
7
+
8
+ {% set describedBy = params.describedBy if params.describedBy else "" %}
9
+ {% if params.errorMessage %}
10
+ {% set errorId = params.id + '-error' %}
11
+ {% set describedBy = describedBy + " " + errorId if describedBy else errorId %}
12
+ {% endif %}
13
+ {% set datepickerContent %}
14
+ {% if caller %}
15
+ {% set myCaller = caller() %}
16
+ {% if myCaller | string != '' %}
17
+ <div class="p-sm overflow-x-auto">
18
+ {{ myCaller }}
19
+ </div>
20
+ {% endif %}
21
+ {% elseif params.caller %}
22
+ <div class="p-sm overflow-x-auto">
23
+ {{ params.caller | safe }}
24
+ </div>
25
+ {% endif %}
26
+ {% endset %}
27
+
28
+ <!-- datepicker -->
29
+ <div data-module="c-datepicker" class="c-datepicker {%- if params.containerClasses %} {{ params.containerClasses }}{% endif %}" {%- for attribute, value in params.containerAttributes %} {{attribute}}="{{value}}"{% endfor %}>
30
+ {% if params.standalone %}
31
+ {{ datepickerContent | safe }}
32
+ {% else %}
33
+ <div class="c-form-group {%- if params.errorMessage %} c-form-group--error{% endif %} {%- if params.formGroup.classes %} {{ params.formGroup.classes }}{% endif %}">
34
+ {{ componentLabel({
35
+ html: params.label.html,
36
+ text: params.label.text,
37
+ classes: params.label.classes,
38
+ isPageHeading: params.label.isPageHeading,
39
+ attributes: params.label.attributes,
40
+ for: params.id
41
+ }) }}
42
+ {% if params.hint %}
43
+ {% set hintId = params.id + '-hint' %}
44
+ {% set describedBy = describedBy + ' ' + hintId if describedBy else hintId %}
45
+ {{ componentHint({
46
+ id: hintId,
47
+ classes: params.hint.classes,
48
+ attributes: params.hint.attributes,
49
+ html: params.hint.html,
50
+ text: params.hint.text
51
+ }) }}
52
+ {% endif %}
53
+ {% if params.errorMessage %}
54
+ {% if not params.errorId %}
55
+ {% set errorId = params.id + '-error' %}
56
+ {% set describedBy = describedBy + ' ' + errorId if describedBy else errorId %}
57
+ {% endif %}
58
+ {{ componentErrorMessage({
59
+ id: errorId,
60
+ classes: params.errorMessage.classes,
61
+ attributes: params.errorMessage.attributes,
62
+ html: params.errorMessage.html,
63
+ text: params.errorMessage.text,
64
+ visuallyHiddenText: params.errorMessage.visuallyHiddenText
65
+ }) }}
66
+ {% endif %}
67
+ <div class="relative {%- if params.dropdown %} flex flex-wrap items-end gap-sm{% endif %}">
68
+ <input class="c-input block mt-sm border-black rounded font-semibold placeholder-neutral-dark focus:border-black focus:shadow-outline-focus-input focus:ring-4 focus:ring-warning-base disabled:bg-neutral-light disabled:border-neutral-base {%- if not params.dropdown %} pr-16 w-full{% endif %} {%- if params.classes %} {{ params.classes }}{% endif %} {%- if params.errorMessage %} border-alert-base ring-2 ring-alert-base {% endif %}" id="{{ params.id }}" name="{{ params.name }}" type="{{ params.type | default('text') }}"
69
+ {%- if params.value %} value="{{ params.value}}"{% endif %}
70
+ {%- if describedBy %} aria-describedby="{{ describedBy }}"{% endif %}
71
+ {%- if params.errorMessage or params.errorId %} aria-errormessage="{{ errorId }}" aria-invalid="true" {%- if not describedBy %} aria-describedby="{{ errorId }}"{% endif %}{% endif %}
72
+ {%- if params.autocomplete %} autocomplete="{{ params.autocomplete}}"{% endif %}
73
+ {%- if params.pattern %} pattern="{{ params.pattern }}"{% endif %}
74
+ {%- if params.inputmode %} inputmode="{{ params.inputmode }}"{% endif %}
75
+ {%- if params.placeholder %} placeholder="{{ params.placeholder }}"{% endif %}
76
+ {{-" disabled" if params.disabled }}
77
+ {%- for attribute, value in params.attributes %} {{ attribute }}="{{ value }}"{% endfor -%}>
78
+ {% set dropdownActionButtons %}
79
+ <ul class="flex flex-wrap justify-between gap-sm p-sm">
80
+ <li>
81
+ {{ componentButton({
82
+ "text": "Aceptar",
83
+ "classes": "c-button--primary c-button--sm",
84
+ "attributes": {
85
+ "id": params.id + "-submit"
86
+ }
87
+ }) }}
88
+ </li>
89
+ <li>
90
+ {{ componentButton({
91
+ "text": "Cancelar",
92
+ "classes": " c-button--sm",
93
+ "attributes": {
94
+ "id": params.id + "-cancel"
95
+ }
96
+ }) }}
97
+ </li>
98
+ </ul>
99
+ {% endset %}
100
+ {% if params.dropdown %}
101
+ {% call componentDropdown(params.dropdown) %}
102
+ {{ datepickerContent | safe }}
103
+ {{ dropdownActionButtons | safe }}
104
+ {% endcall %}
105
+ {% else %}
106
+ <div class="absolute top-0 right-0">
107
+ {% call componentDropdown({
108
+ "html": '<span class="sr-only">Seleccionar fecha con una tabla de calendario</span><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 14 14" width="1.375em" height="1.375em" aria-hidden="true"><g><path fill="currentColor" fill-rule="evenodd" d="M4.5 1.5c0 -0.552285 -0.44772 -1 -1 -1s-1 0.447715 -1 1v1H2C1.17157 2.5 0.5 3.17157 0.5 4v8c0 0.8284 0.67157 1.5 1.5 1.5h10c0.8284 0 1.5 -0.6716 1.5 -1.5V4c0 -0.82843 -0.6716 -1.5 -1.5 -1.5h-0.5v-1c0 -0.552285 -0.4477 -1 -1 -1 -0.55229 0 -1 0.447715 -1 1v1h-5v-1Zm-1 5.75c0.55228 0 1 -0.44772 1 -1s-0.44772 -1 -1 -1 -1 0.44772 -1 1 0.44772 1 1 1Zm3.5 0c0.55228 0 1 -0.44772 1 -1s-0.44772 -1 -1 -1 -1 0.44772 -1 1 0.44772 1 1 1Zm-2.5 3c0 0.5523 -0.44772 1 -1 1s-1 -0.4477 -1 -1c0 -0.55229 0.44772 -1 1 -1s1 0.44771 1 1Zm2.5 1c0.55228 0 1 -0.4477 1 -1 0 -0.55229 -0.44772 -1 -1 -1s-1 0.44771 -1 1c0 0.5523 0.44772 1 1 1Zm4.5 -5c0 0.55228 -0.4477 1 -1 1 -0.55229 0 -1 -0.44772 -1 -1s0.44771 -1 1 -1c0.5523 0 1 0.44772 1 1Z" clip-rule="evenodd" stroke-width="1"></path></g></svg>',
109
+ "classes": params.dropdownClasses if params.dropdownClasses else "c-dropdown--transparent",
110
+ "disabled": params.disabled,
111
+ "attributes": {
112
+ "id": params.id + "-dropdown"
113
+ }
114
+ }) %}
115
+ {{ datepickerContent | safe }}
116
+ {{ dropdownActionButtons | safe }}
117
+ {% endcall %}
118
+ </div>
119
+ {% endif %}
120
+ </div>
121
+ </div>
122
+ {% endif %}
123
+ </div>
124
+ <!-- /datepicker -->