@masterteam/components 0.0.186 → 0.0.188
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 +2 -243
- package/fesm2022/masterteam-components-color-picker-field.mjs +102 -0
- package/fesm2022/masterteam-components-color-picker-field.mjs.map +1 -0
- package/fesm2022/masterteam-components-drawer.mjs +261 -0
- package/fesm2022/masterteam-components-drawer.mjs.map +1 -0
- package/fesm2022/masterteam-components-editor-field.mjs +99 -0
- package/fesm2022/masterteam-components-editor-field.mjs.map +1 -0
- package/fesm2022/masterteam-components-formula.mjs +3641 -0
- package/fesm2022/masterteam-components-formula.mjs.map +1 -0
- package/fesm2022/masterteam-components-icon-field.mjs +161 -0
- package/fesm2022/masterteam-components-icon-field.mjs.map +1 -0
- package/fesm2022/masterteam-components-list.mjs +31 -0
- package/fesm2022/masterteam-components-list.mjs.map +1 -0
- package/fesm2022/masterteam-components-location-field.mjs +322 -0
- package/fesm2022/masterteam-components-location-field.mjs.map +1 -0
- package/fesm2022/masterteam-components-menu.mjs +135 -0
- package/fesm2022/masterteam-components-menu.mjs.map +1 -0
- package/fesm2022/masterteam-components-module-summary-card.mjs +34 -0
- package/fesm2022/masterteam-components-module-summary-card.mjs.map +1 -0
- package/fesm2022/masterteam-components-multi-select-field.mjs +16 -4
- package/fesm2022/masterteam-components-multi-select-field.mjs.map +1 -1
- package/fesm2022/masterteam-components-page-header.mjs +42 -0
- package/fesm2022/masterteam-components-page-header.mjs.map +1 -0
- package/fesm2022/masterteam-components-page.mjs +35 -0
- package/fesm2022/masterteam-components-page.mjs.map +1 -0
- package/fesm2022/masterteam-components-pick-list-field.mjs +206 -0
- package/fesm2022/masterteam-components-pick-list-field.mjs.map +1 -0
- package/fesm2022/masterteam-components-property-filter-builder.mjs +386 -0
- package/fesm2022/masterteam-components-property-filter-builder.mjs.map +1 -0
- package/fesm2022/masterteam-components-radio-button-field.mjs +85 -0
- package/fesm2022/masterteam-components-radio-button-field.mjs.map +1 -0
- package/fesm2022/masterteam-components-radio-cards-field.mjs +126 -0
- package/fesm2022/masterteam-components-radio-cards-field.mjs.map +1 -0
- package/fesm2022/masterteam-components-radio-cards.mjs +74 -0
- package/fesm2022/masterteam-components-radio-cards.mjs.map +1 -0
- package/fesm2022/masterteam-components-runtime-action.mjs +406 -0
- package/fesm2022/masterteam-components-runtime-action.mjs.map +1 -0
- package/fesm2022/masterteam-components-select-field.mjs +10 -4
- package/fesm2022/masterteam-components-select-field.mjs.map +1 -1
- package/fesm2022/masterteam-components-sidebar.mjs +37 -0
- package/fesm2022/masterteam-components-sidebar.mjs.map +1 -0
- package/fesm2022/masterteam-components-slider-field.mjs +115 -0
- package/fesm2022/masterteam-components-slider-field.mjs.map +1 -0
- package/fesm2022/masterteam-components-statistic-card.mjs +22 -0
- package/fesm2022/masterteam-components-statistic-card.mjs.map +1 -0
- package/fesm2022/masterteam-components-table.mjs +10 -3
- package/fesm2022/masterteam-components-table.mjs.map +1 -1
- package/fesm2022/masterteam-components-textarea-field.mjs +122 -0
- package/fesm2022/masterteam-components-textarea-field.mjs.map +1 -0
- package/fesm2022/masterteam-components-toast.mjs +80 -0
- package/fesm2022/masterteam-components-toast.mjs.map +1 -0
- package/fesm2022/masterteam-components-topbar.mjs +32 -0
- package/fesm2022/masterteam-components-topbar.mjs.map +1 -0
- package/fesm2022/masterteam-components-tree.mjs +260 -0
- package/fesm2022/masterteam-components-tree.mjs.map +1 -0
- package/package.json +1 -1
- package/types/masterteam-components-color-picker-field.d.ts +35 -0
- package/types/masterteam-components-drawer.d.ts +61 -0
- package/types/masterteam-components-editor-field.d.ts +35 -0
- package/types/masterteam-components-formula.d.ts +741 -0
- package/types/masterteam-components-icon-field.d.ts +40 -0
- package/types/masterteam-components-list.d.ts +18 -0
- package/types/masterteam-components-location-field.d.ts +95 -0
- package/types/masterteam-components-menu.d.ts +55 -0
- package/types/masterteam-components-module-summary-card.d.ts +18 -0
- package/types/masterteam-components-multi-select-field.d.ts +3 -0
- package/types/masterteam-components-page-header.d.ts +30 -0
- package/types/masterteam-components-page.d.ts +26 -0
- package/types/masterteam-components-pick-list-field.d.ts +61 -0
- package/types/masterteam-components-property-filter-builder.d.ts +90 -0
- package/types/masterteam-components-radio-button-field.d.ts +41 -0
- package/types/masterteam-components-radio-cards-field.d.ts +35 -0
- package/types/masterteam-components-radio-cards.d.ts +33 -0
- package/types/masterteam-components-runtime-action.d.ts +105 -0
- package/types/masterteam-components-select-field.d.ts +3 -0
- package/types/masterteam-components-sidebar.d.ts +28 -0
- package/types/masterteam-components-slider-field.d.ts +38 -0
- package/types/masterteam-components-statistic-card.d.ts +18 -0
- package/types/masterteam-components-table.d.ts +2 -2
- package/types/masterteam-components-textarea-field.d.ts +41 -0
- package/types/masterteam-components-toast.d.ts +27 -0
- package/types/masterteam-components-topbar.d.ts +20 -0
- package/types/masterteam-components-tree.d.ts +106 -0
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { input, signal, inject, effect, ChangeDetectionStrategy, Component } from '@angular/core';
|
|
3
|
+
import * as i1 from '@angular/forms';
|
|
4
|
+
import { Validators, NgControl, FormsModule } from '@angular/forms';
|
|
5
|
+
import { Select } from 'primeng/select';
|
|
6
|
+
import { TranslocoPipe } from '@jsverse/transloco';
|
|
7
|
+
import * as mtIcons from '@masterteam/icons/assets/select-icons.json';
|
|
8
|
+
import { Icon } from '@masterteam/icons';
|
|
9
|
+
import { FieldValidation } from '@masterteam/components/field-validation';
|
|
10
|
+
import { isInvalid } from '@masterteam/components';
|
|
11
|
+
import { Tooltip } from '@masterteam/components/tooltip';
|
|
12
|
+
|
|
13
|
+
const ICON_SEARCH_ALIASES = {
|
|
14
|
+
add: ['plus', 'create', 'new'],
|
|
15
|
+
alert: ['warning', 'notification'],
|
|
16
|
+
approved: ['check', 'done', 'verified'],
|
|
17
|
+
calendar: ['date', 'schedule'],
|
|
18
|
+
chart: ['graph', 'analytics'],
|
|
19
|
+
check: ['tick', 'done', 'approved'],
|
|
20
|
+
clock: ['time'],
|
|
21
|
+
cog: ['gear', 'settings', 'config'],
|
|
22
|
+
config: ['settings', 'gear', 'cog'],
|
|
23
|
+
dollar: ['money', 'finance', 'currency'],
|
|
24
|
+
file: ['document'],
|
|
25
|
+
folder: ['directory'],
|
|
26
|
+
gear: ['settings', 'config', 'cog'],
|
|
27
|
+
lg: ['large'],
|
|
28
|
+
mail: ['email'],
|
|
29
|
+
md: ['medium'],
|
|
30
|
+
message: ['chat', 'comment'],
|
|
31
|
+
minus: ['remove', 'subtract'],
|
|
32
|
+
plus: ['add', 'create', 'new'],
|
|
33
|
+
search: ['find', 'lookup'],
|
|
34
|
+
settings: ['config', 'gear', 'cog'],
|
|
35
|
+
sm: ['small'],
|
|
36
|
+
sp: ['special'],
|
|
37
|
+
trash: ['delete', 'remove'],
|
|
38
|
+
user: ['person', 'profile'],
|
|
39
|
+
users: ['team', 'group'],
|
|
40
|
+
x: ['close', 'cancel', 'remove'],
|
|
41
|
+
};
|
|
42
|
+
const ICON_DISPLAY_TOKEN_LABELS = {
|
|
43
|
+
lg: 'large',
|
|
44
|
+
md: 'medium',
|
|
45
|
+
sm: 'small',
|
|
46
|
+
};
|
|
47
|
+
class IconField {
|
|
48
|
+
label = input('', ...(ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []));
|
|
49
|
+
required = input(false, ...(ngDevMode ? [{ debugName: "required" }] : /* istanbul ignore next */ []));
|
|
50
|
+
icons = (mtIcons?.regular ?? []).map((icon) => this.createIconOption(icon));
|
|
51
|
+
selectedIcon = signal(null, ...(ngDevMode ? [{ debugName: "selectedIcon" }] : /* istanbul ignore next */ []));
|
|
52
|
+
requiredValidator = Validators.required;
|
|
53
|
+
ngControl = inject(NgControl, { self: true, optional: true });
|
|
54
|
+
isInvalid = isInvalid;
|
|
55
|
+
constructor() {
|
|
56
|
+
if (this.ngControl) {
|
|
57
|
+
this.ngControl.valueAccessor = this;
|
|
58
|
+
}
|
|
59
|
+
effect(() => {
|
|
60
|
+
const control = this.ngControl?.control;
|
|
61
|
+
if (control && this.required()) {
|
|
62
|
+
control.addValidators(Validators.required);
|
|
63
|
+
control.updateValueAndValidity();
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
onTouched = () => { };
|
|
68
|
+
onChange = () => { };
|
|
69
|
+
writeValue(value) {
|
|
70
|
+
this.selectedIcon.set(value ?? null);
|
|
71
|
+
}
|
|
72
|
+
registerOnChange(fn) {
|
|
73
|
+
this.onChange = fn;
|
|
74
|
+
}
|
|
75
|
+
registerOnTouched(fn) {
|
|
76
|
+
this.onTouched = fn;
|
|
77
|
+
}
|
|
78
|
+
onChangeIcon(icon) {
|
|
79
|
+
this.selectedIcon.set(icon ?? null);
|
|
80
|
+
this.onChange(icon ?? null);
|
|
81
|
+
}
|
|
82
|
+
validate(c) {
|
|
83
|
+
return c.errors;
|
|
84
|
+
}
|
|
85
|
+
getIconKey(optionOrKey) {
|
|
86
|
+
if (!optionOrKey)
|
|
87
|
+
return null;
|
|
88
|
+
return typeof optionOrKey === 'string' ? optionOrKey : optionOrKey.key;
|
|
89
|
+
}
|
|
90
|
+
getIconTooltip(optionOrKey) {
|
|
91
|
+
if (!optionOrKey)
|
|
92
|
+
return '';
|
|
93
|
+
const icon = typeof optionOrKey === 'string'
|
|
94
|
+
? this.icons.find((item) => item.key === optionOrKey)
|
|
95
|
+
: optionOrKey;
|
|
96
|
+
return icon ? `${icon.name} (${icon.key})` : String(optionOrKey);
|
|
97
|
+
}
|
|
98
|
+
createIconOption(icon) {
|
|
99
|
+
const [categoryKey = '', iconKey = icon] = icon.split('.', 2);
|
|
100
|
+
const keyTokens = this.tokenize(iconKey);
|
|
101
|
+
const category = this.toTitleCase(categoryKey);
|
|
102
|
+
const name = keyTokens.map((token) => this.toTitleCase(token)).join(' ');
|
|
103
|
+
const aliasTokens = keyTokens.flatMap((token) => ICON_SEARCH_ALIASES[token] ?? []);
|
|
104
|
+
return {
|
|
105
|
+
key: icon,
|
|
106
|
+
name,
|
|
107
|
+
category,
|
|
108
|
+
searchText: this.normalizeSearchText([
|
|
109
|
+
icon,
|
|
110
|
+
categoryKey,
|
|
111
|
+
category,
|
|
112
|
+
iconKey,
|
|
113
|
+
name,
|
|
114
|
+
...keyTokens,
|
|
115
|
+
...aliasTokens,
|
|
116
|
+
]),
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
tokenize(value) {
|
|
120
|
+
return value
|
|
121
|
+
.split(/[^a-zA-Z0-9]+/)
|
|
122
|
+
.map((token) => token.trim().toLowerCase())
|
|
123
|
+
.filter(Boolean);
|
|
124
|
+
}
|
|
125
|
+
toTitleCase(value) {
|
|
126
|
+
const normalized = ICON_DISPLAY_TOKEN_LABELS[value] ?? value;
|
|
127
|
+
return normalized
|
|
128
|
+
.split(/[^a-zA-Z0-9]+/)
|
|
129
|
+
.filter(Boolean)
|
|
130
|
+
.map((part) => `${part.charAt(0).toUpperCase()}${part.slice(1).toLowerCase()}`)
|
|
131
|
+
.join(' ');
|
|
132
|
+
}
|
|
133
|
+
normalizeSearchText(values) {
|
|
134
|
+
return Array.from(new Set(values
|
|
135
|
+
.flatMap((value) => [value, ...this.tokenize(value)])
|
|
136
|
+
.map((value) => value.trim().toLowerCase())
|
|
137
|
+
.filter(Boolean))).join(' ');
|
|
138
|
+
}
|
|
139
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: IconField, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
140
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.8", type: IconField, isStandalone: true, selector: "mt-icon-field", inputs: { label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, required: { classPropertyName: "required", publicName: "required", isSignal: true, isRequired: false, transformFunction: null } }, host: { classAttribute: "grid gap-1" }, ngImport: i0, template: "@if (label()) {\r\n <label\r\n (click)=\"dropdown.show(); dropdown.focus()\"\r\n [class.required]=\"ngControl?.control?.hasValidator(requiredValidator)\"\r\n [for]=\"ngControl?.name || label()\"\r\n >{{ label() }}</label\r\n >\r\n}\r\n<p-select\r\n #dropdown\r\n [options]=\"icons\"\r\n [filter]=\"true\"\r\n filterBy=\"searchText\"\r\n optionLabel=\"name\"\r\n optionValue=\"key\"\r\n dataKey=\"key\"\r\n [inputId]=\"ngControl?.name ? ngControl?.name?.toString() : label()\"\r\n appendTo=\"body\"\r\n (onBlur)=\"onTouched()\"\r\n (ngModelChange)=\"onChangeIcon($event)\"\r\n [ngModel]=\"selectedIcon()\"\r\n [invalid]=\"isInvalid(ngControl?.control)\"\r\n [placeholder]=\"'components.iconField.selectIcon' | transloco\"\r\n styleClass=\"w-full\"\r\n panelStyleClass=\"icon-select-panel\"\r\n>\r\n <ng-template let-icon #selectedItem>\r\n @let iconKey = getIconKey(icon);\r\n @if (iconKey) {\r\n <div\r\n class=\"flex items-center justify-center text-2xl\"\r\n [mtTooltip]=\"getIconTooltip(icon)\"\r\n tooltipPosition=\"top\"\r\n appendTo=\"body\"\r\n >\r\n <mt-icon [icon]=\"iconKey\" />\r\n </div>\r\n } @else {\r\n <div class=\"flex items-center justify-center\">\r\n {{ \"components.iconField.selectIcon\" | transloco }}\r\n </div>\r\n }\r\n </ng-template>\r\n <ng-template let-icon #item>\r\n <div\r\n class=\"w-full h-full flex items-center justify-center text-lg\"\r\n [attr.aria-label]=\"getIconTooltip(icon)\"\r\n [title]=\"getIconTooltip(icon)\"\r\n [mtTooltip]=\"getIconTooltip(icon)\"\r\n tooltipPosition=\"top\"\r\n appendTo=\"body\"\r\n >\r\n <mt-icon [icon]=\"icon.key\" />\r\n </div>\r\n </ng-template>\r\n</p-select>\r\n\r\n<mt-field-validation [control]=\"ngControl?.control\"></mt-field-validation>\r\n", styles: ["::ng-deep .icon-select-panel{width:min(22rem,100vw - 2rem)}::ng-deep .icon-select-panel .p-select-filter-container{padding-inline:calc(var(--spacing) * 2);padding-block:calc(var(--spacing) * 2)}::ng-deep .icon-select-panel .p-select-list-container .p-select-list{display:grid;grid-template-columns:repeat(7,1fr);padding-inline:calc(var(--spacing) * 2);gap:.5rem}::ng-deep .icon-select-panel .p-select-list-container .p-select-list .p-select-option{padding:.25rem;border-radius:var(--p-select-option-border-radius);width:2.5rem;height:2.5rem}\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: "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", "motionOptions"], outputs: ["onChange", "onFilter", "onFocus", "onBlur", "onClick", "onShow", "onHide", "onClear", "onLazyLoad"] }, { kind: "component", type: Icon, selector: "mt-icon", inputs: ["icon"] }, { kind: "component", type: FieldValidation, selector: "mt-field-validation", inputs: ["control", "touched"] }, { kind: "directive", type: Tooltip, selector: "[mtTooltip]" }, { kind: "pipe", type: TranslocoPipe, name: "transloco" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
141
|
+
}
|
|
142
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: IconField, decorators: [{
|
|
143
|
+
type: Component,
|
|
144
|
+
args: [{ selector: 'mt-icon-field', imports: [
|
|
145
|
+
FormsModule,
|
|
146
|
+
Select,
|
|
147
|
+
Icon,
|
|
148
|
+
FieldValidation,
|
|
149
|
+
TranslocoPipe,
|
|
150
|
+
Tooltip,
|
|
151
|
+
], changeDetection: ChangeDetectionStrategy.OnPush, host: {
|
|
152
|
+
class: 'grid gap-1',
|
|
153
|
+
}, template: "@if (label()) {\r\n <label\r\n (click)=\"dropdown.show(); dropdown.focus()\"\r\n [class.required]=\"ngControl?.control?.hasValidator(requiredValidator)\"\r\n [for]=\"ngControl?.name || label()\"\r\n >{{ label() }}</label\r\n >\r\n}\r\n<p-select\r\n #dropdown\r\n [options]=\"icons\"\r\n [filter]=\"true\"\r\n filterBy=\"searchText\"\r\n optionLabel=\"name\"\r\n optionValue=\"key\"\r\n dataKey=\"key\"\r\n [inputId]=\"ngControl?.name ? ngControl?.name?.toString() : label()\"\r\n appendTo=\"body\"\r\n (onBlur)=\"onTouched()\"\r\n (ngModelChange)=\"onChangeIcon($event)\"\r\n [ngModel]=\"selectedIcon()\"\r\n [invalid]=\"isInvalid(ngControl?.control)\"\r\n [placeholder]=\"'components.iconField.selectIcon' | transloco\"\r\n styleClass=\"w-full\"\r\n panelStyleClass=\"icon-select-panel\"\r\n>\r\n <ng-template let-icon #selectedItem>\r\n @let iconKey = getIconKey(icon);\r\n @if (iconKey) {\r\n <div\r\n class=\"flex items-center justify-center text-2xl\"\r\n [mtTooltip]=\"getIconTooltip(icon)\"\r\n tooltipPosition=\"top\"\r\n appendTo=\"body\"\r\n >\r\n <mt-icon [icon]=\"iconKey\" />\r\n </div>\r\n } @else {\r\n <div class=\"flex items-center justify-center\">\r\n {{ \"components.iconField.selectIcon\" | transloco }}\r\n </div>\r\n }\r\n </ng-template>\r\n <ng-template let-icon #item>\r\n <div\r\n class=\"w-full h-full flex items-center justify-center text-lg\"\r\n [attr.aria-label]=\"getIconTooltip(icon)\"\r\n [title]=\"getIconTooltip(icon)\"\r\n [mtTooltip]=\"getIconTooltip(icon)\"\r\n tooltipPosition=\"top\"\r\n appendTo=\"body\"\r\n >\r\n <mt-icon [icon]=\"icon.key\" />\r\n </div>\r\n </ng-template>\r\n</p-select>\r\n\r\n<mt-field-validation [control]=\"ngControl?.control\"></mt-field-validation>\r\n", styles: ["::ng-deep .icon-select-panel{width:min(22rem,100vw - 2rem)}::ng-deep .icon-select-panel .p-select-filter-container{padding-inline:calc(var(--spacing) * 2);padding-block:calc(var(--spacing) * 2)}::ng-deep .icon-select-panel .p-select-list-container .p-select-list{display:grid;grid-template-columns:repeat(7,1fr);padding-inline:calc(var(--spacing) * 2);gap:.5rem}::ng-deep .icon-select-panel .p-select-list-container .p-select-list .p-select-option{padding:.25rem;border-radius:var(--p-select-option-border-radius);width:2.5rem;height:2.5rem}\n"] }]
|
|
154
|
+
}], ctorParameters: () => [], propDecorators: { label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: false }] }], required: [{ type: i0.Input, args: [{ isSignal: true, alias: "required", required: false }] }] } });
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Generated bundle index. Do not edit.
|
|
158
|
+
*/
|
|
159
|
+
|
|
160
|
+
export { IconField };
|
|
161
|
+
//# sourceMappingURL=masterteam-components-icon-field.mjs.map
|
|
@@ -0,0 +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 {\r\n Component,\r\n signal,\r\n inject,\r\n input,\r\n ChangeDetectionStrategy,\r\n effect,\r\n} from '@angular/core';\r\nimport {\r\n ControlValueAccessor,\r\n FormControl,\r\n FormsModule,\r\n NgControl,\r\n Validators,\r\n} from '@angular/forms';\r\nimport { Select } from 'primeng/select';\r\nimport { TranslocoPipe } from '@jsverse/transloco';\r\nimport * as mtIcons from '@masterteam/icons/assets/select-icons.json';\r\nimport { Icon, MTIcon } from '@masterteam/icons';\r\nimport { FieldValidation } from '@masterteam/components/field-validation';\r\nimport { isInvalid } from '@masterteam/components';\r\nimport { Tooltip } from '@masterteam/components/tooltip';\r\n\r\nexport interface IconFieldOption {\r\n key: MTIcon;\r\n name: string;\r\n category: string;\r\n searchText: string;\r\n}\r\n\r\nconst ICON_SEARCH_ALIASES: Record<string, readonly string[]> = {\n add: ['plus', 'create', 'new'],\n alert: ['warning', 'notification'],\n approved: ['check', 'done', 'verified'],\n calendar: ['date', 'schedule'],\n chart: ['graph', 'analytics'],\n check: ['tick', 'done', 'approved'],\n clock: ['time'],\n cog: ['gear', 'settings', 'config'],\n config: ['settings', 'gear', 'cog'],\n dollar: ['money', 'finance', 'currency'],\n file: ['document'],\n folder: ['directory'],\n gear: ['settings', 'config', 'cog'],\n lg: ['large'],\n mail: ['email'],\n md: ['medium'],\n message: ['chat', 'comment'],\n minus: ['remove', 'subtract'],\n plus: ['add', 'create', 'new'],\n search: ['find', 'lookup'],\n settings: ['config', 'gear', 'cog'],\n sm: ['small'],\n sp: ['special'],\n trash: ['delete', 'remove'],\n user: ['person', 'profile'],\n users: ['team', 'group'],\r\n x: ['close', 'cancel', 'remove'],\n};\n\nconst ICON_DISPLAY_TOKEN_LABELS: Record<string, string> = {\n lg: 'large',\n md: 'medium',\n sm: 'small',\n};\n\r\n@Component({\r\n selector: 'mt-icon-field',\r\n imports: [\r\n FormsModule,\r\n Select,\r\n Icon,\r\n FieldValidation,\r\n TranslocoPipe,\r\n Tooltip,\r\n ],\r\n templateUrl: './icon-field.html',\r\n styleUrls: ['./icon-field.scss'],\r\n changeDetection: ChangeDetectionStrategy.OnPush,\r\n host: {\r\n class: 'grid gap-1',\r\n },\r\n})\r\nexport class IconField implements ControlValueAccessor {\r\n readonly label = input<string>('');\r\n readonly required = input<boolean>(false);\r\n\r\n icons: IconFieldOption[] = ((mtIcons?.regular as MTIcon[]) ?? []).map(\r\n (icon) => this.createIconOption(icon),\r\n );\r\n selectedIcon = signal<MTIcon | null>(null);\r\n requiredValidator = Validators.required;\r\n\r\n public ngControl = inject(NgControl, { self: true, optional: true });\r\n\r\n isInvalid = isInvalid;\r\n\r\n constructor() {\r\n if (this.ngControl) {\r\n this.ngControl.valueAccessor = this;\r\n }\r\n effect(() => {\r\n const control = this.ngControl?.control;\r\n if (control && this.required()) {\r\n control.addValidators(Validators.required);\r\n control.updateValueAndValidity();\r\n }\r\n });\r\n }\r\n\r\n protected onTouched: () => void = () => {};\r\n private onChange: (icon: MTIcon | null) => void = () => {};\r\n\r\n writeValue(value: MTIcon | null) {\r\n this.selectedIcon.set(value ?? null);\r\n }\r\n\r\n registerOnChange(fn: any) {\r\n this.onChange = fn;\r\n }\r\n\r\n registerOnTouched(fn: any) {\r\n this.onTouched = fn;\r\n }\r\n\r\n onChangeIcon(icon: MTIcon | null) {\r\n this.selectedIcon.set(icon ?? null);\r\n this.onChange(icon ?? null);\r\n }\r\n\r\n public validate(c: FormControl) {\r\n return c.errors;\r\n }\r\n\r\n getIconKey(optionOrKey: IconFieldOption | MTIcon | null): MTIcon | null {\r\n if (!optionOrKey) return null;\r\n return typeof optionOrKey === 'string' ? optionOrKey : optionOrKey.key;\r\n }\r\n\r\n getIconTooltip(optionOrKey: IconFieldOption | MTIcon | null): string {\r\n if (!optionOrKey) return '';\r\n const icon =\r\n typeof optionOrKey === 'string'\r\n ? this.icons.find((item) => item.key === optionOrKey)\r\n : optionOrKey;\r\n\r\n return icon ? `${icon.name} (${icon.key})` : String(optionOrKey);\r\n }\r\n\r\n private createIconOption(icon: MTIcon): IconFieldOption {\r\n const [categoryKey = '', iconKey = icon] = icon.split('.', 2);\r\n const keyTokens = this.tokenize(iconKey);\r\n const category = this.toTitleCase(categoryKey);\r\n const name = keyTokens.map((token) => this.toTitleCase(token)).join(' ');\r\n const aliasTokens = keyTokens.flatMap(\r\n (token) => ICON_SEARCH_ALIASES[token] ?? [],\r\n );\r\n\r\n return {\r\n key: icon,\r\n name,\r\n category,\r\n searchText: this.normalizeSearchText([\r\n icon,\r\n categoryKey,\r\n category,\r\n iconKey,\r\n name,\r\n ...keyTokens,\r\n ...aliasTokens,\r\n ]),\r\n };\r\n }\r\n\r\n private tokenize(value: string): string[] {\r\n return value\r\n .split(/[^a-zA-Z0-9]+/)\r\n .map((token) => token.trim().toLowerCase())\r\n .filter(Boolean);\r\n }\r\n\r\n private toTitleCase(value: string): string {\n const normalized = ICON_DISPLAY_TOKEN_LABELS[value] ?? value;\n return normalized\r\n .split(/[^a-zA-Z0-9]+/)\r\n .filter(Boolean)\r\n .map(\r\n (part) =>\r\n `${part.charAt(0).toUpperCase()}${part.slice(1).toLowerCase()}`,\r\n )\r\n .join(' ');\r\n }\r\n\r\n private normalizeSearchText(values: readonly string[]): string {\r\n return Array.from(\r\n new Set(\r\n values\r\n .flatMap((value) => [value, ...this.tokenize(value)])\r\n .map((value) => value.trim().toLowerCase())\r\n .filter(Boolean),\r\n ),\r\n ).join(' ');\r\n }\r\n}\r\n","@if (label()) {\r\n <label\r\n (click)=\"dropdown.show(); dropdown.focus()\"\r\n [class.required]=\"ngControl?.control?.hasValidator(requiredValidator)\"\r\n [for]=\"ngControl?.name || label()\"\r\n >{{ label() }}</label\r\n >\r\n}\r\n<p-select\r\n #dropdown\r\n [options]=\"icons\"\r\n [filter]=\"true\"\r\n filterBy=\"searchText\"\r\n optionLabel=\"name\"\r\n optionValue=\"key\"\r\n dataKey=\"key\"\r\n [inputId]=\"ngControl?.name ? ngControl?.name?.toString() : label()\"\r\n appendTo=\"body\"\r\n (onBlur)=\"onTouched()\"\r\n (ngModelChange)=\"onChangeIcon($event)\"\r\n [ngModel]=\"selectedIcon()\"\r\n [invalid]=\"isInvalid(ngControl?.control)\"\r\n [placeholder]=\"'components.iconField.selectIcon' | transloco\"\r\n styleClass=\"w-full\"\r\n panelStyleClass=\"icon-select-panel\"\r\n>\r\n <ng-template let-icon #selectedItem>\r\n @let iconKey = getIconKey(icon);\r\n @if (iconKey) {\r\n <div\r\n class=\"flex items-center justify-center text-2xl\"\r\n [mtTooltip]=\"getIconTooltip(icon)\"\r\n tooltipPosition=\"top\"\r\n appendTo=\"body\"\r\n >\r\n <mt-icon [icon]=\"iconKey\" />\r\n </div>\r\n } @else {\r\n <div class=\"flex items-center justify-center\">\r\n {{ \"components.iconField.selectIcon\" | transloco }}\r\n </div>\r\n }\r\n </ng-template>\r\n <ng-template let-icon #item>\r\n <div\r\n class=\"w-full h-full flex items-center justify-center text-lg\"\r\n [attr.aria-label]=\"getIconTooltip(icon)\"\r\n [title]=\"getIconTooltip(icon)\"\r\n [mtTooltip]=\"getIconTooltip(icon)\"\r\n tooltipPosition=\"top\"\r\n appendTo=\"body\"\r\n >\r\n <mt-icon [icon]=\"icon.key\" />\r\n </div>\r\n </ng-template>\r\n</p-select>\r\n\r\n<mt-field-validation [control]=\"ngControl?.control\"></mt-field-validation>\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;;;;;;AA8BA,MAAM,mBAAmB,GAAsC;AAC7D,IAAA,GAAG,EAAE,CAAC,MAAM,EAAE,QAAQ,EAAE,KAAK,CAAC;AAC9B,IAAA,KAAK,EAAE,CAAC,SAAS,EAAE,cAAc,CAAC;AAClC,IAAA,QAAQ,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,UAAU,CAAC;AACvC,IAAA,QAAQ,EAAE,CAAC,MAAM,EAAE,UAAU,CAAC;AAC9B,IAAA,KAAK,EAAE,CAAC,OAAO,EAAE,WAAW,CAAC;AAC7B,IAAA,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,CAAC;IACnC,KAAK,EAAE,CAAC,MAAM,CAAC;AACf,IAAA,GAAG,EAAE,CAAC,MAAM,E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,uBAAA,CAAA,MAAA,EAAA,CAAA;;2FAUJ,SAAS,EAAA,UAAA,EAAA,CAAA;kBAjBrB,SAAS;AACE,YAAA,IAAA,EAAA,CAAA,EAAA,QAAA,EAAA,eAAe,EAAA,OAAA,EAChB;wBACP,WAAW;wBACX,MAAM;wBACN,IAAI;wBACJ,eAAe;wBACf,aAAa;wBACb,OAAO;qBACR,EAAA,eAAA,EAGgB,uBAAuB,CAAC,MAAM,EAAA,IAAA,EACzC;AACJ,wBAAA,KAAK,EAAE,YAAY;AACpB,qBAAA,EAAA,QAAA,EAAA,w1DAAA,EAAA,MAAA,EAAA,CAAA,iiBAAA,CAAA,EAAA;;;AEjFH;;AAEG;;;;"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { input, booleanAttribute, contentChild, computed, Component } from '@angular/core';
|
|
3
|
+
import * as i1 from '@angular/common';
|
|
4
|
+
import { CommonModule } from '@angular/common';
|
|
5
|
+
|
|
6
|
+
class List {
|
|
7
|
+
// Input for the data array to loop through
|
|
8
|
+
data = input([], ...(ngDevMode ? [{ debugName: "data" }] : /* istanbul ignore next */ []));
|
|
9
|
+
separated = input(false, { ...(ngDevMode ? { debugName: "separated" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
10
|
+
// Content child to get the template from ng-content
|
|
11
|
+
itemTemplate = contentChild('item', ...(ngDevMode ? [{ debugName: "itemTemplate" }] : /* istanbul ignore next */ []));
|
|
12
|
+
// Alternative input for template reference
|
|
13
|
+
template = input(null, ...(ngDevMode ? [{ debugName: "template" }] : /* istanbul ignore next */ []));
|
|
14
|
+
// Computed signal for effective template (prioritize template() input over content child)
|
|
15
|
+
effectiveTemplate = computed(() => {
|
|
16
|
+
return this.template() || this.itemTemplate() || null;
|
|
17
|
+
}, ...(ngDevMode ? [{ debugName: "effectiveTemplate" }] : /* istanbul ignore next */ []));
|
|
18
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: List, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
19
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.8", 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\">\r\n @if (effectiveTemplate()) {\r\n @for (item of data(); track $index) {\r\n <div\r\n class=\"border-(--p-content-border-color)\"\r\n [class.border-b]=\"!$last && separated()\"\r\n >\r\n <ng-container\r\n [ngTemplateOutlet]=\"effectiveTemplate()\"\r\n [ngTemplateOutletContext]=\"{\r\n $implicit: item,\r\n index: $index,\r\n first: $first,\r\n last: $last,\r\n count: $count,\r\n }\"\r\n >\r\n </ng-container>\r\n </div>\r\n }\r\n }\r\n</div>\r\n", dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }] });
|
|
20
|
+
}
|
|
21
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: List, decorators: [{
|
|
22
|
+
type: Component,
|
|
23
|
+
args: [{ selector: 'mt-list', standalone: true, imports: [CommonModule], template: "<div class=\"template-list\">\r\n @if (effectiveTemplate()) {\r\n @for (item of data(); track $index) {\r\n <div\r\n class=\"border-(--p-content-border-color)\"\r\n [class.border-b]=\"!$last && separated()\"\r\n >\r\n <ng-container\r\n [ngTemplateOutlet]=\"effectiveTemplate()\"\r\n [ngTemplateOutletContext]=\"{\r\n $implicit: item,\r\n index: $index,\r\n first: $first,\r\n last: $last,\r\n count: $count,\r\n }\"\r\n >\r\n </ng-container>\r\n </div>\r\n }\r\n }\r\n</div>\r\n" }]
|
|
24
|
+
}], propDecorators: { data: [{ type: i0.Input, args: [{ isSignal: true, alias: "data", required: false }] }], separated: [{ type: i0.Input, args: [{ isSignal: true, alias: "separated", required: false }] }], itemTemplate: [{ type: i0.ContentChild, args: ['item', { isSignal: true }] }], template: [{ type: i0.Input, args: [{ isSignal: true, alias: "template", required: false }] }] } });
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Generated bundle index. Do not edit.
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
export { List };
|
|
31
|
+
//# sourceMappingURL=masterteam-components-list.mjs.map
|
|
@@ -0,0 +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 {\r\n Component,\r\n input,\r\n TemplateRef,\r\n contentChild,\r\n computed,\r\n booleanAttribute,\r\n} from '@angular/core';\r\nimport { CommonModule } from '@angular/common';\r\n\r\nexport interface ListItem {\r\n [key: string]: any;\r\n}\r\n\r\n@Component({\r\n selector: 'mt-list',\r\n standalone: true,\r\n imports: [CommonModule],\r\n templateUrl: './list.html',\r\n})\r\nexport class List {\r\n // Input for the data array to loop through\r\n data = input<ListItem[]>([]);\r\n\r\n separated = input<boolean, unknown>(false, { transform: booleanAttribute });\r\n\r\n // Content child to get the template from ng-content\r\n itemTemplate = contentChild<TemplateRef<any>>('item');\r\n // Alternative input for template reference\r\n template = input<TemplateRef<any> | null>(null);\r\n\r\n // Computed signal for effective template (prioritize template() input over content child)\r\n effectiveTemplate = computed(() => {\r\n return this.template() || this.itemTemplate() || null;\r\n });\r\n}\r\n","<div class=\"template-list\">\r\n @if (effectiveTemplate()) {\r\n @for (item of data(); track $index) {\r\n <div\r\n class=\"border-(--p-content-border-color)\"\r\n [class.border-b]=\"!$last && separated()\"\r\n >\r\n <ng-container\r\n [ngTemplateOutlet]=\"effectiveTemplate()\"\r\n [ngTemplateOutletContext]=\"{\r\n $implicit: item,\r\n index: $index,\r\n first: $first,\r\n last: $last,\r\n count: $count,\r\n }\"\r\n >\r\n </ng-container>\r\n </div>\r\n }\r\n }\r\n</div>\r\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,2EAAC;IAE5B,SAAS,GAAG,KAAK,CAAmB,KAAK,iFAAI,SAAS,EAAE,gBAAgB,EAAA,CAAG;;AAG3E,IAAA,YAAY,GAAG,YAAY,CAAmB,MAAM,mFAAC;;AAErD,IAAA,QAAQ,GAAG,KAAK,CAA0B,IAAI,+EAAC;;AAG/C,IAAA,iBAAiB,GAAG,QAAQ,CAAC,MAAK;QAChC,OAAO,IAAI,CAAC,QAAQ,EAAE,IAAI,IAAI,CAAC,YAAY,EAAE,IAAI,IAAI;AACvD,IAAA,CAAC,wFAAC;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,4mBAsBA,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,4mBAAA,EAAA;uQAUuB,MAAM,EAAA,EAAA,QAAA,EAAA,IAAA,EAAA,CAAA,EAAA,CAAA,EAAA,QAAA,EAAA,CAAA,EAAA,IAAA,EAAA,EAAA,CAAA,KAAA,EAAA,IAAA,EAAA,CAAA,EAAA,QAAA,EAAA,IAAA,EAAA,KAAA,EAAA,UAAA,EAAA,QAAA,EAAA,KAAA,EAAA,CAAA,EAAA,CAAA,EAAA,EAAA,CAAA;;AE3BtD;;AAEG;;;;"}
|
|
@@ -0,0 +1,322 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { input, inject, effect, ChangeDetectionStrategy, Component, signal, viewChild, computed } from '@angular/core';
|
|
3
|
+
import { HttpClient, HttpBackend, HttpParams } from '@angular/common/http';
|
|
4
|
+
import * as i1 from '@angular/forms';
|
|
5
|
+
import { FormGroup, FormControl, Validators, ReactiveFormsModule, NgControl, FormsModule } from '@angular/forms';
|
|
6
|
+
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|
7
|
+
import { TranslocoPipe, TranslocoService } from '@jsverse/transloco';
|
|
8
|
+
import * as i2 from 'primeng/autocomplete';
|
|
9
|
+
import { AutoCompleteModule } from 'primeng/autocomplete';
|
|
10
|
+
import * as i4 from 'primeng/inputgroup';
|
|
11
|
+
import { InputGroupModule } from 'primeng/inputgroup';
|
|
12
|
+
import * as i5 from 'primeng/inputgroupaddon';
|
|
13
|
+
import { InputGroupAddonModule } from 'primeng/inputgroupaddon';
|
|
14
|
+
import { Subject, debounceTime, tap, switchMap, take, of, finalize, catchError } from 'rxjs';
|
|
15
|
+
import { FieldValidation } from '@masterteam/components/field-validation';
|
|
16
|
+
import { isInvalid } from '@masterteam/components';
|
|
17
|
+
import { Tooltip } from '@masterteam/components/tooltip';
|
|
18
|
+
import { ModalService } from '@masterteam/components/modal';
|
|
19
|
+
import { Icon } from '@masterteam/icons';
|
|
20
|
+
import { Button } from '@masterteam/components/button';
|
|
21
|
+
import { ModalRef } from '@masterteam/components/dialog';
|
|
22
|
+
import { NumberField } from '@masterteam/components/number-field';
|
|
23
|
+
import { TextField } from '@masterteam/components/text-field';
|
|
24
|
+
import * as i3 from 'primeng/api';
|
|
25
|
+
|
|
26
|
+
function normalizeLocationValue(value) {
|
|
27
|
+
if (value === null || value === undefined || value === '') {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
if (typeof value === 'string') {
|
|
31
|
+
const trimmed = value.trim();
|
|
32
|
+
if (!trimmed)
|
|
33
|
+
return null;
|
|
34
|
+
try {
|
|
35
|
+
return normalizeLocationValue(JSON.parse(trimmed));
|
|
36
|
+
}
|
|
37
|
+
catch {
|
|
38
|
+
return {
|
|
39
|
+
display_name: trimmed,
|
|
40
|
+
address: trimmed,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
if (typeof value !== 'object') {
|
|
45
|
+
return {
|
|
46
|
+
display_name: String(value),
|
|
47
|
+
address: String(value),
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
const source = value;
|
|
51
|
+
const lat = source['lat'];
|
|
52
|
+
const lon = source['lon'] ?? source['lng'];
|
|
53
|
+
const displayName = readString(source['display_name']) ??
|
|
54
|
+
readString(source['displayName']) ??
|
|
55
|
+
readString(source['address']) ??
|
|
56
|
+
readString(source['name']);
|
|
57
|
+
return {
|
|
58
|
+
...source,
|
|
59
|
+
...(displayName ? { display_name: displayName, address: displayName } : {}),
|
|
60
|
+
...(lat !== undefined ? { lat: lat } : {}),
|
|
61
|
+
...(lon !== undefined
|
|
62
|
+
? { lon: lon, lng: lon }
|
|
63
|
+
: {}),
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
function getLocationDisplayName(value) {
|
|
67
|
+
return value?.display_name?.trim() || value?.address?.trim() || '';
|
|
68
|
+
}
|
|
69
|
+
function getLocationLongitude(value) {
|
|
70
|
+
return value?.lon ?? value?.lng;
|
|
71
|
+
}
|
|
72
|
+
function readString(value) {
|
|
73
|
+
return typeof value === 'string' && value.trim() ? value.trim() : undefined;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
class LocationManualDialog {
|
|
77
|
+
initialValue = input(null, ...(ngDevMode ? [{ debugName: "initialValue" }] : /* istanbul ignore next */ []));
|
|
78
|
+
modal = inject(ModalService);
|
|
79
|
+
ref = inject(ModalRef);
|
|
80
|
+
form = new FormGroup({
|
|
81
|
+
display_name: new FormControl('', {
|
|
82
|
+
nonNullable: true,
|
|
83
|
+
validators: [Validators.required],
|
|
84
|
+
}),
|
|
85
|
+
longitude: new FormControl(null, {
|
|
86
|
+
validators: [
|
|
87
|
+
Validators.required,
|
|
88
|
+
Validators.min(-180),
|
|
89
|
+
Validators.max(180),
|
|
90
|
+
],
|
|
91
|
+
}),
|
|
92
|
+
latitude: new FormControl(null, {
|
|
93
|
+
validators: [
|
|
94
|
+
Validators.required,
|
|
95
|
+
Validators.min(-90),
|
|
96
|
+
Validators.max(90),
|
|
97
|
+
],
|
|
98
|
+
}),
|
|
99
|
+
});
|
|
100
|
+
constructor() {
|
|
101
|
+
effect(() => {
|
|
102
|
+
const value = normalizeLocationValue(this.initialValue());
|
|
103
|
+
this.form.patchValue({
|
|
104
|
+
display_name: getLocationDisplayName(value),
|
|
105
|
+
longitude: coerceNumber(getLocationLongitude(value)),
|
|
106
|
+
latitude: coerceNumber(value?.lat),
|
|
107
|
+
}, { emitEvent: false });
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
cancel() {
|
|
111
|
+
this.ref.close(null);
|
|
112
|
+
}
|
|
113
|
+
save() {
|
|
114
|
+
if (this.form.invalid) {
|
|
115
|
+
this.form.markAllAsTouched();
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
const raw = this.form.getRawValue();
|
|
119
|
+
this.ref.close(normalizeLocationValue({
|
|
120
|
+
display_name: raw.display_name,
|
|
121
|
+
address: raw.display_name,
|
|
122
|
+
lon: raw.longitude,
|
|
123
|
+
lng: raw.longitude,
|
|
124
|
+
lat: raw.latitude,
|
|
125
|
+
}));
|
|
126
|
+
}
|
|
127
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: LocationManualDialog, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
128
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "21.2.8", type: LocationManualDialog, isStandalone: true, selector: "mt-location-manual-dialog", inputs: { initialValue: { classPropertyName: "initialValue", publicName: "initialValue", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: "<form\n [formGroup]=\"form\"\n [class]=\"modal.contentClass + ' flex flex-col gap-4 p-4'\"\n>\n <mt-text-field\n [label]=\"'components.locationField.displayName' | transloco\"\n [placeholder]=\"'components.locationField.displayName' | transloco\"\n formControlName=\"display_name\"\n [required]=\"true\"\n />\n <div class=\"grid grid-cols-1 gap-4 sm:grid-cols-2\">\n <mt-number-field\n [label]=\"'components.locationField.longitude' | transloco\"\n [placeholder]=\"'components.locationField.longitude' | transloco\"\n [min]=\"-180\"\n [max]=\"180\"\n formControlName=\"longitude\"\n [required]=\"true\"\n />\n <mt-number-field\n [label]=\"'components.locationField.latitude' | transloco\"\n [placeholder]=\"'components.locationField.latitude' | transloco\"\n [min]=\"-90\"\n [max]=\"90\"\n formControlName=\"latitude\"\n [required]=\"true\"\n />\n </div>\n</form>\n\n<div [class]=\"modal.footerClass\">\n <mt-button\n [label]=\"'components.locationField.cancel' | transloco\"\n variant=\"outlined\"\n (onClick)=\"cancel()\"\n />\n <mt-button\n [label]=\"'components.locationField.save' | transloco\"\n severity=\"primary\"\n [disabled]=\"form.invalid\"\n (onClick)=\"save()\"\n />\n</div>\n", dependencies: [{ kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i1.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],[formArray],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i1.RequiredValidator, selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]", inputs: ["required"] }, { kind: "directive", type: i1.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i1.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { kind: "component", type: Button, selector: "mt-button", inputs: ["icon", "label", "tooltip", "class", "type", "styleClass", "severity", "badge", "variant", "badgeSeverity", "size", "iconPos", "autofocus", "fluid", "raised", "rounded", "text", "plain", "outlined", "link", "disabled", "loading", "pInputs"], outputs: ["onClick", "onFocus", "onBlur"] }, { kind: "component", type: TextField, selector: "mt-text-field", inputs: ["field", "hint", "label", "placeholder", "class", "type", "readonly", "pInputs", "required", "maxLength", "icon", "iconPosition"] }, { kind: "component", type: NumberField, selector: "mt-number-field", inputs: ["field", "hint", "label", "placeholder", "class", "readonly", "pInputs", "format", "useGrouping", "maxFractionDigits", "min", "max", "required"] }, { kind: "pipe", type: TranslocoPipe, name: "transloco" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
129
|
+
}
|
|
130
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: LocationManualDialog, decorators: [{
|
|
131
|
+
type: Component,
|
|
132
|
+
args: [{ selector: 'mt-location-manual-dialog', imports: [ReactiveFormsModule, TranslocoPipe, Button, TextField, NumberField], changeDetection: ChangeDetectionStrategy.OnPush, template: "<form\n [formGroup]=\"form\"\n [class]=\"modal.contentClass + ' flex flex-col gap-4 p-4'\"\n>\n <mt-text-field\n [label]=\"'components.locationField.displayName' | transloco\"\n [placeholder]=\"'components.locationField.displayName' | transloco\"\n formControlName=\"display_name\"\n [required]=\"true\"\n />\n <div class=\"grid grid-cols-1 gap-4 sm:grid-cols-2\">\n <mt-number-field\n [label]=\"'components.locationField.longitude' | transloco\"\n [placeholder]=\"'components.locationField.longitude' | transloco\"\n [min]=\"-180\"\n [max]=\"180\"\n formControlName=\"longitude\"\n [required]=\"true\"\n />\n <mt-number-field\n [label]=\"'components.locationField.latitude' | transloco\"\n [placeholder]=\"'components.locationField.latitude' | transloco\"\n [min]=\"-90\"\n [max]=\"90\"\n formControlName=\"latitude\"\n [required]=\"true\"\n />\n </div>\n</form>\n\n<div [class]=\"modal.footerClass\">\n <mt-button\n [label]=\"'components.locationField.cancel' | transloco\"\n variant=\"outlined\"\n (onClick)=\"cancel()\"\n />\n <mt-button\n [label]=\"'components.locationField.save' | transloco\"\n severity=\"primary\"\n [disabled]=\"form.invalid\"\n (onClick)=\"save()\"\n />\n</div>\n" }]
|
|
133
|
+
}], ctorParameters: () => [], propDecorators: { initialValue: [{ type: i0.Input, args: [{ isSignal: true, alias: "initialValue", required: false }] }] } });
|
|
134
|
+
function coerceNumber(value) {
|
|
135
|
+
if (value === null || value === undefined || value === '') {
|
|
136
|
+
return null;
|
|
137
|
+
}
|
|
138
|
+
const parsed = Number(value);
|
|
139
|
+
return Number.isFinite(parsed) ? parsed : null;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
class LocationField {
|
|
143
|
+
hint = input(...(ngDevMode ? [undefined, { debugName: "hint" }] : /* istanbul ignore next */ []));
|
|
144
|
+
label = input(...(ngDevMode ? [undefined, { debugName: "label" }] : /* istanbul ignore next */ []));
|
|
145
|
+
placeholder = input(...(ngDevMode ? [undefined, { debugName: "placeholder" }] : /* istanbul ignore next */ []));
|
|
146
|
+
readonly = input(false, ...(ngDevMode ? [{ debugName: "readonly" }] : /* istanbul ignore next */ []));
|
|
147
|
+
required = input(false, ...(ngDevMode ? [{ debugName: "required" }] : /* istanbul ignore next */ []));
|
|
148
|
+
minLength = input(2, ...(ngDevMode ? [{ debugName: "minLength" }] : /* istanbul ignore next */ []));
|
|
149
|
+
configuration = input(null, ...(ngDevMode ? [{ debugName: "configuration" }] : /* istanbul ignore next */ []));
|
|
150
|
+
searchUrl = input('https://nominatim.openstreetmap.org/search', ...(ngDevMode ? [{ debugName: "searchUrl" }] : /* istanbul ignore next */ []));
|
|
151
|
+
value = signal(null, ...(ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []));
|
|
152
|
+
suggestions = signal([], ...(ngDevMode ? [{ debugName: "suggestions" }] : /* istanbul ignore next */ []));
|
|
153
|
+
disabled = signal(false, ...(ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []));
|
|
154
|
+
loading = signal(false, ...(ngDevMode ? [{ debugName: "loading" }] : /* istanbul ignore next */ []));
|
|
155
|
+
requiredValidator = Validators.required;
|
|
156
|
+
autocomplete = viewChild('autocomplete', ...(ngDevMode ? [{ debugName: "autocomplete" }] : /* istanbul ignore next */ []));
|
|
157
|
+
displayValue = computed(() => getLocationDisplayName(this.value()), ...(ngDevMode ? [{ debugName: "displayValue" }] : /* istanbul ignore next */ []));
|
|
158
|
+
resolvedSearchUrl = computed(() => {
|
|
159
|
+
const configuredUrl = this.configuration()?.nominatimBaseUrl;
|
|
160
|
+
return typeof configuredUrl === 'string' && configuredUrl.trim()
|
|
161
|
+
? configuredUrl
|
|
162
|
+
: (this.searchUrl() ?? 'https://nominatim.openstreetmap.org/search');
|
|
163
|
+
}, ...(ngDevMode ? [{ debugName: "resolvedSearchUrl" }] : /* istanbul ignore next */ []));
|
|
164
|
+
countryName = computed(() => {
|
|
165
|
+
const country = this.configuration()?.country;
|
|
166
|
+
if (typeof country === 'string')
|
|
167
|
+
return country.trim();
|
|
168
|
+
return country?.name?.trim() ?? '';
|
|
169
|
+
}, ...(ngDevMode ? [{ debugName: "countryName" }] : /* istanbul ignore next */ []));
|
|
170
|
+
countryCode = computed(() => {
|
|
171
|
+
const country = this.configuration()?.country;
|
|
172
|
+
if (typeof country === 'object')
|
|
173
|
+
return country?.code?.trim() ?? '';
|
|
174
|
+
return '';
|
|
175
|
+
}, ...(ngDevMode ? [{ debugName: "countryCode" }] : /* istanbul ignore next */ []));
|
|
176
|
+
viewBox = computed(() => {
|
|
177
|
+
const config = this.configuration();
|
|
178
|
+
const country = config?.country;
|
|
179
|
+
if (typeof config?.viewBox === 'string' && config.viewBox.trim()) {
|
|
180
|
+
return config.viewBox;
|
|
181
|
+
}
|
|
182
|
+
if (typeof country === 'object' && country?.viewBox?.trim()) {
|
|
183
|
+
return country.viewBox;
|
|
184
|
+
}
|
|
185
|
+
return '';
|
|
186
|
+
}, ...(ngDevMode ? [{ debugName: "viewBox" }] : /* istanbul ignore next */ []));
|
|
187
|
+
ngControl = null;
|
|
188
|
+
isInvalid = isInvalid;
|
|
189
|
+
modal = inject(ModalService);
|
|
190
|
+
transloco = inject(TranslocoService);
|
|
191
|
+
http = new HttpClient(inject(HttpBackend));
|
|
192
|
+
searchTerms = new Subject();
|
|
193
|
+
onTouched = () => { };
|
|
194
|
+
onModelChange = () => { };
|
|
195
|
+
constructor() {
|
|
196
|
+
this.ngControl = inject(NgControl, { self: true, optional: true });
|
|
197
|
+
if (this.ngControl) {
|
|
198
|
+
this.ngControl.valueAccessor = this;
|
|
199
|
+
}
|
|
200
|
+
effect(() => {
|
|
201
|
+
if (this.ngControl?.control && this.required()) {
|
|
202
|
+
this.ngControl.control.addValidators(Validators.required);
|
|
203
|
+
this.ngControl.control.updateValueAndValidity({ emitEvent: false });
|
|
204
|
+
}
|
|
205
|
+
});
|
|
206
|
+
this.searchTerms
|
|
207
|
+
.pipe(takeUntilDestroyed(), debounceTime(250), tap(() => this.loading.set(true)), switchMap((term) => this.searchLocations(term)))
|
|
208
|
+
.subscribe((items) => this.suggestions.set(items));
|
|
209
|
+
}
|
|
210
|
+
search(event) {
|
|
211
|
+
this.searchTerms.next(event.query);
|
|
212
|
+
}
|
|
213
|
+
onFocus() {
|
|
214
|
+
if (this.suggestions().length > 0) {
|
|
215
|
+
this.autocomplete()?.show();
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
onSelect(event) {
|
|
219
|
+
this.setValue(normalizeLocationValue(event.value));
|
|
220
|
+
this.suggestions.set([]);
|
|
221
|
+
this.loading.set(false);
|
|
222
|
+
this.autocomplete()?.hide();
|
|
223
|
+
}
|
|
224
|
+
onClear() {
|
|
225
|
+
this.setValue(null);
|
|
226
|
+
this.suggestions.set([]);
|
|
227
|
+
this.loading.set(false);
|
|
228
|
+
}
|
|
229
|
+
openManualDialog() {
|
|
230
|
+
if (this.disabled() || this.readonly())
|
|
231
|
+
return;
|
|
232
|
+
const ref = this.modal.openModal(LocationManualDialog, 'dialog', {
|
|
233
|
+
header: this.transloco.translate('components.locationField.manualHeader'),
|
|
234
|
+
styleClass: '!w-[40rem] max-w-[96vw]',
|
|
235
|
+
dismissableMask: true,
|
|
236
|
+
inputValues: {
|
|
237
|
+
initialValue: this.value(),
|
|
238
|
+
},
|
|
239
|
+
});
|
|
240
|
+
ref.onClose.pipe(take(1)).subscribe((result) => {
|
|
241
|
+
const next = normalizeLocationValue(result);
|
|
242
|
+
if (!next)
|
|
243
|
+
return;
|
|
244
|
+
this.setValue(next);
|
|
245
|
+
this.suggestions.set([]);
|
|
246
|
+
this.loading.set(false);
|
|
247
|
+
this.autocomplete()?.hide();
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
writeValue(value) {
|
|
251
|
+
this.value.set(normalizeLocationValue(value));
|
|
252
|
+
}
|
|
253
|
+
registerOnChange(fn) {
|
|
254
|
+
this.onModelChange = fn;
|
|
255
|
+
}
|
|
256
|
+
registerOnTouched(fn) {
|
|
257
|
+
this.onTouched = fn;
|
|
258
|
+
}
|
|
259
|
+
setDisabledState(disabled) {
|
|
260
|
+
this.disabled.set(disabled);
|
|
261
|
+
}
|
|
262
|
+
setValue(value) {
|
|
263
|
+
this.value.set(value);
|
|
264
|
+
this.onModelChange(value);
|
|
265
|
+
this.onTouched();
|
|
266
|
+
}
|
|
267
|
+
searchLocations(term) {
|
|
268
|
+
const trimmed = term?.trim();
|
|
269
|
+
if (!trimmed || trimmed.length < this.minLength()) {
|
|
270
|
+
this.loading.set(false);
|
|
271
|
+
return of([]);
|
|
272
|
+
}
|
|
273
|
+
const countryName = this.countryName();
|
|
274
|
+
const query = countryName && !trimmed.toLowerCase().includes(countryName.toLowerCase())
|
|
275
|
+
? `${trimmed}, ${countryName}`
|
|
276
|
+
: trimmed;
|
|
277
|
+
let params = new HttpParams()
|
|
278
|
+
.set('q', query)
|
|
279
|
+
.set('format', 'json')
|
|
280
|
+
.set('addressdetails', '1')
|
|
281
|
+
.set('limit', '10')
|
|
282
|
+
.set('accept-language', this.transloco.getActiveLang() || 'en');
|
|
283
|
+
const viewBox = this.viewBox();
|
|
284
|
+
if (viewBox) {
|
|
285
|
+
params = params.set('bounded', '1').set('viewbox', viewBox);
|
|
286
|
+
}
|
|
287
|
+
const countryCode = this.countryCode();
|
|
288
|
+
if (countryCode) {
|
|
289
|
+
params = params.set('countrycodes', countryCode.toLowerCase());
|
|
290
|
+
}
|
|
291
|
+
return this.http.get(this.resolvedSearchUrl(), { params }).pipe(finalize(() => this.loading.set(false)), catchError((error) => {
|
|
292
|
+
console.error('Location search failed:', error);
|
|
293
|
+
return of([]);
|
|
294
|
+
}), switchMap((items) => of(items
|
|
295
|
+
.map((item) => normalizeLocationValue(item))
|
|
296
|
+
.filter((item) => item !== null))));
|
|
297
|
+
}
|
|
298
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: LocationField, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
299
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.8", type: LocationField, isStandalone: true, selector: "mt-location-field", inputs: { 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 }, readonly: { classPropertyName: "readonly", publicName: "readonly", isSignal: true, isRequired: false, transformFunction: null }, required: { classPropertyName: "required", publicName: "required", isSignal: true, isRequired: false, transformFunction: null }, minLength: { classPropertyName: "minLength", publicName: "minLength", isSignal: true, isRequired: false, transformFunction: null }, configuration: { classPropertyName: "configuration", publicName: "configuration", isSignal: true, isRequired: false, transformFunction: null }, searchUrl: { classPropertyName: "searchUrl", publicName: "searchUrl", isSignal: true, isRequired: false, transformFunction: null } }, host: { classAttribute: "grid gap-1" }, viewQueries: [{ propertyName: "autocomplete", first: true, predicate: ["autocomplete"], descendants: true, isSignal: true }], ngImport: i0, template: "@if (label() || hint()) {\n <div class=\"mb-1 flex items-center gap-1\">\n @if (label()) {\n <label\n [class.required]=\"ngControl?.control?.hasValidator(requiredValidator)\"\n [for]=\"ngControl?.name || label()\"\n >\n {{ label() }}\n </label>\n }\n @if (hint()) {\n <span\n class=\"inline-flex text-surface-400\"\n [mtTooltip]=\"hint()\"\n tooltipPosition=\"top\"\n >\n <mt-icon icon=\"general.help-circle\" />\n </span>\n }\n </div>\n}\n\n<div class=\"relative\">\n <p-inputgroup>\n <p-autoComplete\n #autocomplete=\"\"\n [suggestions]=\"suggestions()\"\n (completeMethod)=\"search($event)\"\n (onSelect)=\"onSelect($event)\"\n (onClear)=\"onClear()\"\n (onFocus)=\"onFocus()\"\n (onBlur)=\"onTouched()\"\n [ngModel]=\"value()\"\n [disabled]=\"disabled() || readonly()\"\n [id]=\"ngControl?.name || label()\"\n [invalid]=\"isInvalid(ngControl?.control)\"\n [placeholder]=\"'components.locationField.search' | transloco\"\n [optionLabel]=\"'display_name'\"\n [minLength]=\"minLength()\"\n [forceSelection]=\"true\"\n class=\"w-full\"\n appendTo=\"body\"\n styleClass=\"w-full\"\n >\n <ng-template let-location pTemplate=\"item\">\n <div class=\"flex min-w-0 items-start gap-2\">\n <mt-icon icon=\"map.marker-pin-01\" class=\"mt-0.5 shrink-0 text-xl\" />\n <span class=\"min-w-0 text-wrap text-sm leading-5\">\n {{ location.display_name }}\n </span>\n </div>\n </ng-template>\n\n <ng-template let-location pTemplate=\"selecteditem\">\n <span class=\"min-w-0 truncate\">{{ location?.display_name }}</span>\n </ng-template>\n </p-autoComplete>\n\n <p-inputgroup-addon>\n <button\n type=\"button\"\n class=\"inline-flex h-full items-center justify-center text-surface-500 transition-colors hover:text-primary-500 disabled:cursor-not-allowed disabled:opacity-50\"\n [disabled]=\"disabled() || readonly()\"\n [mtTooltip]=\"'components.locationField.enterManually' | transloco\"\n tooltipPosition=\"top\"\n (click)=\"openManualDialog()\"\n >\n <mt-icon icon=\"general.edit-03\" />\n </button>\n </p-inputgroup-addon>\n </p-inputgroup>\n\n @if (loading()) {\n <mt-icon\n icon=\"general.loading-01\"\n class=\"absolute end-12 top-1/2 -translate-y-1/2 animate-spin bg-white\"\n />\n }\n</div>\n\n<mt-field-validation [control]=\"ngControl?.control\"></mt-field-validation>\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: AutoCompleteModule }, { kind: "component", type: i2.AutoComplete, selector: "p-autoComplete, p-autocomplete, p-auto-complete", inputs: ["minLength", "minQueryLength", "delay", "panelStyle", "styleClass", "panelStyleClass", "inputStyle", "inputId", "inputStyleClass", "placeholder", "readonly", "scrollHeight", "lazy", "virtualScroll", "virtualScrollItemSize", "virtualScrollOptions", "autoHighlight", "forceSelection", "type", "autoZIndex", "baseZIndex", "ariaLabel", "dropdownAriaLabel", "ariaLabelledBy", "dropdownIcon", "unique", "group", "completeOnFocus", "showClear", "dropdown", "showEmptyMessage", "dropdownMode", "multiple", "addOnTab", "tabindex", "dataKey", "emptyMessage", "showTransitionOptions", "hideTransitionOptions", "autofocus", "autocomplete", "optionGroupChildren", "optionGroupLabel", "overlayOptions", "suggestions", "optionLabel", "optionValue", "id", "searchMessage", "emptySelectionMessage", "selectionMessage", "autoOptionFocus", "selectOnFocus", "searchLocale", "optionDisabled", "focusOnHover", "typeahead", "addOnBlur", "separator", "appendTo", "motionOptions"], outputs: ["completeMethod", "onSelect", "onUnselect", "onAdd", "onFocus", "onBlur", "onDropdownClick", "onClear", "onInputKeydown", "onKeyUp", "onShow", "onHide", "onLazyLoad"] }, { kind: "directive", type: i3.PrimeTemplate, selector: "[pTemplate]", inputs: ["type", "pTemplate"] }, { kind: "ngmodule", type: InputGroupModule }, { kind: "component", type: i4.InputGroup, selector: "p-inputgroup, p-inputGroup, p-input-group", inputs: ["styleClass"] }, { kind: "ngmodule", type: InputGroupAddonModule }, { kind: "component", type: i5.InputGroupAddon, selector: "p-inputgroup-addon, p-inputGroupAddon", inputs: ["style", "styleClass"] }, { kind: "component", type: FieldValidation, selector: "mt-field-validation", inputs: ["control", "touched"] }, { kind: "directive", type: Tooltip, selector: "[mtTooltip]" }, { kind: "component", type: Icon, selector: "mt-icon", inputs: ["icon"] }, { kind: "pipe", type: TranslocoPipe, name: "transloco" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
300
|
+
}
|
|
301
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: LocationField, decorators: [{
|
|
302
|
+
type: Component,
|
|
303
|
+
args: [{ selector: 'mt-location-field', imports: [
|
|
304
|
+
FormsModule,
|
|
305
|
+
AutoCompleteModule,
|
|
306
|
+
InputGroupModule,
|
|
307
|
+
InputGroupAddonModule,
|
|
308
|
+
FieldValidation,
|
|
309
|
+
Tooltip,
|
|
310
|
+
Icon,
|
|
311
|
+
TranslocoPipe,
|
|
312
|
+
], changeDetection: ChangeDetectionStrategy.OnPush, host: {
|
|
313
|
+
class: 'grid gap-1',
|
|
314
|
+
}, template: "@if (label() || hint()) {\n <div class=\"mb-1 flex items-center gap-1\">\n @if (label()) {\n <label\n [class.required]=\"ngControl?.control?.hasValidator(requiredValidator)\"\n [for]=\"ngControl?.name || label()\"\n >\n {{ label() }}\n </label>\n }\n @if (hint()) {\n <span\n class=\"inline-flex text-surface-400\"\n [mtTooltip]=\"hint()\"\n tooltipPosition=\"top\"\n >\n <mt-icon icon=\"general.help-circle\" />\n </span>\n }\n </div>\n}\n\n<div class=\"relative\">\n <p-inputgroup>\n <p-autoComplete\n #autocomplete=\"\"\n [suggestions]=\"suggestions()\"\n (completeMethod)=\"search($event)\"\n (onSelect)=\"onSelect($event)\"\n (onClear)=\"onClear()\"\n (onFocus)=\"onFocus()\"\n (onBlur)=\"onTouched()\"\n [ngModel]=\"value()\"\n [disabled]=\"disabled() || readonly()\"\n [id]=\"ngControl?.name || label()\"\n [invalid]=\"isInvalid(ngControl?.control)\"\n [placeholder]=\"'components.locationField.search' | transloco\"\n [optionLabel]=\"'display_name'\"\n [minLength]=\"minLength()\"\n [forceSelection]=\"true\"\n class=\"w-full\"\n appendTo=\"body\"\n styleClass=\"w-full\"\n >\n <ng-template let-location pTemplate=\"item\">\n <div class=\"flex min-w-0 items-start gap-2\">\n <mt-icon icon=\"map.marker-pin-01\" class=\"mt-0.5 shrink-0 text-xl\" />\n <span class=\"min-w-0 text-wrap text-sm leading-5\">\n {{ location.display_name }}\n </span>\n </div>\n </ng-template>\n\n <ng-template let-location pTemplate=\"selecteditem\">\n <span class=\"min-w-0 truncate\">{{ location?.display_name }}</span>\n </ng-template>\n </p-autoComplete>\n\n <p-inputgroup-addon>\n <button\n type=\"button\"\n class=\"inline-flex h-full items-center justify-center text-surface-500 transition-colors hover:text-primary-500 disabled:cursor-not-allowed disabled:opacity-50\"\n [disabled]=\"disabled() || readonly()\"\n [mtTooltip]=\"'components.locationField.enterManually' | transloco\"\n tooltipPosition=\"top\"\n (click)=\"openManualDialog()\"\n >\n <mt-icon icon=\"general.edit-03\" />\n </button>\n </p-inputgroup-addon>\n </p-inputgroup>\n\n @if (loading()) {\n <mt-icon\n icon=\"general.loading-01\"\n class=\"absolute end-12 top-1/2 -translate-y-1/2 animate-spin bg-white\"\n />\n }\n</div>\n\n<mt-field-validation [control]=\"ngControl?.control\"></mt-field-validation>\n" }]
|
|
315
|
+
}], ctorParameters: () => [], propDecorators: { hint: [{ type: i0.Input, args: [{ isSignal: true, alias: "hint", required: false }] }], label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: false }] }], placeholder: [{ type: i0.Input, args: [{ isSignal: true, alias: "placeholder", required: false }] }], readonly: [{ type: i0.Input, args: [{ isSignal: true, alias: "readonly", required: false }] }], required: [{ type: i0.Input, args: [{ isSignal: true, alias: "required", required: false }] }], minLength: [{ type: i0.Input, args: [{ isSignal: true, alias: "minLength", required: false }] }], configuration: [{ type: i0.Input, args: [{ isSignal: true, alias: "configuration", required: false }] }], searchUrl: [{ type: i0.Input, args: [{ isSignal: true, alias: "searchUrl", required: false }] }], autocomplete: [{ type: i0.ViewChild, args: ['autocomplete', { isSignal: true }] }] } });
|
|
316
|
+
|
|
317
|
+
/**
|
|
318
|
+
* Generated bundle index. Do not edit.
|
|
319
|
+
*/
|
|
320
|
+
|
|
321
|
+
export { LocationField, LocationManualDialog, getLocationDisplayName, getLocationLongitude, normalizeLocationValue };
|
|
322
|
+
//# sourceMappingURL=masterteam-components-location-field.mjs.map
|