@reforgium/internal 1.0.1 → 1.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.
|
@@ -1,73 +1,160 @@
|
|
|
1
1
|
import { InjectionToken, Signal, Injector } from '@angular/core';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* Color semantics (appearance)
|
|
5
|
+
* Used for buttons, icons, notifications, etc.
|
|
6
|
+
*
|
|
7
|
+
* @typedef {('primary' | 'success' | 'warning' | 'error' | 'info' | 'light' | 'gray' | 'inherit')} Appearance
|
|
8
|
+
*
|
|
9
|
+
* Possible values:
|
|
10
|
+
* - `primary` - main accent color
|
|
11
|
+
* - `success` - successful action completion
|
|
12
|
+
* - `warning` - warning
|
|
13
|
+
* - `error` - error
|
|
14
|
+
* - `info` - informational message
|
|
15
|
+
* - `light` - light theme
|
|
16
|
+
* - `gray` - gray/neutral color
|
|
17
|
+
* - `inherit` - inherit color from parent
|
|
6
18
|
*/
|
|
7
19
|
type Appearance = 'primary' | 'success' | 'warning' | 'error' | 'info' | 'light' | 'gray' | 'inherit';
|
|
8
20
|
/**
|
|
9
|
-
*
|
|
10
|
-
*
|
|
21
|
+
* Base model for a selection option.
|
|
22
|
+
* Universal for selecting, lists, autocompletes, and radio groups.
|
|
23
|
+
*
|
|
24
|
+
* @template ValueType - Type of the option value (string or number). Default is `string | number`.
|
|
25
|
+
*
|
|
26
|
+
* @property {string} label - Displayed label of the option for the user
|
|
27
|
+
* @property {ValueType} value - Value of the option used programmatically
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```typescript
|
|
31
|
+
* const option: SelectOption<string> = { label: 'Option 1', value: 'option1' };
|
|
32
|
+
* const numericOption: SelectOption<number> = { label: 'First', value: 1 };
|
|
33
|
+
* ```
|
|
11
34
|
*/
|
|
12
35
|
type SelectOption<ValueType extends string | number = string | number> = {
|
|
13
|
-
/**
|
|
36
|
+
/** Displayed label */
|
|
14
37
|
label: string;
|
|
15
|
-
/**
|
|
38
|
+
/** Value (string or number) */
|
|
16
39
|
value: ValueType;
|
|
17
40
|
};
|
|
18
41
|
/**
|
|
19
|
-
*
|
|
42
|
+
* Option with icon (for icon-select or dropdown with graphics)
|
|
43
|
+
* Extends the base model {@link SelectOption} by adding an icon field.
|
|
44
|
+
*
|
|
45
|
+
* @template ValueType - Type of the option value (string or number). Default is `string | number`.
|
|
46
|
+
*
|
|
47
|
+
* @property {string} label - Displayed label of the option (inherited from SelectOption)
|
|
48
|
+
* @property {ValueType} value - Value of the option (inherited from SelectOption)
|
|
49
|
+
* @property {string} icon - Name of the icon to display next to the option (read-only)
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* ```typescript
|
|
53
|
+
* const iconOption: SelectIconOption<string> = {
|
|
54
|
+
* label: 'Settings',
|
|
55
|
+
* value: 'settings',
|
|
56
|
+
* icon: 'settings-icon'
|
|
57
|
+
* };
|
|
58
|
+
* ```
|
|
20
59
|
*/
|
|
21
60
|
type SelectIconOption<ValueType extends string | number = string | number> = SelectOption<ValueType> & {
|
|
22
|
-
/**
|
|
61
|
+
/** Icon name */
|
|
23
62
|
readonly icon: string;
|
|
24
63
|
};
|
|
25
64
|
|
|
26
|
-
/**
|
|
65
|
+
/**
|
|
66
|
+
* Basic directions for positioning elements.
|
|
67
|
+
* Defines four main directions relative to an element.
|
|
68
|
+
*
|
|
69
|
+
* @typedef {'top' | 'right' | 'bottom' | 'left'} Direction
|
|
70
|
+
*/
|
|
27
71
|
type Direction = 'top' | 'right' | 'bottom' | 'left';
|
|
28
|
-
/**
|
|
72
|
+
/**
|
|
73
|
+
* Position of a point in two-dimensional space (for example, an anchor or element center).
|
|
74
|
+
*
|
|
75
|
+
* @typedef {Object} ElementPosition
|
|
76
|
+
* @property {number} x - Coordinate along the horizontal axis.
|
|
77
|
+
* @property {number} y - Coordinate along the vertical axis.
|
|
78
|
+
*/
|
|
29
79
|
type ElementPosition = {
|
|
30
80
|
x: number;
|
|
31
81
|
y: number;
|
|
32
82
|
};
|
|
33
|
-
/**
|
|
83
|
+
/**
|
|
84
|
+
* Dimensions of a DOM element.
|
|
85
|
+
*
|
|
86
|
+
* @typedef {Object} ElementSize
|
|
87
|
+
* @property {number} width - Width of the element in pixels.
|
|
88
|
+
* @property {number} height - Height of the element in pixels.
|
|
89
|
+
*/
|
|
34
90
|
type ElementSize = {
|
|
35
91
|
width: number;
|
|
36
92
|
height: number;
|
|
37
93
|
};
|
|
38
|
-
/**
|
|
94
|
+
/**
|
|
95
|
+
* Element edges (coordinates of the edges relative to the coordinate system).
|
|
96
|
+
* All properties are read-only.
|
|
97
|
+
*
|
|
98
|
+
* @typedef {Object} ElementEdges
|
|
99
|
+
* @property {number} top - Coordinate of the top edge of the element.
|
|
100
|
+
* @property {number} left - Coordinate of the left edge of the element.
|
|
101
|
+
* @property {number} bottom - Coordinate of the bottom edge of the element.
|
|
102
|
+
* @property {number} right - Coordinate of the right edge of the element.
|
|
103
|
+
*/
|
|
39
104
|
type ElementEdges = {
|
|
40
105
|
readonly top: number;
|
|
41
106
|
readonly left: number;
|
|
42
107
|
readonly bottom: number;
|
|
43
108
|
readonly right: number;
|
|
44
109
|
};
|
|
45
|
-
/**
|
|
110
|
+
/**
|
|
111
|
+
* Combined description of a rectangular area of an element.
|
|
112
|
+
* Includes position (optional), dimensions and edge coordinates.
|
|
113
|
+
* All properties are read-only.
|
|
114
|
+
*
|
|
115
|
+
* @typedef {Object} ElementRect
|
|
116
|
+
* @property {number} [x] - Coordinate along the horizontal axis (optional).
|
|
117
|
+
* @property {number} [y] - Coordinate along the vertical axis (optional).
|
|
118
|
+
* @property {number} width - Width of the element in pixels.
|
|
119
|
+
* @property {number} height - Height of the element in pixels.
|
|
120
|
+
* @property {number} top - Coordinate of the top edge of the element.
|
|
121
|
+
* @property {number} left - Coordinate of the left edge of the element.
|
|
122
|
+
* @property {number} bottom - Coordinate of the bottom edge of the element.
|
|
123
|
+
* @property {number} right - Coordinate of the right edge of the element.
|
|
124
|
+
*/
|
|
46
125
|
type ElementRect = Readonly<Partial<ElementPosition> & ElementSize & ElementEdges>;
|
|
47
126
|
|
|
48
127
|
/**
|
|
49
|
-
*
|
|
50
|
-
*
|
|
128
|
+
* Universal type "anything".
|
|
129
|
+
* Prefer to use `unknown` to avoid `any` leaks.
|
|
51
130
|
* @example
|
|
52
131
|
* let value: AnyType = getData();
|
|
53
132
|
*/
|
|
54
133
|
type AnyType = any;
|
|
55
134
|
/**
|
|
56
|
-
*
|
|
57
|
-
* @template V
|
|
135
|
+
* Dictionary with arbitrary keys.
|
|
136
|
+
* @template V Value type
|
|
58
137
|
* @example
|
|
59
138
|
* const map: AnyDict = { a: 1, b: 2 };
|
|
60
139
|
*/
|
|
61
140
|
type AnyDict = Record<string, AnyType>;
|
|
62
141
|
/**
|
|
63
|
-
*
|
|
142
|
+
* Returns union of all property values from an object type.
|
|
143
|
+
* Similar to ValueOf but typically used for literal type extraction.
|
|
144
|
+
* @template T Source object type
|
|
145
|
+
* @example
|
|
146
|
+
* type Status = LiteralOf<{ ACTIVE: 'active'; INACTIVE: 'inactive' }>; // 'active' | 'inactive'
|
|
147
|
+
*/
|
|
148
|
+
type LiteralOf<T> = T[keyof T];
|
|
149
|
+
/**
|
|
150
|
+
* Returns union of values of all object properties.
|
|
64
151
|
* @template T
|
|
65
152
|
* @example
|
|
66
153
|
* type Values = ValueOf<{ a: 1; b: 2 }>; // 1 | 2
|
|
67
154
|
*/
|
|
68
155
|
type ValueOf<T> = T[keyof T];
|
|
69
156
|
/**
|
|
70
|
-
*
|
|
157
|
+
* Makes all object fields nullable.
|
|
71
158
|
* @template T
|
|
72
159
|
* @example
|
|
73
160
|
* type MaybeUser = Nullable<{ name: string; age: number }>;
|
|
@@ -77,16 +164,16 @@ type Nullable<T> = {
|
|
|
77
164
|
[P in keyof T]: T[P] | null;
|
|
78
165
|
};
|
|
79
166
|
/**
|
|
80
|
-
*
|
|
167
|
+
* Makes all fields nullable or undefined (nullish).
|
|
81
168
|
* @template T
|
|
82
169
|
*/
|
|
83
170
|
type Nullish<T> = {
|
|
84
171
|
[P in keyof T]: T[P] | null | undefined;
|
|
85
172
|
};
|
|
86
173
|
/**
|
|
87
|
-
*
|
|
88
|
-
* @template T
|
|
89
|
-
* @template K
|
|
174
|
+
* Makes only specified fields nullable.
|
|
175
|
+
* @template T Source object type
|
|
176
|
+
* @template K Keys that will become nullable
|
|
90
177
|
* @example
|
|
91
178
|
* type PartialUser = NullableProps<User, 'middleName'>;
|
|
92
179
|
*/
|
|
@@ -94,120 +181,355 @@ type NullableProps<T, K extends keyof T> = Omit<T, K> & {
|
|
|
94
181
|
[P in K]: T[P] | null;
|
|
95
182
|
};
|
|
96
183
|
/**
|
|
97
|
-
*
|
|
98
|
-
* @template T
|
|
99
|
-
* @template K
|
|
184
|
+
* Makes all fields optional except specified ones.
|
|
185
|
+
* @template T Source object type
|
|
186
|
+
* @template K Keys that will remain required
|
|
100
187
|
*/
|
|
101
188
|
type OptionalExcept<T, K extends keyof T> = Partial<T> & Pick<T, K>;
|
|
102
189
|
/**
|
|
103
|
-
*
|
|
104
|
-
* @template T
|
|
105
|
-
* @template K
|
|
190
|
+
* Makes all fields required except specified ones.
|
|
191
|
+
* @template T Source object type
|
|
192
|
+
* @template K Keys that will remain optional
|
|
106
193
|
*/
|
|
107
194
|
type RequiredExcept<T, K extends keyof T> = Required<Omit<T, K>> & Pick<T, K>;
|
|
108
195
|
/**
|
|
109
|
-
*
|
|
196
|
+
* Removes readonly modifiers (makes object mutable).
|
|
110
197
|
* @template T
|
|
111
198
|
*/
|
|
112
199
|
type Mutable<T> = {
|
|
113
200
|
-readonly [P in keyof T]: T[P];
|
|
114
201
|
};
|
|
115
202
|
/**
|
|
116
|
-
*
|
|
203
|
+
* JSON primitive values.
|
|
117
204
|
*/
|
|
118
205
|
type JsonPrimitive = string | number | boolean | null;
|
|
119
206
|
/**
|
|
120
|
-
*
|
|
207
|
+
* Any JSON value (object, array, primitive).
|
|
121
208
|
*/
|
|
122
209
|
type JsonValue = JsonPrimitive | {
|
|
123
210
|
[k: string]: JsonValue;
|
|
124
211
|
} | JsonValue[];
|
|
125
212
|
/**
|
|
126
|
-
*
|
|
213
|
+
* JSON-compatible object type.
|
|
127
214
|
*/
|
|
128
215
|
type JsonObject = {
|
|
129
216
|
[k: string]: JsonValue;
|
|
130
217
|
};
|
|
131
218
|
|
|
219
|
+
/**
|
|
220
|
+
* Supported REST API HTTP methods.
|
|
221
|
+
* Defines the standard set of HTTP methods used for API requests.
|
|
222
|
+
*/
|
|
132
223
|
type RestMethods = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
|
133
|
-
/**
|
|
224
|
+
/**
|
|
225
|
+
* Single sort token in format "field,direction".
|
|
226
|
+
* Used to specify sorting criteria for a single field.
|
|
227
|
+
*
|
|
228
|
+
* @template F - Field name type, defaults to string
|
|
229
|
+
* @example
|
|
230
|
+
* ```typescript
|
|
231
|
+
* const sort: SortToken = "name,asc";
|
|
232
|
+
* const sort2: SortToken<"id" | "createdAt"> = "id,desc";
|
|
233
|
+
* ```
|
|
234
|
+
*/
|
|
134
235
|
type SortToken<F extends string = string> = `${F},${'asc' | 'desc'}`;
|
|
135
|
-
/**
|
|
236
|
+
/**
|
|
237
|
+
* Pagination request with optional multi-field sorting.
|
|
238
|
+
* Used to request paginated data from API endpoints.
|
|
239
|
+
*/
|
|
136
240
|
type PageableRequest = {
|
|
241
|
+
/**
|
|
242
|
+
* Page number (0-based indexing).
|
|
243
|
+
* The first page is 0, the second page is 1, etc.
|
|
244
|
+
*/
|
|
137
245
|
page: number;
|
|
246
|
+
/**
|
|
247
|
+
* Optional page size limit.
|
|
248
|
+
* Specifies the maximum number of items to return per page.
|
|
249
|
+
*/
|
|
138
250
|
size?: number;
|
|
251
|
+
/**
|
|
252
|
+
* Optional sorting criteria.
|
|
253
|
+
* Can be a single sort token or an array of sort tokens for multi-field sorting.
|
|
254
|
+
* Format: "field,direction" where direction is "asc" or "desc".
|
|
255
|
+
* @example ["name,asc", "createdAt,desc"]
|
|
256
|
+
*/
|
|
139
257
|
sort?: string | ReadonlyArray<string>;
|
|
140
258
|
};
|
|
141
|
-
/**
|
|
259
|
+
/**
|
|
260
|
+
* Paginated response structure.
|
|
261
|
+
* Compatible with Spring Data pagination format but type-safe.
|
|
262
|
+
*
|
|
263
|
+
* @template T - Type of items in the content array
|
|
264
|
+
*/
|
|
142
265
|
type PageableResponse<T> = {
|
|
266
|
+
/**
|
|
267
|
+
* Optional pagination metadata.
|
|
268
|
+
* Contains information about the current page position and size.
|
|
269
|
+
*/
|
|
143
270
|
pageable?: {
|
|
271
|
+
/**
|
|
272
|
+
* Optional zero-based offset of the first item in the current page.
|
|
273
|
+
*/
|
|
144
274
|
offset?: number;
|
|
275
|
+
/**
|
|
276
|
+
* Current page number (0-based indexing).
|
|
277
|
+
*/
|
|
145
278
|
pageNumber: number;
|
|
279
|
+
/**
|
|
280
|
+
* Number of items per page.
|
|
281
|
+
*/
|
|
146
282
|
pageSize: number;
|
|
147
283
|
};
|
|
284
|
+
/**
|
|
285
|
+
* Total number of elements across all pages.
|
|
286
|
+
*/
|
|
148
287
|
totalElements: number;
|
|
288
|
+
/**
|
|
289
|
+
* Array of items for the current page.
|
|
290
|
+
*/
|
|
149
291
|
content: T[];
|
|
150
292
|
};
|
|
151
|
-
/**
|
|
293
|
+
/**
|
|
294
|
+
* Business-level error response structure.
|
|
295
|
+
* Used to communicate structured error information from API endpoints.
|
|
296
|
+
*/
|
|
152
297
|
type ErrorResponse = {
|
|
298
|
+
/**
|
|
299
|
+
* Error code identifier.
|
|
300
|
+
* Can be a numeric code or string constant for error categorization.
|
|
301
|
+
*/
|
|
153
302
|
errorCode: number | string;
|
|
303
|
+
/**
|
|
304
|
+
* Human-readable error message.
|
|
305
|
+
* Provides a description of the error for display or logging.
|
|
306
|
+
*/
|
|
154
307
|
message: string;
|
|
155
|
-
/**
|
|
308
|
+
/**
|
|
309
|
+
* Optional field-level validation errors map.
|
|
310
|
+
* Maps form/DTO field names to their respective error messages.
|
|
311
|
+
* Supports multiple errors per field when concatenated in the string value.
|
|
312
|
+
*/
|
|
156
313
|
fields?: Record<string, string>;
|
|
157
|
-
/**
|
|
314
|
+
/**
|
|
315
|
+
* Optional arbitrary error details.
|
|
316
|
+
* Can contain additional context such as error code enums, hints, or debugging information.
|
|
317
|
+
*/
|
|
158
318
|
details?: unknown;
|
|
159
319
|
};
|
|
160
|
-
/**
|
|
320
|
+
/**
|
|
321
|
+
* Common query parameters interface for API requests.
|
|
322
|
+
* Combines pagination, sorting, and filtering capabilities.
|
|
323
|
+
*
|
|
324
|
+
* @template Filters - Type of the domain model used for filtering, defaults to unknown
|
|
325
|
+
*/
|
|
161
326
|
interface QueryParams<Filters = unknown> {
|
|
327
|
+
/**
|
|
328
|
+
* Optional page number for pagination (0-based indexing).
|
|
329
|
+
*/
|
|
162
330
|
page?: number;
|
|
331
|
+
/**
|
|
332
|
+
* Optional page size limit.
|
|
333
|
+
*/
|
|
163
334
|
size?: number;
|
|
335
|
+
/**
|
|
336
|
+
* Optional sorting criteria.
|
|
337
|
+
* Can be a single sort token or an array of sort tokens for multi-field sorting.
|
|
338
|
+
*/
|
|
164
339
|
sort?: string | ReadonlyArray<string>;
|
|
340
|
+
/**
|
|
341
|
+
* Optional filters as a partial subset of the domain model.
|
|
342
|
+
* Allows filtering by any combination of model properties.
|
|
343
|
+
*/
|
|
165
344
|
filters?: Partial<Filters>;
|
|
166
345
|
}
|
|
167
|
-
/**
|
|
346
|
+
/**
|
|
347
|
+
* Allowed scalar value types for query parameters.
|
|
348
|
+
* Represents primitive types that can be safely serialized in URL query strings.
|
|
349
|
+
*/
|
|
168
350
|
type QueryScalar = string | number | boolean;
|
|
169
|
-
/**
|
|
351
|
+
/**
|
|
352
|
+
* Universal query parameters dictionary with array support.
|
|
353
|
+
* Maps parameter names to scalar values or arrays of scalar values.
|
|
354
|
+
* Useful for building flexible query strings with multiple values per parameter.
|
|
355
|
+
*
|
|
356
|
+
* @example
|
|
357
|
+
* ```typescript
|
|
358
|
+
* const query: Query = {
|
|
359
|
+
* status: "active",
|
|
360
|
+
* tags: ["typescript", "angular"],
|
|
361
|
+
* limit: 10
|
|
362
|
+
* };
|
|
363
|
+
* ```
|
|
364
|
+
*/
|
|
170
365
|
type Query = Record<string, QueryScalar | ReadonlyArray<QueryScalar>>;
|
|
171
366
|
|
|
172
|
-
/**
|
|
367
|
+
/**
|
|
368
|
+
* Available application languages.
|
|
369
|
+
* Should be synchronized with localization keys.
|
|
370
|
+
*
|
|
371
|
+
* @type {'ru' | 'kg'}
|
|
372
|
+
* 'ru' - Russian language
|
|
373
|
+
* 'kg' - Kyrgyz language
|
|
374
|
+
*/
|
|
173
375
|
type Langs = 'ru' | 'kg';
|
|
174
376
|
/**
|
|
175
|
-
*
|
|
176
|
-
*
|
|
377
|
+
* Translation provider interface for managing translations and namespaces.
|
|
378
|
+
* Provides methods to retrieve translated messages and load translation namespaces.
|
|
379
|
+
*/
|
|
380
|
+
type TranslationProvider = {
|
|
381
|
+
/**
|
|
382
|
+
* Retrieves translated message by key with optional parameter interpolation.
|
|
383
|
+
*
|
|
384
|
+
* @param {string} message - Translation key to retrieve.
|
|
385
|
+
* @param {Record<string, string>} [params] - Optional parameters for interpolation in translation.
|
|
386
|
+
* @return {string} Translated message with applied parameters or original key if translation not found.
|
|
387
|
+
*/
|
|
388
|
+
get: (message: string, params?: Record<string, string>) => string;
|
|
389
|
+
/**
|
|
390
|
+
* Loads translation namespace asynchronously.
|
|
391
|
+
*
|
|
392
|
+
* @param {string} ns - Namespace identifier to load.
|
|
393
|
+
* @return {Promise<void>} Promise that resolves when namespace is loaded successfully.
|
|
394
|
+
*/
|
|
395
|
+
loadNamespace: (ns: string) => Promise<void>;
|
|
396
|
+
};
|
|
397
|
+
/**
|
|
398
|
+
* Provider for changing the application lang.
|
|
399
|
+
*
|
|
400
|
+
* Supplies a method to programmatically switch between supported languages.
|
|
401
|
+
*
|
|
402
|
+
* @example
|
|
403
|
+
* ```ts
|
|
404
|
+
* const changeLang = inject(CHANGE_LANGE);
|
|
405
|
+
* changeLang('ru');
|
|
406
|
+
* ```
|
|
407
|
+
*/
|
|
408
|
+
type ChangeLangProvider = (lang: Langs) => void;
|
|
409
|
+
/**
|
|
410
|
+
* Injection token for the current application language as a Signal.
|
|
411
|
+
* Provides reactive access to the currently selected language.
|
|
412
|
+
* Can be overridden in app.config with a custom provider.
|
|
413
|
+
*
|
|
414
|
+
* @type {InjectionToken<Signal<Langs>>}
|
|
177
415
|
*/
|
|
178
416
|
declare const SELECTED_LANG: InjectionToken<Signal<Langs>>;
|
|
417
|
+
/**
|
|
418
|
+
* Injection token for language change provider.
|
|
419
|
+
* Provides access to method for changing the current application language.
|
|
420
|
+
* Can be overridden in app.config with a custom provider.
|
|
421
|
+
*
|
|
422
|
+
* @type {InjectionToken<ChangeLangProvider>}
|
|
423
|
+
*/
|
|
424
|
+
declare const CHANGE_LANG: InjectionToken<ChangeLangProvider>;
|
|
425
|
+
/**
|
|
426
|
+
* Injection token for translation provider.
|
|
427
|
+
* Provides access to translation methods for message retrieval and namespace loading.
|
|
428
|
+
*
|
|
429
|
+
* @type {InjectionToken<TranslationProvider>}
|
|
430
|
+
*/
|
|
431
|
+
declare const TRANSLATION: InjectionToken<TranslationProvider>;
|
|
179
432
|
|
|
180
433
|
/**
|
|
181
|
-
*
|
|
434
|
+
* List of supported application themes.
|
|
182
435
|
*
|
|
183
|
-
* `'light'` —
|
|
184
|
-
* `'dark'` —
|
|
436
|
+
* `'light'` — light theme
|
|
437
|
+
* `'dark'` — dark theme
|
|
185
438
|
*/
|
|
186
439
|
type Themes = 'light' | 'dark';
|
|
187
440
|
/**
|
|
188
|
-
*
|
|
189
|
-
*
|
|
441
|
+
* Provider for changing the application theme.
|
|
442
|
+
*
|
|
443
|
+
* Supplies a method to programmatically switch between supported themes.
|
|
444
|
+
*
|
|
445
|
+
* @example
|
|
446
|
+
* ```ts
|
|
447
|
+
* const changeTheme = inject(CHANGE_THEME);
|
|
448
|
+
* changeTheme('dark');
|
|
449
|
+
* ```
|
|
450
|
+
*/
|
|
451
|
+
type ChangeThemeProvider = (lang: Themes) => void;
|
|
452
|
+
/**
|
|
453
|
+
* Current application theme as Signal.
|
|
454
|
+
* Can be overridden in app.config with a custom provider.
|
|
190
455
|
*/
|
|
191
456
|
declare const SELECTED_THEME: InjectionToken<Signal<Themes>>;
|
|
457
|
+
declare const CHANGE_THEME: InjectionToken<ChangeThemeProvider>;
|
|
192
458
|
|
|
193
|
-
/**
|
|
459
|
+
/**
|
|
460
|
+
* Supported device types for responsive design and device-specific logic.
|
|
461
|
+
*
|
|
462
|
+
* @typedef {('mobile' | 'tablet' | 'desktop-s' | 'desktop')} Devices
|
|
463
|
+
*
|
|
464
|
+
* Possible values:
|
|
465
|
+
* - 'mobile' - Mobile devices (smartphones)
|
|
466
|
+
* - 'tablet' - Tablet devices
|
|
467
|
+
* - 'desktop-s' - Small desktop screens
|
|
468
|
+
* - 'desktop' - Standard desktop screens
|
|
469
|
+
*/
|
|
194
470
|
type Devices = 'mobile' | 'tablet' | 'desktop-s' | 'desktop';
|
|
195
471
|
/**
|
|
196
|
-
*
|
|
197
|
-
*
|
|
472
|
+
* Injection token for the current device type as a Signal.
|
|
473
|
+
*
|
|
474
|
+
* Provides reactive access to the current device type throughout the application.
|
|
475
|
+
* Can be overridden in app.config with a custom provider to supply device detection logic.
|
|
476
|
+
*
|
|
477
|
+
* @example
|
|
478
|
+
* ```typescript
|
|
479
|
+
* // In app.config.ts
|
|
480
|
+
* providers: [
|
|
481
|
+
* {
|
|
482
|
+
* provide: CURRENT_DEVICE,
|
|
483
|
+
* useValue: signal<Devices>('mobile')
|
|
484
|
+
* }
|
|
485
|
+
* ]
|
|
486
|
+
*
|
|
487
|
+
* // In a component or service
|
|
488
|
+
* private readonly currentDevice = inject(CURRENT_DEVICE);
|
|
489
|
+
* ```
|
|
198
490
|
*/
|
|
199
491
|
declare const CURRENT_DEVICE: InjectionToken<Signal<Devices>>;
|
|
200
492
|
|
|
201
|
-
/**
|
|
493
|
+
/**
|
|
494
|
+
* Represents flexible validation error data without enforced fields.
|
|
495
|
+
* Contains common properties like requiredLength and actualLength
|
|
496
|
+
* and allows additional string properties through index signature.
|
|
497
|
+
*
|
|
498
|
+
* @property {string} requiredLength - The required length for validation.
|
|
499
|
+
* @property {string} actualLength - The actual length of the validated value.
|
|
500
|
+
*/
|
|
202
501
|
type ValidationErrorData = {
|
|
203
502
|
requiredLength: string;
|
|
204
503
|
actualLength: string;
|
|
205
504
|
[key: string]: string;
|
|
206
505
|
};
|
|
207
|
-
/**
|
|
506
|
+
/**
|
|
507
|
+
* Map of validation error names to message generator functions.
|
|
508
|
+
* Each key represents an error name, and the value is a function
|
|
509
|
+
* that takes validation error data and returns a formatted error message.
|
|
510
|
+
*
|
|
511
|
+
* @example
|
|
512
|
+
* const messages: ValidationMessages = {
|
|
513
|
+
* minlength: (error) => `Minimum length is ${error.requiredLength}`
|
|
514
|
+
* };
|
|
515
|
+
*/
|
|
208
516
|
type ValidationMessages = Record<string, (error: ValidationErrorData) => string>;
|
|
209
517
|
/**
|
|
210
|
-
*
|
|
518
|
+
* Injection token for a validation messages map.
|
|
519
|
+
* Can be overridden in feature modules to provide custom validation messages.
|
|
520
|
+
* Defaults to an empty object when not provided.
|
|
521
|
+
*
|
|
522
|
+
* @example
|
|
523
|
+
* // In a feature module:
|
|
524
|
+
* providers: [
|
|
525
|
+
* {
|
|
526
|
+
* provide: VALIDATION_MESSAGES,
|
|
527
|
+
* useValue: {
|
|
528
|
+
* required: () => 'This field is required',
|
|
529
|
+
* minlength: (error) => `Min length: ${error.requiredLength}`
|
|
530
|
+
* }
|
|
531
|
+
* }
|
|
532
|
+
* ]
|
|
211
533
|
*/
|
|
212
534
|
declare const VALIDATION_MESSAGES: InjectionToken<ValidationMessages>;
|
|
213
535
|
|
|
@@ -527,6 +849,6 @@ declare function deepEqual(a: AnyType, b: AnyType, seen?: Map<any, any>): boolea
|
|
|
527
849
|
|
|
528
850
|
declare const generateId: (limit?: number, radix?: number) => string;
|
|
529
851
|
|
|
530
|
-
export { CURRENT_DEVICE, SELECTED_LANG, SELECTED_THEME, VALIDATION_MESSAGES, appendQueryParams, base64ToBlob, compareRoutes, concatArray, copyText, debounceSignal, deepEqual, downloadByBlob, downloadByUrl, fillUrlWithParams, formatDate, formatToLocaledDate, formatToSpacedNumber, generateId, getAvailableHeight, getChainedValue, getCorrectedPosition, isDatePeriod, isNullable, isNumber, isObject, makeQuery, materializeRoutePath, normalizeUrl, parseQueryArray, parseQueryParams, parseToDate, parseToDatePeriod, reformatDateToISO, throttleSignal, toDate, truncate };
|
|
531
|
-
export type { AnyDict, AnyType, Appearance, Devices, Direction, ElementEdges, ElementPosition, ElementRect, ElementSize, ErrorResponse, JsonObject, JsonPrimitive, JsonValue, Langs, Mutable, Nullable, NullableProps, Nullish, OptionalExcept, PageableRequest, PageableResponse, Query, QueryParams, QueryScalar, RequiredExcept, RestMethods, SelectIconOption, SelectOption, SortToken, Themes, ValidationErrorData, ValidationMessages, ValueOf };
|
|
852
|
+
export { CHANGE_LANG, CHANGE_THEME, CURRENT_DEVICE, SELECTED_LANG, SELECTED_THEME, TRANSLATION, VALIDATION_MESSAGES, appendQueryParams, base64ToBlob, compareRoutes, concatArray, copyText, debounceSignal, deepEqual, downloadByBlob, downloadByUrl, fillUrlWithParams, formatDate, formatToLocaledDate, formatToSpacedNumber, generateId, getAvailableHeight, getChainedValue, getCorrectedPosition, isDatePeriod, isNullable, isNumber, isObject, makeQuery, materializeRoutePath, normalizeUrl, parseQueryArray, parseQueryParams, parseToDate, parseToDatePeriod, reformatDateToISO, throttleSignal, toDate, truncate };
|
|
853
|
+
export type { AnyDict, AnyType, Appearance, Devices, Direction, ElementEdges, ElementPosition, ElementRect, ElementSize, ErrorResponse, JsonObject, JsonPrimitive, JsonValue, Langs, LiteralOf, Mutable, Nullable, NullableProps, Nullish, OptionalExcept, PageableRequest, PageableResponse, Query, QueryParams, QueryScalar, RequiredExcept, RestMethods, SelectIconOption, SelectOption, SortToken, Themes, ValidationErrorData, ValidationMessages, ValueOf };
|
|
532
854
|
//# sourceMappingURL=reforgium-internal.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reforgium-internal.d.ts","sources":["../../../../libs/internal/src/models/components.ts","../../../../libs/internal/src/models/elements.ts","../../../../libs/internal/src/models/util.ts","../../../../libs/internal/src/models/api.ts","../../../../libs/internal/src/tokens/locale.token.ts","../../../../libs/internal/src/tokens/theme.token.ts","../../../../libs/internal/src/tokens/device.token.ts","../../../../libs/internal/src/tokens/validation-messages.token.ts","../../../../libs/internal/src/utils/web.utils.ts","../../../../libs/internal/src/utils/timers.utils.ts","../../../../libs/internal/src/utils/date.utils.ts","../../../../libs/internal/src/utils/types.utils.ts","../../../../libs/internal/src/utils/format.utils.ts","../../../../libs/internal/src/utils/positions.utils.ts","../../../../libs/internal/src/utils/available-height.utils.ts","../../../../libs/internal/src/utils/get-chained-value.utils.ts","../../../../libs/internal/src/utils/urls.utils.ts","../../../../libs/internal/src/utils/routes.utils.ts","../../../../libs/internal/src/utils/deep-equal.utils.ts","../../../../libs/internal/src/utils/generate.utils.ts"],"sourcesContent":[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null],"names":[],"mappings":";;AAAA
|
|
1
|
+
{"version":3,"file":"reforgium-internal.d.ts","sources":["../../../../libs/internal/src/models/components.ts","../../../../libs/internal/src/models/elements.ts","../../../../libs/internal/src/models/util.ts","../../../../libs/internal/src/models/api.ts","../../../../libs/internal/src/tokens/locale.token.ts","../../../../libs/internal/src/tokens/theme.token.ts","../../../../libs/internal/src/tokens/device.token.ts","../../../../libs/internal/src/tokens/validation-messages.token.ts","../../../../libs/internal/src/utils/web.utils.ts","../../../../libs/internal/src/utils/timers.utils.ts","../../../../libs/internal/src/utils/date.utils.ts","../../../../libs/internal/src/utils/types.utils.ts","../../../../libs/internal/src/utils/format.utils.ts","../../../../libs/internal/src/utils/positions.utils.ts","../../../../libs/internal/src/utils/available-height.utils.ts","../../../../libs/internal/src/utils/get-chained-value.utils.ts","../../../../libs/internal/src/utils/urls.utils.ts","../../../../libs/internal/src/utils/routes.utils.ts","../../../../libs/internal/src/utils/deep-equal.utils.ts","../../../../libs/internal/src/utils/generate.utils.ts"],"sourcesContent":[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null],"names":[],"mappings":";;AAAA;;;;;;;;;;;;;;;AAeG;;AAGH;;;;;;;;;;;;;;AAcG;AACG;;;;;;AAQN;;;;;;;;;;;;;;;;;;AAkBG;;;AAGD;;;AC9DF;;;;;AAKG;AACG;AAEN;;;;;;AAMG;AACG;;;;AAKN;;;;;;AAMG;AACG;;;;AAKN;;;;;;;;;AASG;AACG;AACJ;AACA;AACA;AACA;;AAGF;;;;;;;;;;;;;;AAcG;AACG;;AChEN;;;;;AAKG;AAEG;AAEN;;;;;AAKG;AACG;AAEN;;;;;;AAMG;AACG;AAEN;;;;;AAKG;AACG;AAEN;;;;;;AAMG;AACG;;;AAEN;;;AAGG;AACG;;;AAEN;;;;;;AAMG;;;;AAKH;;;;AAIG;AACG;AAEN;;;;AAIG;AACG;AAEN;;;AAGG;AACG;;;AAEN;;AAEG;AACG;AAEN;;AAEG;AACG;AAAoC;;AAE1C;;AAEG;AACG;AAAqB;;;AC7F3B;;;AAGG;AACG;AAEN;;;;;;;;;;AAUG;;AAGH;;;AAGG;AACG;AACJ;;;AAGG;;AAGH;;;AAGG;;AAGH;;;;;AAKG;;;AAIL;;;;;AAKG;AACG;AACJ;;;AAGG;AACH;AACE;;AAEG;;AAGH;;AAEG;;AAGH;;AAEG;;;AAIL;;AAEG;;AAGH;;AAEG;;;AAIL;;;AAGG;AACG;AACJ;;;AAGG;AACH;AAEA;;;AAGG;;AAGH;;;;AAIG;;AAGH;;;AAGG;;;AAIL;;;;;AAKG;AACG;AACJ;;AAEG;;AAGH;;AAEG;;AAGH;;;AAGG;;AAGH;;;AAGG;AACH;AACD;AAED;;;AAGG;AACG;AAEN;;;;;;;;;;;;;AAaG;AACG;;ACnKN;;;;;;;AAOG;;AAGH;;;AAGG;AACH;AACE;;;;;;AAMG;AACH;AACA;;;;;AAKG;;;AAIL;;;;;;;;;;AAUG;AACH;AAEA;;;;;;AAMG;AACH;AAEA;;;;;;AAMG;AACH;AAEA;;;;;AAKG;AACH;;ACrEA;;;;;AAKG;;AAGH;;;;;;;;;;AAUG;AACH;AAEA;;;AAGG;AACH;AACA;;AC1BA;;;;;;;;;;AAUG;AACG;AAEN;;;;;;;;;;;;;;;;;;;AAmBG;AACH;;ACjCA;;;;;;;AAOG;AACG;;;AAGJ;;AAGF;;;;;;;;;AASG;AACG;AAEN;;;;;;;;;;;;;;;;AAgBG;AACH;;AC7CA;;;;;;;AAOG;AACH;AAaA;;;;;;;AAOG;AACH;AAcA;;;;;;;AAOG;AACH;AA8BA;;;;;;;;AAQG;AACH;;ACtFA;;AAA0F;AAyB1F;;AAA0F;;AC3B1F;;;;;;;;;;;;;;AAcG;AACH;AAsBA;;;;;;AAMG;AACH;AAQA;;;;;;;;AAQG;AACH;AAuCA;;;;;;;;;;;;;;AAcG;AACH;AAyBA;;;;;;;;AAQG;AACH;AAGA;;;;;;AAMG;AACH;AAQA;;;;;AAKG;AACH;;AC7KA;;;;;;;;;AASG;AACH;AAGA;;;;;;;;;;;AAWG;AACH;AAYA;;;;;;;;;AASG;AACH;AAGA;;;;;;;;;;;;;;AAcG;AACH;AAmCA;;;;;;;;;;;;AAYG;AACH;;ACnHA;;;;;;;AAOG;AACH;AAYA;;;;;;;;AAQG;AACH;;AC3BA;AAEA;;ACJA;;;;;;;AAOG;AACH;;ACRA;;;;;;;AAOG;AACH;;ACNA;;;;;;AAMG;AACH;AAUA;;;;;;;;;AASG;AACH;AAQA;;;;;;;AAOG;AACH;AAcA;;;;;;AAMG;AACH;;AC/DA;;;;;;;;;;AAUG;AACH;AAeA;;;;;;;;;;;AAWG;AACH;AAUA;;;;;;;AAOG;AACH;;ACxDA;;;;;;;;;AASG;AACH;;ACbA;;;"}
|