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,328 +1,518 @@
|
|
|
1
|
-
import * as i0 from
|
|
2
|
-
import {
|
|
3
|
-
import * as i1 from
|
|
4
|
-
import { CommonModule } from
|
|
5
|
-
import {
|
|
6
|
-
import { takeUntilDestroyed } from
|
|
7
|
-
import { TranslocoService } from
|
|
8
|
-
import { ShkConfigService, currencyDecimals,
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
*/
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
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
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
1
|
+
import * as i0 from "@angular/core";
|
|
2
|
+
import { ChangeDetectionStrategy, Component, DestroyRef, computed, effect, forwardRef, inject, input, model, output, signal } from "@angular/core";
|
|
3
|
+
import * as i1 from "@angular/common";
|
|
4
|
+
import { CommonModule } from "@angular/common";
|
|
5
|
+
import { NG_VALUE_ACCESSOR, ReactiveFormsModule } from "@angular/forms";
|
|
6
|
+
import { takeUntilDestroyed } from "@angular/core/rxjs-interop";
|
|
7
|
+
import { TranslocoService } from "@jsverse/transloco";
|
|
8
|
+
import { ShkConfigService, currencyDecimals, currencySymbol, formatNumber, numberSeparators } from "shirkasoft-ui-components/config";
|
|
9
|
+
var PriceInputComponent = class PriceInputComponent {
|
|
10
|
+
constructor() {
|
|
11
|
+
this.control = input(void 0, ...ngDevMode ? [{ debugName: "control" }] : /* istanbul ignore next */ []);
|
|
12
|
+
this.value = model(0, ...ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []);
|
|
13
|
+
this.isPercentage = model(false, ...ngDevMode ? [{ debugName: "isPercentage" }] : /* istanbul ignore next */ []);
|
|
14
|
+
this.label = input("", ...ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []);
|
|
15
|
+
this.inputId = input("", ...ngDevMode ? [{ debugName: "inputId" }] : /* istanbul ignore next */ []);
|
|
16
|
+
this.required = input(false, ...ngDevMode ? [{ debugName: "required" }] : /* istanbul ignore next */ []);
|
|
17
|
+
this.disabled = input(false, ...ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []);
|
|
18
|
+
this.min = input(0, ...ngDevMode ? [{ debugName: "min" }] : /* istanbul ignore next */ []);
|
|
19
|
+
this.max = input(Infinity, ...ngDevMode ? [{ debugName: "max" }] : /* istanbul ignore next */ []);
|
|
20
|
+
this.decimals = input(void 0, ...ngDevMode ? [{ debugName: "decimals" }] : /* istanbul ignore next */ []);
|
|
21
|
+
this.currency = input("", ...ngDevMode ? [{ debugName: "currency" }] : /* istanbul ignore next */ []);
|
|
22
|
+
this.placeholder = input("", ...ngDevMode ? [{ debugName: "placeholder" }] : /* istanbul ignore next */ []);
|
|
23
|
+
this.ariaLabel = input("", ...ngDevMode ? [{ debugName: "ariaLabel" }] : /* istanbul ignore next */ []);
|
|
24
|
+
this.preventNegative = input(false, ...ngDevMode ? [{ debugName: "preventNegative" }] : /* istanbul ignore next */ []);
|
|
25
|
+
this.showError = input(false, ...ngDevMode ? [{ debugName: "showError" }] : /* istanbul ignore next */ []);
|
|
26
|
+
this.errorMessage = input("", ...ngDevMode ? [{ debugName: "errorMessage" }] : /* istanbul ignore next */ []);
|
|
27
|
+
this.touch = output();
|
|
28
|
+
this.destroyRef = inject(DestroyRef);
|
|
29
|
+
this.transloco = inject(TranslocoService);
|
|
30
|
+
this.config = inject(ShkConfigService);
|
|
31
|
+
this.effectiveDecimals = computed(() => Math.max(0, this.decimals() ?? this.config.get("numbers.decimals")() ?? currencyDecimals(this.config.get("numbers.currency")())), ...ngDevMode ? [{ debugName: "effectiveDecimals" }] : /* istanbul ignore next */ []);
|
|
32
|
+
this.numbersLocale = computed(() => this.config.get("numbers.locale")(), ...ngDevMode ? [{ debugName: "numbersLocale" }] : /* istanbul ignore next */ []);
|
|
33
|
+
this.decimalSeparator = computed(() => numberSeparators(this.numbersLocale()).decimal, ...ngDevMode ? [{ debugName: "decimalSeparator" }] : /* istanbul ignore next */ []);
|
|
34
|
+
this.displaySymbol = computed(() => this.currency() || this.config.get("numbers.currencySymbol")() || currencySymbol(this.config.get("numbers.currency")(), this.numbersLocale()), ...ngDevMode ? [{ debugName: "displaySymbol" }] : /* istanbul ignore next */ []);
|
|
35
|
+
this.displayText = signal("", ...ngDevMode ? [{ debugName: "displayText" }] : /* istanbul ignore next */ []);
|
|
36
|
+
this.focused = signal(false, ...ngDevMode ? [{ debugName: "focused" }] : /* istanbul ignore next */ []);
|
|
37
|
+
this.controlDisabled = signal(false, ...ngDevMode ? [{ debugName: "controlDisabled" }] : /* istanbul ignore next */ []);
|
|
38
|
+
this.ctrlSubscribed = false;
|
|
39
|
+
this.statusTick = signal(0, ...ngDevMode ? [{ debugName: "statusTick" }] : /* istanbul ignore next */ []);
|
|
40
|
+
this.hasError = computed(() => {
|
|
41
|
+
this.statusTick();
|
|
42
|
+
if (this.showError()) return true;
|
|
43
|
+
const ctrl = this.control();
|
|
44
|
+
return !!ctrl && ctrl.invalid && (ctrl.touched || ctrl.dirty);
|
|
45
|
+
}, ...ngDevMode ? [{ debugName: "hasError" }] : /* istanbul ignore next */ []);
|
|
46
|
+
this.errorText = computed(() => {
|
|
47
|
+
this.statusTick();
|
|
48
|
+
const custom = this.errorMessage();
|
|
49
|
+
if (custom) return custom;
|
|
50
|
+
const errors = this.control()?.errors;
|
|
51
|
+
if (!errors) return "";
|
|
52
|
+
if (errors["required"]) return this.transloco.translate("validation.required");
|
|
53
|
+
return this.transloco.translate("validation.invalid");
|
|
54
|
+
}, ...ngDevMode ? [{ debugName: "errorText" }] : /* istanbul ignore next */ []);
|
|
55
|
+
this.isDisabled = computed(() => this.disabled() || this.controlDisabled(), ...ngDevMode ? [{ debugName: "isDisabled" }] : /* istanbul ignore next */ []);
|
|
56
|
+
this.onChange = () => {};
|
|
57
|
+
this.onTouched = () => {};
|
|
58
|
+
effect(() => {
|
|
59
|
+
const ctrl = this.control();
|
|
60
|
+
if (!ctrl || this.ctrlSubscribed) return;
|
|
61
|
+
this.ctrlSubscribed = true;
|
|
62
|
+
this.controlDisabled.set(ctrl.disabled);
|
|
63
|
+
ctrl.valueChanges.pipe(takeUntilDestroyed(this.destroyRef)).subscribe((v) => {
|
|
64
|
+
if (!this.focused()) this.displayText.set(this.formatNumber(v ?? 0));
|
|
65
|
+
});
|
|
66
|
+
ctrl.statusChanges.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(() => {
|
|
67
|
+
this.controlDisabled.set(ctrl.disabled);
|
|
68
|
+
this.statusTick.update((v) => v + 1);
|
|
69
|
+
});
|
|
70
|
+
ctrl.events.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(() => {
|
|
71
|
+
this.statusTick.update((v) => v + 1);
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
effect(() => {
|
|
75
|
+
const ctrl = this.control();
|
|
76
|
+
const v = ctrl ? ctrl.value : this.value();
|
|
77
|
+
if (!this.focused()) this.displayText.set(this.formatNumber(v ?? 0));
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
toggleMode() {
|
|
81
|
+
if (this.isDisabled()) return;
|
|
82
|
+
this.isPercentage.update((v) => !v);
|
|
83
|
+
}
|
|
84
|
+
onFocus(event) {
|
|
85
|
+
const input = event.target;
|
|
86
|
+
this.focused.set(true);
|
|
87
|
+
this.displayText.set(this.editableNumber(this.currentValue()));
|
|
88
|
+
setTimeout(() => {
|
|
89
|
+
if (this.focused()) input.select();
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
onBlur() {
|
|
93
|
+
this.focused.set(false);
|
|
94
|
+
this.onTouched();
|
|
95
|
+
this.touch.emit();
|
|
96
|
+
let v = this.parseEditable(this.displayText());
|
|
97
|
+
if (isNaN(v)) v = 0;
|
|
98
|
+
const min = this.min() ?? 0;
|
|
99
|
+
const max = this.max() ?? Infinity;
|
|
100
|
+
if (isFinite(min) && v < min) v = min;
|
|
101
|
+
if (isFinite(max) && v > max) v = max;
|
|
102
|
+
v = this.roundTo(v);
|
|
103
|
+
this.setValue(v);
|
|
104
|
+
this.displayText.set(this.formatNumber(v));
|
|
105
|
+
this.control()?.markAsTouched();
|
|
106
|
+
this.statusTick.update((n) => n + 1);
|
|
107
|
+
}
|
|
108
|
+
onKeydown(event) {
|
|
109
|
+
if ([
|
|
110
|
+
"Backspace",
|
|
111
|
+
"Tab",
|
|
112
|
+
"End",
|
|
113
|
+
"Home",
|
|
114
|
+
"ArrowLeft",
|
|
115
|
+
"ArrowRight",
|
|
116
|
+
"Delete",
|
|
117
|
+
"Enter",
|
|
118
|
+
"Escape"
|
|
119
|
+
].includes(event.key)) return;
|
|
120
|
+
if (/^\d$/.test(event.key)) return;
|
|
121
|
+
if (event.key === "." || event.key === ",") {
|
|
122
|
+
const input = event.target;
|
|
123
|
+
if (input.value.includes(".") || input.value.includes(",")) event.preventDefault();
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
if (event.key === "-") {
|
|
127
|
+
const input = event.target;
|
|
128
|
+
if (this.preventNegative() || (this.min() ?? 0) >= 0) event.preventDefault();
|
|
129
|
+
else if (input.value.includes("-")) event.preventDefault();
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
event.preventDefault();
|
|
133
|
+
}
|
|
134
|
+
onInput(event) {
|
|
135
|
+
const input = event.target;
|
|
136
|
+
const pos = input.selectionStart ?? input.value.length;
|
|
137
|
+
let cleaned = input.value.replace(/[^0-9.,-]/g, "");
|
|
138
|
+
if (this.preventNegative() || (this.min() ?? 0) >= 0) cleaned = cleaned.replace(/-/g, "");
|
|
139
|
+
cleaned = cleaned.replace(/,/g, ".");
|
|
140
|
+
const dot = cleaned.indexOf(".");
|
|
141
|
+
if (dot >= 0) {
|
|
142
|
+
const dec = this.effectiveDecimals();
|
|
143
|
+
const intPart = cleaned.slice(0, dot);
|
|
144
|
+
const decPart = cleaned.slice(dot + 1, dot + 1 + dec).replace(/\./g, "");
|
|
145
|
+
cleaned = dec > 0 ? intPart + "." + decPart : intPart;
|
|
146
|
+
}
|
|
147
|
+
const shown = cleaned.replace(".", this.decimalSeparator());
|
|
148
|
+
input.value = shown;
|
|
149
|
+
const newPos = Math.min(pos, shown.length);
|
|
150
|
+
input.setSelectionRange(newPos, newPos);
|
|
151
|
+
this.displayText.set(shown);
|
|
152
|
+
const num = parseFloat(cleaned);
|
|
153
|
+
this.setValue(isNaN(num) ? 0 : num);
|
|
154
|
+
}
|
|
155
|
+
setValue(v) {
|
|
156
|
+
const ctrl = this.control();
|
|
157
|
+
if (ctrl) ctrl.setValue(v, { emitEvent: true });
|
|
158
|
+
else this.value.set(v);
|
|
159
|
+
this.onChange(v);
|
|
160
|
+
}
|
|
161
|
+
roundTo(v) {
|
|
162
|
+
const factor = Math.pow(10, this.effectiveDecimals());
|
|
163
|
+
return Math.round(v * factor) / factor;
|
|
164
|
+
}
|
|
165
|
+
formatNumber(v) {
|
|
166
|
+
if (v == null || isNaN(v)) return "0";
|
|
167
|
+
return formatNumber(v, this.numbersLocale(), this.effectiveDecimals());
|
|
168
|
+
}
|
|
169
|
+
editableNumber(v) {
|
|
170
|
+
if (v == null || isNaN(v)) return "";
|
|
171
|
+
return String(this.roundTo(v)).replace(".", this.decimalSeparator());
|
|
172
|
+
}
|
|
173
|
+
parseEditable(text) {
|
|
174
|
+
return parseFloat(text.replace(/\s/g, "").replace(/,/g, "."));
|
|
175
|
+
}
|
|
176
|
+
currentValue() {
|
|
177
|
+
const ctrl = this.control();
|
|
178
|
+
return ctrl ? ctrl.value : this.value();
|
|
179
|
+
}
|
|
180
|
+
writeValue(value) {
|
|
181
|
+
if (!this.focused()) this.displayText.set(this.formatNumber(value ?? 0));
|
|
182
|
+
}
|
|
183
|
+
registerOnChange(fn) {
|
|
184
|
+
this.onChange = fn;
|
|
185
|
+
}
|
|
186
|
+
registerOnTouched(fn) {
|
|
187
|
+
this.onTouched = fn;
|
|
188
|
+
}
|
|
189
|
+
setDisabledState(isDisabled) {
|
|
190
|
+
this.controlDisabled.set(isDisabled);
|
|
191
|
+
}
|
|
192
|
+
static {
|
|
193
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
194
|
+
minVersion: "12.0.0",
|
|
195
|
+
version: "22.3.2",
|
|
196
|
+
ngImport: i0,
|
|
197
|
+
type: PriceInputComponent,
|
|
198
|
+
deps: [],
|
|
199
|
+
target: i0.ɵɵFactoryTarget.Component
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
static {
|
|
203
|
+
this.ɵcmp = i0.ɵɵngDeclareComponent({
|
|
204
|
+
minVersion: "17.0.0",
|
|
205
|
+
version: "22.3.2",
|
|
206
|
+
type: PriceInputComponent,
|
|
207
|
+
isStandalone: true,
|
|
208
|
+
selector: "shk-price-input",
|
|
209
|
+
inputs: {
|
|
210
|
+
control: {
|
|
211
|
+
classPropertyName: "control",
|
|
212
|
+
publicName: "control",
|
|
213
|
+
isSignal: true,
|
|
214
|
+
isRequired: false,
|
|
215
|
+
transformFunction: null
|
|
216
|
+
},
|
|
217
|
+
value: {
|
|
218
|
+
classPropertyName: "value",
|
|
219
|
+
publicName: "value",
|
|
220
|
+
isSignal: true,
|
|
221
|
+
isRequired: false,
|
|
222
|
+
transformFunction: null
|
|
223
|
+
},
|
|
224
|
+
isPercentage: {
|
|
225
|
+
classPropertyName: "isPercentage",
|
|
226
|
+
publicName: "isPercentage",
|
|
227
|
+
isSignal: true,
|
|
228
|
+
isRequired: false,
|
|
229
|
+
transformFunction: null
|
|
230
|
+
},
|
|
231
|
+
label: {
|
|
232
|
+
classPropertyName: "label",
|
|
233
|
+
publicName: "label",
|
|
234
|
+
isSignal: true,
|
|
235
|
+
isRequired: false,
|
|
236
|
+
transformFunction: null
|
|
237
|
+
},
|
|
238
|
+
inputId: {
|
|
239
|
+
classPropertyName: "inputId",
|
|
240
|
+
publicName: "inputId",
|
|
241
|
+
isSignal: true,
|
|
242
|
+
isRequired: false,
|
|
243
|
+
transformFunction: null
|
|
244
|
+
},
|
|
245
|
+
required: {
|
|
246
|
+
classPropertyName: "required",
|
|
247
|
+
publicName: "required",
|
|
248
|
+
isSignal: true,
|
|
249
|
+
isRequired: false,
|
|
250
|
+
transformFunction: null
|
|
251
|
+
},
|
|
252
|
+
disabled: {
|
|
253
|
+
classPropertyName: "disabled",
|
|
254
|
+
publicName: "disabled",
|
|
255
|
+
isSignal: true,
|
|
256
|
+
isRequired: false,
|
|
257
|
+
transformFunction: null
|
|
258
|
+
},
|
|
259
|
+
min: {
|
|
260
|
+
classPropertyName: "min",
|
|
261
|
+
publicName: "min",
|
|
262
|
+
isSignal: true,
|
|
263
|
+
isRequired: false,
|
|
264
|
+
transformFunction: null
|
|
265
|
+
},
|
|
266
|
+
max: {
|
|
267
|
+
classPropertyName: "max",
|
|
268
|
+
publicName: "max",
|
|
269
|
+
isSignal: true,
|
|
270
|
+
isRequired: false,
|
|
271
|
+
transformFunction: null
|
|
272
|
+
},
|
|
273
|
+
decimals: {
|
|
274
|
+
classPropertyName: "decimals",
|
|
275
|
+
publicName: "decimals",
|
|
276
|
+
isSignal: true,
|
|
277
|
+
isRequired: false,
|
|
278
|
+
transformFunction: null
|
|
279
|
+
},
|
|
280
|
+
currency: {
|
|
281
|
+
classPropertyName: "currency",
|
|
282
|
+
publicName: "currency",
|
|
283
|
+
isSignal: true,
|
|
284
|
+
isRequired: false,
|
|
285
|
+
transformFunction: null
|
|
286
|
+
},
|
|
287
|
+
placeholder: {
|
|
288
|
+
classPropertyName: "placeholder",
|
|
289
|
+
publicName: "placeholder",
|
|
290
|
+
isSignal: true,
|
|
291
|
+
isRequired: false,
|
|
292
|
+
transformFunction: null
|
|
293
|
+
},
|
|
294
|
+
ariaLabel: {
|
|
295
|
+
classPropertyName: "ariaLabel",
|
|
296
|
+
publicName: "ariaLabel",
|
|
297
|
+
isSignal: true,
|
|
298
|
+
isRequired: false,
|
|
299
|
+
transformFunction: null
|
|
300
|
+
},
|
|
301
|
+
preventNegative: {
|
|
302
|
+
classPropertyName: "preventNegative",
|
|
303
|
+
publicName: "preventNegative",
|
|
304
|
+
isSignal: true,
|
|
305
|
+
isRequired: false,
|
|
306
|
+
transformFunction: null
|
|
307
|
+
},
|
|
308
|
+
showError: {
|
|
309
|
+
classPropertyName: "showError",
|
|
310
|
+
publicName: "showError",
|
|
311
|
+
isSignal: true,
|
|
312
|
+
isRequired: false,
|
|
313
|
+
transformFunction: null
|
|
314
|
+
},
|
|
315
|
+
errorMessage: {
|
|
316
|
+
classPropertyName: "errorMessage",
|
|
317
|
+
publicName: "errorMessage",
|
|
318
|
+
isSignal: true,
|
|
319
|
+
isRequired: false,
|
|
320
|
+
transformFunction: null
|
|
321
|
+
}
|
|
322
|
+
},
|
|
323
|
+
outputs: {
|
|
324
|
+
value: "valueChange",
|
|
325
|
+
isPercentage: "isPercentageChange",
|
|
326
|
+
touch: "touch"
|
|
327
|
+
},
|
|
328
|
+
providers: [{
|
|
329
|
+
provide: NG_VALUE_ACCESSOR,
|
|
330
|
+
useExisting: forwardRef(() => PriceInputComponent),
|
|
331
|
+
multi: true
|
|
332
|
+
}],
|
|
333
|
+
ngImport: i0,
|
|
334
|
+
template: "<div>\n @if (label()) {\n <div class=\"text-sm font-medium _shk-text-surface-700 mb-1\">\n {{ label() }}\n @if (required()) {\n <span class=\"text-red-400\">*</span>\n }\n </div>\n }\n <div class=\"flex\">\n <input\n [id]=\"inputId()\"\n type=\"text\"\n inputmode=\"decimal\"\n autocomplete=\"off\"\n [value]=\"displayText()\"\n [placeholder]=\"placeholder()\"\n [attr.aria-label]=\"ariaLabel() || label()\"\n [attr.aria-invalid]=\"hasError() || null\"\n [disabled]=\"isDisabled()\"\n (focus)=\"onFocus($event)\"\n (blur)=\"onBlur()\"\n (keydown)=\"onKeydown($event)\"\n (input)=\"onInput($event)\"\n class=\"shk-control shk-control-addon block w-full px-3 py-2 _shk-text-surface-700 _shk-bg-surface-50 border rounded-l-lg transition-colors placeholder:[color:var(--shk-surface-400)] dark:placeholder:[color:var(--shk-surface-400)] focus:outline-none focus:[background-color:var(--shk-surface-50)] dark:focus:[background-color:var(--shk-surface-100)] focus:ring-1 disabled:[background-color:var(--shk-surface-50)] dark:disabled:[background-color:var(--shk-surface-100)] disabled:cursor-not-allowed sm:text-sm\"\n [ngClass]=\"{\n 'border-red-500 focus:border-red-500 focus:ring-red-500': hasError(),\n '_shk-border dark:[border-color:var(--shk-surface-200)] focus:[border-color:var(--shk-primary-500)] focus:[--tw-ring-color:var(--shk-primary-500)]': !hasError()\n }\"\n />\n <button\n type=\"button\"\n (click)=\"toggleMode()\"\n [disabled]=\"isDisabled()\"\n class=\"px-3 py-2 text-sm font-medium border rounded-r-lg transition-colors shrink-0\"\n [ngClass]=\"{\n '_shk-bg-primary-soft _shk-border-primary-200 _shk-text-primary-700 dark:[background-color:var(--shk-primary-900)] dark:[border-color:var(--shk-primary-700)] dark:[color:var(--shk-primary-300)]': isPercentage(),\n '_shk-bg-white _shk-border _shk-text-surface-500 dark:[background-color:var(--shk-surface-100)] dark:[border-color:var(--shk-surface-200)] dark:[color:var(--shk-surface-400)]': !isPercentage(),\n 'cursor-not-allowed opacity-50': isDisabled()\n }\"\n >\n {{ isPercentage() ? '%' : displaySymbol() }}\n </button>\n </div>\n @if (hasError() && errorText()) {\n <div class=\"text-xs _shk-text-red-500 mt-1\">\n {{ errorText() }}\n </div>\n }\n</div>\n",
|
|
335
|
+
dependencies: [
|
|
336
|
+
{
|
|
337
|
+
kind: "ngmodule",
|
|
338
|
+
type: CommonModule
|
|
339
|
+
},
|
|
340
|
+
{
|
|
341
|
+
kind: "directive",
|
|
342
|
+
type: i1.NgClass,
|
|
343
|
+
selector: "[ngClass]",
|
|
344
|
+
inputs: ["class", "ngClass"]
|
|
345
|
+
},
|
|
346
|
+
{
|
|
347
|
+
kind: "ngmodule",
|
|
348
|
+
type: ReactiveFormsModule
|
|
349
|
+
}
|
|
350
|
+
],
|
|
351
|
+
changeDetection: i0.ChangeDetectionStrategy.OnPush
|
|
352
|
+
});
|
|
353
|
+
}
|
|
354
|
+
};
|
|
355
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
356
|
+
minVersion: "12.0.0",
|
|
357
|
+
version: "22.3.2",
|
|
358
|
+
ngImport: i0,
|
|
359
|
+
type: PriceInputComponent,
|
|
360
|
+
decorators: [{
|
|
361
|
+
type: Component,
|
|
362
|
+
args: [{
|
|
363
|
+
selector: "shk-price-input",
|
|
364
|
+
imports: [CommonModule, ReactiveFormsModule],
|
|
365
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
366
|
+
providers: [{
|
|
367
|
+
provide: NG_VALUE_ACCESSOR,
|
|
368
|
+
useExisting: forwardRef(() => PriceInputComponent),
|
|
369
|
+
multi: true
|
|
370
|
+
}],
|
|
371
|
+
template: "<div>\n @if (label()) {\n <div class=\"text-sm font-medium _shk-text-surface-700 mb-1\">\n {{ label() }}\n @if (required()) {\n <span class=\"text-red-400\">*</span>\n }\n </div>\n }\n <div class=\"flex\">\n <input\n [id]=\"inputId()\"\n type=\"text\"\n inputmode=\"decimal\"\n autocomplete=\"off\"\n [value]=\"displayText()\"\n [placeholder]=\"placeholder()\"\n [attr.aria-label]=\"ariaLabel() || label()\"\n [attr.aria-invalid]=\"hasError() || null\"\n [disabled]=\"isDisabled()\"\n (focus)=\"onFocus($event)\"\n (blur)=\"onBlur()\"\n (keydown)=\"onKeydown($event)\"\n (input)=\"onInput($event)\"\n class=\"shk-control shk-control-addon block w-full px-3 py-2 _shk-text-surface-700 _shk-bg-surface-50 border rounded-l-lg transition-colors placeholder:[color:var(--shk-surface-400)] dark:placeholder:[color:var(--shk-surface-400)] focus:outline-none focus:[background-color:var(--shk-surface-50)] dark:focus:[background-color:var(--shk-surface-100)] focus:ring-1 disabled:[background-color:var(--shk-surface-50)] dark:disabled:[background-color:var(--shk-surface-100)] disabled:cursor-not-allowed sm:text-sm\"\n [ngClass]=\"{\n 'border-red-500 focus:border-red-500 focus:ring-red-500': hasError(),\n '_shk-border dark:[border-color:var(--shk-surface-200)] focus:[border-color:var(--shk-primary-500)] focus:[--tw-ring-color:var(--shk-primary-500)]': !hasError()\n }\"\n />\n <button\n type=\"button\"\n (click)=\"toggleMode()\"\n [disabled]=\"isDisabled()\"\n class=\"px-3 py-2 text-sm font-medium border rounded-r-lg transition-colors shrink-0\"\n [ngClass]=\"{\n '_shk-bg-primary-soft _shk-border-primary-200 _shk-text-primary-700 dark:[background-color:var(--shk-primary-900)] dark:[border-color:var(--shk-primary-700)] dark:[color:var(--shk-primary-300)]': isPercentage(),\n '_shk-bg-white _shk-border _shk-text-surface-500 dark:[background-color:var(--shk-surface-100)] dark:[border-color:var(--shk-surface-200)] dark:[color:var(--shk-surface-400)]': !isPercentage(),\n 'cursor-not-allowed opacity-50': isDisabled()\n }\"\n >\n {{ isPercentage() ? '%' : displaySymbol() }}\n </button>\n </div>\n @if (hasError() && errorText()) {\n <div class=\"text-xs _shk-text-red-500 mt-1\">\n {{ errorText() }}\n </div>\n }\n</div>\n"
|
|
372
|
+
}]
|
|
373
|
+
}],
|
|
374
|
+
ctorParameters: () => [],
|
|
375
|
+
propDecorators: {
|
|
376
|
+
control: [{
|
|
377
|
+
type: i0.Input,
|
|
378
|
+
args: [{
|
|
379
|
+
isSignal: true,
|
|
380
|
+
alias: "control",
|
|
381
|
+
required: false
|
|
382
|
+
}]
|
|
383
|
+
}],
|
|
384
|
+
value: [{
|
|
385
|
+
type: i0.Input,
|
|
386
|
+
args: [{
|
|
387
|
+
isSignal: true,
|
|
388
|
+
alias: "value",
|
|
389
|
+
required: false
|
|
390
|
+
}]
|
|
391
|
+
}, {
|
|
392
|
+
type: i0.Output,
|
|
393
|
+
args: ["valueChange"]
|
|
394
|
+
}],
|
|
395
|
+
isPercentage: [{
|
|
396
|
+
type: i0.Input,
|
|
397
|
+
args: [{
|
|
398
|
+
isSignal: true,
|
|
399
|
+
alias: "isPercentage",
|
|
400
|
+
required: false
|
|
401
|
+
}]
|
|
402
|
+
}, {
|
|
403
|
+
type: i0.Output,
|
|
404
|
+
args: ["isPercentageChange"]
|
|
405
|
+
}],
|
|
406
|
+
label: [{
|
|
407
|
+
type: i0.Input,
|
|
408
|
+
args: [{
|
|
409
|
+
isSignal: true,
|
|
410
|
+
alias: "label",
|
|
411
|
+
required: false
|
|
412
|
+
}]
|
|
413
|
+
}],
|
|
414
|
+
inputId: [{
|
|
415
|
+
type: i0.Input,
|
|
416
|
+
args: [{
|
|
417
|
+
isSignal: true,
|
|
418
|
+
alias: "inputId",
|
|
419
|
+
required: false
|
|
420
|
+
}]
|
|
421
|
+
}],
|
|
422
|
+
required: [{
|
|
423
|
+
type: i0.Input,
|
|
424
|
+
args: [{
|
|
425
|
+
isSignal: true,
|
|
426
|
+
alias: "required",
|
|
427
|
+
required: false
|
|
428
|
+
}]
|
|
429
|
+
}],
|
|
430
|
+
disabled: [{
|
|
431
|
+
type: i0.Input,
|
|
432
|
+
args: [{
|
|
433
|
+
isSignal: true,
|
|
434
|
+
alias: "disabled",
|
|
435
|
+
required: false
|
|
436
|
+
}]
|
|
437
|
+
}],
|
|
438
|
+
min: [{
|
|
439
|
+
type: i0.Input,
|
|
440
|
+
args: [{
|
|
441
|
+
isSignal: true,
|
|
442
|
+
alias: "min",
|
|
443
|
+
required: false
|
|
444
|
+
}]
|
|
445
|
+
}],
|
|
446
|
+
max: [{
|
|
447
|
+
type: i0.Input,
|
|
448
|
+
args: [{
|
|
449
|
+
isSignal: true,
|
|
450
|
+
alias: "max",
|
|
451
|
+
required: false
|
|
452
|
+
}]
|
|
453
|
+
}],
|
|
454
|
+
decimals: [{
|
|
455
|
+
type: i0.Input,
|
|
456
|
+
args: [{
|
|
457
|
+
isSignal: true,
|
|
458
|
+
alias: "decimals",
|
|
459
|
+
required: false
|
|
460
|
+
}]
|
|
461
|
+
}],
|
|
462
|
+
currency: [{
|
|
463
|
+
type: i0.Input,
|
|
464
|
+
args: [{
|
|
465
|
+
isSignal: true,
|
|
466
|
+
alias: "currency",
|
|
467
|
+
required: false
|
|
468
|
+
}]
|
|
469
|
+
}],
|
|
470
|
+
placeholder: [{
|
|
471
|
+
type: i0.Input,
|
|
472
|
+
args: [{
|
|
473
|
+
isSignal: true,
|
|
474
|
+
alias: "placeholder",
|
|
475
|
+
required: false
|
|
476
|
+
}]
|
|
477
|
+
}],
|
|
478
|
+
ariaLabel: [{
|
|
479
|
+
type: i0.Input,
|
|
480
|
+
args: [{
|
|
481
|
+
isSignal: true,
|
|
482
|
+
alias: "ariaLabel",
|
|
483
|
+
required: false
|
|
484
|
+
}]
|
|
485
|
+
}],
|
|
486
|
+
preventNegative: [{
|
|
487
|
+
type: i0.Input,
|
|
488
|
+
args: [{
|
|
489
|
+
isSignal: true,
|
|
490
|
+
alias: "preventNegative",
|
|
491
|
+
required: false
|
|
492
|
+
}]
|
|
493
|
+
}],
|
|
494
|
+
showError: [{
|
|
495
|
+
type: i0.Input,
|
|
496
|
+
args: [{
|
|
497
|
+
isSignal: true,
|
|
498
|
+
alias: "showError",
|
|
499
|
+
required: false
|
|
500
|
+
}]
|
|
501
|
+
}],
|
|
502
|
+
errorMessage: [{
|
|
503
|
+
type: i0.Input,
|
|
504
|
+
args: [{
|
|
505
|
+
isSignal: true,
|
|
506
|
+
alias: "errorMessage",
|
|
507
|
+
required: false
|
|
508
|
+
}]
|
|
509
|
+
}],
|
|
510
|
+
touch: [{
|
|
511
|
+
type: i0.Output,
|
|
512
|
+
args: ["touch"]
|
|
513
|
+
}]
|
|
514
|
+
}
|
|
515
|
+
});
|
|
327
516
|
export { PriceInputComponent };
|
|
328
|
-
|
|
517
|
+
|
|
518
|
+
//# sourceMappingURL=shirkasoft-ui-components-price-input.mjs.map
|