@fuentis/phoenix-ui 0.0.9-alpha.662 → 0.0.9-alpha.663
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.
|
@@ -4088,6 +4088,16 @@ function getLangPattern(currentLang) {
|
|
|
4088
4088
|
return regexPatternSr;
|
|
4089
4089
|
}
|
|
4090
4090
|
}
|
|
4091
|
+
/**
|
|
4092
|
+
* True when `value` is a non-empty, well-formed time-period string for the given
|
|
4093
|
+
* language (e.g. "2w 4d 6h 45m"). Used by fields to decide whether to show the
|
|
4094
|
+
* format guidance — a valid value needs none.
|
|
4095
|
+
*/
|
|
4096
|
+
function isTimePeriodFormatValid(value, currentLang) {
|
|
4097
|
+
if (!value)
|
|
4098
|
+
return false;
|
|
4099
|
+
return getLangPattern(currentLang).test(value);
|
|
4100
|
+
}
|
|
4091
4101
|
function timePeriod(currentLang, tpMin) {
|
|
4092
4102
|
return (control) => {
|
|
4093
4103
|
if (!control.pristine) {
|
|
@@ -8688,12 +8698,15 @@ class MetaTimeperiodV2Component {
|
|
|
8688
8698
|
disable = input(false, ...(ngDevMode ? [{ debugName: "disable" }] : []));
|
|
8689
8699
|
/** Whether the field is required (drives the empty "required" note). */
|
|
8690
8700
|
mandatory = input(false, ...(ngDevMode ? [{ debugName: "mandatory" }] : []));
|
|
8701
|
+
translate = inject(TranslateService);
|
|
8691
8702
|
formDisabled = signal(false, ...(ngDevMode ? [{ debugName: "formDisabled" }] : []));
|
|
8692
8703
|
/** True once the user has typed in / left the field — gates the "required" note. */
|
|
8693
8704
|
interacted = signal(false, ...(ngDevMode ? [{ debugName: "interacted" }] : []));
|
|
8694
8705
|
/** The duration string shown in the input (the control value is this string). */
|
|
8695
8706
|
value = signal('', ...(ngDevMode ? [{ debugName: "value" }] : []));
|
|
8696
8707
|
disabled = computed(() => this.disable() || this.formDisabled(), ...(ngDevMode ? [{ debugName: "disabled" }] : []));
|
|
8708
|
+
/** True when the current value is a well-formed period — then no guidance is shown. */
|
|
8709
|
+
validFormat = computed(() => isTimePeriodFormatValid(this.value(), this.translate.currentLang), ...(ngDevMode ? [{ debugName: "validFormat" }] : []));
|
|
8697
8710
|
onChange = () => { };
|
|
8698
8711
|
onTouched = () => { };
|
|
8699
8712
|
writeValue(v) {
|
|
@@ -8741,12 +8754,12 @@ class MetaTimeperiodV2Component {
|
|
|
8741
8754
|
(input)="onInput($event)"
|
|
8742
8755
|
(blur)="handleBlur()"
|
|
8743
8756
|
/>
|
|
8744
|
-
@if (value()) {
|
|
8745
|
-
<!-- Guidance while typing
|
|
8757
|
+
@if (value() && !validFormat()) {
|
|
8758
|
+
<!-- Guidance while typing an incomplete/invalid value; hidden once it's valid. -->
|
|
8746
8759
|
<small class="block mt-1 timeperiod-v2-note">
|
|
8747
8760
|
<i class="pi pi-info-circle mr-1"></i>{{ 'VALIDATION_MESSAGE.VALUE_SHOULD_MATCH_TIMEPATTERN' | translate }}
|
|
8748
8761
|
</small>
|
|
8749
|
-
} @else if (mandatory() && interacted()) {
|
|
8762
|
+
} @else if (!value() && mandatory() && interacted()) {
|
|
8750
8763
|
<!-- Empty required field (e.g. cleared on edit). -->
|
|
8751
8764
|
<small class="block mt-1 timeperiod-v2-note">
|
|
8752
8765
|
<i class="pi pi-info-circle mr-1"></i>{{ 'VALIDATION_MESSAGE.THIS_FIELD_IS_REQUIRED' | translate }}
|
|
@@ -8768,12 +8781,12 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.16", ngImpo
|
|
|
8768
8781
|
(input)="onInput($event)"
|
|
8769
8782
|
(blur)="handleBlur()"
|
|
8770
8783
|
/>
|
|
8771
|
-
@if (value()) {
|
|
8772
|
-
<!-- Guidance while typing
|
|
8784
|
+
@if (value() && !validFormat()) {
|
|
8785
|
+
<!-- Guidance while typing an incomplete/invalid value; hidden once it's valid. -->
|
|
8773
8786
|
<small class="block mt-1 timeperiod-v2-note">
|
|
8774
8787
|
<i class="pi pi-info-circle mr-1"></i>{{ 'VALIDATION_MESSAGE.VALUE_SHOULD_MATCH_TIMEPATTERN' | translate }}
|
|
8775
8788
|
</small>
|
|
8776
|
-
} @else if (mandatory() && interacted()) {
|
|
8789
|
+
} @else if (!value() && mandatory() && interacted()) {
|
|
8777
8790
|
<!-- Empty required field (e.g. cleared on edit). -->
|
|
8778
8791
|
<small class="block mt-1 timeperiod-v2-note">
|
|
8779
8792
|
<i class="pi pi-info-circle mr-1"></i>{{ 'VALIDATION_MESSAGE.THIS_FIELD_IS_REQUIRED' | translate }}
|