@sebgroup/green-angular 1.0.0-beta.2 → 1.0.0-beta.20
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/esm2020/index.mjs +6 -5
- package/esm2020/lib/badge/badge.component.mjs +78 -0
- package/esm2020/lib/badge/badge.module.mjs +18 -0
- package/esm2020/lib/datepicker/datepicker.component.mjs +186 -0
- package/esm2020/lib/datepicker/datepicker.module.mjs +19 -0
- package/esm2020/lib/dropdown/dropdown-option.directive.mjs +16 -0
- package/esm2020/lib/dropdown/dropdown.component.mjs +394 -57
- package/esm2020/lib/dropdown/dropdown.module.mjs +8 -31
- package/esm2020/lib/green-angular.module.mjs +7 -6
- package/esm2020/lib/segmented-control/segmented-control.component.mjs +3 -3
- package/esm2020/lib/segmented-control/segmented-control.module.mjs +4 -4
- package/fesm2015/sebgroup-green-angular.mjs +699 -470
- package/fesm2015/sebgroup-green-angular.mjs.map +1 -1
- package/fesm2020/sebgroup-green-angular.mjs +697 -464
- package/fesm2020/sebgroup-green-angular.mjs.map +1 -1
- package/index.d.ts +5 -4
- package/lib/badge/badge.component.d.ts +25 -0
- package/lib/badge/badge.module.d.ts +8 -0
- package/lib/datepicker/datepicker.component.d.ts +49 -0
- package/lib/datepicker/datepicker.module.d.ts +9 -0
- package/lib/dropdown/dropdown-option.directive.d.ts +8 -0
- package/lib/dropdown/dropdown.component.d.ts +44 -13
- package/lib/dropdown/dropdown.module.d.ts +4 -7
- package/lib/green-angular.module.d.ts +2 -1
- package/package.json +10 -11
- package/esm2020/lib/dropdown/popover-element.directive.mjs +0 -218
- package/esm2020/lib/dropdown/popover-option.directive.mjs +0 -58
- package/esm2020/lib/dropdown/popover-trigger.directive.mjs +0 -80
- package/esm2020/lib/dropdown/popover.directive.mjs +0 -46
- package/lib/dropdown/popover-element.directive.d.ts +0 -36
- package/lib/dropdown/popover-option.directive.d.ts +0 -20
- package/lib/dropdown/popover-trigger.directive.d.ts +0 -19
- package/lib/dropdown/popover.directive.d.ts +0 -24
|
@@ -1,19 +1,17 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { Component, ChangeDetectionStrategy, Input, NgModule, Directive,
|
|
2
|
+
import { Component, ChangeDetectionStrategy, Input, NgModule, Directive, EventEmitter, Output, ViewChild, ContentChild, HostBinding } from '@angular/core';
|
|
3
3
|
import * as i1 from '@angular/common';
|
|
4
4
|
import { CommonModule } from '@angular/common';
|
|
5
5
|
import * as i2 from '@angular/router';
|
|
6
6
|
import { RouterModule } from '@angular/router';
|
|
7
7
|
import { NG_VALUE_ACCESSOR } from '@angular/forms';
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import { createPopper } from '@popperjs/core';
|
|
11
|
-
import { enableBodyScroll, disableBodyScroll } from 'body-scroll-lock';
|
|
8
|
+
import { dropdownValues, createDropdown, randomId, months, years, createDatepicker } from '@sebgroup/extract';
|
|
9
|
+
import { startOfDay, endOfDay } from 'date-fns';
|
|
12
10
|
|
|
13
11
|
class NggSegmentedControlComponent {
|
|
14
12
|
}
|
|
15
|
-
NggSegmentedControlComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.
|
|
16
|
-
NggSegmentedControlComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.
|
|
13
|
+
NggSegmentedControlComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.3", ngImport: i0, type: NggSegmentedControlComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
14
|
+
NggSegmentedControlComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.3", type: NggSegmentedControlComponent, selector: "ngg-segmented-control", inputs: { $controls: "$controls" }, ngImport: i0, template: `
|
|
17
15
|
<div class="group">
|
|
18
16
|
<a
|
|
19
17
|
*ngFor="let control of $controls | async"
|
|
@@ -24,7 +22,7 @@ NggSegmentedControlComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12
|
|
|
24
22
|
>
|
|
25
23
|
</div>
|
|
26
24
|
`, isInline: true, directives: [{ type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i2.RouterLinkWithHref, selector: "a[routerLink],area[routerLink]", inputs: ["target", "queryParams", "fragment", "queryParamsHandling", "preserveFragment", "skipLocationChange", "replaceUrl", "state", "relativeTo", "routerLink"] }, { type: i2.RouterLinkActive, selector: "[routerLinkActive]", inputs: ["routerLinkActiveOptions", "routerLinkActive"], outputs: ["isActiveChange"], exportAs: ["routerLinkActive"] }], pipes: { "async": i1.AsyncPipe }, changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
27
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.
|
|
25
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.3", ngImport: i0, type: NggSegmentedControlComponent, decorators: [{
|
|
28
26
|
type: Component,
|
|
29
27
|
args: [{
|
|
30
28
|
selector: 'ngg-segmented-control',
|
|
@@ -48,10 +46,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.2", ngImpor
|
|
|
48
46
|
|
|
49
47
|
class NggSegmentedControlModule {
|
|
50
48
|
}
|
|
51
|
-
NggSegmentedControlModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.
|
|
52
|
-
NggSegmentedControlModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.
|
|
53
|
-
NggSegmentedControlModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.
|
|
54
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.
|
|
49
|
+
NggSegmentedControlModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.3", ngImport: i0, type: NggSegmentedControlModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
50
|
+
NggSegmentedControlModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.3.3", ngImport: i0, type: NggSegmentedControlModule, declarations: [NggSegmentedControlComponent], imports: [RouterModule, CommonModule], exports: [NggSegmentedControlComponent] });
|
|
51
|
+
NggSegmentedControlModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.3.3", ngImport: i0, type: NggSegmentedControlModule, imports: [[RouterModule, CommonModule]] });
|
|
52
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.3", ngImport: i0, type: NggSegmentedControlModule, decorators: [{
|
|
55
53
|
type: NgModule,
|
|
56
54
|
args: [{
|
|
57
55
|
declarations: [NggSegmentedControlComponent],
|
|
@@ -60,405 +58,98 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.2", ngImpor
|
|
|
60
58
|
}]
|
|
61
59
|
}] });
|
|
62
60
|
|
|
63
|
-
class
|
|
64
|
-
constructor() {
|
|
65
|
-
this.
|
|
66
|
-
usePopper: true,
|
|
67
|
-
container: '',
|
|
68
|
-
useBodyScrollLock: true,
|
|
69
|
-
};
|
|
70
|
-
this.state = {
|
|
71
|
-
$isOpen: new BehaviorSubject(false),
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
get config() {
|
|
75
|
-
return this._config;
|
|
76
|
-
}
|
|
77
|
-
set config(config) {
|
|
78
|
-
this._config = { ...this.config, ...config };
|
|
79
|
-
}
|
|
80
|
-
close() {
|
|
81
|
-
this.state.$isOpen.next(false);
|
|
82
|
-
}
|
|
83
|
-
open() {
|
|
84
|
-
this.state.$isOpen.next(true);
|
|
85
|
-
}
|
|
86
|
-
toggle() {
|
|
87
|
-
if (this.state.$isOpen.value) {
|
|
88
|
-
this.close();
|
|
89
|
-
}
|
|
90
|
-
else {
|
|
91
|
-
this.open();
|
|
92
|
-
}
|
|
61
|
+
class NggDropdownOptionDirective {
|
|
62
|
+
constructor(templateRef) {
|
|
63
|
+
this.templateRef = templateRef;
|
|
93
64
|
}
|
|
94
65
|
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.
|
|
66
|
+
NggDropdownOptionDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.3", ngImport: i0, type: NggDropdownOptionDirective, deps: [{ token: i0.TemplateRef }], target: i0.ɵɵFactoryTarget.Directive });
|
|
67
|
+
NggDropdownOptionDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.3.3", type: NggDropdownOptionDirective, selector: "[nggDropdownOption]", ngImport: i0 });
|
|
68
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.3", ngImport: i0, type: NggDropdownOptionDirective, decorators: [{
|
|
98
69
|
type: Directive,
|
|
99
70
|
args: [{
|
|
100
|
-
selector: '[
|
|
71
|
+
selector: '[nggDropdownOption]',
|
|
101
72
|
}]
|
|
102
|
-
}],
|
|
103
|
-
type: Input
|
|
104
|
-
}] } });
|
|
73
|
+
}], ctorParameters: function () { return [{ type: i0.TemplateRef }]; } });
|
|
105
74
|
|
|
106
|
-
class
|
|
107
|
-
constructor(
|
|
108
|
-
this.
|
|
109
|
-
this.
|
|
110
|
-
this
|
|
111
|
-
this.
|
|
112
|
-
this.
|
|
113
|
-
this.
|
|
114
|
-
this.
|
|
115
|
-
this.
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
return;
|
|
120
|
-
}
|
|
121
|
-
else {
|
|
122
|
-
// prevent container from scrolling
|
|
123
|
-
event.preventDefault();
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
event.stopPropagation();
|
|
127
|
-
this.popover.toggle();
|
|
128
|
-
};
|
|
129
|
-
}
|
|
130
|
-
ngOnInit() {
|
|
131
|
-
// if trigger element does not have an id...
|
|
132
|
-
if (!this._elRef.nativeElement.id) {
|
|
133
|
-
// ...add a unique id
|
|
134
|
-
this._elRef.nativeElement.id = `ngg_dropdownTrigger_${new Date().getTime()}`;
|
|
135
|
-
this.owns = this._elRef.nativeElement.id.replace(/dropdownTrigger/, 'popover');
|
|
136
|
-
}
|
|
137
|
-
else {
|
|
138
|
-
this.owns = this._elRef.nativeElement.id + '_popover';
|
|
139
|
-
}
|
|
140
|
-
this.popover.triggerElement = this._elRef;
|
|
141
|
-
this.popover.state.$isOpen
|
|
142
|
-
.pipe(tap((isOpen) => (this.expanded = isOpen)), takeUntil(this.$unsubscribe))
|
|
143
|
-
.subscribe();
|
|
144
|
-
}
|
|
145
|
-
ngOnDestroy() {
|
|
146
|
-
this.$unsubscribe.next();
|
|
147
|
-
this.$unsubscribe.complete();
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
NggPopoverTriggerDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: NggPopoverTriggerDirective, deps: [{ token: forwardRef(() => NggPopoverDirective) }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive });
|
|
151
|
-
NggPopoverTriggerDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.0.2", type: NggPopoverTriggerDirective, selector: "[nggPopoverTrigger]", host: { listeners: { "keydown.arrowdown": "toggle($event)", "click": "toggle($event)" }, properties: { "class": "this.class", "attr.aria-haspopup": "this.haspopup", "attr.aria-owns": "this.owns", "attr.aria-expanded": "this.expanded" } }, ngImport: i0 });
|
|
152
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: NggPopoverTriggerDirective, decorators: [{
|
|
153
|
-
type: Directive,
|
|
154
|
-
args: [{
|
|
155
|
-
selector: '[nggPopoverTrigger]',
|
|
156
|
-
}]
|
|
157
|
-
}], ctorParameters: function () { return [{ type: NggPopoverDirective, decorators: [{
|
|
158
|
-
type: Inject,
|
|
159
|
-
args: [forwardRef(() => NggPopoverDirective)]
|
|
160
|
-
}] }, { type: i0.ElementRef }]; }, propDecorators: { class: [{
|
|
161
|
-
type: HostBinding,
|
|
162
|
-
args: ['class']
|
|
163
|
-
}], haspopup: [{
|
|
164
|
-
type: HostBinding,
|
|
165
|
-
args: ['attr.aria-haspopup']
|
|
166
|
-
}], owns: [{
|
|
167
|
-
type: HostBinding,
|
|
168
|
-
args: ['attr.aria-owns']
|
|
169
|
-
}], expanded: [{
|
|
170
|
-
type: HostBinding,
|
|
171
|
-
args: ['attr.aria-expanded']
|
|
172
|
-
}], toggle: [{
|
|
173
|
-
type: HostListener,
|
|
174
|
-
args: ['keydown.arrowdown', ['$event']]
|
|
175
|
-
}, {
|
|
176
|
-
type: HostListener,
|
|
177
|
-
args: ['click', ['$event']]
|
|
178
|
-
}] } });
|
|
179
|
-
|
|
180
|
-
class NggPopoverOptionDirective {
|
|
181
|
-
constructor(popover, elRef) {
|
|
182
|
-
this.popover = popover;
|
|
183
|
-
this.elRef = elRef;
|
|
184
|
-
this.selected = false;
|
|
185
|
-
this.selectedChanged = new EventEmitter();
|
|
186
|
-
this.role = 'option';
|
|
187
|
-
this.id = '';
|
|
188
|
-
this.clickHandler = (event) => {
|
|
189
|
-
this.select(event);
|
|
190
|
-
};
|
|
191
|
-
this.select = (event) => {
|
|
192
|
-
this.selectedChanged.emit(this.nggPopoverOption);
|
|
75
|
+
class NggDropdownComponent {
|
|
76
|
+
constructor(cd) {
|
|
77
|
+
this.cd = cd;
|
|
78
|
+
this.loop = false;
|
|
79
|
+
this._multiSelect = false;
|
|
80
|
+
this.options = [];
|
|
81
|
+
this.valueChange = new EventEmitter();
|
|
82
|
+
this.touched = new EventEmitter();
|
|
83
|
+
this.toggler = dropdownValues.elements?.toggler;
|
|
84
|
+
this.listbox = dropdownValues.elements?.listbox;
|
|
85
|
+
this.fieldset = dropdownValues.elements?.fieldset;
|
|
86
|
+
this.trackByKey = (index, option) => {
|
|
87
|
+
return option[''] || option.key;
|
|
193
88
|
};
|
|
194
89
|
}
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
args: ['attr.id']
|
|
229
|
-
}], clickHandler: [{
|
|
230
|
-
type: HostListener,
|
|
231
|
-
args: ['click']
|
|
232
|
-
}] } });
|
|
233
|
-
|
|
234
|
-
class NggPopoverElementDirective {
|
|
235
|
-
constructor(popover, _elRef, _renderer, _cdr) {
|
|
236
|
-
this.popover = popover;
|
|
237
|
-
this._elRef = _elRef;
|
|
238
|
-
this._renderer = _renderer;
|
|
239
|
-
this._cdr = _cdr;
|
|
240
|
-
this.$unsubscribe = new Subject();
|
|
241
|
-
this.sm = window.innerWidth <= 576;
|
|
242
|
-
this.class = true;
|
|
243
|
-
this.role = 'listbox';
|
|
244
|
-
this.id = null;
|
|
245
|
-
this.show = this.popover.state.$isOpen.value;
|
|
246
|
-
this.activeDescendant = null;
|
|
247
|
-
}
|
|
248
|
-
// TODO: refactor and move to general size/device service
|
|
249
|
-
onResize(event) {
|
|
250
|
-
// determine if small screen size i.e less than or equal to 576 pixels which is the breakpoint for small screens
|
|
251
|
-
this.sm = event.target.innerWidth <= 576;
|
|
252
|
-
if (this.sm) {
|
|
253
|
-
// remove popper
|
|
254
|
-
this.removePopper();
|
|
255
|
-
}
|
|
256
|
-
else if (!this._popper) {
|
|
257
|
-
// add popper
|
|
258
|
-
this.addPopper();
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
handleClickEvent(event) {
|
|
262
|
-
// if click inside popover element...
|
|
263
|
-
if (this._elRef.nativeElement.contains(event.target)) {
|
|
264
|
-
this.popover.close();
|
|
265
|
-
}
|
|
266
|
-
else if (this.popover.state.$isOpen.value) {
|
|
267
|
-
// else if click outside popover element...
|
|
268
|
-
this.popover.close();
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
handleKeydownEvent(event) {
|
|
272
|
-
if (event.key === 'Escape') {
|
|
273
|
-
this.popover.close();
|
|
274
|
-
return;
|
|
275
|
-
}
|
|
276
|
-
let next = 0; // Used for home key
|
|
277
|
-
const currentSelection = this.options?.find((option) => !!option.selected)?.index || 0;
|
|
278
|
-
if (event.key === 'End') {
|
|
279
|
-
// set next to last option
|
|
280
|
-
next = (this.options?.length || 1) - 1;
|
|
281
|
-
}
|
|
282
|
-
else if (event.key === 'ArrowUp') {
|
|
283
|
-
// next can't be less than zero
|
|
284
|
-
next = Math.max(0, currentSelection - 1);
|
|
285
|
-
// prevent container from scrolling
|
|
286
|
-
event.preventDefault();
|
|
287
|
-
}
|
|
288
|
-
else if (event.key === 'ArrowDown') {
|
|
289
|
-
// next can't be greater than number of options
|
|
290
|
-
next = Math.min((this.options?.length || 1) - 1, currentSelection + 1);
|
|
291
|
-
// prevent container from scrolling
|
|
292
|
-
event.preventDefault();
|
|
293
|
-
}
|
|
294
|
-
// select next option
|
|
295
|
-
this.options?.get(next)?.select(event);
|
|
296
|
-
}
|
|
297
|
-
ngOnInit() {
|
|
298
|
-
this.id = /^ngg_dropdownTrigger/.test(this.popover.triggerElement?.nativeElement.id)
|
|
299
|
-
? this.popover.triggerElement?.nativeElement.id.replace(/dropdownTrigger/, 'popover')
|
|
300
|
-
: this.popover.triggerElement?.nativeElement.id + '_popover';
|
|
301
|
-
this.popover.state.$isOpen
|
|
302
|
-
.pipe(skip(1), // skip initial value
|
|
303
|
-
tap((isOpen) => {
|
|
304
|
-
this.show = isOpen; // toggle visibility
|
|
305
|
-
if (isOpen) {
|
|
306
|
-
this.activeDescendant =
|
|
307
|
-
this.options?.find((option) => !!option.selected)?.id || null;
|
|
308
|
-
// if use body scroll lock
|
|
309
|
-
if (this.popover.config.useBodyScrollLock) {
|
|
310
|
-
this.disableBodyScrollLock();
|
|
311
|
-
}
|
|
312
|
-
// if popover is configured to use a container...
|
|
313
|
-
if (this.popover.config.container !== '') {
|
|
314
|
-
// ...add container
|
|
315
|
-
this.addContainer();
|
|
90
|
+
set multiSelect(value) {
|
|
91
|
+
this._multiSelect =
|
|
92
|
+
value === '' || value === 'true' || value.toString() === 'true' || false;
|
|
93
|
+
}
|
|
94
|
+
get multiSelect() {
|
|
95
|
+
return this._multiSelect;
|
|
96
|
+
}
|
|
97
|
+
get value() {
|
|
98
|
+
return this._value;
|
|
99
|
+
}
|
|
100
|
+
set value(newValue) {
|
|
101
|
+
this.setSelectionByValue(newValue);
|
|
102
|
+
}
|
|
103
|
+
ngAfterViewInit() {
|
|
104
|
+
if (this.togglerRef?.nativeElement && this.listboxRef?.nativeElement) {
|
|
105
|
+
this.handler = createDropdown(this.props, this.togglerRef.nativeElement, this.listboxRef.nativeElement, this.fieldsetRef?.nativeElement, (dropdown) => {
|
|
106
|
+
this.dropdown = dropdown;
|
|
107
|
+
this.toggler = dropdown.elements.toggler;
|
|
108
|
+
this.listbox = dropdown.elements.listbox;
|
|
109
|
+
this.fieldset = dropdown.elements.fieldset;
|
|
110
|
+
// TODO: refactor state handling to only emit value changes when value changes (not on state change), perhaps using rxjs?
|
|
111
|
+
if (!dropdown.isMultiSelect) {
|
|
112
|
+
let selectedOption = this.dropdown.options?.find((option) => option.selected);
|
|
113
|
+
if ((selectedOption && !this._value) ||
|
|
114
|
+
(selectedOption &&
|
|
115
|
+
selectedOption[dropdown.useValue] !==
|
|
116
|
+
this._value[dropdown.useValue])) {
|
|
117
|
+
const { attributes, classes, active, selected, ...data } = selectedOption;
|
|
118
|
+
selectedOption = dropdown.selectValue
|
|
119
|
+
? data[dropdown.selectValue]
|
|
120
|
+
: data;
|
|
121
|
+
this.updateValue(selectedOption);
|
|
122
|
+
}
|
|
316
123
|
}
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
124
|
+
else {
|
|
125
|
+
const selectedOption = this.dropdown.options
|
|
126
|
+
?.filter((option) => option.selected)
|
|
127
|
+
.map((option) => {
|
|
128
|
+
const { attributes, classes, active, selected, ...data } = option;
|
|
129
|
+
return dropdown.selectValue ? data[dropdown.selectValue] : data;
|
|
130
|
+
});
|
|
131
|
+
if ((this._value !== undefined || selectedOption?.length > 0) &&
|
|
132
|
+
this._value !== [] &&
|
|
133
|
+
selectedOption &&
|
|
134
|
+
JSON.stringify(this._value) !== JSON.stringify(selectedOption)) {
|
|
135
|
+
this.updateValue(selectedOption);
|
|
136
|
+
}
|
|
326
137
|
}
|
|
327
|
-
this.
|
|
328
|
-
this.removePopper();
|
|
329
|
-
}
|
|
330
|
-
}), switchMap((isOpen) => isOpen
|
|
331
|
-
? merge(
|
|
332
|
-
// listen to click events
|
|
333
|
-
fromEvent(document, 'click').pipe(tap((event) => this.handleClickEvent(event))),
|
|
334
|
-
// listen to keydown events
|
|
335
|
-
fromEvent(document, 'keydown').pipe(
|
|
336
|
-
// filter keys
|
|
337
|
-
filter((event) => ['ArrowDown', 'ArrowUp', 'Escape', 'Home', 'End'].indexOf(event.key) !== -1), tap((event) => this.handleKeydownEvent(event))))
|
|
338
|
-
: EMPTY), takeUntil(this.$unsubscribe))
|
|
339
|
-
.subscribe();
|
|
340
|
-
}
|
|
341
|
-
ngOnDestroy() {
|
|
342
|
-
this.removePopper();
|
|
343
|
-
// enable scroll if body scroll lock is used
|
|
344
|
-
if (this.popover.config.useBodyScrollLock) {
|
|
345
|
-
this.enableBodyScrollLock();
|
|
346
|
-
}
|
|
347
|
-
// remove container if declared
|
|
348
|
-
if (this._container) {
|
|
349
|
-
this.removeContainer();
|
|
350
|
-
}
|
|
351
|
-
this.$unsubscribe.next();
|
|
352
|
-
this.$unsubscribe.complete();
|
|
353
|
-
}
|
|
354
|
-
enableBodyScrollLock() {
|
|
355
|
-
enableBodyScroll(this._elRef.nativeElement);
|
|
356
|
-
}
|
|
357
|
-
disableBodyScrollLock() {
|
|
358
|
-
disableBodyScroll(this._elRef.nativeElement);
|
|
359
|
-
}
|
|
360
|
-
addPopper() {
|
|
361
|
-
if (this.sm) {
|
|
362
|
-
return;
|
|
363
|
-
}
|
|
364
|
-
if (!this._popper) {
|
|
365
|
-
// ...create popper instance for anchoring popover with trigger element
|
|
366
|
-
this._popper = createPopper(this.popover.triggerElement?.nativeElement, this._elRef.nativeElement, {
|
|
367
|
-
placement: 'bottom-start',
|
|
368
|
-
modifiers: [
|
|
369
|
-
{
|
|
370
|
-
name: 'offset',
|
|
371
|
-
options: {
|
|
372
|
-
offset: [0, 4],
|
|
373
|
-
},
|
|
374
|
-
},
|
|
375
|
-
],
|
|
138
|
+
this.cd.detectChanges();
|
|
376
139
|
});
|
|
377
|
-
// detect changes once element and popper is initiated to update initial position
|
|
378
|
-
this._cdr.detectChanges();
|
|
379
|
-
}
|
|
380
|
-
else {
|
|
381
|
-
this._popper.state.elements.reference =
|
|
382
|
-
this.popover.triggerElement?.nativeElement;
|
|
383
|
-
this._popper.update().then((_) => this._cdr.detectChanges());
|
|
384
140
|
}
|
|
385
141
|
}
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
if (this._popper) {
|
|
389
|
-
this._popper?.destroy();
|
|
390
|
-
this._popper = null;
|
|
391
|
-
}
|
|
142
|
+
ngOnDestroy() {
|
|
143
|
+
this.handler?.destroy();
|
|
392
144
|
}
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
this.
|
|
397
|
-
}
|
|
398
|
-
this._renderer.appendChild(this._container, this._elRef.nativeElement);
|
|
399
|
-
this._renderer.appendChild(document.body, this._container);
|
|
400
|
-
}
|
|
401
|
-
removeContainer() {
|
|
402
|
-
if (this._container) {
|
|
403
|
-
// remove container from DOM tree
|
|
404
|
-
this._renderer.removeChild(document.body, this._container);
|
|
405
|
-
// clear container
|
|
406
|
-
this._container = null;
|
|
145
|
+
ngOnChanges(changes) {
|
|
146
|
+
if (this.handler &&
|
|
147
|
+
(changes.id || changes.text || changes.loop || changes.options)) {
|
|
148
|
+
this.handler.update(this.props);
|
|
407
149
|
}
|
|
408
150
|
}
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
NggPopoverElementDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.0.2", type: NggPopoverElementDirective, selector: "[nggPopoverElement]", host: { listeners: { "window:resize": "onResize($event)" }, properties: { "class.popover": "this.class", "attr.role": "this.role", "attr.id": "this.id", "class.active": "this.show", "attr.aria-activedescendant": "this.activeDescendant" } }, queries: [{ propertyName: "options", predicate: NggPopoverOptionDirective, descendants: true }], ngImport: i0 });
|
|
412
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: NggPopoverElementDirective, decorators: [{
|
|
413
|
-
type: Directive,
|
|
414
|
-
args: [{
|
|
415
|
-
selector: '[nggPopoverElement]',
|
|
416
|
-
}]
|
|
417
|
-
}], ctorParameters: function () { return [{ type: NggPopoverDirective, decorators: [{
|
|
418
|
-
type: Inject,
|
|
419
|
-
args: [forwardRef(() => NggPopoverDirective)]
|
|
420
|
-
}] }, { type: i0.ElementRef }, { type: i0.Renderer2 }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { options: [{
|
|
421
|
-
type: ContentChildren,
|
|
422
|
-
args: [NggPopoverOptionDirective, { descendants: true }]
|
|
423
|
-
}], class: [{
|
|
424
|
-
type: HostBinding,
|
|
425
|
-
args: ['class.popover']
|
|
426
|
-
}], role: [{
|
|
427
|
-
type: HostBinding,
|
|
428
|
-
args: ['attr.role']
|
|
429
|
-
}], id: [{
|
|
430
|
-
type: HostBinding,
|
|
431
|
-
args: ['attr.id']
|
|
432
|
-
}], show: [{
|
|
433
|
-
type: HostBinding,
|
|
434
|
-
args: ['class.active']
|
|
435
|
-
}], activeDescendant: [{
|
|
436
|
-
type: HostBinding,
|
|
437
|
-
args: ['attr.aria-activedescendant']
|
|
438
|
-
}], onResize: [{
|
|
439
|
-
type: HostListener,
|
|
440
|
-
args: ['window:resize', ['$event']]
|
|
441
|
-
}] } });
|
|
442
|
-
|
|
443
|
-
class NggDropdownComponent {
|
|
444
|
-
constructor() {
|
|
445
|
-
this._options = [];
|
|
446
|
-
this._config = {};
|
|
447
|
-
}
|
|
448
|
-
get options() {
|
|
449
|
-
return this._options;
|
|
450
|
-
}
|
|
451
|
-
set options(value) {
|
|
452
|
-
this._options = value;
|
|
453
|
-
}
|
|
454
|
-
get config() {
|
|
455
|
-
return this._config;
|
|
456
|
-
}
|
|
457
|
-
set config(value) {
|
|
458
|
-
this._config = value;
|
|
459
|
-
}
|
|
460
|
-
writeValue(obj) {
|
|
461
|
-
this.value = obj;
|
|
151
|
+
writeValue(value) {
|
|
152
|
+
this.value = value;
|
|
462
153
|
}
|
|
463
154
|
registerOnChange(fn) {
|
|
464
155
|
this.onChangeFn = fn;
|
|
@@ -466,67 +157,311 @@ class NggDropdownComponent {
|
|
|
466
157
|
registerOnTouched(fn) {
|
|
467
158
|
this.onTouchedFn = fn;
|
|
468
159
|
}
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
160
|
+
get props() {
|
|
161
|
+
return {
|
|
162
|
+
id: this.id || this.dropdown?.id,
|
|
163
|
+
texts: this.texts,
|
|
164
|
+
useValue: this.useValue,
|
|
165
|
+
display: this.display,
|
|
166
|
+
selectValue: this.selectValue,
|
|
167
|
+
options: this.options,
|
|
168
|
+
loop: this.loop,
|
|
169
|
+
value: this.value,
|
|
170
|
+
multiSelect: this.multiSelect,
|
|
171
|
+
onTouched: () => {
|
|
172
|
+
this.onTouchedFn?.();
|
|
173
|
+
this.touched.emit(true);
|
|
174
|
+
this.cd.markForCheck();
|
|
175
|
+
},
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
updateValue(option) {
|
|
179
|
+
this._value = option;
|
|
180
|
+
this.valueChange.emit(option);
|
|
181
|
+
this.onChangeFn?.(option);
|
|
182
|
+
}
|
|
183
|
+
setSelectionByValue(value) {
|
|
184
|
+
if (!this.dropdown?.isMultiSelect) {
|
|
185
|
+
if (this._value !== value && value !== undefined) {
|
|
186
|
+
this._value = value;
|
|
187
|
+
const valueKey = this.handler?.dropdown.useValue;
|
|
188
|
+
const selected = this.handler?.dropdown?.options.find((option) => option[valueKey] === value[valueKey] || option[valueKey] === value);
|
|
189
|
+
if (selected)
|
|
190
|
+
this.handler?.select(selected);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
472
193
|
}
|
|
473
194
|
}
|
|
474
|
-
NggDropdownComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.
|
|
475
|
-
NggDropdownComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.
|
|
195
|
+
NggDropdownComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.3", ngImport: i0, type: NggDropdownComponent, deps: [{ token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
|
|
196
|
+
NggDropdownComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.3", type: NggDropdownComponent, selector: "ngg-dropdown", inputs: { id: "id", texts: "texts", loop: "loop", display: "display", selectValue: "selectValue", useValue: "useValue", multiSelect: "multiSelect", label: "label", options: "options", valid: "valid", invalid: "invalid", value: "value" }, outputs: { valueChange: "valueChange", touched: "touched" }, providers: [
|
|
476
197
|
{
|
|
477
198
|
provide: NG_VALUE_ACCESSOR,
|
|
478
199
|
useExisting: NggDropdownComponent,
|
|
479
200
|
multi: true,
|
|
480
201
|
},
|
|
481
|
-
], ngImport: i0, template: `
|
|
482
|
-
<div
|
|
483
|
-
<
|
|
484
|
-
|
|
202
|
+
], queries: [{ propertyName: "customOption", first: true, predicate: NggDropdownOptionDirective, descendants: true }], viewQueries: [{ propertyName: "togglerRef", first: true, predicate: ["togglerRef"], descendants: true }, { propertyName: "listboxRef", first: true, predicate: ["listboxRef"], descendants: true }, { propertyName: "fieldsetRef", first: true, predicate: ["fieldsetRef"], descendants: true }], usesOnChanges: true, ngImport: i0, template: `
|
|
203
|
+
<div>
|
|
204
|
+
<span
|
|
205
|
+
class="label"
|
|
206
|
+
*ngIf="label"
|
|
207
|
+
[id]="toggler?.attributes?.id + '_label'"
|
|
208
|
+
>{{ label }}</span
|
|
209
|
+
>
|
|
210
|
+
<button
|
|
211
|
+
[attr.aria-labelledby]="
|
|
212
|
+
label ? toggler?.attributes?.id + '_label' : null
|
|
213
|
+
"
|
|
214
|
+
[attr.aria-describedby]="
|
|
215
|
+
formInfo?.textContent && (formInfo?.textContent?.length ?? 0 > 0)
|
|
216
|
+
? toggler?.attributes?.id + '_info'
|
|
217
|
+
: null
|
|
218
|
+
"
|
|
219
|
+
type="button"
|
|
220
|
+
#togglerRef
|
|
221
|
+
[id]="toggler?.attributes?.id"
|
|
222
|
+
[attr.aria-haspopup]="toggler?.attributes?.['aria-haspopup']"
|
|
223
|
+
[attr.aria-expanded]="toggler?.attributes?.['aria-expanded']"
|
|
224
|
+
[attr.aria-owns]="toggler?.attributes?.['aria-owns']"
|
|
225
|
+
[tabindex]="toggler?.attributes?.tabIndex"
|
|
226
|
+
[style]="toggler?.attributes?.style"
|
|
227
|
+
[class]="toggler?.classes"
|
|
228
|
+
(click)="handler?.toggle()"
|
|
229
|
+
[class.is-valid]="valid"
|
|
230
|
+
[class.is-invalid]="invalid"
|
|
231
|
+
>
|
|
232
|
+
<span>{{
|
|
233
|
+
dropdown?.texts?.select || dropdown?.texts?.placeholder
|
|
234
|
+
}}</span>
|
|
485
235
|
</button>
|
|
486
|
-
<
|
|
487
|
-
|
|
488
|
-
|
|
236
|
+
<span
|
|
237
|
+
class="form-info"
|
|
238
|
+
#formInfo
|
|
239
|
+
[attr.id]="toggler?.attributes?.id + '_info'"
|
|
240
|
+
><ng-content select="[data-form-info]"></ng-content
|
|
241
|
+
></span>
|
|
242
|
+
<div
|
|
243
|
+
#listboxRef
|
|
244
|
+
[id]="listbox?.attributes?.id"
|
|
245
|
+
[attr.role]="listbox?.attributes?.role"
|
|
246
|
+
[attr.aria-activedescendant]="
|
|
247
|
+
listbox?.attributes?.['aria-activedescendant']
|
|
248
|
+
"
|
|
249
|
+
[tabindex]="listbox?.attributes?.tabIndex"
|
|
250
|
+
[style]="listbox?.attributes?.style"
|
|
251
|
+
[class]="listbox?.classes"
|
|
252
|
+
>
|
|
253
|
+
<button
|
|
254
|
+
type="button"
|
|
255
|
+
class="close m-4 m-sm-2 d-block d-sm-none"
|
|
256
|
+
(click)="handler?.close()"
|
|
257
|
+
>
|
|
258
|
+
<span class="sr-only">{{ dropdown?.texts?.close }}</span>
|
|
489
259
|
</button>
|
|
490
|
-
<ul role="listbox">
|
|
260
|
+
<ul role="listbox" *ngIf="!dropdown?.isMultiSelect">
|
|
491
261
|
<li
|
|
492
|
-
*ngFor="
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
262
|
+
*ngFor="
|
|
263
|
+
let option of dropdown?.options;
|
|
264
|
+
let index = index;
|
|
265
|
+
trackBy: trackByKey
|
|
266
|
+
"
|
|
267
|
+
[id]="option.attributes.id"
|
|
268
|
+
[attr.role]="option.attributes.role"
|
|
269
|
+
[attr.aria-selected]="option.attributes['aria-selected']"
|
|
270
|
+
[style]="option.attributes.style"
|
|
271
|
+
[class]="option.classes"
|
|
272
|
+
(click)="handler?.select(option)"
|
|
497
273
|
>
|
|
498
|
-
|
|
274
|
+
<ng-container
|
|
275
|
+
*ngTemplateOutlet="
|
|
276
|
+
customOption?.templateRef
|
|
277
|
+
? customOption!.templateRef
|
|
278
|
+
: defaultOption;
|
|
279
|
+
context: { option: option, index: index }
|
|
280
|
+
"
|
|
281
|
+
></ng-container>
|
|
499
282
|
</li>
|
|
500
283
|
</ul>
|
|
284
|
+
<div *ngIf="dropdown?.isMultiSelect" class="sg-fieldset-container">
|
|
285
|
+
<fieldset
|
|
286
|
+
#fieldsetRef
|
|
287
|
+
[attr.aria-describedby]="fieldset?.attributes?.id"
|
|
288
|
+
role="listbox"
|
|
289
|
+
tabIndex="-1"
|
|
290
|
+
aria-multiselectable="true"
|
|
291
|
+
>
|
|
292
|
+
<legend class="sr-only" [id]="fieldset?.attributes?.id">
|
|
293
|
+
Options
|
|
294
|
+
</legend>
|
|
295
|
+
<label
|
|
296
|
+
class="form-control"
|
|
297
|
+
[attr.role]="option.attributes.role"
|
|
298
|
+
[id]="option.attributes.id"
|
|
299
|
+
[attr.aria-selected]="option.attributes['aria-selected']"
|
|
300
|
+
[class]="option.classes"
|
|
301
|
+
*ngFor="
|
|
302
|
+
let option of dropdown?.options;
|
|
303
|
+
let index = index;
|
|
304
|
+
trackBy: trackByKey
|
|
305
|
+
"
|
|
306
|
+
>
|
|
307
|
+
<input
|
|
308
|
+
type="checkbox"
|
|
309
|
+
(change)="handler?.select(option, false)"
|
|
310
|
+
[checked]="option.selected"
|
|
311
|
+
tabIndex="-1"
|
|
312
|
+
/>
|
|
313
|
+
<ng-container
|
|
314
|
+
*ngTemplateOutlet="
|
|
315
|
+
customOption?.templateRef
|
|
316
|
+
? customOption!.templateRef
|
|
317
|
+
: defaultOption;
|
|
318
|
+
context: { option: option, index: index }
|
|
319
|
+
"
|
|
320
|
+
></ng-container>
|
|
321
|
+
<i></i>
|
|
322
|
+
</label>
|
|
323
|
+
</fieldset>
|
|
324
|
+
</div>
|
|
501
325
|
</div>
|
|
502
326
|
</div>
|
|
503
|
-
|
|
504
|
-
|
|
327
|
+
|
|
328
|
+
<ng-template #defaultOption let-option="option">
|
|
329
|
+
{{ option[dropdown!.display] }}
|
|
330
|
+
</ng-template>
|
|
331
|
+
`, isInline: true, directives: [{ type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
332
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.3", ngImport: i0, type: NggDropdownComponent, decorators: [{
|
|
505
333
|
type: Component,
|
|
506
334
|
args: [{
|
|
507
335
|
selector: 'ngg-dropdown',
|
|
508
336
|
template: `
|
|
509
|
-
<div
|
|
510
|
-
<
|
|
511
|
-
|
|
337
|
+
<div>
|
|
338
|
+
<span
|
|
339
|
+
class="label"
|
|
340
|
+
*ngIf="label"
|
|
341
|
+
[id]="toggler?.attributes?.id + '_label'"
|
|
342
|
+
>{{ label }}</span
|
|
343
|
+
>
|
|
344
|
+
<button
|
|
345
|
+
[attr.aria-labelledby]="
|
|
346
|
+
label ? toggler?.attributes?.id + '_label' : null
|
|
347
|
+
"
|
|
348
|
+
[attr.aria-describedby]="
|
|
349
|
+
formInfo?.textContent && (formInfo?.textContent?.length ?? 0 > 0)
|
|
350
|
+
? toggler?.attributes?.id + '_info'
|
|
351
|
+
: null
|
|
352
|
+
"
|
|
353
|
+
type="button"
|
|
354
|
+
#togglerRef
|
|
355
|
+
[id]="toggler?.attributes?.id"
|
|
356
|
+
[attr.aria-haspopup]="toggler?.attributes?.['aria-haspopup']"
|
|
357
|
+
[attr.aria-expanded]="toggler?.attributes?.['aria-expanded']"
|
|
358
|
+
[attr.aria-owns]="toggler?.attributes?.['aria-owns']"
|
|
359
|
+
[tabindex]="toggler?.attributes?.tabIndex"
|
|
360
|
+
[style]="toggler?.attributes?.style"
|
|
361
|
+
[class]="toggler?.classes"
|
|
362
|
+
(click)="handler?.toggle()"
|
|
363
|
+
[class.is-valid]="valid"
|
|
364
|
+
[class.is-invalid]="invalid"
|
|
365
|
+
>
|
|
366
|
+
<span>{{
|
|
367
|
+
dropdown?.texts?.select || dropdown?.texts?.placeholder
|
|
368
|
+
}}</span>
|
|
512
369
|
</button>
|
|
513
|
-
<
|
|
514
|
-
|
|
515
|
-
|
|
370
|
+
<span
|
|
371
|
+
class="form-info"
|
|
372
|
+
#formInfo
|
|
373
|
+
[attr.id]="toggler?.attributes?.id + '_info'"
|
|
374
|
+
><ng-content select="[data-form-info]"></ng-content
|
|
375
|
+
></span>
|
|
376
|
+
<div
|
|
377
|
+
#listboxRef
|
|
378
|
+
[id]="listbox?.attributes?.id"
|
|
379
|
+
[attr.role]="listbox?.attributes?.role"
|
|
380
|
+
[attr.aria-activedescendant]="
|
|
381
|
+
listbox?.attributes?.['aria-activedescendant']
|
|
382
|
+
"
|
|
383
|
+
[tabindex]="listbox?.attributes?.tabIndex"
|
|
384
|
+
[style]="listbox?.attributes?.style"
|
|
385
|
+
[class]="listbox?.classes"
|
|
386
|
+
>
|
|
387
|
+
<button
|
|
388
|
+
type="button"
|
|
389
|
+
class="close m-4 m-sm-2 d-block d-sm-none"
|
|
390
|
+
(click)="handler?.close()"
|
|
391
|
+
>
|
|
392
|
+
<span class="sr-only">{{ dropdown?.texts?.close }}</span>
|
|
516
393
|
</button>
|
|
517
|
-
<ul role="listbox">
|
|
394
|
+
<ul role="listbox" *ngIf="!dropdown?.isMultiSelect">
|
|
518
395
|
<li
|
|
519
|
-
*ngFor="
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
396
|
+
*ngFor="
|
|
397
|
+
let option of dropdown?.options;
|
|
398
|
+
let index = index;
|
|
399
|
+
trackBy: trackByKey
|
|
400
|
+
"
|
|
401
|
+
[id]="option.attributes.id"
|
|
402
|
+
[attr.role]="option.attributes.role"
|
|
403
|
+
[attr.aria-selected]="option.attributes['aria-selected']"
|
|
404
|
+
[style]="option.attributes.style"
|
|
405
|
+
[class]="option.classes"
|
|
406
|
+
(click)="handler?.select(option)"
|
|
524
407
|
>
|
|
525
|
-
|
|
408
|
+
<ng-container
|
|
409
|
+
*ngTemplateOutlet="
|
|
410
|
+
customOption?.templateRef
|
|
411
|
+
? customOption!.templateRef
|
|
412
|
+
: defaultOption;
|
|
413
|
+
context: { option: option, index: index }
|
|
414
|
+
"
|
|
415
|
+
></ng-container>
|
|
526
416
|
</li>
|
|
527
417
|
</ul>
|
|
418
|
+
<div *ngIf="dropdown?.isMultiSelect" class="sg-fieldset-container">
|
|
419
|
+
<fieldset
|
|
420
|
+
#fieldsetRef
|
|
421
|
+
[attr.aria-describedby]="fieldset?.attributes?.id"
|
|
422
|
+
role="listbox"
|
|
423
|
+
tabIndex="-1"
|
|
424
|
+
aria-multiselectable="true"
|
|
425
|
+
>
|
|
426
|
+
<legend class="sr-only" [id]="fieldset?.attributes?.id">
|
|
427
|
+
Options
|
|
428
|
+
</legend>
|
|
429
|
+
<label
|
|
430
|
+
class="form-control"
|
|
431
|
+
[attr.role]="option.attributes.role"
|
|
432
|
+
[id]="option.attributes.id"
|
|
433
|
+
[attr.aria-selected]="option.attributes['aria-selected']"
|
|
434
|
+
[class]="option.classes"
|
|
435
|
+
*ngFor="
|
|
436
|
+
let option of dropdown?.options;
|
|
437
|
+
let index = index;
|
|
438
|
+
trackBy: trackByKey
|
|
439
|
+
"
|
|
440
|
+
>
|
|
441
|
+
<input
|
|
442
|
+
type="checkbox"
|
|
443
|
+
(change)="handler?.select(option, false)"
|
|
444
|
+
[checked]="option.selected"
|
|
445
|
+
tabIndex="-1"
|
|
446
|
+
/>
|
|
447
|
+
<ng-container
|
|
448
|
+
*ngTemplateOutlet="
|
|
449
|
+
customOption?.templateRef
|
|
450
|
+
? customOption!.templateRef
|
|
451
|
+
: defaultOption;
|
|
452
|
+
context: { option: option, index: index }
|
|
453
|
+
"
|
|
454
|
+
></ng-container>
|
|
455
|
+
<i></i>
|
|
456
|
+
</label>
|
|
457
|
+
</fieldset>
|
|
458
|
+
</div>
|
|
528
459
|
</div>
|
|
529
460
|
</div>
|
|
461
|
+
|
|
462
|
+
<ng-template #defaultOption let-option="option">
|
|
463
|
+
{{ option[dropdown!.display] }}
|
|
464
|
+
</ng-template>
|
|
530
465
|
`,
|
|
531
466
|
providers: [
|
|
532
467
|
{
|
|
@@ -535,59 +470,357 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.2", ngImpor
|
|
|
535
470
|
multi: true,
|
|
536
471
|
},
|
|
537
472
|
],
|
|
538
|
-
|
|
473
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
539
474
|
}]
|
|
540
|
-
}], propDecorators: {
|
|
475
|
+
}], ctorParameters: function () { return [{ type: i0.ChangeDetectorRef }]; }, propDecorators: { id: [{
|
|
476
|
+
type: Input
|
|
477
|
+
}], texts: [{
|
|
478
|
+
type: Input
|
|
479
|
+
}], loop: [{
|
|
480
|
+
type: Input
|
|
481
|
+
}], display: [{
|
|
541
482
|
type: Input
|
|
542
|
-
}],
|
|
483
|
+
}], selectValue: [{
|
|
543
484
|
type: Input
|
|
485
|
+
}], useValue: [{
|
|
486
|
+
type: Input
|
|
487
|
+
}], multiSelect: [{
|
|
488
|
+
type: Input
|
|
489
|
+
}], label: [{
|
|
490
|
+
type: Input
|
|
491
|
+
}], options: [{
|
|
492
|
+
type: Input
|
|
493
|
+
}], valid: [{
|
|
494
|
+
type: Input
|
|
495
|
+
}], invalid: [{
|
|
496
|
+
type: Input
|
|
497
|
+
}], value: [{
|
|
498
|
+
type: Input
|
|
499
|
+
}], valueChange: [{
|
|
500
|
+
type: Output
|
|
501
|
+
}], touched: [{
|
|
502
|
+
type: Output
|
|
503
|
+
}], togglerRef: [{
|
|
504
|
+
type: ViewChild,
|
|
505
|
+
args: ['togglerRef']
|
|
506
|
+
}], listboxRef: [{
|
|
507
|
+
type: ViewChild,
|
|
508
|
+
args: ['listboxRef']
|
|
509
|
+
}], fieldsetRef: [{
|
|
510
|
+
type: ViewChild,
|
|
511
|
+
args: ['fieldsetRef']
|
|
512
|
+
}], customOption: [{
|
|
513
|
+
type: ContentChild,
|
|
514
|
+
args: [NggDropdownOptionDirective]
|
|
544
515
|
}] } });
|
|
545
516
|
|
|
546
517
|
class NggDropdownModule {
|
|
547
518
|
}
|
|
548
|
-
NggDropdownModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.
|
|
549
|
-
NggDropdownModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
NggPopoverTriggerDirective,
|
|
553
|
-
NggDropdownComponent], imports: [CommonModule], exports: [NggPopoverDirective,
|
|
554
|
-
NggPopoverOptionDirective,
|
|
555
|
-
NggPopoverElementDirective,
|
|
556
|
-
NggPopoverTriggerDirective,
|
|
557
|
-
NggDropdownComponent] });
|
|
558
|
-
NggDropdownModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: NggDropdownModule, imports: [[CommonModule]] });
|
|
559
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: NggDropdownModule, decorators: [{
|
|
519
|
+
NggDropdownModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.3", ngImport: i0, type: NggDropdownModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
520
|
+
NggDropdownModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.3.3", ngImport: i0, type: NggDropdownModule, declarations: [NggDropdownComponent, NggDropdownOptionDirective], imports: [CommonModule], exports: [NggDropdownComponent, NggDropdownOptionDirective] });
|
|
521
|
+
NggDropdownModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.3.3", ngImport: i0, type: NggDropdownModule, imports: [[CommonModule]] });
|
|
522
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.3", ngImport: i0, type: NggDropdownModule, decorators: [{
|
|
560
523
|
type: NgModule,
|
|
561
524
|
args: [{
|
|
562
|
-
declarations: [
|
|
563
|
-
NggPopoverDirective,
|
|
564
|
-
NggPopoverOptionDirective,
|
|
565
|
-
NggPopoverElementDirective,
|
|
566
|
-
NggPopoverTriggerDirective,
|
|
567
|
-
NggDropdownComponent,
|
|
568
|
-
],
|
|
525
|
+
declarations: [NggDropdownComponent, NggDropdownOptionDirective],
|
|
569
526
|
imports: [CommonModule],
|
|
570
|
-
exports: [
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
527
|
+
exports: [NggDropdownComponent, NggDropdownOptionDirective],
|
|
528
|
+
}]
|
|
529
|
+
}] });
|
|
530
|
+
|
|
531
|
+
class NggDatepickerComponent {
|
|
532
|
+
constructor(_cdr) {
|
|
533
|
+
this._cdr = _cdr;
|
|
534
|
+
this.id = randomId();
|
|
535
|
+
this.isValid = null;
|
|
536
|
+
this.valueChange = new EventEmitter();
|
|
537
|
+
this._months = months({});
|
|
538
|
+
this.listener = (data, state) => {
|
|
539
|
+
if (this.dp && state) {
|
|
540
|
+
this.dp.state = { ...state };
|
|
541
|
+
this.years = years({
|
|
542
|
+
from: this.dp.state?.minDate?.getFullYear(),
|
|
543
|
+
to: this.dp.state?.maxDate?.getFullYear(),
|
|
544
|
+
});
|
|
545
|
+
}
|
|
546
|
+
this.onTouchedFn && this.onTouchedFn();
|
|
547
|
+
if (data) {
|
|
548
|
+
// only emit change event if date has changed
|
|
549
|
+
if (this.data?.selectedDate !== data.selectedDate) {
|
|
550
|
+
this.valueChange.emit(data.selectedDate);
|
|
551
|
+
this.onChangeFn && this.onChangeFn(data.selectedDate);
|
|
552
|
+
}
|
|
553
|
+
this.data = data;
|
|
554
|
+
}
|
|
555
|
+
if (data || state) {
|
|
556
|
+
this._cdr.markForCheck();
|
|
557
|
+
}
|
|
558
|
+
};
|
|
559
|
+
}
|
|
560
|
+
get months() {
|
|
561
|
+
return this._months;
|
|
562
|
+
}
|
|
563
|
+
set months(value) {
|
|
564
|
+
this._months = value;
|
|
565
|
+
}
|
|
566
|
+
get options() {
|
|
567
|
+
return this._options;
|
|
568
|
+
}
|
|
569
|
+
set options(value) {
|
|
570
|
+
this._options = value;
|
|
571
|
+
if (value.locale) {
|
|
572
|
+
this.months = months({ locale: this.options?.locale });
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
get value() {
|
|
576
|
+
return this._value;
|
|
577
|
+
}
|
|
578
|
+
set value(newValue) {
|
|
579
|
+
if (newValue !== this._value) {
|
|
580
|
+
this._value = newValue;
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
writeValue(value) {
|
|
584
|
+
this.value = value;
|
|
585
|
+
// When binding using ngModel we need to set initial select date
|
|
586
|
+
// once we get initial value as it's not available when component is created
|
|
587
|
+
if (value && this.dp && !this.data?.selectedDate) {
|
|
588
|
+
this.dp.select(value);
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
registerOnChange(fn) {
|
|
592
|
+
this.onChangeFn = fn;
|
|
593
|
+
}
|
|
594
|
+
registerOnTouched(fn) {
|
|
595
|
+
this.onTouchedFn = fn;
|
|
596
|
+
}
|
|
597
|
+
get data() {
|
|
598
|
+
return this._data;
|
|
599
|
+
}
|
|
600
|
+
set data(value) {
|
|
601
|
+
this._data = value;
|
|
602
|
+
}
|
|
603
|
+
onDateChange(value) {
|
|
604
|
+
const newDate = new Date(value);
|
|
605
|
+
// Only pass valid date to date picker
|
|
606
|
+
if (!isNaN(newDate.getTime())) {
|
|
607
|
+
this.dp?.select(value);
|
|
608
|
+
}
|
|
609
|
+
else {
|
|
610
|
+
this.valueChange.emit(value);
|
|
611
|
+
this.onChangeFn && this.onChangeFn(value);
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
trackWeek(index, week) {
|
|
615
|
+
return week;
|
|
616
|
+
}
|
|
617
|
+
ngAfterViewInit() {
|
|
618
|
+
// initialize datepicker
|
|
619
|
+
if (this.datepickerElRef &&
|
|
620
|
+
this.datepickerDialogElRef &&
|
|
621
|
+
this.dateInputElRef &&
|
|
622
|
+
this.datepickerTriggerElRef &&
|
|
623
|
+
!this.dp) {
|
|
624
|
+
this.dp = createDatepicker(this.listener, {
|
|
625
|
+
...this.options,
|
|
626
|
+
selectedDate: this.value,
|
|
627
|
+
}, this.datepickerElRef.nativeElement, this.datepickerDialogElRef.nativeElement, this.dateInputElRef.nativeElement, this.datepickerTriggerElRef.nativeElement);
|
|
628
|
+
this._cdr.detectChanges();
|
|
629
|
+
}
|
|
630
|
+
else {
|
|
631
|
+
throw 'Missing one or more elements...';
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
NggDatepickerComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.3", ngImport: i0, type: NggDatepickerComponent, deps: [{ token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
|
|
636
|
+
NggDatepickerComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.3", type: NggDatepickerComponent, selector: "ngg-datepicker", inputs: { options: "options", value: "value", id: "id", label: "label", isValid: "isValid" }, outputs: { valueChange: "valueChange" }, providers: [
|
|
637
|
+
{
|
|
638
|
+
provide: NG_VALUE_ACCESSOR,
|
|
639
|
+
useExisting: NggDatepickerComponent,
|
|
640
|
+
multi: true,
|
|
641
|
+
},
|
|
642
|
+
], viewQueries: [{ propertyName: "datepickerDialogElRef", first: true, predicate: ["datepickerDialogElRef"], descendants: true }, { propertyName: "dateInputElRef", first: true, predicate: ["dateInputElRef"], descendants: true }, { propertyName: "datepickerElRef", first: true, predicate: ["datepickerElRef"], descendants: true }, { propertyName: "datepickerTriggerElRef", first: true, predicate: ["datepickerTriggerElRef"], descendants: true }], ngImport: i0, template: "<div class=\"form-group\">\n <label *ngIf=\"label\" [for]=\"id\">{{ label }}</label>\n <div\n class=\"group\"\n #datepickerElRef\n [class.is-valid]=\"isValid\"\n [class.is-invalid]=\"isValid === false\"\n >\n <input\n [attr.id]=\"id\"\n [attr.aria-describedby]=\"\n formInfo?.innerText && formInfo.innerText.length > 0\n ? id + '_info'\n : null\n \"\n type=\"text\"\n placeholder=\"yyyy-mm-dd\"\n #dateInputElRef\n [value]=\"data?.formattedSelectedDate || ''\"\n (change)=\"onDateChange(dateInputElRef.value)\"\n />\n <button\n #datepickerTriggerElRef\n (click)=\"dp?.toggle()\"\n type=\"button\"\n class=\"primary\"\n >\n <i class=\"sg-icon sg-icon-calendar\">Select date</i>\n </button>\n </div>\n <span class=\"form-info\" #formInfo [attr.id]=\"id + '_info'\"\n ><ng-content select=\"[data-form-info]\"></ng-content\n ></span>\n</div>\n<!-- TODO: get or set attributes from within datepicker instance (dp) -->\n<div\n #datepickerDialogElRef\n class=\"popover popover-datepicker\"\n [class.active]=\"dp?.state?.isActive\"\n role=\"dialog\"\n aria-modal=\"true\"\n aria-label=\"Choose Date\"\n>\n <button type=\"button\" class=\"close\" (click)=\"dp?.close()\">Close</button>\n <div class=\"sg-date\">\n <header>\n <button type=\"button\" class=\"link\" (click)=\"dp?.sub(1, 'months')\">\n <i class=\"sg-icon sg-icon-previous\">Previous month</i>\n </button>\n <ngg-dropdown\n [options]=\"months\"\n text=\"Select\"\n [value]=\"data?.month\"\n selectValue=\"value\"\n (valueChange)=\"dp?.setMonth($event)\"\n ></ngg-dropdown>\n <ngg-dropdown\n *ngIf=\"years\"\n [options]=\"years\"\n text=\"Select\"\n [value]=\"data?.year\"\n selectValue=\"value\"\n (valueChange)=\"dp?.setYear($event)\"\n ></ngg-dropdown>\n <button type=\"button\" class=\"link\" (click)=\"dp?.add(1, 'months')\">\n <i class=\"sg-icon sg-icon-next\">Next month</i>\n </button>\n </header>\n <main>\n <table role=\"grid\">\n <thead>\n <tr>\n <th\n scope=\"col\"\n *ngFor=\"let header of data?.calendar?.headers\"\n [abbr]=\"header.abbr\"\n [class.sg-week-header]=\"header.type === 'week'\"\n [class.sg-day-header]=\"header.type === 'day'\"\n >\n {{ header.displayText }}\n </th>\n </tr>\n </thead>\n <tbody>\n <tr\n *ngFor=\"\n let week of data?.calendar?.calendarGrid;\n trackBy: trackWeek;\n let i = index\n \"\n >\n <th\n *ngIf=\"data?.calendar?.weekNumbers as weekNumbers\"\n class=\"sg-week-number\"\n >\n {{ weekNumbers[i] }}\n </th>\n <td\n *ngFor=\"let day of week\"\n [attr.data-date]=\"day.formattedDate\"\n [attr.role]=\"day.selected ? 'gridcell' : null\"\n [attr.aria-selected]=\"\n day.selected && !data?.highlightedDate ? true : null\n \"\n [class.disabled]=\"day.disabled\"\n [class.sg-date-today]=\"day.today\"\n [title]=\"day.today ? 'Today' : ''\"\n [tabIndex]=\"\n day.highlighted ||\n (day.selected && !data?.highlightedDate) ||\n (day.today && !data?.highlightedDate && !data?.selectedDate)\n ? 0\n : -1\n \"\n (click)=\"day.currentMonth && dp?.select(day.date)\"\n >\n {{ day.day }}\n </td>\n </tr>\n </tbody>\n </table>\n </main>\n </div>\n</div>\n", components: [{ type: NggDropdownComponent, selector: "ngg-dropdown", inputs: ["id", "texts", "loop", "display", "selectValue", "useValue", "multiSelect", "label", "options", "valid", "invalid", "value"], outputs: ["valueChange", "touched"] }], directives: [{ type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
643
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.3", ngImport: i0, type: NggDatepickerComponent, decorators: [{
|
|
644
|
+
type: Component,
|
|
645
|
+
args: [{ selector: 'ngg-datepicker', providers: [
|
|
646
|
+
{
|
|
647
|
+
provide: NG_VALUE_ACCESSOR,
|
|
648
|
+
useExisting: NggDatepickerComponent,
|
|
649
|
+
multi: true,
|
|
650
|
+
},
|
|
651
|
+
], changeDetection: ChangeDetectionStrategy.OnPush, template: "<div class=\"form-group\">\n <label *ngIf=\"label\" [for]=\"id\">{{ label }}</label>\n <div\n class=\"group\"\n #datepickerElRef\n [class.is-valid]=\"isValid\"\n [class.is-invalid]=\"isValid === false\"\n >\n <input\n [attr.id]=\"id\"\n [attr.aria-describedby]=\"\n formInfo?.innerText && formInfo.innerText.length > 0\n ? id + '_info'\n : null\n \"\n type=\"text\"\n placeholder=\"yyyy-mm-dd\"\n #dateInputElRef\n [value]=\"data?.formattedSelectedDate || ''\"\n (change)=\"onDateChange(dateInputElRef.value)\"\n />\n <button\n #datepickerTriggerElRef\n (click)=\"dp?.toggle()\"\n type=\"button\"\n class=\"primary\"\n >\n <i class=\"sg-icon sg-icon-calendar\">Select date</i>\n </button>\n </div>\n <span class=\"form-info\" #formInfo [attr.id]=\"id + '_info'\"\n ><ng-content select=\"[data-form-info]\"></ng-content\n ></span>\n</div>\n<!-- TODO: get or set attributes from within datepicker instance (dp) -->\n<div\n #datepickerDialogElRef\n class=\"popover popover-datepicker\"\n [class.active]=\"dp?.state?.isActive\"\n role=\"dialog\"\n aria-modal=\"true\"\n aria-label=\"Choose Date\"\n>\n <button type=\"button\" class=\"close\" (click)=\"dp?.close()\">Close</button>\n <div class=\"sg-date\">\n <header>\n <button type=\"button\" class=\"link\" (click)=\"dp?.sub(1, 'months')\">\n <i class=\"sg-icon sg-icon-previous\">Previous month</i>\n </button>\n <ngg-dropdown\n [options]=\"months\"\n text=\"Select\"\n [value]=\"data?.month\"\n selectValue=\"value\"\n (valueChange)=\"dp?.setMonth($event)\"\n ></ngg-dropdown>\n <ngg-dropdown\n *ngIf=\"years\"\n [options]=\"years\"\n text=\"Select\"\n [value]=\"data?.year\"\n selectValue=\"value\"\n (valueChange)=\"dp?.setYear($event)\"\n ></ngg-dropdown>\n <button type=\"button\" class=\"link\" (click)=\"dp?.add(1, 'months')\">\n <i class=\"sg-icon sg-icon-next\">Next month</i>\n </button>\n </header>\n <main>\n <table role=\"grid\">\n <thead>\n <tr>\n <th\n scope=\"col\"\n *ngFor=\"let header of data?.calendar?.headers\"\n [abbr]=\"header.abbr\"\n [class.sg-week-header]=\"header.type === 'week'\"\n [class.sg-day-header]=\"header.type === 'day'\"\n >\n {{ header.displayText }}\n </th>\n </tr>\n </thead>\n <tbody>\n <tr\n *ngFor=\"\n let week of data?.calendar?.calendarGrid;\n trackBy: trackWeek;\n let i = index\n \"\n >\n <th\n *ngIf=\"data?.calendar?.weekNumbers as weekNumbers\"\n class=\"sg-week-number\"\n >\n {{ weekNumbers[i] }}\n </th>\n <td\n *ngFor=\"let day of week\"\n [attr.data-date]=\"day.formattedDate\"\n [attr.role]=\"day.selected ? 'gridcell' : null\"\n [attr.aria-selected]=\"\n day.selected && !data?.highlightedDate ? true : null\n \"\n [class.disabled]=\"day.disabled\"\n [class.sg-date-today]=\"day.today\"\n [title]=\"day.today ? 'Today' : ''\"\n [tabIndex]=\"\n day.highlighted ||\n (day.selected && !data?.highlightedDate) ||\n (day.today && !data?.highlightedDate && !data?.selectedDate)\n ? 0\n : -1\n \"\n (click)=\"day.currentMonth && dp?.select(day.date)\"\n >\n {{ day.day }}\n </td>\n </tr>\n </tbody>\n </table>\n </main>\n </div>\n</div>\n" }]
|
|
652
|
+
}], ctorParameters: function () { return [{ type: i0.ChangeDetectorRef }]; }, propDecorators: { options: [{
|
|
653
|
+
type: Input
|
|
654
|
+
}], value: [{
|
|
655
|
+
type: Input
|
|
656
|
+
}], id: [{
|
|
657
|
+
type: Input
|
|
658
|
+
}], label: [{
|
|
659
|
+
type: Input
|
|
660
|
+
}], isValid: [{
|
|
661
|
+
type: Input
|
|
662
|
+
}], valueChange: [{
|
|
663
|
+
type: Output
|
|
664
|
+
}], datepickerDialogElRef: [{
|
|
665
|
+
type: ViewChild,
|
|
666
|
+
args: ['datepickerDialogElRef']
|
|
667
|
+
}], dateInputElRef: [{
|
|
668
|
+
type: ViewChild,
|
|
669
|
+
args: ['dateInputElRef']
|
|
670
|
+
}], datepickerElRef: [{
|
|
671
|
+
type: ViewChild,
|
|
672
|
+
args: ['datepickerElRef']
|
|
673
|
+
}], datepickerTriggerElRef: [{
|
|
674
|
+
type: ViewChild,
|
|
675
|
+
args: ['datepickerTriggerElRef']
|
|
676
|
+
}] } });
|
|
677
|
+
function dateValidator(dates) {
|
|
678
|
+
return (control) => {
|
|
679
|
+
const value = control.value;
|
|
680
|
+
if (!value) {
|
|
681
|
+
return null;
|
|
682
|
+
}
|
|
683
|
+
const newDate = new Date(value);
|
|
684
|
+
const isValidDate = !isNaN(newDate.getTime());
|
|
685
|
+
if (!isValidDate) {
|
|
686
|
+
return { validDate: true };
|
|
687
|
+
}
|
|
688
|
+
const validMinDate = dates?.min ? newDate >= startOfDay(dates.min) : true;
|
|
689
|
+
const validMaxDate = dates?.max ? newDate <= endOfDay(dates.max) : true;
|
|
690
|
+
if (!validMinDate && dates?.min) {
|
|
691
|
+
return {
|
|
692
|
+
validDate: {
|
|
693
|
+
minDate: startOfDay(dates.min),
|
|
694
|
+
actualDate: newDate,
|
|
695
|
+
},
|
|
696
|
+
};
|
|
697
|
+
}
|
|
698
|
+
if (!validMaxDate && dates?.max) {
|
|
699
|
+
return {
|
|
700
|
+
validDate: {
|
|
701
|
+
maxDate: endOfDay(dates.max),
|
|
702
|
+
actualDate: newDate,
|
|
703
|
+
},
|
|
704
|
+
};
|
|
705
|
+
}
|
|
706
|
+
return null;
|
|
707
|
+
};
|
|
708
|
+
}
|
|
709
|
+
|
|
710
|
+
class NggDatepickerModule {
|
|
711
|
+
}
|
|
712
|
+
NggDatepickerModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.3", ngImport: i0, type: NggDatepickerModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
713
|
+
NggDatepickerModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.3.3", ngImport: i0, type: NggDatepickerModule, declarations: [NggDatepickerComponent], imports: [CommonModule, NggDropdownModule], exports: [NggDatepickerComponent] });
|
|
714
|
+
NggDatepickerModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.3.3", ngImport: i0, type: NggDatepickerModule, imports: [[CommonModule, NggDropdownModule]] });
|
|
715
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.3", ngImport: i0, type: NggDatepickerModule, decorators: [{
|
|
716
|
+
type: NgModule,
|
|
717
|
+
args: [{
|
|
718
|
+
declarations: [NggDatepickerComponent],
|
|
719
|
+
imports: [CommonModule, NggDropdownModule],
|
|
720
|
+
exports: [NggDatepickerComponent],
|
|
577
721
|
}]
|
|
578
722
|
}] });
|
|
579
723
|
|
|
580
724
|
class NggModule {
|
|
581
725
|
}
|
|
582
|
-
NggModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.
|
|
583
|
-
NggModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.
|
|
584
|
-
NggModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.
|
|
585
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.
|
|
726
|
+
NggModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.3", ngImport: i0, type: NggModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
727
|
+
NggModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.3.3", ngImport: i0, type: NggModule, imports: [CommonModule], exports: [NggSegmentedControlModule, NggDropdownModule, NggDatepickerModule] });
|
|
728
|
+
NggModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.3.3", ngImport: i0, type: NggModule, imports: [[CommonModule], NggSegmentedControlModule, NggDropdownModule, NggDatepickerModule] });
|
|
729
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.3", ngImport: i0, type: NggModule, decorators: [{
|
|
586
730
|
type: NgModule,
|
|
587
731
|
args: [{
|
|
588
732
|
declarations: [],
|
|
589
733
|
imports: [CommonModule],
|
|
590
|
-
exports: [NggSegmentedControlModule, NggDropdownModule],
|
|
734
|
+
exports: [NggSegmentedControlModule, NggDropdownModule, NggDatepickerModule],
|
|
735
|
+
}]
|
|
736
|
+
}] });
|
|
737
|
+
|
|
738
|
+
class NggBadgeComponent {
|
|
739
|
+
//eslint-disable-next-line
|
|
740
|
+
constructor() {
|
|
741
|
+
/** The color of the component */
|
|
742
|
+
this.badgeType = '';
|
|
743
|
+
/** Callback when component is dismissed */
|
|
744
|
+
this.handleClose = new EventEmitter();
|
|
745
|
+
}
|
|
746
|
+
/** Flag whether the component can be dismissed */
|
|
747
|
+
set isCloseable(value) {
|
|
748
|
+
this._isCloseable = value;
|
|
749
|
+
}
|
|
750
|
+
get isCloseable() {
|
|
751
|
+
return this._isCloseable === '' || !!this._isCloseable;
|
|
752
|
+
}
|
|
753
|
+
get class() {
|
|
754
|
+
return ['badge', this.badgeType].join(' ');
|
|
755
|
+
}
|
|
756
|
+
ngOnInit() {
|
|
757
|
+
if (!!this.customColor || !!this.customBackgroundColor) {
|
|
758
|
+
this.badgeType = '';
|
|
759
|
+
}
|
|
760
|
+
}
|
|
761
|
+
close(e) {
|
|
762
|
+
this.handleClose.emit(e);
|
|
763
|
+
}
|
|
764
|
+
}
|
|
765
|
+
NggBadgeComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.3", ngImport: i0, type: NggBadgeComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
766
|
+
NggBadgeComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.3", type: NggBadgeComponent, selector: "[ngg-badge]", inputs: { badgeType: "badgeType", isCloseable: "isCloseable", closeText: "closeText", customColor: "customColor", customBackgroundColor: "customBackgroundColor" }, outputs: { handleClose: "handleClose" }, host: { properties: { "style.color": "this.customColor", "style.background-color": "this.customBackgroundColor", "class": "this.class" } }, ngImport: i0, template: `
|
|
767
|
+
<strong>
|
|
768
|
+
<ng-content></ng-content>
|
|
769
|
+
</strong>
|
|
770
|
+
<button *ngIf="isCloseable" class="close" (click)="close($event)">
|
|
771
|
+
{{ closeText }}
|
|
772
|
+
</button>
|
|
773
|
+
`, isInline: true, directives: [{ type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
774
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.3", ngImport: i0, type: NggBadgeComponent, decorators: [{
|
|
775
|
+
type: Component,
|
|
776
|
+
args: [{
|
|
777
|
+
// we need to disable this warning since we don't want the badge component to create a new element
|
|
778
|
+
// eslint-disable-next-line @angular-eslint/component-selector
|
|
779
|
+
selector: '[ngg-badge]',
|
|
780
|
+
template: `
|
|
781
|
+
<strong>
|
|
782
|
+
<ng-content></ng-content>
|
|
783
|
+
</strong>
|
|
784
|
+
<button *ngIf="isCloseable" class="close" (click)="close($event)">
|
|
785
|
+
{{ closeText }}
|
|
786
|
+
</button>
|
|
787
|
+
`,
|
|
788
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
789
|
+
}]
|
|
790
|
+
}], ctorParameters: function () { return []; }, propDecorators: { badgeType: [{
|
|
791
|
+
type: Input
|
|
792
|
+
}], isCloseable: [{
|
|
793
|
+
type: Input
|
|
794
|
+
}], closeText: [{
|
|
795
|
+
type: Input
|
|
796
|
+
}], customColor: [{
|
|
797
|
+
type: HostBinding,
|
|
798
|
+
args: ['style.color']
|
|
799
|
+
}, {
|
|
800
|
+
type: Input
|
|
801
|
+
}], customBackgroundColor: [{
|
|
802
|
+
type: HostBinding,
|
|
803
|
+
args: ['style.background-color']
|
|
804
|
+
}, {
|
|
805
|
+
type: Input
|
|
806
|
+
}], class: [{
|
|
807
|
+
type: HostBinding,
|
|
808
|
+
args: ['class']
|
|
809
|
+
}], handleClose: [{
|
|
810
|
+
type: Output
|
|
811
|
+
}] } });
|
|
812
|
+
|
|
813
|
+
class NggBadgeModule {
|
|
814
|
+
}
|
|
815
|
+
NggBadgeModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.3", ngImport: i0, type: NggBadgeModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
816
|
+
NggBadgeModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.3.3", ngImport: i0, type: NggBadgeModule, declarations: [NggBadgeComponent], imports: [CommonModule], exports: [NggBadgeComponent] });
|
|
817
|
+
NggBadgeModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.3.3", ngImport: i0, type: NggBadgeModule, imports: [[CommonModule]] });
|
|
818
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.3", ngImport: i0, type: NggBadgeModule, decorators: [{
|
|
819
|
+
type: NgModule,
|
|
820
|
+
args: [{
|
|
821
|
+
declarations: [NggBadgeComponent],
|
|
822
|
+
imports: [CommonModule],
|
|
823
|
+
exports: [NggBadgeComponent],
|
|
591
824
|
}]
|
|
592
825
|
}] });
|
|
593
826
|
|
|
@@ -595,5 +828,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.2", ngImpor
|
|
|
595
828
|
* Generated bundle index. Do not edit.
|
|
596
829
|
*/
|
|
597
830
|
|
|
598
|
-
export {
|
|
831
|
+
export { NggBadgeComponent, NggBadgeModule, NggDatepickerComponent, NggDatepickerModule, NggDropdownComponent, NggDropdownModule, NggDropdownOptionDirective, NggModule, NggSegmentedControlComponent, NggSegmentedControlModule, dateValidator };
|
|
599
832
|
//# sourceMappingURL=sebgroup-green-angular.mjs.map
|