shirkasoft-ui-components 1.14.0 → 2.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/README.md +12 -9
- package/fesm2022/shirkasoft-ui-components-breadcrumb.mjs +189 -100
- package/fesm2022/shirkasoft-ui-components-breadcrumb.mjs.map +1 -1
- package/fesm2022/shirkasoft-ui-components-button.mjs +363 -69
- package/fesm2022/shirkasoft-ui-components-button.mjs.map +1 -1
- package/fesm2022/shirkasoft-ui-components-chart.mjs +206 -142
- package/fesm2022/shirkasoft-ui-components-chart.mjs.map +1 -1
- package/fesm2022/shirkasoft-ui-components-config.mjs +905 -843
- package/fesm2022/shirkasoft-ui-components-config.mjs.map +1 -1
- package/fesm2022/shirkasoft-ui-components-confirm-dialog.mjs +307 -142
- package/fesm2022/shirkasoft-ui-components-confirm-dialog.mjs.map +1 -1
- package/fesm2022/shirkasoft-ui-components-date-picker.mjs +1697 -1440
- package/fesm2022/shirkasoft-ui-components-date-picker.mjs.map +1 -1
- package/fesm2022/shirkasoft-ui-components-fieldset.mjs +347 -92
- package/fesm2022/shirkasoft-ui-components-fieldset.mjs.map +1 -1
- package/fesm2022/shirkasoft-ui-components-file-upload.mjs +555 -300
- package/fesm2022/shirkasoft-ui-components-file-upload.mjs.map +1 -1
- package/fesm2022/shirkasoft-ui-components-icons.mjs +1028 -533
- package/fesm2022/shirkasoft-ui-components-icons.mjs.map +1 -1
- package/fesm2022/shirkasoft-ui-components-knob.mjs +389 -201
- package/fesm2022/shirkasoft-ui-components-knob.mjs.map +1 -1
- package/fesm2022/shirkasoft-ui-components-loading.mjs +505 -128
- package/fesm2022/shirkasoft-ui-components-loading.mjs.map +1 -1
- package/fesm2022/shirkasoft-ui-components-modal.mjs +311 -314
- package/fesm2022/shirkasoft-ui-components-modal.mjs.map +1 -1
- package/fesm2022/shirkasoft-ui-components-notification.mjs +188 -142
- package/fesm2022/shirkasoft-ui-components-notification.mjs.map +1 -1
- package/fesm2022/shirkasoft-ui-components-price-input.mjs +585 -327
- package/fesm2022/shirkasoft-ui-components-price-input.mjs.map +1 -1
- package/fesm2022/shirkasoft-ui-components-rail-sidebar.mjs +669 -289
- package/fesm2022/shirkasoft-ui-components-rail-sidebar.mjs.map +1 -1
- package/fesm2022/shirkasoft-ui-components-select.mjs +1076 -819
- package/fesm2022/shirkasoft-ui-components-select.mjs.map +1 -1
- package/fesm2022/shirkasoft-ui-components-sidebar.mjs +508 -184
- package/fesm2022/shirkasoft-ui-components-sidebar.mjs.map +1 -1
- package/fesm2022/shirkasoft-ui-components-skeleton.mjs +197 -57
- package/fesm2022/shirkasoft-ui-components-skeleton.mjs.map +1 -1
- package/fesm2022/shirkasoft-ui-components-table.mjs +1916 -1698
- package/fesm2022/shirkasoft-ui-components-table.mjs.map +1 -1
- package/fesm2022/shirkasoft-ui-components-tabs.mjs +419 -175
- package/fesm2022/shirkasoft-ui-components-tabs.mjs.map +1 -1
- package/fesm2022/shirkasoft-ui-components-tag.mjs +175 -49
- package/fesm2022/shirkasoft-ui-components-tag.mjs.map +1 -1
- package/fesm2022/shirkasoft-ui-components-text-field.mjs +749 -402
- package/fesm2022/shirkasoft-ui-components-text-field.mjs.map +1 -1
- package/fesm2022/shirkasoft-ui-components-theme-picker.mjs +310 -124
- package/fesm2022/shirkasoft-ui-components-theme-picker.mjs.map +1 -1
- package/fesm2022/shirkasoft-ui-components-theme.mjs +141 -174
- package/fesm2022/shirkasoft-ui-components-theme.mjs.map +1 -1
- package/fesm2022/shirkasoft-ui-components-timeline.mjs +791 -203
- package/fesm2022/shirkasoft-ui-components-timeline.mjs.map +1 -1
- package/fesm2022/shirkasoft-ui-components-toggle.mjs +179 -109
- package/fesm2022/shirkasoft-ui-components-toggle.mjs.map +1 -1
- package/fesm2022/shirkasoft-ui-components-tooltip.mjs +244 -180
- package/fesm2022/shirkasoft-ui-components-tooltip.mjs.map +1 -1
- package/fesm2022/shirkasoft-ui-components-utils.mjs +129 -133
- package/fesm2022/shirkasoft-ui-components-utils.mjs.map +1 -1
- package/fesm2022/shirkasoft-ui-components-wizard.mjs +673 -165
- package/fesm2022/shirkasoft-ui-components-wizard.mjs.map +1 -1
- package/fesm2022/shirkasoft-ui-components.mjs +0 -9
- package/package.json +5 -5
- package/types/shirkasoft-ui-components-breadcrumb.d.ts +59 -44
- package/types/shirkasoft-ui-components-button.d.ts +142 -49
- package/types/shirkasoft-ui-components-chart.d.ts +59 -44
- package/types/shirkasoft-ui-components-config.d.ts +193 -204
- package/types/shirkasoft-ui-components-confirm-dialog.d.ts +107 -66
- package/types/shirkasoft-ui-components-date-picker.d.ts +561 -398
- package/types/shirkasoft-ui-components-fieldset.d.ts +135 -60
- package/types/shirkasoft-ui-components-file-upload.d.ts +210 -112
- package/types/shirkasoft-ui-components-icons.d.ts +1302 -1294
- package/types/shirkasoft-ui-components-knob.d.ts +144 -78
- package/types/shirkasoft-ui-components-loading.d.ts +155 -64
- package/types/shirkasoft-ui-components-modal.d.ts +134 -136
- package/types/shirkasoft-ui-components-notification.d.ts +63 -59
- package/types/shirkasoft-ui-components-price-input.d.ts +232 -113
- package/types/shirkasoft-ui-components-rail-sidebar.d.ts +262 -142
- package/types/shirkasoft-ui-components-select.d.ts +335 -196
- package/types/shirkasoft-ui-components-sidebar.d.ts +198 -93
- package/types/shirkasoft-ui-components-skeleton.d.ts +68 -27
- package/types/shirkasoft-ui-components-table.d.ts +849 -660
- package/types/shirkasoft-ui-components-tabs.d.ts +102 -61
- package/types/shirkasoft-ui-components-tag.d.ts +54 -23
- package/types/shirkasoft-ui-components-text-field.d.ts +263 -127
- package/types/shirkasoft-ui-components-theme-picker.d.ts +92 -58
- package/types/shirkasoft-ui-components-theme.d.ts +56 -64
- package/types/shirkasoft-ui-components-timeline.d.ts +325 -150
- package/types/shirkasoft-ui-components-toggle.d.ts +73 -49
- package/types/shirkasoft-ui-components-tooltip.d.ts +64 -43
- package/types/shirkasoft-ui-components-utils.d.ts +47 -15
- package/types/shirkasoft-ui-components-wizard.d.ts +236 -87
- package/types/shirkasoft-ui-components.d.ts +1 -2
- package/fesm2022/shirkasoft-ui-components.mjs.map +0 -1
|
@@ -1,914 +1,976 @@
|
|
|
1
|
-
import { DOCUMENT } from
|
|
2
|
-
import * as i0 from
|
|
3
|
-
import {
|
|
4
|
-
import { DEFAULT_SHK_THEME_CONFIG, SHK_THEME_CONFIG, ShkThemeService } from
|
|
5
|
-
|
|
6
|
-
/** Locales offered by the built-in `select` options (any BCP 47 tag is still accepted via `set`). */
|
|
7
|
-
const LOCALE_CHOICES = [
|
|
8
|
-
{ value: 'es', label: 'Español' },
|
|
9
|
-
{ value: 'es-ES', label: 'Español (España)' },
|
|
10
|
-
{ value: 'es-MX', label: 'Español (México)' },
|
|
11
|
-
{ value: 'en-US', label: 'English (US)' },
|
|
12
|
-
{ value: 'en-GB', label: 'English (UK)' },
|
|
13
|
-
{ value: 'pt-BR', label: 'Português (Brasil)' },
|
|
14
|
-
{ value: 'fr-FR', label: 'Français' },
|
|
15
|
-
];
|
|
16
|
-
/** Date options (`dates.*`), always registered. */
|
|
1
|
+
import { DOCUMENT } from "@angular/common";
|
|
2
|
+
import * as i0 from "@angular/core";
|
|
3
|
+
import { CSP_NONCE, Injectable, InjectionToken, computed, effect, inject, makeEnvironmentProviders, provideAppInitializer, signal, untracked } from "@angular/core";
|
|
4
|
+
import { DEFAULT_SHK_THEME_CONFIG, SHK_THEME_CONFIG, ShkThemeService } from "shirkasoft-ui-components/theme";
|
|
17
5
|
const DATE_OPTIONS = [
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
6
|
+
{
|
|
7
|
+
key: "dates.locale",
|
|
8
|
+
module: "dates",
|
|
9
|
+
type: "select",
|
|
10
|
+
default: "es",
|
|
11
|
+
label: "Idioma de las fechas",
|
|
12
|
+
description: "Nombres de meses y días del calendario.",
|
|
13
|
+
choices: [
|
|
14
|
+
{
|
|
15
|
+
value: "es",
|
|
16
|
+
label: "Español"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
value: "es-ES",
|
|
20
|
+
label: "Español (España)"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
value: "es-MX",
|
|
24
|
+
label: "Español (México)"
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
value: "en-US",
|
|
28
|
+
label: "English (US)"
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
value: "en-GB",
|
|
32
|
+
label: "English (UK)"
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
value: "pt-BR",
|
|
36
|
+
label: "Português (Brasil)"
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
value: "fr-FR",
|
|
40
|
+
label: "Français"
|
|
41
|
+
}
|
|
42
|
+
],
|
|
43
|
+
allowCustom: true
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
key: "dates.format",
|
|
47
|
+
module: "dates",
|
|
48
|
+
type: "select",
|
|
49
|
+
default: "",
|
|
50
|
+
label: "Formato de fecha",
|
|
51
|
+
description: "Cómo se escriben y muestran las fechas en campos y tablas.",
|
|
52
|
+
allowCustom: true,
|
|
53
|
+
choices: [
|
|
54
|
+
{
|
|
55
|
+
value: "",
|
|
56
|
+
label: "Automático según el idioma"
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
value: "dd/MM/yyyy",
|
|
60
|
+
label: "31/12/2026"
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
value: "MM/dd/yyyy",
|
|
64
|
+
label: "12/31/2026"
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
value: "yyyy-MM-dd",
|
|
68
|
+
label: "2026-12-31"
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
value: "dd-MM-yyyy",
|
|
72
|
+
label: "31-12-2026"
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
value: "dd.MM.yyyy",
|
|
76
|
+
label: "31.12.2026"
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
value: "d MMM yyyy",
|
|
80
|
+
label: "31 dic 2026"
|
|
81
|
+
}
|
|
82
|
+
]
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
key: "dates.displayStyle",
|
|
86
|
+
module: "dates",
|
|
87
|
+
type: "select",
|
|
88
|
+
default: "long",
|
|
89
|
+
label: "Fecha seleccionada",
|
|
90
|
+
description: "Cómo muestra el selector de fecha el valor elegido.",
|
|
91
|
+
choices: [
|
|
92
|
+
{
|
|
93
|
+
value: "long",
|
|
94
|
+
label: "Larga (31 de diciembre de 2026)"
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
value: "medium",
|
|
98
|
+
label: "Media (31 dic 2026)"
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
value: "short",
|
|
102
|
+
label: "Corta (31/12/26)"
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
value: "format",
|
|
106
|
+
label: "Con el formato de fecha"
|
|
107
|
+
}
|
|
108
|
+
]
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
key: "dates.hourFormat",
|
|
112
|
+
module: "dates",
|
|
113
|
+
type: "select",
|
|
114
|
+
default: "24",
|
|
115
|
+
label: "Formato de hora",
|
|
116
|
+
choices: [{
|
|
117
|
+
value: "24",
|
|
118
|
+
label: "24 horas (14:30)"
|
|
119
|
+
}, {
|
|
120
|
+
value: "12",
|
|
121
|
+
label: "12 horas (02:30 PM)"
|
|
122
|
+
}]
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
key: "dates.weekStart",
|
|
126
|
+
module: "dates",
|
|
127
|
+
type: "select",
|
|
128
|
+
default: null,
|
|
129
|
+
label: "Primer día de la semana",
|
|
130
|
+
choices: [
|
|
131
|
+
{
|
|
132
|
+
value: null,
|
|
133
|
+
label: "Según el idioma"
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
value: 1,
|
|
137
|
+
label: "Lunes"
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
value: 0,
|
|
141
|
+
label: "Domingo"
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
value: 6,
|
|
145
|
+
label: "Sábado"
|
|
146
|
+
}
|
|
147
|
+
]
|
|
148
|
+
}
|
|
84
149
|
];
|
|
85
|
-
/** Number and currency options (`numbers.*`), always registered. */
|
|
86
150
|
const NUMBER_OPTIONS = [
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
151
|
+
{
|
|
152
|
+
key: "numbers.locale",
|
|
153
|
+
module: "numbers",
|
|
154
|
+
type: "select",
|
|
155
|
+
default: "en-US",
|
|
156
|
+
label: "Formato de números",
|
|
157
|
+
description: "Separadores de miles y decimales (1,234.56 o 1.234,56).",
|
|
158
|
+
allowCustom: true,
|
|
159
|
+
choices: [
|
|
160
|
+
{
|
|
161
|
+
value: "en-US",
|
|
162
|
+
label: "1,234.56"
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
value: "es-ES",
|
|
166
|
+
label: "1.234,56"
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
value: "fr-FR",
|
|
170
|
+
label: "1 234,56"
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
value: "de-CH",
|
|
174
|
+
label: "1'234.56"
|
|
175
|
+
}
|
|
176
|
+
]
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
key: "numbers.currency",
|
|
180
|
+
module: "numbers",
|
|
181
|
+
type: "select",
|
|
182
|
+
default: "USD",
|
|
183
|
+
label: "Moneda",
|
|
184
|
+
description: "Moneda por defecto de importes y columnas de moneda.",
|
|
185
|
+
allowCustom: true,
|
|
186
|
+
choices: [
|
|
187
|
+
{
|
|
188
|
+
value: "USD",
|
|
189
|
+
label: "Dólar estadounidense (USD)"
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
value: "EUR",
|
|
193
|
+
label: "Euro (EUR)"
|
|
194
|
+
},
|
|
195
|
+
{
|
|
196
|
+
value: "CUP",
|
|
197
|
+
label: "Peso cubano (CUP)"
|
|
198
|
+
},
|
|
199
|
+
{
|
|
200
|
+
value: "MXN",
|
|
201
|
+
label: "Peso mexicano (MXN)"
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
value: "GBP",
|
|
205
|
+
label: "Libra esterlina (GBP)"
|
|
206
|
+
},
|
|
207
|
+
{
|
|
208
|
+
value: "BRL",
|
|
209
|
+
label: "Real brasileño (BRL)"
|
|
210
|
+
}
|
|
211
|
+
]
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
key: "numbers.currencySymbol",
|
|
215
|
+
module: "numbers",
|
|
216
|
+
type: "string",
|
|
217
|
+
default: "",
|
|
218
|
+
label: "Símbolo de moneda",
|
|
219
|
+
description: "Vacío = el de la moneda ($, €…)."
|
|
220
|
+
},
|
|
221
|
+
{
|
|
222
|
+
key: "numbers.decimals",
|
|
223
|
+
module: "numbers",
|
|
224
|
+
type: "select",
|
|
225
|
+
default: null,
|
|
226
|
+
label: "Decimales",
|
|
227
|
+
description: "Decimales de los importes.",
|
|
228
|
+
choices: [
|
|
229
|
+
{
|
|
230
|
+
value: null,
|
|
231
|
+
label: "Según la moneda (USD 2, JPY 0)"
|
|
232
|
+
},
|
|
233
|
+
{
|
|
234
|
+
value: 0,
|
|
235
|
+
label: "0"
|
|
236
|
+
},
|
|
237
|
+
{
|
|
238
|
+
value: 1,
|
|
239
|
+
label: "1"
|
|
240
|
+
},
|
|
241
|
+
{
|
|
242
|
+
value: 2,
|
|
243
|
+
label: "2"
|
|
244
|
+
},
|
|
245
|
+
{
|
|
246
|
+
value: 3,
|
|
247
|
+
label: "3"
|
|
248
|
+
},
|
|
249
|
+
{
|
|
250
|
+
value: 4,
|
|
251
|
+
label: "4"
|
|
252
|
+
}
|
|
253
|
+
]
|
|
254
|
+
}
|
|
143
255
|
];
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
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
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
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
|
-
default:
|
|
346
|
-
if (typeof value !== 'string')
|
|
347
|
-
fail('expected a string');
|
|
348
|
-
return value;
|
|
349
|
-
}
|
|
350
|
-
}
|
|
351
|
-
loadStored() {
|
|
352
|
-
if (!this.persistence)
|
|
353
|
-
return {};
|
|
354
|
-
try {
|
|
355
|
-
const raw = this.win?.localStorage?.getItem(this.persistence.storageKey);
|
|
356
|
-
const parsed = raw ? JSON.parse(raw) : null;
|
|
357
|
-
return parsed && typeof parsed === 'object' && !Array.isArray(parsed) ? parsed : {};
|
|
358
|
-
}
|
|
359
|
-
catch {
|
|
360
|
-
return {};
|
|
361
|
-
}
|
|
362
|
-
}
|
|
363
|
-
save(values) {
|
|
364
|
-
if (!this.persistence)
|
|
365
|
-
return;
|
|
366
|
-
const defs = untracked(this.defs);
|
|
367
|
-
// Keep stored values of options that are not registered yet (registered later).
|
|
368
|
-
const stored = { ...this.pending };
|
|
369
|
-
for (const [key, value] of Object.entries(values)) {
|
|
370
|
-
if (defs.get(key)?.persist !== false)
|
|
371
|
-
stored[key] = value;
|
|
372
|
-
}
|
|
373
|
-
try {
|
|
374
|
-
this.win?.localStorage?.setItem(this.persistence.storageKey, JSON.stringify(stored));
|
|
375
|
-
}
|
|
376
|
-
catch {
|
|
377
|
-
// Storage can be blocked (private mode, quota); the option still applies.
|
|
378
|
-
}
|
|
379
|
-
}
|
|
380
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.27", ngImport: i0, type: ShkConfigService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
381
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.27", ngImport: i0, type: ShkConfigService, providedIn: 'root' }); }
|
|
382
|
-
}
|
|
383
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.27", ngImport: i0, type: ShkConfigService, decorators: [{
|
|
384
|
-
type: Injectable,
|
|
385
|
-
args: [{ providedIn: 'root' }]
|
|
386
|
-
}], ctorParameters: () => [] });
|
|
387
|
-
/** Value equality for option values (primitives and `null`). */
|
|
256
|
+
const SHK_CONFIG_FEATURES = new InjectionToken("SHK_CONFIG_FEATURES");
|
|
257
|
+
const SHK_CONFIG_PERSISTENCE = new InjectionToken("SHK_CONFIG_PERSISTENCE");
|
|
258
|
+
var ShkConfigService = class ShkConfigService {
|
|
259
|
+
constructor() {
|
|
260
|
+
this.win = inject(DOCUMENT).defaultView;
|
|
261
|
+
this.persistence = inject(SHK_CONFIG_PERSISTENCE, { optional: true });
|
|
262
|
+
this.defs = signal(/* @__PURE__ */ new Map(), ...ngDevMode ? [{ debugName: "defs" }] : /* istanbul ignore next */ []);
|
|
263
|
+
this.values = signal({}, ...ngDevMode ? [{ debugName: "values" }] : /* istanbul ignore next */ []);
|
|
264
|
+
this.sources = signal(/* @__PURE__ */ new Map(), ...ngDevMode ? [{ debugName: "sources" }] : /* istanbul ignore next */ []);
|
|
265
|
+
this.pending = {};
|
|
266
|
+
this.cache = /* @__PURE__ */ new Map();
|
|
267
|
+
this.options = computed(() => [...this.defs().values()].map((def) => {
|
|
268
|
+
const value = this.read(def.key);
|
|
269
|
+
return {
|
|
270
|
+
...def,
|
|
271
|
+
value,
|
|
272
|
+
isDefault: sameValue(value, def.default)
|
|
273
|
+
};
|
|
274
|
+
}), ...ngDevMode ? [{ debugName: "options" }] : /* istanbul ignore next */ []);
|
|
275
|
+
this.modules = computed(() => [...new Set([...this.defs().values()].map((def) => def.module))], ...ngDevMode ? [{ debugName: "modules" }] : /* istanbul ignore next */ []);
|
|
276
|
+
this.pending = this.loadStored();
|
|
277
|
+
this.register([...DATE_OPTIONS, ...NUMBER_OPTIONS]);
|
|
278
|
+
for (const feature of inject(SHK_CONFIG_FEATURES, { optional: true }) ?? []) {
|
|
279
|
+
if (feature.options) this.register(feature.options);
|
|
280
|
+
if (feature.defaults) this.setDefaults(feature.defaults);
|
|
281
|
+
}
|
|
282
|
+
if (this.persistence) effect(() => this.save(this.values()));
|
|
283
|
+
}
|
|
284
|
+
get(key) {
|
|
285
|
+
this.requireDef(key);
|
|
286
|
+
let sig = this.cache.get(key);
|
|
287
|
+
if (!sig) {
|
|
288
|
+
sig = computed(() => this.read(key));
|
|
289
|
+
this.cache.set(key, sig);
|
|
290
|
+
}
|
|
291
|
+
return sig;
|
|
292
|
+
}
|
|
293
|
+
has(key) {
|
|
294
|
+
return untracked(this.defs).has(key);
|
|
295
|
+
}
|
|
296
|
+
value(key) {
|
|
297
|
+
return untracked(this.get(key));
|
|
298
|
+
}
|
|
299
|
+
set(key, value) {
|
|
300
|
+
const def = this.requireDef(key);
|
|
301
|
+
const valid = this.validate(def, value);
|
|
302
|
+
const source = untracked(this.sources).get(key);
|
|
303
|
+
if (source) {
|
|
304
|
+
source.set(valid);
|
|
305
|
+
return;
|
|
306
|
+
}
|
|
307
|
+
this.values.update((current) => ({
|
|
308
|
+
...current,
|
|
309
|
+
[key]: valid
|
|
310
|
+
}));
|
|
311
|
+
}
|
|
312
|
+
reset(key) {
|
|
313
|
+
const keys = key ? [key] : [...untracked(this.defs).keys()];
|
|
314
|
+
for (const k of keys) {
|
|
315
|
+
const def = this.requireDef(k);
|
|
316
|
+
const source = untracked(this.sources).get(k);
|
|
317
|
+
if (source) source.set(def.default);
|
|
318
|
+
}
|
|
319
|
+
this.values.update((current) => {
|
|
320
|
+
if (!key) return {};
|
|
321
|
+
const { [key]: _removed, ...rest } = current;
|
|
322
|
+
return rest;
|
|
323
|
+
});
|
|
324
|
+
}
|
|
325
|
+
register(defs) {
|
|
326
|
+
this.defs.update((current) => {
|
|
327
|
+
const next = new Map(current);
|
|
328
|
+
for (const def of defs) next.set(def.key, def);
|
|
329
|
+
return next;
|
|
330
|
+
});
|
|
331
|
+
for (const def of defs) {
|
|
332
|
+
if (!(def.key in this.pending)) continue;
|
|
333
|
+
const stored = this.pending[def.key];
|
|
334
|
+
delete this.pending[def.key];
|
|
335
|
+
if (def.persist === false) continue;
|
|
336
|
+
try {
|
|
337
|
+
const valid = this.validate(def, stored);
|
|
338
|
+
this.values.update((current) => ({
|
|
339
|
+
...current,
|
|
340
|
+
[def.key]: valid
|
|
341
|
+
}));
|
|
342
|
+
} catch {}
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
bind(key, source) {
|
|
346
|
+
this.requireDef(key);
|
|
347
|
+
this.sources.update((current) => new Map(current).set(key, source));
|
|
348
|
+
}
|
|
349
|
+
setDefaults(defaults) {
|
|
350
|
+
const updated = [];
|
|
351
|
+
for (const [key, value] of Object.entries(defaults)) {
|
|
352
|
+
if (value === void 0) continue;
|
|
353
|
+
const def = this.requireDef(key);
|
|
354
|
+
updated.push({
|
|
355
|
+
...def,
|
|
356
|
+
default: this.validate(def, value)
|
|
357
|
+
});
|
|
358
|
+
}
|
|
359
|
+
this.defs.update((current) => {
|
|
360
|
+
const next = new Map(current);
|
|
361
|
+
for (const def of updated) next.set(def.key, def);
|
|
362
|
+
return next;
|
|
363
|
+
});
|
|
364
|
+
}
|
|
365
|
+
read(key) {
|
|
366
|
+
const source = this.sources().get(key);
|
|
367
|
+
if (source) return source.value();
|
|
368
|
+
const values = this.values();
|
|
369
|
+
return key in values ? values[key] : this.defs().get(key)?.default;
|
|
370
|
+
}
|
|
371
|
+
requireDef(key) {
|
|
372
|
+
const def = untracked(this.defs).get(key);
|
|
373
|
+
if (!def) throw new Error(`[shk-config] Unknown option "${key}". Register it with withOptions() or ShkConfigService.register().`);
|
|
374
|
+
return def;
|
|
375
|
+
}
|
|
376
|
+
validate(def, value) {
|
|
377
|
+
const fail = (why) => {
|
|
378
|
+
throw new Error(`[shk-config] Invalid value for "${def.key}": ${why}.`);
|
|
379
|
+
};
|
|
380
|
+
switch (def.type) {
|
|
381
|
+
case "boolean":
|
|
382
|
+
if (typeof value !== "boolean") fail("expected a boolean");
|
|
383
|
+
return value;
|
|
384
|
+
case "number": {
|
|
385
|
+
const n = typeof value === "string" && value.trim() !== "" ? Number(value) : value;
|
|
386
|
+
if (typeof n !== "number" || !isFinite(n)) fail("expected a number");
|
|
387
|
+
if (def.min !== void 0 && n < def.min) fail(`minimum is ${def.min}`);
|
|
388
|
+
if (def.max !== void 0 && n > def.max) fail(`maximum is ${def.max}`);
|
|
389
|
+
return n;
|
|
390
|
+
}
|
|
391
|
+
case "color":
|
|
392
|
+
if (typeof value !== "string") fail("expected a color string");
|
|
393
|
+
if (value !== "" && !/^#([0-9a-f]{3}|[0-9a-f]{6})$/i.test(value)) fail("expected a hex color such as #2563eb (or empty)");
|
|
394
|
+
return value;
|
|
395
|
+
case "select": {
|
|
396
|
+
const match = def.choices?.find((choice) => sameValue(choice.value, value));
|
|
397
|
+
if (match) return match.value;
|
|
398
|
+
if (def.allowCustom && typeof value === "string" && value.trim() !== "") return value.trim();
|
|
399
|
+
return fail("not one of the allowed choices");
|
|
400
|
+
}
|
|
401
|
+
default:
|
|
402
|
+
if (typeof value !== "string") fail("expected a string");
|
|
403
|
+
return value;
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
loadStored() {
|
|
407
|
+
if (!this.persistence) return {};
|
|
408
|
+
try {
|
|
409
|
+
const raw = this.win?.localStorage?.getItem(this.persistence.storageKey);
|
|
410
|
+
const parsed = raw ? JSON.parse(raw) : null;
|
|
411
|
+
return parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : {};
|
|
412
|
+
} catch {
|
|
413
|
+
return {};
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
save(values) {
|
|
417
|
+
if (!this.persistence) return;
|
|
418
|
+
const defs = untracked(this.defs);
|
|
419
|
+
const stored = { ...this.pending };
|
|
420
|
+
for (const [key, value] of Object.entries(values)) if (defs.get(key)?.persist !== false) stored[key] = value;
|
|
421
|
+
try {
|
|
422
|
+
this.win?.localStorage?.setItem(this.persistence.storageKey, JSON.stringify(stored));
|
|
423
|
+
} catch {}
|
|
424
|
+
}
|
|
425
|
+
static {
|
|
426
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
427
|
+
minVersion: "12.0.0",
|
|
428
|
+
version: "22.3.2",
|
|
429
|
+
ngImport: i0,
|
|
430
|
+
type: ShkConfigService,
|
|
431
|
+
deps: [],
|
|
432
|
+
target: i0.ɵɵFactoryTarget.Injectable
|
|
433
|
+
});
|
|
434
|
+
}
|
|
435
|
+
static {
|
|
436
|
+
this.ɵprov = i0.ɵɵngDeclareInjectable({
|
|
437
|
+
minVersion: "12.0.0",
|
|
438
|
+
version: "22.3.2",
|
|
439
|
+
ngImport: i0,
|
|
440
|
+
type: ShkConfigService,
|
|
441
|
+
providedIn: "root"
|
|
442
|
+
});
|
|
443
|
+
}
|
|
444
|
+
};
|
|
445
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
446
|
+
minVersion: "12.0.0",
|
|
447
|
+
version: "22.3.2",
|
|
448
|
+
ngImport: i0,
|
|
449
|
+
type: ShkConfigService,
|
|
450
|
+
decorators: [{
|
|
451
|
+
type: Injectable,
|
|
452
|
+
args: [{ providedIn: "root" }]
|
|
453
|
+
}],
|
|
454
|
+
ctorParameters: () => []
|
|
455
|
+
});
|
|
388
456
|
function sameValue(a, b) {
|
|
389
|
-
|
|
457
|
+
return a === b || Number.isNaN(a) && Number.isNaN(b);
|
|
390
458
|
}
|
|
391
|
-
|
|
392
|
-
/**
|
|
393
|
-
* Shirkasoft UI Components.
|
|
394
|
-
* Authors: Roberto Valladares Martin (Ansem13), Julio César García García (Sanjuli14).
|
|
395
|
-
* Belongs to Shirkasoft.
|
|
396
|
-
*
|
|
397
|
-
* Builds the `--shk-primary-*` scale from a single color with CSS `color-mix()`,
|
|
398
|
-
* so the browser derives every shade and no color math ships in JavaScript.
|
|
399
|
-
*/
|
|
400
459
|
const HEX = /^#([0-9a-f]{3}|[0-9a-f]{6})$/i;
|
|
401
460
|
const THEME_NAME = /^[a-z][a-z0-9-]*$/i;
|
|
402
461
|
const CSS_VAR_NAME = /^--shk-[a-z0-9-]+$/i;
|
|
403
|
-
/** How much of the base color each shade keeps, mixed with white (light) or black (dark). */
|
|
404
462
|
const SHADES = [
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
463
|
+
[
|
|
464
|
+
50,
|
|
465
|
+
6,
|
|
466
|
+
"white"
|
|
467
|
+
],
|
|
468
|
+
[
|
|
469
|
+
100,
|
|
470
|
+
12,
|
|
471
|
+
"white"
|
|
472
|
+
],
|
|
473
|
+
[
|
|
474
|
+
200,
|
|
475
|
+
24,
|
|
476
|
+
"white"
|
|
477
|
+
],
|
|
478
|
+
[
|
|
479
|
+
300,
|
|
480
|
+
42,
|
|
481
|
+
"white"
|
|
482
|
+
],
|
|
483
|
+
[
|
|
484
|
+
400,
|
|
485
|
+
66,
|
|
486
|
+
"white"
|
|
487
|
+
],
|
|
488
|
+
[
|
|
489
|
+
500,
|
|
490
|
+
85,
|
|
491
|
+
"white"
|
|
492
|
+
],
|
|
493
|
+
[
|
|
494
|
+
600,
|
|
495
|
+
100,
|
|
496
|
+
null
|
|
497
|
+
],
|
|
498
|
+
[
|
|
499
|
+
700,
|
|
500
|
+
84,
|
|
501
|
+
"black"
|
|
502
|
+
],
|
|
503
|
+
[
|
|
504
|
+
800,
|
|
505
|
+
68,
|
|
506
|
+
"black"
|
|
507
|
+
],
|
|
508
|
+
[
|
|
509
|
+
900,
|
|
510
|
+
54,
|
|
511
|
+
"black"
|
|
512
|
+
],
|
|
513
|
+
[
|
|
514
|
+
950,
|
|
515
|
+
36,
|
|
516
|
+
"black"
|
|
517
|
+
]
|
|
416
518
|
];
|
|
417
|
-
/** Custom properties a primary color controls (the scale + the decorative accent). */
|
|
418
519
|
const PRIMARY_VARS = [
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
520
|
+
...SHADES.map(([shade]) => `--shk-primary-${shade}`),
|
|
521
|
+
"--shk-emerald-400",
|
|
522
|
+
"--shk-emerald-600",
|
|
523
|
+
"--shk-emerald-700"
|
|
423
524
|
];
|
|
424
|
-
/** Throws when `color` is not a hex color. */
|
|
425
525
|
function assertHexColor(color, where) {
|
|
426
|
-
|
|
427
|
-
throw new Error(`[shk-config] ${where}: "${color}" is not a hex color such as #2563eb.`);
|
|
428
|
-
}
|
|
526
|
+
if (!HEX.test(color)) throw new Error(`[shk-config] ${where}: "${color}" is not a hex color such as #2563eb.`);
|
|
429
527
|
}
|
|
430
|
-
/** `--shk-primary-50` … `--shk-primary-950` (and the accent vars) derived from one color. */
|
|
431
528
|
function primaryScale(color) {
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
// Themes keep the decorative gradient in the accent color.
|
|
439
|
-
vars['--shk-emerald-400'] = vars['--shk-primary-400'];
|
|
440
|
-
vars['--shk-emerald-600'] = vars['--shk-primary-600'];
|
|
441
|
-
vars['--shk-emerald-700'] = vars['--shk-primary-700'];
|
|
442
|
-
return vars;
|
|
529
|
+
const vars = {};
|
|
530
|
+
for (const [shade, base, mixWith] of SHADES) vars[`--shk-primary-${shade}`] = mixWith ? `color-mix(in oklab, ${color} ${base}%, ${mixWith})` : color;
|
|
531
|
+
vars["--shk-emerald-400"] = vars["--shk-primary-400"];
|
|
532
|
+
vars["--shk-emerald-600"] = vars["--shk-primary-600"];
|
|
533
|
+
vars["--shk-emerald-700"] = vars["--shk-primary-700"];
|
|
534
|
+
return vars;
|
|
443
535
|
}
|
|
444
|
-
/** Normalizes `'#2563eb' | { primary }` and validates name and colors. */
|
|
445
536
|
function normalizeCustomTheme(name, theme) {
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
for (const [prop, value] of Object.entries(normalized.vars ?? {})) {
|
|
452
|
-
// The values are written into a CSS rule: reject anything that could end it.
|
|
453
|
-
if (!CSS_VAR_NAME.test(prop) || typeof value !== 'string' || /[;{}<>]/.test(value)) {
|
|
454
|
-
throw new Error(`[shk-config] theme "${name}": invalid variable ${prop}: ${String(value)} (names are --shk-…; values cannot contain ; { } < >).`);
|
|
455
|
-
}
|
|
456
|
-
}
|
|
457
|
-
return normalized;
|
|
537
|
+
if (!THEME_NAME.test(name)) throw new Error(`[shk-config] Theme name "${name}" must start with a letter and contain only letters, digits and dashes.`);
|
|
538
|
+
const normalized = typeof theme === "string" ? { primary: theme } : theme;
|
|
539
|
+
assertHexColor(normalized.primary, `theme "${name}"`);
|
|
540
|
+
for (const [prop, value] of Object.entries(normalized.vars ?? {})) if (!CSS_VAR_NAME.test(prop) || typeof value !== "string" || /[;{}<>]/.test(value)) throw new Error(`[shk-config] theme "${name}": invalid variable ${prop}: ${String(value)} (names are --shk-…; values cannot contain ; { } < >).`);
|
|
541
|
+
return normalized;
|
|
458
542
|
}
|
|
459
|
-
/** CSS rule that activates a custom theme through `<html data-shk-theme="name">`. */
|
|
460
543
|
function customThemeCss(name, theme, attribute) {
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
544
|
+
const vars = {
|
|
545
|
+
...primaryScale(theme.primary),
|
|
546
|
+
...theme.vars ?? {}
|
|
547
|
+
};
|
|
548
|
+
return `[${attribute}='${name}'] {\n${Object.entries(vars).map(([prop, value]) => ` ${prop}: ${value};`).join("\n")}\n}`;
|
|
466
549
|
}
|
|
467
|
-
/** Neutral palettes for `theme.surface` (Tailwind scales, 50 … 900). */
|
|
468
550
|
const SURFACE_PALETTES = {
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
551
|
+
slate: {
|
|
552
|
+
label: "Slate",
|
|
553
|
+
scale: [
|
|
554
|
+
"#f8fafc",
|
|
555
|
+
"#f1f5f9",
|
|
556
|
+
"#e2e8f0",
|
|
557
|
+
"#cbd5e1",
|
|
558
|
+
"#94a3b8",
|
|
559
|
+
"#64748b",
|
|
560
|
+
"#475569",
|
|
561
|
+
"#334155",
|
|
562
|
+
"#1e293b",
|
|
563
|
+
"#0f172a"
|
|
564
|
+
]
|
|
565
|
+
},
|
|
566
|
+
gray: {
|
|
567
|
+
label: "Gray",
|
|
568
|
+
scale: [
|
|
569
|
+
"#f9fafb",
|
|
570
|
+
"#f3f4f6",
|
|
571
|
+
"#e5e7eb",
|
|
572
|
+
"#d1d5db",
|
|
573
|
+
"#9ca3af",
|
|
574
|
+
"#6b7280",
|
|
575
|
+
"#4b5563",
|
|
576
|
+
"#374151",
|
|
577
|
+
"#1f2937",
|
|
578
|
+
"#111827"
|
|
579
|
+
]
|
|
580
|
+
},
|
|
581
|
+
zinc: {
|
|
582
|
+
label: "Zinc",
|
|
583
|
+
scale: [
|
|
584
|
+
"#fafafa",
|
|
585
|
+
"#f4f4f5",
|
|
586
|
+
"#e4e4e7",
|
|
587
|
+
"#d4d4d8",
|
|
588
|
+
"#a1a1aa",
|
|
589
|
+
"#71717a",
|
|
590
|
+
"#52525b",
|
|
591
|
+
"#3f3f46",
|
|
592
|
+
"#27272a",
|
|
593
|
+
"#18181b"
|
|
594
|
+
]
|
|
595
|
+
},
|
|
596
|
+
neutral: {
|
|
597
|
+
label: "Neutral",
|
|
598
|
+
scale: [
|
|
599
|
+
"#fafafa",
|
|
600
|
+
"#f5f5f5",
|
|
601
|
+
"#e5e5e5",
|
|
602
|
+
"#d4d4d4",
|
|
603
|
+
"#a3a3a3",
|
|
604
|
+
"#737373",
|
|
605
|
+
"#525252",
|
|
606
|
+
"#404040",
|
|
607
|
+
"#262626",
|
|
608
|
+
"#171717"
|
|
609
|
+
]
|
|
610
|
+
},
|
|
611
|
+
stone: {
|
|
612
|
+
label: "Stone",
|
|
613
|
+
scale: [
|
|
614
|
+
"#fafaf9",
|
|
615
|
+
"#f5f5f4",
|
|
616
|
+
"#e7e5e4",
|
|
617
|
+
"#d6d3d1",
|
|
618
|
+
"#a8a29e",
|
|
619
|
+
"#78716c",
|
|
620
|
+
"#57534e",
|
|
621
|
+
"#44403c",
|
|
622
|
+
"#292524",
|
|
623
|
+
"#1c1917"
|
|
624
|
+
]
|
|
625
|
+
}
|
|
489
626
|
};
|
|
490
|
-
const SURFACE_STEPS = [
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
627
|
+
const SURFACE_STEPS = [
|
|
628
|
+
50,
|
|
629
|
+
100,
|
|
630
|
+
200,
|
|
631
|
+
300,
|
|
632
|
+
400,
|
|
633
|
+
500,
|
|
634
|
+
600,
|
|
635
|
+
700,
|
|
636
|
+
800,
|
|
637
|
+
900
|
|
638
|
+
];
|
|
639
|
+
function surfaceCss(attribute = "data-shk-surface") {
|
|
640
|
+
return Object.entries(SURFACE_PALETTES).map(([name, { scale }]) => {
|
|
641
|
+
const sel = `html[${attribute}='${name}'][${attribute}]`;
|
|
642
|
+
const light = SURFACE_STEPS.map((step, i) => `--shk-surface-${step}: ${scale[i]};`).join(" ");
|
|
643
|
+
const dark = SURFACE_STEPS.map((step, i) => `--shk-surface-${step}: ${scale[9 - i]};`).join(" ");
|
|
644
|
+
return `${sel} { ${light} --shk-scrollbar-thumb: ${scale[3]}; --shk-scrollbar-thumb-hover: ${scale[4]}; }\nhtml.dark[${attribute}='${name}'][${attribute}] { ${dark} --shk-scrollbar-thumb: ${scale[6]}; --shk-scrollbar-thumb-hover: ${scale[5]}; }`;
|
|
645
|
+
}).join("\n");
|
|
506
646
|
}
|
|
507
|
-
/** The built-in theme packs as presets. */
|
|
508
647
|
const BUILT_IN_PRESETS = [
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
648
|
+
{
|
|
649
|
+
name: "default",
|
|
650
|
+
label: "Esmeralda",
|
|
651
|
+
primary: "#059669",
|
|
652
|
+
surface: "zinc"
|
|
653
|
+
},
|
|
654
|
+
{
|
|
655
|
+
name: "ocean",
|
|
656
|
+
label: "Océano",
|
|
657
|
+
primary: "#0284c7",
|
|
658
|
+
surface: "slate"
|
|
659
|
+
},
|
|
660
|
+
{
|
|
661
|
+
name: "violet",
|
|
662
|
+
label: "Violeta",
|
|
663
|
+
primary: "#7c3aed",
|
|
664
|
+
surface: "zinc"
|
|
665
|
+
},
|
|
666
|
+
{
|
|
667
|
+
name: "sunset",
|
|
668
|
+
label: "Atardecer",
|
|
669
|
+
primary: "#ea580c",
|
|
670
|
+
surface: "stone"
|
|
671
|
+
}
|
|
513
672
|
];
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
* Authors: Roberto Valladares Martin (Ansem13), Julio César García García (Sanjuli14).
|
|
518
|
-
* Belongs to Shirkasoft.
|
|
519
|
-
*/
|
|
520
|
-
/**
|
|
521
|
-
* Theme packs offered as presets (built-in + `withTheme({ themes })`), with the
|
|
522
|
-
* primary color and surface each one uses. Read by `shk-theme-picker`.
|
|
523
|
-
*/
|
|
524
|
-
const SHK_THEME_PRESETS = new InjectionToken('SHK_THEME_PRESETS', {
|
|
525
|
-
providedIn: 'root',
|
|
526
|
-
factory: () => BUILT_IN_PRESETS,
|
|
673
|
+
const SHK_THEME_PRESETS = new InjectionToken("SHK_THEME_PRESETS", {
|
|
674
|
+
providedIn: "root",
|
|
675
|
+
factory: () => BUILT_IN_PRESETS
|
|
527
676
|
});
|
|
528
|
-
|
|
529
|
-
const SURFACE_ATTRIBUTE = 'data-shk-surface';
|
|
677
|
+
const SURFACE_ATTRIBUTE = "data-shk-surface";
|
|
530
678
|
function feature(value, extra = []) {
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
679
|
+
return { ɵproviders: [{
|
|
680
|
+
provide: SHK_CONFIG_FEATURES,
|
|
681
|
+
multi: true,
|
|
682
|
+
useValue: value
|
|
683
|
+
}, ...extra] };
|
|
534
684
|
}
|
|
535
|
-
/** Drops `undefined` entries and prefixes the keys with the module name. */
|
|
536
685
|
function defaultsOf(module, values) {
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
out[`${module}.${name}`] = value;
|
|
541
|
-
}
|
|
542
|
-
return out;
|
|
686
|
+
const out = {};
|
|
687
|
+
for (const [name, value] of Object.entries(values)) if (value !== void 0) out[`${module}.${name}`] = value;
|
|
688
|
+
return out;
|
|
543
689
|
}
|
|
544
|
-
/**
|
|
545
|
-
* Configures the library. Every module is optional; component inputs still
|
|
546
|
-
* override the configured values.
|
|
547
|
-
*
|
|
548
|
-
* ```ts
|
|
549
|
-
* bootstrapApplication(App, {
|
|
550
|
-
* providers: [
|
|
551
|
-
* provideShk(
|
|
552
|
-
* withDates({ locale: 'es', format: 'dd/MM/yyyy' }),
|
|
553
|
-
* withNumbers({ currency: 'EUR', locale: 'es-ES' }),
|
|
554
|
-
* withTheme({ defaultTheme: 'marca', themes: { marca: '#2563eb' } }),
|
|
555
|
-
* withPersistence(),
|
|
556
|
-
* ),
|
|
557
|
-
* ],
|
|
558
|
-
* });
|
|
559
|
-
* ```
|
|
560
|
-
*/
|
|
561
690
|
function provideShk(...features) {
|
|
562
|
-
|
|
691
|
+
return makeEnvironmentProviders(features.flatMap((f) => f.ɵproviders));
|
|
563
692
|
}
|
|
564
|
-
/** Date module: locale, pattern, display style, 12/24 h and first day of the week. */
|
|
565
693
|
function withDates(config) {
|
|
566
|
-
|
|
694
|
+
return feature({ defaults: defaultsOf("dates", config) });
|
|
567
695
|
}
|
|
568
|
-
/** Number module: separators locale, currency, currency symbol and decimals. */
|
|
569
696
|
function withNumbers(config) {
|
|
570
|
-
|
|
697
|
+
return feature({ defaults: defaultsOf("numbers", config) });
|
|
571
698
|
}
|
|
572
|
-
/**
|
|
573
|
-
* Theme module: built-in and custom themes, light/dark/system scheme and a
|
|
574
|
-
* runtime primary color. Replaces `provideShkTheme()` (do not use both).
|
|
575
|
-
*
|
|
576
|
-
* `theme.name` and `theme.scheme` are shared with `ShkThemeService` (which
|
|
577
|
-
* persists them); `theme.primary` is stored by `withPersistence()`.
|
|
578
|
-
*/
|
|
579
699
|
function withTheme(config = {}) {
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
700
|
+
const { themes = {}, primary = "", surface = "", ...themeConfig } = config;
|
|
701
|
+
const resolved = {
|
|
702
|
+
...DEFAULT_SHK_THEME_CONFIG,
|
|
703
|
+
...themeConfig
|
|
704
|
+
};
|
|
705
|
+
const custom = Object.entries(themes).map(([name, theme]) => [name, normalizeCustomTheme(name, theme)]);
|
|
706
|
+
if (primary) assertHexColor(primary, "withTheme({ primary })");
|
|
707
|
+
const presets = [...BUILT_IN_PRESETS, ...custom.map(([name, theme]) => ({
|
|
708
|
+
name,
|
|
709
|
+
label: theme.label ?? name,
|
|
710
|
+
primary: theme.primary,
|
|
711
|
+
surface: ""
|
|
712
|
+
}))];
|
|
713
|
+
return feature({ options: [
|
|
714
|
+
{
|
|
715
|
+
key: "theme.name",
|
|
716
|
+
module: "theme",
|
|
717
|
+
type: "select",
|
|
718
|
+
default: resolved.defaultTheme,
|
|
719
|
+
label: "Tema",
|
|
720
|
+
description: "Paleta de colores de la interfaz.",
|
|
721
|
+
choices: presets.map((preset) => ({
|
|
722
|
+
value: preset.name,
|
|
723
|
+
label: preset.label
|
|
724
|
+
})),
|
|
725
|
+
persist: false
|
|
726
|
+
},
|
|
727
|
+
{
|
|
728
|
+
key: "theme.scheme",
|
|
729
|
+
module: "theme",
|
|
730
|
+
type: "select",
|
|
731
|
+
default: resolved.defaultScheme,
|
|
732
|
+
label: "Modo",
|
|
733
|
+
choices: [
|
|
734
|
+
{
|
|
735
|
+
value: "system",
|
|
736
|
+
label: "Según el sistema"
|
|
737
|
+
},
|
|
738
|
+
{
|
|
739
|
+
value: "light",
|
|
740
|
+
label: "Claro"
|
|
741
|
+
},
|
|
742
|
+
{
|
|
743
|
+
value: "dark",
|
|
744
|
+
label: "Oscuro"
|
|
745
|
+
}
|
|
746
|
+
],
|
|
747
|
+
persist: false
|
|
748
|
+
},
|
|
749
|
+
{
|
|
750
|
+
key: "theme.primary",
|
|
751
|
+
module: "theme",
|
|
752
|
+
type: "color",
|
|
753
|
+
default: primary,
|
|
754
|
+
label: "Color principal",
|
|
755
|
+
description: "Sustituye el color principal del tema. Vacío = el del tema."
|
|
756
|
+
},
|
|
757
|
+
{
|
|
758
|
+
key: "theme.surface",
|
|
759
|
+
module: "theme",
|
|
760
|
+
type: "select",
|
|
761
|
+
default: surface,
|
|
762
|
+
label: "Superficie",
|
|
763
|
+
description: "Gama de grises de fondos, bordes y textos. Vacío = la del tema.",
|
|
764
|
+
choices: [{
|
|
765
|
+
value: "",
|
|
766
|
+
label: "La del tema"
|
|
767
|
+
}, ...Object.entries(SURFACE_PALETTES).map(([value, { label }]) => ({
|
|
768
|
+
value,
|
|
769
|
+
label
|
|
770
|
+
}))]
|
|
771
|
+
}
|
|
772
|
+
] }, [
|
|
773
|
+
{
|
|
774
|
+
provide: SHK_THEME_CONFIG,
|
|
775
|
+
useValue: resolved
|
|
776
|
+
},
|
|
777
|
+
{
|
|
778
|
+
provide: SHK_THEME_PRESETS,
|
|
779
|
+
useValue: presets
|
|
780
|
+
},
|
|
781
|
+
provideAppInitializer(() => {
|
|
782
|
+
const doc = inject(DOCUMENT);
|
|
783
|
+
const themeService = inject(ShkThemeService);
|
|
784
|
+
const configService = inject(ShkConfigService);
|
|
785
|
+
const nonce = inject(CSP_NONCE, { optional: true });
|
|
786
|
+
const css = [surfaceCss(SURFACE_ATTRIBUTE), ...custom.map(([name, theme]) => customThemeCss(name, theme, resolved.attribute))].join("\n");
|
|
787
|
+
let style = doc.head?.querySelector("style[data-shk-themes]");
|
|
788
|
+
if (!style && doc.head) {
|
|
789
|
+
style = doc.createElement("style");
|
|
790
|
+
style.setAttribute("data-shk-themes", "");
|
|
791
|
+
if (nonce) style.setAttribute("nonce", nonce);
|
|
792
|
+
doc.head.appendChild(style);
|
|
793
|
+
}
|
|
794
|
+
if (style) style.textContent = css;
|
|
795
|
+
configService.bind("theme.name", {
|
|
796
|
+
value: themeService.theme,
|
|
797
|
+
set: (name) => themeService.setTheme(name)
|
|
798
|
+
});
|
|
799
|
+
configService.bind("theme.scheme", {
|
|
800
|
+
value: themeService.scheme,
|
|
801
|
+
set: (scheme) => themeService.setScheme(scheme)
|
|
802
|
+
});
|
|
803
|
+
const root = doc.documentElement;
|
|
804
|
+
effect(() => {
|
|
805
|
+
const color = configService.get("theme.primary")();
|
|
806
|
+
if (color) for (const [prop, value] of Object.entries(primaryScale(color))) root.style.setProperty(prop, value);
|
|
807
|
+
else for (const prop of PRIMARY_VARS) root.style.removeProperty(prop);
|
|
808
|
+
});
|
|
809
|
+
effect(() => {
|
|
810
|
+
const palette = configService.get("theme.surface")();
|
|
811
|
+
if (palette) root.setAttribute(SURFACE_ATTRIBUTE, palette);
|
|
812
|
+
else root.removeAttribute(SURFACE_ATTRIBUTE);
|
|
813
|
+
});
|
|
814
|
+
})
|
|
815
|
+
]);
|
|
695
816
|
}
|
|
696
|
-
/** Registers app-defined options in the same registry (`app.pageSize`, …). */
|
|
697
817
|
function withOptions(options) {
|
|
698
|
-
|
|
818
|
+
return feature({ options });
|
|
699
819
|
}
|
|
700
|
-
/**
|
|
701
|
-
* Persists changed options in localStorage so they survive reloads.
|
|
702
|
-
* Options with `persist: false` are skipped (the theme service stores its own).
|
|
703
|
-
*/
|
|
704
820
|
function withPersistence(config = {}) {
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
useValue: { storageKey: config.storageKey ?? 'shk-config' },
|
|
710
|
-
},
|
|
711
|
-
],
|
|
712
|
-
};
|
|
821
|
+
return { ɵproviders: [{
|
|
822
|
+
provide: SHK_CONFIG_PERSISTENCE,
|
|
823
|
+
useValue: { storageKey: config.storageKey ?? "shk-config" }
|
|
824
|
+
}] };
|
|
713
825
|
}
|
|
714
|
-
|
|
715
|
-
/**
|
|
716
|
-
* Shirkasoft UI Components.
|
|
717
|
-
* Authors: Roberto Valladares Martin (Ansem13), Julio César García García (Sanjuli14).
|
|
718
|
-
* Belongs to Shirkasoft.
|
|
719
|
-
*
|
|
720
|
-
* Locale-aware formatting helpers used by the components and available to apps.
|
|
721
|
-
* Pure functions on top of `Intl`: no Angular locale data needs registering.
|
|
722
|
-
*/
|
|
723
|
-
/** `Intl` formatters are expensive to build; reuse them per locale/options. */
|
|
724
|
-
const formatterCache = new Map();
|
|
826
|
+
const formatterCache = /* @__PURE__ */ new Map();
|
|
725
827
|
function dateFormatter(locale, options) {
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
828
|
+
const key = `d|${locale}|${JSON.stringify(options)}`;
|
|
829
|
+
let fmt = formatterCache.get(key);
|
|
830
|
+
if (!fmt) {
|
|
831
|
+
fmt = new Intl.DateTimeFormat(safeLocale(locale), options);
|
|
832
|
+
formatterCache.set(key, fmt);
|
|
833
|
+
}
|
|
834
|
+
return fmt;
|
|
733
835
|
}
|
|
734
836
|
function numberFormatter(locale, options) {
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
837
|
+
const key = `n|${locale}|${JSON.stringify(options)}`;
|
|
838
|
+
let fmt = formatterCache.get(key);
|
|
839
|
+
if (!fmt) {
|
|
840
|
+
fmt = new Intl.NumberFormat(safeLocale(locale), options);
|
|
841
|
+
formatterCache.set(key, fmt);
|
|
842
|
+
}
|
|
843
|
+
return fmt;
|
|
742
844
|
}
|
|
743
|
-
/** Falls back to the runtime default when the tag is not a valid BCP 47 locale. */
|
|
744
845
|
function safeLocale(locale) {
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
}
|
|
846
|
+
try {
|
|
847
|
+
return Intl.getCanonicalLocales(locale)[0];
|
|
848
|
+
} catch {
|
|
849
|
+
return;
|
|
850
|
+
}
|
|
751
851
|
}
|
|
752
|
-
/** Default numeric pattern for a locale: `MM/dd/yyyy` for English, `dd/MM/yyyy` otherwise. */
|
|
753
852
|
function resolveDateFormat(format, locale) {
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
return locale.toLowerCase().startsWith('en') ? 'MM/dd/yyyy' : 'dd/MM/yyyy';
|
|
853
|
+
if (format) return format;
|
|
854
|
+
return locale.toLowerCase().startsWith("en") ? "MM/dd/yyyy" : "dd/MM/yyyy";
|
|
757
855
|
}
|
|
758
|
-
/** Converts a value to a `Date`. ISO date-only strings (`2026-12-31`) are read as local dates. */
|
|
759
856
|
function toDate(value) {
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
}
|
|
769
|
-
}
|
|
770
|
-
const date = new Date(value);
|
|
771
|
-
return isNaN(date.getTime()) ? null : date;
|
|
857
|
+
if (value === null || value === void 0 || value === "") return null;
|
|
858
|
+
if (value instanceof Date) return isNaN(value.getTime()) ? null : value;
|
|
859
|
+
if (typeof value === "string") {
|
|
860
|
+
const dateOnly = /^(\d{4})-(\d{1,2})-(\d{1,2})$/.exec(value.trim());
|
|
861
|
+
if (dateOnly) return new Date(Number(dateOnly[1]), Number(dateOnly[2]) - 1, Number(dateOnly[3]));
|
|
862
|
+
}
|
|
863
|
+
const date = new Date(value);
|
|
864
|
+
return isNaN(date.getTime()) ? null : date;
|
|
772
865
|
}
|
|
773
|
-
const pad = (n, width = 2) => String(n).padStart(width,
|
|
774
|
-
/**
|
|
775
|
-
* Pattern tokens, longest first. Text between single quotes is copied verbatim.
|
|
776
|
-
* Compatible with the common Angular `DatePipe` tokens (`y` = full year).
|
|
777
|
-
*/
|
|
866
|
+
const pad = (n, width = 2) => String(n).padStart(width, "0");
|
|
778
867
|
const DATE_TOKENS = /'[^']*'|yyyy|yy|y|MMMM|MMM|MM|M|dd|d|EEEE|EEE|HH|H|hh|h|mm|ss|a/g;
|
|
779
|
-
/**
|
|
780
|
-
* Formats a date with a pattern (`dd/MM/yyyy`, `d MMM yyyy`, `yyyy-MM-dd HH:mm`…).
|
|
781
|
-
*
|
|
782
|
-
* Tokens: `yyyy y yy` year · `MMMM MMM MM M` month · `dd d` day · `EEEE EEE` weekday ·
|
|
783
|
-
* `HH H` 0-23 · `hh h` 1-12 · `mm` minutes · `ss` seconds · `a` AM/PM ·
|
|
784
|
-
* `'text'` literal. Month and weekday names follow `locale`, with its own casing
|
|
785
|
-
* ("31 dic 2026" in Spanish, "Dec 31, 2026" in English).
|
|
786
|
-
* Returns an empty string for empty or invalid values.
|
|
787
|
-
*/
|
|
788
868
|
function formatDate(value, pattern, locale) {
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
});
|
|
869
|
+
const date = toDate(value);
|
|
870
|
+
if (!date) return "";
|
|
871
|
+
const name = (options) => dateFormatter(locale, options).format(date).replace(".", "");
|
|
872
|
+
const h = date.getHours();
|
|
873
|
+
return pattern.replace(DATE_TOKENS, (token) => {
|
|
874
|
+
switch (token) {
|
|
875
|
+
case "yyyy":
|
|
876
|
+
case "y": return String(date.getFullYear());
|
|
877
|
+
case "yy": return pad(date.getFullYear() % 100);
|
|
878
|
+
case "MMMM": return name({ month: "long" });
|
|
879
|
+
case "MMM": return name({ month: "short" });
|
|
880
|
+
case "MM": return pad(date.getMonth() + 1);
|
|
881
|
+
case "M": return String(date.getMonth() + 1);
|
|
882
|
+
case "dd": return pad(date.getDate());
|
|
883
|
+
case "d": return String(date.getDate());
|
|
884
|
+
case "EEEE": return name({ weekday: "long" });
|
|
885
|
+
case "EEE": return name({ weekday: "short" });
|
|
886
|
+
case "HH": return pad(h);
|
|
887
|
+
case "H": return String(h);
|
|
888
|
+
case "hh": return pad(h % 12 || 12);
|
|
889
|
+
case "h": return String(h % 12 || 12);
|
|
890
|
+
case "mm": return pad(date.getMinutes());
|
|
891
|
+
case "ss": return pad(date.getSeconds());
|
|
892
|
+
case "a": return h < 12 ? "AM" : "PM";
|
|
893
|
+
default: return token.slice(1, -1);
|
|
894
|
+
}
|
|
895
|
+
});
|
|
817
896
|
}
|
|
818
|
-
/**
|
|
819
|
-
* Date formatted with an `Intl` style (`long`: "31 de diciembre de 2026"),
|
|
820
|
-
* optionally followed by the time in `timeStyle`.
|
|
821
|
-
*/
|
|
822
897
|
function formatDateStyle(value, style, locale, timeStyle) {
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
return dateFormatter(locale, options).format(date);
|
|
898
|
+
const date = toDate(value);
|
|
899
|
+
if (!date) return "";
|
|
900
|
+
return dateFormatter(locale, timeStyle ? {
|
|
901
|
+
dateStyle: style,
|
|
902
|
+
timeStyle
|
|
903
|
+
} : { dateStyle: style }).format(date);
|
|
830
904
|
}
|
|
831
|
-
/**
|
|
832
|
-
* Field order and separator of a pattern, for typing dates in an input.
|
|
833
|
-
* Named months and weekdays are typed as numbers (`d MMM yyyy` → `dd/MM/yyyy`).
|
|
834
|
-
*/
|
|
835
905
|
function typedDateLayout(pattern) {
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
906
|
+
const order = [];
|
|
907
|
+
for (const token of pattern.replace(/'[^']*'/g, "").match(/y+|M+|d+/g) ?? []) {
|
|
908
|
+
const field = token[0] === "y" ? "y" : token[0] === "M" ? "m" : "d";
|
|
909
|
+
if (!order.includes(field)) order.push(field);
|
|
910
|
+
}
|
|
911
|
+
for (const field of [
|
|
912
|
+
"d",
|
|
913
|
+
"m",
|
|
914
|
+
"y"
|
|
915
|
+
]) if (!order.includes(field)) order.push(field);
|
|
916
|
+
return {
|
|
917
|
+
order,
|
|
918
|
+
separator: /[\/\-.]/.exec(pattern)?.[0] ?? "/"
|
|
919
|
+
};
|
|
848
920
|
}
|
|
849
|
-
/** Narrow currency symbol (`USD` → `$`, `EUR` → `€`). Unknown codes are returned as-is. */
|
|
850
921
|
function currencySymbol(currency, locale) {
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
return currency;
|
|
861
|
-
}
|
|
922
|
+
try {
|
|
923
|
+
return numberFormatter(locale, {
|
|
924
|
+
style: "currency",
|
|
925
|
+
currency,
|
|
926
|
+
currencyDisplay: "narrowSymbol"
|
|
927
|
+
}).formatToParts(0).find((p) => p.type === "currency")?.value ?? currency;
|
|
928
|
+
} catch {
|
|
929
|
+
return currency;
|
|
930
|
+
}
|
|
862
931
|
}
|
|
863
|
-
/**
|
|
864
|
-
* Formats an amount as money (`$1,234.50`, `1.234,50 €`, `¥1,000`).
|
|
865
|
-
* `decimals` `null`/omitted = the currency's own digits (2 for USD, 0 for JPY).
|
|
866
|
-
*/
|
|
867
932
|
function formatCurrency(value, currency, locale, decimals = null) {
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
933
|
+
const n = typeof value === "string" ? Number(value) : value;
|
|
934
|
+
if (n === null || n === void 0 || !isFinite(n)) return "";
|
|
935
|
+
const digits = decimals === null ? {} : {
|
|
936
|
+
minimumFractionDigits: decimals,
|
|
937
|
+
maximumFractionDigits: decimals
|
|
938
|
+
};
|
|
939
|
+
try {
|
|
940
|
+
return numberFormatter(locale, {
|
|
941
|
+
style: "currency",
|
|
942
|
+
currency,
|
|
943
|
+
...digits
|
|
944
|
+
}).format(n);
|
|
945
|
+
} catch {
|
|
946
|
+
const d = decimals ?? 2;
|
|
947
|
+
return `${formatNumber(n, locale, d, d)} ${currency}`;
|
|
948
|
+
}
|
|
880
949
|
}
|
|
881
|
-
/** Decimal digits a currency uses by default (USD → 2, JPY → 0, BHD → 3). Unknown codes → 2. */
|
|
882
950
|
function currencyDecimals(currency) {
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
951
|
+
try {
|
|
952
|
+
return numberFormatter("en-US", {
|
|
953
|
+
style: "currency",
|
|
954
|
+
currency
|
|
955
|
+
}).resolvedOptions().maximumFractionDigits ?? 2;
|
|
956
|
+
} catch {
|
|
957
|
+
return 2;
|
|
958
|
+
}
|
|
890
959
|
}
|
|
891
|
-
/** Formats a number with the locale's grouping and decimal separators. */
|
|
892
960
|
function formatNumber(value, locale, maxDecimals = 2, minDecimals = 0) {
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
}).format(value);
|
|
961
|
+
if (!isFinite(value)) return "";
|
|
962
|
+
return numberFormatter(locale, {
|
|
963
|
+
minimumFractionDigits: minDecimals,
|
|
964
|
+
maximumFractionDigits: maxDecimals
|
|
965
|
+
}).format(value);
|
|
899
966
|
}
|
|
900
|
-
/** Decimal and grouping separators of a locale (`es-ES` → `,` and `.`). */
|
|
901
967
|
function numberSeparators(locale) {
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
968
|
+
const parts = numberFormatter(locale, {}).formatToParts(12345.6);
|
|
969
|
+
return {
|
|
970
|
+
decimal: parts.find((p) => p.type === "decimal")?.value ?? ".",
|
|
971
|
+
group: parts.find((p) => p.type === "group")?.value ?? ","
|
|
972
|
+
};
|
|
907
973
|
}
|
|
908
|
-
|
|
909
|
-
/**
|
|
910
|
-
* Generated bundle index. Do not edit.
|
|
911
|
-
*/
|
|
912
|
-
|
|
913
974
|
export { BUILT_IN_PRESETS, DATE_OPTIONS, NUMBER_OPTIONS, SHK_CONFIG_FEATURES, SHK_CONFIG_PERSISTENCE, SHK_THEME_PRESETS, SURFACE_PALETTES, ShkConfigService, currencyDecimals, currencySymbol, formatCurrency, formatDate, formatDateStyle, formatNumber, numberSeparators, primaryScale, provideShk, resolveDateFormat, toDate, typedDateLayout, withDates, withNumbers, withOptions, withPersistence, withTheme };
|
|
914
|
-
|
|
975
|
+
|
|
976
|
+
//# sourceMappingURL=shirkasoft-ui-components-config.mjs.map
|