@masterteam/components 0.0.11 → 0.0.13
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/assets/common.css +37 -0
- package/checkbox-field/index.d.ts +2 -1
- package/color-picker-field/index.d.ts +2 -1
- package/date-field/index.d.ts +2 -1
- package/editor-field/index.d.ts +2 -1
- package/fesm2022/masterteam-components-card.mjs +3 -3
- package/fesm2022/masterteam-components-card.mjs.map +1 -1
- package/fesm2022/masterteam-components-checkbox-field.mjs +9 -1
- package/fesm2022/masterteam-components-checkbox-field.mjs.map +1 -1
- package/fesm2022/masterteam-components-color-picker-field.mjs +9 -1
- package/fesm2022/masterteam-components-color-picker-field.mjs.map +1 -1
- package/fesm2022/masterteam-components-date-field.mjs +9 -2
- package/fesm2022/masterteam-components-date-field.mjs.map +1 -1
- package/fesm2022/masterteam-components-editor-field.mjs +10 -3
- package/fesm2022/masterteam-components-editor-field.mjs.map +1 -1
- package/fesm2022/masterteam-components-icon-field.mjs +9 -2
- package/fesm2022/masterteam-components-icon-field.mjs.map +1 -1
- package/fesm2022/masterteam-components-list.mjs +2 -2
- package/fesm2022/masterteam-components-list.mjs.map +1 -1
- package/fesm2022/masterteam-components-multi-select-field.mjs +9 -2
- package/fesm2022/masterteam-components-multi-select-field.mjs.map +1 -1
- package/fesm2022/masterteam-components-number-field.mjs +9 -2
- package/fesm2022/masterteam-components-number-field.mjs.map +1 -1
- package/fesm2022/masterteam-components-select-field.mjs +9 -2
- package/fesm2022/masterteam-components-select-field.mjs.map +1 -1
- package/fesm2022/masterteam-components-slider-field.mjs +9 -2
- package/fesm2022/masterteam-components-slider-field.mjs.map +1 -1
- package/fesm2022/masterteam-components-text-field.mjs +9 -2
- package/fesm2022/masterteam-components-text-field.mjs.map +1 -1
- package/fesm2022/masterteam-components-textarea-field.mjs +9 -2
- package/fesm2022/masterteam-components-textarea-field.mjs.map +1 -1
- package/fesm2022/masterteam-components-toast.mjs +75 -0
- package/fesm2022/masterteam-components-toast.mjs.map +1 -0
- package/fesm2022/masterteam-components-toggle-field.mjs +9 -1
- package/fesm2022/masterteam-components-toggle-field.mjs.map +1 -1
- package/fesm2022/masterteam-components.mjs +58 -21
- package/fesm2022/masterteam-components.mjs.map +1 -1
- package/icon-field/index.d.ts +2 -1
- package/index.d.ts +4 -1
- package/multi-select-field/index.d.ts +2 -1
- package/number-field/index.d.ts +2 -1
- package/package.json +29 -25
- package/select-field/index.d.ts +2 -1
- package/slider-field/index.d.ts +2 -1
- package/text-field/index.d.ts +2 -1
- package/textarea-field/index.d.ts +2 -1
- package/toast/index.d.ts +26 -0
- package/toggle-field/index.d.ts +2 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"masterteam-components-icon-field.mjs","sources":["../../../../packages/masterteam/components/icon-field/icon-field.ts","../../../../packages/masterteam/components/icon-field/icon-field.html","../../../../packages/masterteam/components/icon-field/masterteam-components-icon-field.ts"],"sourcesContent":["import {\n Component,\n signal,\n inject,\n input,\n ChangeDetectionStrategy,\n} from '@angular/core';\nimport {\n ControlValueAccessor,\n FormControl,\n FormsModule,\n NgControl,\n Validators,\n} from '@angular/forms';\nimport { Select } from 'primeng/select';\nimport * as mtIcons from '@masterteam/icons/assets/select-icons.json';\nimport { Icon, MTIcon } from '@masterteam/icons';\nimport { FieldValidation } from '@masterteam/components/field-validation';\nimport { isInvalid } from '@masterteam/components';\n\n@Component({\n selector: 'mt-icon-field',\n imports: [FormsModule, Select, Icon, FieldValidation],\n templateUrl: './icon-field.html',\n styleUrls: ['./icon-field.scss'],\n changeDetection: ChangeDetectionStrategy.OnPush,\n host: {\n class: 'grid gap-1',\n },\n})\nexport class IconField implements ControlValueAccessor {\n readonly label = input<string>('');\n\n icons: MTIcon[] = (mtIcons?.regular as MTIcon[]) ?? [];\n selectedIcon = signal<string | null>(null);\n requiredValidator = Validators.required;\n\n public ngControl = inject(NgControl, { self: true });\n\n isInvalid = isInvalid;\n\n constructor() {\n if (this.ngControl) {\n this.ngControl.valueAccessor = this;\n }\n }\n\n protected onTouched: () => void = () => {};\n private onChange: (icon: string) => void = () => {};\n\n writeValue(value: string) {\n this.selectedIcon.set(value);\n }\n\n registerOnChange(fn: any) {\n this.onChange = fn;\n }\n\n registerOnTouched(fn: any) {\n this.onTouched = fn;\n }\n\n onChangeIcon(icon: string) {\n this.selectedIcon.set(icon);\n this.onChange(icon);\n }\n\n public validate(c: FormControl) {\n return c.errors;\n }\n}\n","@if (label()) {\n <label\n (click)=\"dropdown.show(); dropdown.focus()\"\n [class.required]=\"ngControl?.control?.hasValidator(requiredValidator)\"\n [for]=\"ngControl?.name || label()\"\n >{{ label() }}</label\n >\n}\n<p-select\n #dropdown\n [options]=\"icons\"\n [filter]=\"false\"\n filterBy=\"name\"\n [inputId]=\"ngControl?.name ? ngControl?.name?.toString() : label()\"\n appendTo=\"body\"\n (onBlur)=\"onTouched()\"\n (ngModelChange)=\"onChangeIcon($event)\"\n [ngModel]=\"selectedIcon()\"\n [invalid]=\"isInvalid(ngControl?.control)\"\n placeholder=\"Select Icon\"\n styleClass=\"w-full\"\n panelStyleClass=\"icon-select-panel\"\n>\n <ng-template let-icon #selectedItem>\n @if (icon) {\n <div class=\"flex items-center justify-center text-2xl\">\n <mt-icon [icon]=\"icon\" />\n </div>\n } @else {\n <div class=\"flex items-center justify-center\">Select Icon</div>\n }\n </ng-template>\n <ng-template let-icon #item>\n <div class=\"w-full h-full flex items-center justify-center text-lg\">\n <mt-icon [icon]=\"icon\" />\n </div>\n </ng-template>\n</p-select>\n\n<mt-field-validation [control]=\"ngControl?.control\"></mt-field-validation>\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"masterteam-components-icon-field.mjs","sources":["../../../../packages/masterteam/components/icon-field/icon-field.ts","../../../../packages/masterteam/components/icon-field/icon-field.html","../../../../packages/masterteam/components/icon-field/masterteam-components-icon-field.ts"],"sourcesContent":["import {\n Component,\n signal,\n inject,\n input,\n ChangeDetectionStrategy,\n effect,\n} from '@angular/core';\nimport {\n ControlValueAccessor,\n FormControl,\n FormsModule,\n NgControl,\n Validators,\n} from '@angular/forms';\nimport { Select } from 'primeng/select';\nimport * as mtIcons from '@masterteam/icons/assets/select-icons.json';\nimport { Icon, MTIcon } from '@masterteam/icons';\nimport { FieldValidation } from '@masterteam/components/field-validation';\nimport { isInvalid } from '@masterteam/components';\n\n@Component({\n selector: 'mt-icon-field',\n imports: [FormsModule, Select, Icon, FieldValidation],\n templateUrl: './icon-field.html',\n styleUrls: ['./icon-field.scss'],\n changeDetection: ChangeDetectionStrategy.OnPush,\n host: {\n class: 'grid gap-1',\n },\n})\nexport class IconField implements ControlValueAccessor {\n readonly label = input<string>('');\n readonly required = input<boolean>(false);\n\n icons: MTIcon[] = (mtIcons?.regular as MTIcon[]) ?? [];\n selectedIcon = signal<string | null>(null);\n requiredValidator = Validators.required;\n\n public ngControl = inject(NgControl, { self: true });\n\n isInvalid = isInvalid;\n\n constructor() {\n if (this.ngControl) {\n this.ngControl.valueAccessor = this;\n }\n effect(() => {\n if (this.ngControl.control && this.required()) {\n this.ngControl.control.addValidators(Validators.required);\n this.ngControl.control.updateValueAndValidity();\n }\n });\n }\n\n protected onTouched: () => void = () => {};\n private onChange: (icon: string) => void = () => {};\n\n writeValue(value: string) {\n this.selectedIcon.set(value);\n }\n\n registerOnChange(fn: any) {\n this.onChange = fn;\n }\n\n registerOnTouched(fn: any) {\n this.onTouched = fn;\n }\n\n onChangeIcon(icon: string) {\n this.selectedIcon.set(icon);\n this.onChange(icon);\n }\n\n public validate(c: FormControl) {\n return c.errors;\n }\n}\n","@if (label()) {\n <label\n (click)=\"dropdown.show(); dropdown.focus()\"\n [class.required]=\"ngControl?.control?.hasValidator(requiredValidator)\"\n [for]=\"ngControl?.name || label()\"\n >{{ label() }}</label\n >\n}\n<p-select\n #dropdown\n [options]=\"icons\"\n [filter]=\"false\"\n filterBy=\"name\"\n [inputId]=\"ngControl?.name ? ngControl?.name?.toString() : label()\"\n appendTo=\"body\"\n (onBlur)=\"onTouched()\"\n (ngModelChange)=\"onChangeIcon($event)\"\n [ngModel]=\"selectedIcon()\"\n [invalid]=\"isInvalid(ngControl?.control)\"\n placeholder=\"Select Icon\"\n styleClass=\"w-full\"\n panelStyleClass=\"icon-select-panel\"\n>\n <ng-template let-icon #selectedItem>\n @if (icon) {\n <div class=\"flex items-center justify-center text-2xl\">\n <mt-icon [icon]=\"icon\" />\n </div>\n } @else {\n <div class=\"flex items-center justify-center\">Select Icon</div>\n }\n </ng-template>\n <ng-template let-icon #item>\n <div class=\"w-full h-full flex items-center justify-center text-lg\">\n <mt-icon [icon]=\"icon\" />\n </div>\n </ng-template>\n</p-select>\n\n<mt-field-validation [control]=\"ngControl?.control\"></mt-field-validation>\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;;;;MA+Ba,SAAS,CAAA;AACX,IAAA,KAAK,GAAG,KAAK,CAAS,EAAE,iDAAC;AACzB,IAAA,QAAQ,GAAG,KAAK,CAAU,KAAK,oDAAC;AAEzC,IAAA,KAAK,GAAc,OAAO,EAAE,OAAoB,IAAI,EAAE;AACtD,IAAA,YAAY,GAAG,MAAM,CAAgB,IAAI,wDAAC;AAC1C,IAAA,iBAAiB,GAAG,UAAU,CAAC,QAAQ;IAEhC,SAAS,GAAG,MAAM,CAAC,SAAS,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;IAEpD,SAAS,GAAG,SAAS;AAErB,IAAA,WAAA,GAAA;AACE,QAAA,IAAI,IAAI,CAAC,SAAS,EAAE;AAClB,YAAA,IAAI,CAAC,SAAS,CAAC,aAAa,GAAG,IAAI;QACrC;QACA,MAAM,CAAC,MAAK;YACV,IAAI,IAAI,CAAC,SAAS,CAAC,OAAO,IAAI,IAAI,CAAC,QAAQ,EAAE,EAAE;gBAC7C,IAAI,CAAC,SAAS,CAA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AA,EAAA,MAAA,EAAA,CAAA,SAAA,EAAA,SAAA,CAAA,EAAA,CAAA,EAAA,eAAA,EAAA,EAAA,CAAA,uBAAA,CAAA,MAAA,EAAA,CAAA;;2FAQzC,SAAS,EAAA,UAAA,EAAA,CAAA;kBAVrB,SAAS;AACE,YAAA,IAAA,EAAA,CAAA,EAAA,QAAA,EAAA,eAAe,EAAA,OAAA,EAChB,CAAC,WAAW,EAAE,MAAM,EAAE,IAAI,EAAE,eAAe,CAAC,EAAA,eAAA,EAGpC,uBAAuB,CAAC,MAAM,EAAA,IAAA,EACzC;AACJ,wBAAA,KAAK,EAAE,YAAY;AACpB,qBAAA,EAAA,QAAA,EAAA,usCAAA,EAAA,MAAA,EAAA,CAAA,+VAAA,CAAA,EAAA;;;AE7BH;;AAEG;;;;"}
|
|
@@ -16,11 +16,11 @@ class List {
|
|
|
16
16
|
return this.template() || this.itemTemplate() || null;
|
|
17
17
|
}, ...(ngDevMode ? [{ debugName: "effectiveTemplate" }] : []));
|
|
18
18
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.3", ngImport: i0, type: List, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
19
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.1.3", type: List, isStandalone: true, selector: "mt-list", inputs: { data: { classPropertyName: "data", publicName: "data", isSignal: true, isRequired: false, transformFunction: null }, separated: { classPropertyName: "separated", publicName: "separated", isSignal: true, isRequired: false, transformFunction: null }, template: { classPropertyName: "template", publicName: "template", isSignal: true, isRequired: false, transformFunction: null } }, queries: [{ propertyName: "itemTemplate", first: true, predicate: ["item"], descendants: true, isSignal: true }], ngImport: i0, template: "<div class=\"template-list\">\n @if (effectiveTemplate()) {\n @for (item of data(); track $index) {\n <div
|
|
19
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.1.3", type: List, isStandalone: true, selector: "mt-list", inputs: { data: { classPropertyName: "data", publicName: "data", isSignal: true, isRequired: false, transformFunction: null }, separated: { classPropertyName: "separated", publicName: "separated", isSignal: true, isRequired: false, transformFunction: null }, template: { classPropertyName: "template", publicName: "template", isSignal: true, isRequired: false, transformFunction: null } }, queries: [{ propertyName: "itemTemplate", first: true, predicate: ["item"], descendants: true, isSignal: true }], ngImport: i0, template: "<div class=\"template-list\">\n @if (effectiveTemplate()) {\n @for (item of data(); track $index) {\n <div\n class=\"border-(--p-content-border-color)\"\n [class.border-b]=\"!$last && separated()\"\n >\n <ng-container\n [ngTemplateOutlet]=\"effectiveTemplate()\"\n [ngTemplateOutletContext]=\"{\n $implicit: item,\n index: $index,\n first: $first,\n last: $last,\n count: $count,\n }\"\n >\n </ng-container>\n </div>\n }\n }\n</div>\n", dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }] });
|
|
20
20
|
}
|
|
21
21
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.3", ngImport: i0, type: List, decorators: [{
|
|
22
22
|
type: Component,
|
|
23
|
-
args: [{ selector: 'mt-list', standalone: true, imports: [CommonModule], template: "<div class=\"template-list\">\n @if (effectiveTemplate()) {\n @for (item of data(); track $index) {\n <div
|
|
23
|
+
args: [{ selector: 'mt-list', standalone: true, imports: [CommonModule], template: "<div class=\"template-list\">\n @if (effectiveTemplate()) {\n @for (item of data(); track $index) {\n <div\n class=\"border-(--p-content-border-color)\"\n [class.border-b]=\"!$last && separated()\"\n >\n <ng-container\n [ngTemplateOutlet]=\"effectiveTemplate()\"\n [ngTemplateOutletContext]=\"{\n $implicit: item,\n index: $index,\n first: $first,\n last: $last,\n count: $count,\n }\"\n >\n </ng-container>\n </div>\n }\n }\n</div>\n" }]
|
|
24
24
|
}] });
|
|
25
25
|
|
|
26
26
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"masterteam-components-list.mjs","sources":["../../../../packages/masterteam/components/list/list.ts","../../../../packages/masterteam/components/list/list.html","../../../../packages/masterteam/components/list/masterteam-components-list.ts"],"sourcesContent":["import {\n Component,\n input,\n TemplateRef,\n contentChild,\n computed,\n booleanAttribute,\n} from '@angular/core';\nimport { CommonModule } from '@angular/common';\n\nexport interface ListItem {\n [key: string]: any;\n}\n\n@Component({\n selector: 'mt-list',\n standalone: true,\n imports: [CommonModule],\n templateUrl: './list.html',\n})\nexport class List {\n // Input for the data array to loop through\n data = input<ListItem[]>([]);\n\n separated = input<boolean, unknown>(false, { transform: booleanAttribute });\n\n // Content child to get the template from ng-content\n itemTemplate = contentChild<TemplateRef<any>>('item');\n // Alternative input for template reference\n template = input<TemplateRef<any> | null>(null);\n\n // Computed signal for effective template (prioritize template() input over content child)\n effectiveTemplate = computed(() => {\n return this.template() || this.itemTemplate() || null;\n });\n}\n","<div class=\"template-list\">\n @if (effectiveTemplate()) {\n @for (item of data(); track $index) {\n <div
|
|
1
|
+
{"version":3,"file":"masterteam-components-list.mjs","sources":["../../../../packages/masterteam/components/list/list.ts","../../../../packages/masterteam/components/list/list.html","../../../../packages/masterteam/components/list/masterteam-components-list.ts"],"sourcesContent":["import {\n Component,\n input,\n TemplateRef,\n contentChild,\n computed,\n booleanAttribute,\n} from '@angular/core';\nimport { CommonModule } from '@angular/common';\n\nexport interface ListItem {\n [key: string]: any;\n}\n\n@Component({\n selector: 'mt-list',\n standalone: true,\n imports: [CommonModule],\n templateUrl: './list.html',\n})\nexport class List {\n // Input for the data array to loop through\n data = input<ListItem[]>([]);\n\n separated = input<boolean, unknown>(false, { transform: booleanAttribute });\n\n // Content child to get the template from ng-content\n itemTemplate = contentChild<TemplateRef<any>>('item');\n // Alternative input for template reference\n template = input<TemplateRef<any> | null>(null);\n\n // Computed signal for effective template (prioritize template() input over content child)\n effectiveTemplate = computed(() => {\n return this.template() || this.itemTemplate() || null;\n });\n}\n","<div class=\"template-list\">\n @if (effectiveTemplate()) {\n @for (item of data(); track $index) {\n <div\n class=\"border-(--p-content-border-color)\"\n [class.border-b]=\"!$last && separated()\"\n >\n <ng-container\n [ngTemplateOutlet]=\"effectiveTemplate()\"\n [ngTemplateOutletContext]=\"{\n $implicit: item,\n index: $index,\n first: $first,\n last: $last,\n count: $count,\n }\"\n >\n </ng-container>\n </div>\n }\n }\n</div>\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;MAoBa,IAAI,CAAA;;AAEf,IAAA,IAAI,GAAG,KAAK,CAAa,EAAE,gDAAC;AAE5B,IAAA,SAAS,GAAG,KAAK,CAAmB,KAAK,6CAAI,SAAS,EAAE,gBAAgB,EAAA,CAAA,GAAA,CAA7B,EAAE,SAAS,EAAE,gBAAgB,EAAE,GAAC;;AAG3E,IAAA,YAAY,GAAG,YAAY,CAAmB,MAAM,wDAAC;;AAErD,IAAA,QAAQ,GAAG,KAAK,CAA0B,IAAI,oDAAC;;AAG/C,IAAA,iBAAiB,GAAG,QAAQ,CAAC,MAAK;QAChC,OAAO,IAAI,CAAC,QAAQ,EAAE,IAAI,IAAI,CAAC,YAAY,EAAE,IAAI,IAAI;AACvD,IAAA,CAAC,6DAAC;uGAdS,IAAI,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,SAAA,EAAA,CAAA;2FAAJ,IAAI,EAAA,YAAA,EAAA,IAAA,EAAA,QAAA,EAAA,SAAA,EAAA,MAAA,EAAA,EAAA,IAAA,EAAA,EAAA,iBAAA,EAAA,MAAA,EAAA,UAAA,EAAA,MAAA,EAAA,QAAA,EAAA,IAAA,EAAA,UAAA,EAAA,KAAA,EAAA,iBAAA,EAAA,IAAA,EAAA,EAAA,SAAA,EAAA,EAAA,iBAAA,EAAA,WAAA,EAAA,UAAA,EAAA,WAAA,EAAA,QAAA,EAAA,IAAA,EAAA,UAAA,EAAA,KAAA,EAAA,iBAAA,EAAA,IAAA,EAAA,EAAA,QAAA,EAAA,EAAA,iBAAA,EAAA,UAAA,EAAA,UAAA,EAAA,UAAA,EAAA,QAAA,EAAA,IAAA,EAAA,UAAA,EAAA,KAAA,EAAA,iBAAA,EAAA,IAAA,EAAA,EAAA,EAAA,OAAA,EAAA,CAAA,EAAA,YAAA,EAAA,cAAA,EAAA,KAAA,EAAA,IAAA,EAAA,SAAA,EAAA,CAAA,MAAA,CAAA,EAAA,WAAA,EAAA,IAAA,EAAA,QAAA,EAAA,IAAA,EAAA,CAAA,EAAA,QAAA,EAAA,EAAA,EAAA,QAAA,ECpBjB,gkBAsBA,EAAA,YAAA,EAAA,CAAA,EAAA,IAAA,EAAA,UAAA,EAAA,IAAA,EDLY,YAAY,EAAA,EAAA,EAAA,IAAA,EAAA,WAAA,EAAA,IAAA,EAAA,EAAA,CAAA,gBAAA,EAAA,QAAA,EAAA,oBAAA,EAAA,MAAA,EAAA,CAAA,yBAAA,EAAA,kBAAA,EAAA,0BAAA,CAAA,EAAA,CAAA,EAAA,CAAA;;2FAGX,IAAI,EAAA,UAAA,EAAA,CAAA;kBANhB,SAAS;AACE,YAAA,IAAA,EAAA,CAAA,EAAA,QAAA,EAAA,SAAS,EAAA,UAAA,EACP,IAAI,EAAA,OAAA,EACP,CAAC,YAAY,CAAC,EAAA,QAAA,EAAA,gkBAAA,EAAA;;;AEjBzB;;AAEG;;;;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { input, EventEmitter, signal, inject, HostBinding, Output, ViewChild, ChangeDetectionStrategy, Component } from '@angular/core';
|
|
2
|
+
import { input, EventEmitter, signal, inject, effect, HostBinding, Output, ViewChild, ChangeDetectionStrategy, Component } from '@angular/core';
|
|
3
3
|
import * as i1 from '@angular/forms';
|
|
4
4
|
import { Validators, NgControl, FormsModule } from '@angular/forms';
|
|
5
5
|
import * as i2 from 'primeng/multiselect';
|
|
@@ -23,6 +23,7 @@ class MultiSelectField {
|
|
|
23
23
|
dataKey = input(...(ngDevMode ? [undefined, { debugName: "dataKey" }] : []));
|
|
24
24
|
showClear = input(false, ...(ngDevMode ? [{ debugName: "showClear" }] : []));
|
|
25
25
|
display = input('chip', ...(ngDevMode ? [{ debugName: "display" }] : []));
|
|
26
|
+
required = input(false, ...(ngDevMode ? [{ debugName: "required" }] : []));
|
|
26
27
|
onChange = new EventEmitter();
|
|
27
28
|
styleClass;
|
|
28
29
|
requiredValidator = Validators.required;
|
|
@@ -36,6 +37,12 @@ class MultiSelectField {
|
|
|
36
37
|
if (this.ngControl) {
|
|
37
38
|
this.ngControl.valueAccessor = this;
|
|
38
39
|
}
|
|
40
|
+
effect(() => {
|
|
41
|
+
if (this.ngControl.control && this.required()) {
|
|
42
|
+
this.ngControl.control.addValidators(Validators.required);
|
|
43
|
+
this.ngControl.control.updateValueAndValidity();
|
|
44
|
+
}
|
|
45
|
+
});
|
|
39
46
|
}
|
|
40
47
|
applyInputsToMultiSelect() {
|
|
41
48
|
Object.assign(this.multiSelect, this.pInputs());
|
|
@@ -70,7 +77,7 @@ class MultiSelectField {
|
|
|
70
77
|
this.disabled.set(disabled);
|
|
71
78
|
}
|
|
72
79
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.3", ngImport: i0, type: MultiSelectField, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
73
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.1.3", type: MultiSelectField, isStandalone: true, selector: "mt-multi-select-field", inputs: { field: { classPropertyName: "field", publicName: "field", isSignal: true, isRequired: false, transformFunction: null }, label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, placeholder: { classPropertyName: "placeholder", publicName: "placeholder", isSignal: true, isRequired: false, transformFunction: null }, class: { classPropertyName: "class", publicName: "class", isSignal: true, isRequired: false, transformFunction: null }, readonly: { classPropertyName: "readonly", publicName: "readonly", isSignal: true, isRequired: false, transformFunction: null }, pInputs: { classPropertyName: "pInputs", publicName: "pInputs", isSignal: true, isRequired: false, transformFunction: null }, options: { classPropertyName: "options", publicName: "options", isSignal: true, isRequired: false, transformFunction: null }, optionValue: { classPropertyName: "optionValue", publicName: "optionValue", isSignal: true, isRequired: false, transformFunction: null }, optionLabel: { classPropertyName: "optionLabel", publicName: "optionLabel", isSignal: true, isRequired: false, transformFunction: null }, filter: { classPropertyName: "filter", publicName: "filter", isSignal: true, isRequired: false, transformFunction: null }, filterBy: { classPropertyName: "filterBy", publicName: "filterBy", isSignal: true, isRequired: false, transformFunction: null }, dataKey: { classPropertyName: "dataKey", publicName: "dataKey", isSignal: true, isRequired: false, transformFunction: null }, showClear: { classPropertyName: "showClear", publicName: "showClear", isSignal: true, isRequired: false, transformFunction: null }, display: { classPropertyName: "display", publicName: "display", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { onChange: "onChange" }, host: { properties: { "class": "this.styleClass" }, classAttribute: "grid gap-1" }, viewQueries: [{ propertyName: "multiSelect", first: true, predicate: ["multiSelect"], descendants: true, static: true }], usesOnChanges: true, ngImport: i0, template: "@if (label()) {\n <label\n (click)=\"multiSelect?.show()\"\n [class.required]=\"ngControl?.control?.hasValidator(requiredValidator)\"\n [for]=\"ngControl?.name || label()\"\n >{{ label() }}</label\n >\n}\n<p-multiSelect\n #multiSelect\n [ngModel]=\"value()\"\n (ngModelChange)=\"onValueChange($event)\"\n [options]=\"options()\"\n [display]=\"display()\"\n [optionLabel]=\"optionLabel()\"\n [optionValue]=\"optionValue()\"\n (onBlur)=\"onTouched()\"\n [disabled]=\"disabled() || readonly()\"\n [inputId]=\"ngControl?.name?.toString() || label()\"\n [invalid]=\"isInvalid(ngControl?.control)\"\n placeholder=\"{{ placeholder() ?? label() ?? '' }}\"\n [filter]=\"filter()\"\n [filterBy]=\"filterBy()\"\n [dataKey]=\"dataKey()\"\n styleClass=\"w-full\"\n appendTo=\"body\"\n [showClear]=\"showClear()\"\n></p-multiSelect>\n\n<mt-field-validation [control]=\"ngControl?.control\"></mt-field-validation>\n", styles: [""], dependencies: [{ kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "ngmodule", type: MultiSelectModule }, { kind: "component", type: i2.MultiSelect, selector: "p-multiSelect, p-multiselect, p-multi-select", inputs: ["id", "ariaLabel", "styleClass", "panelStyle", "panelStyleClass", "inputId", "readonly", "group", "filter", "filterPlaceHolder", "filterLocale", "overlayVisible", "tabindex", "dataKey", "ariaLabelledBy", "displaySelectedLabel", "maxSelectedLabels", "selectionLimit", "selectedItemsLabel", "showToggleAll", "emptyFilterMessage", "emptyMessage", "resetFilterOnHide", "dropdownIcon", "chipIcon", "optionLabel", "optionValue", "optionDisabled", "optionGroupLabel", "optionGroupChildren", "showHeader", "filterBy", "scrollHeight", "lazy", "virtualScroll", "loading", "virtualScrollItemSize", "loadingIcon", "virtualScrollOptions", "overlayOptions", "ariaFilterLabel", "filterMatchMode", "tooltip", "tooltipPosition", "tooltipPositionStyle", "tooltipStyleClass", "autofocusFilter", "display", "autocomplete", "showClear", "autofocus", "placeholder", "options", "filterValue", "selectAll", "focusOnHover", "filterFields", "selectOnFocus", "autoOptionFocus", "highlightOnSelect", "size", "variant", "fluid", "appendTo"], outputs: ["onChange", "onFilter", "onFocus", "onBlur", "onClick", "onClear", "onPanelShow", "onPanelHide", "onLazyLoad", "onRemove", "onSelectAllChange"] }, { kind: "component", type: FieldValidation, selector: "mt-field-validation", inputs: ["control", "touched"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
80
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.1.3", type: MultiSelectField, isStandalone: true, selector: "mt-multi-select-field", inputs: { field: { classPropertyName: "field", publicName: "field", isSignal: true, isRequired: false, transformFunction: null }, label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, placeholder: { classPropertyName: "placeholder", publicName: "placeholder", isSignal: true, isRequired: false, transformFunction: null }, class: { classPropertyName: "class", publicName: "class", isSignal: true, isRequired: false, transformFunction: null }, readonly: { classPropertyName: "readonly", publicName: "readonly", isSignal: true, isRequired: false, transformFunction: null }, pInputs: { classPropertyName: "pInputs", publicName: "pInputs", isSignal: true, isRequired: false, transformFunction: null }, options: { classPropertyName: "options", publicName: "options", isSignal: true, isRequired: false, transformFunction: null }, optionValue: { classPropertyName: "optionValue", publicName: "optionValue", isSignal: true, isRequired: false, transformFunction: null }, optionLabel: { classPropertyName: "optionLabel", publicName: "optionLabel", isSignal: true, isRequired: false, transformFunction: null }, filter: { classPropertyName: "filter", publicName: "filter", isSignal: true, isRequired: false, transformFunction: null }, filterBy: { classPropertyName: "filterBy", publicName: "filterBy", isSignal: true, isRequired: false, transformFunction: null }, dataKey: { classPropertyName: "dataKey", publicName: "dataKey", isSignal: true, isRequired: false, transformFunction: null }, showClear: { classPropertyName: "showClear", publicName: "showClear", isSignal: true, isRequired: false, transformFunction: null }, display: { classPropertyName: "display", publicName: "display", isSignal: true, isRequired: false, transformFunction: null }, required: { classPropertyName: "required", publicName: "required", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { onChange: "onChange" }, host: { properties: { "class": "this.styleClass" }, classAttribute: "grid gap-1" }, viewQueries: [{ propertyName: "multiSelect", first: true, predicate: ["multiSelect"], descendants: true, static: true }], usesOnChanges: true, ngImport: i0, template: "@if (label()) {\n <label\n (click)=\"multiSelect?.show()\"\n [class.required]=\"ngControl?.control?.hasValidator(requiredValidator)\"\n [for]=\"ngControl?.name || label()\"\n >{{ label() }}</label\n >\n}\n<p-multiSelect\n #multiSelect\n [ngModel]=\"value()\"\n (ngModelChange)=\"onValueChange($event)\"\n [options]=\"options()\"\n [display]=\"display()\"\n [optionLabel]=\"optionLabel()\"\n [optionValue]=\"optionValue()\"\n (onBlur)=\"onTouched()\"\n [disabled]=\"disabled() || readonly()\"\n [inputId]=\"ngControl?.name?.toString() || label()\"\n [invalid]=\"isInvalid(ngControl?.control)\"\n placeholder=\"{{ placeholder() ?? label() ?? '' }}\"\n [filter]=\"filter()\"\n [filterBy]=\"filterBy()\"\n [dataKey]=\"dataKey()\"\n styleClass=\"w-full\"\n appendTo=\"body\"\n [showClear]=\"showClear()\"\n></p-multiSelect>\n\n<mt-field-validation [control]=\"ngControl?.control\"></mt-field-validation>\n", styles: [""], dependencies: [{ kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "ngmodule", type: MultiSelectModule }, { kind: "component", type: i2.MultiSelect, selector: "p-multiSelect, p-multiselect, p-multi-select", inputs: ["id", "ariaLabel", "styleClass", "panelStyle", "panelStyleClass", "inputId", "readonly", "group", "filter", "filterPlaceHolder", "filterLocale", "overlayVisible", "tabindex", "dataKey", "ariaLabelledBy", "displaySelectedLabel", "maxSelectedLabels", "selectionLimit", "selectedItemsLabel", "showToggleAll", "emptyFilterMessage", "emptyMessage", "resetFilterOnHide", "dropdownIcon", "chipIcon", "optionLabel", "optionValue", "optionDisabled", "optionGroupLabel", "optionGroupChildren", "showHeader", "filterBy", "scrollHeight", "lazy", "virtualScroll", "loading", "virtualScrollItemSize", "loadingIcon", "virtualScrollOptions", "overlayOptions", "ariaFilterLabel", "filterMatchMode", "tooltip", "tooltipPosition", "tooltipPositionStyle", "tooltipStyleClass", "autofocusFilter", "display", "autocomplete", "showClear", "autofocus", "placeholder", "options", "filterValue", "selectAll", "focusOnHover", "filterFields", "selectOnFocus", "autoOptionFocus", "highlightOnSelect", "size", "variant", "fluid", "appendTo"], outputs: ["onChange", "onFilter", "onFocus", "onBlur", "onClick", "onClear", "onPanelShow", "onPanelHide", "onLazyLoad", "onRemove", "onSelectAllChange"] }, { kind: "component", type: FieldValidation, selector: "mt-field-validation", inputs: ["control", "touched"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
74
81
|
}
|
|
75
82
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.3", ngImport: i0, type: MultiSelectField, decorators: [{
|
|
76
83
|
type: Component,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"masterteam-components-multi-select-field.mjs","sources":["../../../../packages/masterteam/components/multi-select-field/multi-select-field.ts","../../../../packages/masterteam/components/multi-select-field/multi-select-field.html","../../../../packages/masterteam/components/multi-select-field/masterteam-components-multi-select-field.ts"],"sourcesContent":["import {\n Component,\n EventEmitter,\n HostBinding,\n OnChanges,\n OnInit,\n Output,\n SimpleChanges,\n ViewChild,\n signal,\n input,\n inject,\n ChangeDetectionStrategy,\n} from '@angular/core';\nimport {\n ControlValueAccessor,\n FormsModule,\n NgControl,\n Validators,\n} from '@angular/forms';\nimport { MultiSelect } from 'primeng/multiselect';\nimport { MultiSelectModule } from 'primeng/multiselect';\nimport { FieldValidation } from '@masterteam/components/field-validation';\nimport { isInvalid } from '@masterteam/components';\n\n@Component({\n selector: 'mt-multi-select-field',\n templateUrl: './multi-select-field.html',\n styleUrls: ['./multi-select-field.scss'],\n standalone: true,\n imports: [FormsModule, MultiSelectModule, FieldValidation],\n changeDetection: ChangeDetectionStrategy.OnPush,\n host: {\n class: 'grid gap-1',\n },\n})\nexport class MultiSelectField\n implements ControlValueAccessor, OnInit, OnChanges\n{\n @ViewChild('multiSelect', { static: true })\n multiSelect: MultiSelect;\n\n readonly field = input<boolean>(true);\n readonly label = input<string>();\n readonly placeholder = input<string>();\n readonly class = input<string>('');\n readonly readonly = input<boolean>(false);\n readonly pInputs = input<Partial<MultiSelect>>();\n readonly options = input<any[]>();\n readonly optionValue = input<string>();\n readonly optionLabel = input<string>();\n readonly filter = input<boolean>(false);\n readonly filterBy = input<string>();\n readonly dataKey = input<string>();\n readonly showClear = input<boolean>(false);\n readonly display = input<string>('chip');\n @Output() onChange: EventEmitter<any> = new EventEmitter();\n\n @HostBinding('class') styleClass: string;\n\n requiredValidator = Validators.required;\n value = signal<any>(null);\n disabled = signal<boolean>(false);\n\n onTouched: () => void = () => {};\n onModelChange: (value: any) => void = () => {};\n\n public ngControl = inject(NgControl, { self: true });\n\n isInvalid = isInvalid;\n\n constructor() {\n if (this.ngControl) {\n this.ngControl.valueAccessor = this;\n }\n }\n\n applyInputsToMultiSelect() {\n Object.assign(this.multiSelect, this.pInputs());\n }\n\n ngOnInit() {\n this.styleClass = this.class();\n if (this.pInputs()) {\n this.applyInputsToMultiSelect();\n }\n }\n onValueChange(value: any) {\n this.onModelChange(value);\n this.value.set(value);\n this.onChange.emit(value);\n }\n ngOnChanges(changes: SimpleChanges) {\n if (changes['pInputs']) {\n this.applyInputsToMultiSelect();\n }\n }\n\n writeValue(value: any) {\n this.value.set(value);\n this.multiSelect.writeValue(value);\n }\n\n registerOnChange(fn: any) {\n this.onModelChange = fn;\n }\n\n registerOnTouched(fn: any) {\n this.onTouched = fn;\n }\n\n setDisabledState(disabled: boolean) {\n this.disabled.set(disabled);\n }\n}\n","@if (label()) {\n <label\n (click)=\"multiSelect?.show()\"\n [class.required]=\"ngControl?.control?.hasValidator(requiredValidator)\"\n [for]=\"ngControl?.name || label()\"\n >{{ label() }}</label\n >\n}\n<p-multiSelect\n #multiSelect\n [ngModel]=\"value()\"\n (ngModelChange)=\"onValueChange($event)\"\n [options]=\"options()\"\n [display]=\"display()\"\n [optionLabel]=\"optionLabel()\"\n [optionValue]=\"optionValue()\"\n (onBlur)=\"onTouched()\"\n [disabled]=\"disabled() || readonly()\"\n [inputId]=\"ngControl?.name?.toString() || label()\"\n [invalid]=\"isInvalid(ngControl?.control)\"\n placeholder=\"{{ placeholder() ?? label() ?? '' }}\"\n [filter]=\"filter()\"\n [filterBy]=\"filterBy()\"\n [dataKey]=\"dataKey()\"\n styleClass=\"w-full\"\n appendTo=\"body\"\n [showClear]=\"showClear()\"\n></p-multiSelect>\n\n<mt-field-validation [control]=\"ngControl?.control\"></mt-field-validation>\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;;;
|
|
1
|
+
{"version":3,"file":"masterteam-components-multi-select-field.mjs","sources":["../../../../packages/masterteam/components/multi-select-field/multi-select-field.ts","../../../../packages/masterteam/components/multi-select-field/multi-select-field.html","../../../../packages/masterteam/components/multi-select-field/masterteam-components-multi-select-field.ts"],"sourcesContent":["import {\n Component,\n EventEmitter,\n HostBinding,\n OnChanges,\n OnInit,\n Output,\n SimpleChanges,\n ViewChild,\n signal,\n input,\n inject,\n ChangeDetectionStrategy,\n effect,\n} from '@angular/core';\nimport {\n ControlValueAccessor,\n FormsModule,\n NgControl,\n Validators,\n} from '@angular/forms';\nimport { MultiSelect } from 'primeng/multiselect';\nimport { MultiSelectModule } from 'primeng/multiselect';\nimport { FieldValidation } from '@masterteam/components/field-validation';\nimport { isInvalid } from '@masterteam/components';\n\n@Component({\n selector: 'mt-multi-select-field',\n templateUrl: './multi-select-field.html',\n styleUrls: ['./multi-select-field.scss'],\n standalone: true,\n imports: [FormsModule, MultiSelectModule, FieldValidation],\n changeDetection: ChangeDetectionStrategy.OnPush,\n host: {\n class: 'grid gap-1',\n },\n})\nexport class MultiSelectField\n implements ControlValueAccessor, OnInit, OnChanges\n{\n @ViewChild('multiSelect', { static: true })\n multiSelect: MultiSelect;\n\n readonly field = input<boolean>(true);\n readonly label = input<string>();\n readonly placeholder = input<string>();\n readonly class = input<string>('');\n readonly readonly = input<boolean>(false);\n readonly pInputs = input<Partial<MultiSelect>>();\n readonly options = input<any[]>();\n readonly optionValue = input<string>();\n readonly optionLabel = input<string>();\n readonly filter = input<boolean>(false);\n readonly filterBy = input<string>();\n readonly dataKey = input<string>();\n readonly showClear = input<boolean>(false);\n readonly display = input<string>('chip');\n readonly required = input<boolean>(false);\n\n @Output() onChange: EventEmitter<any> = new EventEmitter();\n\n @HostBinding('class') styleClass: string;\n\n requiredValidator = Validators.required;\n value = signal<any>(null);\n disabled = signal<boolean>(false);\n\n onTouched: () => void = () => {};\n onModelChange: (value: any) => void = () => {};\n\n public ngControl = inject(NgControl, { self: true });\n\n isInvalid = isInvalid;\n\n constructor() {\n if (this.ngControl) {\n this.ngControl.valueAccessor = this;\n }\n effect(() => {\n if (this.ngControl.control && this.required()) {\n this.ngControl.control.addValidators(Validators.required);\n this.ngControl.control.updateValueAndValidity();\n }\n });\n }\n\n applyInputsToMultiSelect() {\n Object.assign(this.multiSelect, this.pInputs());\n }\n\n ngOnInit() {\n this.styleClass = this.class();\n if (this.pInputs()) {\n this.applyInputsToMultiSelect();\n }\n }\n onValueChange(value: any) {\n this.onModelChange(value);\n this.value.set(value);\n this.onChange.emit(value);\n }\n ngOnChanges(changes: SimpleChanges) {\n if (changes['pInputs']) {\n this.applyInputsToMultiSelect();\n }\n }\n\n writeValue(value: any) {\n this.value.set(value);\n this.multiSelect.writeValue(value);\n }\n\n registerOnChange(fn: any) {\n this.onModelChange = fn;\n }\n\n registerOnTouched(fn: any) {\n this.onTouched = fn;\n }\n\n setDisabledState(disabled: boolean) {\n this.disabled.set(disabled);\n }\n}\n","@if (label()) {\n <label\n (click)=\"multiSelect?.show()\"\n [class.required]=\"ngControl?.control?.hasValidator(requiredValidator)\"\n [for]=\"ngControl?.name || label()\"\n >{{ label() }}</label\n >\n}\n<p-multiSelect\n #multiSelect\n [ngModel]=\"value()\"\n (ngModelChange)=\"onValueChange($event)\"\n [options]=\"options()\"\n [display]=\"display()\"\n [optionLabel]=\"optionLabel()\"\n [optionValue]=\"optionValue()\"\n (onBlur)=\"onTouched()\"\n [disabled]=\"disabled() || readonly()\"\n [inputId]=\"ngControl?.name?.toString() || label()\"\n [invalid]=\"isInvalid(ngControl?.control)\"\n placeholder=\"{{ placeholder() ?? label() ?? '' }}\"\n [filter]=\"filter()\"\n [filterBy]=\"filterBy()\"\n [dataKey]=\"dataKey()\"\n styleClass=\"w-full\"\n appendTo=\"body\"\n [showClear]=\"showClear()\"\n></p-multiSelect>\n\n<mt-field-validation [control]=\"ngControl?.control\"></mt-field-validation>\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;;;MAqCa,gBAAgB,CAAA;AAI3B,IAAA,WAAW;AAEF,IAAA,KAAK,GAAG,KAAK,CAAU,IAAI,iDAAC;IAC5B,KAAK,GAAG,KAAK,CAAA,IAAA,SAAA,GAAA,CAAA,SAAA,EAAA,EAAA,SAAA,EAAA,OAAA,EAAA,CAAA,GAAA,EAAA,CAAA,CAAU;IACvB,WAAW,GAAG,KAAK,CAAA,IAAA,SAAA,GAAA,CAAA,SAAA,EAAA,EAAA,SAAA,EAAA,aAAA,EAAA,CAAA,GAAA,EAAA,CAAA,CAAU;AAC7B,IAAA,KAAK,GAAG,KAAK,CAAS,EAAE,iDAAC;AACzB,IAAA,QAAQ,GAAG,KAAK,CAAU,KAAK,oDAAC;IAChC,OAAO,GAAG,KAAK,CAAA,IAAA,SAAA,GAAA,CAAA,SAAA,EAAA,EAAA,SAAA,EAAA,SAAA,EAAA,CAAA,GAAA,EAAA,CAAA,CAAwB;IACvC,OAAO,GAAG,KAAK,CAAA,IAAA,SAAA,GAAA,CAAA,SAAA,EAAA,EAAA,SAAA,EAAA,SAAA,EAAA,CAAA,GAAA,EAAA,CAAA,CAAS;IACxB,WAAW,GAAG,KAAK,CAAA,IAAA,SAAA,GAAA,CAAA,SAAA,EAAA,EAAA,SAAA,EAAA,aAAA,EAAA,CAAA,GAAA,EAAA,CAAA,CAAU;IAC7B,WAAW,GAAG,KAAK,CAAA,IAAA,SAAA,GAAA,CAAA,SAAA,EAAA,EAAA,SAAA,EAAA,aAAA,EAAA,CAAA,GAA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AE,MAAM,EAAE,IAAI,EAAE;gBAmBhC,QAAQ,EAAA,CAAA;sBAAjB;gBAEqB,UAAU,EAAA,CAAA;sBAA/B,WAAW;uBAAC,OAAO;;;AE7DtB;;AAEG;;;;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { input, inject, signal, HostBinding, ViewChild, ChangeDetectionStrategy, Component } from '@angular/core';
|
|
2
|
+
import { input, inject, signal, effect, HostBinding, ViewChild, ChangeDetectionStrategy, Component } from '@angular/core';
|
|
3
3
|
import * as i1 from '@angular/forms';
|
|
4
4
|
import { NgControl, Validators, FormsModule } from '@angular/forms';
|
|
5
5
|
import * as i2 from 'primeng/inputnumber';
|
|
@@ -20,6 +20,7 @@ class NumberField {
|
|
|
20
20
|
// TODO: wait for primeng to allow undefined and remove these numbers
|
|
21
21
|
min = input(-999999999999999, ...(ngDevMode ? [{ debugName: "min" }] : []));
|
|
22
22
|
max = input(999999999999999, ...(ngDevMode ? [{ debugName: "max" }] : []));
|
|
23
|
+
required = input(false, ...(ngDevMode ? [{ debugName: "required" }] : []));
|
|
23
24
|
styleClass;
|
|
24
25
|
ngControl = inject(NgControl, { self: true });
|
|
25
26
|
isInvalid = isInvalid;
|
|
@@ -32,6 +33,12 @@ class NumberField {
|
|
|
32
33
|
if (this.ngControl) {
|
|
33
34
|
this.ngControl.valueAccessor = this;
|
|
34
35
|
}
|
|
36
|
+
effect(() => {
|
|
37
|
+
if (this.ngControl.control && this.required()) {
|
|
38
|
+
this.ngControl.control.addValidators(Validators.required);
|
|
39
|
+
this.ngControl.control.updateValueAndValidity();
|
|
40
|
+
}
|
|
41
|
+
});
|
|
35
42
|
}
|
|
36
43
|
applyInputsToInputNumber() {
|
|
37
44
|
Object.assign(this.inputNumber, this.pInputs());
|
|
@@ -64,7 +71,7 @@ class NumberField {
|
|
|
64
71
|
this.disabled.set(disabled);
|
|
65
72
|
}
|
|
66
73
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.3", ngImport: i0, type: NumberField, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
67
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.1.3", type: NumberField, isStandalone: true, selector: "mt-number-field", inputs: { field: { classPropertyName: "field", publicName: "field", isSignal: true, isRequired: false, transformFunction: null }, label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, placeholder: { classPropertyName: "placeholder", publicName: "placeholder", isSignal: true, isRequired: false, transformFunction: null }, class: { classPropertyName: "class", publicName: "class", isSignal: true, isRequired: false, transformFunction: null }, readonly: { classPropertyName: "readonly", publicName: "readonly", isSignal: true, isRequired: false, transformFunction: null }, pInputs: { classPropertyName: "pInputs", publicName: "pInputs", isSignal: true, isRequired: false, transformFunction: null }, format: { classPropertyName: "format", publicName: "format", isSignal: true, isRequired: false, transformFunction: null }, maxFractionDigits: { classPropertyName: "maxFractionDigits", publicName: "maxFractionDigits", 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 } }, host: { properties: { "class": "this.styleClass" }, classAttribute: "grid gap-1" }, viewQueries: [{ propertyName: "inputNumber", first: true, predicate: ["inputNumber"], descendants: true, static: true }], usesOnChanges: true, ngImport: i0, template: "@if (label()) {\n <label\n [class.required]=\"ngControl?.control?.hasValidator(requiredValidator)\"\n [for]=\"ngControl?.name || label()\"\n >{{ label() }}</label\n >\n}\n<p-inputnumber\n #inputNumber\n [ngModel]=\"value()\"\n (ngModelChange)=\"onValueChange($event)\"\n (onBlur)=\"onTouched()\"\n [disabled]=\"disabled() || readonly()\"\n [inputId]=\"ngControl?.name ? ngControl?.name?.toString() : label()\"\n [format]=\"format()\"\n [min]=\"min()\"\n [max]=\"max()\"\n [maxFractionDigits]=\"maxFractionDigits()\"\n [invalid]=\"isInvalid(ngControl?.control)\"\n placeholder=\"{{ placeholder() ?? label() ?? '' }}\"\n styleClass=\"w-full\"\n inputStyleClass=\"w-full\"\n></p-inputnumber>\n\n<mt-field-validation [control]=\"ngControl?.control\"></mt-field-validation>\n", styles: [":host p-inputNumber{display:block;width:100%}:host p-inputNumber input{width:100%}\n"], dependencies: [{ kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "ngmodule", type: InputNumberModule }, { kind: "component", type: i2.InputNumber, selector: "p-inputNumber, p-inputnumber, p-input-number", inputs: ["showButtons", "format", "buttonLayout", "inputId", "styleClass", "placeholder", "tabindex", "title", "ariaLabelledBy", "ariaDescribedBy", "ariaLabel", "ariaRequired", "autocomplete", "incrementButtonClass", "decrementButtonClass", "incrementButtonIcon", "decrementButtonIcon", "readonly", "allowEmpty", "locale", "localeMatcher", "mode", "currency", "currencyDisplay", "useGrouping", "minFractionDigits", "maxFractionDigits", "prefix", "suffix", "inputStyle", "inputStyleClass", "showClear", "autofocus"], outputs: ["onInput", "onFocus", "onBlur", "onKeyDown", "onClear"] }, { kind: "component", type: FieldValidation, selector: "mt-field-validation", inputs: ["control", "touched"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
74
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.1.3", type: NumberField, isStandalone: true, selector: "mt-number-field", inputs: { field: { classPropertyName: "field", publicName: "field", isSignal: true, isRequired: false, transformFunction: null }, label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, placeholder: { classPropertyName: "placeholder", publicName: "placeholder", isSignal: true, isRequired: false, transformFunction: null }, class: { classPropertyName: "class", publicName: "class", isSignal: true, isRequired: false, transformFunction: null }, readonly: { classPropertyName: "readonly", publicName: "readonly", isSignal: true, isRequired: false, transformFunction: null }, pInputs: { classPropertyName: "pInputs", publicName: "pInputs", isSignal: true, isRequired: false, transformFunction: null }, format: { classPropertyName: "format", publicName: "format", isSignal: true, isRequired: false, transformFunction: null }, maxFractionDigits: { classPropertyName: "maxFractionDigits", publicName: "maxFractionDigits", 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 }, required: { classPropertyName: "required", publicName: "required", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class": "this.styleClass" }, classAttribute: "grid gap-1" }, viewQueries: [{ propertyName: "inputNumber", first: true, predicate: ["inputNumber"], descendants: true, static: true }], usesOnChanges: true, ngImport: i0, template: "@if (label()) {\n <label\n [class.required]=\"ngControl?.control?.hasValidator(requiredValidator)\"\n [for]=\"ngControl?.name || label()\"\n >{{ label() }}</label\n >\n}\n<p-inputnumber\n #inputNumber\n [ngModel]=\"value()\"\n (ngModelChange)=\"onValueChange($event)\"\n (onBlur)=\"onTouched()\"\n [disabled]=\"disabled() || readonly()\"\n [inputId]=\"ngControl?.name ? ngControl?.name?.toString() : label()\"\n [format]=\"format()\"\n [min]=\"min()\"\n [max]=\"max()\"\n [maxFractionDigits]=\"maxFractionDigits()\"\n [invalid]=\"isInvalid(ngControl?.control)\"\n placeholder=\"{{ placeholder() ?? label() ?? '' }}\"\n styleClass=\"w-full\"\n inputStyleClass=\"w-full\"\n></p-inputnumber>\n\n<mt-field-validation [control]=\"ngControl?.control\"></mt-field-validation>\n", styles: [":host p-inputNumber{display:block;width:100%}:host p-inputNumber input{width:100%}\n"], dependencies: [{ kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "ngmodule", type: InputNumberModule }, { kind: "component", type: i2.InputNumber, selector: "p-inputNumber, p-inputnumber, p-input-number", inputs: ["showButtons", "format", "buttonLayout", "inputId", "styleClass", "placeholder", "tabindex", "title", "ariaLabelledBy", "ariaDescribedBy", "ariaLabel", "ariaRequired", "autocomplete", "incrementButtonClass", "decrementButtonClass", "incrementButtonIcon", "decrementButtonIcon", "readonly", "allowEmpty", "locale", "localeMatcher", "mode", "currency", "currencyDisplay", "useGrouping", "minFractionDigits", "maxFractionDigits", "prefix", "suffix", "inputStyle", "inputStyleClass", "showClear", "autofocus"], outputs: ["onInput", "onFocus", "onBlur", "onKeyDown", "onClear"] }, { kind: "component", type: FieldValidation, selector: "mt-field-validation", inputs: ["control", "touched"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
68
75
|
}
|
|
69
76
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.3", ngImport: i0, type: NumberField, decorators: [{
|
|
70
77
|
type: Component,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"masterteam-components-number-field.mjs","sources":["../../../../packages/masterteam/components/number-field/number-field.ts","../../../../packages/masterteam/components/number-field/number-field.html","../../../../packages/masterteam/components/number-field/masterteam-components-number-field.ts"],"sourcesContent":["import {\n Component,\n HostBinding,\n OnChanges,\n OnInit,\n SimpleChanges,\n ViewChild,\n signal,\n input,\n inject,\n ChangeDetectionStrategy,\n} from '@angular/core';\nimport {\n ControlValueAccessor,\n FormsModule,\n NgControl,\n Validators,\n} from '@angular/forms';\nimport { InputNumberModule, InputNumber } from 'primeng/inputnumber';\nimport { FieldValidation } from '@masterteam/components/field-validation';\nimport { isInvalid } from '@masterteam/components';\n\n@Component({\n selector: 'mt-number-field',\n standalone: true,\n imports: [FormsModule, InputNumberModule, FieldValidation],\n templateUrl: './number-field.html',\n styleUrls: ['./number-field.scss'],\n changeDetection: ChangeDetectionStrategy.OnPush,\n host: {\n class: 'grid gap-1',\n },\n})\nexport class NumberField implements ControlValueAccessor, OnInit, OnChanges {\n @ViewChild('inputNumber', { static: true })\n inputNumber: InputNumber;\n\n readonly field = input<boolean>(true);\n readonly label = input<string>();\n readonly placeholder = input<string>();\n readonly class = input<string>('');\n readonly readonly = input<boolean>(false);\n readonly pInputs = input<Partial<InputNumber>>();\n readonly format = input<boolean>(false);\n readonly maxFractionDigits = input<number>(2);\n // TODO: wait for primeng to allow undefined and remove these numbers\n readonly min = input<number>(-999999999999999);\n readonly max = input<number>(999999999999999);\n\n @HostBinding('class') styleClass: string;\n\n public ngControl = inject(NgControl, { self: true });\n\n isInvalid = isInvalid;\n\n requiredValidator = Validators.required;\n value = signal<number | null>(null);\n disabled = signal<boolean>(false);\n\n onTouched: () => void = () => {};\n onModelChange: (value: number | null) => void = () => {};\n\n constructor() {\n if (this.ngControl) {\n this.ngControl.valueAccessor = this;\n }\n }\n\n applyInputsToInputNumber() {\n Object.assign(this.inputNumber, this.pInputs());\n }\n\n ngOnInit() {\n this.styleClass = this.class();\n if (this.pInputs()) {\n this.applyInputsToInputNumber();\n }\n }\n onValueChange(value: number | null) {\n this.onModelChange(value);\n this.value.set(value);\n }\n ngOnChanges(changes: SimpleChanges) {\n if (changes['pInputs']) {\n this.applyInputsToInputNumber();\n }\n }\n\n writeValue(value: number | null) {\n this.value.set(value);\n }\n\n registerOnChange(fn: any) {\n this.onModelChange = fn;\n }\n\n registerOnTouched(fn: any) {\n this.onTouched = fn;\n }\n\n setDisabledState(disabled: boolean) {\n this.disabled.set(disabled);\n }\n}\n","@if (label()) {\n <label\n [class.required]=\"ngControl?.control?.hasValidator(requiredValidator)\"\n [for]=\"ngControl?.name || label()\"\n >{{ label() }}</label\n >\n}\n<p-inputnumber\n #inputNumber\n [ngModel]=\"value()\"\n (ngModelChange)=\"onValueChange($event)\"\n (onBlur)=\"onTouched()\"\n [disabled]=\"disabled() || readonly()\"\n [inputId]=\"ngControl?.name ? ngControl?.name?.toString() : label()\"\n [format]=\"format()\"\n [min]=\"min()\"\n [max]=\"max()\"\n [maxFractionDigits]=\"maxFractionDigits()\"\n [invalid]=\"isInvalid(ngControl?.control)\"\n placeholder=\"{{ placeholder() ?? label() ?? '' }}\"\n styleClass=\"w-full\"\n inputStyleClass=\"w-full\"\n></p-inputnumber>\n\n<mt-field-validation [control]=\"ngControl?.control\"></mt-field-validation>\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;;;
|
|
1
|
+
{"version":3,"file":"masterteam-components-number-field.mjs","sources":["../../../../packages/masterteam/components/number-field/number-field.ts","../../../../packages/masterteam/components/number-field/number-field.html","../../../../packages/masterteam/components/number-field/masterteam-components-number-field.ts"],"sourcesContent":["import {\n Component,\n HostBinding,\n OnChanges,\n OnInit,\n SimpleChanges,\n ViewChild,\n signal,\n input,\n inject,\n ChangeDetectionStrategy,\n effect,\n} from '@angular/core';\nimport {\n ControlValueAccessor,\n FormsModule,\n NgControl,\n Validators,\n} from '@angular/forms';\nimport { InputNumberModule, InputNumber } from 'primeng/inputnumber';\nimport { FieldValidation } from '@masterteam/components/field-validation';\nimport { isInvalid } from '@masterteam/components';\n\n@Component({\n selector: 'mt-number-field',\n standalone: true,\n imports: [FormsModule, InputNumberModule, FieldValidation],\n templateUrl: './number-field.html',\n styleUrls: ['./number-field.scss'],\n changeDetection: ChangeDetectionStrategy.OnPush,\n host: {\n class: 'grid gap-1',\n },\n})\nexport class NumberField implements ControlValueAccessor, OnInit, OnChanges {\n @ViewChild('inputNumber', { static: true })\n inputNumber: InputNumber;\n\n readonly field = input<boolean>(true);\n readonly label = input<string>();\n readonly placeholder = input<string>();\n readonly class = input<string>('');\n readonly readonly = input<boolean>(false);\n readonly pInputs = input<Partial<InputNumber>>();\n readonly format = input<boolean>(false);\n readonly maxFractionDigits = input<number>(2);\n // TODO: wait for primeng to allow undefined and remove these numbers\n readonly min = input<number>(-999999999999999);\n readonly max = input<number>(999999999999999);\n readonly required = input<boolean>(false);\n\n @HostBinding('class') styleClass: string;\n\n public ngControl = inject(NgControl, { self: true });\n\n isInvalid = isInvalid;\n\n requiredValidator = Validators.required;\n value = signal<number | null>(null);\n disabled = signal<boolean>(false);\n\n onTouched: () => void = () => {};\n onModelChange: (value: number | null) => void = () => {};\n\n constructor() {\n if (this.ngControl) {\n this.ngControl.valueAccessor = this;\n }\n effect(() => {\n if (this.ngControl.control && this.required()) {\n this.ngControl.control.addValidators(Validators.required);\n this.ngControl.control.updateValueAndValidity();\n }\n });\n }\n\n applyInputsToInputNumber() {\n Object.assign(this.inputNumber, this.pInputs());\n }\n\n ngOnInit() {\n this.styleClass = this.class();\n if (this.pInputs()) {\n this.applyInputsToInputNumber();\n }\n }\n onValueChange(value: number | null) {\n this.onModelChange(value);\n this.value.set(value);\n }\n ngOnChanges(changes: SimpleChanges) {\n if (changes['pInputs']) {\n this.applyInputsToInputNumber();\n }\n }\n\n writeValue(value: number | null) {\n this.value.set(value);\n }\n\n registerOnChange(fn: any) {\n this.onModelChange = fn;\n }\n\n registerOnTouched(fn: any) {\n this.onTouched = fn;\n }\n\n setDisabledState(disabled: boolean) {\n this.disabled.set(disabled);\n }\n}\n","@if (label()) {\n <label\n [class.required]=\"ngControl?.control?.hasValidator(requiredValidator)\"\n [for]=\"ngControl?.name || label()\"\n >{{ label() }}</label\n >\n}\n<p-inputnumber\n #inputNumber\n [ngModel]=\"value()\"\n (ngModelChange)=\"onValueChange($event)\"\n (onBlur)=\"onTouched()\"\n [disabled]=\"disabled() || readonly()\"\n [inputId]=\"ngControl?.name ? ngControl?.name?.toString() : label()\"\n [format]=\"format()\"\n [min]=\"min()\"\n [max]=\"max()\"\n [maxFractionDigits]=\"maxFractionDigits()\"\n [invalid]=\"isInvalid(ngControl?.control)\"\n placeholder=\"{{ placeholder() ?? label() ?? '' }}\"\n styleClass=\"w-full\"\n inputStyleClass=\"w-full\"\n></p-inputnumber>\n\n<mt-field-validation [control]=\"ngControl?.control\"></mt-field-validation>\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;;;MAkCa,WAAW,CAAA;AAEtB,IAAA,WAAW;AAEF,IAAA,KAAK,GAAG,KAAK,CAAU,IAAI,iDAAC;IAC5B,KAAK,GAAG,KAAK,CAAA,IAAA,SAAA,GAAA,CAAA,SAAA,EAAA,EAAA,SAAA,EAAA,OAAA,EAAA,CAAA,GAAA,EAAA,CAAA,CAAU;IACvB,WAAW,GAAG,KAAK,CAAA,IAAA,SAAA,GAAA,CAAA,SAAA,EAAA,EAAA,SAAA,EAAA,aAAA,EAAA,CAAA,GAAA,EAAA,CAAA,CAAU;AAC7B,IAAA,KAAK,GAAG,KAAK,CAAS,EAAE,iDAAC;AACzB,IAAA,QAAQ,GAAG,KAAK,CAAU,KAAK,oDAAC;IAChC,OAAO,GAAG,KAAK,CAAA,IAAA,SAAA,GAAA,CAAA,SAAA,EAAA,EAAA,SAAA,EAAA,SAAA,EAAA,CAAA,GAAA,EAAA,CAAA,CAAwB;AACvC,IAAA,MAAM,GAAG,KAAK,CAAU,KAAK,kDAAC;AAC9B,IAAA,iBAAiB,GAAG,KAAK,CAAS,CAAC,6DAAC;;AAEpC,IAAA,GAAG,GAAG,KAAK,CAAS,CAAC,eAAe,+CAAC;AACrC,IAAA,GAAG,GAAG,KAAK,CAAS,eAAe,+CAAC;AACpC,IAAA,QAAQ,GAAG,KAAK,CAAU,KAAK,oDAAC;AAEnB,IAAA,UAAU;IAEzB,SAAS,GAAG,MAAM,CAAC,SAAS,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;IAEpD,SAAS,GAAG,SAAS;AAErB,IAAA,iBAAiB,GAAG,UAAU,CAAC,QAAQ;AACvC,IAAA,KAAK,GAAG,MAAM,CAAgB,IAAI,iDAAC;AACnC,IAAA,QAAQ,GAAG,MAAM,CAAU,KAAK,oDAA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EAAA,iBAAiB,EAAA,UAAA,EACf,IAAI,EAAA,OAAA,EACP,CAAC,WAAW,EAAE,iBAAiB,EAAE,eAAe,CAAC,EAAA,eAAA,EAGzC,uBAAuB,CAAC,MAAM,EAAA,IAAA,EACzC;AACJ,wBAAA,KAAK,EAAE,YAAY;AACpB,qBAAA,EAAA,QAAA,EAAA,6xBAAA,EAAA,MAAA,EAAA,CAAA,sFAAA,CAAA,EAAA;wDAID,WAAW,EAAA,CAAA;sBADV,SAAS;AAAC,gBAAA,IAAA,EAAA,CAAA,aAAa,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE;gBAgBpB,UAAU,EAAA,CAAA;sBAA/B,WAAW;uBAAC,OAAO;;;AEnDtB;;AAEG;;;;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { inject, ChangeDetectorRef, input, EventEmitter, signal, HostBinding, Output, ViewChild, ChangeDetectionStrategy, Component } from '@angular/core';
|
|
2
|
+
import { inject, ChangeDetectorRef, input, EventEmitter, signal, effect, HostBinding, Output, ViewChild, ChangeDetectionStrategy, Component } from '@angular/core';
|
|
3
3
|
import * as i1 from '@angular/forms';
|
|
4
4
|
import { Validators, NgControl, FormsModule } from '@angular/forms';
|
|
5
5
|
import { Select } from 'primeng/select';
|
|
@@ -24,6 +24,7 @@ class SelectField {
|
|
|
24
24
|
dataKey = input(undefined, ...(ngDevMode ? [{ debugName: "dataKey" }] : []));
|
|
25
25
|
showClear = input(undefined, ...(ngDevMode ? [{ debugName: "showClear" }] : []));
|
|
26
26
|
clearAfterSelect = input(undefined, ...(ngDevMode ? [{ debugName: "clearAfterSelect" }] : []));
|
|
27
|
+
required = input(false, ...(ngDevMode ? [{ debugName: "required" }] : [])); // Add readonly required input
|
|
27
28
|
onChange = new EventEmitter();
|
|
28
29
|
styleClass;
|
|
29
30
|
requiredValidator = Validators.required;
|
|
@@ -37,6 +38,12 @@ class SelectField {
|
|
|
37
38
|
if (this.ngControl) {
|
|
38
39
|
this.ngControl.valueAccessor = this;
|
|
39
40
|
}
|
|
41
|
+
effect(() => {
|
|
42
|
+
if (this.ngControl.control && this.required()) {
|
|
43
|
+
this.ngControl.control.addValidators(Validators.required);
|
|
44
|
+
this.ngControl.control.updateValueAndValidity();
|
|
45
|
+
}
|
|
46
|
+
});
|
|
40
47
|
}
|
|
41
48
|
applyInputsToDropdown() {
|
|
42
49
|
// Object.assign(this.dropdown, this.pInputs());
|
|
@@ -82,7 +89,7 @@ class SelectField {
|
|
|
82
89
|
this.cdr.detectChanges();
|
|
83
90
|
}
|
|
84
91
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.3", ngImport: i0, type: SelectField, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
85
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.1.3", type: SelectField, isStandalone: true, selector: "mt-select-field", inputs: { field: { classPropertyName: "field", publicName: "field", isSignal: true, isRequired: false, transformFunction: null }, label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, placeholder: { classPropertyName: "placeholder", publicName: "placeholder", isSignal: true, isRequired: false, transformFunction: null }, hasPlaceholderPrefix: { classPropertyName: "hasPlaceholderPrefix", publicName: "hasPlaceholderPrefix", isSignal: true, isRequired: false, transformFunction: null }, class: { classPropertyName: "class", publicName: "class", isSignal: true, isRequired: false, transformFunction: null }, readonly: { classPropertyName: "readonly", publicName: "readonly", isSignal: true, isRequired: false, transformFunction: null }, pInputs: { classPropertyName: "pInputs", publicName: "pInputs", isSignal: true, isRequired: false, transformFunction: null }, options: { classPropertyName: "options", publicName: "options", isSignal: true, isRequired: false, transformFunction: null }, optionValue: { classPropertyName: "optionValue", publicName: "optionValue", isSignal: true, isRequired: false, transformFunction: null }, optionLabel: { classPropertyName: "optionLabel", publicName: "optionLabel", isSignal: true, isRequired: false, transformFunction: null }, filter: { classPropertyName: "filter", publicName: "filter", isSignal: true, isRequired: false, transformFunction: null }, filterBy: { classPropertyName: "filterBy", publicName: "filterBy", isSignal: true, isRequired: false, transformFunction: null }, dataKey: { classPropertyName: "dataKey", publicName: "dataKey", isSignal: true, isRequired: false, transformFunction: null }, showClear: { classPropertyName: "showClear", publicName: "showClear", isSignal: true, isRequired: false, transformFunction: null }, clearAfterSelect: { classPropertyName: "clearAfterSelect", publicName: "clearAfterSelect", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { onChange: "onChange" }, host: { properties: { "class": "this.styleClass" }, classAttribute: "grid gap-1" }, viewQueries: [{ propertyName: "dropdown", first: true, predicate: ["dropdown"], descendants: true, static: true }], usesOnChanges: true, ngImport: i0, template: "@if (label()) {\n <label\n (click)=\"dropdown.show(); dropdown.focus()\"\n [class.required]=\"ngControl?.control?.hasValidator(requiredValidator)\"\n [for]=\"ngControl?.name || label()\"\n >{{ label() }}</label\n >\n}\n<p-select\n #dropdown\n appendTo=\"body\"\n [overlayOptions]=\"{ baseZIndex: 1051 }\"\n [ngModel]=\"value()\"\n (ngModelChange)=\"onValueChange($event)\"\n [options]=\"options()\"\n [optionLabel]=\"optionLabel()\"\n [optionValue]=\"optionValue()\"\n (onBlur)=\"onTouched()\"\n [disabled]=\"disabled() || readonly()\"\n [inputId]=\"ngControl?.name ? ngControl?.name?.toString() : label()\"\n [id]=\"ngControl?.name ? ngControl?.name?.toString() : label()\"\n [invalid]=\"isInvalid(ngControl?.control)\"\n placeholder=\"{{ hasPlaceholderPrefix() ? 'select' : '' }} {{\n placeholder() ?? label() ?? ''\n }}\"\n [filter]=\"filter()\"\n [filterBy]=\"filterBy()\"\n [dataKey]=\"dataKey()\"\n styleClass=\"w-full\"\n [showClear]=\"showClear()\"\n appendTo=\"body\"\n></p-select>\n\n<mt-field-validation [control]=\"ngControl?.control\"></mt-field-validation>\n", styles: [""], dependencies: [{ kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "component", type: Select, selector: "p-select", inputs: ["id", "scrollHeight", "filter", "panelStyle", "styleClass", "panelStyleClass", "readonly", "editable", "tabindex", "placeholder", "loadingIcon", "filterPlaceholder", "filterLocale", "inputId", "dataKey", "filterBy", "filterFields", "autofocus", "resetFilterOnHide", "checkmark", "dropdownIcon", "loading", "optionLabel", "optionValue", "optionDisabled", "optionGroupLabel", "optionGroupChildren", "group", "showClear", "emptyFilterMessage", "emptyMessage", "lazy", "virtualScroll", "virtualScrollItemSize", "virtualScrollOptions", "overlayOptions", "ariaFilterLabel", "ariaLabel", "ariaLabelledBy", "filterMatchMode", "tooltip", "tooltipPosition", "tooltipPositionStyle", "tooltipStyleClass", "focusOnHover", "selectOnFocus", "autoOptionFocus", "autofocusFilter", "filterValue", "options", "appendTo"], outputs: ["onChange", "onFilter", "onFocus", "onBlur", "onClick", "onShow", "onHide", "onClear", "onLazyLoad"] }, { kind: "component", type: FieldValidation, selector: "mt-field-validation", inputs: ["control", "touched"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
92
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.1.3", type: SelectField, isStandalone: true, selector: "mt-select-field", inputs: { field: { classPropertyName: "field", publicName: "field", isSignal: true, isRequired: false, transformFunction: null }, label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, placeholder: { classPropertyName: "placeholder", publicName: "placeholder", isSignal: true, isRequired: false, transformFunction: null }, hasPlaceholderPrefix: { classPropertyName: "hasPlaceholderPrefix", publicName: "hasPlaceholderPrefix", isSignal: true, isRequired: false, transformFunction: null }, class: { classPropertyName: "class", publicName: "class", isSignal: true, isRequired: false, transformFunction: null }, readonly: { classPropertyName: "readonly", publicName: "readonly", isSignal: true, isRequired: false, transformFunction: null }, pInputs: { classPropertyName: "pInputs", publicName: "pInputs", isSignal: true, isRequired: false, transformFunction: null }, options: { classPropertyName: "options", publicName: "options", isSignal: true, isRequired: false, transformFunction: null }, optionValue: { classPropertyName: "optionValue", publicName: "optionValue", isSignal: true, isRequired: false, transformFunction: null }, optionLabel: { classPropertyName: "optionLabel", publicName: "optionLabel", isSignal: true, isRequired: false, transformFunction: null }, filter: { classPropertyName: "filter", publicName: "filter", isSignal: true, isRequired: false, transformFunction: null }, filterBy: { classPropertyName: "filterBy", publicName: "filterBy", isSignal: true, isRequired: false, transformFunction: null }, dataKey: { classPropertyName: "dataKey", publicName: "dataKey", isSignal: true, isRequired: false, transformFunction: null }, showClear: { classPropertyName: "showClear", publicName: "showClear", isSignal: true, isRequired: false, transformFunction: null }, clearAfterSelect: { classPropertyName: "clearAfterSelect", publicName: "clearAfterSelect", isSignal: true, isRequired: false, transformFunction: null }, required: { classPropertyName: "required", publicName: "required", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { onChange: "onChange" }, host: { properties: { "class": "this.styleClass" }, classAttribute: "grid gap-1" }, viewQueries: [{ propertyName: "dropdown", first: true, predicate: ["dropdown"], descendants: true, static: true }], usesOnChanges: true, ngImport: i0, template: "@if (label()) {\n <label\n (click)=\"dropdown.show(); dropdown.focus()\"\n [class.required]=\"ngControl?.control?.hasValidator(requiredValidator)\"\n [for]=\"ngControl?.name || label()\"\n >{{ label() }}</label\n >\n}\n<p-select\n #dropdown\n appendTo=\"body\"\n [overlayOptions]=\"{ baseZIndex: 1051 }\"\n [ngModel]=\"value()\"\n (ngModelChange)=\"onValueChange($event)\"\n [options]=\"options()\"\n [optionLabel]=\"optionLabel()\"\n [optionValue]=\"optionValue()\"\n (onBlur)=\"onTouched()\"\n [disabled]=\"disabled() || readonly()\"\n [inputId]=\"ngControl?.name ? ngControl?.name?.toString() : label()\"\n [id]=\"ngControl?.name ? ngControl?.name?.toString() : label()\"\n [invalid]=\"isInvalid(ngControl?.control)\"\n placeholder=\"{{ hasPlaceholderPrefix() ? 'select' : '' }} {{\n placeholder() ?? label() ?? ''\n }}\"\n [filter]=\"filter()\"\n [filterBy]=\"filterBy()\"\n [dataKey]=\"dataKey()\"\n styleClass=\"w-full\"\n [showClear]=\"showClear()\"\n appendTo=\"body\"\n></p-select>\n\n<mt-field-validation [control]=\"ngControl?.control\"></mt-field-validation>\n", styles: [""], dependencies: [{ kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "component", type: Select, selector: "p-select", inputs: ["id", "scrollHeight", "filter", "panelStyle", "styleClass", "panelStyleClass", "readonly", "editable", "tabindex", "placeholder", "loadingIcon", "filterPlaceholder", "filterLocale", "inputId", "dataKey", "filterBy", "filterFields", "autofocus", "resetFilterOnHide", "checkmark", "dropdownIcon", "loading", "optionLabel", "optionValue", "optionDisabled", "optionGroupLabel", "optionGroupChildren", "group", "showClear", "emptyFilterMessage", "emptyMessage", "lazy", "virtualScroll", "virtualScrollItemSize", "virtualScrollOptions", "overlayOptions", "ariaFilterLabel", "ariaLabel", "ariaLabelledBy", "filterMatchMode", "tooltip", "tooltipPosition", "tooltipPositionStyle", "tooltipStyleClass", "focusOnHover", "selectOnFocus", "autoOptionFocus", "autofocusFilter", "filterValue", "options", "appendTo"], outputs: ["onChange", "onFilter", "onFocus", "onBlur", "onClick", "onShow", "onHide", "onClear", "onLazyLoad"] }, { kind: "component", type: FieldValidation, selector: "mt-field-validation", inputs: ["control", "touched"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
86
93
|
}
|
|
87
94
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.3", ngImport: i0, type: SelectField, decorators: [{
|
|
88
95
|
type: Component,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"masterteam-components-select-field.mjs","sources":["../../../../packages/masterteam/components/select-field/select-field.ts","../../../../packages/masterteam/components/select-field/select-field.html","../../../../packages/masterteam/components/select-field/masterteam-components-select-field.ts"],"sourcesContent":["import {\n Component,\n EventEmitter,\n HostBinding,\n OnChanges,\n OnInit,\n Output,\n SimpleChanges,\n ViewChild,\n signal,\n input,\n inject,\n ChangeDetectorRef,\n ChangeDetectionStrategy,\n} from '@angular/core';\n\nimport {\n ControlValueAccessor,\n FormsModule,\n NgControl,\n Validators,\n} from '@angular/forms';\nimport { Select } from 'primeng/select';\nimport { FieldValidation } from '@masterteam/components/field-validation';\nimport { isInvalid } from '@masterteam/components';\n\n@Component({\n selector: 'mt-select-field',\n standalone: true,\n imports: [FormsModule, Select, FieldValidation],\n templateUrl: './select-field.html',\n styleUrls: ['./select-field.scss'],\n changeDetection: ChangeDetectionStrategy.OnPush,\n host: {\n class: 'grid gap-1',\n },\n})\nexport class SelectField implements ControlValueAccessor, OnInit, OnChanges {\n cdr = inject(ChangeDetectorRef);\n @ViewChild('dropdown', { static: true })\n dropdown: Select;\n\n readonly field = input<boolean>(true);\n readonly label = input<string>('');\n readonly placeholder = input<string>('');\n readonly hasPlaceholderPrefix = input<boolean>(true);\n readonly class = input<string>('');\n readonly readonly = input<boolean>(false);\n readonly pInputs = input<Partial<Select>>();\n readonly options = input<any[] | undefined>(undefined);\n readonly optionValue = input<string | undefined>(undefined);\n readonly optionLabel = input<string | undefined>(undefined);\n readonly filter = input<boolean | undefined>(undefined);\n readonly filterBy = input<string | undefined>(undefined);\n readonly dataKey = input<string | undefined>(undefined);\n readonly showClear = input<boolean | undefined>(undefined);\n readonly clearAfterSelect = input<boolean | undefined>(undefined);\n @Output() onChange: EventEmitter<any> = new EventEmitter();\n\n @HostBinding('class') styleClass: string;\n\n requiredValidator = Validators.required;\n value = signal<any>(null);\n disabled = signal<boolean>(false);\n\n onTouched: () => void = () => {};\n onModelChange: (value: any) => void = () => {};\n\n public ngControl = inject(NgControl, { self: true });\n\n isInvalid = isInvalid;\n\n constructor() {\n if (this.ngControl) {\n this.ngControl.valueAccessor = this;\n }\n }\n\n applyInputsToDropdown() {\n // Object.assign(this.dropdown, this.pInputs());\n }\n\n ngOnInit() {\n this.styleClass = this.class();\n if (this.pInputs()) {\n this.applyInputsToDropdown();\n }\n }\n\n onValueChange(value: any) {\n this.onModelChange(value);\n this.value.set(value);\n this.onChange.emit(value);\n if (this.clearAfterSelect()) {\n this.clearSelection();\n }\n }\n\n ngOnChanges(changes: SimpleChanges) {\n if (changes['pInputs']) {\n this.applyInputsToDropdown();\n }\n }\n\n writeValue(value: string) {\n this.value.set(value);\n }\n\n registerOnChange(fn: any) {\n this.onModelChange = fn;\n }\n\n registerOnTouched(fn: any) {\n this.onTouched = fn;\n }\n\n setDisabledState(disabled: boolean) {\n this.disabled.set(disabled);\n }\n\n // TODO: make this method work\n public clearSelection() {\n this.dropdown.clear(this.value());\n this.dropdown.value = null;\n this.value.set(null);\n this.onModelChange(null);\n this.onChange.emit(null);\n this.cdr.detectChanges();\n }\n}\n","@if (label()) {\n <label\n (click)=\"dropdown.show(); dropdown.focus()\"\n [class.required]=\"ngControl?.control?.hasValidator(requiredValidator)\"\n [for]=\"ngControl?.name || label()\"\n >{{ label() }}</label\n >\n}\n<p-select\n #dropdown\n appendTo=\"body\"\n [overlayOptions]=\"{ baseZIndex: 1051 }\"\n [ngModel]=\"value()\"\n (ngModelChange)=\"onValueChange($event)\"\n [options]=\"options()\"\n [optionLabel]=\"optionLabel()\"\n [optionValue]=\"optionValue()\"\n (onBlur)=\"onTouched()\"\n [disabled]=\"disabled() || readonly()\"\n [inputId]=\"ngControl?.name ? ngControl?.name?.toString() : label()\"\n [id]=\"ngControl?.name ? ngControl?.name?.toString() : label()\"\n [invalid]=\"isInvalid(ngControl?.control)\"\n placeholder=\"{{ hasPlaceholderPrefix() ? 'select' : '' }} {{\n placeholder() ?? label() ?? ''\n }}\"\n [filter]=\"filter()\"\n [filterBy]=\"filterBy()\"\n [dataKey]=\"dataKey()\"\n styleClass=\"w-full\"\n [showClear]=\"showClear()\"\n appendTo=\"body\"\n></p-select>\n\n<mt-field-validation [control]=\"ngControl?.control\"></mt-field-validation>\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;;
|
|
1
|
+
{"version":3,"file":"masterteam-components-select-field.mjs","sources":["../../../../packages/masterteam/components/select-field/select-field.ts","../../../../packages/masterteam/components/select-field/select-field.html","../../../../packages/masterteam/components/select-field/masterteam-components-select-field.ts"],"sourcesContent":["import {\n Component,\n EventEmitter,\n HostBinding,\n OnChanges,\n OnInit,\n Output,\n SimpleChanges,\n ViewChild,\n signal,\n input,\n inject,\n ChangeDetectorRef,\n ChangeDetectionStrategy,\n effect,\n} from '@angular/core';\n\nimport {\n ControlValueAccessor,\n FormsModule,\n NgControl,\n Validators,\n} from '@angular/forms';\nimport { Select } from 'primeng/select';\nimport { FieldValidation } from '@masterteam/components/field-validation';\nimport { isInvalid } from '@masterteam/components';\n\n@Component({\n selector: 'mt-select-field',\n standalone: true,\n imports: [FormsModule, Select, FieldValidation],\n templateUrl: './select-field.html',\n styleUrls: ['./select-field.scss'],\n changeDetection: ChangeDetectionStrategy.OnPush,\n host: {\n class: 'grid gap-1',\n },\n})\nexport class SelectField implements ControlValueAccessor, OnInit, OnChanges {\n cdr = inject(ChangeDetectorRef);\n @ViewChild('dropdown', { static: true })\n dropdown: Select;\n\n readonly field = input<boolean>(true);\n readonly label = input<string>('');\n readonly placeholder = input<string>('');\n readonly hasPlaceholderPrefix = input<boolean>(true);\n readonly class = input<string>('');\n readonly readonly = input<boolean>(false);\n readonly pInputs = input<Partial<Select>>();\n readonly options = input<any[] | undefined>(undefined);\n readonly optionValue = input<string | undefined>(undefined);\n readonly optionLabel = input<string | undefined>(undefined);\n readonly filter = input<boolean | undefined>(undefined);\n readonly filterBy = input<string | undefined>(undefined);\n readonly dataKey = input<string | undefined>(undefined);\n readonly showClear = input<boolean | undefined>(undefined);\n readonly clearAfterSelect = input<boolean | undefined>(undefined);\n readonly required = input<boolean>(false); // Add readonly required input\n\n @Output() onChange: EventEmitter<any> = new EventEmitter();\n\n @HostBinding('class') styleClass: string;\n\n requiredValidator = Validators.required;\n value = signal<any>(null);\n disabled = signal<boolean>(false);\n\n onTouched: () => void = () => {};\n onModelChange: (value: any) => void = () => {};\n\n public ngControl = inject(NgControl, { self: true });\n\n isInvalid = isInvalid;\n\n constructor() {\n if (this.ngControl) {\n this.ngControl.valueAccessor = this;\n }\n effect(() => {\n if (this.ngControl.control && this.required()) {\n this.ngControl.control.addValidators(Validators.required);\n this.ngControl.control.updateValueAndValidity();\n }\n });\n }\n\n applyInputsToDropdown() {\n // Object.assign(this.dropdown, this.pInputs());\n }\n\n ngOnInit() {\n this.styleClass = this.class();\n if (this.pInputs()) {\n this.applyInputsToDropdown();\n }\n }\n\n onValueChange(value: any) {\n this.onModelChange(value);\n this.value.set(value);\n this.onChange.emit(value);\n if (this.clearAfterSelect()) {\n this.clearSelection();\n }\n }\n\n ngOnChanges(changes: SimpleChanges) {\n if (changes['pInputs']) {\n this.applyInputsToDropdown();\n }\n }\n\n writeValue(value: string) {\n this.value.set(value);\n }\n\n registerOnChange(fn: any) {\n this.onModelChange = fn;\n }\n\n registerOnTouched(fn: any) {\n this.onTouched = fn;\n }\n\n setDisabledState(disabled: boolean) {\n this.disabled.set(disabled);\n }\n\n // TODO: make this method work\n public clearSelection() {\n this.dropdown.clear(this.value());\n this.dropdown.value = null;\n this.value.set(null);\n this.onModelChange(null);\n this.onChange.emit(null);\n this.cdr.detectChanges();\n }\n}\n","@if (label()) {\n <label\n (click)=\"dropdown.show(); dropdown.focus()\"\n [class.required]=\"ngControl?.control?.hasValidator(requiredValidator)\"\n [for]=\"ngControl?.name || label()\"\n >{{ label() }}</label\n >\n}\n<p-select\n #dropdown\n appendTo=\"body\"\n [overlayOptions]=\"{ baseZIndex: 1051 }\"\n [ngModel]=\"value()\"\n (ngModelChange)=\"onValueChange($event)\"\n [options]=\"options()\"\n [optionLabel]=\"optionLabel()\"\n [optionValue]=\"optionValue()\"\n (onBlur)=\"onTouched()\"\n [disabled]=\"disabled() || readonly()\"\n [inputId]=\"ngControl?.name ? ngControl?.name?.toString() : label()\"\n [id]=\"ngControl?.name ? ngControl?.name?.toString() : label()\"\n [invalid]=\"isInvalid(ngControl?.control)\"\n placeholder=\"{{ hasPlaceholderPrefix() ? 'select' : '' }} {{\n placeholder() ?? label() ?? ''\n }}\"\n [filter]=\"filter()\"\n [filterBy]=\"filterBy()\"\n [dataKey]=\"dataKey()\"\n styleClass=\"w-full\"\n [showClear]=\"showClear()\"\n appendTo=\"body\"\n></p-select>\n\n<mt-field-validation [control]=\"ngControl?.control\"></mt-field-validation>\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;;MAsCa,WAAW,CAAA;AACtB,IAAA,GAAG,GAAG,MAAM,CAAC,iBAAiB,CAAC;AAE/B,IAAA,QAAQ;AAEC,IAAA,KAAK,GAAG,KAAK,CAAU,IAAI,iDAAC;AAC5B,IAAA,KAAK,GAAG,KAAK,CAAS,EAAE,iDAAC;AACzB,IAAA,WAAW,GAAG,KAAK,CAAS,EAAE,uDAAC;AAC/B,IAAA,oBAAoB,GAAG,KAAK,CAAU,IAAI,gEAAC;AAC3C,IAAA,KAAK,GAAG,KAAK,CAAS,EAAE,iDAAC;AACzB,IAAA,QAAQ,GAAG,KAAK,CAAU,KAAK,oDAAC;IAChC,OAAO,GAAG,KAAK,CAAA,IAAA,SAAA,GAAA,CAAA,SAAA,EAAA,EAAA,SAAA,EAAA,SAAA,EAAA,CAAA,GAAA,EAAA,CAAA,CAAmB;AAClC,IAAA,OAAO,GAAG,KAAK,CAAoB,SAAS,mDAAC;AAC7C,IAAA,WAAW,GAAG,KAAK,CAAqB,SAAS,uDAAC;AAClD,IAAA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,EACP,CAAC,WAAW,EAAE,MAAM,EAAE,eAAe,CAAC,EAAA,eAAA,EAG9B,uBAAuB,CAAC,MAAM,EAAA,IAAA,EACzC;AACJ,wBAAA,KAAK,EAAE,YAAY;AACpB,qBAAA,EAAA,QAAA,EAAA,wlCAAA,EAAA;wDAKD,QAAQ,EAAA,CAAA;sBADP,SAAS;AAAC,gBAAA,IAAA,EAAA,CAAA,UAAU,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE;gBAoB7B,QAAQ,EAAA,CAAA;sBAAjB;gBAEqB,UAAU,EAAA,CAAA;sBAA/B,WAAW;uBAAC,OAAO;;;AE9DtB;;AAEG;;;;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { input, numberAttribute, booleanAttribute, EventEmitter, signal, inject, HostBinding, Output, ViewChild, ChangeDetectionStrategy, Component } from '@angular/core';
|
|
2
|
+
import { input, numberAttribute, booleanAttribute, EventEmitter, signal, inject, effect, HostBinding, Output, ViewChild, ChangeDetectionStrategy, Component } from '@angular/core';
|
|
3
3
|
import * as i1 from '@angular/forms';
|
|
4
4
|
import { Validators, NgControl, FormsModule } from '@angular/forms';
|
|
5
5
|
import * as i2 from 'primeng/slider';
|
|
@@ -24,6 +24,7 @@ class SliderField {
|
|
|
24
24
|
unit = input('', ...(ngDevMode ? [{ debugName: "unit" }] : []));
|
|
25
25
|
readonly = input(false, ...(ngDevMode ? [{ debugName: "readonly" }] : []));
|
|
26
26
|
pInputs = input(...(ngDevMode ? [undefined, { debugName: "pInputs" }] : []));
|
|
27
|
+
required = input(false, ...(ngDevMode ? [{ debugName: "required" }] : []));
|
|
27
28
|
onChange = new EventEmitter();
|
|
28
29
|
onSlideEnd = new EventEmitter();
|
|
29
30
|
styleClass;
|
|
@@ -38,6 +39,12 @@ class SliderField {
|
|
|
38
39
|
if (this.ngControl) {
|
|
39
40
|
this.ngControl.valueAccessor = this;
|
|
40
41
|
}
|
|
42
|
+
effect(() => {
|
|
43
|
+
if (this.ngControl.control && this.required()) {
|
|
44
|
+
this.ngControl.control.addValidators(Validators.required);
|
|
45
|
+
this.ngControl.control.updateValueAndValidity();
|
|
46
|
+
}
|
|
47
|
+
});
|
|
41
48
|
}
|
|
42
49
|
applyInputsToInput() {
|
|
43
50
|
Object.assign(this.input, this.pInputs());
|
|
@@ -67,7 +74,7 @@ class SliderField {
|
|
|
67
74
|
this.disabled.set(disabled);
|
|
68
75
|
}
|
|
69
76
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.3", ngImport: i0, type: SliderField, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
70
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.1.3", type: SliderField, isStandalone: true, selector: "mt-slider-field", inputs: { field: { classPropertyName: "field", publicName: "field", isSignal: true, isRequired: false, transformFunction: null }, label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, animate: { classPropertyName: "animate", publicName: "animate", isSignal: true, isRequired: false, transformFunction: null }, class: { classPropertyName: "class", publicName: "class", 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 }, step: { classPropertyName: "step", publicName: "step", isSignal: true, isRequired: false, transformFunction: null }, hideNumber: { classPropertyName: "hideNumber", publicName: "hideNumber", isSignal: true, isRequired: false, transformFunction: null }, unit: { classPropertyName: "unit", publicName: "unit", isSignal: true, isRequired: false, transformFunction: null }, readonly: { classPropertyName: "readonly", publicName: "readonly", isSignal: true, isRequired: false, transformFunction: null }, pInputs: { classPropertyName: "pInputs", publicName: "pInputs", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { onChange: "onChange", onSlideEnd: "onSlideEnd" }, host: { properties: { "class": "this.styleClass" }, classAttribute: "grid gap-1" }, viewQueries: [{ propertyName: "input", first: true, predicate: ["input"], descendants: true, static: true }], usesOnChanges: true, ngImport: i0, template: "@if (label()) {\n <label\n [class.required]=\"ngControl?.control?.hasValidator(requiredValidator)\"\n [for]=\"ngControl?.name || label()\"\n [class.mb-3]=\"hideNumber()\"\n >{{ label() }}</label\n >\n}\n<div\n class=\"flex items-center gap-3 w-full\"\n [style.padding-inline-start]=\"'calc(var(--p-slider-handle-width) / 2)'\"\n>\n <p-slider\n #input\n [ngModel]=\"value()\"\n (ngModelChange)=\"onValueChange($event)\"\n (onChange)=\"onChange.emit($event)\"\n (onSlideEnd)=\"onTouched(); onSlideEnd.emit($event)\"\n [disabled]=\"disabled() || readonly()\"\n [animate]=\"animate()\"\n [id]=\"ngControl?.name || label()\"\n [min]=\"min()\"\n [max]=\"max()\"\n [step]=\"step()\"\n [invalid]=\"isInvalid(ngControl?.control)\"\n class=\"grow\"\n ></p-slider>\n @if (!hideNumber()) {\n <span class=\"leading-none\">{{ value() ? value() + unit() : \"-\" }}</span>\n }\n</div>\n\n<mt-field-validation [control]=\"ngControl?.control\"></mt-field-validation>\n", styles: [""], dependencies: [{ kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "ngmodule", type: SliderModule }, { kind: "component", type: i2.Slider, selector: "p-slider", inputs: ["animate", "min", "max", "orientation", "step", "range", "styleClass", "ariaLabel", "ariaLabelledBy", "tabindex", "autofocus"], outputs: ["onChange", "onSlideEnd"] }, { kind: "component", type: FieldValidation, selector: "mt-field-validation", inputs: ["control", "touched"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
77
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.1.3", type: SliderField, isStandalone: true, selector: "mt-slider-field", inputs: { field: { classPropertyName: "field", publicName: "field", isSignal: true, isRequired: false, transformFunction: null }, label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, animate: { classPropertyName: "animate", publicName: "animate", isSignal: true, isRequired: false, transformFunction: null }, class: { classPropertyName: "class", publicName: "class", 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 }, step: { classPropertyName: "step", publicName: "step", isSignal: true, isRequired: false, transformFunction: null }, hideNumber: { classPropertyName: "hideNumber", publicName: "hideNumber", isSignal: true, isRequired: false, transformFunction: null }, unit: { classPropertyName: "unit", publicName: "unit", isSignal: true, isRequired: false, transformFunction: null }, readonly: { classPropertyName: "readonly", publicName: "readonly", isSignal: true, isRequired: false, transformFunction: null }, pInputs: { classPropertyName: "pInputs", publicName: "pInputs", isSignal: true, isRequired: false, transformFunction: null }, required: { classPropertyName: "required", publicName: "required", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { onChange: "onChange", onSlideEnd: "onSlideEnd" }, host: { properties: { "class": "this.styleClass" }, classAttribute: "grid gap-1" }, viewQueries: [{ propertyName: "input", first: true, predicate: ["input"], descendants: true, static: true }], usesOnChanges: true, ngImport: i0, template: "@if (label()) {\n <label\n [class.required]=\"ngControl?.control?.hasValidator(requiredValidator)\"\n [for]=\"ngControl?.name || label()\"\n [class.mb-3]=\"hideNumber()\"\n >{{ label() }}</label\n >\n}\n<div\n class=\"flex items-center gap-3 w-full\"\n [style.padding-inline-start]=\"'calc(var(--p-slider-handle-width) / 2)'\"\n>\n <p-slider\n #input\n [ngModel]=\"value()\"\n (ngModelChange)=\"onValueChange($event)\"\n (onChange)=\"onChange.emit($event)\"\n (onSlideEnd)=\"onTouched(); onSlideEnd.emit($event)\"\n [disabled]=\"disabled() || readonly()\"\n [animate]=\"animate()\"\n [id]=\"ngControl?.name || label()\"\n [min]=\"min()\"\n [max]=\"max()\"\n [step]=\"step()\"\n [invalid]=\"isInvalid(ngControl?.control)\"\n class=\"grow\"\n ></p-slider>\n @if (!hideNumber()) {\n <span class=\"leading-none\">{{ value() ? value() + unit() : \"-\" }}</span>\n }\n</div>\n\n<mt-field-validation [control]=\"ngControl?.control\"></mt-field-validation>\n", styles: [""], dependencies: [{ kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "ngmodule", type: SliderModule }, { kind: "component", type: i2.Slider, selector: "p-slider", inputs: ["animate", "min", "max", "orientation", "step", "range", "styleClass", "ariaLabel", "ariaLabelledBy", "tabindex", "autofocus"], outputs: ["onChange", "onSlideEnd"] }, { kind: "component", type: FieldValidation, selector: "mt-field-validation", inputs: ["control", "touched"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
71
78
|
}
|
|
72
79
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.3", ngImport: i0, type: SliderField, decorators: [{
|
|
73
80
|
type: Component,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"masterteam-components-slider-field.mjs","sources":["../../../../packages/masterteam/components/slider-field/slider-field.ts","../../../../packages/masterteam/components/slider-field/slider-field.html","../../../../packages/masterteam/components/slider-field/masterteam-components-slider-field.ts"],"sourcesContent":["import {\n Component,\n EventEmitter,\n HostBinding,\n Output,\n SimpleChanges,\n ViewChild,\n booleanAttribute,\n input,\n numberAttribute,\n signal,\n OnInit,\n OnChanges,\n inject,\n ChangeDetectionStrategy,\n} from '@angular/core';\nimport {\n ControlValueAccessor,\n FormsModule,\n NgControl,\n Validators,\n} from '@angular/forms';\nimport {\n Slider,\n SliderChangeEvent,\n SliderSlideEndEvent,\n SliderModule,\n} from 'primeng/slider';\nimport { FieldValidation } from '@masterteam/components/field-validation';\nimport { isInvalid } from '@masterteam/components';\n\n@Component({\n selector: 'mt-slider-field',\n standalone: true,\n imports: [FormsModule, SliderModule, FieldValidation],\n templateUrl: './slider-field.html',\n styleUrls: ['./slider-field.scss'],\n changeDetection: ChangeDetectionStrategy.OnPush,\n host: {\n class: 'grid gap-1',\n },\n})\nexport class SliderField implements ControlValueAccessor, OnInit, OnChanges {\n @ViewChild('input', { static: true })\n input: Slider;\n\n readonly field = input<boolean>(true);\n readonly label = input<string>();\n readonly animate = input<boolean>(true);\n readonly class = input<string>('');\n readonly min = input<number, unknown>(0, { transform: numberAttribute });\n readonly max = input<number, unknown>(100, { transform: numberAttribute });\n readonly step = input<number, unknown>(undefined, {\n transform: numberAttribute,\n });\n readonly hideNumber = input<boolean, unknown>(false, {\n transform: booleanAttribute,\n });\n readonly unit = input<string>('');\n readonly readonly = input<boolean>(false);\n readonly pInputs = input<Partial<Slider>>();\n @Output() onChange: EventEmitter<SliderChangeEvent> = new EventEmitter();\n @Output() onSlideEnd: EventEmitter<SliderSlideEndEvent> = new EventEmitter();\n\n @HostBinding('class') styleClass: string;\n\n requiredValidator = Validators.required;\n value = signal<number | null>(null);\n disabled = signal<boolean>(false);\n\n onTouched: () => void = () => {};\n onModelChange: (value: number | null) => void = () => {};\n\n public ngControl = inject(NgControl, { self: true });\n\n isInvalid = isInvalid;\n\n constructor() {\n if (this.ngControl) {\n this.ngControl.valueAccessor = this;\n }\n }\n\n applyInputsToInput() {\n Object.assign(this.input, this.pInputs());\n }\n\n ngOnInit() {\n this.styleClass = this.class();\n }\n onValueChange(value: number | null) {\n this.onModelChange(value);\n this.value.set(value);\n }\n ngOnChanges(changes: SimpleChanges) {\n if (changes['pInputs']) {\n this.applyInputsToInput();\n }\n }\n\n writeValue(value: number) {\n this.value.set(value);\n }\n\n registerOnChange(fn: any) {\n this.onModelChange = fn;\n }\n\n registerOnTouched(fn: any) {\n this.onTouched = fn;\n }\n\n setDisabledState(disabled: boolean) {\n this.disabled.set(disabled);\n }\n}\n","@if (label()) {\n <label\n [class.required]=\"ngControl?.control?.hasValidator(requiredValidator)\"\n [for]=\"ngControl?.name || label()\"\n [class.mb-3]=\"hideNumber()\"\n >{{ label() }}</label\n >\n}\n<div\n class=\"flex items-center gap-3 w-full\"\n [style.padding-inline-start]=\"'calc(var(--p-slider-handle-width) / 2)'\"\n>\n <p-slider\n #input\n [ngModel]=\"value()\"\n (ngModelChange)=\"onValueChange($event)\"\n (onChange)=\"onChange.emit($event)\"\n (onSlideEnd)=\"onTouched(); onSlideEnd.emit($event)\"\n [disabled]=\"disabled() || readonly()\"\n [animate]=\"animate()\"\n [id]=\"ngControl?.name || label()\"\n [min]=\"min()\"\n [max]=\"max()\"\n [step]=\"step()\"\n [invalid]=\"isInvalid(ngControl?.control)\"\n class=\"grow\"\n ></p-slider>\n @if (!hideNumber()) {\n <span class=\"leading-none\">{{ value() ? value() + unit() : \"-\" }}</span>\n }\n</div>\n\n<mt-field-validation [control]=\"ngControl?.control\"></mt-field-validation>\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;;;
|
|
1
|
+
{"version":3,"file":"masterteam-components-slider-field.mjs","sources":["../../../../packages/masterteam/components/slider-field/slider-field.ts","../../../../packages/masterteam/components/slider-field/slider-field.html","../../../../packages/masterteam/components/slider-field/masterteam-components-slider-field.ts"],"sourcesContent":["import {\n Component,\n EventEmitter,\n HostBinding,\n Output,\n SimpleChanges,\n ViewChild,\n booleanAttribute,\n input,\n numberAttribute,\n signal,\n OnInit,\n OnChanges,\n inject,\n ChangeDetectionStrategy,\n effect,\n} from '@angular/core';\nimport {\n ControlValueAccessor,\n FormsModule,\n NgControl,\n Validators,\n} from '@angular/forms';\nimport {\n Slider,\n SliderChangeEvent,\n SliderSlideEndEvent,\n SliderModule,\n} from 'primeng/slider';\nimport { FieldValidation } from '@masterteam/components/field-validation';\nimport { isInvalid } from '@masterteam/components';\n\n@Component({\n selector: 'mt-slider-field',\n standalone: true,\n imports: [FormsModule, SliderModule, FieldValidation],\n templateUrl: './slider-field.html',\n styleUrls: ['./slider-field.scss'],\n changeDetection: ChangeDetectionStrategy.OnPush,\n host: {\n class: 'grid gap-1',\n },\n})\nexport class SliderField implements ControlValueAccessor, OnInit, OnChanges {\n @ViewChild('input', { static: true })\n input: Slider;\n\n readonly field = input<boolean>(true);\n readonly label = input<string>();\n readonly animate = input<boolean>(true);\n readonly class = input<string>('');\n readonly min = input<number, unknown>(0, { transform: numberAttribute });\n readonly max = input<number, unknown>(100, { transform: numberAttribute });\n readonly step = input<number, unknown>(undefined, {\n transform: numberAttribute,\n });\n readonly hideNumber = input<boolean, unknown>(false, {\n transform: booleanAttribute,\n });\n readonly unit = input<string>('');\n readonly readonly = input<boolean>(false);\n readonly pInputs = input<Partial<Slider>>();\n readonly required = input<boolean>(false);\n\n @Output() onChange: EventEmitter<SliderChangeEvent> = new EventEmitter();\n @Output() onSlideEnd: EventEmitter<SliderSlideEndEvent> = new EventEmitter();\n\n @HostBinding('class') styleClass: string;\n\n requiredValidator = Validators.required;\n value = signal<number | null>(null);\n disabled = signal<boolean>(false);\n\n onTouched: () => void = () => {};\n onModelChange: (value: number | null) => void = () => {};\n\n public ngControl = inject(NgControl, { self: true });\n\n isInvalid = isInvalid;\n\n constructor() {\n if (this.ngControl) {\n this.ngControl.valueAccessor = this;\n }\n effect(() => {\n if (this.ngControl.control && this.required()) {\n this.ngControl.control.addValidators(Validators.required);\n this.ngControl.control.updateValueAndValidity();\n }\n });\n }\n\n applyInputsToInput() {\n Object.assign(this.input, this.pInputs());\n }\n\n ngOnInit() {\n this.styleClass = this.class();\n }\n onValueChange(value: number | null) {\n this.onModelChange(value);\n this.value.set(value);\n }\n ngOnChanges(changes: SimpleChanges) {\n if (changes['pInputs']) {\n this.applyInputsToInput();\n }\n }\n\n writeValue(value: number) {\n this.value.set(value);\n }\n\n registerOnChange(fn: any) {\n this.onModelChange = fn;\n }\n\n registerOnTouched(fn: any) {\n this.onTouched = fn;\n }\n\n setDisabledState(disabled: boolean) {\n this.disabled.set(disabled);\n }\n}\n","@if (label()) {\n <label\n [class.required]=\"ngControl?.control?.hasValidator(requiredValidator)\"\n [for]=\"ngControl?.name || label()\"\n [class.mb-3]=\"hideNumber()\"\n >{{ label() }}</label\n >\n}\n<div\n class=\"flex items-center gap-3 w-full\"\n [style.padding-inline-start]=\"'calc(var(--p-slider-handle-width) / 2)'\"\n>\n <p-slider\n #input\n [ngModel]=\"value()\"\n (ngModelChange)=\"onValueChange($event)\"\n (onChange)=\"onChange.emit($event)\"\n (onSlideEnd)=\"onTouched(); onSlideEnd.emit($event)\"\n [disabled]=\"disabled() || readonly()\"\n [animate]=\"animate()\"\n [id]=\"ngControl?.name || label()\"\n [min]=\"min()\"\n [max]=\"max()\"\n [step]=\"step()\"\n [invalid]=\"isInvalid(ngControl?.control)\"\n class=\"grow\"\n ></p-slider>\n @if (!hideNumber()) {\n <span class=\"leading-none\">{{ value() ? value() + unit() : \"-\" }}</span>\n }\n</div>\n\n<mt-field-validation [control]=\"ngControl?.control\"></mt-field-validation>\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;;;MA2Ca,WAAW,CAAA;AAEtB,IAAA,KAAK;AAEI,IAAA,KAAK,GAAG,KAAK,CAAU,IAAI,iDAAC;IAC5B,KAAK,GAAG,KAAK,CAAA,IAAA,SAAA,GAAA,CAAA,SAAA,EAAA,EAAA,SAAA,EAAA,OAAA,EAAA,CAAA,GAAA,EAAA,CAAA,CAAU;AACvB,IAAA,OAAO,GAAG,KAAK,CAAU,IAAI,mDAAC;AAC9B,IAAA,KAAK,GAAG,KAAK,CAAS,EAAE,iDAAC;AACzB,IAAA,GAAG,GAAG,KAAK,CAAkB,CAAC,uCAAI,SAAS,EAAE,eAAe,EAAA,CAAA,GAAA,CAA5B,EAAE,SAAS,EAAE,e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AK,EAAA,CAAA;sBADJ,SAAS;AAAC,gBAAA,IAAA,EAAA,CAAA,OAAO,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE;gBAoB1B,QAAQ,EAAA,CAAA;sBAAjB;gBACS,UAAU,EAAA,CAAA;sBAAnB;gBAEqB,UAAU,EAAA,CAAA;sBAA/B,WAAW;uBAAC,OAAO;;;AEnEtB;;AAEG;;;;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { input, signal, inject, HostBinding, ViewChild, ChangeDetectionStrategy, Component } from '@angular/core';
|
|
2
|
+
import { input, signal, inject, effect, HostBinding, ViewChild, ChangeDetectionStrategy, Component } from '@angular/core';
|
|
3
3
|
import * as i2 from 'primeng/inputtext';
|
|
4
4
|
import { InputTextModule } from 'primeng/inputtext';
|
|
5
5
|
import * as i1 from '@angular/forms';
|
|
@@ -28,6 +28,7 @@ class TextField {
|
|
|
28
28
|
readonly = input(false, ...(ngDevMode ? [{ debugName: "readonly" }] : []));
|
|
29
29
|
pInputs = input(...(ngDevMode ? [undefined, { debugName: "pInputs" }] : []));
|
|
30
30
|
pKeyFilter = input(...(ngDevMode ? [undefined, { debugName: "pKeyFilter" }] : []));
|
|
31
|
+
required = input(false, ...(ngDevMode ? [{ debugName: "required" }] : []));
|
|
31
32
|
// readonly externalControl = input<any>(null);
|
|
32
33
|
styleClass;
|
|
33
34
|
requiredValidator = Validators.required;
|
|
@@ -50,6 +51,12 @@ class TextField {
|
|
|
50
51
|
// If injection fails, ngControl will remain null
|
|
51
52
|
this.ngControl = null;
|
|
52
53
|
}
|
|
54
|
+
effect(() => {
|
|
55
|
+
if (this.ngControl?.control && this.required()) {
|
|
56
|
+
this.ngControl.control.addValidators(Validators.required);
|
|
57
|
+
this.ngControl.control.updateValueAndValidity();
|
|
58
|
+
}
|
|
59
|
+
});
|
|
53
60
|
}
|
|
54
61
|
ngOnInit() {
|
|
55
62
|
this.styleClass = this.class();
|
|
@@ -87,7 +94,7 @@ class TextField {
|
|
|
87
94
|
this.disabled.set(disabled);
|
|
88
95
|
}
|
|
89
96
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.3", ngImport: i0, type: TextField, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
90
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.1.3", type: TextField, isStandalone: true, selector: "mt-text-field", inputs: { field: { classPropertyName: "field", publicName: "field", isSignal: true, isRequired: false, transformFunction: null }, hint: { classPropertyName: "hint", publicName: "hint", isSignal: true, isRequired: false, transformFunction: null }, label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, placeholder: { classPropertyName: "placeholder", publicName: "placeholder", isSignal: true, isRequired: false, transformFunction: null }, class: { classPropertyName: "class", publicName: "class", isSignal: true, isRequired: false, transformFunction: null }, type: { classPropertyName: "type", publicName: "type", isSignal: true, isRequired: false, transformFunction: null }, readonly: { classPropertyName: "readonly", publicName: "readonly", isSignal: true, isRequired: false, transformFunction: null }, pInputs: { classPropertyName: "pInputs", publicName: "pInputs", isSignal: true, isRequired: false, transformFunction: null }, pKeyFilter: { classPropertyName: "pKeyFilter", publicName: "pKeyFilter", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class": "this.styleClass" }, classAttribute: "grid gap-1" }, viewQueries: [{ propertyName: "inputText", first: true, predicate: ["inputText"], descendants: true, static: true }], usesOnChanges: true, ngImport: i0, template: "@if (label()) {\n <label\n [class.required]=\"ngControl?.control?.hasValidator(requiredValidator)\"\n [for]=\"ngControl?.name || label()\"\n >{{ label() }}</label\n >\n}\n@if (!hint()) {\n @if (!pKeyFilter()) {\n <input\n #inputText=\"\"\n pInputText=\"\"\n [ngModel]=\"value()\"\n (ngModelChange)=\"onValueChange($event)\"\n [disabled]=\"disabled() || readonly()\"\n [type]=\"type()\"\n [id]=\"ngControl?.name || label()\"\n [invalid]=\"isInvalid(ngControl?.control)\"\n (blur)=\"onTouched()\"\n placeholder=\"{{ placeholder() ?? label() ?? '' }}\"\n class=\"w-full\"\n />\n }\n @if (pKeyFilter()) {\n <input\n #inputText=\"\"\n pInputText=\"\"\n [ngModel]=\"value()\"\n (ngModelChange)=\"onValueChange($event)\"\n [disabled]=\"disabled() || readonly()\"\n [type]=\"type()\"\n [id]=\"ngControl?.name || label()\"\n [invalid]=\"isInvalid(ngControl?.control)\"\n (blur)=\"onTouched()\"\n placeholder=\"{{ placeholder() ?? label() ?? '' }}\"\n class=\"w-full\"\n [pKeyFilter]=\"pKeyFilter() === 'alphanum' ? alphaNum : pKeyFilter()\"\n />\n }\n} @else {\n <p-inputgroup>\n @if (!pKeyFilter()) {\n <input\n #inputText=\"\"\n pInputText=\"\"\n [ngModel]=\"value()\"\n (ngModelChange)=\"onValueChange($event)\"\n [disabled]=\"disabled() || readonly()\"\n [type]=\"type()\"\n [id]=\"ngControl?.name || label()\"\n [invalid]=\"isInvalid(ngControl?.control)\"\n (blur)=\"onTouched()\"\n placeholder=\"{{ placeholder() ?? label() ?? '' }}\"\n class=\"w-full\"\n />\n }\n @if (pKeyFilter()) {\n <input\n #inputText=\"\"\n pInputText=\"\"\n [ngModel]=\"value()\"\n (ngModelChange)=\"onValueChange($event)\"\n [disabled]=\"disabled() || readonly()\"\n [type]=\"type()\"\n [id]=\"ngControl?.name || label()\"\n [invalid]=\"isInvalid(ngControl?.control)\"\n (blur)=\"onTouched()\"\n placeholder=\"{{ placeholder() ?? label() ?? '' }}\"\n class=\"w-full\"\n [pKeyFilter]=\"pKeyFilter() === 'alphanum' ? alphaNum : pKeyFilter()\"\n />\n }\n <p-inputgroup-addon [pTooltip]=\"hint()\" tooltipPosition=\"top\">\n <mt-icon icon=\"general.help-circle\" />\n </p-inputgroup-addon>\n </p-inputgroup>\n}\n\n<mt-field-validation [control]=\"ngControl?.control\"></mt-field-validation>\n", styles: [""], dependencies: [{ kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1.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.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "ngmodule", type: InputTextModule }, { kind: "directive", type: i2.InputText, selector: "[pInputText]", inputs: ["pSize", "variant", "fluid", "invalid"] }, { kind: "ngmodule", type: KeyFilterModule }, { kind: "directive", type: i3.KeyFilter, selector: "[pKeyFilter]", inputs: ["pValidateOnly", "pKeyFilter"], outputs: ["ngModelChange"] }, { kind: "ngmodule", type: TooltipModule }, { kind: "directive", type: i4.Tooltip, selector: "[pTooltip]", inputs: ["tooltipPosition", "tooltipEvent", "positionStyle", "tooltipStyleClass", "tooltipZIndex", "escape", "showDelay", "hideDelay", "life", "positionTop", "positionLeft", "autoHide", "fitContent", "hideOnEscape", "pTooltip", "tooltipDisabled", "tooltipOptions", "appendTo"] }, { kind: "ngmodule", type: InputGroupModule }, { kind: "component", type: i5.InputGroup, selector: "p-inputgroup, p-inputGroup, p-input-group", inputs: ["styleClass"] }, { kind: "ngmodule", type: InputGroupAddonModule }, { kind: "component", type: i6.InputGroupAddon, selector: "p-inputgroup-addon, p-inputGroupAddon", inputs: ["style", "styleClass"] }, { kind: "component", type: FieldValidation, selector: "mt-field-validation", inputs: ["control", "touched"] }, { kind: "component", type: Icon, selector: "mt-icon", inputs: ["icon"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
97
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.1.3", type: TextField, isStandalone: true, selector: "mt-text-field", inputs: { field: { classPropertyName: "field", publicName: "field", isSignal: true, isRequired: false, transformFunction: null }, hint: { classPropertyName: "hint", publicName: "hint", isSignal: true, isRequired: false, transformFunction: null }, label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, placeholder: { classPropertyName: "placeholder", publicName: "placeholder", isSignal: true, isRequired: false, transformFunction: null }, class: { classPropertyName: "class", publicName: "class", isSignal: true, isRequired: false, transformFunction: null }, type: { classPropertyName: "type", publicName: "type", isSignal: true, isRequired: false, transformFunction: null }, readonly: { classPropertyName: "readonly", publicName: "readonly", isSignal: true, isRequired: false, transformFunction: null }, pInputs: { classPropertyName: "pInputs", publicName: "pInputs", isSignal: true, isRequired: false, transformFunction: null }, pKeyFilter: { classPropertyName: "pKeyFilter", publicName: "pKeyFilter", isSignal: true, isRequired: false, transformFunction: null }, required: { classPropertyName: "required", publicName: "required", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class": "this.styleClass" }, classAttribute: "grid gap-1" }, viewQueries: [{ propertyName: "inputText", first: true, predicate: ["inputText"], descendants: true, static: true }], usesOnChanges: true, ngImport: i0, template: "@if (label()) {\n <label\n [class.required]=\"ngControl?.control?.hasValidator(requiredValidator)\"\n [for]=\"ngControl?.name || label()\"\n >{{ label() }}</label\n >\n}\n@if (!hint()) {\n @if (!pKeyFilter()) {\n <input\n #inputText=\"\"\n pInputText=\"\"\n [ngModel]=\"value()\"\n (ngModelChange)=\"onValueChange($event)\"\n [disabled]=\"disabled() || readonly()\"\n [type]=\"type()\"\n [id]=\"ngControl?.name || label()\"\n [invalid]=\"isInvalid(ngControl?.control)\"\n (blur)=\"onTouched()\"\n placeholder=\"{{ placeholder() ?? label() ?? '' }}\"\n class=\"w-full\"\n />\n }\n @if (pKeyFilter()) {\n <input\n #inputText=\"\"\n pInputText=\"\"\n [ngModel]=\"value()\"\n (ngModelChange)=\"onValueChange($event)\"\n [disabled]=\"disabled() || readonly()\"\n [type]=\"type()\"\n [id]=\"ngControl?.name || label()\"\n [invalid]=\"isInvalid(ngControl?.control)\"\n (blur)=\"onTouched()\"\n placeholder=\"{{ placeholder() ?? label() ?? '' }}\"\n class=\"w-full\"\n [pKeyFilter]=\"pKeyFilter() === 'alphanum' ? alphaNum : pKeyFilter()\"\n />\n }\n} @else {\n <p-inputgroup>\n @if (!pKeyFilter()) {\n <input\n #inputText=\"\"\n pInputText=\"\"\n [ngModel]=\"value()\"\n (ngModelChange)=\"onValueChange($event)\"\n [disabled]=\"disabled() || readonly()\"\n [type]=\"type()\"\n [id]=\"ngControl?.name || label()\"\n [invalid]=\"isInvalid(ngControl?.control)\"\n (blur)=\"onTouched()\"\n placeholder=\"{{ placeholder() ?? label() ?? '' }}\"\n class=\"w-full\"\n />\n }\n @if (pKeyFilter()) {\n <input\n #inputText=\"\"\n pInputText=\"\"\n [ngModel]=\"value()\"\n (ngModelChange)=\"onValueChange($event)\"\n [disabled]=\"disabled() || readonly()\"\n [type]=\"type()\"\n [id]=\"ngControl?.name || label()\"\n [invalid]=\"isInvalid(ngControl?.control)\"\n (blur)=\"onTouched()\"\n placeholder=\"{{ placeholder() ?? label() ?? '' }}\"\n class=\"w-full\"\n [pKeyFilter]=\"pKeyFilter() === 'alphanum' ? alphaNum : pKeyFilter()\"\n />\n }\n <p-inputgroup-addon [pTooltip]=\"hint()\" tooltipPosition=\"top\">\n <mt-icon icon=\"general.help-circle\" />\n </p-inputgroup-addon>\n </p-inputgroup>\n}\n\n<mt-field-validation [control]=\"ngControl?.control\"></mt-field-validation>\n", styles: [""], dependencies: [{ kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1.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.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "ngmodule", type: InputTextModule }, { kind: "directive", type: i2.InputText, selector: "[pInputText]", inputs: ["pSize", "variant", "fluid", "invalid"] }, { kind: "ngmodule", type: KeyFilterModule }, { kind: "directive", type: i3.KeyFilter, selector: "[pKeyFilter]", inputs: ["pValidateOnly", "pKeyFilter"], outputs: ["ngModelChange"] }, { kind: "ngmodule", type: TooltipModule }, { kind: "directive", type: i4.Tooltip, selector: "[pTooltip]", inputs: ["tooltipPosition", "tooltipEvent", "positionStyle", "tooltipStyleClass", "tooltipZIndex", "escape", "showDelay", "hideDelay", "life", "positionTop", "positionLeft", "autoHide", "fitContent", "hideOnEscape", "pTooltip", "tooltipDisabled", "tooltipOptions", "appendTo"] }, { kind: "ngmodule", type: InputGroupModule }, { kind: "component", type: i5.InputGroup, selector: "p-inputgroup, p-inputGroup, p-input-group", inputs: ["styleClass"] }, { kind: "ngmodule", type: InputGroupAddonModule }, { kind: "component", type: i6.InputGroupAddon, selector: "p-inputgroup-addon, p-inputGroupAddon", inputs: ["style", "styleClass"] }, { kind: "component", type: FieldValidation, selector: "mt-field-validation", inputs: ["control", "touched"] }, { kind: "component", type: Icon, selector: "mt-icon", inputs: ["icon"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
91
98
|
}
|
|
92
99
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.3", ngImport: i0, type: TextField, decorators: [{
|
|
93
100
|
type: Component,
|