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.
Files changed (92) hide show
  1. package/README.md +4 -8
  2. package/fesm2022/shirkasoft-ui-components-breadcrumb.mjs +189 -100
  3. package/fesm2022/shirkasoft-ui-components-breadcrumb.mjs.map +1 -1
  4. package/fesm2022/shirkasoft-ui-components-button.mjs +363 -69
  5. package/fesm2022/shirkasoft-ui-components-button.mjs.map +1 -1
  6. package/fesm2022/shirkasoft-ui-components-chart.mjs +206 -142
  7. package/fesm2022/shirkasoft-ui-components-chart.mjs.map +1 -1
  8. package/fesm2022/shirkasoft-ui-components-config.mjs +905 -843
  9. package/fesm2022/shirkasoft-ui-components-config.mjs.map +1 -1
  10. package/fesm2022/shirkasoft-ui-components-confirm-dialog.mjs +307 -142
  11. package/fesm2022/shirkasoft-ui-components-confirm-dialog.mjs.map +1 -1
  12. package/fesm2022/shirkasoft-ui-components-date-picker.mjs +1624 -1440
  13. package/fesm2022/shirkasoft-ui-components-date-picker.mjs.map +1 -1
  14. package/fesm2022/shirkasoft-ui-components-fieldset.mjs +347 -92
  15. package/fesm2022/shirkasoft-ui-components-fieldset.mjs.map +1 -1
  16. package/fesm2022/shirkasoft-ui-components-file-upload.mjs +484 -300
  17. package/fesm2022/shirkasoft-ui-components-file-upload.mjs.map +1 -1
  18. package/fesm2022/shirkasoft-ui-components-icons.mjs +1028 -533
  19. package/fesm2022/shirkasoft-ui-components-icons.mjs.map +1 -1
  20. package/fesm2022/shirkasoft-ui-components-knob.mjs +389 -201
  21. package/fesm2022/shirkasoft-ui-components-knob.mjs.map +1 -1
  22. package/fesm2022/shirkasoft-ui-components-loading.mjs +505 -128
  23. package/fesm2022/shirkasoft-ui-components-loading.mjs.map +1 -1
  24. package/fesm2022/shirkasoft-ui-components-modal.mjs +311 -314
  25. package/fesm2022/shirkasoft-ui-components-modal.mjs.map +1 -1
  26. package/fesm2022/shirkasoft-ui-components-notification.mjs +188 -142
  27. package/fesm2022/shirkasoft-ui-components-notification.mjs.map +1 -1
  28. package/fesm2022/shirkasoft-ui-components-price-input.mjs +517 -327
  29. package/fesm2022/shirkasoft-ui-components-price-input.mjs.map +1 -1
  30. package/fesm2022/shirkasoft-ui-components-rail-sidebar.mjs +669 -289
  31. package/fesm2022/shirkasoft-ui-components-rail-sidebar.mjs.map +1 -1
  32. package/fesm2022/shirkasoft-ui-components-select.mjs +1014 -819
  33. package/fesm2022/shirkasoft-ui-components-select.mjs.map +1 -1
  34. package/fesm2022/shirkasoft-ui-components-sidebar.mjs +508 -184
  35. package/fesm2022/shirkasoft-ui-components-sidebar.mjs.map +1 -1
  36. package/fesm2022/shirkasoft-ui-components-skeleton.mjs +197 -57
  37. package/fesm2022/shirkasoft-ui-components-skeleton.mjs.map +1 -1
  38. package/fesm2022/shirkasoft-ui-components-table.mjs +1916 -1698
  39. package/fesm2022/shirkasoft-ui-components-table.mjs.map +1 -1
  40. package/fesm2022/shirkasoft-ui-components-tabs.mjs +419 -175
  41. package/fesm2022/shirkasoft-ui-components-tabs.mjs.map +1 -1
  42. package/fesm2022/shirkasoft-ui-components-tag.mjs +175 -49
  43. package/fesm2022/shirkasoft-ui-components-tag.mjs.map +1 -1
  44. package/fesm2022/shirkasoft-ui-components-text-field.mjs +687 -402
  45. package/fesm2022/shirkasoft-ui-components-text-field.mjs.map +1 -1
  46. package/fesm2022/shirkasoft-ui-components-theme-picker.mjs +310 -124
  47. package/fesm2022/shirkasoft-ui-components-theme-picker.mjs.map +1 -1
  48. package/fesm2022/shirkasoft-ui-components-theme.mjs +141 -174
  49. package/fesm2022/shirkasoft-ui-components-theme.mjs.map +1 -1
  50. package/fesm2022/shirkasoft-ui-components-timeline.mjs +791 -203
  51. package/fesm2022/shirkasoft-ui-components-timeline.mjs.map +1 -1
  52. package/fesm2022/shirkasoft-ui-components-toggle.mjs +179 -109
  53. package/fesm2022/shirkasoft-ui-components-toggle.mjs.map +1 -1
  54. package/fesm2022/shirkasoft-ui-components-tooltip.mjs +244 -180
  55. package/fesm2022/shirkasoft-ui-components-tooltip.mjs.map +1 -1
  56. package/fesm2022/shirkasoft-ui-components-utils.mjs +95 -134
  57. package/fesm2022/shirkasoft-ui-components-utils.mjs.map +1 -1
  58. package/fesm2022/shirkasoft-ui-components-wizard.mjs +673 -165
  59. package/fesm2022/shirkasoft-ui-components-wizard.mjs.map +1 -1
  60. package/fesm2022/shirkasoft-ui-components.mjs +0 -9
  61. package/package.json +5 -5
  62. package/types/shirkasoft-ui-components-breadcrumb.d.ts +59 -44
  63. package/types/shirkasoft-ui-components-button.d.ts +142 -49
  64. package/types/shirkasoft-ui-components-chart.d.ts +59 -44
  65. package/types/shirkasoft-ui-components-config.d.ts +193 -204
  66. package/types/shirkasoft-ui-components-confirm-dialog.d.ts +107 -66
  67. package/types/shirkasoft-ui-components-date-picker.d.ts +527 -398
  68. package/types/shirkasoft-ui-components-fieldset.d.ts +135 -60
  69. package/types/shirkasoft-ui-components-file-upload.d.ts +176 -112
  70. package/types/shirkasoft-ui-components-icons.d.ts +1302 -1294
  71. package/types/shirkasoft-ui-components-knob.d.ts +144 -78
  72. package/types/shirkasoft-ui-components-loading.d.ts +155 -64
  73. package/types/shirkasoft-ui-components-modal.d.ts +134 -136
  74. package/types/shirkasoft-ui-components-notification.d.ts +63 -59
  75. package/types/shirkasoft-ui-components-price-input.d.ts +198 -113
  76. package/types/shirkasoft-ui-components-rail-sidebar.d.ts +262 -142
  77. package/types/shirkasoft-ui-components-select.d.ts +301 -196
  78. package/types/shirkasoft-ui-components-sidebar.d.ts +198 -93
  79. package/types/shirkasoft-ui-components-skeleton.d.ts +68 -27
  80. package/types/shirkasoft-ui-components-table.d.ts +849 -660
  81. package/types/shirkasoft-ui-components-tabs.d.ts +102 -61
  82. package/types/shirkasoft-ui-components-tag.d.ts +54 -23
  83. package/types/shirkasoft-ui-components-text-field.d.ts +231 -127
  84. package/types/shirkasoft-ui-components-theme-picker.d.ts +92 -58
  85. package/types/shirkasoft-ui-components-theme.d.ts +56 -64
  86. package/types/shirkasoft-ui-components-timeline.d.ts +325 -150
  87. package/types/shirkasoft-ui-components-toggle.d.ts +73 -49
  88. package/types/shirkasoft-ui-components-tooltip.d.ts +64 -43
  89. package/types/shirkasoft-ui-components-utils.d.ts +15 -16
  90. package/types/shirkasoft-ui-components-wizard.d.ts +236 -87
  91. package/types/shirkasoft-ui-components.d.ts +1 -2
  92. package/fesm2022/shirkasoft-ui-components.mjs.map +0 -1
@@ -1,328 +1,518 @@
1
- import * as i0 from '@angular/core';
2
- import { input, model, output, inject, DestroyRef, computed, signal, effect, forwardRef, ChangeDetectionStrategy, Component } from '@angular/core';
3
- import * as i1 from '@angular/common';
4
- import { CommonModule } from '@angular/common';
5
- import { ReactiveFormsModule, NG_VALUE_ACCESSOR } from '@angular/forms';
6
- import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
7
- import { TranslocoService } from '@jsverse/transloco';
8
- import { ShkConfigService, currencyDecimals, numberSeparators, currencySymbol, formatNumber } from 'shirkasoft-ui-components/config';
9
-
10
- /**
11
- * Shirkasoft UI Components.
12
- * Authors: Roberto Valladares Martin (Ansem13), Julio César García García (Sanjuli14).
13
- * Belongs to Shirkasoft.
14
- */
15
- /**
16
- * Currency/percentage numeric input with reactive forms support.
17
- *
18
- * Binding modes (highest precedence first):
19
- * - `control`: a FormControl (or use it inside a form with `formControlName`).
20
- * - `value`/`valueChange` or `[(value)]`: two-way model signals.
21
- *
22
- * Text-based input (`type="text"` + `inputmode="decimal"`) with decimal
23
- * precision control, min/max clamping on blur and thousands formatting.
24
- */
25
- class PriceInputComponent {
26
- constructor() {
27
- /** Reactive control. When provided it takes precedence over `value`/`valueChange`. */
28
- this.control = input(undefined, ...(ngDevMode ? [{ debugName: "control" }] : /* istanbul ignore next */ []));
29
- /** Numeric value (two-way), used when no `control` is bound. */
30
- this.value = model(0, ...(ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []));
31
- /** Whether the input works as a percentage (two-way). */
32
- this.isPercentage = model(false, ...(ngDevMode ? [{ debugName: "isPercentage" }] : /* istanbul ignore next */ []));
33
- /** Label displayed above the field. */
34
- this.label = input('', ...(ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []));
35
- /** id attribute applied to the native input. */
36
- this.inputId = input('', ...(ngDevMode ? [{ debugName: "inputId" }] : /* istanbul ignore next */ []));
37
- /** Marks the field as required. */
38
- this.required = input(false, ...(ngDevMode ? [{ debugName: "required" }] : /* istanbul ignore next */ []));
39
- /** Disables the input. */
40
- this.disabled = input(false, ...(ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []));
41
- /** Minimum allowed value (clamped on blur). */
42
- this.min = input(0, ...(ngDevMode ? [{ debugName: "min" }] : /* istanbul ignore next */ []));
43
- /** Maximum allowed value (clamped on blur). */
44
- this.max = input(Infinity, ...(ngDevMode ? [{ debugName: "max" }] : /* istanbul ignore next */ []));
45
- /**
46
- * Maximum number of decimal places (0 = integer). Unset = the `numbers.decimals`
47
- * option, else the digits of the `numbers.currency` option (2 for USD).
48
- */
49
- this.decimals = input(undefined, ...(ngDevMode ? [{ debugName: "decimals" }] : /* istanbul ignore next */ []));
50
- /**
51
- * Symbol shown in the mode toggle button when not a percentage. Empty = the
52
- * `numbers.currencySymbol` option, else the symbol of `numbers.currency` ('$').
53
- */
54
- this.currency = input('', ...(ngDevMode ? [{ debugName: "currency" }] : /* istanbul ignore next */ []));
55
- /** Placeholder text of the native input. */
56
- this.placeholder = input('', ...(ngDevMode ? [{ debugName: "placeholder" }] : /* istanbul ignore next */ []));
57
- /** Accessible label; falls back to `label`. */
58
- this.ariaLabel = input('', ...(ngDevMode ? [{ debugName: "ariaLabel" }] : /* istanbul ignore next */ []));
59
- /** Blocks the minus sign from being typed. */
60
- this.preventNegative = input(false, ...(ngDevMode ? [{ debugName: "preventNegative" }] : /* istanbul ignore next */ []));
61
- /** Shows the error styling on the field. */
62
- this.showError = input(false, ...(ngDevMode ? [{ debugName: "showError" }] : /* istanbul ignore next */ []));
63
- /** Message rendered when the field is in error state. */
64
- this.errorMessage = input('', ...(ngDevMode ? [{ debugName: "errorMessage" }] : /* istanbul ignore next */ []));
65
- /** Emitted on blur so Signal Forms can mark the field as touched. */
66
- this.touch = output();
67
- this.destroyRef = inject(DestroyRef);
68
- this.transloco = inject(TranslocoService);
69
- /** Library-wide options: currency, decimals and number separators. */
70
- this.config = inject(ShkConfigService);
71
- /** Decimal places actually used. */
72
- this.effectiveDecimals = computed(() => Math.max(0, this.decimals() ??
73
- this.config.get('numbers.decimals')() ??
74
- currencyDecimals(this.config.get('numbers.currency')())), ...(ngDevMode ? [{ debugName: "effectiveDecimals" }] : /* istanbul ignore next */ []));
75
- /** Locale of the grouping/decimal separators. */
76
- this.numbersLocale = computed(() => this.config.get('numbers.locale')(), ...(ngDevMode ? [{ debugName: "numbersLocale" }] : /* istanbul ignore next */ []));
77
- /** Decimal separator of the locale (`.` or `,`), used while editing. */
78
- this.decimalSeparator = computed(() => numberSeparators(this.numbersLocale()).decimal, ...(ngDevMode ? [{ debugName: "decimalSeparator" }] : /* istanbul ignore next */ []));
79
- /** Symbol shown in the toggle: input, `numbers.currencySymbol`, or the currency's symbol. */
80
- this.displaySymbol = computed(() => this.currency() ||
81
- this.config.get('numbers.currencySymbol')() ||
82
- currencySymbol(this.config.get('numbers.currency')(), this.numbersLocale()), ...(ngDevMode ? [{ debugName: "displaySymbol" }] : /* istanbul ignore next */ []));
83
- /** Text currently shown in the input (raw while focused, formatted on blur). */
84
- this.displayText = signal('', ...(ngDevMode ? [{ debugName: "displayText" }] : /* istanbul ignore next */ []));
85
- /** Whether the native input currently has focus. */
86
- this.focused = signal(false, ...(ngDevMode ? [{ debugName: "focused" }] : /* istanbul ignore next */ []));
87
- /** Disabled state coming from the reactive control. */
88
- this.controlDisabled = signal(false, ...(ngDevMode ? [{ debugName: "controlDisabled" }] : /* istanbul ignore next */ []));
89
- /** Prevents re-subscribing to the same form control. */
90
- this.ctrlSubscribed = false;
91
- /** Bumped on control status changes / blur so error computeds refresh. */
92
- this.statusTick = signal(0, ...(ngDevMode ? [{ debugName: "statusTick" }] : /* istanbul ignore next */ []));
93
- /**
94
- * Whether the error state is shown: forced with `showError`, or when the
95
- * bound `control` is invalid and has been touched or modified.
96
- */
97
- this.hasError = computed(() => {
98
- this.statusTick();
99
- if (this.showError())
100
- return true;
101
- const ctrl = this.control();
102
- return !!ctrl && ctrl.invalid && (ctrl.touched || ctrl.dirty);
103
- }, ...(ngDevMode ? [{ debugName: "hasError" }] : /* istanbul ignore next */ []));
104
- /** Message shown under the field: `errorMessage` or one derived from the control errors. */
105
- this.errorText = computed(() => {
106
- this.statusTick();
107
- const custom = this.errorMessage();
108
- if (custom)
109
- return custom;
110
- const errors = this.control()?.errors;
111
- if (!errors)
112
- return '';
113
- if (errors['required'])
114
- return this.transloco.translate('validation.required');
115
- return this.transloco.translate('validation.invalid');
116
- }, ...(ngDevMode ? [{ debugName: "errorText" }] : /* istanbul ignore next */ []));
117
- /** Effective disabled state combining the input and the form binding. */
118
- this.isDisabled = computed(() => this.disabled() || this.controlDisabled(), ...(ngDevMode ? [{ debugName: "isDisabled" }] : /* istanbul ignore next */ []));
119
- /** Callbacks used by the ControlValueAccessor contract. */
120
- this.onChange = () => { };
121
- this.onTouched = () => { };
122
- // Subscribe once to the bound control for change/status tracking.
123
- effect(() => {
124
- const ctrl = this.control();
125
- if (!ctrl || this.ctrlSubscribed)
126
- return;
127
- this.ctrlSubscribed = true;
128
- this.controlDisabled.set(ctrl.disabled);
129
- ctrl.valueChanges.pipe(takeUntilDestroyed(this.destroyRef)).subscribe((v) => {
130
- if (!this.focused()) {
131
- this.displayText.set(this.formatNumber(v ?? 0));
132
- }
133
- });
134
- ctrl.statusChanges.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(() => {
135
- this.controlDisabled.set(ctrl.disabled);
136
- this.statusTick.update((v) => v + 1);
137
- });
138
- // Also refresh on touched/pristine changes (e.g. markAllAsTouched()).
139
- ctrl.events.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(() => {
140
- this.statusTick.update((v) => v + 1);
141
- });
142
- });
143
- // Reflect the effective value into the display (unless the user is typing).
144
- effect(() => {
145
- const ctrl = this.control();
146
- const v = ctrl ? ctrl.value : this.value();
147
- if (!this.focused()) {
148
- this.displayText.set(this.formatNumber(v ?? 0));
149
- }
150
- });
151
- }
152
- /** Toggles between amount and percentage modes (unless disabled). */
153
- toggleMode() {
154
- if (this.isDisabled())
155
- return;
156
- this.isPercentage.update((v) => !v);
157
- }
158
- /**
159
- * Switches to the editable form (no grouping, locale decimal separator) and
160
- * selects it so the user can type over it or edit in the middle safely.
161
- */
162
- onFocus(event) {
163
- const input = event.target;
164
- this.focused.set(true);
165
- this.displayText.set(this.editableNumber(this.currentValue()));
166
- // Select once the new text is rendered.
167
- setTimeout(() => {
168
- if (this.focused())
169
- input.select();
170
- });
171
- }
172
- /** Clamps, rounds and formats the value when the field loses focus. */
173
- onBlur() {
174
- this.focused.set(false);
175
- this.onTouched();
176
- this.touch.emit();
177
- let v = this.parseEditable(this.displayText());
178
- if (isNaN(v))
179
- v = 0;
180
- const min = this.min() ?? 0;
181
- const max = this.max() ?? Infinity;
182
- if (isFinite(min) && v < min)
183
- v = min;
184
- if (isFinite(max) && v > max)
185
- v = max;
186
- v = this.roundTo(v);
187
- this.setValue(v);
188
- this.displayText.set(this.formatNumber(v));
189
- this.control()?.markAsTouched();
190
- this.statusTick.update((n) => n + 1);
191
- }
192
- /** Blocks characters that would break the numeric format. */
193
- onKeydown(event) {
194
- const allowed = [
195
- 'Backspace',
196
- 'Tab',
197
- 'End',
198
- 'Home',
199
- 'ArrowLeft',
200
- 'ArrowRight',
201
- 'Delete',
202
- 'Enter',
203
- 'Escape',
204
- ];
205
- if (allowed.includes(event.key))
206
- return;
207
- if (/^\d$/.test(event.key))
208
- return;
209
- if (event.key === '.' || event.key === ',') {
210
- const input = event.target;
211
- if (input.value.includes('.') || input.value.includes(','))
212
- event.preventDefault();
213
- return;
214
- }
215
- if (event.key === '-') {
216
- const input = event.target;
217
- if (this.preventNegative() || (this.min() ?? 0) >= 0) {
218
- event.preventDefault();
219
- }
220
- else if (input.value.includes('-')) {
221
- event.preventDefault();
222
- }
223
- return;
224
- }
225
- event.preventDefault();
226
- }
227
- /** Sanitizes the raw input (digits + one separator + optional sign) and writes the value once. */
228
- onInput(event) {
229
- const input = event.target;
230
- const pos = input.selectionStart ?? input.value.length;
231
- let cleaned = input.value.replace(/[^0-9.,-]/g, '');
232
- if (this.preventNegative() || (this.min() ?? 0) >= 0)
233
- cleaned = cleaned.replace(/-/g, '');
234
- // Either `.` or `,` is accepted as the decimal separator while typing.
235
- cleaned = cleaned.replace(/,/g, '.');
236
- const dot = cleaned.indexOf('.');
237
- if (dot >= 0) {
238
- const dec = this.effectiveDecimals();
239
- const intPart = cleaned.slice(0, dot);
240
- const decPart = cleaned.slice(dot + 1, dot + 1 + dec).replace(/\./g, '');
241
- cleaned = dec > 0 ? intPart + '.' + decPart : intPart;
242
- }
243
- // Show the locale's decimal separator; keep `.` for parsing.
244
- const shown = cleaned.replace('.', this.decimalSeparator());
245
- input.value = shown;
246
- const newPos = Math.min(pos, shown.length);
247
- input.setSelectionRange(newPos, newPos);
248
- this.displayText.set(shown);
249
- const num = parseFloat(cleaned);
250
- this.setValue(isNaN(num) ? 0 : num);
251
- }
252
- /** Writes the value to the effective binding source. */
253
- setValue(v) {
254
- const ctrl = this.control();
255
- if (ctrl) {
256
- ctrl.setValue(v, { emitEvent: true });
257
- }
258
- else {
259
- this.value.set(v);
260
- }
261
- this.onChange(v);
262
- }
263
- roundTo(v) {
264
- const factor = Math.pow(10, this.effectiveDecimals());
265
- return Math.round(v * factor) / factor;
266
- }
267
- /** Formats a number with the locale's separators and up to `decimals` places. */
268
- formatNumber(v) {
269
- if (v == null || isNaN(v))
270
- return '0';
271
- return formatNumber(v, this.numbersLocale(), this.effectiveDecimals());
272
- }
273
- /** Number as edited: no grouping, locale decimal separator ("1234,5" for es-ES). */
274
- editableNumber(v) {
275
- if (v == null || isNaN(v))
276
- return '';
277
- return String(this.roundTo(v)).replace('.', this.decimalSeparator());
278
- }
279
- /** Parses the editable text back to a number (either separator is accepted). */
280
- parseEditable(text) {
281
- return parseFloat(text.replace(/\s/g, '').replace(/,/g, '.'));
282
- }
283
- /** Value of the effective binding source (control or `value`). */
284
- currentValue() {
285
- const ctrl = this.control();
286
- return ctrl ? ctrl.value : this.value();
287
- }
288
- // ── ControlValueAccessor ───────────────────────────────────────────────────
289
- writeValue(value) {
290
- if (!this.focused()) {
291
- this.displayText.set(this.formatNumber(value ?? 0));
292
- }
293
- }
294
- registerOnChange(fn) {
295
- this.onChange = fn;
296
- }
297
- registerOnTouched(fn) {
298
- this.onTouched = fn;
299
- }
300
- setDisabledState(isDisabled) {
301
- this.controlDisabled.set(isDisabled);
302
- }
303
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.27", ngImport: i0, type: PriceInputComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
304
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.27", type: PriceInputComponent, isStandalone: true, selector: "shk-price-input", inputs: { control: { classPropertyName: "control", publicName: "control", isSignal: true, isRequired: false, transformFunction: null }, value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null }, isPercentage: { classPropertyName: "isPercentage", publicName: "isPercentage", isSignal: true, isRequired: false, transformFunction: null }, label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, inputId: { classPropertyName: "inputId", publicName: "inputId", isSignal: true, isRequired: false, transformFunction: null }, required: { classPropertyName: "required", publicName: "required", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, min: { classPropertyName: "min", publicName: "min", isSignal: true, isRequired: false, transformFunction: null }, max: { classPropertyName: "max", publicName: "max", isSignal: true, isRequired: false, transformFunction: null }, decimals: { classPropertyName: "decimals", publicName: "decimals", isSignal: true, isRequired: false, transformFunction: null }, currency: { classPropertyName: "currency", publicName: "currency", isSignal: true, isRequired: false, transformFunction: null }, placeholder: { classPropertyName: "placeholder", publicName: "placeholder", isSignal: true, isRequired: false, transformFunction: null }, ariaLabel: { classPropertyName: "ariaLabel", publicName: "ariaLabel", isSignal: true, isRequired: false, transformFunction: null }, preventNegative: { classPropertyName: "preventNegative", publicName: "preventNegative", isSignal: true, isRequired: false, transformFunction: null }, showError: { classPropertyName: "showError", publicName: "showError", isSignal: true, isRequired: false, transformFunction: null }, errorMessage: { classPropertyName: "errorMessage", publicName: "errorMessage", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { value: "valueChange", isPercentage: "isPercentageChange", touch: "touch" }, providers: [
305
- {
306
- provide: NG_VALUE_ACCESSOR,
307
- useExisting: forwardRef(() => PriceInputComponent),
308
- multi: true,
309
- },
310
- ], ngImport: i0, 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", dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "ngmodule", type: ReactiveFormsModule }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
311
- }
312
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.27", ngImport: i0, type: PriceInputComponent, decorators: [{
313
- type: Component,
314
- args: [{ selector: 'shk-price-input', imports: [CommonModule, ReactiveFormsModule], changeDetection: ChangeDetectionStrategy.OnPush, providers: [
315
- {
316
- provide: NG_VALUE_ACCESSOR,
317
- useExisting: forwardRef(() => PriceInputComponent),
318
- multi: true,
319
- },
320
- ], 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" }]
321
- }], ctorParameters: () => [], propDecorators: { control: [{ type: i0.Input, args: [{ isSignal: true, alias: "control", required: false }] }], value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: false }] }, { type: i0.Output, args: ["valueChange"] }], isPercentage: [{ type: i0.Input, args: [{ isSignal: true, alias: "isPercentage", required: false }] }, { type: i0.Output, args: ["isPercentageChange"] }], label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: false }] }], inputId: [{ type: i0.Input, args: [{ isSignal: true, alias: "inputId", required: false }] }], required: [{ type: i0.Input, args: [{ isSignal: true, alias: "required", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], min: [{ type: i0.Input, args: [{ isSignal: true, alias: "min", required: false }] }], max: [{ type: i0.Input, args: [{ isSignal: true, alias: "max", required: false }] }], decimals: [{ type: i0.Input, args: [{ isSignal: true, alias: "decimals", required: false }] }], currency: [{ type: i0.Input, args: [{ isSignal: true, alias: "currency", required: false }] }], placeholder: [{ type: i0.Input, args: [{ isSignal: true, alias: "placeholder", required: false }] }], ariaLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "ariaLabel", required: false }] }], preventNegative: [{ type: i0.Input, args: [{ isSignal: true, alias: "preventNegative", required: false }] }], showError: [{ type: i0.Input, args: [{ isSignal: true, alias: "showError", required: false }] }], errorMessage: [{ type: i0.Input, args: [{ isSignal: true, alias: "errorMessage", required: false }] }], touch: [{ type: i0.Output, args: ["touch"] }] } });
322
-
323
- /**
324
- * Generated bundle index. Do not edit.
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
- //# sourceMappingURL=shirkasoft-ui-components-price-input.mjs.map
517
+
518
+ //# sourceMappingURL=shirkasoft-ui-components-price-input.mjs.map