shirkasoft-ui-components 1.14.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -8
- 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 +1624 -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 +484 -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 +517 -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 +1014 -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 +687 -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 +95 -134
- 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 +527 -398
- package/types/shirkasoft-ui-components-fieldset.d.ts +135 -60
- package/types/shirkasoft-ui-components-file-upload.d.ts +176 -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 +198 -113
- package/types/shirkasoft-ui-components-rail-sidebar.d.ts +262 -142
- package/types/shirkasoft-ui-components-select.d.ts +301 -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 +231 -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 +15 -16
- 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,113 +1,212 @@
|
|
|
1
|
-
import * as i0 from
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { ShkIconDirective } from
|
|
5
|
-
import { getIcon } from
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Default primary colors (Tailwind 600 shades). Red and rose are left out on
|
|
9
|
-
* purpose: red is reserved for danger states.
|
|
10
|
-
*/
|
|
1
|
+
import * as i0 from "@angular/core";
|
|
2
|
+
import { ChangeDetectionStrategy, Component, ElementRef, computed, inject, input, signal, viewChild } from "@angular/core";
|
|
3
|
+
import { SHK_THEME_PRESETS, SURFACE_PALETTES, ShkConfigService } from "shirkasoft-ui-components/config";
|
|
4
|
+
import { ShkIconDirective } from "shirkasoft-ui-components/icons";
|
|
5
|
+
import { getIcon } from "shirkasoft-ui-components/utils";
|
|
11
6
|
const DEFAULT_PRIMARY_COLORS = [
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
7
|
+
{
|
|
8
|
+
color: "#334155",
|
|
9
|
+
label: "Noir"
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
color: "#059669",
|
|
13
|
+
label: "Emerald"
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
color: "#16a34a",
|
|
17
|
+
label: "Green"
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
color: "#65a30d",
|
|
21
|
+
label: "Lime"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
color: "#ea580c",
|
|
25
|
+
label: "Orange"
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
color: "#d97706",
|
|
29
|
+
label: "Amber"
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
color: "#ca8a04",
|
|
33
|
+
label: "Yellow"
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
color: "#0d9488",
|
|
37
|
+
label: "Teal"
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
color: "#0891b2",
|
|
41
|
+
label: "Cyan"
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
color: "#0284c7",
|
|
45
|
+
label: "Sky"
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
color: "#2563eb",
|
|
49
|
+
label: "Blue"
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
color: "#4f46e5",
|
|
53
|
+
label: "Indigo"
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
color: "#7c3aed",
|
|
57
|
+
label: "Violet"
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
color: "#9333ea",
|
|
61
|
+
label: "Purple"
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
color: "#c026d3",
|
|
65
|
+
label: "Fuchsia"
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
color: "#db2777",
|
|
69
|
+
label: "Pink"
|
|
70
|
+
}
|
|
28
71
|
];
|
|
29
72
|
let pickerCounter = 0;
|
|
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
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
73
|
+
var ThemePickerComponent = class ThemePickerComponent {
|
|
74
|
+
constructor() {
|
|
75
|
+
this.config = inject(ShkConfigService);
|
|
76
|
+
this.host = inject(ElementRef);
|
|
77
|
+
this.trigger = viewChild("trigger", ...ngDevMode ? [{ debugName: "trigger" }] : /* istanbul ignore next */ []);
|
|
78
|
+
this.primaryColors = input(DEFAULT_PRIMARY_COLORS, ...ngDevMode ? [{ debugName: "primaryColors" }] : /* istanbul ignore next */ []);
|
|
79
|
+
this.showSurface = input(true, ...ngDevMode ? [{ debugName: "showSurface" }] : /* istanbul ignore next */ []);
|
|
80
|
+
this.showPresets = input(true, ...ngDevMode ? [{ debugName: "showPresets" }] : /* istanbul ignore next */ []);
|
|
81
|
+
this.triggerLabel = input("Personalizar tema", ...ngDevMode ? [{ debugName: "triggerLabel" }] : /* istanbul ignore next */ []);
|
|
82
|
+
this.primaryLabel = input("Primario", ...ngDevMode ? [{ debugName: "primaryLabel" }] : /* istanbul ignore next */ []);
|
|
83
|
+
this.surfaceLabel = input("Superficie", ...ngDevMode ? [{ debugName: "surfaceLabel" }] : /* istanbul ignore next */ []);
|
|
84
|
+
this.presetsLabel = input("Temas", ...ngDevMode ? [{ debugName: "presetsLabel" }] : /* istanbul ignore next */ []);
|
|
85
|
+
this.available = this.config.has("theme.primary") && this.config.has("theme.surface");
|
|
86
|
+
this.open = signal(false, ...ngDevMode ? [{ debugName: "open" }] : /* istanbul ignore next */ []);
|
|
87
|
+
this.panelId = `shk-theme-picker-${++pickerCounter}`;
|
|
88
|
+
this.paletteIcon = getIcon("palette");
|
|
89
|
+
this.presets = inject(SHK_THEME_PRESETS);
|
|
90
|
+
this.surfaces = Object.entries(SURFACE_PALETTES).map(([name, palette]) => ({
|
|
91
|
+
name,
|
|
92
|
+
label: palette.label,
|
|
93
|
+
color: palette.scale[5]
|
|
94
|
+
}));
|
|
95
|
+
this.themeName = computed(() => this.available ? this.config.get("theme.name")() : "", ...ngDevMode ? [{ debugName: "themeName" }] : /* istanbul ignore next */ []);
|
|
96
|
+
this.currentPreset = computed(() => this.presets.find((preset) => preset.name === this.themeName()), ...ngDevMode ? [{ debugName: "currentPreset" }] : /* istanbul ignore next */ []);
|
|
97
|
+
this.primaryOverride = computed(() => this.available ? this.config.get("theme.primary")() : "", ...ngDevMode ? [{ debugName: "primaryOverride" }] : /* istanbul ignore next */ []);
|
|
98
|
+
this.surfaceOverride = computed(() => this.available ? this.config.get("theme.surface")() : "", ...ngDevMode ? [{ debugName: "surfaceOverride" }] : /* istanbul ignore next */ []);
|
|
99
|
+
this.activePrimary = computed(() => (this.primaryOverride() || this.currentPreset()?.primary || "").toLowerCase(), ...ngDevMode ? [{ debugName: "activePrimary" }] : /* istanbul ignore next */ []);
|
|
100
|
+
this.activeSurface = computed(() => this.surfaceOverride() || this.currentPreset()?.surface || "", ...ngDevMode ? [{ debugName: "activeSurface" }] : /* istanbul ignore next */ []);
|
|
101
|
+
this.isPresetPure = computed(() => !this.primaryOverride() && !this.surfaceOverride(), ...ngDevMode ? [{ debugName: "isPresetPure" }] : /* istanbul ignore next */ []);
|
|
102
|
+
}
|
|
103
|
+
toggle() {
|
|
104
|
+
this.open.update((open) => !open);
|
|
105
|
+
}
|
|
106
|
+
setPrimary(color) {
|
|
107
|
+
const own = this.currentPreset()?.primary.toLowerCase();
|
|
108
|
+
this.config.set("theme.primary", color.toLowerCase() === own ? "" : color);
|
|
109
|
+
}
|
|
110
|
+
setSurface(name) {
|
|
111
|
+
this.config.set("theme.surface", name === this.currentPreset()?.surface ? "" : name);
|
|
112
|
+
}
|
|
113
|
+
setPreset(name) {
|
|
114
|
+
this.config.set("theme.name", name);
|
|
115
|
+
this.config.set("theme.primary", "");
|
|
116
|
+
this.config.set("theme.surface", "");
|
|
117
|
+
}
|
|
118
|
+
onDocumentPointerDown(event) {
|
|
119
|
+
if (this.open() && !this.host.nativeElement.contains(event.target)) this.open.set(false);
|
|
120
|
+
}
|
|
121
|
+
onEscape() {
|
|
122
|
+
if (!this.open()) return;
|
|
123
|
+
this.open.set(false);
|
|
124
|
+
this.trigger()?.nativeElement.focus();
|
|
125
|
+
}
|
|
126
|
+
static {
|
|
127
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
128
|
+
minVersion: "12.0.0",
|
|
129
|
+
version: "22.3.2",
|
|
130
|
+
ngImport: i0,
|
|
131
|
+
type: ThemePickerComponent,
|
|
132
|
+
deps: [],
|
|
133
|
+
target: i0.ɵɵFactoryTarget.Component
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
static {
|
|
137
|
+
this.ɵcmp = i0.ɵɵngDeclareComponent({
|
|
138
|
+
minVersion: "17.0.0",
|
|
139
|
+
version: "22.3.2",
|
|
140
|
+
type: ThemePickerComponent,
|
|
141
|
+
isStandalone: true,
|
|
142
|
+
selector: "shk-theme-picker",
|
|
143
|
+
inputs: {
|
|
144
|
+
primaryColors: {
|
|
145
|
+
classPropertyName: "primaryColors",
|
|
146
|
+
publicName: "primaryColors",
|
|
147
|
+
isSignal: true,
|
|
148
|
+
isRequired: false,
|
|
149
|
+
transformFunction: null
|
|
150
|
+
},
|
|
151
|
+
showSurface: {
|
|
152
|
+
classPropertyName: "showSurface",
|
|
153
|
+
publicName: "showSurface",
|
|
154
|
+
isSignal: true,
|
|
155
|
+
isRequired: false,
|
|
156
|
+
transformFunction: null
|
|
157
|
+
},
|
|
158
|
+
showPresets: {
|
|
159
|
+
classPropertyName: "showPresets",
|
|
160
|
+
publicName: "showPresets",
|
|
161
|
+
isSignal: true,
|
|
162
|
+
isRequired: false,
|
|
163
|
+
transformFunction: null
|
|
164
|
+
},
|
|
165
|
+
triggerLabel: {
|
|
166
|
+
classPropertyName: "triggerLabel",
|
|
167
|
+
publicName: "triggerLabel",
|
|
168
|
+
isSignal: true,
|
|
169
|
+
isRequired: false,
|
|
170
|
+
transformFunction: null
|
|
171
|
+
},
|
|
172
|
+
primaryLabel: {
|
|
173
|
+
classPropertyName: "primaryLabel",
|
|
174
|
+
publicName: "primaryLabel",
|
|
175
|
+
isSignal: true,
|
|
176
|
+
isRequired: false,
|
|
177
|
+
transformFunction: null
|
|
178
|
+
},
|
|
179
|
+
surfaceLabel: {
|
|
180
|
+
classPropertyName: "surfaceLabel",
|
|
181
|
+
publicName: "surfaceLabel",
|
|
182
|
+
isSignal: true,
|
|
183
|
+
isRequired: false,
|
|
184
|
+
transformFunction: null
|
|
185
|
+
},
|
|
186
|
+
presetsLabel: {
|
|
187
|
+
classPropertyName: "presetsLabel",
|
|
188
|
+
publicName: "presetsLabel",
|
|
189
|
+
isSignal: true,
|
|
190
|
+
isRequired: false,
|
|
191
|
+
transformFunction: null
|
|
192
|
+
}
|
|
193
|
+
},
|
|
194
|
+
host: {
|
|
195
|
+
listeners: {
|
|
196
|
+
"document:pointerdown": "onDocumentPointerDown($event)",
|
|
197
|
+
"document:keydown.escape": "onEscape()"
|
|
198
|
+
},
|
|
199
|
+
classAttribute: "shk-theme-picker"
|
|
200
|
+
},
|
|
201
|
+
viewQueries: [{
|
|
202
|
+
propertyName: "trigger",
|
|
203
|
+
first: true,
|
|
204
|
+
predicate: ["trigger"],
|
|
205
|
+
descendants: true,
|
|
206
|
+
isSignal: true
|
|
207
|
+
}],
|
|
208
|
+
ngImport: i0,
|
|
209
|
+
template: `
|
|
111
210
|
@if (available) {
|
|
112
211
|
<button
|
|
113
212
|
#trigger
|
|
@@ -184,15 +283,41 @@ class ThemePickerComponent {
|
|
|
184
283
|
</div>
|
|
185
284
|
}
|
|
186
285
|
}
|
|
187
|
-
`,
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
286
|
+
`,
|
|
287
|
+
isInline: true,
|
|
288
|
+
styles: [":host{position:relative;display:inline-flex}.shk-tp-trigger{display:grid;place-items:center;width:2.25rem;height:2.25rem;border:0;border-radius:9999px;cursor:pointer;color:#fff;background-color:var(--shk-primary-600);transition:filter .15s ease}.shk-tp-trigger:hover{filter:brightness(1.1)}.shk-tp-trigger:focus-visible{outline:2px solid var(--shk-primary-600);outline-offset:2px}.shk-tp-trigger-icon{width:1.15rem;height:1.15rem}.shk-tp-panel{position:absolute;top:calc(100% + .5rem);right:0;z-index:70;width:max-content;max-width:min(19rem,calc(100vw - 1.5rem));padding:.875rem 1rem 1rem;border-radius:.75rem;border:1px solid var(--shk-surface-200);box-shadow:0 10px 30px #00000024;display:grid;gap:.875rem;text-align:left}.shk-tp-title{display:block;margin-bottom:.5rem;font-size:.8125rem;font-weight:600;color:var(--shk-surface-600)}.shk-tp-swatches{display:grid;grid-template-columns:repeat(8,1.375rem);gap:.5rem}.shk-tp-swatch{width:1.375rem;height:1.375rem;padding:0;border:0;border-radius:9999px;cursor:pointer;transition:transform .12s ease}.shk-tp-swatch:hover{transform:scale(1.12)}.shk-tp-swatch:focus-visible,.shk-tp-swatch.is-selected{outline:2px solid var(--shk-surface-800);outline-offset:2px}.shk-tp-segmented{display:flex;flex-wrap:wrap;gap:.25rem;padding:.25rem;border-radius:.5rem;background-color:var(--shk-surface-100)}.shk-tp-segment{padding:.3rem .65rem;border:0;border-radius:.375rem;background:transparent;font-size:.8125rem;color:var(--shk-surface-600);cursor:pointer}.shk-tp-segment:hover{color:var(--shk-surface-800)}.shk-tp-segment:focus-visible{outline:2px solid var(--shk-primary-600);outline-offset:1px}.shk-tp-segment.is-active{background-color:var(--shk-surface-50);color:var(--shk-surface-900);font-weight:600;box-shadow:0 1px 2px #0000001f}\n"],
|
|
289
|
+
dependencies: [{
|
|
290
|
+
kind: "directive",
|
|
291
|
+
type: ShkIconDirective,
|
|
292
|
+
selector: "svg[shkIcon]",
|
|
293
|
+
inputs: [
|
|
294
|
+
"shkIcon",
|
|
295
|
+
"size",
|
|
296
|
+
"strokeWidth",
|
|
297
|
+
"color"
|
|
298
|
+
]
|
|
299
|
+
}],
|
|
300
|
+
changeDetection: i0.ChangeDetectionStrategy.OnPush
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
};
|
|
304
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
305
|
+
minVersion: "12.0.0",
|
|
306
|
+
version: "22.3.2",
|
|
307
|
+
ngImport: i0,
|
|
308
|
+
type: ThemePickerComponent,
|
|
309
|
+
decorators: [{
|
|
310
|
+
type: Component,
|
|
311
|
+
args: [{
|
|
312
|
+
selector: "shk-theme-picker",
|
|
313
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
314
|
+
imports: [ShkIconDirective],
|
|
315
|
+
host: {
|
|
316
|
+
class: "shk-theme-picker",
|
|
317
|
+
"(document:pointerdown)": "onDocumentPointerDown($event)",
|
|
318
|
+
"(document:keydown.escape)": "onEscape()"
|
|
319
|
+
},
|
|
320
|
+
template: `
|
|
196
321
|
@if (available) {
|
|
197
322
|
<button
|
|
198
323
|
#trigger
|
|
@@ -269,12 +394,73 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.27", ngImpo
|
|
|
269
394
|
</div>
|
|
270
395
|
}
|
|
271
396
|
}
|
|
272
|
-
`,
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
397
|
+
`,
|
|
398
|
+
styles: [":host{position:relative;display:inline-flex}.shk-tp-trigger{display:grid;place-items:center;width:2.25rem;height:2.25rem;border:0;border-radius:9999px;cursor:pointer;color:#fff;background-color:var(--shk-primary-600);transition:filter .15s ease}.shk-tp-trigger:hover{filter:brightness(1.1)}.shk-tp-trigger:focus-visible{outline:2px solid var(--shk-primary-600);outline-offset:2px}.shk-tp-trigger-icon{width:1.15rem;height:1.15rem}.shk-tp-panel{position:absolute;top:calc(100% + .5rem);right:0;z-index:70;width:max-content;max-width:min(19rem,calc(100vw - 1.5rem));padding:.875rem 1rem 1rem;border-radius:.75rem;border:1px solid var(--shk-surface-200);box-shadow:0 10px 30px #00000024;display:grid;gap:.875rem;text-align:left}.shk-tp-title{display:block;margin-bottom:.5rem;font-size:.8125rem;font-weight:600;color:var(--shk-surface-600)}.shk-tp-swatches{display:grid;grid-template-columns:repeat(8,1.375rem);gap:.5rem}.shk-tp-swatch{width:1.375rem;height:1.375rem;padding:0;border:0;border-radius:9999px;cursor:pointer;transition:transform .12s ease}.shk-tp-swatch:hover{transform:scale(1.12)}.shk-tp-swatch:focus-visible,.shk-tp-swatch.is-selected{outline:2px solid var(--shk-surface-800);outline-offset:2px}.shk-tp-segmented{display:flex;flex-wrap:wrap;gap:.25rem;padding:.25rem;border-radius:.5rem;background-color:var(--shk-surface-100)}.shk-tp-segment{padding:.3rem .65rem;border:0;border-radius:.375rem;background:transparent;font-size:.8125rem;color:var(--shk-surface-600);cursor:pointer}.shk-tp-segment:hover{color:var(--shk-surface-800)}.shk-tp-segment:focus-visible{outline:2px solid var(--shk-primary-600);outline-offset:1px}.shk-tp-segment.is-active{background-color:var(--shk-surface-50);color:var(--shk-surface-900);font-weight:600;box-shadow:0 1px 2px #0000001f}\n"]
|
|
399
|
+
}]
|
|
400
|
+
}],
|
|
401
|
+
propDecorators: {
|
|
402
|
+
trigger: [{
|
|
403
|
+
type: i0.ViewChild,
|
|
404
|
+
args: ["trigger", { isSignal: true }]
|
|
405
|
+
}],
|
|
406
|
+
primaryColors: [{
|
|
407
|
+
type: i0.Input,
|
|
408
|
+
args: [{
|
|
409
|
+
isSignal: true,
|
|
410
|
+
alias: "primaryColors",
|
|
411
|
+
required: false
|
|
412
|
+
}]
|
|
413
|
+
}],
|
|
414
|
+
showSurface: [{
|
|
415
|
+
type: i0.Input,
|
|
416
|
+
args: [{
|
|
417
|
+
isSignal: true,
|
|
418
|
+
alias: "showSurface",
|
|
419
|
+
required: false
|
|
420
|
+
}]
|
|
421
|
+
}],
|
|
422
|
+
showPresets: [{
|
|
423
|
+
type: i0.Input,
|
|
424
|
+
args: [{
|
|
425
|
+
isSignal: true,
|
|
426
|
+
alias: "showPresets",
|
|
427
|
+
required: false
|
|
428
|
+
}]
|
|
429
|
+
}],
|
|
430
|
+
triggerLabel: [{
|
|
431
|
+
type: i0.Input,
|
|
432
|
+
args: [{
|
|
433
|
+
isSignal: true,
|
|
434
|
+
alias: "triggerLabel",
|
|
435
|
+
required: false
|
|
436
|
+
}]
|
|
437
|
+
}],
|
|
438
|
+
primaryLabel: [{
|
|
439
|
+
type: i0.Input,
|
|
440
|
+
args: [{
|
|
441
|
+
isSignal: true,
|
|
442
|
+
alias: "primaryLabel",
|
|
443
|
+
required: false
|
|
444
|
+
}]
|
|
445
|
+
}],
|
|
446
|
+
surfaceLabel: [{
|
|
447
|
+
type: i0.Input,
|
|
448
|
+
args: [{
|
|
449
|
+
isSignal: true,
|
|
450
|
+
alias: "surfaceLabel",
|
|
451
|
+
required: false
|
|
452
|
+
}]
|
|
453
|
+
}],
|
|
454
|
+
presetsLabel: [{
|
|
455
|
+
type: i0.Input,
|
|
456
|
+
args: [{
|
|
457
|
+
isSignal: true,
|
|
458
|
+
alias: "presetsLabel",
|
|
459
|
+
required: false
|
|
460
|
+
}]
|
|
461
|
+
}]
|
|
462
|
+
}
|
|
463
|
+
});
|
|
279
464
|
export { DEFAULT_PRIMARY_COLORS, ThemePickerComponent };
|
|
280
|
-
|
|
465
|
+
|
|
466
|
+
//# sourceMappingURL=shirkasoft-ui-components-theme-picker.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shirkasoft-ui-components-theme-picker.mjs","sources":["../../../projects/ui-components/theme-picker/theme-picker.component.ts","../../../projects/ui-components/theme-picker/shirkasoft-ui-components-theme-picker.ts"],"sourcesContent":["import {\n ChangeDetectionStrategy,\n Component,\n ElementRef,\n computed,\n inject,\n input,\n signal,\n viewChild,\n} from '@angular/core';\nimport {\n SHK_THEME_PRESETS,\n SURFACE_PALETTES,\n ShkConfigService,\n} from 'shirkasoft-ui-components/config';\nimport { ShkIconDirective } from 'shirkasoft-ui-components/icons';\nimport { getIcon } from 'shirkasoft-ui-components/utils';\n\n/**\n * Shirkasoft UI Components.\n * Authors: Roberto Valladares Martin (Ansem13), Julio César García García (Sanjuli14).\n * Belongs to Shirkasoft.\n */\n\n/** A primary color offered by the picker. */\nexport interface ShkPickerColor {\n /** Hex color; it becomes `--shk-primary-600` (`theme.primary`). */\n color: string;\n /** Accessible name / tooltip. */\n label: string;\n}\n\n/**\n * Default primary colors (Tailwind 600 shades). Red and rose are left out on\n * purpose: red is reserved for danger states.\n */\nexport const DEFAULT_PRIMARY_COLORS: readonly ShkPickerColor[] = [\n { color: '#334155', label: 'Noir' },\n { color: '#059669', label: 'Emerald' },\n { color: '#16a34a', label: 'Green' },\n { color: '#65a30d', label: 'Lime' },\n { color: '#ea580c', label: 'Orange' },\n { color: '#d97706', label: 'Amber' },\n { color: '#ca8a04', label: 'Yellow' },\n { color: '#0d9488', label: 'Teal' },\n { color: '#0891b2', label: 'Cyan' },\n { color: '#0284c7', label: 'Sky' },\n { color: '#2563eb', label: 'Blue' },\n { color: '#4f46e5', label: 'Indigo' },\n { color: '#7c3aed', label: 'Violet' },\n { color: '#9333ea', label: 'Purple' },\n { color: '#c026d3', label: 'Fuchsia' },\n { color: '#db2777', label: 'Pink' },\n];\n\nlet pickerCounter = 0;\n\n/**\n * Theme customizer: a palette button that opens a panel to pick the primary\n * color, the surface (neutral) palette and a theme preset at runtime.\n *\n * It edits the `theme.primary`, `theme.surface` and `theme.name` options, so it\n * needs `provideShk(withTheme(...))`; add `withPersistence()` to remember the\n * choice. Without `withTheme()` it renders nothing.\n *\n * ```html\n * <shk-theme-picker />\n * ```\n */\n@Component({\n selector: 'shk-theme-picker',\n changeDetection: ChangeDetectionStrategy.OnPush,\n imports: [ShkIconDirective],\n host: {\n class: 'shk-theme-picker',\n '(document:pointerdown)': 'onDocumentPointerDown($event)',\n '(document:keydown.escape)': 'onEscape()',\n },\n template: `\n @if (available) {\n <button\n #trigger\n type=\"button\"\n class=\"shk-tp-trigger\"\n aria-haspopup=\"dialog\"\n [attr.aria-expanded]=\"open()\"\n [attr.aria-controls]=\"panelId\"\n [attr.aria-label]=\"triggerLabel()\"\n [attr.title]=\"triggerLabel()\"\n (click)=\"toggle()\"\n >\n <svg [shkIcon]=\"paletteIcon\" class=\"shk-tp-trigger-icon\"></svg>\n </button>\n\n @if (open()) {\n <div class=\"shk-tp-panel _shk-bg-panel-raised\" role=\"dialog\" [id]=\"panelId\" [attr.aria-label]=\"triggerLabel()\">\n <div class=\"shk-tp-section\">\n <span class=\"shk-tp-title\" [id]=\"panelId + '-primary'\">{{ primaryLabel() }}</span>\n <div class=\"shk-tp-swatches\" role=\"group\" [attr.aria-labelledby]=\"panelId + '-primary'\">\n @for (item of primaryColors(); track item.color) {\n <button\n type=\"button\"\n class=\"shk-tp-swatch\"\n [style.background-color]=\"item.color\"\n [class.is-selected]=\"item.color.toLowerCase() === activePrimary()\"\n [attr.aria-pressed]=\"item.color.toLowerCase() === activePrimary()\"\n [attr.aria-label]=\"item.label\"\n [attr.title]=\"item.label\"\n (click)=\"setPrimary(item.color)\"\n ></button>\n }\n </div>\n </div>\n\n @if (showSurface()) {\n <div class=\"shk-tp-section\">\n <span class=\"shk-tp-title\" [id]=\"panelId + '-surface'\">{{ surfaceLabel() }}</span>\n <div class=\"shk-tp-swatches\" role=\"group\" [attr.aria-labelledby]=\"panelId + '-surface'\">\n @for (item of surfaces; track item.name) {\n <button\n type=\"button\"\n class=\"shk-tp-swatch\"\n [style.background-color]=\"item.color\"\n [class.is-selected]=\"item.name === activeSurface()\"\n [attr.aria-pressed]=\"item.name === activeSurface()\"\n [attr.aria-label]=\"item.label\"\n [attr.title]=\"item.label\"\n (click)=\"setSurface(item.name)\"\n ></button>\n }\n </div>\n </div>\n }\n\n @if (showPresets() && presets.length > 1) {\n <div class=\"shk-tp-section\">\n <span class=\"shk-tp-title\" [id]=\"panelId + '-presets'\">{{ presetsLabel() }}</span>\n <div class=\"shk-tp-segmented\" role=\"group\" [attr.aria-labelledby]=\"panelId + '-presets'\">\n @for (preset of presets; track preset.name) {\n <button\n type=\"button\"\n class=\"shk-tp-segment\"\n [class.is-active]=\"preset.name === themeName() && isPresetPure()\"\n [attr.aria-pressed]=\"preset.name === themeName() && isPresetPure()\"\n (click)=\"setPreset(preset.name)\"\n >\n {{ preset.label }}\n </button>\n }\n </div>\n </div>\n }\n </div>\n }\n }\n `,\n styles: [\n `\n :host { position: relative; display: inline-flex; }\n .shk-tp-trigger {\n display: grid; place-items: center; width: 2.25rem; height: 2.25rem;\n border: 0; border-radius: 9999px; cursor: pointer; color: #fff;\n background-color: var(--shk-primary-600); transition: filter 0.15s ease;\n }\n .shk-tp-trigger:hover { filter: brightness(1.1); }\n .shk-tp-trigger:focus-visible { outline: 2px solid var(--shk-primary-600); outline-offset: 2px; }\n .shk-tp-trigger-icon { width: 1.15rem; height: 1.15rem; }\n .shk-tp-panel {\n position: absolute; top: calc(100% + 0.5rem); right: 0; z-index: 70;\n width: max-content; max-width: min(19rem, calc(100vw - 1.5rem));\n padding: 0.875rem 1rem 1rem; border-radius: 0.75rem;\n border: 1px solid var(--shk-surface-200);\n box-shadow: 0 10px 30px rgb(0 0 0 / 0.14);\n display: grid; gap: 0.875rem; text-align: left;\n }\n .shk-tp-title { display: block; margin-bottom: 0.5rem; font-size: 0.8125rem; font-weight: 600; color: var(--shk-surface-600); }\n .shk-tp-swatches { display: grid; grid-template-columns: repeat(8, 1.375rem); gap: 0.5rem; }\n .shk-tp-swatch {\n width: 1.375rem; height: 1.375rem; padding: 0; border: 0; border-radius: 9999px; cursor: pointer;\n transition: transform 0.12s ease;\n }\n .shk-tp-swatch:hover { transform: scale(1.12); }\n .shk-tp-swatch:focus-visible, .shk-tp-swatch.is-selected {\n outline: 2px solid var(--shk-surface-800); outline-offset: 2px;\n }\n .shk-tp-segmented {\n display: flex; flex-wrap: wrap; gap: 0.25rem; padding: 0.25rem;\n border-radius: 0.5rem; background-color: var(--shk-surface-100);\n }\n .shk-tp-segment {\n padding: 0.3rem 0.65rem; border: 0; border-radius: 0.375rem; background: transparent;\n font-size: 0.8125rem; color: var(--shk-surface-600); cursor: pointer;\n }\n .shk-tp-segment:hover { color: var(--shk-surface-800); }\n .shk-tp-segment:focus-visible { outline: 2px solid var(--shk-primary-600); outline-offset: 1px; }\n .shk-tp-segment.is-active {\n background-color: var(--shk-surface-50); color: var(--shk-surface-900);\n font-weight: 600; box-shadow: 0 1px 2px rgb(0 0 0 / 0.12);\n }\n `,\n ],\n})\nexport class ThemePickerComponent {\n private readonly config = inject(ShkConfigService);\n private readonly host = inject<ElementRef<HTMLElement>>(ElementRef);\n private readonly trigger = viewChild<ElementRef<HTMLButtonElement>>('trigger');\n\n /** Primary colors offered. */\n readonly primaryColors = input<readonly ShkPickerColor[]>(DEFAULT_PRIMARY_COLORS);\n /** Shows the surface (neutral palette) section. */\n readonly showSurface = input<boolean>(true);\n /** Shows the theme presets section (needs more than one preset). */\n readonly showPresets = input<boolean>(true);\n /** Accessible name and tooltip of the button. */\n readonly triggerLabel = input<string>('Personalizar tema');\n readonly primaryLabel = input<string>('Primario');\n readonly surfaceLabel = input<string>('Superficie');\n readonly presetsLabel = input<string>('Temas');\n\n /** `theme.*` options exist only when the app uses `withTheme()`. */\n protected readonly available = this.config.has('theme.primary') && this.config.has('theme.surface');\n protected readonly open = signal(false);\n protected readonly panelId = `shk-theme-picker-${++pickerCounter}`;\n protected readonly paletteIcon = getIcon('palette');\n protected readonly presets = inject(SHK_THEME_PRESETS);\n\n /** Surface palettes, each shown with its 500 shade. */\n protected readonly surfaces = Object.entries(SURFACE_PALETTES).map(([name, palette]) => ({\n name,\n label: palette.label,\n color: palette.scale[5],\n }));\n\n protected readonly themeName = computed(() =>\n this.available ? this.config.get<string>('theme.name')() : '',\n );\n private readonly currentPreset = computed(() =>\n this.presets.find((preset) => preset.name === this.themeName()),\n );\n private readonly primaryOverride = computed(() =>\n this.available ? this.config.get<string>('theme.primary')() : '',\n );\n private readonly surfaceOverride = computed(() =>\n this.available ? this.config.get<string>('theme.surface')() : '',\n );\n\n /** Primary color in use: the override, else the preset's own (lowercase hex). */\n protected readonly activePrimary = computed(() =>\n (this.primaryOverride() || this.currentPreset()?.primary || '').toLowerCase(),\n );\n /** Surface palette in use: the override, else the preset's own. */\n protected readonly activeSurface = computed(\n () => this.surfaceOverride() || this.currentPreset()?.surface || '',\n );\n /** True while no primary/surface override is applied on top of the preset. */\n protected readonly isPresetPure = computed(() => !this.primaryOverride() && !this.surfaceOverride());\n\n protected toggle(): void {\n this.open.update((open) => !open);\n }\n\n protected setPrimary(color: string): void {\n // Picking the preset's own color clears the override instead of pinning it.\n const own = this.currentPreset()?.primary.toLowerCase();\n this.config.set('theme.primary', color.toLowerCase() === own ? '' : color);\n }\n\n protected setSurface(name: string): void {\n this.config.set('theme.surface', name === this.currentPreset()?.surface ? '' : name);\n }\n\n /** Applies a theme pack and clears the primary/surface overrides. */\n protected setPreset(name: string): void {\n this.config.set('theme.name', name);\n this.config.set('theme.primary', '');\n this.config.set('theme.surface', '');\n }\n\n protected onDocumentPointerDown(event: PointerEvent): void {\n if (this.open() && !this.host.nativeElement.contains(event.target as Node)) {\n this.open.set(false);\n }\n }\n\n protected onEscape(): void {\n if (!this.open()) return;\n this.open.set(false);\n this.trigger()?.nativeElement.focus();\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;AAgCA;;;AAGG;AACI,MAAM,sBAAsB,GAA8B;AAC/D,IAAA,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE;AACnC,IAAA,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE;AACtC,IAAA,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE;AACpC,IAAA,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE;AACnC,IAAA,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE;AACrC,IAAA,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE;AACpC,IAAA,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE;AACrC,IAAA,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE;AACnC,IAAA,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE;AACnC,IAAA,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,EAAE;AAClC,IAAA,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE;AACnC,IAAA,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE;AACrC,IAAA,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE;AACrC,IAAA,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE;AACrC,IAAA,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE;AACtC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AA,EAAA,CAAA,EAAA,QAAA,EAAA,IAAA,EAAA,KAAA,EAAA,cAAA,EAAA,QAAA,EAAA,KAAA,EAAA,CAAA,EAAA,CAAA,EAAA,YAAA,EAAA,CAAA,EAAA,IAAA,EAAA,EAAA,CAAA,KAAA,EAAA,IAAA,EAAA,CAAA,EAAA,QAAA,EAAA,IAAA,EAAA,KAAA,EAAA,cAAA,EAAA,QAAA,EAAA,KAAA,EAAA,CAAA,EAAA,CAAA,EAAA,YAAA,EAAA,CAAA,EAAA,IAAA,EAAA,EAAA,CAAA,KAAA,EAAA,IAAA,EAAA,CAAA,EAAA,QAAA,EAAA,IAAA,EAAA,KAAA,EAAA,cAAA,EAAA,QAAA,EAAA,KAAA,EAAA,CAAA,EAAA,CAAA,EAAA,YAAA,EAAA,CAAA,EAAA,IAAA,EAAA,EAAA,CAAA,KAAA,EAAA,IAAA,EAAA,CAAA,EAAA,QAAA,EAAA,IAAA,EAAA,KAAA,EAAA,cAAA,EAAA,QAAA,EAAA,KAAA,EAAA,CAAA,EAAA,CAAA,EAAA,EAAA,CAAA;;AC7M/E;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"shirkasoft-ui-components-theme-picker.mjs","names":[],"sources":["../../../projects/ui-components/theme-picker/theme-picker.component.ts"],"sourcesContent":["import {\n ChangeDetectionStrategy,\n Component,\n ElementRef,\n computed,\n inject,\n input,\n signal,\n viewChild,\n} from '@angular/core';\nimport {\n SHK_THEME_PRESETS,\n SURFACE_PALETTES,\n ShkConfigService,\n} from 'shirkasoft-ui-components/config';\nimport { ShkIconDirective } from 'shirkasoft-ui-components/icons';\nimport { getIcon } from 'shirkasoft-ui-components/utils';\n\n/**\n * Shirkasoft UI Components.\n * Authors: Roberto Valladares Martin (Ansem13), Julio César García García (Sanjuli14).\n * Belongs to Shirkasoft.\n */\n\n/** A primary color offered by the picker. */\nexport interface ShkPickerColor {\n /** Hex color; it becomes `--shk-primary-600` (`theme.primary`). */\n color: string;\n /** Accessible name / tooltip. */\n label: string;\n}\n\n/**\n * Default primary colors (Tailwind 600 shades). Red and rose are left out on\n * purpose: red is reserved for danger states.\n */\nexport const DEFAULT_PRIMARY_COLORS: readonly ShkPickerColor[] = [\n { color: '#334155', label: 'Noir' },\n { color: '#059669', label: 'Emerald' },\n { color: '#16a34a', label: 'Green' },\n { color: '#65a30d', label: 'Lime' },\n { color: '#ea580c', label: 'Orange' },\n { color: '#d97706', label: 'Amber' },\n { color: '#ca8a04', label: 'Yellow' },\n { color: '#0d9488', label: 'Teal' },\n { color: '#0891b2', label: 'Cyan' },\n { color: '#0284c7', label: 'Sky' },\n { color: '#2563eb', label: 'Blue' },\n { color: '#4f46e5', label: 'Indigo' },\n { color: '#7c3aed', label: 'Violet' },\n { color: '#9333ea', label: 'Purple' },\n { color: '#c026d3', label: 'Fuchsia' },\n { color: '#db2777', label: 'Pink' },\n];\n\nlet pickerCounter = 0;\n\n/**\n * Theme customizer: a palette button that opens a panel to pick the primary\n * color, the surface (neutral) palette and a theme preset at runtime.\n *\n * It edits the `theme.primary`, `theme.surface` and `theme.name` options, so it\n * needs `provideShk(withTheme(...))`; add `withPersistence()` to remember the\n * choice. Without `withTheme()` it renders nothing.\n *\n * ```html\n * <shk-theme-picker />\n * ```\n */\n@Component({\n selector: 'shk-theme-picker',\n changeDetection: ChangeDetectionStrategy.OnPush,\n imports: [ShkIconDirective],\n host: {\n class: 'shk-theme-picker',\n '(document:pointerdown)': 'onDocumentPointerDown($event)',\n '(document:keydown.escape)': 'onEscape()',\n },\n template: `\n @if (available) {\n <button\n #trigger\n type=\"button\"\n class=\"shk-tp-trigger\"\n aria-haspopup=\"dialog\"\n [attr.aria-expanded]=\"open()\"\n [attr.aria-controls]=\"panelId\"\n [attr.aria-label]=\"triggerLabel()\"\n [attr.title]=\"triggerLabel()\"\n (click)=\"toggle()\"\n >\n <svg [shkIcon]=\"paletteIcon\" class=\"shk-tp-trigger-icon\"></svg>\n </button>\n\n @if (open()) {\n <div class=\"shk-tp-panel _shk-bg-panel-raised\" role=\"dialog\" [id]=\"panelId\" [attr.aria-label]=\"triggerLabel()\">\n <div class=\"shk-tp-section\">\n <span class=\"shk-tp-title\" [id]=\"panelId + '-primary'\">{{ primaryLabel() }}</span>\n <div class=\"shk-tp-swatches\" role=\"group\" [attr.aria-labelledby]=\"panelId + '-primary'\">\n @for (item of primaryColors(); track item.color) {\n <button\n type=\"button\"\n class=\"shk-tp-swatch\"\n [style.background-color]=\"item.color\"\n [class.is-selected]=\"item.color.toLowerCase() === activePrimary()\"\n [attr.aria-pressed]=\"item.color.toLowerCase() === activePrimary()\"\n [attr.aria-label]=\"item.label\"\n [attr.title]=\"item.label\"\n (click)=\"setPrimary(item.color)\"\n ></button>\n }\n </div>\n </div>\n\n @if (showSurface()) {\n <div class=\"shk-tp-section\">\n <span class=\"shk-tp-title\" [id]=\"panelId + '-surface'\">{{ surfaceLabel() }}</span>\n <div class=\"shk-tp-swatches\" role=\"group\" [attr.aria-labelledby]=\"panelId + '-surface'\">\n @for (item of surfaces; track item.name) {\n <button\n type=\"button\"\n class=\"shk-tp-swatch\"\n [style.background-color]=\"item.color\"\n [class.is-selected]=\"item.name === activeSurface()\"\n [attr.aria-pressed]=\"item.name === activeSurface()\"\n [attr.aria-label]=\"item.label\"\n [attr.title]=\"item.label\"\n (click)=\"setSurface(item.name)\"\n ></button>\n }\n </div>\n </div>\n }\n\n @if (showPresets() && presets.length > 1) {\n <div class=\"shk-tp-section\">\n <span class=\"shk-tp-title\" [id]=\"panelId + '-presets'\">{{ presetsLabel() }}</span>\n <div class=\"shk-tp-segmented\" role=\"group\" [attr.aria-labelledby]=\"panelId + '-presets'\">\n @for (preset of presets; track preset.name) {\n <button\n type=\"button\"\n class=\"shk-tp-segment\"\n [class.is-active]=\"preset.name === themeName() && isPresetPure()\"\n [attr.aria-pressed]=\"preset.name === themeName() && isPresetPure()\"\n (click)=\"setPreset(preset.name)\"\n >\n {{ preset.label }}\n </button>\n }\n </div>\n </div>\n }\n </div>\n }\n }\n `,\n styles: [\n `\n :host { position: relative; display: inline-flex; }\n .shk-tp-trigger {\n display: grid; place-items: center; width: 2.25rem; height: 2.25rem;\n border: 0; border-radius: 9999px; cursor: pointer; color: #fff;\n background-color: var(--shk-primary-600); transition: filter 0.15s ease;\n }\n .shk-tp-trigger:hover { filter: brightness(1.1); }\n .shk-tp-trigger:focus-visible { outline: 2px solid var(--shk-primary-600); outline-offset: 2px; }\n .shk-tp-trigger-icon { width: 1.15rem; height: 1.15rem; }\n .shk-tp-panel {\n position: absolute; top: calc(100% + 0.5rem); right: 0; z-index: 70;\n width: max-content; max-width: min(19rem, calc(100vw - 1.5rem));\n padding: 0.875rem 1rem 1rem; border-radius: 0.75rem;\n border: 1px solid var(--shk-surface-200);\n box-shadow: 0 10px 30px rgb(0 0 0 / 0.14);\n display: grid; gap: 0.875rem; text-align: left;\n }\n .shk-tp-title { display: block; margin-bottom: 0.5rem; font-size: 0.8125rem; font-weight: 600; color: var(--shk-surface-600); }\n .shk-tp-swatches { display: grid; grid-template-columns: repeat(8, 1.375rem); gap: 0.5rem; }\n .shk-tp-swatch {\n width: 1.375rem; height: 1.375rem; padding: 0; border: 0; border-radius: 9999px; cursor: pointer;\n transition: transform 0.12s ease;\n }\n .shk-tp-swatch:hover { transform: scale(1.12); }\n .shk-tp-swatch:focus-visible, .shk-tp-swatch.is-selected {\n outline: 2px solid var(--shk-surface-800); outline-offset: 2px;\n }\n .shk-tp-segmented {\n display: flex; flex-wrap: wrap; gap: 0.25rem; padding: 0.25rem;\n border-radius: 0.5rem; background-color: var(--shk-surface-100);\n }\n .shk-tp-segment {\n padding: 0.3rem 0.65rem; border: 0; border-radius: 0.375rem; background: transparent;\n font-size: 0.8125rem; color: var(--shk-surface-600); cursor: pointer;\n }\n .shk-tp-segment:hover { color: var(--shk-surface-800); }\n .shk-tp-segment:focus-visible { outline: 2px solid var(--shk-primary-600); outline-offset: 1px; }\n .shk-tp-segment.is-active {\n background-color: var(--shk-surface-50); color: var(--shk-surface-900);\n font-weight: 600; box-shadow: 0 1px 2px rgb(0 0 0 / 0.12);\n }\n `,\n ],\n})\nexport class ThemePickerComponent {\n private readonly config = inject(ShkConfigService);\n private readonly host = inject<ElementRef<HTMLElement>>(ElementRef);\n private readonly trigger = viewChild<ElementRef<HTMLButtonElement>>('trigger');\n\n /** Primary colors offered. */\n readonly primaryColors = input<readonly ShkPickerColor[]>(DEFAULT_PRIMARY_COLORS);\n /** Shows the surface (neutral palette) section. */\n readonly showSurface = input<boolean>(true);\n /** Shows the theme presets section (needs more than one preset). */\n readonly showPresets = input<boolean>(true);\n /** Accessible name and tooltip of the button. */\n readonly triggerLabel = input<string>('Personalizar tema');\n readonly primaryLabel = input<string>('Primario');\n readonly surfaceLabel = input<string>('Superficie');\n readonly presetsLabel = input<string>('Temas');\n\n /** `theme.*` options exist only when the app uses `withTheme()`. */\n protected readonly available = this.config.has('theme.primary') && this.config.has('theme.surface');\n protected readonly open = signal(false);\n protected readonly panelId = `shk-theme-picker-${++pickerCounter}`;\n protected readonly paletteIcon = getIcon('palette');\n protected readonly presets = inject(SHK_THEME_PRESETS);\n\n /** Surface palettes, each shown with its 500 shade. */\n protected readonly surfaces = Object.entries(SURFACE_PALETTES).map(([name, palette]) => ({\n name,\n label: palette.label,\n color: palette.scale[5],\n }));\n\n protected readonly themeName = computed(() =>\n this.available ? this.config.get<string>('theme.name')() : '',\n );\n private readonly currentPreset = computed(() =>\n this.presets.find((preset) => preset.name === this.themeName()),\n );\n private readonly primaryOverride = computed(() =>\n this.available ? this.config.get<string>('theme.primary')() : '',\n );\n private readonly surfaceOverride = computed(() =>\n this.available ? this.config.get<string>('theme.surface')() : '',\n );\n\n /** Primary color in use: the override, else the preset's own (lowercase hex). */\n protected readonly activePrimary = computed(() =>\n (this.primaryOverride() || this.currentPreset()?.primary || '').toLowerCase(),\n );\n /** Surface palette in use: the override, else the preset's own. */\n protected readonly activeSurface = computed(\n () => this.surfaceOverride() || this.currentPreset()?.surface || '',\n );\n /** True while no primary/surface override is applied on top of the preset. */\n protected readonly isPresetPure = computed(() => !this.primaryOverride() && !this.surfaceOverride());\n\n protected toggle(): void {\n this.open.update((open) => !open);\n }\n\n protected setPrimary(color: string): void {\n // Picking the preset's own color clears the override instead of pinning it.\n const own = this.currentPreset()?.primary.toLowerCase();\n this.config.set('theme.primary', color.toLowerCase() === own ? '' : color);\n }\n\n protected setSurface(name: string): void {\n this.config.set('theme.surface', name === this.currentPreset()?.surface ? '' : name);\n }\n\n /** Applies a theme pack and clears the primary/surface overrides. */\n protected setPreset(name: string): void {\n this.config.set('theme.name', name);\n this.config.set('theme.primary', '');\n this.config.set('theme.surface', '');\n }\n\n protected onDocumentPointerDown(event: PointerEvent): void {\n if (this.open() && !this.host.nativeElement.contains(event.target as Node)) {\n this.open.set(false);\n }\n }\n\n protected onEscape(): void {\n if (!this.open()) return;\n this.open.set(false);\n this.trigger()?.nativeElement.focus();\n }\n}\n"],"mappings":";;;;;AAoCA,MAAa,yBAAoD;CAC/D;EAAE,OAAO;EAAW,OAAO;CAAM;CACjC;EAAE,OAAO;EAAW,OAAO;CAAS;CACpC;EAAE,OAAO;EAAW,OAAO;CAAO;CAClC;EAAE,OAAO;EAAW,OAAO;CAAM;CACjC;EAAE,OAAO;EAAW,OAAO;CAAQ;CACnC;EAAE,OAAO;EAAW,OAAO;CAAO;CAClC;EAAE,OAAO;EAAW,OAAO;CAAQ;CACnC;EAAE,OAAO;EAAW,OAAO;CAAM;CACjC;EAAE,OAAO;EAAW,OAAO;CAAM;CACjC;EAAE,OAAO;EAAW,OAAO;CAAK;CAChC;EAAE,OAAO;EAAW,OAAO;CAAM;CACjC;EAAE,OAAO;EAAW,OAAO;CAAQ;CACnC;EAAE,OAAO;EAAW,OAAO;CAAQ;CACnC;EAAE,OAAO;EAAW,OAAO;CAAQ;CACnC;EAAE,OAAO;EAAW,OAAO;CAAS;CACpC;EAAE,OAAO;EAAW,OAAO;CAAM;AAClC;AAED,IAAI,gBAAgB;AAmJ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