ngx-core-components 0.0.7 → 0.0.8
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/charts/index.d.ts +5 -0
- package/charts/public-api.d.ts +11 -0
- package/dialog/dialog-container.component.d.ts +24 -0
- package/dialog/dialog.service.d.ts +37 -0
- package/dialog/index.d.ts +5 -0
- package/dialog/public-api.d.ts +3 -0
- package/fesm2022/ngx-core-components-charts.mjs +2313 -0
- package/fesm2022/ngx-core-components-charts.mjs.map +1 -0
- package/fesm2022/ngx-core-components-dialog.mjs +168 -0
- package/fesm2022/ngx-core-components-dialog.mjs.map +1 -0
- package/fesm2022/ngx-core-components-grid.mjs +335 -0
- package/fesm2022/ngx-core-components-grid.mjs.map +1 -0
- package/fesm2022/ngx-core-components-inputs.mjs +1320 -0
- package/fesm2022/ngx-core-components-inputs.mjs.map +1 -0
- package/fesm2022/ngx-core-components-views.mjs +357 -0
- package/fesm2022/ngx-core-components-views.mjs.map +1 -0
- package/fesm2022/ngx-core-components.mjs +11 -3689
- package/fesm2022/ngx-core-components.mjs.map +1 -1
- package/grid/index.d.ts +5 -0
- package/grid/public-api.d.ts +2 -0
- package/inputs/autocomplete/autocomplete.component.d.ts +35 -0
- package/inputs/checkbox/checkbox.component.d.ts +21 -0
- package/{lib/inputs → inputs}/date-picker/date-picker.component.d.ts +11 -1
- package/{lib/inputs → inputs}/dropdown/dropdown.component.d.ts +11 -1
- package/inputs/index.d.ts +5 -0
- package/{lib/inputs → inputs}/multi-select/multi-select.component.d.ts +11 -1
- package/inputs/public-api.d.ts +9 -0
- package/inputs/radio/radio-group.component.d.ts +28 -0
- package/{lib/inputs → inputs}/textbox/textbox.component.d.ts +12 -1
- package/lib/tooltip/popover.component.d.ts +1 -1
- package/package.json +21 -1
- package/public-api.d.ts +29 -22
- package/views/index.d.ts +5 -0
- package/views/public-api.d.ts +4 -0
- /package/{lib/charts → charts}/bar-chart/bar-chart.component.d.ts +0 -0
- /package/{lib → charts}/gantt-chart/gantt-chart.component.d.ts +0 -0
- /package/{lib → charts}/gantt-chart/models/gantt-config.model.d.ts +0 -0
- /package/{lib → charts}/gantt-chart/models/gantt-dependency.model.d.ts +0 -0
- /package/{lib → charts}/gantt-chart/models/gantt-event.model.d.ts +0 -0
- /package/{lib → charts}/gantt-chart/models/gantt-task.model.d.ts +0 -0
- /package/{lib → charts}/gantt-chart/models/index.d.ts +0 -0
- /package/{lib → charts}/gantt-chart/services/gantt-keyboard.service.d.ts +0 -0
- /package/{lib → charts}/gantt-chart/services/gantt-layout.service.d.ts +0 -0
- /package/{lib → charts}/gantt-chart/services/gantt-scale.service.d.ts +0 -0
- /package/{lib → charts}/gantt-chart/utils/date-utils.d.ts +0 -0
- /package/{lib → charts}/gantt-chart/utils/svg-utils.d.ts +0 -0
- /package/{lib/charts → charts}/line-chart/line-chart.component.d.ts +0 -0
- /package/{lib/charts → charts}/pie-chart/pie-chart.component.d.ts +0 -0
- /package/{lib/charts → charts}/shared/chart-utils.d.ts +0 -0
- /package/{lib/charts → charts}/sparkline/sparkline.component.d.ts +0 -0
- /package/{lib → grid}/data-grid/data-grid.component.d.ts +0 -0
- /package/{lib → views}/list-view/list-view.component.d.ts +0 -0
- /package/{lib → views}/tree-view/tree-view.component.d.ts +0 -0
|
@@ -0,0 +1,1320 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { input, output, signal, computed, forwardRef, ChangeDetectionStrategy, Component, inject, ElementRef, HostListener } from '@angular/core';
|
|
3
|
+
import { NG_VALUE_ACCESSOR } from '@angular/forms';
|
|
4
|
+
|
|
5
|
+
class TextBoxComponent {
|
|
6
|
+
value = input('');
|
|
7
|
+
label = input('');
|
|
8
|
+
placeholder = input('');
|
|
9
|
+
type = input('text');
|
|
10
|
+
disabled = input(false);
|
|
11
|
+
readonly = input(false);
|
|
12
|
+
error = input('');
|
|
13
|
+
hint = input('');
|
|
14
|
+
valueChange = output();
|
|
15
|
+
focusChange = output();
|
|
16
|
+
isFocused = signal(false);
|
|
17
|
+
_cvaValue = signal('');
|
|
18
|
+
_cvaActive = false;
|
|
19
|
+
_onChange = () => { };
|
|
20
|
+
_onTouched = () => { };
|
|
21
|
+
/** Merges reactive-form value (CVA) with template binding (input()). CVA takes precedence. */
|
|
22
|
+
_displayValue = computed(() => this._cvaActive ? this._cvaValue() : this.value());
|
|
23
|
+
onInput(e) {
|
|
24
|
+
const v = e.target.value;
|
|
25
|
+
this._cvaValue.set(v);
|
|
26
|
+
this._onChange(v);
|
|
27
|
+
this.valueChange.emit(v);
|
|
28
|
+
}
|
|
29
|
+
onFocus() {
|
|
30
|
+
this.isFocused.set(true);
|
|
31
|
+
this.focusChange.emit(true);
|
|
32
|
+
}
|
|
33
|
+
onBlur() {
|
|
34
|
+
this.isFocused.set(false);
|
|
35
|
+
this.focusChange.emit(false);
|
|
36
|
+
this._onTouched();
|
|
37
|
+
}
|
|
38
|
+
// ControlValueAccessor
|
|
39
|
+
writeValue(val) {
|
|
40
|
+
this._cvaActive = true;
|
|
41
|
+
this._cvaValue.set(val ?? '');
|
|
42
|
+
}
|
|
43
|
+
registerOnChange(fn) {
|
|
44
|
+
this._onChange = fn;
|
|
45
|
+
}
|
|
46
|
+
registerOnTouched(fn) {
|
|
47
|
+
this._onTouched = fn;
|
|
48
|
+
}
|
|
49
|
+
setDisabledState(_isDisabled) {
|
|
50
|
+
// disabled is controlled via input() for template usage;
|
|
51
|
+
// reactive-form disable/enable is handled at the FormControl level.
|
|
52
|
+
}
|
|
53
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.20", ngImport: i0, type: TextBoxComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
54
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.20", type: TextBoxComponent, isStandalone: true, selector: "ngx-textbox", inputs: { value: { classPropertyName: "value", publicName: "value", 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 }, type: { classPropertyName: "type", publicName: "type", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, readonly: { classPropertyName: "readonly", publicName: "readonly", isSignal: true, isRequired: false, transformFunction: null }, error: { classPropertyName: "error", publicName: "error", isSignal: true, isRequired: false, transformFunction: null }, hint: { classPropertyName: "hint", publicName: "hint", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { valueChange: "valueChange", focusChange: "focusChange" }, providers: [
|
|
55
|
+
{
|
|
56
|
+
provide: NG_VALUE_ACCESSOR,
|
|
57
|
+
useExisting: forwardRef(() => TextBoxComponent),
|
|
58
|
+
multi: true,
|
|
59
|
+
},
|
|
60
|
+
], ngImport: i0, template: `
|
|
61
|
+
<div class="ngx-textbox" [class.focused]="isFocused()" [class.has-error]="!!error()" [class.disabled]="disabled()">
|
|
62
|
+
@if (label()) {
|
|
63
|
+
<label class="ngx-textbox-label" [class.floating]="isFocused() || !!_displayValue()">{{ label() }}</label>
|
|
64
|
+
}
|
|
65
|
+
<div class="ngx-textbox-wrap">
|
|
66
|
+
<input
|
|
67
|
+
class="ngx-textbox-input"
|
|
68
|
+
[type]="type()"
|
|
69
|
+
[value]="_displayValue()"
|
|
70
|
+
[placeholder]="isFocused() || !label() ? placeholder() : ''"
|
|
71
|
+
[disabled]="disabled()"
|
|
72
|
+
[readOnly]="readonly()"
|
|
73
|
+
[attr.aria-invalid]="!!error()"
|
|
74
|
+
(input)="onInput($event)"
|
|
75
|
+
(focus)="onFocus()"
|
|
76
|
+
(blur)="onBlur()"
|
|
77
|
+
/>
|
|
78
|
+
</div>
|
|
79
|
+
@if (error()) {
|
|
80
|
+
<div class="ngx-textbox-error">{{ error() }}</div>
|
|
81
|
+
} @else if (hint()) {
|
|
82
|
+
<div class="ngx-textbox-hint">{{ hint() }}</div>
|
|
83
|
+
}
|
|
84
|
+
</div>
|
|
85
|
+
`, isInline: true, styles: [":host{display:block}.ngx-textbox{position:relative;font-family:inherit}.ngx-textbox-label{display:block;font-size:13px;color:var(--ngx-input-label, #6c757d);margin-bottom:4px;font-weight:500;transition:all .15s}.ngx-textbox-wrap{position:relative;border:1px solid var(--ngx-input-border, #ced4da);border-radius:var(--ngx-input-radius, 4px);background:var(--ngx-input-bg, #fff);transition:border-color .15s,box-shadow .15s}.focused .ngx-textbox-wrap{border-color:var(--ngx-input-focus, #4a90d9);box-shadow:0 0 0 2px #4a90d92e}.has-error .ngx-textbox-wrap{border-color:var(--ngx-input-error, #e74c3c)}.has-error.focused .ngx-textbox-wrap{box-shadow:0 0 0 2px #e74c3c2e}.disabled .ngx-textbox-wrap{background:var(--ngx-input-disabled-bg, #f8f9fa);cursor:not-allowed}.ngx-textbox-input{display:block;width:100%;padding:8px 12px;border:none;outline:none;background:transparent;font-size:14px;color:var(--ngx-input-text, #212529);font-family:inherit}.ngx-textbox-input:disabled{cursor:not-allowed;color:#adb5bd}.ngx-textbox-error{font-size:12px;color:var(--ngx-input-error, #e74c3c);margin-top:4px}.ngx-textbox-hint{font-size:12px;color:var(--ngx-input-label, #6c757d);margin-top:4px}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
86
|
+
}
|
|
87
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.20", ngImport: i0, type: TextBoxComponent, decorators: [{
|
|
88
|
+
type: Component,
|
|
89
|
+
args: [{ selector: 'ngx-textbox', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, providers: [
|
|
90
|
+
{
|
|
91
|
+
provide: NG_VALUE_ACCESSOR,
|
|
92
|
+
useExisting: forwardRef(() => TextBoxComponent),
|
|
93
|
+
multi: true,
|
|
94
|
+
},
|
|
95
|
+
], template: `
|
|
96
|
+
<div class="ngx-textbox" [class.focused]="isFocused()" [class.has-error]="!!error()" [class.disabled]="disabled()">
|
|
97
|
+
@if (label()) {
|
|
98
|
+
<label class="ngx-textbox-label" [class.floating]="isFocused() || !!_displayValue()">{{ label() }}</label>
|
|
99
|
+
}
|
|
100
|
+
<div class="ngx-textbox-wrap">
|
|
101
|
+
<input
|
|
102
|
+
class="ngx-textbox-input"
|
|
103
|
+
[type]="type()"
|
|
104
|
+
[value]="_displayValue()"
|
|
105
|
+
[placeholder]="isFocused() || !label() ? placeholder() : ''"
|
|
106
|
+
[disabled]="disabled()"
|
|
107
|
+
[readOnly]="readonly()"
|
|
108
|
+
[attr.aria-invalid]="!!error()"
|
|
109
|
+
(input)="onInput($event)"
|
|
110
|
+
(focus)="onFocus()"
|
|
111
|
+
(blur)="onBlur()"
|
|
112
|
+
/>
|
|
113
|
+
</div>
|
|
114
|
+
@if (error()) {
|
|
115
|
+
<div class="ngx-textbox-error">{{ error() }}</div>
|
|
116
|
+
} @else if (hint()) {
|
|
117
|
+
<div class="ngx-textbox-hint">{{ hint() }}</div>
|
|
118
|
+
}
|
|
119
|
+
</div>
|
|
120
|
+
`, styles: [":host{display:block}.ngx-textbox{position:relative;font-family:inherit}.ngx-textbox-label{display:block;font-size:13px;color:var(--ngx-input-label, #6c757d);margin-bottom:4px;font-weight:500;transition:all .15s}.ngx-textbox-wrap{position:relative;border:1px solid var(--ngx-input-border, #ced4da);border-radius:var(--ngx-input-radius, 4px);background:var(--ngx-input-bg, #fff);transition:border-color .15s,box-shadow .15s}.focused .ngx-textbox-wrap{border-color:var(--ngx-input-focus, #4a90d9);box-shadow:0 0 0 2px #4a90d92e}.has-error .ngx-textbox-wrap{border-color:var(--ngx-input-error, #e74c3c)}.has-error.focused .ngx-textbox-wrap{box-shadow:0 0 0 2px #e74c3c2e}.disabled .ngx-textbox-wrap{background:var(--ngx-input-disabled-bg, #f8f9fa);cursor:not-allowed}.ngx-textbox-input{display:block;width:100%;padding:8px 12px;border:none;outline:none;background:transparent;font-size:14px;color:var(--ngx-input-text, #212529);font-family:inherit}.ngx-textbox-input:disabled{cursor:not-allowed;color:#adb5bd}.ngx-textbox-error{font-size:12px;color:var(--ngx-input-error, #e74c3c);margin-top:4px}.ngx-textbox-hint{font-size:12px;color:var(--ngx-input-label, #6c757d);margin-top:4px}\n"] }]
|
|
121
|
+
}] });
|
|
122
|
+
|
|
123
|
+
class CheckboxComponent {
|
|
124
|
+
label = input('');
|
|
125
|
+
checked = input(false);
|
|
126
|
+
disabled = input(false);
|
|
127
|
+
indeterminate = input(false);
|
|
128
|
+
checkedChange = output();
|
|
129
|
+
_checked = signal(false);
|
|
130
|
+
_cvaActive = false;
|
|
131
|
+
_onChange = () => { };
|
|
132
|
+
_onTouched = () => { };
|
|
133
|
+
_displayChecked = computed(() => this._cvaActive ? this._checked() : this.checked());
|
|
134
|
+
toggle() {
|
|
135
|
+
if (this.disabled())
|
|
136
|
+
return;
|
|
137
|
+
const next = !this._displayChecked();
|
|
138
|
+
this._checked.set(next);
|
|
139
|
+
this._onChange(next);
|
|
140
|
+
this._onTouched();
|
|
141
|
+
this.checkedChange.emit(next);
|
|
142
|
+
}
|
|
143
|
+
// ControlValueAccessor
|
|
144
|
+
writeValue(val) {
|
|
145
|
+
this._cvaActive = true;
|
|
146
|
+
this._checked.set(!!val);
|
|
147
|
+
}
|
|
148
|
+
registerOnChange(fn) {
|
|
149
|
+
this._onChange = fn;
|
|
150
|
+
}
|
|
151
|
+
registerOnTouched(fn) {
|
|
152
|
+
this._onTouched = fn;
|
|
153
|
+
}
|
|
154
|
+
setDisabledState(_isDisabled) {
|
|
155
|
+
// disabled handled via input()
|
|
156
|
+
}
|
|
157
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.20", ngImport: i0, type: CheckboxComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
158
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.20", type: CheckboxComponent, isStandalone: true, selector: "ngx-checkbox", inputs: { label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, checked: { classPropertyName: "checked", publicName: "checked", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, indeterminate: { classPropertyName: "indeterminate", publicName: "indeterminate", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { checkedChange: "checkedChange" }, providers: [
|
|
159
|
+
{
|
|
160
|
+
provide: NG_VALUE_ACCESSOR,
|
|
161
|
+
useExisting: forwardRef(() => CheckboxComponent),
|
|
162
|
+
multi: true,
|
|
163
|
+
},
|
|
164
|
+
], ngImport: i0, template: `
|
|
165
|
+
<label class="ngx-checkbox" [class.disabled]="disabled()">
|
|
166
|
+
<span class="ngx-checkbox-box" [class.checked]="_displayChecked()" [class.indeterminate]="indeterminate()" (click)="toggle()">
|
|
167
|
+
@if (_displayChecked()) {
|
|
168
|
+
<svg class="ngx-checkbox-icon" viewBox="0 0 12 10" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
169
|
+
<path d="M1 5L4.5 8.5L11 1" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
|
170
|
+
</svg>
|
|
171
|
+
} @else if (indeterminate()) {
|
|
172
|
+
<span class="ngx-checkbox-dash"></span>
|
|
173
|
+
}
|
|
174
|
+
</span>
|
|
175
|
+
@if (label()) {
|
|
176
|
+
<span class="ngx-checkbox-label">{{ label() }}</span>
|
|
177
|
+
}
|
|
178
|
+
</label>
|
|
179
|
+
`, isInline: true, styles: [":host{display:inline-block}.ngx-checkbox{display:inline-flex;align-items:center;gap:8px;cursor:pointer;-webkit-user-select:none;user-select:none;font-family:inherit}.ngx-checkbox.disabled{cursor:not-allowed;opacity:.55}.ngx-checkbox-box{width:18px;height:18px;flex-shrink:0;border:2px solid var(--ngx-checkbox-border, #ced4da);border-radius:var(--ngx-checkbox-radius, 3px);background:var(--ngx-checkbox-bg, #fff);display:flex;align-items:center;justify-content:center;transition:background .15s,border-color .15s}.ngx-checkbox-box.checked,.ngx-checkbox-box.indeterminate{background:var(--ngx-checkbox-active, #4a90d9);border-color:var(--ngx-checkbox-active, #4a90d9);color:#fff}.ngx-checkbox-icon{width:12px;height:10px}.ngx-checkbox-dash{width:8px;height:2px;background:#fff;border-radius:1px}.ngx-checkbox-label{font-size:14px;color:var(--ngx-input-text, #212529)}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
180
|
+
}
|
|
181
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.20", ngImport: i0, type: CheckboxComponent, decorators: [{
|
|
182
|
+
type: Component,
|
|
183
|
+
args: [{ selector: 'ngx-checkbox', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, providers: [
|
|
184
|
+
{
|
|
185
|
+
provide: NG_VALUE_ACCESSOR,
|
|
186
|
+
useExisting: forwardRef(() => CheckboxComponent),
|
|
187
|
+
multi: true,
|
|
188
|
+
},
|
|
189
|
+
], template: `
|
|
190
|
+
<label class="ngx-checkbox" [class.disabled]="disabled()">
|
|
191
|
+
<span class="ngx-checkbox-box" [class.checked]="_displayChecked()" [class.indeterminate]="indeterminate()" (click)="toggle()">
|
|
192
|
+
@if (_displayChecked()) {
|
|
193
|
+
<svg class="ngx-checkbox-icon" viewBox="0 0 12 10" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
194
|
+
<path d="M1 5L4.5 8.5L11 1" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
|
195
|
+
</svg>
|
|
196
|
+
} @else if (indeterminate()) {
|
|
197
|
+
<span class="ngx-checkbox-dash"></span>
|
|
198
|
+
}
|
|
199
|
+
</span>
|
|
200
|
+
@if (label()) {
|
|
201
|
+
<span class="ngx-checkbox-label">{{ label() }}</span>
|
|
202
|
+
}
|
|
203
|
+
</label>
|
|
204
|
+
`, styles: [":host{display:inline-block}.ngx-checkbox{display:inline-flex;align-items:center;gap:8px;cursor:pointer;-webkit-user-select:none;user-select:none;font-family:inherit}.ngx-checkbox.disabled{cursor:not-allowed;opacity:.55}.ngx-checkbox-box{width:18px;height:18px;flex-shrink:0;border:2px solid var(--ngx-checkbox-border, #ced4da);border-radius:var(--ngx-checkbox-radius, 3px);background:var(--ngx-checkbox-bg, #fff);display:flex;align-items:center;justify-content:center;transition:background .15s,border-color .15s}.ngx-checkbox-box.checked,.ngx-checkbox-box.indeterminate{background:var(--ngx-checkbox-active, #4a90d9);border-color:var(--ngx-checkbox-active, #4a90d9);color:#fff}.ngx-checkbox-icon{width:12px;height:10px}.ngx-checkbox-dash{width:8px;height:2px;background:#fff;border-radius:1px}.ngx-checkbox-label{font-size:14px;color:var(--ngx-input-text, #212529)}\n"] }]
|
|
205
|
+
}] });
|
|
206
|
+
|
|
207
|
+
class RadioGroupComponent {
|
|
208
|
+
options = input([]);
|
|
209
|
+
label = input('');
|
|
210
|
+
value = input(null);
|
|
211
|
+
disabled = input(false);
|
|
212
|
+
inline = input(false);
|
|
213
|
+
valueChange = output();
|
|
214
|
+
_value = signal(null);
|
|
215
|
+
_cvaActive = false;
|
|
216
|
+
_onChange = () => { };
|
|
217
|
+
_onTouched = () => { };
|
|
218
|
+
_activeValue = computed(() => this._cvaActive ? this._value() : this.value());
|
|
219
|
+
isChecked(val) {
|
|
220
|
+
return this._activeValue() === val;
|
|
221
|
+
}
|
|
222
|
+
select(opt) {
|
|
223
|
+
if (this.disabled() || opt.disabled)
|
|
224
|
+
return;
|
|
225
|
+
this._value.set(opt.value);
|
|
226
|
+
this._onChange(opt.value);
|
|
227
|
+
this._onTouched();
|
|
228
|
+
this.valueChange.emit(opt.value);
|
|
229
|
+
}
|
|
230
|
+
// ControlValueAccessor
|
|
231
|
+
writeValue(val) {
|
|
232
|
+
this._cvaActive = true;
|
|
233
|
+
this._value.set(val ?? null);
|
|
234
|
+
}
|
|
235
|
+
registerOnChange(fn) {
|
|
236
|
+
this._onChange = fn;
|
|
237
|
+
}
|
|
238
|
+
registerOnTouched(fn) {
|
|
239
|
+
this._onTouched = fn;
|
|
240
|
+
}
|
|
241
|
+
setDisabledState(_isDisabled) {
|
|
242
|
+
// disabled handled via input()
|
|
243
|
+
}
|
|
244
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.20", ngImport: i0, type: RadioGroupComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
245
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.20", type: RadioGroupComponent, isStandalone: true, selector: "ngx-radio-group", inputs: { options: { classPropertyName: "options", publicName: "options", isSignal: true, isRequired: false, transformFunction: null }, label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, inline: { classPropertyName: "inline", publicName: "inline", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { valueChange: "valueChange" }, providers: [
|
|
246
|
+
{
|
|
247
|
+
provide: NG_VALUE_ACCESSOR,
|
|
248
|
+
useExisting: forwardRef(() => RadioGroupComponent),
|
|
249
|
+
multi: true,
|
|
250
|
+
},
|
|
251
|
+
], ngImport: i0, template: `
|
|
252
|
+
<div
|
|
253
|
+
class="ngx-radio-group"
|
|
254
|
+
[class.inline]="inline()"
|
|
255
|
+
role="radiogroup"
|
|
256
|
+
[attr.aria-label]="label()"
|
|
257
|
+
>
|
|
258
|
+
@if (label()) {
|
|
259
|
+
<span class="ngx-radio-group-label">{{ label() }}</span>
|
|
260
|
+
}
|
|
261
|
+
@for (opt of options(); track opt.value) {
|
|
262
|
+
<label
|
|
263
|
+
class="ngx-radio"
|
|
264
|
+
[class.disabled]="disabled() || !!opt.disabled"
|
|
265
|
+
[class.checked]="isChecked(opt.value)"
|
|
266
|
+
>
|
|
267
|
+
<span
|
|
268
|
+
class="ngx-radio-btn"
|
|
269
|
+
[class.checked]="isChecked(opt.value)"
|
|
270
|
+
(click)="select(opt)"
|
|
271
|
+
role="radio"
|
|
272
|
+
[attr.aria-checked]="isChecked(opt.value)"
|
|
273
|
+
tabindex="0"
|
|
274
|
+
(keydown.enter)="select(opt)"
|
|
275
|
+
(keydown.space)="select(opt)"
|
|
276
|
+
>
|
|
277
|
+
<span class="ngx-radio-dot" [class.visible]="isChecked(opt.value)"></span>
|
|
278
|
+
</span>
|
|
279
|
+
<span class="ngx-radio-label">{{ opt.label }}</span>
|
|
280
|
+
</label>
|
|
281
|
+
}
|
|
282
|
+
</div>
|
|
283
|
+
`, isInline: true, styles: [":host{display:block}.ngx-radio-group{display:flex;flex-direction:column;gap:8px;font-family:inherit}.ngx-radio-group.inline{flex-direction:row;flex-wrap:wrap;gap:16px}.ngx-radio-group-label{display:block;font-size:13px;color:var(--ngx-input-label, #6c757d);font-weight:500;margin-bottom:4px}.ngx-radio{display:inline-flex;align-items:center;gap:8px;cursor:pointer;-webkit-user-select:none;user-select:none}.ngx-radio.disabled{cursor:not-allowed;opacity:.55}.ngx-radio-btn{width:18px;height:18px;flex-shrink:0;border:2px solid var(--ngx-radio-border, #ced4da);border-radius:50%;background:var(--ngx-radio-bg, #fff);display:flex;align-items:center;justify-content:center;transition:border-color .15s;outline:none}.ngx-radio-btn.checked{border-color:var(--ngx-radio-active, #4a90d9)}.ngx-radio-btn:focus-visible{box-shadow:0 0 0 2px #4a90d959}.ngx-radio-dot{width:8px;height:8px;border-radius:50%;background:var(--ngx-radio-active, #4a90d9);opacity:0;transform:scale(.5);transition:opacity .15s,transform .15s}.ngx-radio-dot.visible{opacity:1;transform:scale(1)}.ngx-radio-label{font-size:14px;color:var(--ngx-input-text, #212529)}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
284
|
+
}
|
|
285
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.20", ngImport: i0, type: RadioGroupComponent, decorators: [{
|
|
286
|
+
type: Component,
|
|
287
|
+
args: [{ selector: 'ngx-radio-group', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, providers: [
|
|
288
|
+
{
|
|
289
|
+
provide: NG_VALUE_ACCESSOR,
|
|
290
|
+
useExisting: forwardRef(() => RadioGroupComponent),
|
|
291
|
+
multi: true,
|
|
292
|
+
},
|
|
293
|
+
], template: `
|
|
294
|
+
<div
|
|
295
|
+
class="ngx-radio-group"
|
|
296
|
+
[class.inline]="inline()"
|
|
297
|
+
role="radiogroup"
|
|
298
|
+
[attr.aria-label]="label()"
|
|
299
|
+
>
|
|
300
|
+
@if (label()) {
|
|
301
|
+
<span class="ngx-radio-group-label">{{ label() }}</span>
|
|
302
|
+
}
|
|
303
|
+
@for (opt of options(); track opt.value) {
|
|
304
|
+
<label
|
|
305
|
+
class="ngx-radio"
|
|
306
|
+
[class.disabled]="disabled() || !!opt.disabled"
|
|
307
|
+
[class.checked]="isChecked(opt.value)"
|
|
308
|
+
>
|
|
309
|
+
<span
|
|
310
|
+
class="ngx-radio-btn"
|
|
311
|
+
[class.checked]="isChecked(opt.value)"
|
|
312
|
+
(click)="select(opt)"
|
|
313
|
+
role="radio"
|
|
314
|
+
[attr.aria-checked]="isChecked(opt.value)"
|
|
315
|
+
tabindex="0"
|
|
316
|
+
(keydown.enter)="select(opt)"
|
|
317
|
+
(keydown.space)="select(opt)"
|
|
318
|
+
>
|
|
319
|
+
<span class="ngx-radio-dot" [class.visible]="isChecked(opt.value)"></span>
|
|
320
|
+
</span>
|
|
321
|
+
<span class="ngx-radio-label">{{ opt.label }}</span>
|
|
322
|
+
</label>
|
|
323
|
+
}
|
|
324
|
+
</div>
|
|
325
|
+
`, styles: [":host{display:block}.ngx-radio-group{display:flex;flex-direction:column;gap:8px;font-family:inherit}.ngx-radio-group.inline{flex-direction:row;flex-wrap:wrap;gap:16px}.ngx-radio-group-label{display:block;font-size:13px;color:var(--ngx-input-label, #6c757d);font-weight:500;margin-bottom:4px}.ngx-radio{display:inline-flex;align-items:center;gap:8px;cursor:pointer;-webkit-user-select:none;user-select:none}.ngx-radio.disabled{cursor:not-allowed;opacity:.55}.ngx-radio-btn{width:18px;height:18px;flex-shrink:0;border:2px solid var(--ngx-radio-border, #ced4da);border-radius:50%;background:var(--ngx-radio-bg, #fff);display:flex;align-items:center;justify-content:center;transition:border-color .15s;outline:none}.ngx-radio-btn.checked{border-color:var(--ngx-radio-active, #4a90d9)}.ngx-radio-btn:focus-visible{box-shadow:0 0 0 2px #4a90d959}.ngx-radio-dot{width:8px;height:8px;border-radius:50%;background:var(--ngx-radio-active, #4a90d9);opacity:0;transform:scale(.5);transition:opacity .15s,transform .15s}.ngx-radio-dot.visible{opacity:1;transform:scale(1)}.ngx-radio-label{font-size:14px;color:var(--ngx-input-text, #212529)}\n"] }]
|
|
326
|
+
}] });
|
|
327
|
+
|
|
328
|
+
class DropdownComponent {
|
|
329
|
+
options = input([]);
|
|
330
|
+
value = input(null);
|
|
331
|
+
label = input('');
|
|
332
|
+
placeholder = input('Select...');
|
|
333
|
+
disabled = input(false);
|
|
334
|
+
filterable = input(false);
|
|
335
|
+
valueChange = output();
|
|
336
|
+
isOpen = signal(false);
|
|
337
|
+
filterText = signal('');
|
|
338
|
+
focusedIndex = signal(-1);
|
|
339
|
+
_cvaValue = signal(null);
|
|
340
|
+
_cvaActive = false;
|
|
341
|
+
_onChange = () => { };
|
|
342
|
+
_onTouched = () => { };
|
|
343
|
+
el = inject(ElementRef);
|
|
344
|
+
_activeValue = computed(() => this._cvaActive ? this._cvaValue() : this.value());
|
|
345
|
+
selectedLabel = computed(() => {
|
|
346
|
+
const opt = this.options().find(o => o.value === this._activeValue());
|
|
347
|
+
return opt?.label ?? '';
|
|
348
|
+
});
|
|
349
|
+
filteredOptions = computed(() => {
|
|
350
|
+
const f = this.filterText().toLowerCase();
|
|
351
|
+
return f ? this.options().filter(o => o.label.toLowerCase().includes(f)) : this.options();
|
|
352
|
+
});
|
|
353
|
+
isSelected(opt) { return opt.value === this._activeValue(); }
|
|
354
|
+
toggle() {
|
|
355
|
+
if (this.disabled())
|
|
356
|
+
return;
|
|
357
|
+
this.isOpen.update(v => !v);
|
|
358
|
+
if (!this.isOpen())
|
|
359
|
+
this.filterText.set('');
|
|
360
|
+
}
|
|
361
|
+
selectOption(opt) {
|
|
362
|
+
if (opt.disabled)
|
|
363
|
+
return;
|
|
364
|
+
this._cvaValue.set(opt.value);
|
|
365
|
+
this._onChange(opt.value);
|
|
366
|
+
this._onTouched();
|
|
367
|
+
this.valueChange.emit(opt.value);
|
|
368
|
+
this.isOpen.set(false);
|
|
369
|
+
this.filterText.set('');
|
|
370
|
+
}
|
|
371
|
+
onTriggerKey(e) {
|
|
372
|
+
if (e.key === 'Enter' || e.key === ' ') {
|
|
373
|
+
e.preventDefault();
|
|
374
|
+
this.toggle();
|
|
375
|
+
}
|
|
376
|
+
if (e.key === 'Escape')
|
|
377
|
+
this.isOpen.set(false);
|
|
378
|
+
if (e.key === 'ArrowDown') {
|
|
379
|
+
e.preventDefault();
|
|
380
|
+
if (!this.isOpen())
|
|
381
|
+
this.isOpen.set(true);
|
|
382
|
+
else
|
|
383
|
+
this.moveFocus(1);
|
|
384
|
+
}
|
|
385
|
+
if (e.key === 'ArrowUp') {
|
|
386
|
+
e.preventDefault();
|
|
387
|
+
this.moveFocus(-1);
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
onFilterKey(e) {
|
|
391
|
+
if (e.key === 'ArrowDown') {
|
|
392
|
+
e.preventDefault();
|
|
393
|
+
this.moveFocus(1);
|
|
394
|
+
}
|
|
395
|
+
if (e.key === 'ArrowUp') {
|
|
396
|
+
e.preventDefault();
|
|
397
|
+
this.moveFocus(-1);
|
|
398
|
+
}
|
|
399
|
+
if (e.key === 'Enter') {
|
|
400
|
+
const opts = this.filteredOptions();
|
|
401
|
+
const i = this.focusedIndex();
|
|
402
|
+
if (i >= 0 && i < opts.length)
|
|
403
|
+
this.selectOption(opts[i]);
|
|
404
|
+
}
|
|
405
|
+
if (e.key === 'Escape')
|
|
406
|
+
this.isOpen.set(false);
|
|
407
|
+
}
|
|
408
|
+
moveFocus(delta) {
|
|
409
|
+
const n = this.filteredOptions().length;
|
|
410
|
+
this.focusedIndex.update(i => Math.max(0, Math.min(n - 1, i + delta)));
|
|
411
|
+
}
|
|
412
|
+
onDocClick(e) {
|
|
413
|
+
if (!this.el.nativeElement.contains(e.target)) {
|
|
414
|
+
this.isOpen.set(false);
|
|
415
|
+
this.filterText.set('');
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
// ControlValueAccessor
|
|
419
|
+
writeValue(val) {
|
|
420
|
+
this._cvaActive = true;
|
|
421
|
+
this._cvaValue.set(val ?? null);
|
|
422
|
+
}
|
|
423
|
+
registerOnChange(fn) {
|
|
424
|
+
this._onChange = fn;
|
|
425
|
+
}
|
|
426
|
+
registerOnTouched(fn) {
|
|
427
|
+
this._onTouched = fn;
|
|
428
|
+
}
|
|
429
|
+
setDisabledState(_isDisabled) {
|
|
430
|
+
// disabled is controlled via input() for template usage.
|
|
431
|
+
}
|
|
432
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.20", ngImport: i0, type: DropdownComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
433
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.20", type: DropdownComponent, isStandalone: true, selector: "ngx-dropdown", inputs: { options: { classPropertyName: "options", publicName: "options", isSignal: true, isRequired: false, transformFunction: null }, value: { classPropertyName: "value", publicName: "value", 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 }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, filterable: { classPropertyName: "filterable", publicName: "filterable", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { valueChange: "valueChange" }, host: { listeners: { "document:click": "onDocClick($event)" } }, providers: [
|
|
434
|
+
{
|
|
435
|
+
provide: NG_VALUE_ACCESSOR,
|
|
436
|
+
useExisting: forwardRef(() => DropdownComponent),
|
|
437
|
+
multi: true,
|
|
438
|
+
},
|
|
439
|
+
], ngImport: i0, template: `
|
|
440
|
+
<div
|
|
441
|
+
class="ngx-dropdown"
|
|
442
|
+
[class.open]="isOpen()"
|
|
443
|
+
[class.disabled]="disabled()"
|
|
444
|
+
[attr.aria-expanded]="isOpen()"
|
|
445
|
+
role="combobox"
|
|
446
|
+
>
|
|
447
|
+
@if (label()) {
|
|
448
|
+
<label class="ngx-dropdown-label">{{ label() }}</label>
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
<!-- Trigger -->
|
|
452
|
+
<div
|
|
453
|
+
class="ngx-dropdown-trigger"
|
|
454
|
+
tabindex="0"
|
|
455
|
+
(click)="toggle()"
|
|
456
|
+
(keydown)="onTriggerKey($event)"
|
|
457
|
+
[attr.aria-label]="selectedLabel() || placeholder()"
|
|
458
|
+
>
|
|
459
|
+
<span class="trigger-text" [class.placeholder]="!selectedLabel()">
|
|
460
|
+
{{ selectedLabel() || placeholder() }}
|
|
461
|
+
</span>
|
|
462
|
+
<span class="trigger-arrow" [class.open]="isOpen()">▼</span>
|
|
463
|
+
</div>
|
|
464
|
+
|
|
465
|
+
<!-- Popup -->
|
|
466
|
+
@if (isOpen()) {
|
|
467
|
+
<div class="ngx-dropdown-popup" role="listbox">
|
|
468
|
+
@if (filterable()) {
|
|
469
|
+
<div class="popup-search">
|
|
470
|
+
<input
|
|
471
|
+
#filterInput
|
|
472
|
+
class="popup-search-input"
|
|
473
|
+
placeholder="Search..."
|
|
474
|
+
[value]="filterText()"
|
|
475
|
+
(input)="filterText.set($any($event.target).value)"
|
|
476
|
+
(keydown)="onFilterKey($event)"
|
|
477
|
+
/>
|
|
478
|
+
</div>
|
|
479
|
+
}
|
|
480
|
+
<div class="popup-list">
|
|
481
|
+
@for (opt of filteredOptions(); track opt.value; let i = $index) {
|
|
482
|
+
<div
|
|
483
|
+
class="popup-item"
|
|
484
|
+
[class.selected]="isSelected(opt)"
|
|
485
|
+
[class.focused]="focusedIndex() === i"
|
|
486
|
+
[class.disabled]="opt.disabled"
|
|
487
|
+
role="option"
|
|
488
|
+
[attr.aria-selected]="isSelected(opt)"
|
|
489
|
+
(click)="selectOption(opt)"
|
|
490
|
+
(mouseenter)="focusedIndex.set(i)"
|
|
491
|
+
>{{ opt.label }}</div>
|
|
492
|
+
}
|
|
493
|
+
@if (filteredOptions().length === 0) {
|
|
494
|
+
<div class="popup-empty">No results</div>
|
|
495
|
+
}
|
|
496
|
+
</div>
|
|
497
|
+
</div>
|
|
498
|
+
}
|
|
499
|
+
</div>
|
|
500
|
+
`, isInline: true, styles: [":host{display:block}.ngx-dropdown{position:relative;font-family:inherit}.ngx-dropdown-label{display:block;font-size:13px;color:var(--ngx-input-label, #6c757d);margin-bottom:4px;font-weight:500}.ngx-dropdown-trigger{display:flex;align-items:center;justify-content:space-between;padding:8px 12px;border:1px solid var(--ngx-input-border, #ced4da);border-radius:var(--ngx-input-radius, 4px);background:var(--ngx-input-bg, #fff);cursor:pointer;-webkit-user-select:none;user-select:none;font-size:14px;transition:border-color .15s,box-shadow .15s}.ngx-dropdown-trigger:hover{border-color:#adb5bd}.open .ngx-dropdown-trigger{border-color:var(--ngx-input-focus, #4a90d9);box-shadow:0 0 0 2px #4a90d92e}.disabled .ngx-dropdown-trigger{background:#f8f9fa;cursor:not-allowed;color:#adb5bd}.trigger-text{flex:1;color:var(--ngx-input-text, #212529)}.trigger-text.placeholder{color:#adb5bd}.trigger-arrow{font-size:10px;color:#6c757d;transition:transform .15s}.trigger-arrow.open{transform:rotate(180deg)}.ngx-dropdown-popup{position:absolute;top:calc(100% + 4px);left:0;right:0;z-index:1000;background:var(--ngx-input-bg, #fff);border:1px solid var(--ngx-input-border, #ced4da);border-radius:var(--ngx-input-radius, 4px);box-shadow:0 4px 16px #0000001f;overflow:hidden}.popup-search{padding:8px;border-bottom:1px solid var(--ngx-input-border, #ced4da)}.popup-search-input{width:100%;padding:6px 10px;border:1px solid var(--ngx-input-border, #ced4da);border-radius:3px;font-size:13px;outline:none;font-family:inherit}.popup-list{max-height:240px;overflow-y:auto}.popup-item{padding:8px 12px;font-size:14px;cursor:pointer;color:var(--ngx-input-text, #212529);transition:background .1s}.popup-item:hover,.popup-item.focused{background:var(--ngx-input-hover-bg, #f1f3f5)}.popup-item.selected{background:var(--ngx-input-selected-bg, #e8f0fe);color:var(--ngx-input-focus, #4a90d9);font-weight:500}.popup-item.disabled{color:#adb5bd;cursor:not-allowed}.popup-item.disabled:hover{background:none}.popup-empty{padding:12px;text-align:center;color:#adb5bd;font-size:13px}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
501
|
+
}
|
|
502
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.20", ngImport: i0, type: DropdownComponent, decorators: [{
|
|
503
|
+
type: Component,
|
|
504
|
+
args: [{ selector: 'ngx-dropdown', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, providers: [
|
|
505
|
+
{
|
|
506
|
+
provide: NG_VALUE_ACCESSOR,
|
|
507
|
+
useExisting: forwardRef(() => DropdownComponent),
|
|
508
|
+
multi: true,
|
|
509
|
+
},
|
|
510
|
+
], template: `
|
|
511
|
+
<div
|
|
512
|
+
class="ngx-dropdown"
|
|
513
|
+
[class.open]="isOpen()"
|
|
514
|
+
[class.disabled]="disabled()"
|
|
515
|
+
[attr.aria-expanded]="isOpen()"
|
|
516
|
+
role="combobox"
|
|
517
|
+
>
|
|
518
|
+
@if (label()) {
|
|
519
|
+
<label class="ngx-dropdown-label">{{ label() }}</label>
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
<!-- Trigger -->
|
|
523
|
+
<div
|
|
524
|
+
class="ngx-dropdown-trigger"
|
|
525
|
+
tabindex="0"
|
|
526
|
+
(click)="toggle()"
|
|
527
|
+
(keydown)="onTriggerKey($event)"
|
|
528
|
+
[attr.aria-label]="selectedLabel() || placeholder()"
|
|
529
|
+
>
|
|
530
|
+
<span class="trigger-text" [class.placeholder]="!selectedLabel()">
|
|
531
|
+
{{ selectedLabel() || placeholder() }}
|
|
532
|
+
</span>
|
|
533
|
+
<span class="trigger-arrow" [class.open]="isOpen()">▼</span>
|
|
534
|
+
</div>
|
|
535
|
+
|
|
536
|
+
<!-- Popup -->
|
|
537
|
+
@if (isOpen()) {
|
|
538
|
+
<div class="ngx-dropdown-popup" role="listbox">
|
|
539
|
+
@if (filterable()) {
|
|
540
|
+
<div class="popup-search">
|
|
541
|
+
<input
|
|
542
|
+
#filterInput
|
|
543
|
+
class="popup-search-input"
|
|
544
|
+
placeholder="Search..."
|
|
545
|
+
[value]="filterText()"
|
|
546
|
+
(input)="filterText.set($any($event.target).value)"
|
|
547
|
+
(keydown)="onFilterKey($event)"
|
|
548
|
+
/>
|
|
549
|
+
</div>
|
|
550
|
+
}
|
|
551
|
+
<div class="popup-list">
|
|
552
|
+
@for (opt of filteredOptions(); track opt.value; let i = $index) {
|
|
553
|
+
<div
|
|
554
|
+
class="popup-item"
|
|
555
|
+
[class.selected]="isSelected(opt)"
|
|
556
|
+
[class.focused]="focusedIndex() === i"
|
|
557
|
+
[class.disabled]="opt.disabled"
|
|
558
|
+
role="option"
|
|
559
|
+
[attr.aria-selected]="isSelected(opt)"
|
|
560
|
+
(click)="selectOption(opt)"
|
|
561
|
+
(mouseenter)="focusedIndex.set(i)"
|
|
562
|
+
>{{ opt.label }}</div>
|
|
563
|
+
}
|
|
564
|
+
@if (filteredOptions().length === 0) {
|
|
565
|
+
<div class="popup-empty">No results</div>
|
|
566
|
+
}
|
|
567
|
+
</div>
|
|
568
|
+
</div>
|
|
569
|
+
}
|
|
570
|
+
</div>
|
|
571
|
+
`, styles: [":host{display:block}.ngx-dropdown{position:relative;font-family:inherit}.ngx-dropdown-label{display:block;font-size:13px;color:var(--ngx-input-label, #6c757d);margin-bottom:4px;font-weight:500}.ngx-dropdown-trigger{display:flex;align-items:center;justify-content:space-between;padding:8px 12px;border:1px solid var(--ngx-input-border, #ced4da);border-radius:var(--ngx-input-radius, 4px);background:var(--ngx-input-bg, #fff);cursor:pointer;-webkit-user-select:none;user-select:none;font-size:14px;transition:border-color .15s,box-shadow .15s}.ngx-dropdown-trigger:hover{border-color:#adb5bd}.open .ngx-dropdown-trigger{border-color:var(--ngx-input-focus, #4a90d9);box-shadow:0 0 0 2px #4a90d92e}.disabled .ngx-dropdown-trigger{background:#f8f9fa;cursor:not-allowed;color:#adb5bd}.trigger-text{flex:1;color:var(--ngx-input-text, #212529)}.trigger-text.placeholder{color:#adb5bd}.trigger-arrow{font-size:10px;color:#6c757d;transition:transform .15s}.trigger-arrow.open{transform:rotate(180deg)}.ngx-dropdown-popup{position:absolute;top:calc(100% + 4px);left:0;right:0;z-index:1000;background:var(--ngx-input-bg, #fff);border:1px solid var(--ngx-input-border, #ced4da);border-radius:var(--ngx-input-radius, 4px);box-shadow:0 4px 16px #0000001f;overflow:hidden}.popup-search{padding:8px;border-bottom:1px solid var(--ngx-input-border, #ced4da)}.popup-search-input{width:100%;padding:6px 10px;border:1px solid var(--ngx-input-border, #ced4da);border-radius:3px;font-size:13px;outline:none;font-family:inherit}.popup-list{max-height:240px;overflow-y:auto}.popup-item{padding:8px 12px;font-size:14px;cursor:pointer;color:var(--ngx-input-text, #212529);transition:background .1s}.popup-item:hover,.popup-item.focused{background:var(--ngx-input-hover-bg, #f1f3f5)}.popup-item.selected{background:var(--ngx-input-selected-bg, #e8f0fe);color:var(--ngx-input-focus, #4a90d9);font-weight:500}.popup-item.disabled{color:#adb5bd;cursor:not-allowed}.popup-item.disabled:hover{background:none}.popup-empty{padding:12px;text-align:center;color:#adb5bd;font-size:13px}\n"] }]
|
|
572
|
+
}], propDecorators: { onDocClick: [{
|
|
573
|
+
type: HostListener,
|
|
574
|
+
args: ['document:click', ['$event']]
|
|
575
|
+
}] } });
|
|
576
|
+
|
|
577
|
+
class MultiSelectComponent {
|
|
578
|
+
options = input([]);
|
|
579
|
+
values = input([]);
|
|
580
|
+
label = input('');
|
|
581
|
+
placeholder = input('Select...');
|
|
582
|
+
disabled = input(false);
|
|
583
|
+
filterable = input(false);
|
|
584
|
+
maxTags = input(Infinity);
|
|
585
|
+
valuesChange = output();
|
|
586
|
+
isOpen = signal(false);
|
|
587
|
+
filterText = signal('');
|
|
588
|
+
focusedIndex = signal(-1);
|
|
589
|
+
_cvaValues = signal([]);
|
|
590
|
+
_cvaActive = false;
|
|
591
|
+
_onChange = () => { };
|
|
592
|
+
_onTouched = () => { };
|
|
593
|
+
el = inject(ElementRef);
|
|
594
|
+
_activeValues = computed(() => this._cvaActive ? this._cvaValues() : this.values());
|
|
595
|
+
displayValues = computed(() => this._activeValues()
|
|
596
|
+
.slice(0, this.maxTags() === Infinity ? undefined : this.maxTags())
|
|
597
|
+
.map(v => ({ value: v, label: this.options().find(o => o.value === v)?.label ?? String(v) })));
|
|
598
|
+
filteredOptions = computed(() => {
|
|
599
|
+
const f = this.filterText().toLowerCase();
|
|
600
|
+
return f ? this.options().filter(o => o.label.toLowerCase().includes(f)) : this.options();
|
|
601
|
+
});
|
|
602
|
+
allSelected = computed(() => this.options().every(o => this._activeValues().includes(o.value)));
|
|
603
|
+
someSelected = computed(() => this.options().some(o => this._activeValues().includes(o.value)));
|
|
604
|
+
isChecked(opt) { return this._activeValues().includes(opt.value); }
|
|
605
|
+
toggle() {
|
|
606
|
+
if (this.disabled())
|
|
607
|
+
return;
|
|
608
|
+
this.isOpen.update(v => !v);
|
|
609
|
+
}
|
|
610
|
+
toggleOption(opt) {
|
|
611
|
+
if (opt.disabled)
|
|
612
|
+
return;
|
|
613
|
+
const cur = this._activeValues();
|
|
614
|
+
const next = cur.includes(opt.value) ? cur.filter(v => v !== opt.value) : [...cur, opt.value];
|
|
615
|
+
this._cvaValues.set(next);
|
|
616
|
+
this._onChange(next);
|
|
617
|
+
this._onTouched();
|
|
618
|
+
this.valuesChange.emit(next);
|
|
619
|
+
}
|
|
620
|
+
removeValue(val, e) {
|
|
621
|
+
e.stopPropagation();
|
|
622
|
+
const next = this._activeValues().filter(v => v !== val);
|
|
623
|
+
this._cvaValues.set(next);
|
|
624
|
+
this._onChange(next);
|
|
625
|
+
this.valuesChange.emit(next);
|
|
626
|
+
}
|
|
627
|
+
toggleAll() {
|
|
628
|
+
const next = this.allSelected() ? [] : this.options().filter(o => !o.disabled).map(o => o.value);
|
|
629
|
+
this._cvaValues.set(next);
|
|
630
|
+
this._onChange(next);
|
|
631
|
+
this.valuesChange.emit(next);
|
|
632
|
+
}
|
|
633
|
+
onTriggerKey(e) {
|
|
634
|
+
if (e.key === 'Enter' || e.key === ' ') {
|
|
635
|
+
e.preventDefault();
|
|
636
|
+
this.toggle();
|
|
637
|
+
}
|
|
638
|
+
if (e.key === 'Escape')
|
|
639
|
+
this.isOpen.set(false);
|
|
640
|
+
}
|
|
641
|
+
onDocClick(e) {
|
|
642
|
+
if (!this.el.nativeElement.contains(e.target)) {
|
|
643
|
+
this.isOpen.set(false);
|
|
644
|
+
this.filterText.set('');
|
|
645
|
+
}
|
|
646
|
+
}
|
|
647
|
+
// ControlValueAccessor
|
|
648
|
+
writeValue(val) {
|
|
649
|
+
this._cvaActive = true;
|
|
650
|
+
this._cvaValues.set(Array.isArray(val) ? val : []);
|
|
651
|
+
}
|
|
652
|
+
registerOnChange(fn) {
|
|
653
|
+
this._onChange = fn;
|
|
654
|
+
}
|
|
655
|
+
registerOnTouched(fn) {
|
|
656
|
+
this._onTouched = fn;
|
|
657
|
+
}
|
|
658
|
+
setDisabledState(_isDisabled) {
|
|
659
|
+
// disabled is controlled via input() for template usage.
|
|
660
|
+
}
|
|
661
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.20", ngImport: i0, type: MultiSelectComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
662
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.20", type: MultiSelectComponent, isStandalone: true, selector: "ngx-multi-select", inputs: { options: { classPropertyName: "options", publicName: "options", isSignal: true, isRequired: false, transformFunction: null }, values: { classPropertyName: "values", publicName: "values", 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 }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, filterable: { classPropertyName: "filterable", publicName: "filterable", isSignal: true, isRequired: false, transformFunction: null }, maxTags: { classPropertyName: "maxTags", publicName: "maxTags", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { valuesChange: "valuesChange" }, host: { listeners: { "document:click": "onDocClick($event)" } }, providers: [
|
|
663
|
+
{
|
|
664
|
+
provide: NG_VALUE_ACCESSOR,
|
|
665
|
+
useExisting: forwardRef(() => MultiSelectComponent),
|
|
666
|
+
multi: true,
|
|
667
|
+
},
|
|
668
|
+
], ngImport: i0, template: `
|
|
669
|
+
<div class="ngx-multi-select" [class.open]="isOpen()" [class.disabled]="disabled()" role="combobox">
|
|
670
|
+
@if (label()) {
|
|
671
|
+
<label class="ms-label">{{ label() }}</label>
|
|
672
|
+
}
|
|
673
|
+
<!-- Trigger -->
|
|
674
|
+
<div class="ms-trigger" tabindex="0" (click)="toggle()" (keydown)="onTriggerKey($event)">
|
|
675
|
+
<div class="ms-tags">
|
|
676
|
+
@for (val of displayValues(); track val.value) {
|
|
677
|
+
<span class="ms-tag">
|
|
678
|
+
{{ val.label }}
|
|
679
|
+
<button class="ms-tag-remove" (click)="removeValue(val.value, $event)" [attr.aria-label]="'Remove ' + val.label">✕</button>
|
|
680
|
+
</span>
|
|
681
|
+
}
|
|
682
|
+
@if (displayValues().length === 0) {
|
|
683
|
+
<span class="ms-placeholder">{{ placeholder() }}</span>
|
|
684
|
+
}
|
|
685
|
+
</div>
|
|
686
|
+
<span class="ms-arrow" [class.open]="isOpen()">▼</span>
|
|
687
|
+
</div>
|
|
688
|
+
|
|
689
|
+
<!-- Popup -->
|
|
690
|
+
@if (isOpen()) {
|
|
691
|
+
<div class="ms-popup">
|
|
692
|
+
@if (filterable()) {
|
|
693
|
+
<div class="ms-search">
|
|
694
|
+
<input
|
|
695
|
+
class="ms-search-input"
|
|
696
|
+
placeholder="Search..."
|
|
697
|
+
[value]="filterText()"
|
|
698
|
+
(input)="filterText.set($any($event.target).value)"
|
|
699
|
+
(click)="$event.stopPropagation()"
|
|
700
|
+
/>
|
|
701
|
+
</div>
|
|
702
|
+
}
|
|
703
|
+
<div class="ms-list">
|
|
704
|
+
<!-- Select All -->
|
|
705
|
+
<label class="ms-item ms-select-all">
|
|
706
|
+
<input
|
|
707
|
+
type="checkbox"
|
|
708
|
+
[checked]="allSelected()"
|
|
709
|
+
[indeterminate]="someSelected() && !allSelected()"
|
|
710
|
+
(change)="toggleAll()"
|
|
711
|
+
/>
|
|
712
|
+
<span>Select All</span>
|
|
713
|
+
</label>
|
|
714
|
+
<div class="ms-divider"></div>
|
|
715
|
+
@for (opt of filteredOptions(); track opt.value; let i = $index) {
|
|
716
|
+
<label
|
|
717
|
+
class="ms-item"
|
|
718
|
+
[class.checked]="isChecked(opt)"
|
|
719
|
+
[class.disabled]="opt.disabled"
|
|
720
|
+
[class.focused]="focusedIndex() === i"
|
|
721
|
+
(mouseenter)="focusedIndex.set(i)"
|
|
722
|
+
>
|
|
723
|
+
<input
|
|
724
|
+
type="checkbox"
|
|
725
|
+
[checked]="isChecked(opt)"
|
|
726
|
+
[disabled]="!!opt.disabled"
|
|
727
|
+
(change)="toggleOption(opt)"
|
|
728
|
+
(click)="$event.stopPropagation()"
|
|
729
|
+
/>
|
|
730
|
+
<span>{{ opt.label }}</span>
|
|
731
|
+
</label>
|
|
732
|
+
}
|
|
733
|
+
@if (filteredOptions().length === 0) {
|
|
734
|
+
<div class="ms-empty">No results</div>
|
|
735
|
+
}
|
|
736
|
+
</div>
|
|
737
|
+
</div>
|
|
738
|
+
}
|
|
739
|
+
</div>
|
|
740
|
+
`, isInline: true, styles: [":host{display:block}.ngx-multi-select{position:relative;font-family:inherit}.ms-label{display:block;font-size:13px;color:var(--ngx-input-label, #6c757d);margin-bottom:4px;font-weight:500}.ms-trigger{display:flex;align-items:center;min-height:38px;padding:4px 8px 4px 4px;border:1px solid var(--ngx-input-border, #ced4da);border-radius:var(--ngx-input-radius, 4px);background:var(--ngx-input-bg, #fff);cursor:pointer;-webkit-user-select:none;user-select:none;transition:border-color .15s,box-shadow .15s}.ms-trigger:hover{border-color:#adb5bd}.open .ms-trigger{border-color:var(--ngx-input-focus, #4a90d9);box-shadow:0 0 0 2px #4a90d92e}.disabled .ms-trigger{background:#f8f9fa;cursor:not-allowed}.ms-tags{display:flex;flex-wrap:wrap;gap:4px;flex:1;align-items:center}.ms-tag{display:inline-flex;align-items:center;gap:4px;background:var(--ngx-input-tag-bg, #e8f0fe);color:var(--ngx-input-tag-color, #1a73e8);padding:2px 4px 2px 8px;border-radius:3px;font-size:12px}.ms-tag-remove{background:none;border:none;cursor:pointer;padding:0 2px;color:var(--ngx-input-tag-color, #1a73e8);font-size:10px;line-height:1}.ms-placeholder{color:#adb5bd;font-size:14px;padding:0 4px}.ms-arrow{font-size:10px;color:#6c757d;transition:transform .15s;margin-left:auto}.ms-arrow.open{transform:rotate(180deg)}.ms-popup{position:absolute;top:calc(100% + 4px);left:0;right:0;z-index:1000;background:var(--ngx-input-bg, #fff);border:1px solid var(--ngx-input-border, #ced4da);border-radius:var(--ngx-input-radius, 4px);box-shadow:0 4px 16px #0000001f;overflow:hidden}.ms-search{padding:8px;border-bottom:1px solid var(--ngx-input-border, #ced4da)}.ms-search-input{width:100%;padding:6px 10px;border:1px solid var(--ngx-input-border, #ced4da);border-radius:3px;font-size:13px;outline:none;font-family:inherit}.ms-list{max-height:240px;overflow-y:auto}.ms-item{display:flex;align-items:center;gap:10px;padding:8px 12px;cursor:pointer;font-size:14px;color:var(--ngx-input-text, #212529)}.ms-item:hover,.ms-item.focused{background:#f1f3f5}.ms-item.checked{background:#f0f7ff}.ms-item.disabled{color:#adb5bd;cursor:not-allowed}.ms-item input[type=checkbox]{width:14px;height:14px;cursor:pointer;accent-color:var(--ngx-input-focus, #4a90d9)}.ms-select-all{font-weight:500}.ms-divider{height:1px;background:#eee;margin:2px 0}.ms-empty{padding:12px;text-align:center;color:#adb5bd;font-size:13px}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
741
|
+
}
|
|
742
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.20", ngImport: i0, type: MultiSelectComponent, decorators: [{
|
|
743
|
+
type: Component,
|
|
744
|
+
args: [{ selector: 'ngx-multi-select', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, providers: [
|
|
745
|
+
{
|
|
746
|
+
provide: NG_VALUE_ACCESSOR,
|
|
747
|
+
useExisting: forwardRef(() => MultiSelectComponent),
|
|
748
|
+
multi: true,
|
|
749
|
+
},
|
|
750
|
+
], template: `
|
|
751
|
+
<div class="ngx-multi-select" [class.open]="isOpen()" [class.disabled]="disabled()" role="combobox">
|
|
752
|
+
@if (label()) {
|
|
753
|
+
<label class="ms-label">{{ label() }}</label>
|
|
754
|
+
}
|
|
755
|
+
<!-- Trigger -->
|
|
756
|
+
<div class="ms-trigger" tabindex="0" (click)="toggle()" (keydown)="onTriggerKey($event)">
|
|
757
|
+
<div class="ms-tags">
|
|
758
|
+
@for (val of displayValues(); track val.value) {
|
|
759
|
+
<span class="ms-tag">
|
|
760
|
+
{{ val.label }}
|
|
761
|
+
<button class="ms-tag-remove" (click)="removeValue(val.value, $event)" [attr.aria-label]="'Remove ' + val.label">✕</button>
|
|
762
|
+
</span>
|
|
763
|
+
}
|
|
764
|
+
@if (displayValues().length === 0) {
|
|
765
|
+
<span class="ms-placeholder">{{ placeholder() }}</span>
|
|
766
|
+
}
|
|
767
|
+
</div>
|
|
768
|
+
<span class="ms-arrow" [class.open]="isOpen()">▼</span>
|
|
769
|
+
</div>
|
|
770
|
+
|
|
771
|
+
<!-- Popup -->
|
|
772
|
+
@if (isOpen()) {
|
|
773
|
+
<div class="ms-popup">
|
|
774
|
+
@if (filterable()) {
|
|
775
|
+
<div class="ms-search">
|
|
776
|
+
<input
|
|
777
|
+
class="ms-search-input"
|
|
778
|
+
placeholder="Search..."
|
|
779
|
+
[value]="filterText()"
|
|
780
|
+
(input)="filterText.set($any($event.target).value)"
|
|
781
|
+
(click)="$event.stopPropagation()"
|
|
782
|
+
/>
|
|
783
|
+
</div>
|
|
784
|
+
}
|
|
785
|
+
<div class="ms-list">
|
|
786
|
+
<!-- Select All -->
|
|
787
|
+
<label class="ms-item ms-select-all">
|
|
788
|
+
<input
|
|
789
|
+
type="checkbox"
|
|
790
|
+
[checked]="allSelected()"
|
|
791
|
+
[indeterminate]="someSelected() && !allSelected()"
|
|
792
|
+
(change)="toggleAll()"
|
|
793
|
+
/>
|
|
794
|
+
<span>Select All</span>
|
|
795
|
+
</label>
|
|
796
|
+
<div class="ms-divider"></div>
|
|
797
|
+
@for (opt of filteredOptions(); track opt.value; let i = $index) {
|
|
798
|
+
<label
|
|
799
|
+
class="ms-item"
|
|
800
|
+
[class.checked]="isChecked(opt)"
|
|
801
|
+
[class.disabled]="opt.disabled"
|
|
802
|
+
[class.focused]="focusedIndex() === i"
|
|
803
|
+
(mouseenter)="focusedIndex.set(i)"
|
|
804
|
+
>
|
|
805
|
+
<input
|
|
806
|
+
type="checkbox"
|
|
807
|
+
[checked]="isChecked(opt)"
|
|
808
|
+
[disabled]="!!opt.disabled"
|
|
809
|
+
(change)="toggleOption(opt)"
|
|
810
|
+
(click)="$event.stopPropagation()"
|
|
811
|
+
/>
|
|
812
|
+
<span>{{ opt.label }}</span>
|
|
813
|
+
</label>
|
|
814
|
+
}
|
|
815
|
+
@if (filteredOptions().length === 0) {
|
|
816
|
+
<div class="ms-empty">No results</div>
|
|
817
|
+
}
|
|
818
|
+
</div>
|
|
819
|
+
</div>
|
|
820
|
+
}
|
|
821
|
+
</div>
|
|
822
|
+
`, styles: [":host{display:block}.ngx-multi-select{position:relative;font-family:inherit}.ms-label{display:block;font-size:13px;color:var(--ngx-input-label, #6c757d);margin-bottom:4px;font-weight:500}.ms-trigger{display:flex;align-items:center;min-height:38px;padding:4px 8px 4px 4px;border:1px solid var(--ngx-input-border, #ced4da);border-radius:var(--ngx-input-radius, 4px);background:var(--ngx-input-bg, #fff);cursor:pointer;-webkit-user-select:none;user-select:none;transition:border-color .15s,box-shadow .15s}.ms-trigger:hover{border-color:#adb5bd}.open .ms-trigger{border-color:var(--ngx-input-focus, #4a90d9);box-shadow:0 0 0 2px #4a90d92e}.disabled .ms-trigger{background:#f8f9fa;cursor:not-allowed}.ms-tags{display:flex;flex-wrap:wrap;gap:4px;flex:1;align-items:center}.ms-tag{display:inline-flex;align-items:center;gap:4px;background:var(--ngx-input-tag-bg, #e8f0fe);color:var(--ngx-input-tag-color, #1a73e8);padding:2px 4px 2px 8px;border-radius:3px;font-size:12px}.ms-tag-remove{background:none;border:none;cursor:pointer;padding:0 2px;color:var(--ngx-input-tag-color, #1a73e8);font-size:10px;line-height:1}.ms-placeholder{color:#adb5bd;font-size:14px;padding:0 4px}.ms-arrow{font-size:10px;color:#6c757d;transition:transform .15s;margin-left:auto}.ms-arrow.open{transform:rotate(180deg)}.ms-popup{position:absolute;top:calc(100% + 4px);left:0;right:0;z-index:1000;background:var(--ngx-input-bg, #fff);border:1px solid var(--ngx-input-border, #ced4da);border-radius:var(--ngx-input-radius, 4px);box-shadow:0 4px 16px #0000001f;overflow:hidden}.ms-search{padding:8px;border-bottom:1px solid var(--ngx-input-border, #ced4da)}.ms-search-input{width:100%;padding:6px 10px;border:1px solid var(--ngx-input-border, #ced4da);border-radius:3px;font-size:13px;outline:none;font-family:inherit}.ms-list{max-height:240px;overflow-y:auto}.ms-item{display:flex;align-items:center;gap:10px;padding:8px 12px;cursor:pointer;font-size:14px;color:var(--ngx-input-text, #212529)}.ms-item:hover,.ms-item.focused{background:#f1f3f5}.ms-item.checked{background:#f0f7ff}.ms-item.disabled{color:#adb5bd;cursor:not-allowed}.ms-item input[type=checkbox]{width:14px;height:14px;cursor:pointer;accent-color:var(--ngx-input-focus, #4a90d9)}.ms-select-all{font-weight:500}.ms-divider{height:1px;background:#eee;margin:2px 0}.ms-empty{padding:12px;text-align:center;color:#adb5bd;font-size:13px}\n"] }]
|
|
823
|
+
}], propDecorators: { onDocClick: [{
|
|
824
|
+
type: HostListener,
|
|
825
|
+
args: ['document:click', ['$event']]
|
|
826
|
+
}] } });
|
|
827
|
+
|
|
828
|
+
class AutocompleteComponent {
|
|
829
|
+
options = input([]);
|
|
830
|
+
label = input('');
|
|
831
|
+
placeholder = input('Type to search...');
|
|
832
|
+
disabled = input(false);
|
|
833
|
+
error = input('');
|
|
834
|
+
minLength = input(1);
|
|
835
|
+
valueChange = output();
|
|
836
|
+
_inputText = signal('');
|
|
837
|
+
_selectedValue = signal(null);
|
|
838
|
+
isOpen = signal(false);
|
|
839
|
+
isFocused = signal(false);
|
|
840
|
+
focusedIndex = signal(-1);
|
|
841
|
+
_onChange = () => { };
|
|
842
|
+
_onTouched = () => { };
|
|
843
|
+
el = inject(ElementRef);
|
|
844
|
+
filteredOptions = computed(() => {
|
|
845
|
+
const text = this._inputText().toLowerCase();
|
|
846
|
+
if (text.length < this.minLength())
|
|
847
|
+
return [];
|
|
848
|
+
return this.options().filter(o => o.label.toLowerCase().includes(text));
|
|
849
|
+
});
|
|
850
|
+
isSelected(opt) {
|
|
851
|
+
return this._selectedValue() === opt.value;
|
|
852
|
+
}
|
|
853
|
+
onInput(e) {
|
|
854
|
+
const text = e.target.value;
|
|
855
|
+
this._inputText.set(text);
|
|
856
|
+
this._selectedValue.set(null);
|
|
857
|
+
this.isOpen.set(text.length >= this.minLength());
|
|
858
|
+
this.focusedIndex.set(-1);
|
|
859
|
+
}
|
|
860
|
+
onFocus() {
|
|
861
|
+
this.isFocused.set(true);
|
|
862
|
+
if (this._inputText().length >= this.minLength()) {
|
|
863
|
+
this.isOpen.set(true);
|
|
864
|
+
}
|
|
865
|
+
}
|
|
866
|
+
onBlur() {
|
|
867
|
+
this.isFocused.set(false);
|
|
868
|
+
this._onTouched();
|
|
869
|
+
setTimeout(() => this.isOpen.set(false), 150);
|
|
870
|
+
}
|
|
871
|
+
onKeyDown(e) {
|
|
872
|
+
const n = this.filteredOptions().length;
|
|
873
|
+
if (e.key === 'ArrowDown') {
|
|
874
|
+
e.preventDefault();
|
|
875
|
+
this.focusedIndex.update(i => Math.min(n - 1, i + 1));
|
|
876
|
+
}
|
|
877
|
+
else if (e.key === 'ArrowUp') {
|
|
878
|
+
e.preventDefault();
|
|
879
|
+
this.focusedIndex.update(i => Math.max(-1, i - 1));
|
|
880
|
+
}
|
|
881
|
+
else if (e.key === 'Enter') {
|
|
882
|
+
const idx = this.focusedIndex();
|
|
883
|
+
if (idx >= 0 && idx < n)
|
|
884
|
+
this.selectOption(this.filteredOptions()[idx]);
|
|
885
|
+
}
|
|
886
|
+
else if (e.key === 'Escape') {
|
|
887
|
+
this.isOpen.set(false);
|
|
888
|
+
}
|
|
889
|
+
}
|
|
890
|
+
selectOption(opt) {
|
|
891
|
+
if (opt.disabled)
|
|
892
|
+
return;
|
|
893
|
+
this._inputText.set(opt.label);
|
|
894
|
+
this._selectedValue.set(opt.value);
|
|
895
|
+
this.isOpen.set(false);
|
|
896
|
+
this._onChange(opt.value);
|
|
897
|
+
this._onTouched();
|
|
898
|
+
this.valueChange.emit(opt.value);
|
|
899
|
+
}
|
|
900
|
+
clear() {
|
|
901
|
+
this._inputText.set('');
|
|
902
|
+
this._selectedValue.set(null);
|
|
903
|
+
this.isOpen.set(false);
|
|
904
|
+
this._onChange(null);
|
|
905
|
+
this.valueChange.emit(null);
|
|
906
|
+
}
|
|
907
|
+
onDocClick(e) {
|
|
908
|
+
if (!this.el.nativeElement.contains(e.target)) {
|
|
909
|
+
this.isOpen.set(false);
|
|
910
|
+
}
|
|
911
|
+
}
|
|
912
|
+
// ControlValueAccessor
|
|
913
|
+
writeValue(val) {
|
|
914
|
+
if (val === null || val === undefined) {
|
|
915
|
+
this._inputText.set('');
|
|
916
|
+
this._selectedValue.set(null);
|
|
917
|
+
return;
|
|
918
|
+
}
|
|
919
|
+
const match = this.options().find(o => o.value === val);
|
|
920
|
+
this._inputText.set(match?.label ?? String(val));
|
|
921
|
+
this._selectedValue.set(val);
|
|
922
|
+
}
|
|
923
|
+
registerOnChange(fn) {
|
|
924
|
+
this._onChange = fn;
|
|
925
|
+
}
|
|
926
|
+
registerOnTouched(fn) {
|
|
927
|
+
this._onTouched = fn;
|
|
928
|
+
}
|
|
929
|
+
setDisabledState(_isDisabled) {
|
|
930
|
+
// disabled handled via input()
|
|
931
|
+
}
|
|
932
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.20", ngImport: i0, type: AutocompleteComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
933
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.20", type: AutocompleteComponent, isStandalone: true, selector: "ngx-autocomplete", inputs: { options: { classPropertyName: "options", publicName: "options", 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 }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, error: { classPropertyName: "error", publicName: "error", isSignal: true, isRequired: false, transformFunction: null }, minLength: { classPropertyName: "minLength", publicName: "minLength", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { valueChange: "valueChange" }, host: { listeners: { "document:click": "onDocClick($event)" } }, providers: [
|
|
934
|
+
{
|
|
935
|
+
provide: NG_VALUE_ACCESSOR,
|
|
936
|
+
useExisting: forwardRef(() => AutocompleteComponent),
|
|
937
|
+
multi: true,
|
|
938
|
+
},
|
|
939
|
+
], ngImport: i0, template: `
|
|
940
|
+
<div
|
|
941
|
+
class="ngx-autocomplete"
|
|
942
|
+
[class.open]="isOpen()"
|
|
943
|
+
[class.focused]="isFocused()"
|
|
944
|
+
[class.has-error]="!!error()"
|
|
945
|
+
[class.disabled]="disabled()"
|
|
946
|
+
>
|
|
947
|
+
@if (label()) {
|
|
948
|
+
<label class="ngx-ac-label">{{ label() }}</label>
|
|
949
|
+
}
|
|
950
|
+
<div class="ngx-ac-wrap">
|
|
951
|
+
<input
|
|
952
|
+
class="ngx-ac-input"
|
|
953
|
+
[placeholder]="placeholder()"
|
|
954
|
+
[disabled]="disabled()"
|
|
955
|
+
[value]="_inputText()"
|
|
956
|
+
(input)="onInput($event)"
|
|
957
|
+
(focus)="onFocus()"
|
|
958
|
+
(blur)="onBlur()"
|
|
959
|
+
(keydown)="onKeyDown($event)"
|
|
960
|
+
role="combobox"
|
|
961
|
+
[attr.aria-expanded]="isOpen()"
|
|
962
|
+
aria-autocomplete="list"
|
|
963
|
+
aria-haspopup="listbox"
|
|
964
|
+
/>
|
|
965
|
+
@if (_inputText()) {
|
|
966
|
+
<button class="ngx-ac-clear" (click)="clear()" aria-label="Clear">✕</button>
|
|
967
|
+
}
|
|
968
|
+
</div>
|
|
969
|
+
|
|
970
|
+
<!-- Suggestion panel — floats above DOM via absolute positioning -->
|
|
971
|
+
@if (isOpen() && filteredOptions().length > 0) {
|
|
972
|
+
<div class="ngx-ac-panel" role="listbox">
|
|
973
|
+
@for (opt of filteredOptions(); track opt.value; let i = $index) {
|
|
974
|
+
<div
|
|
975
|
+
class="ngx-ac-item"
|
|
976
|
+
[class.focused]="focusedIndex() === i"
|
|
977
|
+
[class.disabled]="opt.disabled"
|
|
978
|
+
role="option"
|
|
979
|
+
[attr.aria-selected]="isSelected(opt)"
|
|
980
|
+
(mousedown)="selectOption(opt)"
|
|
981
|
+
(mouseenter)="focusedIndex.set(i)"
|
|
982
|
+
>{{ opt.label }}</div>
|
|
983
|
+
}
|
|
984
|
+
</div>
|
|
985
|
+
}
|
|
986
|
+
|
|
987
|
+
@if (error()) {
|
|
988
|
+
<div class="ngx-ac-error">{{ error() }}</div>
|
|
989
|
+
}
|
|
990
|
+
</div>
|
|
991
|
+
`, isInline: true, styles: [":host{display:block}.ngx-autocomplete{position:relative;font-family:inherit}.ngx-ac-label{display:block;font-size:13px;color:var(--ngx-input-label, #6c757d);margin-bottom:4px;font-weight:500}.ngx-ac-wrap{display:flex;align-items:center;border:1px solid var(--ngx-input-border, #ced4da);border-radius:var(--ngx-input-radius, 4px);background:var(--ngx-input-bg, #fff);transition:border-color .15s,box-shadow .15s}.focused .ngx-ac-wrap{border-color:var(--ngx-input-focus, #4a90d9);box-shadow:0 0 0 2px #4a90d92e}.has-error .ngx-ac-wrap{border-color:var(--ngx-input-error, #e74c3c)}.disabled .ngx-ac-wrap{background:#f8f9fa}.ngx-ac-input{flex:1;padding:8px 12px;border:none;outline:none;background:transparent;font-size:14px;color:var(--ngx-input-text, #212529);font-family:inherit}.ngx-ac-input:disabled{cursor:not-allowed;color:#adb5bd}.ngx-ac-clear{padding:0 10px;background:none;border:none;cursor:pointer;color:#adb5bd;font-size:14px;line-height:1}.ngx-ac-panel{position:absolute;top:calc(100% + 4px);left:0;right:0;z-index:1000;background:var(--ngx-input-bg, #fff);border:1px solid var(--ngx-input-border, #ced4da);border-radius:var(--ngx-input-radius, 4px);box-shadow:0 4px 16px #0000001f;max-height:240px;overflow-y:auto}.ngx-ac-item{padding:8px 12px;font-size:14px;cursor:pointer;color:var(--ngx-input-text, #212529);transition:background .1s}.ngx-ac-item:hover,.ngx-ac-item.focused{background:var(--ngx-input-hover-bg, #f1f3f5)}.ngx-ac-item.disabled{color:#adb5bd;cursor:not-allowed;pointer-events:none}.ngx-ac-error{font-size:12px;color:var(--ngx-input-error, #e74c3c);margin-top:4px}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
992
|
+
}
|
|
993
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.20", ngImport: i0, type: AutocompleteComponent, decorators: [{
|
|
994
|
+
type: Component,
|
|
995
|
+
args: [{ selector: 'ngx-autocomplete', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, providers: [
|
|
996
|
+
{
|
|
997
|
+
provide: NG_VALUE_ACCESSOR,
|
|
998
|
+
useExisting: forwardRef(() => AutocompleteComponent),
|
|
999
|
+
multi: true,
|
|
1000
|
+
},
|
|
1001
|
+
], template: `
|
|
1002
|
+
<div
|
|
1003
|
+
class="ngx-autocomplete"
|
|
1004
|
+
[class.open]="isOpen()"
|
|
1005
|
+
[class.focused]="isFocused()"
|
|
1006
|
+
[class.has-error]="!!error()"
|
|
1007
|
+
[class.disabled]="disabled()"
|
|
1008
|
+
>
|
|
1009
|
+
@if (label()) {
|
|
1010
|
+
<label class="ngx-ac-label">{{ label() }}</label>
|
|
1011
|
+
}
|
|
1012
|
+
<div class="ngx-ac-wrap">
|
|
1013
|
+
<input
|
|
1014
|
+
class="ngx-ac-input"
|
|
1015
|
+
[placeholder]="placeholder()"
|
|
1016
|
+
[disabled]="disabled()"
|
|
1017
|
+
[value]="_inputText()"
|
|
1018
|
+
(input)="onInput($event)"
|
|
1019
|
+
(focus)="onFocus()"
|
|
1020
|
+
(blur)="onBlur()"
|
|
1021
|
+
(keydown)="onKeyDown($event)"
|
|
1022
|
+
role="combobox"
|
|
1023
|
+
[attr.aria-expanded]="isOpen()"
|
|
1024
|
+
aria-autocomplete="list"
|
|
1025
|
+
aria-haspopup="listbox"
|
|
1026
|
+
/>
|
|
1027
|
+
@if (_inputText()) {
|
|
1028
|
+
<button class="ngx-ac-clear" (click)="clear()" aria-label="Clear">✕</button>
|
|
1029
|
+
}
|
|
1030
|
+
</div>
|
|
1031
|
+
|
|
1032
|
+
<!-- Suggestion panel — floats above DOM via absolute positioning -->
|
|
1033
|
+
@if (isOpen() && filteredOptions().length > 0) {
|
|
1034
|
+
<div class="ngx-ac-panel" role="listbox">
|
|
1035
|
+
@for (opt of filteredOptions(); track opt.value; let i = $index) {
|
|
1036
|
+
<div
|
|
1037
|
+
class="ngx-ac-item"
|
|
1038
|
+
[class.focused]="focusedIndex() === i"
|
|
1039
|
+
[class.disabled]="opt.disabled"
|
|
1040
|
+
role="option"
|
|
1041
|
+
[attr.aria-selected]="isSelected(opt)"
|
|
1042
|
+
(mousedown)="selectOption(opt)"
|
|
1043
|
+
(mouseenter)="focusedIndex.set(i)"
|
|
1044
|
+
>{{ opt.label }}</div>
|
|
1045
|
+
}
|
|
1046
|
+
</div>
|
|
1047
|
+
}
|
|
1048
|
+
|
|
1049
|
+
@if (error()) {
|
|
1050
|
+
<div class="ngx-ac-error">{{ error() }}</div>
|
|
1051
|
+
}
|
|
1052
|
+
</div>
|
|
1053
|
+
`, styles: [":host{display:block}.ngx-autocomplete{position:relative;font-family:inherit}.ngx-ac-label{display:block;font-size:13px;color:var(--ngx-input-label, #6c757d);margin-bottom:4px;font-weight:500}.ngx-ac-wrap{display:flex;align-items:center;border:1px solid var(--ngx-input-border, #ced4da);border-radius:var(--ngx-input-radius, 4px);background:var(--ngx-input-bg, #fff);transition:border-color .15s,box-shadow .15s}.focused .ngx-ac-wrap{border-color:var(--ngx-input-focus, #4a90d9);box-shadow:0 0 0 2px #4a90d92e}.has-error .ngx-ac-wrap{border-color:var(--ngx-input-error, #e74c3c)}.disabled .ngx-ac-wrap{background:#f8f9fa}.ngx-ac-input{flex:1;padding:8px 12px;border:none;outline:none;background:transparent;font-size:14px;color:var(--ngx-input-text, #212529);font-family:inherit}.ngx-ac-input:disabled{cursor:not-allowed;color:#adb5bd}.ngx-ac-clear{padding:0 10px;background:none;border:none;cursor:pointer;color:#adb5bd;font-size:14px;line-height:1}.ngx-ac-panel{position:absolute;top:calc(100% + 4px);left:0;right:0;z-index:1000;background:var(--ngx-input-bg, #fff);border:1px solid var(--ngx-input-border, #ced4da);border-radius:var(--ngx-input-radius, 4px);box-shadow:0 4px 16px #0000001f;max-height:240px;overflow-y:auto}.ngx-ac-item{padding:8px 12px;font-size:14px;cursor:pointer;color:var(--ngx-input-text, #212529);transition:background .1s}.ngx-ac-item:hover,.ngx-ac-item.focused{background:var(--ngx-input-hover-bg, #f1f3f5)}.ngx-ac-item.disabled{color:#adb5bd;cursor:not-allowed;pointer-events:none}.ngx-ac-error{font-size:12px;color:var(--ngx-input-error, #e74c3c);margin-top:4px}\n"] }]
|
|
1054
|
+
}], propDecorators: { onDocClick: [{
|
|
1055
|
+
type: HostListener,
|
|
1056
|
+
args: ['document:click', ['$event']]
|
|
1057
|
+
}] } });
|
|
1058
|
+
|
|
1059
|
+
class DatePickerComponent {
|
|
1060
|
+
value = input(null);
|
|
1061
|
+
label = input('');
|
|
1062
|
+
placeholder = input('Select date...');
|
|
1063
|
+
disabled = input(false);
|
|
1064
|
+
min = input(null);
|
|
1065
|
+
max = input(null);
|
|
1066
|
+
format = input('MM/dd/yyyy');
|
|
1067
|
+
valueChange = output();
|
|
1068
|
+
WEEKDAYS = ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'];
|
|
1069
|
+
isOpen = signal(false);
|
|
1070
|
+
viewYear = signal(new Date().getFullYear());
|
|
1071
|
+
viewMonth = signal(new Date().getMonth());
|
|
1072
|
+
_cvaValue = signal(null);
|
|
1073
|
+
_cvaActive = false;
|
|
1074
|
+
_onChange = () => { };
|
|
1075
|
+
_onTouched = () => { };
|
|
1076
|
+
el = inject(ElementRef);
|
|
1077
|
+
_activeValue = computed(() => this._cvaActive ? this._cvaValue() : this.value());
|
|
1078
|
+
displayValue = computed(() => {
|
|
1079
|
+
const v = this._activeValue();
|
|
1080
|
+
if (!v)
|
|
1081
|
+
return '';
|
|
1082
|
+
return v.toLocaleDateString('en-US', { month: '2-digit', day: '2-digit', year: 'numeric' });
|
|
1083
|
+
});
|
|
1084
|
+
monthTitle = computed(() => {
|
|
1085
|
+
const d = new Date(this.viewYear(), this.viewMonth(), 1);
|
|
1086
|
+
return d.toLocaleDateString('en-US', { month: 'long', year: 'numeric' });
|
|
1087
|
+
});
|
|
1088
|
+
calendarDays = computed(() => {
|
|
1089
|
+
const y = this.viewYear(), m = this.viewMonth();
|
|
1090
|
+
const first = new Date(y, m, 1);
|
|
1091
|
+
const last = new Date(y, m + 1, 0);
|
|
1092
|
+
const today = new Date();
|
|
1093
|
+
today.setHours(0, 0, 0, 0);
|
|
1094
|
+
const selectedTime = this._activeValue()?.setHours(0, 0, 0, 0) ?? -1;
|
|
1095
|
+
const days = [];
|
|
1096
|
+
// Leading blanks
|
|
1097
|
+
for (let i = 0; i < first.getDay(); i++) {
|
|
1098
|
+
const d = new Date(y, m, -first.getDay() + i + 1);
|
|
1099
|
+
days.push({ date: d, label: d.getDate().toString(), current: false, isToday: false, isSelected: false, disabled: true });
|
|
1100
|
+
}
|
|
1101
|
+
// Days in month
|
|
1102
|
+
for (let d = 1; d <= last.getDate(); d++) {
|
|
1103
|
+
const date = new Date(y, m, d);
|
|
1104
|
+
const isDisabled = (this.min() && date < this.min()) || (this.max() && date > this.max()) || false;
|
|
1105
|
+
days.push({
|
|
1106
|
+
date, label: d.toString(), current: true,
|
|
1107
|
+
isToday: date.getTime() === today.getTime(),
|
|
1108
|
+
isSelected: date.setHours(0, 0, 0, 0) === selectedTime,
|
|
1109
|
+
disabled: isDisabled,
|
|
1110
|
+
});
|
|
1111
|
+
}
|
|
1112
|
+
// Trailing blanks
|
|
1113
|
+
const remaining = 42 - days.length;
|
|
1114
|
+
for (let i = 1; i <= remaining; i++) {
|
|
1115
|
+
const d = new Date(y, m + 1, i);
|
|
1116
|
+
days.push({ date: d, label: i.toString(), current: false, isToday: false, isSelected: false, disabled: true });
|
|
1117
|
+
}
|
|
1118
|
+
return days;
|
|
1119
|
+
});
|
|
1120
|
+
toggle() {
|
|
1121
|
+
if (this.disabled())
|
|
1122
|
+
return;
|
|
1123
|
+
this.isOpen.update(v => !v);
|
|
1124
|
+
if (this.isOpen() && this._activeValue()) {
|
|
1125
|
+
this.viewYear.set(this._activeValue().getFullYear());
|
|
1126
|
+
this.viewMonth.set(this._activeValue().getMonth());
|
|
1127
|
+
}
|
|
1128
|
+
}
|
|
1129
|
+
prevMonth() {
|
|
1130
|
+
if (this.viewMonth() === 0) {
|
|
1131
|
+
this.viewMonth.set(11);
|
|
1132
|
+
this.viewYear.update(y => y - 1);
|
|
1133
|
+
}
|
|
1134
|
+
else
|
|
1135
|
+
this.viewMonth.update(m => m - 1);
|
|
1136
|
+
}
|
|
1137
|
+
nextMonth() {
|
|
1138
|
+
if (this.viewMonth() === 11) {
|
|
1139
|
+
this.viewMonth.set(0);
|
|
1140
|
+
this.viewYear.update(y => y + 1);
|
|
1141
|
+
}
|
|
1142
|
+
else
|
|
1143
|
+
this.viewMonth.update(m => m + 1);
|
|
1144
|
+
}
|
|
1145
|
+
selectDay(date) {
|
|
1146
|
+
if (!date)
|
|
1147
|
+
return;
|
|
1148
|
+
this._cvaValue.set(date);
|
|
1149
|
+
this._onChange(date);
|
|
1150
|
+
this._onTouched();
|
|
1151
|
+
this.valueChange.emit(date);
|
|
1152
|
+
this.isOpen.set(false);
|
|
1153
|
+
}
|
|
1154
|
+
selectToday() { this.selectDay(new Date()); }
|
|
1155
|
+
clearValue() {
|
|
1156
|
+
this._cvaValue.set(null);
|
|
1157
|
+
this._onChange(null);
|
|
1158
|
+
this.valueChange.emit(null);
|
|
1159
|
+
this.isOpen.set(false);
|
|
1160
|
+
}
|
|
1161
|
+
onDocClick(e) {
|
|
1162
|
+
if (!this.el.nativeElement.contains(e.target))
|
|
1163
|
+
this.isOpen.set(false);
|
|
1164
|
+
}
|
|
1165
|
+
// ControlValueAccessor
|
|
1166
|
+
writeValue(val) {
|
|
1167
|
+
this._cvaActive = true;
|
|
1168
|
+
this._cvaValue.set(val instanceof Date ? val : null);
|
|
1169
|
+
}
|
|
1170
|
+
registerOnChange(fn) {
|
|
1171
|
+
this._onChange = fn;
|
|
1172
|
+
}
|
|
1173
|
+
registerOnTouched(fn) {
|
|
1174
|
+
this._onTouched = fn;
|
|
1175
|
+
}
|
|
1176
|
+
setDisabledState(_isDisabled) {
|
|
1177
|
+
// disabled is controlled via input() for template usage.
|
|
1178
|
+
}
|
|
1179
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.20", ngImport: i0, type: DatePickerComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1180
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.20", type: DatePickerComponent, isStandalone: true, selector: "ngx-date-picker", inputs: { value: { classPropertyName: "value", publicName: "value", 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 }, disabled: { classPropertyName: "disabled", publicName: "disabled", 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 }, format: { classPropertyName: "format", publicName: "format", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { valueChange: "valueChange" }, host: { listeners: { "document:click": "onDocClick($event)" } }, providers: [
|
|
1181
|
+
{
|
|
1182
|
+
provide: NG_VALUE_ACCESSOR,
|
|
1183
|
+
useExisting: forwardRef(() => DatePickerComponent),
|
|
1184
|
+
multi: true,
|
|
1185
|
+
},
|
|
1186
|
+
], ngImport: i0, template: `
|
|
1187
|
+
<div class="ngx-date-picker" [class.open]="isOpen()" [class.disabled]="disabled()">
|
|
1188
|
+
@if (label()) {
|
|
1189
|
+
<label class="dp-label">{{ label() }}</label>
|
|
1190
|
+
}
|
|
1191
|
+
<!-- Input trigger -->
|
|
1192
|
+
<div class="dp-input-wrap" (click)="toggle()">
|
|
1193
|
+
<input
|
|
1194
|
+
class="dp-input"
|
|
1195
|
+
readonly
|
|
1196
|
+
[value]="displayValue()"
|
|
1197
|
+
[placeholder]="placeholder()"
|
|
1198
|
+
[disabled]="disabled()"
|
|
1199
|
+
/>
|
|
1200
|
+
<span class="dp-icon">📅</span>
|
|
1201
|
+
</div>
|
|
1202
|
+
|
|
1203
|
+
<!-- Calendar popup -->
|
|
1204
|
+
@if (isOpen()) {
|
|
1205
|
+
<div class="dp-popup" (click)="$event.stopPropagation()">
|
|
1206
|
+
<!-- Month/Year nav -->
|
|
1207
|
+
<div class="dp-nav">
|
|
1208
|
+
<button class="dp-nav-btn" (click)="prevMonth()">‹</button>
|
|
1209
|
+
<span class="dp-nav-title">{{ monthTitle() }}</span>
|
|
1210
|
+
<button class="dp-nav-btn" (click)="nextMonth()">›</button>
|
|
1211
|
+
</div>
|
|
1212
|
+
<!-- Weekday headers -->
|
|
1213
|
+
<div class="dp-weekdays">
|
|
1214
|
+
@for (d of WEEKDAYS; track d) {
|
|
1215
|
+
<span class="dp-wd">{{ d }}</span>
|
|
1216
|
+
}
|
|
1217
|
+
</div>
|
|
1218
|
+
<!-- Days grid -->
|
|
1219
|
+
<div class="dp-days">
|
|
1220
|
+
@for (day of calendarDays(); track day.date?.getTime() ?? $index) {
|
|
1221
|
+
<button
|
|
1222
|
+
class="dp-day"
|
|
1223
|
+
[class.other-month]="!day.current"
|
|
1224
|
+
[class.today]="day.isToday"
|
|
1225
|
+
[class.selected]="day.isSelected"
|
|
1226
|
+
[class.disabled]="day.disabled"
|
|
1227
|
+
[disabled]="day.disabled || !day.date"
|
|
1228
|
+
(click)="selectDay(day.date)"
|
|
1229
|
+
>{{ day.label }}</button>
|
|
1230
|
+
}
|
|
1231
|
+
</div>
|
|
1232
|
+
<!-- Footer -->
|
|
1233
|
+
<div class="dp-footer">
|
|
1234
|
+
<button class="dp-today-btn" (click)="selectToday()">Today</button>
|
|
1235
|
+
<button class="dp-clear-btn" (click)="clearValue()">Clear</button>
|
|
1236
|
+
</div>
|
|
1237
|
+
</div>
|
|
1238
|
+
}
|
|
1239
|
+
</div>
|
|
1240
|
+
`, isInline: true, styles: [":host{display:block}.ngx-date-picker{position:relative;font-family:inherit}.dp-label{display:block;font-size:13px;color:var(--ngx-input-label, #6c757d);margin-bottom:4px;font-weight:500}.dp-input-wrap{display:flex;align-items:center;border:1px solid var(--ngx-input-border, #ced4da);border-radius:var(--ngx-input-radius, 4px);background:var(--ngx-input-bg, #fff);cursor:pointer;transition:border-color .15s,box-shadow .15s}.dp-input-wrap:hover{border-color:#adb5bd}.open .dp-input-wrap{border-color:var(--ngx-input-focus, #4a90d9);box-shadow:0 0 0 2px #4a90d92e}.disabled .dp-input-wrap{background:#f8f9fa;cursor:not-allowed}.dp-input{flex:1;padding:8px 12px;border:none;outline:none;background:transparent;font-size:14px;color:var(--ngx-input-text, #212529);cursor:pointer;font-family:inherit}.dp-icon{padding:0 12px;color:#6c757d}.dp-popup{position:absolute;top:calc(100% + 4px);left:0;z-index:1000;background:var(--ngx-input-bg, #fff);border:1px solid var(--ngx-input-border, #ced4da);border-radius:var(--ngx-input-radius, 4px);box-shadow:0 4px 16px #0000001f;padding:12px;width:260px}.dp-nav{display:flex;align-items:center;justify-content:space-between;margin-bottom:8px}.dp-nav-btn{background:none;border:none;cursor:pointer;font-size:20px;color:#6c757d;padding:2px 8px;border-radius:3px;line-height:1}.dp-nav-btn:hover{background:#f1f3f5}.dp-nav-title{font-size:14px;font-weight:600;color:var(--ngx-input-text, #212529)}.dp-weekdays{display:grid;grid-template-columns:repeat(7,1fr);gap:2px;margin-bottom:4px}.dp-wd{text-align:center;font-size:11px;color:#adb5bd;font-weight:600;padding:4px 0}.dp-days{display:grid;grid-template-columns:repeat(7,1fr);gap:2px}.dp-day{aspect-ratio:1;display:flex;align-items:center;justify-content:center;font-size:13px;border:none;background:none;cursor:pointer;border-radius:50%;color:var(--ngx-input-text, #212529);transition:background .1s}.dp-day:hover:not(.disabled):not(.selected){background:#f1f3f5}.dp-day.other-month{color:#ced4da}.dp-day.today{font-weight:700;color:var(--ngx-input-focus, #4a90d9)}.dp-day.selected{background:var(--ngx-input-focus, #4a90d9);color:#fff}.dp-day.disabled{color:#ced4da;cursor:not-allowed}.dp-footer{display:flex;justify-content:space-between;margin-top:8px;padding-top:8px;border-top:1px solid #f1f3f5}.dp-today-btn,.dp-clear-btn{background:none;border:none;cursor:pointer;font-size:12px;color:var(--ngx-input-focus, #4a90d9);padding:4px 8px;border-radius:3px;font-family:inherit}.dp-today-btn:hover,.dp-clear-btn:hover{background:#f1f3f5}.dp-clear-btn{color:#6c757d}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
1241
|
+
}
|
|
1242
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.20", ngImport: i0, type: DatePickerComponent, decorators: [{
|
|
1243
|
+
type: Component,
|
|
1244
|
+
args: [{ selector: 'ngx-date-picker', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, providers: [
|
|
1245
|
+
{
|
|
1246
|
+
provide: NG_VALUE_ACCESSOR,
|
|
1247
|
+
useExisting: forwardRef(() => DatePickerComponent),
|
|
1248
|
+
multi: true,
|
|
1249
|
+
},
|
|
1250
|
+
], template: `
|
|
1251
|
+
<div class="ngx-date-picker" [class.open]="isOpen()" [class.disabled]="disabled()">
|
|
1252
|
+
@if (label()) {
|
|
1253
|
+
<label class="dp-label">{{ label() }}</label>
|
|
1254
|
+
}
|
|
1255
|
+
<!-- Input trigger -->
|
|
1256
|
+
<div class="dp-input-wrap" (click)="toggle()">
|
|
1257
|
+
<input
|
|
1258
|
+
class="dp-input"
|
|
1259
|
+
readonly
|
|
1260
|
+
[value]="displayValue()"
|
|
1261
|
+
[placeholder]="placeholder()"
|
|
1262
|
+
[disabled]="disabled()"
|
|
1263
|
+
/>
|
|
1264
|
+
<span class="dp-icon">📅</span>
|
|
1265
|
+
</div>
|
|
1266
|
+
|
|
1267
|
+
<!-- Calendar popup -->
|
|
1268
|
+
@if (isOpen()) {
|
|
1269
|
+
<div class="dp-popup" (click)="$event.stopPropagation()">
|
|
1270
|
+
<!-- Month/Year nav -->
|
|
1271
|
+
<div class="dp-nav">
|
|
1272
|
+
<button class="dp-nav-btn" (click)="prevMonth()">‹</button>
|
|
1273
|
+
<span class="dp-nav-title">{{ monthTitle() }}</span>
|
|
1274
|
+
<button class="dp-nav-btn" (click)="nextMonth()">›</button>
|
|
1275
|
+
</div>
|
|
1276
|
+
<!-- Weekday headers -->
|
|
1277
|
+
<div class="dp-weekdays">
|
|
1278
|
+
@for (d of WEEKDAYS; track d) {
|
|
1279
|
+
<span class="dp-wd">{{ d }}</span>
|
|
1280
|
+
}
|
|
1281
|
+
</div>
|
|
1282
|
+
<!-- Days grid -->
|
|
1283
|
+
<div class="dp-days">
|
|
1284
|
+
@for (day of calendarDays(); track day.date?.getTime() ?? $index) {
|
|
1285
|
+
<button
|
|
1286
|
+
class="dp-day"
|
|
1287
|
+
[class.other-month]="!day.current"
|
|
1288
|
+
[class.today]="day.isToday"
|
|
1289
|
+
[class.selected]="day.isSelected"
|
|
1290
|
+
[class.disabled]="day.disabled"
|
|
1291
|
+
[disabled]="day.disabled || !day.date"
|
|
1292
|
+
(click)="selectDay(day.date)"
|
|
1293
|
+
>{{ day.label }}</button>
|
|
1294
|
+
}
|
|
1295
|
+
</div>
|
|
1296
|
+
<!-- Footer -->
|
|
1297
|
+
<div class="dp-footer">
|
|
1298
|
+
<button class="dp-today-btn" (click)="selectToday()">Today</button>
|
|
1299
|
+
<button class="dp-clear-btn" (click)="clearValue()">Clear</button>
|
|
1300
|
+
</div>
|
|
1301
|
+
</div>
|
|
1302
|
+
}
|
|
1303
|
+
</div>
|
|
1304
|
+
`, styles: [":host{display:block}.ngx-date-picker{position:relative;font-family:inherit}.dp-label{display:block;font-size:13px;color:var(--ngx-input-label, #6c757d);margin-bottom:4px;font-weight:500}.dp-input-wrap{display:flex;align-items:center;border:1px solid var(--ngx-input-border, #ced4da);border-radius:var(--ngx-input-radius, 4px);background:var(--ngx-input-bg, #fff);cursor:pointer;transition:border-color .15s,box-shadow .15s}.dp-input-wrap:hover{border-color:#adb5bd}.open .dp-input-wrap{border-color:var(--ngx-input-focus, #4a90d9);box-shadow:0 0 0 2px #4a90d92e}.disabled .dp-input-wrap{background:#f8f9fa;cursor:not-allowed}.dp-input{flex:1;padding:8px 12px;border:none;outline:none;background:transparent;font-size:14px;color:var(--ngx-input-text, #212529);cursor:pointer;font-family:inherit}.dp-icon{padding:0 12px;color:#6c757d}.dp-popup{position:absolute;top:calc(100% + 4px);left:0;z-index:1000;background:var(--ngx-input-bg, #fff);border:1px solid var(--ngx-input-border, #ced4da);border-radius:var(--ngx-input-radius, 4px);box-shadow:0 4px 16px #0000001f;padding:12px;width:260px}.dp-nav{display:flex;align-items:center;justify-content:space-between;margin-bottom:8px}.dp-nav-btn{background:none;border:none;cursor:pointer;font-size:20px;color:#6c757d;padding:2px 8px;border-radius:3px;line-height:1}.dp-nav-btn:hover{background:#f1f3f5}.dp-nav-title{font-size:14px;font-weight:600;color:var(--ngx-input-text, #212529)}.dp-weekdays{display:grid;grid-template-columns:repeat(7,1fr);gap:2px;margin-bottom:4px}.dp-wd{text-align:center;font-size:11px;color:#adb5bd;font-weight:600;padding:4px 0}.dp-days{display:grid;grid-template-columns:repeat(7,1fr);gap:2px}.dp-day{aspect-ratio:1;display:flex;align-items:center;justify-content:center;font-size:13px;border:none;background:none;cursor:pointer;border-radius:50%;color:var(--ngx-input-text, #212529);transition:background .1s}.dp-day:hover:not(.disabled):not(.selected){background:#f1f3f5}.dp-day.other-month{color:#ced4da}.dp-day.today{font-weight:700;color:var(--ngx-input-focus, #4a90d9)}.dp-day.selected{background:var(--ngx-input-focus, #4a90d9);color:#fff}.dp-day.disabled{color:#ced4da;cursor:not-allowed}.dp-footer{display:flex;justify-content:space-between;margin-top:8px;padding-top:8px;border-top:1px solid #f1f3f5}.dp-today-btn,.dp-clear-btn{background:none;border:none;cursor:pointer;font-size:12px;color:var(--ngx-input-focus, #4a90d9);padding:4px 8px;border-radius:3px;font-family:inherit}.dp-today-btn:hover,.dp-clear-btn:hover{background:#f1f3f5}.dp-clear-btn{color:#6c757d}\n"] }]
|
|
1305
|
+
}], propDecorators: { onDocClick: [{
|
|
1306
|
+
type: HostListener,
|
|
1307
|
+
args: ['document:click', ['$event']]
|
|
1308
|
+
}] } });
|
|
1309
|
+
|
|
1310
|
+
/*
|
|
1311
|
+
* Public API Surface — secondary entry point: ngx-core-components/inputs
|
|
1312
|
+
*/
|
|
1313
|
+
// Text input
|
|
1314
|
+
|
|
1315
|
+
/**
|
|
1316
|
+
* Generated bundle index. Do not edit.
|
|
1317
|
+
*/
|
|
1318
|
+
|
|
1319
|
+
export { AutocompleteComponent, CheckboxComponent, DatePickerComponent, DropdownComponent, MultiSelectComponent, RadioGroupComponent, TextBoxComponent };
|
|
1320
|
+
//# sourceMappingURL=ngx-core-components-inputs.mjs.map
|