shirkasoft-ui-components 2.0.0 → 2.0.1
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 +8 -1
- package/fesm2022/shirkasoft-ui-components-date-picker.mjs +79 -6
- package/fesm2022/shirkasoft-ui-components-date-picker.mjs.map +1 -1
- package/fesm2022/shirkasoft-ui-components-file-upload.mjs +74 -3
- package/fesm2022/shirkasoft-ui-components-file-upload.mjs.map +1 -1
- package/fesm2022/shirkasoft-ui-components-price-input.mjs +70 -2
- package/fesm2022/shirkasoft-ui-components-price-input.mjs.map +1 -1
- package/fesm2022/shirkasoft-ui-components-select.mjs +76 -14
- package/fesm2022/shirkasoft-ui-components-select.mjs.map +1 -1
- package/fesm2022/shirkasoft-ui-components-text-field.mjs +80 -18
- package/fesm2022/shirkasoft-ui-components-text-field.mjs.map +1 -1
- package/fesm2022/shirkasoft-ui-components-utils.mjs +36 -1
- package/fesm2022/shirkasoft-ui-components-utils.mjs.map +1 -1
- package/package.json +1 -1
- package/types/shirkasoft-ui-components-date-picker.d.ts +35 -1
- package/types/shirkasoft-ui-components-file-upload.d.ts +35 -1
- package/types/shirkasoft-ui-components-price-input.d.ts +36 -2
- package/types/shirkasoft-ui-components-select.d.ts +36 -2
- package/types/shirkasoft-ui-components-text-field.d.ts +36 -4
- package/types/shirkasoft-ui-components-utils.d.ts +34 -1
package/README.md
CHANGED
|
@@ -1566,13 +1566,20 @@ Both lines get the same features and fixes: land a change on one branch and
|
|
|
1566
1566
|
The scripts read the current branch and refuse to cross lines:
|
|
1567
1567
|
|
|
1568
1568
|
```bash
|
|
1569
|
-
pnpm version:patch # 2.0.0 → 2.0.1 on main, 1.
|
|
1569
|
+
pnpm version:patch # 2.0.0 → 2.0.1 on main, 1.4.0 → 1.4.1 on 1.x (commit + git tag)
|
|
1570
1570
|
pnpm version:minor # 2.0.0 → 2.1.0
|
|
1571
1571
|
git push origin <branch> --follow-tags
|
|
1572
1572
|
```
|
|
1573
1573
|
|
|
1574
1574
|
There is no `version:major`: a new Angular major gets a new branch and line.
|
|
1575
1575
|
|
|
1576
|
+
> **1.x numbering fix.** After `1.3.15`, versions `1.13.16`–`1.13.18` and
|
|
1577
|
+
> `1.14.0` were published by mistake (they should have been `1.3.x`/`1.4.0`).
|
|
1578
|
+
> They are deprecated and the 1.x line continues at **`1.4.0`**. Because npm
|
|
1579
|
+
> orders `1.4.0` below `1.13.x`, apps whose `package.json` has `^1.13.x` or
|
|
1580
|
+
> `^1.14.0` will not receive new 1.x releases: change the dependency to
|
|
1581
|
+
> `shirkasoft-ui-components@ng21` (or `^1.4.0`).
|
|
1582
|
+
|
|
1576
1583
|
### Performance
|
|
1577
1584
|
|
|
1578
1585
|
Bundle sizes, the before/after comparison and the measurement methodology live
|
|
@@ -5,7 +5,7 @@ import { ChangeDetectionStrategy, ChangeDetectorRef, Component, DestroyRef, Elem
|
|
|
5
5
|
import { NG_VALUE_ACCESSOR, ReactiveFormsModule } from "@angular/forms";
|
|
6
6
|
import { takeUntilDestroyed } from "@angular/core/rxjs-interop";
|
|
7
7
|
import { TranslocoService } from "@jsverse/transloco";
|
|
8
|
-
import { PortalDirective } from "shirkasoft-ui-components/utils";
|
|
8
|
+
import { PortalDirective, errorMessagesFromMap, signalErrorsToMap } from "shirkasoft-ui-components/utils";
|
|
9
9
|
import { ShkConfigService, formatDate, formatDateStyle, resolveDateFormat, typedDateLayout } from "shirkasoft-ui-components/config";
|
|
10
10
|
var DatePickerComponent = class DatePickerComponent {
|
|
11
11
|
get _value() {
|
|
@@ -28,6 +28,10 @@ var DatePickerComponent = class DatePickerComponent {
|
|
|
28
28
|
this.controlName = input("", ...ngDevMode ? [{ debugName: "controlName" }] : /* istanbul ignore next */ []);
|
|
29
29
|
this.control = input(void 0, ...ngDevMode ? [{ debugName: "control" }] : /* istanbul ignore next */ []);
|
|
30
30
|
this.disabled = input(false, ...ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []);
|
|
31
|
+
this.errors = input([], ...ngDevMode ? [{ debugName: "errors" }] : /* istanbul ignore next */ []);
|
|
32
|
+
this.invalid = input(false, ...ngDevMode ? [{ debugName: "invalid" }] : /* istanbul ignore next */ []);
|
|
33
|
+
this.touched = input(false, ...ngDevMode ? [{ debugName: "touched" }] : /* istanbul ignore next */ []);
|
|
34
|
+
this.dirty = input(false, ...ngDevMode ? [{ debugName: "dirty" }] : /* istanbul ignore next */ []);
|
|
31
35
|
this.errorMessage = input("", ...ngDevMode ? [{ debugName: "errorMessage" }] : /* istanbul ignore next */ []);
|
|
32
36
|
this.errorMessages = input({}, ...ngDevMode ? [{ debugName: "errorMessages" }] : /* istanbul ignore next */ []);
|
|
33
37
|
this.minValue = input("", ...ngDevMode ? [{ debugName: "minValue" }] : /* istanbul ignore next */ []);
|
|
@@ -89,12 +93,15 @@ var DatePickerComponent = class DatePickerComponent {
|
|
|
89
93
|
if (!name) return void 0;
|
|
90
94
|
return fg.get(name) ?? void 0;
|
|
91
95
|
}, ...ngDevMode ? [{ debugName: "actualControl" }] : /* istanbul ignore next */ []);
|
|
96
|
+
this.usesSignalForms = computed(() => !this.actualControl(), ...ngDevMode ? [{ debugName: "usesSignalForms" }] : /* istanbul ignore next */ []);
|
|
92
97
|
this.shouldShowError = computed(() => {
|
|
98
|
+
if (this.usesSignalForms()) return this.invalid() && (this.touched() || this.dirty());
|
|
93
99
|
this.errorTracker();
|
|
94
100
|
const ctrl = this.actualControl();
|
|
95
101
|
return ctrl?.invalid && (ctrl?.dirty || ctrl?.touched);
|
|
96
102
|
}, ...ngDevMode ? [{ debugName: "shouldShowError" }] : /* istanbul ignore next */ []);
|
|
97
103
|
this.wasFixedError = computed(() => {
|
|
104
|
+
if (this.usesSignalForms()) return this.hadError() && !this.invalid() && this.touched();
|
|
98
105
|
this.errorTracker();
|
|
99
106
|
const ctrl = this.actualControl();
|
|
100
107
|
return this.hadError() && ctrl?.valid && ctrl?.touched;
|
|
@@ -103,13 +110,12 @@ var DatePickerComponent = class DatePickerComponent {
|
|
|
103
110
|
this.errorTracker();
|
|
104
111
|
const customError = this.errorMessage();
|
|
105
112
|
if (customError) return [customError];
|
|
113
|
+
const customErrors = this.errorMessages();
|
|
114
|
+
const translate = (key, params) => this.transloco.translate(key, params);
|
|
115
|
+
if (this.usesSignalForms()) return errorMessagesFromMap(signalErrorsToMap(this.errors()), customErrors, translate);
|
|
106
116
|
const ctrl = this.actualControl();
|
|
107
117
|
if (!ctrl?.errors) return [];
|
|
108
|
-
|
|
109
|
-
return Object.keys(ctrl.errors).map((key) => {
|
|
110
|
-
if (customErrors[key]) return customErrors[key];
|
|
111
|
-
return key === "required" ? this.transloco.translate("validation.required") : this.transloco.translate("validation.invalid");
|
|
112
|
-
});
|
|
118
|
+
return errorMessagesFromMap(ctrl.errors, customErrors, translate);
|
|
113
119
|
}, ...ngDevMode ? [{ debugName: "getErrorMessages" }] : /* istanbul ignore next */ []);
|
|
114
120
|
this.texts = computed(() => this.effectiveLocale().startsWith("en") ? {
|
|
115
121
|
today: "Today",
|
|
@@ -325,6 +331,10 @@ var DatePickerComponent = class DatePickerComponent {
|
|
|
325
331
|
this.secondOptions = Array.from({ length: 60 }, (_, i) => i);
|
|
326
332
|
this.timeText = computed(() => this.formatTime(this.viewHour(), this.viewMinute(), this.viewSecond()), ...ngDevMode ? [{ debugName: "timeText" }] : /* istanbul ignore next */ []);
|
|
327
333
|
this.timeTextError = signal(false, ...ngDevMode ? [{ debugName: "timeTextError" }] : /* istanbul ignore next */ []);
|
|
334
|
+
effect(() => {
|
|
335
|
+
if (!this.usesSignalForms()) return;
|
|
336
|
+
if (this.invalid() && (this.touched() || this.dirty())) this.hadError.set(true);
|
|
337
|
+
});
|
|
328
338
|
const doc = this.elementRef.nativeElement.ownerDocument;
|
|
329
339
|
const onScroll = () => this.onViewportChange();
|
|
330
340
|
doc.addEventListener("scroll", onScroll, true);
|
|
@@ -780,6 +790,9 @@ var DatePickerComponent = class DatePickerComponent {
|
|
|
780
790
|
this.typingValid.set(null);
|
|
781
791
|
}
|
|
782
792
|
onInputBlur() {
|
|
793
|
+
this.onTouched();
|
|
794
|
+
this.touch.emit();
|
|
795
|
+
this.errorTracker.update((v) => v + 1);
|
|
783
796
|
const text = this.typedValue().trim();
|
|
784
797
|
this.isTyping.set(false);
|
|
785
798
|
if (!text || text === this.typedFormOfValue()) return;
|
|
@@ -1197,6 +1210,34 @@ var DatePickerComponent = class DatePickerComponent {
|
|
|
1197
1210
|
isRequired: false,
|
|
1198
1211
|
transformFunction: null
|
|
1199
1212
|
},
|
|
1213
|
+
errors: {
|
|
1214
|
+
classPropertyName: "errors",
|
|
1215
|
+
publicName: "errors",
|
|
1216
|
+
isSignal: true,
|
|
1217
|
+
isRequired: false,
|
|
1218
|
+
transformFunction: null
|
|
1219
|
+
},
|
|
1220
|
+
invalid: {
|
|
1221
|
+
classPropertyName: "invalid",
|
|
1222
|
+
publicName: "invalid",
|
|
1223
|
+
isSignal: true,
|
|
1224
|
+
isRequired: false,
|
|
1225
|
+
transformFunction: null
|
|
1226
|
+
},
|
|
1227
|
+
touched: {
|
|
1228
|
+
classPropertyName: "touched",
|
|
1229
|
+
publicName: "touched",
|
|
1230
|
+
isSignal: true,
|
|
1231
|
+
isRequired: false,
|
|
1232
|
+
transformFunction: null
|
|
1233
|
+
},
|
|
1234
|
+
dirty: {
|
|
1235
|
+
classPropertyName: "dirty",
|
|
1236
|
+
publicName: "dirty",
|
|
1237
|
+
isSignal: true,
|
|
1238
|
+
isRequired: false,
|
|
1239
|
+
transformFunction: null
|
|
1240
|
+
},
|
|
1200
1241
|
errorMessage: {
|
|
1201
1242
|
classPropertyName: "errorMessage",
|
|
1202
1243
|
publicName: "errorMessage",
|
|
@@ -1475,6 +1516,38 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
1475
1516
|
required: false
|
|
1476
1517
|
}]
|
|
1477
1518
|
}],
|
|
1519
|
+
errors: [{
|
|
1520
|
+
type: i0.Input,
|
|
1521
|
+
args: [{
|
|
1522
|
+
isSignal: true,
|
|
1523
|
+
alias: "errors",
|
|
1524
|
+
required: false
|
|
1525
|
+
}]
|
|
1526
|
+
}],
|
|
1527
|
+
invalid: [{
|
|
1528
|
+
type: i0.Input,
|
|
1529
|
+
args: [{
|
|
1530
|
+
isSignal: true,
|
|
1531
|
+
alias: "invalid",
|
|
1532
|
+
required: false
|
|
1533
|
+
}]
|
|
1534
|
+
}],
|
|
1535
|
+
touched: [{
|
|
1536
|
+
type: i0.Input,
|
|
1537
|
+
args: [{
|
|
1538
|
+
isSignal: true,
|
|
1539
|
+
alias: "touched",
|
|
1540
|
+
required: false
|
|
1541
|
+
}]
|
|
1542
|
+
}],
|
|
1543
|
+
dirty: [{
|
|
1544
|
+
type: i0.Input,
|
|
1545
|
+
args: [{
|
|
1546
|
+
isSignal: true,
|
|
1547
|
+
alias: "dirty",
|
|
1548
|
+
required: false
|
|
1549
|
+
}]
|
|
1550
|
+
}],
|
|
1478
1551
|
errorMessage: [{
|
|
1479
1552
|
type: i0.Input,
|
|
1480
1553
|
args: [{
|