shirkasoft-ui-components 2.0.0 → 2.1.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 +209 -53
- package/fesm2022/shirkasoft-ui-components-config.mjs +610 -72
- package/fesm2022/shirkasoft-ui-components-config.mjs.map +1 -1
- package/fesm2022/shirkasoft-ui-components-date-picker.mjs +79 -6
- package/fesm2022/shirkasoft-ui-components-date-picker.mjs.map +1 -1
- package/fesm2022/shirkasoft-ui-components-file-upload.mjs +74 -3
- package/fesm2022/shirkasoft-ui-components-file-upload.mjs.map +1 -1
- package/fesm2022/shirkasoft-ui-components-icons.mjs +6 -6
- package/fesm2022/shirkasoft-ui-components-icons.mjs.map +1 -1
- package/fesm2022/shirkasoft-ui-components-price-input.mjs +70 -2
- package/fesm2022/shirkasoft-ui-components-price-input.mjs.map +1 -1
- package/fesm2022/shirkasoft-ui-components-select.mjs +76 -14
- package/fesm2022/shirkasoft-ui-components-select.mjs.map +1 -1
- package/fesm2022/shirkasoft-ui-components-table.mjs +11 -0
- package/fesm2022/shirkasoft-ui-components-table.mjs.map +1 -1
- package/fesm2022/shirkasoft-ui-components-text-field.mjs +80 -18
- package/fesm2022/shirkasoft-ui-components-text-field.mjs.map +1 -1
- package/fesm2022/shirkasoft-ui-components-theme-picker.mjs +262 -165
- package/fesm2022/shirkasoft-ui-components-theme-picker.mjs.map +1 -1
- package/fesm2022/shirkasoft-ui-components-theme.mjs +2 -24
- package/fesm2022/shirkasoft-ui-components-theme.mjs.map +1 -1
- package/fesm2022/shirkasoft-ui-components-utils.mjs +36 -1
- package/fesm2022/shirkasoft-ui-components-utils.mjs.map +1 -1
- package/package.json +1 -1
- package/types/shirkasoft-ui-components-config.d.ts +246 -20
- package/types/shirkasoft-ui-components-date-picker.d.ts +35 -1
- package/types/shirkasoft-ui-components-file-upload.d.ts +35 -1
- package/types/shirkasoft-ui-components-icons.d.ts +6 -6
- package/types/shirkasoft-ui-components-price-input.d.ts +36 -2
- package/types/shirkasoft-ui-components-select.d.ts +36 -2
- package/types/shirkasoft-ui-components-text-field.d.ts +36 -4
- package/types/shirkasoft-ui-components-theme-picker.d.ts +40 -12
- package/types/shirkasoft-ui-components-theme.d.ts +17 -9
- package/types/shirkasoft-ui-components-utils.d.ts +34 -1
|
@@ -11,10 +11,22 @@ import { ShkThemeConfig } from "shirkasoft-ui-components/theme";
|
|
|
11
11
|
*/
|
|
12
12
|
/** Kind of value an option holds; drives validation and the editor a settings UI shows. */
|
|
13
13
|
type ShkOptionType = 'string' | 'number' | 'boolean' | 'select' | 'color';
|
|
14
|
+
/**
|
|
15
|
+
* Layer an option is written to by `ShkConfigService.set()`.
|
|
16
|
+
*
|
|
17
|
+
* - `device`: the user's own preference (localStorage, `withPersistence()`).
|
|
18
|
+
* - `shared`: the system-wide value (a `ShkConfigStore`, usually the backend).
|
|
19
|
+
*/
|
|
20
|
+
type ShkConfigLayer = 'device' | 'shared';
|
|
21
|
+
/** Layer the current value of an option comes from. */
|
|
22
|
+
type ShkConfigSource = ShkConfigLayer | 'draft' | 'default';
|
|
14
23
|
/** One allowed value of a `select` option. */
|
|
15
24
|
interface ShkOptionChoice<T = unknown> {
|
|
16
25
|
value: T;
|
|
26
|
+
/** English label (fallback when there is no translation). */
|
|
17
27
|
label: string;
|
|
28
|
+
/** Translation key of the label. */
|
|
29
|
+
labelKey?: string;
|
|
18
30
|
}
|
|
19
31
|
/**
|
|
20
32
|
* Definition of a configurable option (an entry of the options registry).
|
|
@@ -30,10 +42,14 @@ interface ShkOptionDef<T = unknown> {
|
|
|
30
42
|
type: ShkOptionType;
|
|
31
43
|
/** Value used until the option is set (or after `reset`). */
|
|
32
44
|
default: T;
|
|
33
|
-
/** Human-readable name for a settings screen. */
|
|
45
|
+
/** Human-readable name for a settings screen (English fallback). */
|
|
34
46
|
label?: string;
|
|
35
|
-
/**
|
|
47
|
+
/** Translation key of `label`. */
|
|
48
|
+
labelKey?: string;
|
|
49
|
+
/** Longer help text for a settings screen (English fallback). */
|
|
36
50
|
description?: string;
|
|
51
|
+
/** Translation key of `description`. */
|
|
52
|
+
descriptionKey?: string;
|
|
37
53
|
/** Allowed values for `select` options. */
|
|
38
54
|
choices?: readonly ShkOptionChoice<T>[];
|
|
39
55
|
/**
|
|
@@ -45,9 +61,13 @@ interface ShkOptionDef<T = unknown> {
|
|
|
45
61
|
min?: number;
|
|
46
62
|
/** Upper bound for `number` options. */
|
|
47
63
|
max?: number;
|
|
64
|
+
/**
|
|
65
|
+
* Layer `set()` writes to. Defaults to `device`. While a preview is active
|
|
66
|
+
* (`ShkConfigSync.preview()`) every write goes to the draft instead.
|
|
67
|
+
*/
|
|
68
|
+
scope?: ShkConfigLayer;
|
|
48
69
|
/**
|
|
49
70
|
* Whether `withPersistence()` stores this option. Defaults to `true`.
|
|
50
|
-
* Options persisted elsewhere (e.g. the theme service) set it to `false`.
|
|
51
71
|
*/
|
|
52
72
|
persist?: boolean;
|
|
53
73
|
}
|
|
@@ -56,6 +76,8 @@ interface ShkOptionEntry<T = unknown> extends ShkOptionDef<T> {
|
|
|
56
76
|
value: T;
|
|
57
77
|
/** True when the current value equals the default. */
|
|
58
78
|
isDefault: boolean;
|
|
79
|
+
/** Layer the current value comes from. */
|
|
80
|
+
source: ShkConfigSource;
|
|
59
81
|
}
|
|
60
82
|
/** How the date picker shows the selected date when the field is not being edited. */
|
|
61
83
|
type ShkDateDisplayStyle = 'long' | 'medium' | 'short' | 'format';
|
|
@@ -105,8 +127,11 @@ interface ShkConfigPersistence {
|
|
|
105
127
|
}
|
|
106
128
|
export declare const SHK_CONFIG_PERSISTENCE: InjectionToken<ShkConfigPersistence>;
|
|
107
129
|
/**
|
|
108
|
-
* Value held outside the registry
|
|
109
|
-
*
|
|
130
|
+
* Value held outside the registry. Kept for backwards compatibility: prefer
|
|
131
|
+
* `ShkConfigService.apply()` so the registry keeps owning the value.
|
|
132
|
+
*
|
|
133
|
+
* @deprecated The registry stores option values now. Bind a callback with
|
|
134
|
+
* `apply()` to react to changes instead of holding the value elsewhere.
|
|
110
135
|
*/
|
|
111
136
|
interface ShkOptionSource<T = unknown> {
|
|
112
137
|
value: Signal<T>;
|
|
@@ -119,6 +144,16 @@ interface ShkOptionSource<T = unknown> {
|
|
|
119
144
|
* Components read options as signals, so changing one at runtime updates every
|
|
120
145
|
* component that uses it. A settings screen can list them with `options()`.
|
|
121
146
|
*
|
|
147
|
+
* Values live in layers, read in this order:
|
|
148
|
+
*
|
|
149
|
+
* 1. `draft` — the preview an admin screen is editing (`ShkConfigSync.preview()`).
|
|
150
|
+
* 2. `device` — the user's own choice (localStorage, `withPersistence()`).
|
|
151
|
+
* 3. `shared` — the system-wide value (`withSharedConfig()`, usually the backend).
|
|
152
|
+
* 4. the option's `default`.
|
|
153
|
+
*
|
|
154
|
+
* `set()` writes to the draft while a preview is active, otherwise to the
|
|
155
|
+
* option's `scope` (`device` by default).
|
|
156
|
+
*
|
|
122
157
|
* ```ts
|
|
123
158
|
* const config = inject(ShkConfigService);
|
|
124
159
|
* config.get('dates.format')(); // 'dd/MM/yyyy'
|
|
@@ -129,16 +164,31 @@ interface ShkOptionSource<T = unknown> {
|
|
|
129
164
|
export declare class ShkConfigService {
|
|
130
165
|
private readonly win;
|
|
131
166
|
private readonly persistence;
|
|
167
|
+
private readonly labels;
|
|
132
168
|
/** Registered definitions, by key. */
|
|
133
169
|
private readonly defs;
|
|
134
|
-
/** Values set explicitly
|
|
135
|
-
private readonly
|
|
136
|
-
/**
|
|
170
|
+
/** Values set explicitly on this device (persisted by `withPersistence()`). */
|
|
171
|
+
private readonly deviceValues;
|
|
172
|
+
/** Values coming from the shared layer (`withSharedConfig()`). */
|
|
173
|
+
private readonly sharedValues;
|
|
174
|
+
/** Values of the preview being edited (`null` when no preview is active). */
|
|
175
|
+
private readonly draftValues;
|
|
176
|
+
/** Options whose value lives elsewhere (legacy `bind`). */
|
|
137
177
|
private readonly sources;
|
|
178
|
+
/** Callbacks registered with `apply()`, run on every value change. */
|
|
179
|
+
private readonly appliers;
|
|
138
180
|
/** Stored values whose option is not registered yet; applied on `register`. */
|
|
139
181
|
private pending;
|
|
140
182
|
/** Cached per-key signals returned by `get`. */
|
|
141
183
|
private readonly cache;
|
|
184
|
+
/** Values set on this device, by key. */
|
|
185
|
+
readonly device: Signal<Readonly<Record<string, unknown>>>;
|
|
186
|
+
/** Values of the shared layer, by key. */
|
|
187
|
+
readonly shared: Signal<Readonly<Record<string, unknown>>>;
|
|
188
|
+
/** Values of the preview being edited, or `null`. */
|
|
189
|
+
readonly draft: Signal<Readonly<Record<string, unknown>> | null>;
|
|
190
|
+
/** `true` while an admin screen is previewing changes. */
|
|
191
|
+
readonly isPreviewing: Signal<boolean>;
|
|
142
192
|
/** Every registered option with its current value, in registration order. */
|
|
143
193
|
readonly options: Signal<ShkOptionEntry[]>;
|
|
144
194
|
/** Module names in registration order (`dates`, `numbers`, `theme`, …). */
|
|
@@ -155,9 +205,12 @@ export declare class ShkConfigService {
|
|
|
155
205
|
/**
|
|
156
206
|
* Sets an option. The value is validated against the definition (type,
|
|
157
207
|
* choices, bounds); an invalid value throws and changes nothing.
|
|
208
|
+
*
|
|
209
|
+
* While a preview is active it is written to the draft; otherwise to
|
|
210
|
+
* `layer`, or to the option's `scope` (`device` by default).
|
|
158
211
|
*/
|
|
159
|
-
set<K extends ShkConfigKey>(key: K, value: ShkConfigValues[K]): void;
|
|
160
|
-
set(key: string, value: unknown): void;
|
|
212
|
+
set<K extends ShkConfigKey>(key: K, value: ShkConfigValues[K], layer?: ShkConfigLayer): void;
|
|
213
|
+
set(key: string, value: unknown, layer?: ShkConfigLayer): void;
|
|
161
214
|
/** Restores one option (or all of them) to its default. */
|
|
162
215
|
reset(key?: string): void;
|
|
163
216
|
/**
|
|
@@ -166,13 +219,35 @@ export declare class ShkConfigService {
|
|
|
166
219
|
*/
|
|
167
220
|
register(defs: readonly ShkOptionDef[]): void;
|
|
168
221
|
/**
|
|
169
|
-
* Binds an option to a value held elsewhere
|
|
170
|
-
*
|
|
222
|
+
* Binds an option to a value held elsewhere.
|
|
223
|
+
*
|
|
224
|
+
* @deprecated The registry owns option values now. Use `apply()` to react to
|
|
225
|
+
* changes (`theme.*` uses it) and let the layers store the value.
|
|
171
226
|
*/
|
|
172
227
|
bind<T>(key: string, source: ShkOptionSource<T>): void;
|
|
228
|
+
/**
|
|
229
|
+
* Runs `callback` with the option's current value and again on every change
|
|
230
|
+
* (any layer, including the preview). Used by `withTheme()` to apply
|
|
231
|
+
* `theme.name`/`theme.scheme`/`theme.primary`/`theme.surface` to the DOM.
|
|
232
|
+
*/
|
|
233
|
+
apply(key: string, callback: (value: unknown) => void): void;
|
|
234
|
+
/**
|
|
235
|
+
* Replaces the shared layer with values loaded from a store. Invalid or
|
|
236
|
+
* unknown keys are ignored, so a store from a newer build cannot break the
|
|
237
|
+
* app.
|
|
238
|
+
*/
|
|
239
|
+
setShared(values: Readonly<Record<string, unknown>>): void;
|
|
240
|
+
/** Starts (or restarts) a preview: an empty draft on top of the current values. */
|
|
241
|
+
beginDraft(): void;
|
|
242
|
+
/** Moves the preview values to the shared layer and closes the preview. */
|
|
243
|
+
commitDraft(): void;
|
|
244
|
+
/** Throws away the preview, keeping the previous values. */
|
|
245
|
+
discardDraft(): void;
|
|
173
246
|
/** Changes the defaults of registered options (`reset` returns to these). */
|
|
174
247
|
private setDefaults;
|
|
175
248
|
private read;
|
|
249
|
+
/** Layer the current value comes from (for settings screens). */
|
|
250
|
+
private sourceOf;
|
|
176
251
|
private requireDef;
|
|
177
252
|
/** Returns the value coerced to the option's type, or throws if it is not acceptable. */
|
|
178
253
|
private validate;
|
|
@@ -181,6 +256,81 @@ export declare class ShkConfigService {
|
|
|
181
256
|
static ɵfac: i0.ɵɵFactoryDeclaration<ShkConfigService, never>;
|
|
182
257
|
static ɵprov: i0.ɵɵInjectableDeclaration<any>;
|
|
183
258
|
}
|
|
259
|
+
/** Values and revision returned by a {@link ShkConfigStore}. */
|
|
260
|
+
interface ShkConfigSnapshot {
|
|
261
|
+
/** Stored values, by option key. Keys equal to the default may be omitted. */
|
|
262
|
+
values: Readonly<Record<string, unknown>>;
|
|
263
|
+
/** Opaque revision of `values`; sent back on `save` to detect lost updates. */
|
|
264
|
+
revision: string;
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* Persistence of the shared layer (usually the backend).
|
|
268
|
+
*
|
|
269
|
+
* The library never talks to the network: the app implements this and passes
|
|
270
|
+
* it to `withSharedConfig()`. `save` must fail with
|
|
271
|
+
* {@link ShkConfigConflictError} when `revision` is not the current one.
|
|
272
|
+
*/
|
|
273
|
+
interface ShkConfigStore {
|
|
274
|
+
load(): Promise<ShkConfigSnapshot>;
|
|
275
|
+
save(values: Readonly<Record<string, unknown>>, revision: string | null): Promise<ShkConfigSnapshot>;
|
|
276
|
+
}
|
|
277
|
+
/** The app's {@link ShkConfigStore}, enabled with `withSharedConfig()`. */
|
|
278
|
+
export declare const SHK_CONFIG_STORE: InjectionToken<ShkConfigStore>;
|
|
279
|
+
/** The shared values changed on the server since they were loaded. */
|
|
280
|
+
export declare class ShkConfigConflictError extends Error {
|
|
281
|
+
readonly expected: string | null;
|
|
282
|
+
readonly actual: string | null;
|
|
283
|
+
constructor(expected: string | null, actual: string | null);
|
|
284
|
+
}
|
|
285
|
+
/** State of a {@link ShkConfigSync} operation. */
|
|
286
|
+
type ShkConfigSyncStatus = 'idle' | 'loading' | 'saving' | 'error';
|
|
287
|
+
/**
|
|
288
|
+
* Loads, previews and saves the shared layer.
|
|
289
|
+
*
|
|
290
|
+
* ```ts
|
|
291
|
+
* const sync = inject(ShkConfigSync);
|
|
292
|
+
* await sync.load(); // shared values from the backend
|
|
293
|
+
* sync.preview(); // the admin screen now edits a draft
|
|
294
|
+
* sync.isDirty(); // true once something changed
|
|
295
|
+
* await sync.save(); // draft → shared (backend)
|
|
296
|
+
* sync.discard(); // throw the draft away
|
|
297
|
+
* ```
|
|
298
|
+
*
|
|
299
|
+
* While a preview is active, every `ShkConfigService.set()` goes to the draft,
|
|
300
|
+
* so the same settings screen (and the same `shk-theme-picker`) works for both
|
|
301
|
+
* the user and the admin without knowing about layers.
|
|
302
|
+
*/
|
|
303
|
+
export declare class ShkConfigSync {
|
|
304
|
+
private readonly config;
|
|
305
|
+
private readonly store;
|
|
306
|
+
/** Whether a store is configured (`withSharedConfig()`). */
|
|
307
|
+
readonly available: boolean;
|
|
308
|
+
readonly status: import("@angular/core").WritableSignal<ShkConfigSyncStatus>;
|
|
309
|
+
/** Revision of the loaded values; `null` until the first load. */
|
|
310
|
+
readonly revision: import("@angular/core").WritableSignal<string | null>;
|
|
311
|
+
/** Last error (conflict, network…), or `null`. */
|
|
312
|
+
readonly error: import("@angular/core").WritableSignal<unknown>;
|
|
313
|
+
/** True when the draft differs from the shared values. */
|
|
314
|
+
readonly isDirty: import("@angular/core").Signal<boolean>;
|
|
315
|
+
/** Reads the shared layer from the store. */
|
|
316
|
+
load(): Promise<void>;
|
|
317
|
+
/** Starts editing a draft of the shared layer (live preview). */
|
|
318
|
+
preview(): void;
|
|
319
|
+
/** Saves the draft to the store and makes it the shared layer. */
|
|
320
|
+
save(): Promise<void>;
|
|
321
|
+
/** Throws the draft away and keeps the current shared values. */
|
|
322
|
+
discard(): void;
|
|
323
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ShkConfigSync, never>;
|
|
324
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<any>;
|
|
325
|
+
}
|
|
326
|
+
/**
|
|
327
|
+
* Revision of a set of values: `sha256(canonical_json(values))`, first 16 hex
|
|
328
|
+
* characters. Key order does not matter, so equal values give equal revisions.
|
|
329
|
+
*
|
|
330
|
+
* Used by stores that keep the values locally; a backend can compute the same
|
|
331
|
+
* string to reject lost updates.
|
|
332
|
+
*/
|
|
333
|
+
export declare function configRevision(values: Readonly<Record<string, unknown>>): Promise<string>;
|
|
184
334
|
/**
|
|
185
335
|
* Shirkasoft UI Components.
|
|
186
336
|
* Authors: Roberto Valladares Martin (Ansem13), Julio César García García (Sanjuli14).
|
|
@@ -188,34 +338,58 @@ export declare class ShkConfigService {
|
|
|
188
338
|
*
|
|
189
339
|
* Builds the `--shk-primary-*` scale from a single color with CSS `color-mix()`,
|
|
190
340
|
* so the browser derives every shade and no color math ships in JavaScript.
|
|
341
|
+
*
|
|
342
|
+
* A theme pack is plain data (`vars` + `darkVars`), not a CSS file: the
|
|
343
|
+
* stylesheet is generated at runtime, so `theme.name` works in any build
|
|
344
|
+
* without importing `themes/*.css`. The published CSS files are still shipped
|
|
345
|
+
* for apps that prefer a static import.
|
|
191
346
|
*/
|
|
192
|
-
/** A theme
|
|
347
|
+
/** A theme pack: a primary color, an optional surface palette and overrides. */
|
|
193
348
|
interface ShkCustomTheme {
|
|
194
349
|
/** Main brand color (hex). It becomes `--shk-primary-600`, the shade buttons use. */
|
|
195
350
|
primary: string;
|
|
196
351
|
/** Name shown in settings screens. Defaults to the theme key. */
|
|
197
352
|
label?: string;
|
|
198
|
-
/**
|
|
353
|
+
/** Translation key for `label`; `label` is the English fallback. */
|
|
354
|
+
labelKey?: string;
|
|
355
|
+
/** Neutral palette (`slate`, `gray`, `zinc`, `neutral`, `stone`). */
|
|
356
|
+
surface?: string;
|
|
357
|
+
/** Light-mode custom properties, e.g. `{ '--shk-surface-50': '#f8fafc' }`. */
|
|
199
358
|
vars?: Readonly<Record<`--shk-${string}`, string>>;
|
|
359
|
+
/** Dark-mode custom properties. Merged over the generated dark primary scale. */
|
|
360
|
+
darkVars?: Readonly<Record<`--shk-${string}`, string>>;
|
|
200
361
|
}
|
|
362
|
+
/** Custom properties a primary color controls (the scale + the decorative accent). */
|
|
363
|
+
export declare const PRIMARY_VARS: readonly string[];
|
|
364
|
+
/** Primary color of the default theme (matches `tokens.css`). */
|
|
365
|
+
export declare const DEFAULT_PRIMARY = "#059669";
|
|
201
366
|
/** `--shk-primary-50` … `--shk-primary-950` (and the accent vars) derived from one color. */
|
|
202
367
|
export declare function primaryScale(color: string): Record<string, string>;
|
|
368
|
+
/**
|
|
369
|
+
* Dark-mode counterpart of {@link primaryScale}. Same variable names, shades
|
|
370
|
+
* chosen for dark backgrounds: 50–200 are dark tints, 300–500 light accents,
|
|
371
|
+
* 600 keeps the brand color and 700 is the light hover/text tone.
|
|
372
|
+
*/
|
|
373
|
+
export declare function primaryScaleDark(color: string): Record<string, string>;
|
|
203
374
|
/** Neutral palettes for `theme.surface` (Tailwind scales, 50 … 900). */
|
|
204
375
|
export declare const SURFACE_PALETTES: Readonly<Record<string, {
|
|
205
376
|
label: string;
|
|
206
377
|
scale: readonly string[];
|
|
207
378
|
}>>;
|
|
208
379
|
/** A selectable combination shown as a preset: a theme pack and its colors. */
|
|
209
|
-
interface ShkThemePreset {
|
|
380
|
+
interface ShkThemePreset extends ShkCustomTheme {
|
|
210
381
|
/** Theme name (`theme.name`). */
|
|
211
382
|
name: string;
|
|
383
|
+
/** English label (fallback when there is no translation). */
|
|
212
384
|
label: string;
|
|
385
|
+
/** Translation key of the label. */
|
|
386
|
+
labelKey: string;
|
|
213
387
|
/** Its primary color (`--shk-primary-600`). */
|
|
214
388
|
primary: string;
|
|
215
389
|
/** Its surface palette (a `SURFACE_PALETTES` key), or '' when it has its own. */
|
|
216
390
|
surface: string;
|
|
217
391
|
}
|
|
218
|
-
/**
|
|
392
|
+
/** Built-in theme packs, as data. `default` is the `tokens.css` palette. */
|
|
219
393
|
export declare const BUILT_IN_PRESETS: readonly ShkThemePreset[];
|
|
220
394
|
/**
|
|
221
395
|
* Theme packs offered as presets (built-in + `withTheme({ themes })`), with the
|
|
@@ -243,6 +417,9 @@ interface ShkFeature {
|
|
|
243
417
|
* ],
|
|
244
418
|
* });
|
|
245
419
|
* ```
|
|
420
|
+
*
|
|
421
|
+
* Options persist in localStorage by default; add `withPersistence()` to use a
|
|
422
|
+
* different key.
|
|
246
423
|
*/
|
|
247
424
|
export declare function provideShk(...features: ShkFeature[]): EnvironmentProviders;
|
|
248
425
|
/** App defaults for the date options (`dates.*`). */
|
|
@@ -275,24 +452,73 @@ interface ShkThemeModuleConfig extends ShkThemeConfig {
|
|
|
275
452
|
primary?: string;
|
|
276
453
|
/** Neutral palette applied on top of any theme (`theme.surface`). Empty = none. */
|
|
277
454
|
surface?: string;
|
|
455
|
+
/**
|
|
456
|
+
* Layer `theme.*` writes to outside a preview. Defaults to `device`: the
|
|
457
|
+
* picker is the user's own preference and the admin screen edits a draft.
|
|
458
|
+
*/
|
|
459
|
+
scope?: ShkConfigLayer;
|
|
278
460
|
}
|
|
279
461
|
/**
|
|
280
462
|
* Theme module: built-in and custom themes, light/dark/system scheme and a
|
|
281
463
|
* runtime primary color. Replaces `provideShkTheme()` (do not use both).
|
|
282
464
|
*
|
|
283
|
-
* `
|
|
284
|
-
*
|
|
465
|
+
* Theme packs are data (`vars` + `darkVars`), so `theme.name` works without
|
|
466
|
+
* importing `themes/*.css` and every pack has a dark variant.
|
|
285
467
|
*/
|
|
286
468
|
export declare function withTheme(config?: ShkThemeModuleConfig): ShkFeature;
|
|
287
469
|
/** Registers app-defined options in the same registry (`app.pageSize`, …). */
|
|
288
470
|
export declare function withOptions(options: readonly ShkOptionDef[]): ShkFeature;
|
|
289
471
|
/**
|
|
290
472
|
* Persists changed options in localStorage so they survive reloads.
|
|
291
|
-
* Options with `persist: false` are skipped
|
|
473
|
+
* Options with `persist: false` are skipped.
|
|
292
474
|
*/
|
|
293
475
|
export declare function withPersistence(config?: {
|
|
294
476
|
storageKey?: string;
|
|
295
477
|
}): ShkFeature;
|
|
478
|
+
/**
|
|
479
|
+
* Enables the shared layer: the system-wide values an admin screen edits.
|
|
480
|
+
*
|
|
481
|
+
* ```ts
|
|
482
|
+
* provideShk(withSharedConfig({ provide: SHK_CONFIG_STORE, useClass: ApiConfigStore }))
|
|
483
|
+
* ```
|
|
484
|
+
*/
|
|
485
|
+
export declare function withSharedConfig(store: ShkConfigStore | Provider): ShkFeature;
|
|
486
|
+
/**
|
|
487
|
+
* Explicit label translations for the library's own texts (theme names, option
|
|
488
|
+
* labels…). Transloco is used automatically when it is configured; this is for
|
|
489
|
+
* apps that use another i18n system. Untranslated labels fall back to English.
|
|
490
|
+
*
|
|
491
|
+
* ```ts
|
|
492
|
+
* withLabels({ 'theme.presets.ocean': 'Océano', 'theme.options.name': 'Tema' })
|
|
493
|
+
* ```
|
|
494
|
+
*/
|
|
495
|
+
export declare function withLabels(labels: Readonly<Record<string, string>>): ShkFeature;
|
|
496
|
+
/**
|
|
497
|
+
* Labels the library shows for its own options and theme packs.
|
|
498
|
+
*
|
|
499
|
+
* Every definition carries an English fallback, so a translated label is
|
|
500
|
+
* optional: when there is no translation the English one is used.
|
|
501
|
+
*/
|
|
502
|
+
export declare class ShkLabels {
|
|
503
|
+
/** Explicit translations registered with `withLabels()`. */
|
|
504
|
+
private readonly overrides;
|
|
505
|
+
/** Transloco is optional: without it only the overrides and fallbacks apply. */
|
|
506
|
+
private readonly transloco;
|
|
507
|
+
/** Bumped on every language change so signals reading `get()` recompute. */
|
|
508
|
+
private readonly revision;
|
|
509
|
+
constructor();
|
|
510
|
+
/**
|
|
511
|
+
* Translation of `key`, or `fallback` when there is none. Reads the language
|
|
512
|
+
* signal, so it can be used inside `computed`.
|
|
513
|
+
*/
|
|
514
|
+
get(key: string | undefined, fallback: string): string;
|
|
515
|
+
/** Transloco is an optional peer: a missing provider must not break the app. */
|
|
516
|
+
private injectTransloco;
|
|
517
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ShkLabels, never>;
|
|
518
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<any>;
|
|
519
|
+
}
|
|
520
|
+
/** Explicit label translations (`withLabels()`), keyed by translation key. */
|
|
521
|
+
export declare const SHK_LABEL_OVERRIDES: InjectionToken<Readonly<Record<string, string>>>;
|
|
296
522
|
/** Date options (`dates.*`), always registered. */
|
|
297
523
|
export declare const DATE_OPTIONS: readonly ShkOptionDef[];
|
|
298
524
|
/** Number and currency options (`numbers.*`), always registered. */
|
|
@@ -354,4 +580,4 @@ export declare function numberSeparators(locale: string): {
|
|
|
354
580
|
decimal: string;
|
|
355
581
|
group: string;
|
|
356
582
|
};
|
|
357
|
-
export type { ShkConfigFeature, ShkConfigKey, ShkConfigPersistence, ShkConfigValues, ShkCustomTheme, ShkDateDisplayStyle, ShkDatesConfig, ShkFeature, ShkIntlStyle, ShkNumbersConfig, ShkOptionChoice, ShkOptionDef, ShkOptionEntry, ShkOptionSource, ShkOptionType, ShkThemeModuleConfig, ShkThemePreset, TypedDateLayout };
|
|
583
|
+
export type { ShkConfigFeature, ShkConfigKey, ShkConfigLayer, ShkConfigPersistence, ShkConfigSnapshot, ShkConfigSource, ShkConfigStore, ShkConfigSyncStatus, ShkConfigValues, ShkCustomTheme, ShkDateDisplayStyle, ShkDatesConfig, ShkFeature, ShkIntlStyle, ShkNumbersConfig, ShkOptionChoice, ShkOptionDef, ShkOptionEntry, ShkOptionSource, ShkOptionType, ShkThemeModuleConfig, ShkThemePreset, TypedDateLayout };
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Generated bundle index. Do not edit.
|
|
3
3
|
*/
|
|
4
4
|
import { ControlValueAccessor, FormControl, FormGroup } from "@angular/forms";
|
|
5
|
-
import { FormValueControl } from "@angular/forms/signals";
|
|
5
|
+
import { FormValueControl, ValidationError } from "@angular/forms/signals";
|
|
6
6
|
import { ShkDateDisplayStyle } from "shirkasoft-ui-components/config";
|
|
7
7
|
import * as i0 from "@angular/core";
|
|
8
8
|
/** Which granularity the picker edits: a day, a week, a month or a year. */
|
|
@@ -70,6 +70,14 @@ export declare class DatePickerComponent implements ControlValueAccessor, FormVa
|
|
|
70
70
|
control: import("@angular/core").InputSignal<FormControl<any> | undefined>;
|
|
71
71
|
/** Disables the picker. */
|
|
72
72
|
disabled: import("@angular/core").InputSignal<boolean>;
|
|
73
|
+
/** Errors bound automatically by the Signal Forms `[formField]` directive. */
|
|
74
|
+
errors: import("@angular/core").InputSignal<readonly ValidationError.WithOptionalFieldTree[]>;
|
|
75
|
+
/** Invalid status bound automatically by `[formField]`. */
|
|
76
|
+
invalid: import("@angular/core").InputSignal<boolean>;
|
|
77
|
+
/** Touched status bound automatically by `[formField]`. */
|
|
78
|
+
touched: import("@angular/core").InputSignal<boolean>;
|
|
79
|
+
/** Dirty status bound automatically by `[formField]`. */
|
|
80
|
+
dirty: import("@angular/core").InputSignal<boolean>;
|
|
73
81
|
/** Custom error message displayed (overrides translated ones). */
|
|
74
82
|
errorMessage: import("@angular/core").InputSignal<string>;
|
|
75
83
|
/** Per-validation-key custom error messages. */
|
|
@@ -185,6 +193,12 @@ export declare class DatePickerComponent implements ControlValueAccessor, FormVa
|
|
|
185
193
|
isDisabled: import("@angular/core").Signal<boolean>;
|
|
186
194
|
/** Resolves the control from `control` input or `formGroup`+`controlName`. */
|
|
187
195
|
actualControl: import("@angular/core").Signal<FormControl<any> | undefined>;
|
|
196
|
+
/**
|
|
197
|
+
* True when the picker is driven by Signal Forms instead of a reactive control.
|
|
198
|
+
* Detected by the absence of a reactive control: `[formField]` provides the
|
|
199
|
+
* state through its `errors`/`invalid`/`touched`/`dirty` inputs.
|
|
200
|
+
*/
|
|
201
|
+
protected readonly usesSignalForms: import("@angular/core").Signal<boolean>;
|
|
188
202
|
shouldShowError: import("@angular/core").Signal<boolean | undefined>;
|
|
189
203
|
wasFixedError: import("@angular/core").Signal<boolean | undefined>;
|
|
190
204
|
getErrorMessages: import("@angular/core").Signal<string[]>;
|
|
@@ -475,6 +489,26 @@ export declare class DatePickerComponent implements ControlValueAccessor, FormVa
|
|
|
475
489
|
"required": false;
|
|
476
490
|
"isSignal": true;
|
|
477
491
|
};
|
|
492
|
+
"errors": {
|
|
493
|
+
"alias": "errors";
|
|
494
|
+
"required": false;
|
|
495
|
+
"isSignal": true;
|
|
496
|
+
};
|
|
497
|
+
"invalid": {
|
|
498
|
+
"alias": "invalid";
|
|
499
|
+
"required": false;
|
|
500
|
+
"isSignal": true;
|
|
501
|
+
};
|
|
502
|
+
"touched": {
|
|
503
|
+
"alias": "touched";
|
|
504
|
+
"required": false;
|
|
505
|
+
"isSignal": true;
|
|
506
|
+
};
|
|
507
|
+
"dirty": {
|
|
508
|
+
"alias": "dirty";
|
|
509
|
+
"required": false;
|
|
510
|
+
"isSignal": true;
|
|
511
|
+
};
|
|
478
512
|
"errorMessage": {
|
|
479
513
|
"alias": "errorMessage";
|
|
480
514
|
"required": false;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import * as i0 from "@angular/core";
|
|
5
5
|
import { OnDestroy } from "@angular/core";
|
|
6
|
-
import { FormValueControl } from "@angular/forms/signals";
|
|
6
|
+
import { FormValueControl, ValidationError } from "@angular/forms/signals";
|
|
7
7
|
interface FileUploadError {
|
|
8
8
|
type: 'size' | 'type';
|
|
9
9
|
message: string;
|
|
@@ -48,6 +48,14 @@ export declare class FileUploadComponent implements OnDestroy, FormValueControl<
|
|
|
48
48
|
existingFiles: import("@angular/core").InputSignal<ExistingFile[]>;
|
|
49
49
|
/** How existing files are rendered. */
|
|
50
50
|
existingDisplay: import("@angular/core").InputSignal<"chips" | "tiles">;
|
|
51
|
+
/** Errors bound automatically by the Signal Forms `[formField]` directive. */
|
|
52
|
+
errors: import("@angular/core").InputSignal<readonly ValidationError.WithOptionalFieldTree[]>;
|
|
53
|
+
/** Invalid status bound automatically by `[formField]`. */
|
|
54
|
+
invalid: import("@angular/core").InputSignal<boolean>;
|
|
55
|
+
/** Touched status bound automatically by `[formField]`. */
|
|
56
|
+
touched: import("@angular/core").InputSignal<boolean>;
|
|
57
|
+
/** Dirty status bound automatically by `[formField]`. */
|
|
58
|
+
dirty: import("@angular/core").InputSignal<boolean>;
|
|
51
59
|
/** Emitted with the currently selected files. */
|
|
52
60
|
fileSelected: import("@angular/core").OutputEmitterRef<File[]>;
|
|
53
61
|
/** Emitted when the last selected file is removed. */
|
|
@@ -70,6 +78,12 @@ export declare class FileUploadComponent implements OnDestroy, FormValueControl<
|
|
|
70
78
|
errorMessage: import("@angular/core").WritableSignal<string>;
|
|
71
79
|
/** Whether the user is dragging files over the zone. */
|
|
72
80
|
isDragOver: import("@angular/core").WritableSignal<boolean>;
|
|
81
|
+
/**
|
|
82
|
+
* Error message rendered under the uploader. Local type/size errors take
|
|
83
|
+
* precedence; otherwise the first Signal Forms error is shown once the field
|
|
84
|
+
* has been touched or modified.
|
|
85
|
+
*/
|
|
86
|
+
displayError: import("@angular/core").Signal<string>;
|
|
73
87
|
/** Object URLs used for image previews. */
|
|
74
88
|
private previewUrls;
|
|
75
89
|
/** Whether another selection is allowed. */
|
|
@@ -172,6 +186,26 @@ export declare class FileUploadComponent implements OnDestroy, FormValueControl<
|
|
|
172
186
|
"required": false;
|
|
173
187
|
"isSignal": true;
|
|
174
188
|
};
|
|
189
|
+
"errors": {
|
|
190
|
+
"alias": "errors";
|
|
191
|
+
"required": false;
|
|
192
|
+
"isSignal": true;
|
|
193
|
+
};
|
|
194
|
+
"invalid": {
|
|
195
|
+
"alias": "invalid";
|
|
196
|
+
"required": false;
|
|
197
|
+
"isSignal": true;
|
|
198
|
+
};
|
|
199
|
+
"touched": {
|
|
200
|
+
"alias": "touched";
|
|
201
|
+
"required": false;
|
|
202
|
+
"isSignal": true;
|
|
203
|
+
};
|
|
204
|
+
"dirty": {
|
|
205
|
+
"alias": "dirty";
|
|
206
|
+
"required": false;
|
|
207
|
+
"isSignal": true;
|
|
208
|
+
};
|
|
175
209
|
"value": {
|
|
176
210
|
"alias": "value";
|
|
177
211
|
"required": false;
|
|
@@ -383,7 +383,7 @@ export declare const ICON_NODES: {
|
|
|
383
383
|
readonly cy: "12";
|
|
384
384
|
readonly r: "10";
|
|
385
385
|
}], readonly ["path", {
|
|
386
|
-
readonly d: "M9 9.5a3 2.5 0
|
|
386
|
+
readonly d: "M9 9.5a3 2.5 0 0 1 6 0c0 2-2 2-3 3.5";
|
|
387
387
|
}], readonly ["path", {
|
|
388
388
|
readonly d: "M12 17h.01";
|
|
389
389
|
}]];
|
|
@@ -471,7 +471,7 @@ export declare const ICON_NODES: {
|
|
|
471
471
|
readonly LucideDollarSign: readonly [readonly ["path", {
|
|
472
472
|
readonly d: "M12 3v18";
|
|
473
473
|
}], readonly ["path", {
|
|
474
|
-
readonly d: "M17 5H9.5a1 1 0
|
|
474
|
+
readonly d: "M17 5H9.5a1 1 0 0 0 0 7h5a1 1 0 0 1 0 7H6";
|
|
475
475
|
}]];
|
|
476
476
|
/** download */
|
|
477
477
|
readonly LucideDownload: readonly [readonly ["path", {
|
|
@@ -505,7 +505,7 @@ export declare const ICON_NODES: {
|
|
|
505
505
|
}]];
|
|
506
506
|
/** eye-off */
|
|
507
507
|
readonly LucideEyeOff: readonly [readonly ["path", {
|
|
508
|
-
readonly d: "M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.
|
|
508
|
+
readonly d: "M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.8 10.8 0 0 1-1.444 2.49";
|
|
509
509
|
}], readonly ["path", {
|
|
510
510
|
readonly d: "M14.084 14.158a3 3 0 0 1-4.242-4.242";
|
|
511
511
|
}], readonly ["path", {
|
|
@@ -980,9 +980,9 @@ export declare const ICON_NODES: {
|
|
|
980
980
|
}], readonly ["path", {
|
|
981
981
|
readonly d: "M12 9.189V13";
|
|
982
982
|
}], readonly ["path", {
|
|
983
|
-
readonly d: "M19 12V6a2 2 0
|
|
983
|
+
readonly d: "M19 12V6a2 2 0 0 0-2-2H7a2 2 0 0 0-2 2v6";
|
|
984
984
|
}], readonly ["path", {
|
|
985
|
-
readonly d: "M19.38 19A11.6 11.6 0
|
|
985
|
+
readonly d: "M19.38 19A11.6 11.6 0 0 0 21 13l-8.188-3.639a2 2 0 0 0-1.624 0L3 13.001a11.6 11.6 0 0 0 2.81 7.76";
|
|
986
986
|
}], readonly ["path", {
|
|
987
987
|
readonly d: "M2 20c.6.5 1.2 1 2.5 1 2.5 0 2.5-2 5-2 1.3 0 1.9.5 2.5 1s1.2 1 2.5 1c2.5 0 2.5-2 5-2 1.3 0 1.9.5 2.5 1";
|
|
988
988
|
}]];
|
|
@@ -1032,7 +1032,7 @@ export declare const ICON_NODES: {
|
|
|
1032
1032
|
}]];
|
|
1033
1033
|
/** star */
|
|
1034
1034
|
readonly LucideStar: readonly [readonly ["path", {
|
|
1035
|
-
readonly d: "M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.
|
|
1035
|
+
readonly d: "M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.12 2.12 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.12 2.12 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.12 2.12 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.12 2.12 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.12 2.12 0 0 0 1.597-1.16z";
|
|
1036
1036
|
}]];
|
|
1037
1037
|
/** table */
|
|
1038
1038
|
readonly LucideTable: readonly [readonly ["path", {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Generated bundle index. Do not edit.
|
|
3
3
|
*/
|
|
4
4
|
import { ControlValueAccessor, FormControl } from "@angular/forms";
|
|
5
|
-
import { FormValueControl } from "@angular/forms/signals";
|
|
5
|
+
import { FormValueControl, ValidationError } from "@angular/forms/signals";
|
|
6
6
|
import * as i0 from "@angular/core";
|
|
7
7
|
/**
|
|
8
8
|
* Shirkasoft UI Components.
|
|
@@ -34,6 +34,14 @@ export declare class PriceInputComponent implements ControlValueAccessor, FormVa
|
|
|
34
34
|
required: import("@angular/core").InputSignal<boolean>;
|
|
35
35
|
/** Disables the input. */
|
|
36
36
|
disabled: import("@angular/core").InputSignal<boolean>;
|
|
37
|
+
/** Errors bound automatically by the Signal Forms `[formField]` directive. */
|
|
38
|
+
errors: import("@angular/core").InputSignal<readonly ValidationError.WithOptionalFieldTree[]>;
|
|
39
|
+
/** Invalid status bound automatically by `[formField]`. */
|
|
40
|
+
invalid: import("@angular/core").InputSignal<boolean>;
|
|
41
|
+
/** Touched status bound automatically by `[formField]`. */
|
|
42
|
+
touched: import("@angular/core").InputSignal<boolean>;
|
|
43
|
+
/** Dirty status bound automatically by `[formField]`. */
|
|
44
|
+
dirty: import("@angular/core").InputSignal<boolean>;
|
|
37
45
|
/** Minimum allowed value (clamped on blur). */
|
|
38
46
|
min: import("@angular/core").InputSignal<number | undefined>;
|
|
39
47
|
/** Maximum allowed value (clamped on blur). */
|
|
@@ -82,12 +90,18 @@ export declare class PriceInputComponent implements ControlValueAccessor, FormVa
|
|
|
82
90
|
private ctrlSubscribed;
|
|
83
91
|
/** Bumped on control status changes / blur so error computeds refresh. */
|
|
84
92
|
private statusTick;
|
|
93
|
+
/**
|
|
94
|
+
* True when the input is driven by Signal Forms instead of a reactive control.
|
|
95
|
+
* Detected by the absence of a reactive control: `[formField]` provides the
|
|
96
|
+
* state through its `errors`/`invalid`/`touched`/`dirty` inputs.
|
|
97
|
+
*/
|
|
98
|
+
protected readonly usesSignalForms: import("@angular/core").Signal<boolean>;
|
|
85
99
|
/**
|
|
86
100
|
* Whether the error state is shown: forced with `showError`, or when the
|
|
87
101
|
* bound `control` is invalid and has been touched or modified.
|
|
88
102
|
*/
|
|
89
103
|
hasError: import("@angular/core").Signal<boolean>;
|
|
90
|
-
/** Message shown under the field: `errorMessage` or one derived from the
|
|
104
|
+
/** Message shown under the field: `errorMessage` or one derived from the errors. */
|
|
91
105
|
errorText: import("@angular/core").Signal<string>;
|
|
92
106
|
/** Effective disabled state combining the input and the form binding. */
|
|
93
107
|
isDisabled: import("@angular/core").Signal<boolean>;
|
|
@@ -160,6 +174,26 @@ export declare class PriceInputComponent implements ControlValueAccessor, FormVa
|
|
|
160
174
|
"required": false;
|
|
161
175
|
"isSignal": true;
|
|
162
176
|
};
|
|
177
|
+
"errors": {
|
|
178
|
+
"alias": "errors";
|
|
179
|
+
"required": false;
|
|
180
|
+
"isSignal": true;
|
|
181
|
+
};
|
|
182
|
+
"invalid": {
|
|
183
|
+
"alias": "invalid";
|
|
184
|
+
"required": false;
|
|
185
|
+
"isSignal": true;
|
|
186
|
+
};
|
|
187
|
+
"touched": {
|
|
188
|
+
"alias": "touched";
|
|
189
|
+
"required": false;
|
|
190
|
+
"isSignal": true;
|
|
191
|
+
};
|
|
192
|
+
"dirty": {
|
|
193
|
+
"alias": "dirty";
|
|
194
|
+
"required": false;
|
|
195
|
+
"isSignal": true;
|
|
196
|
+
};
|
|
163
197
|
"min": {
|
|
164
198
|
"alias": "min";
|
|
165
199
|
"required": false;
|