@softpak/components 18.6.1 → 18.6.3
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/esm2022/spx-helpers/spx-severity.enum.mjs +2 -1
- package/esm2022/spx-inputs/spx-input-date/spx-input-date.component.mjs +164 -0
- package/esm2022/spx-inputs/spx-input.component.mjs +9 -11
- package/esm2022/spx-suggestion/spx-suggestion.component.mjs +40 -48
- package/fesm2022/softpak-components-spx-helpers.mjs +1 -0
- package/fesm2022/softpak-components-spx-helpers.mjs.map +1 -1
- package/fesm2022/softpak-components-spx-inputs.mjs +166 -304
- package/fesm2022/softpak-components-spx-inputs.mjs.map +1 -1
- package/fesm2022/softpak-components-spx-suggestion.mjs +39 -47
- package/fesm2022/softpak-components-spx-suggestion.mjs.map +1 -1
- package/package.json +49 -49
- package/spx-helpers/spx-severity.enum.d.ts +2 -1
- package/spx-inputs/spx-input-date/spx-input-date.component.d.ts +39 -0
- package/spx-suggestion/spx-suggestion.component.d.ts +5 -5
- package/esm2022/spx-inputs/spx-input-date.component.mjs +0 -297
- package/spx-inputs/spx-input-date.component.d.ts +0 -49
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { EventEmitter, Component, Input, Output, HostListener, ViewChild } from '@angular/core';
|
|
2
|
+
import { EventEmitter, Component, Input, Output, HostListener, ViewChild, input, model, output, signal, computed } from '@angular/core';
|
|
3
3
|
import { SpxButtonComponent } from '@softpak/components/spx-button';
|
|
4
4
|
import * as i1 from '@fortawesome/angular-fontawesome';
|
|
5
5
|
import { FontAwesomeModule } from '@fortawesome/angular-fontawesome';
|
|
@@ -8,8 +8,8 @@ import { fromEvent } from 'rxjs';
|
|
|
8
8
|
import * as i1$1 from '@angular/forms';
|
|
9
9
|
import { FormsModule, NG_VALUE_ACCESSOR } from '@angular/forms';
|
|
10
10
|
import { SpxSuggestionComponent } from '@softpak/components/spx-suggestion';
|
|
11
|
-
import { DateTime } from 'luxon';
|
|
12
11
|
import { valuePairToValue, SpxSeverityEnum } from '@softpak/components/spx-helpers';
|
|
12
|
+
import { DateTime } from 'luxon';
|
|
13
13
|
import * as i1$2 from '@ionic/angular';
|
|
14
14
|
import { IonicModule } from '@ionic/angular';
|
|
15
15
|
|
|
@@ -526,299 +526,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImpo
|
|
|
526
526
|
args: ['input', { static: true }]
|
|
527
527
|
}] } });
|
|
528
528
|
|
|
529
|
-
class SpxInputDateComponent {
|
|
530
|
-
constructor() {
|
|
531
|
-
this.spxReadonly = false;
|
|
532
|
-
this.spxFocused = true;
|
|
533
|
-
this.spxSelectMonth = true;
|
|
534
|
-
this.spxSelectDay = true;
|
|
535
|
-
this.spxChange = new EventEmitter();
|
|
536
|
-
this.spxFocus = new EventEmitter();
|
|
537
|
-
this.spxSelectStep = 'years';
|
|
538
|
-
this.spxInternalValue = {};
|
|
539
|
-
this.spxSuggestions = {
|
|
540
|
-
years: [],
|
|
541
|
-
months: [{
|
|
542
|
-
description: 'Jan',
|
|
543
|
-
value: 1,
|
|
544
|
-
}, {
|
|
545
|
-
description: 'Feb',
|
|
546
|
-
value: 2,
|
|
547
|
-
}, {
|
|
548
|
-
description: 'Mar',
|
|
549
|
-
value: 3,
|
|
550
|
-
}, {
|
|
551
|
-
description: 'Apr',
|
|
552
|
-
value: 4,
|
|
553
|
-
}, {
|
|
554
|
-
description: 'May',
|
|
555
|
-
value: 5,
|
|
556
|
-
}, {
|
|
557
|
-
description: 'Jun',
|
|
558
|
-
value: 6,
|
|
559
|
-
}, {
|
|
560
|
-
description: 'Jul',
|
|
561
|
-
value: 7,
|
|
562
|
-
}, {
|
|
563
|
-
description: 'Aug',
|
|
564
|
-
value: 8,
|
|
565
|
-
}, {
|
|
566
|
-
description: 'Sep',
|
|
567
|
-
value: 9,
|
|
568
|
-
}, {
|
|
569
|
-
description: 'Oct',
|
|
570
|
-
value: 10,
|
|
571
|
-
}, {
|
|
572
|
-
description: 'Nov',
|
|
573
|
-
value: 11,
|
|
574
|
-
}, {
|
|
575
|
-
description: 'Dec',
|
|
576
|
-
value: 12,
|
|
577
|
-
}],
|
|
578
|
-
days: [],
|
|
579
|
-
};
|
|
580
|
-
this.spxWasInternalUpdate = false;
|
|
581
|
-
}
|
|
582
|
-
async spxSetFocus() {
|
|
583
|
-
// this.elYear.focus();
|
|
584
|
-
}
|
|
585
|
-
// @Watch('spxValidators') watchSpxValidators(newValue) {
|
|
586
|
-
// console.log('validators', newValue);
|
|
587
|
-
// }
|
|
588
|
-
// @Watch('value') watchValue(newValue) {
|
|
589
|
-
// if (this.spxWasInternalUpdate) {
|
|
590
|
-
// this.spxWasInternalUpdate = false;
|
|
591
|
-
// } else {
|
|
592
|
-
// const parsedValue = DateTime.fromISO(newValue?.value);
|
|
593
|
-
// this.spxInternalValue.years = parsedValue.year;
|
|
594
|
-
// this.spxInternalValue.months = parsedValue.month;
|
|
595
|
-
// this.spxInternalValue.days = parsedValue.day;
|
|
596
|
-
// this.spxSelectStep = 'years';
|
|
597
|
-
// }
|
|
598
|
-
// }
|
|
599
|
-
ngOnInit() {
|
|
600
|
-
const parsedValue = this.value ? DateTime.fromISO(this.value.value) : DateTime.now();
|
|
601
|
-
this.suggestYears();
|
|
602
|
-
this.spxInternalValue.years = parsedValue.year;
|
|
603
|
-
this.spxInternalValue.months = parsedValue.month;
|
|
604
|
-
this.spxInternalValue.days = parsedValue.day;
|
|
605
|
-
}
|
|
606
|
-
handleDayInput(event) {
|
|
607
|
-
this.spxInternalValue.days = event.target ? event.target.value : null;
|
|
608
|
-
this.updateValue();
|
|
609
|
-
}
|
|
610
|
-
handleMonthInput(event) {
|
|
611
|
-
this.spxInternalValue.months = event.target ? event.target.value : null;
|
|
612
|
-
this.afterMonthChange();
|
|
613
|
-
}
|
|
614
|
-
afterMonthChange() {
|
|
615
|
-
if (this.spxInternalValue.months.toString().length === 2 && this.spxSelectDay && this.spxLastKeyPressed !== 38 && this.spxLastKeyPressed !== 40) {
|
|
616
|
-
this.elDay?.focus();
|
|
617
|
-
}
|
|
618
|
-
this.updateValue();
|
|
619
|
-
}
|
|
620
|
-
handleYearInput(event) {
|
|
621
|
-
this.spxInternalValue.years = event.target ? event.target.value : null;
|
|
622
|
-
this.afterYearChange();
|
|
623
|
-
}
|
|
624
|
-
afterYearChange() {
|
|
625
|
-
if (this.spxInternalValue.years.toString().length === 4 && this.spxSelectMonth && this.spxLastKeyPressed !== 38 && this.spxLastKeyPressed !== 40) {
|
|
626
|
-
this.elMonth?.focus();
|
|
627
|
-
}
|
|
628
|
-
this.updateValue();
|
|
629
|
-
}
|
|
630
|
-
handleInput(event) {
|
|
631
|
-
this.setValue(event.target ? event.target.value : null);
|
|
632
|
-
}
|
|
633
|
-
handleFocus(step) {
|
|
634
|
-
this.spxSelectStep = step;
|
|
635
|
-
this.spxFocus.emit();
|
|
636
|
-
}
|
|
637
|
-
handleKeyDown(event) {
|
|
638
|
-
this.spxLastKeyPressed = event.which;
|
|
639
|
-
}
|
|
640
|
-
handleSuggestionClick(value) {
|
|
641
|
-
this.spxLastKeyPressed = null;
|
|
642
|
-
this.spxInternalValue[this.spxSelectStep] = value;
|
|
643
|
-
this.updateValue();
|
|
644
|
-
this.doneWithField();
|
|
645
|
-
}
|
|
646
|
-
updateValue() {
|
|
647
|
-
const concatenatedValue = `${this.spxInternalValue.years ? this.spxInternalValue.years : ``}${this.spxInternalValue.months ? `-${this.spxInternalValue.months < 10 ? `0${this.spxInternalValue.months}` : this.spxInternalValue.months}` : ``}${this.spxInternalValue.days ? `-${this.spxInternalValue.days < 10 ? `0${this.spxInternalValue.days}` : this.spxInternalValue.days}` : ``}`;
|
|
648
|
-
const parsedValue = DateTime.fromISO(concatenatedValue);
|
|
649
|
-
this.spxWasInternalUpdate = true;
|
|
650
|
-
this.value = {
|
|
651
|
-
description: parsedValue.toISO(),
|
|
652
|
-
value: parsedValue.toISO(),
|
|
653
|
-
};
|
|
654
|
-
this.spxChange.emit(this.value);
|
|
655
|
-
}
|
|
656
|
-
doneWithField() {
|
|
657
|
-
if (this.spxSelectStep === 'days') {
|
|
658
|
-
this.spxSelectStep = 'years';
|
|
659
|
-
}
|
|
660
|
-
else if (this.spxSelectStep === 'months') {
|
|
661
|
-
this.spxSelectStep = this.spxSelectDay ? 'days' : 'years';
|
|
662
|
-
this.afterMonthChange();
|
|
663
|
-
}
|
|
664
|
-
else if (this.spxSelectStep === 'years') {
|
|
665
|
-
this.afterYearChange();
|
|
666
|
-
this.spxSelectStep = this.spxSelectMonth ? 'months' : 'years';
|
|
667
|
-
}
|
|
668
|
-
}
|
|
669
|
-
setValue(value) {
|
|
670
|
-
this.spxInternalValue = value;
|
|
671
|
-
const parsed = DateTime.fromISO(value);
|
|
672
|
-
this.value = {
|
|
673
|
-
description: parsed.toISO(),
|
|
674
|
-
value: parsed.toISO(),
|
|
675
|
-
};
|
|
676
|
-
this.spxChange.emit(this.value);
|
|
677
|
-
this.spxWasInternalUpdate = true;
|
|
678
|
-
}
|
|
679
|
-
suggestYears() {
|
|
680
|
-
console.log('suggest years', this.spxMin, this.spxMax);
|
|
681
|
-
this.spxSuggestions.years = [];
|
|
682
|
-
for (let year = DateTime.fromISO(this.spxMin).year; year <= DateTime.fromISO(this.spxMax).year; year++) {
|
|
683
|
-
this.spxSuggestions.years.push({
|
|
684
|
-
description: `'${year.toString().substring(2, 4)}`,
|
|
685
|
-
value: year,
|
|
686
|
-
});
|
|
687
|
-
}
|
|
688
|
-
console.log('suggest years', this.spxSuggestions);
|
|
689
|
-
}
|
|
690
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: SpxInputDateComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
691
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.13", type: SpxInputDateComponent, isStandalone: true, selector: "spx-input-date", inputs: { spxMax: "spxMax", spxMin: "spxMin", spxName: "spxName", spxReadonly: "spxReadonly", spxValidators: "spxValidators", spxFocused: "spxFocused", spxSelectMonth: "spxSelectMonth", spxSelectDay: "spxSelectDay", value: "value", spxLastKeyPressed: "spxLastKeyPressed", spxSelectStep: "spxSelectStep", spxInternalValue: "spxInternalValue", spxSuggestions: "spxSuggestions", spxWasInternalUpdate: "spxWasInternalUpdate" }, outputs: { spxChange: "spxChange", spxFocus: "spxFocus" }, ngImport: i0, template: `<div class='spx-input-date__controls'>
|
|
692
|
-
<input
|
|
693
|
-
class='spx-input-date__input'
|
|
694
|
-
[attr.value]="this.spxInternalValue.years"
|
|
695
|
-
(focus)="this.handleFocus('years')"
|
|
696
|
-
(input)="this.handleYearInput($event)"
|
|
697
|
-
(keyDown)="this.handleKeyDown($event)"
|
|
698
|
-
[attr.type]="'number'"
|
|
699
|
-
[attr.min]="1900"
|
|
700
|
-
[attr.max]="2100"
|
|
701
|
-
[attr.step]="1"
|
|
702
|
-
/>
|
|
703
|
-
<div class='spx-input-date__control-label'>Year</div>
|
|
704
|
-
@if (this.spxSelectMonth) {
|
|
705
|
-
<input
|
|
706
|
-
class='spx-input-date__input'
|
|
707
|
-
[attr.value]="this.spxInternalValue.months"
|
|
708
|
-
(focus)="this.handleFocus('months')"
|
|
709
|
-
(input)="this.handleMonthInput($event)"
|
|
710
|
-
(keyDown)="this.handleKeyDown($event)"
|
|
711
|
-
[attr.type]="'number'"
|
|
712
|
-
[attr.min]="1"
|
|
713
|
-
[attr.max]="12"
|
|
714
|
-
[attr.step]="1" />
|
|
715
|
-
}
|
|
716
|
-
<div class='spx-input-date__control-label'>Month</div>
|
|
717
|
-
@if (this.spxSelectDay) {
|
|
718
|
-
<input
|
|
719
|
-
class='spx-input-date__input'
|
|
720
|
-
[attr.value]="this.spxInternalValue.days"
|
|
721
|
-
(focus)="this.handleFocus('days')"
|
|
722
|
-
(input)="this.handleDayInput($event)"
|
|
723
|
-
(keyDown)="this.handleKeyDown($event)"
|
|
724
|
-
[attr.type]="'number'"
|
|
725
|
-
[attr.min]="1"
|
|
726
|
-
[attr.max]="31"
|
|
727
|
-
[attr.step]="1" />
|
|
728
|
-
<div class='spx-input-date__control-label'>Days</div>
|
|
729
|
-
}
|
|
730
|
-
</div>
|
|
731
|
-
<div class='spx-input-date__suggestions'>
|
|
732
|
-
@for (valuePair of spxSuggestions[spxSelectStep]; track valuePair) {
|
|
733
|
-
<spx-suggestion
|
|
734
|
-
(click)="this.handleSuggestionClick(valuePair.value)">{{valuePair?.description}}</spx-suggestion>
|
|
735
|
-
}
|
|
736
|
-
</div>`, isInline: true, styles: [":host{display:block}.spx-input-date__input{background-color:transparent;border:1px solid #979797;border-radius:4px;color:var(--spx-input--color, rgba(0, 0, 0, .9));box-sizing:border-box;font-size:16px;margin-right:10px;padding:6px;text-align:center;width:100%}.spx-input-date__input:active{transform:scale(.95)}.spx-input-date__input:focus{border:var(--spx-input-box--focus--border, 1px solid rgb(115, 168, 210));border-radius:4px;outline:none}.spx-input-date__control-label{align-items:center;color:#000000b3;display:inline-grid;font-size:13px;letter-spacing:1px}.spx-input-date__input::-webkit-outer-spin-button,.spx-input-date__input::-webkit-inner-spin-button{-webkit-appearance:none;margin:0}.spx-input-date__input[type=number]{-moz-appearance:textfield}.spx-input-date__suggestions,.spx-input-date__controls{display:grid;grid-gap:8px;grid-template-columns:repeat(4,1fr);margin-top:8px}\n"], dependencies: [{ kind: "component", type: SpxSuggestionComponent, selector: "spx-suggestion", inputs: ["spxDisabled", "spxFocused", "spxSelected", "spxTabbable"] }] }); }
|
|
737
|
-
}
|
|
738
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: SpxInputDateComponent, decorators: [{
|
|
739
|
-
type: Component,
|
|
740
|
-
args: [{ selector: 'spx-input-date', standalone: true, imports: [
|
|
741
|
-
SpxSuggestionComponent
|
|
742
|
-
], template: `<div class='spx-input-date__controls'>
|
|
743
|
-
<input
|
|
744
|
-
class='spx-input-date__input'
|
|
745
|
-
[attr.value]="this.spxInternalValue.years"
|
|
746
|
-
(focus)="this.handleFocus('years')"
|
|
747
|
-
(input)="this.handleYearInput($event)"
|
|
748
|
-
(keyDown)="this.handleKeyDown($event)"
|
|
749
|
-
[attr.type]="'number'"
|
|
750
|
-
[attr.min]="1900"
|
|
751
|
-
[attr.max]="2100"
|
|
752
|
-
[attr.step]="1"
|
|
753
|
-
/>
|
|
754
|
-
<div class='spx-input-date__control-label'>Year</div>
|
|
755
|
-
@if (this.spxSelectMonth) {
|
|
756
|
-
<input
|
|
757
|
-
class='spx-input-date__input'
|
|
758
|
-
[attr.value]="this.spxInternalValue.months"
|
|
759
|
-
(focus)="this.handleFocus('months')"
|
|
760
|
-
(input)="this.handleMonthInput($event)"
|
|
761
|
-
(keyDown)="this.handleKeyDown($event)"
|
|
762
|
-
[attr.type]="'number'"
|
|
763
|
-
[attr.min]="1"
|
|
764
|
-
[attr.max]="12"
|
|
765
|
-
[attr.step]="1" />
|
|
766
|
-
}
|
|
767
|
-
<div class='spx-input-date__control-label'>Month</div>
|
|
768
|
-
@if (this.spxSelectDay) {
|
|
769
|
-
<input
|
|
770
|
-
class='spx-input-date__input'
|
|
771
|
-
[attr.value]="this.spxInternalValue.days"
|
|
772
|
-
(focus)="this.handleFocus('days')"
|
|
773
|
-
(input)="this.handleDayInput($event)"
|
|
774
|
-
(keyDown)="this.handleKeyDown($event)"
|
|
775
|
-
[attr.type]="'number'"
|
|
776
|
-
[attr.min]="1"
|
|
777
|
-
[attr.max]="31"
|
|
778
|
-
[attr.step]="1" />
|
|
779
|
-
<div class='spx-input-date__control-label'>Days</div>
|
|
780
|
-
}
|
|
781
|
-
</div>
|
|
782
|
-
<div class='spx-input-date__suggestions'>
|
|
783
|
-
@for (valuePair of spxSuggestions[spxSelectStep]; track valuePair) {
|
|
784
|
-
<spx-suggestion
|
|
785
|
-
(click)="this.handleSuggestionClick(valuePair.value)">{{valuePair?.description}}</spx-suggestion>
|
|
786
|
-
}
|
|
787
|
-
</div>`, styles: [":host{display:block}.spx-input-date__input{background-color:transparent;border:1px solid #979797;border-radius:4px;color:var(--spx-input--color, rgba(0, 0, 0, .9));box-sizing:border-box;font-size:16px;margin-right:10px;padding:6px;text-align:center;width:100%}.spx-input-date__input:active{transform:scale(.95)}.spx-input-date__input:focus{border:var(--spx-input-box--focus--border, 1px solid rgb(115, 168, 210));border-radius:4px;outline:none}.spx-input-date__control-label{align-items:center;color:#000000b3;display:inline-grid;font-size:13px;letter-spacing:1px}.spx-input-date__input::-webkit-outer-spin-button,.spx-input-date__input::-webkit-inner-spin-button{-webkit-appearance:none;margin:0}.spx-input-date__input[type=number]{-moz-appearance:textfield}.spx-input-date__suggestions,.spx-input-date__controls{display:grid;grid-gap:8px;grid-template-columns:repeat(4,1fr);margin-top:8px}\n"] }]
|
|
788
|
-
}], propDecorators: { spxMax: [{
|
|
789
|
-
type: Input
|
|
790
|
-
}], spxMin: [{
|
|
791
|
-
type: Input
|
|
792
|
-
}], spxName: [{
|
|
793
|
-
type: Input
|
|
794
|
-
}], spxReadonly: [{
|
|
795
|
-
type: Input
|
|
796
|
-
}], spxValidators: [{
|
|
797
|
-
type: Input
|
|
798
|
-
}], spxFocused: [{
|
|
799
|
-
type: Input
|
|
800
|
-
}], spxSelectMonth: [{
|
|
801
|
-
type: Input
|
|
802
|
-
}], spxSelectDay: [{
|
|
803
|
-
type: Input
|
|
804
|
-
}], value: [{
|
|
805
|
-
type: Input
|
|
806
|
-
}], spxChange: [{
|
|
807
|
-
type: Output
|
|
808
|
-
}], spxFocus: [{
|
|
809
|
-
type: Output
|
|
810
|
-
}], spxLastKeyPressed: [{
|
|
811
|
-
type: Input
|
|
812
|
-
}], spxSelectStep: [{
|
|
813
|
-
type: Input
|
|
814
|
-
}], spxInternalValue: [{
|
|
815
|
-
type: Input
|
|
816
|
-
}], spxSuggestions: [{
|
|
817
|
-
type: Input
|
|
818
|
-
}], spxWasInternalUpdate: [{
|
|
819
|
-
type: Input
|
|
820
|
-
}] } });
|
|
821
|
-
|
|
822
529
|
class SpxInputFloatComponent {
|
|
823
530
|
constructor() {
|
|
824
531
|
this.internalValue = {
|
|
@@ -1472,6 +1179,163 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImpo
|
|
|
1472
1179
|
args: ['input', { static: true }]
|
|
1473
1180
|
}] } });
|
|
1474
1181
|
|
|
1182
|
+
var stepType;
|
|
1183
|
+
(function (stepType) {
|
|
1184
|
+
stepType["years"] = "years";
|
|
1185
|
+
stepType["months"] = "months";
|
|
1186
|
+
stepType["days"] = "days";
|
|
1187
|
+
})(stepType || (stepType = {}));
|
|
1188
|
+
class SpxInputDateComponent {
|
|
1189
|
+
constructor() {
|
|
1190
|
+
this.spxMax = input.required();
|
|
1191
|
+
this.spxMin = input.required();
|
|
1192
|
+
this.spxReadonly = input();
|
|
1193
|
+
this.spxValidators = input();
|
|
1194
|
+
this.value = model({
|
|
1195
|
+
description: "",
|
|
1196
|
+
value: "",
|
|
1197
|
+
});
|
|
1198
|
+
this.spxChange = output();
|
|
1199
|
+
this.spxFocused = input(true);
|
|
1200
|
+
this.spxFocus = output();
|
|
1201
|
+
this.spxSelectedStep = signal(stepType.years);
|
|
1202
|
+
this.spxSelectDay = input(false);
|
|
1203
|
+
this.spxSelectMonth = input(true);
|
|
1204
|
+
this.selectedYear = signal(null);
|
|
1205
|
+
this.selectedMonth = signal(null);
|
|
1206
|
+
this.selectedDay = signal(null);
|
|
1207
|
+
this.spxSuggestionC = computed(() => {
|
|
1208
|
+
switch (this.spxSelectedStep()) {
|
|
1209
|
+
case 'months':
|
|
1210
|
+
return [...this.spxSuggestions().months];
|
|
1211
|
+
case 'days':
|
|
1212
|
+
return [...this.spxSuggestions().days];
|
|
1213
|
+
default:
|
|
1214
|
+
return this.spxSuggestions().years;
|
|
1215
|
+
}
|
|
1216
|
+
});
|
|
1217
|
+
this.spxSuggestions = input({ years: [],
|
|
1218
|
+
months: [{
|
|
1219
|
+
description: 'Jan',
|
|
1220
|
+
value: 1,
|
|
1221
|
+
}, {
|
|
1222
|
+
description: 'Feb',
|
|
1223
|
+
value: 2,
|
|
1224
|
+
}, {
|
|
1225
|
+
description: 'Mar',
|
|
1226
|
+
value: 3,
|
|
1227
|
+
}, {
|
|
1228
|
+
description: 'Apr',
|
|
1229
|
+
value: 4,
|
|
1230
|
+
}, {
|
|
1231
|
+
description: 'May',
|
|
1232
|
+
value: 5,
|
|
1233
|
+
}, {
|
|
1234
|
+
description: 'Jun',
|
|
1235
|
+
value: 6,
|
|
1236
|
+
}, {
|
|
1237
|
+
description: 'Jul',
|
|
1238
|
+
value: 7,
|
|
1239
|
+
}, {
|
|
1240
|
+
description: 'Aug',
|
|
1241
|
+
value: 8,
|
|
1242
|
+
}, {
|
|
1243
|
+
description: 'Sep',
|
|
1244
|
+
value: 9,
|
|
1245
|
+
}, {
|
|
1246
|
+
description: 'Oct',
|
|
1247
|
+
value: 10,
|
|
1248
|
+
}, {
|
|
1249
|
+
description: 'Nov',
|
|
1250
|
+
value: 11,
|
|
1251
|
+
}, {
|
|
1252
|
+
description: 'Dec',
|
|
1253
|
+
value: 12,
|
|
1254
|
+
}],
|
|
1255
|
+
days: [], });
|
|
1256
|
+
}
|
|
1257
|
+
onModelChange(newValue, selectedStep) {
|
|
1258
|
+
const parsedValue = +newValue; // Convert to number
|
|
1259
|
+
if (parsedValue == 0)
|
|
1260
|
+
return;
|
|
1261
|
+
switch (selectedStep) {
|
|
1262
|
+
case stepType.years:
|
|
1263
|
+
this.selectedYear.set(parsedValue);
|
|
1264
|
+
break;
|
|
1265
|
+
case stepType.months:
|
|
1266
|
+
this.selectedMonth.set(parsedValue);
|
|
1267
|
+
break;
|
|
1268
|
+
case stepType.days:
|
|
1269
|
+
this.selectedDay.set(parsedValue);
|
|
1270
|
+
break;
|
|
1271
|
+
}
|
|
1272
|
+
}
|
|
1273
|
+
ngOnInit() {
|
|
1274
|
+
this.suggestYears();
|
|
1275
|
+
if (valuePairToValue(this.value)) {
|
|
1276
|
+
const parsedValue = DateTime.fromISO(valuePairToValue(this.value));
|
|
1277
|
+
this.selectedYear.set(parsedValue.year);
|
|
1278
|
+
this.selectedMonth.set(parsedValue.month);
|
|
1279
|
+
this.selectedDay.set(parsedValue.day);
|
|
1280
|
+
}
|
|
1281
|
+
}
|
|
1282
|
+
handleSuggestionClick(value) {
|
|
1283
|
+
switch (this.spxSelectedStep()) {
|
|
1284
|
+
case "years":
|
|
1285
|
+
this.selectedYear.set(value);
|
|
1286
|
+
break;
|
|
1287
|
+
case "months":
|
|
1288
|
+
this.selectedMonth.set(value);
|
|
1289
|
+
break;
|
|
1290
|
+
case "days":
|
|
1291
|
+
this.selectedDay.set(value);
|
|
1292
|
+
break;
|
|
1293
|
+
}
|
|
1294
|
+
this.updateValueAndEmit();
|
|
1295
|
+
this.changeSelectedStep();
|
|
1296
|
+
}
|
|
1297
|
+
updateValueAndEmit() {
|
|
1298
|
+
const concatenatedValue = `
|
|
1299
|
+
${this.selectedYear() ? this.selectedYear() : ``}
|
|
1300
|
+
${this.selectedMonth() ? `${this.selectedMonth() < 10 ? `0${this.selectedMonth()}` : this.selectedMonth()}` : ``}
|
|
1301
|
+
${this.selectedDay() ? `-${this.selectedDay() < 10 ? `0${this.selectedDay()}` : this.selectedDay()}` : ``}`;
|
|
1302
|
+
const parsedValue = DateTime.fromISO(concatenatedValue);
|
|
1303
|
+
this.value.set({ value: parsedValue.toISO(), description: parsedValue.toISO() });
|
|
1304
|
+
this.spxChange.emit(this.value());
|
|
1305
|
+
}
|
|
1306
|
+
changeSelectedStep() {
|
|
1307
|
+
switch (this.spxSelectedStep()) {
|
|
1308
|
+
case 'days':
|
|
1309
|
+
this.spxSelectedStep.set(stepType.years);
|
|
1310
|
+
break;
|
|
1311
|
+
case 'months':
|
|
1312
|
+
this.spxSelectedStep.set(this.spxSelectDay() ? stepType.days : stepType.years);
|
|
1313
|
+
break;
|
|
1314
|
+
case 'years':
|
|
1315
|
+
this.spxSelectedStep.set(this.spxSelectMonth() ? stepType.months : stepType.years);
|
|
1316
|
+
break;
|
|
1317
|
+
}
|
|
1318
|
+
}
|
|
1319
|
+
suggestYears() {
|
|
1320
|
+
this.spxSuggestions().years = [];
|
|
1321
|
+
for (let year = DateTime.fromISO(this.spxMin()).year; year <= DateTime.fromISO(this.spxMax()).year; year++) {
|
|
1322
|
+
this.spxSuggestions().years.push({
|
|
1323
|
+
description: `'${year.toString().substring(2, 4)}`,
|
|
1324
|
+
value: year,
|
|
1325
|
+
});
|
|
1326
|
+
}
|
|
1327
|
+
}
|
|
1328
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: SpxInputDateComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
1329
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.13", type: SpxInputDateComponent, isStandalone: true, selector: "spx-input-date", inputs: { spxMax: { classPropertyName: "spxMax", publicName: "spxMax", isSignal: true, isRequired: true, transformFunction: null }, spxMin: { classPropertyName: "spxMin", publicName: "spxMin", isSignal: true, isRequired: true, transformFunction: null }, spxReadonly: { classPropertyName: "spxReadonly", publicName: "spxReadonly", isSignal: true, isRequired: false, transformFunction: null }, spxValidators: { classPropertyName: "spxValidators", publicName: "spxValidators", isSignal: true, isRequired: false, transformFunction: null }, value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null }, spxFocused: { classPropertyName: "spxFocused", publicName: "spxFocused", isSignal: true, isRequired: false, transformFunction: null }, spxSelectDay: { classPropertyName: "spxSelectDay", publicName: "spxSelectDay", isSignal: true, isRequired: false, transformFunction: null }, spxSelectMonth: { classPropertyName: "spxSelectMonth", publicName: "spxSelectMonth", isSignal: true, isRequired: false, transformFunction: null }, spxSuggestions: { classPropertyName: "spxSuggestions", publicName: "spxSuggestions", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { value: "valueChange", spxChange: "spxChange", spxFocus: "spxFocus" }, ngImport: i0, template: "<div class='spx-input-date__controls'>\r\n <input\r\n class='spx-input-date__input'\r\n [(ngModel)]=\"selectedYear\"\r\n [attr.type]=\"'number'\"\r\n (ngModelChange)=\"onModelChange($event, 'years')\"\r\n [attr.min]=\"1900\"\r\n [attr.max]=\"2100\"\r\n [attr.step]=\"1\"\r\n />\r\n <div class='spx-input-date__control-label'>Year</div>\r\n @if (this.spxSelectMonth()) {\r\n <input\r\n class='spx-input-date__input'\r\n [(ngModel)]=\"selectedMonth\"\r\n (ngModelChange)=\"onModelChange($event, 'months')\"\r\n [attr.type]=\"'number'\"\r\n [attr.min]=\"1\"\r\n [attr.max]=\"12\"\r\n [attr.step]=\"1\" />\r\n }\r\n <div class='spx-input-date__control-label'>Month</div>\r\n @if (this.spxSelectDay()) {\r\n <input\r\n class='spx-input-date__input'\r\n [(ngModel)]=\"selectedDay\"\r\n (ngModelChange)=\"onModelChange($event, 'days')\"\r\n [attr.type]=\"'number'\"\r\n [attr.min]=\"1\"\r\n [attr.max]=\"31\"\r\n [attr.step]=\"1\" />\r\n <div class='spx-input-date__control-label'>Days</div>\r\n }\r\n</div>\r\n<div class='spx-input-date__suggestions'>\r\n @for (valuePair of spxSuggestionC(); track valuePair.value) {\r\n <spx-suggestion [spxSelected]=\"\r\n (selectedYear() === valuePair.value) ||\r\n (selectedMonth() === valuePair.value) || \r\n (selectedDay() === valuePair.value)\"\r\n (click)=\"this.handleSuggestionClick(valuePair.value)\">{{valuePair?.description}}</spx-suggestion>\r\n }\r\n</div>", styles: [":host{display:block}.spx-input-date__input{background-color:transparent;border:1px solid #979797;border-radius:4px;color:var(--spx-input--color, rgba(0, 0, 0, .9));box-sizing:border-box;font-size:16px;margin-right:10px;padding:6px;text-align:center;width:100%}.spx-input-date__input:active{transform:scale(.95)}.spx-input-date__input:focus{border:var(--spx-input-box--focus--border, 1px solid rgb(115, 168, 210));border-radius:4px;outline:none}.spx-input-date__control-label{align-items:center;color:#000000b3;display:inline-grid;font-size:13px;letter-spacing:1px}.spx-input-date__input::-webkit-outer-spin-button,.spx-input-date__input::-webkit-inner-spin-button{-webkit-appearance:none;margin:0}.spx-input-date__input[type=number]{-moz-appearance:textfield}.spx-input-date__suggestions,.spx-input-date__controls{display:grid;grid-gap:8px;grid-template-columns:repeat(4,1fr);margin-top:8px}\n"], dependencies: [{ kind: "component", type: SpxSuggestionComponent, selector: "spx-suggestion", inputs: ["spxDisabled", "spxFocused", "spxSelected", "spxTabbable"] }, { kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1$1.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i1$1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1$1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }] }); }
|
|
1330
|
+
}
|
|
1331
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: SpxInputDateComponent, decorators: [{
|
|
1332
|
+
type: Component,
|
|
1333
|
+
args: [{ selector: 'spx-input-date', standalone: true, imports: [
|
|
1334
|
+
SpxSuggestionComponent,
|
|
1335
|
+
FormsModule
|
|
1336
|
+
], template: "<div class='spx-input-date__controls'>\r\n <input\r\n class='spx-input-date__input'\r\n [(ngModel)]=\"selectedYear\"\r\n [attr.type]=\"'number'\"\r\n (ngModelChange)=\"onModelChange($event, 'years')\"\r\n [attr.min]=\"1900\"\r\n [attr.max]=\"2100\"\r\n [attr.step]=\"1\"\r\n />\r\n <div class='spx-input-date__control-label'>Year</div>\r\n @if (this.spxSelectMonth()) {\r\n <input\r\n class='spx-input-date__input'\r\n [(ngModel)]=\"selectedMonth\"\r\n (ngModelChange)=\"onModelChange($event, 'months')\"\r\n [attr.type]=\"'number'\"\r\n [attr.min]=\"1\"\r\n [attr.max]=\"12\"\r\n [attr.step]=\"1\" />\r\n }\r\n <div class='spx-input-date__control-label'>Month</div>\r\n @if (this.spxSelectDay()) {\r\n <input\r\n class='spx-input-date__input'\r\n [(ngModel)]=\"selectedDay\"\r\n (ngModelChange)=\"onModelChange($event, 'days')\"\r\n [attr.type]=\"'number'\"\r\n [attr.min]=\"1\"\r\n [attr.max]=\"31\"\r\n [attr.step]=\"1\" />\r\n <div class='spx-input-date__control-label'>Days</div>\r\n }\r\n</div>\r\n<div class='spx-input-date__suggestions'>\r\n @for (valuePair of spxSuggestionC(); track valuePair.value) {\r\n <spx-suggestion [spxSelected]=\"\r\n (selectedYear() === valuePair.value) ||\r\n (selectedMonth() === valuePair.value) || \r\n (selectedDay() === valuePair.value)\"\r\n (click)=\"this.handleSuggestionClick(valuePair.value)\">{{valuePair?.description}}</spx-suggestion>\r\n }\r\n</div>", styles: [":host{display:block}.spx-input-date__input{background-color:transparent;border:1px solid #979797;border-radius:4px;color:var(--spx-input--color, rgba(0, 0, 0, .9));box-sizing:border-box;font-size:16px;margin-right:10px;padding:6px;text-align:center;width:100%}.spx-input-date__input:active{transform:scale(.95)}.spx-input-date__input:focus{border:var(--spx-input-box--focus--border, 1px solid rgb(115, 168, 210));border-radius:4px;outline:none}.spx-input-date__control-label{align-items:center;color:#000000b3;display:inline-grid;font-size:13px;letter-spacing:1px}.spx-input-date__input::-webkit-outer-spin-button,.spx-input-date__input::-webkit-inner-spin-button{-webkit-appearance:none;margin:0}.spx-input-date__input[type=number]{-moz-appearance:textfield}.spx-input-date__suggestions,.spx-input-date__controls{display:grid;grid-gap:8px;grid-template-columns:repeat(4,1fr);margin-top:8px}\n"] }]
|
|
1337
|
+
}] });
|
|
1338
|
+
|
|
1475
1339
|
class SpxInputComponent {
|
|
1476
1340
|
constructor() {
|
|
1477
1341
|
this.spxLabel = 'label';
|
|
@@ -1634,14 +1498,13 @@ class SpxInputComponent {
|
|
|
1634
1498
|
(spxChange)="this.handleChange($event)"
|
|
1635
1499
|
(spxFocus)="this.handleFocus()"
|
|
1636
1500
|
[spxFocused]="this.spxFocused"
|
|
1637
|
-
[spxMax]="this.spxMax"
|
|
1638
|
-
[spxMin]="this.spxMin"
|
|
1639
|
-
[spxName]="this.spxName"
|
|
1501
|
+
[spxMax]="this.spxMax!"
|
|
1502
|
+
[spxMin]="this.spxMin!"
|
|
1640
1503
|
[spxReadonly]="this.spxReadonly"
|
|
1641
1504
|
[spxSelectDay]="this.spxSelectDay"
|
|
1642
1505
|
[spxSelectMonth]="this.spxSelectMonth"
|
|
1643
1506
|
[spxValidators]="this.spxValidators"
|
|
1644
|
-
[value]="this.value"
|
|
1507
|
+
[(value)]="this.value"
|
|
1645
1508
|
></spx-input-date>
|
|
1646
1509
|
}
|
|
1647
1510
|
@if (this.spxType === 'float') {
|
|
@@ -1700,7 +1563,7 @@ class SpxInputComponent {
|
|
|
1700
1563
|
<div validation-messages>
|
|
1701
1564
|
<ng-content></ng-content>
|
|
1702
1565
|
</div>
|
|
1703
|
-
</spx-input-box>`, isInline: true, dependencies: [{ kind: "component", type: SpxInputBoxComponent, selector: "spx-input-box", inputs: ["spxCompact", "spxFocused", "spxLabel", "spxReadonly", "spxRequired", "spxShowClear", "spxShowEdit", "spxShowHelp", "spxShowLabel", "spxShowSearch", "spxShowValidationMessages", "spxValue"], outputs: ["spxClear", "spxSearch", "spxFocus", "spxFocusOut", "spxEdit", "spxHelp"] }, { kind: "component", type: SpxInputDateComponent, selector: "spx-input-date", inputs: ["spxMax", "spxMin", "
|
|
1566
|
+
</spx-input-box>`, isInline: true, dependencies: [{ kind: "component", type: SpxInputBoxComponent, selector: "spx-input-box", inputs: ["spxCompact", "spxFocused", "spxLabel", "spxReadonly", "spxRequired", "spxShowClear", "spxShowEdit", "spxShowHelp", "spxShowLabel", "spxShowSearch", "spxShowValidationMessages", "spxValue"], outputs: ["spxClear", "spxSearch", "spxFocus", "spxFocusOut", "spxEdit", "spxHelp"] }, { kind: "component", type: SpxInputDateComponent, selector: "spx-input-date", inputs: ["spxMax", "spxMin", "spxReadonly", "spxValidators", "value", "spxFocused", "spxSelectDay", "spxSelectMonth", "spxSuggestions"], outputs: ["valueChange", "spxChange", "spxFocus"] }, { kind: "component", type: SpxInputFloatComponent, selector: "spx-input-float", inputs: ["spxName", "spxAutofocus", "spxReadonly", "spxValidators", "spxFocused", "spxStep", "value", "spxWasInternalUpdate", "tick"], outputs: ["spxChange", "spxFocus"] }, { kind: "component", type: SpxInputNumberComponent, selector: "spx-input-number", inputs: ["spxName", "spxAutofocus", "spxInputMode", "spxReadonly", "spxValidators", "spxFocused", "spxStep", "value"], outputs: ["spxChange", "spxFocus"] }, { kind: "component", type: SpxInputRadioComponent, selector: "spx-input-radio", inputs: ["spxName", "spxValidators", "spxFocused", "spxShowLabel", "spxReadonly", "spxSuggestions", "value"], outputs: ["spxChange", "spxFocus"] }, { kind: "component", type: SpxInputTextComponent, selector: "spx-input-text", inputs: ["spxName", "spxAutofocus", "spxAutocomplete", "spxInputMode", "spxPattern", "spxSuggestions", "spxReadonly", "spxValidators", "spxCapitalize", "spxFocused", "spxType", "value", "spxWasInternalUpdate"], outputs: ["spxBlurFromChild", "spxChange", "spxFocus"] }, { kind: "component", type: SpxInputTimeComponent, selector: "spx-input-time", inputs: ["spxName", "spxAutofocus", "spxInputMode", "spxPattern", "spxSuggestions", "spxReadonly", "spxValidators", "spxCapitalize", "spxFocused", "spxType", "value", "spxWasInternalUpdate"], outputs: ["spxBlurFromChild", "spxChange", "spxFocus"] }] }); }
|
|
1704
1567
|
}
|
|
1705
1568
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: SpxInputComponent, decorators: [{
|
|
1706
1569
|
type: Component,
|
|
@@ -1770,14 +1633,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImpo
|
|
|
1770
1633
|
(spxChange)="this.handleChange($event)"
|
|
1771
1634
|
(spxFocus)="this.handleFocus()"
|
|
1772
1635
|
[spxFocused]="this.spxFocused"
|
|
1773
|
-
[spxMax]="this.spxMax"
|
|
1774
|
-
[spxMin]="this.spxMin"
|
|
1775
|
-
[spxName]="this.spxName"
|
|
1636
|
+
[spxMax]="this.spxMax!"
|
|
1637
|
+
[spxMin]="this.spxMin!"
|
|
1776
1638
|
[spxReadonly]="this.spxReadonly"
|
|
1777
1639
|
[spxSelectDay]="this.spxSelectDay"
|
|
1778
1640
|
[spxSelectMonth]="this.spxSelectMonth"
|
|
1779
1641
|
[spxValidators]="this.spxValidators"
|
|
1780
|
-
[value]="this.value"
|
|
1642
|
+
[(value)]="this.value"
|
|
1781
1643
|
></spx-input-date>
|
|
1782
1644
|
}
|
|
1783
1645
|
@if (this.spxType === 'float') {
|