@bootkit/ng0 0.0.0-alpha.2 → 0.0.0-alpha.21
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/common/index.d.ts +118 -6
- package/components/accordion/index.d.ts +1 -1
- package/components/backdrop/index.d.ts +12 -0
- package/components/button/index.d.ts +48 -0
- package/components/card/index.d.ts +27 -0
- package/components/code/index.d.ts +35 -0
- package/components/confirmation/index.d.ts +66 -0
- package/components/dropdown/index.d.ts +78 -0
- package/components/form-field/index.d.ts +72 -0
- package/components/list/index.d.ts +127 -0
- package/components/modal/index.d.ts +22 -4
- package/components/nav/index.d.ts +23 -19
- package/components/pagination/index.d.ts +35 -9
- package/components/popover/index.d.ts +1 -1
- package/components/select/index.d.ts +116 -0
- package/components/sidenav/index.d.ts +59 -0
- package/components/stepper/index.d.ts +26 -0
- package/components/table/index.d.ts +273 -0
- package/components/toast/index.d.ts +1 -1
- package/components/tooltip/index.d.ts +1 -1
- package/components/vertical-menu/index.d.ts +61 -0
- package/data/index.d.ts +258 -46
- package/date/index.d.ts +34 -0
- package/fesm2022/bootkit-ng0-common.mjs +89 -11
- package/fesm2022/bootkit-ng0-common.mjs.map +1 -1
- package/fesm2022/bootkit-ng0-components-accordion.mjs +13 -13
- package/fesm2022/bootkit-ng0-components-accordion.mjs.map +1 -1
- package/fesm2022/bootkit-ng0-components-backdrop.mjs +46 -0
- package/fesm2022/bootkit-ng0-components-backdrop.mjs.map +1 -0
- package/fesm2022/bootkit-ng0-components-button.mjs +119 -0
- package/fesm2022/bootkit-ng0-components-button.mjs.map +1 -0
- package/fesm2022/bootkit-ng0-components-card.mjs +62 -0
- package/fesm2022/bootkit-ng0-components-card.mjs.map +1 -0
- package/fesm2022/bootkit-ng0-components-code.mjs +70 -0
- package/fesm2022/bootkit-ng0-components-code.mjs.map +1 -0
- package/fesm2022/bootkit-ng0-components-collapse.mjs +14 -14
- package/fesm2022/bootkit-ng0-components-collapse.mjs.map +1 -1
- package/fesm2022/bootkit-ng0-components-confirmation.mjs +167 -0
- package/fesm2022/bootkit-ng0-components-confirmation.mjs.map +1 -0
- package/fesm2022/bootkit-ng0-components-dropdown.mjs +189 -0
- package/fesm2022/bootkit-ng0-components-dropdown.mjs.map +1 -0
- package/fesm2022/bootkit-ng0-components-form-field.mjs +147 -0
- package/fesm2022/bootkit-ng0-components-form-field.mjs.map +1 -0
- package/fesm2022/bootkit-ng0-components-list.mjs +331 -0
- package/fesm2022/bootkit-ng0-components-list.mjs.map +1 -0
- package/fesm2022/bootkit-ng0-components-modal.mjs +40 -23
- package/fesm2022/bootkit-ng0-components-modal.mjs.map +1 -1
- package/fesm2022/bootkit-ng0-components-nav.mjs +58 -59
- package/fesm2022/bootkit-ng0-components-nav.mjs.map +1 -1
- package/fesm2022/bootkit-ng0-components-offcanvas.mjs +9 -9
- package/fesm2022/bootkit-ng0-components-offcanvas.mjs.map +1 -1
- package/fesm2022/bootkit-ng0-components-overlay.mjs.map +1 -1
- package/fesm2022/bootkit-ng0-components-pagination.mjs +58 -23
- package/fesm2022/bootkit-ng0-components-pagination.mjs.map +1 -1
- package/fesm2022/bootkit-ng0-components-popover.mjs +10 -10
- package/fesm2022/bootkit-ng0-components-popover.mjs.map +1 -1
- package/fesm2022/bootkit-ng0-components-select.mjs +427 -0
- package/fesm2022/bootkit-ng0-components-select.mjs.map +1 -0
- package/fesm2022/bootkit-ng0-components-sidenav.mjs +153 -0
- package/fesm2022/bootkit-ng0-components-sidenav.mjs.map +1 -0
- package/fesm2022/bootkit-ng0-components-stepper.mjs +91 -0
- package/fesm2022/bootkit-ng0-components-stepper.mjs.map +1 -0
- package/fesm2022/bootkit-ng0-components-table.mjs +461 -0
- package/fesm2022/bootkit-ng0-components-table.mjs.map +1 -0
- package/fesm2022/bootkit-ng0-components-toast.mjs +7 -7
- package/fesm2022/bootkit-ng0-components-toast.mjs.map +1 -1
- package/fesm2022/bootkit-ng0-components-tooltip.mjs +8 -8
- package/fesm2022/bootkit-ng0-components-tooltip.mjs.map +1 -1
- package/fesm2022/bootkit-ng0-components-vertical-menu.mjs +161 -0
- package/fesm2022/bootkit-ng0-components-vertical-menu.mjs.map +1 -0
- package/fesm2022/bootkit-ng0-data.mjs +291 -90
- package/fesm2022/bootkit-ng0-data.mjs.map +1 -1
- package/fesm2022/bootkit-ng0-date.mjs +50 -0
- package/fesm2022/bootkit-ng0-date.mjs.map +1 -0
- package/fesm2022/bootkit-ng0-file.mjs +50 -0
- package/fesm2022/bootkit-ng0-file.mjs.map +1 -0
- package/fesm2022/bootkit-ng0-form.mjs +514 -0
- package/fesm2022/bootkit-ng0-form.mjs.map +1 -0
- package/fesm2022/bootkit-ng0-http.mjs +225 -179
- package/fesm2022/bootkit-ng0-http.mjs.map +1 -1
- package/fesm2022/bootkit-ng0-localization-locales.mjs +115 -0
- package/fesm2022/bootkit-ng0-localization-locales.mjs.map +1 -0
- package/fesm2022/bootkit-ng0-localization.mjs +481 -0
- package/fesm2022/bootkit-ng0-localization.mjs.map +1 -0
- package/fesm2022/bootkit-ng0-platform-browser.mjs +51 -0
- package/fesm2022/bootkit-ng0-platform-browser.mjs.map +1 -0
- package/fesm2022/bootkit-ng0-script.mjs +59 -0
- package/fesm2022/bootkit-ng0-script.mjs.map +1 -0
- package/fesm2022/bootkit-ng0-security.mjs +17 -15
- package/fesm2022/bootkit-ng0-security.mjs.map +1 -1
- package/file/index.d.ts +22 -0
- package/form/index.d.ts +127 -0
- package/http/index.d.ts +141 -40
- package/localization/index.d.ts +305 -0
- package/localization/locales/index.d.ts +7 -0
- package/package.json +90 -10
- package/platform/browser/index.d.ts +22 -0
- package/script/index.d.ts +27 -0
- package/security/index.d.ts +3 -9
|
@@ -0,0 +1,331 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { inject, DOCUMENT, ChangeDetectorRef, signal, input, booleanAttribute, TemplateRef, forwardRef, HostListener, ContentChild, ChangeDetectionStrategy, Component, NgModule } from '@angular/core';
|
|
3
|
+
import * as i1 from '@angular/common';
|
|
4
|
+
import { CommonModule } from '@angular/common';
|
|
5
|
+
import { dataSourceAttribute, defaultBooleanValueComparer, BooleanValueComparerAttribute, defaultValueExtractor, ValueExtractorAttribute, stringFilter, FilterPredicateAttribute, DataRequest } from '@bootkit/ng0/data';
|
|
6
|
+
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|
7
|
+
import { NG_VALUE_ACCESSOR } from '@angular/forms';
|
|
8
|
+
import { OverlayModule } from '@angular/cdk/overlay';
|
|
9
|
+
import { CssClassAttribute, sequentialIdGenerator } from '@bootkit/ng0/common';
|
|
10
|
+
import { LocalizationService, defaultValueFormatter, ValueFormatterAttribute } from '@bootkit/ng0/localization';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Select component that allows users to choose an option from a dropdown list.
|
|
14
|
+
*/
|
|
15
|
+
class ListComponent {
|
|
16
|
+
_el;
|
|
17
|
+
_renderer;
|
|
18
|
+
_destroyRef;
|
|
19
|
+
_document = inject(DOCUMENT);
|
|
20
|
+
_ls = inject(LocalizationService);
|
|
21
|
+
_changeDetector = inject(ChangeDetectorRef);
|
|
22
|
+
_value = signal(undefined, ...(ngDevMode ? [{ debugName: "_value" }] : []));
|
|
23
|
+
_onChangeCallback;
|
|
24
|
+
_onTouchedCallback;
|
|
25
|
+
_items = signal([], ...(ngDevMode ? [{ debugName: "_items" }] : []));
|
|
26
|
+
_isDisabled = signal(false, ...(ngDevMode ? [{ debugName: "_isDisabled" }] : []));
|
|
27
|
+
_activeOptionIndex = signal(-1, ...(ngDevMode ? [{ debugName: "_activeOptionIndex" }] : []));
|
|
28
|
+
_itemTemplate;
|
|
29
|
+
/**
|
|
30
|
+
* The data source for the select component.
|
|
31
|
+
* This can be an array of data, a function that returns an observable of data,
|
|
32
|
+
* or an instance of DataSource.
|
|
33
|
+
*/
|
|
34
|
+
source = input.required(...(ngDevMode ? [{ debugName: "source", transform: v => dataSourceAttribute(v) }] : [{
|
|
35
|
+
transform: v => dataSourceAttribute(v)
|
|
36
|
+
}]));
|
|
37
|
+
/**
|
|
38
|
+
* Indicates whether multi selection is enabled or not.
|
|
39
|
+
*/
|
|
40
|
+
multiple = input(false, ...(ngDevMode ? [{ debugName: "multiple", transform: booleanAttribute }] : [{
|
|
41
|
+
transform: booleanAttribute
|
|
42
|
+
}]));
|
|
43
|
+
/**
|
|
44
|
+
* Indicates whether to show selection indicator (checkbox/radio) next to each item.
|
|
45
|
+
* Default is false.
|
|
46
|
+
*/
|
|
47
|
+
showIndicator = input(false, ...(ngDevMode ? [{ debugName: "showIndicator", transform: booleanAttribute }] : [{
|
|
48
|
+
transform: booleanAttribute
|
|
49
|
+
}]));
|
|
50
|
+
/**
|
|
51
|
+
* A custom comparer function or the name of a field for comparing two objects.
|
|
52
|
+
*/
|
|
53
|
+
compareBy = input(defaultBooleanValueComparer, ...(ngDevMode ? [{ debugName: "compareBy", transform: BooleanValueComparerAttribute }] : [{
|
|
54
|
+
transform: BooleanValueComparerAttribute
|
|
55
|
+
}]));
|
|
56
|
+
/**
|
|
57
|
+
* Custom format function to convert an item to a string for display.
|
|
58
|
+
* Default converts the item to a string using its toString method.
|
|
59
|
+
*/
|
|
60
|
+
formatBy = input(defaultValueFormatter, ...(ngDevMode ? [{ debugName: "formatBy", transform: ValueFormatterAttribute(this._ls.get()) }] : [{
|
|
61
|
+
transform: ValueFormatterAttribute(this._ls.get())
|
|
62
|
+
}]));
|
|
63
|
+
/**
|
|
64
|
+
* Custom value extractor function to extract the value of any object while writing values.
|
|
65
|
+
*/
|
|
66
|
+
writeBy = input(defaultValueExtractor, ...(ngDevMode ? [{ debugName: "writeBy", transform: ValueExtractorAttribute }] : [{
|
|
67
|
+
transform: ValueExtractorAttribute
|
|
68
|
+
}]));
|
|
69
|
+
/**
|
|
70
|
+
* A custom filter predicate function to filter items based on a search string.
|
|
71
|
+
* Default checks if the item's string representation contains the filter string (case-insensitive).
|
|
72
|
+
* The filter predicate can be a function or a string representing the property name to filter.
|
|
73
|
+
*/
|
|
74
|
+
filterBy = input(stringFilter, ...(ngDevMode ? [{ debugName: "filterBy", transform: FilterPredicateAttribute }] : [{
|
|
75
|
+
transform: FilterPredicateAttribute
|
|
76
|
+
}]));
|
|
77
|
+
/**
|
|
78
|
+
* CSS class or classes to apply to the list container.
|
|
79
|
+
* Default is undefined.
|
|
80
|
+
*/
|
|
81
|
+
itemClass = input((item) => undefined, ...(ngDevMode ? [{ debugName: "itemClass", transform: CssClassAttribute }] : [{
|
|
82
|
+
transform: CssClassAttribute
|
|
83
|
+
}]));
|
|
84
|
+
focus = input('activeDescendant', ...(ngDevMode ? [{ debugName: "focus" }] : []));
|
|
85
|
+
idGenerator = input(sequentialIdGenerator('ng0-list-item-'), ...(ngDevMode ? [{ debugName: "idGenerator" }] : []));
|
|
86
|
+
constructor(_el, _renderer, _destroyRef) {
|
|
87
|
+
this._el = _el;
|
|
88
|
+
this._renderer = _renderer;
|
|
89
|
+
this._destroyRef = _destroyRef;
|
|
90
|
+
}
|
|
91
|
+
ngOnInit() {
|
|
92
|
+
this._loadItems();
|
|
93
|
+
this._listenToDataSourceChanges();
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Sets an option as active
|
|
97
|
+
*/
|
|
98
|
+
active(index) {
|
|
99
|
+
if (index < 0) {
|
|
100
|
+
throw Error();
|
|
101
|
+
}
|
|
102
|
+
this._activeOptionIndex.set(index);
|
|
103
|
+
// this.scrollItemIntoView(this._activeOptionIndex(), 'nearest');
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Filters the list items based on the provided criteria.
|
|
107
|
+
* @param params The filter parameters to apply.
|
|
108
|
+
* @returns void
|
|
109
|
+
*/
|
|
110
|
+
filter(...params) {
|
|
111
|
+
let filterBy = this.filterBy();
|
|
112
|
+
this._items().forEach(x => x.filtered = !filterBy(x.value, ...params));
|
|
113
|
+
this._changeDetector.markForCheck();
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Clears any applied filters and shows all items in the list.
|
|
117
|
+
* @returns void
|
|
118
|
+
*/
|
|
119
|
+
clearFilter() {
|
|
120
|
+
this._items().forEach(x => x.filtered = false);
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Scrolls the item at the specified index into view within the dropdown list.
|
|
124
|
+
* @param index The index of the item to scroll into view.
|
|
125
|
+
* @param position The vertical alignment of the item after scrolling.
|
|
126
|
+
* Can be 'start', 'center', 'end', or 'nearest'.
|
|
127
|
+
* Default is 'nearest'.
|
|
128
|
+
* @param behavior The scrolling behavior.
|
|
129
|
+
*/
|
|
130
|
+
scrollItemIntoView(index, position, behavior) {
|
|
131
|
+
let item = this._items()[index];
|
|
132
|
+
let elm = this._document.getElementById(item.id);
|
|
133
|
+
elm.scrollIntoView({ block: position, behavior: behavior });
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Toggles the selection of an option by index
|
|
137
|
+
*/
|
|
138
|
+
toggleSelection(index) {
|
|
139
|
+
let optionsCount = this._items().length;
|
|
140
|
+
if (optionsCount == 0 || index < 0 || index > optionsCount - 1) {
|
|
141
|
+
throw new Error('Index out of range');
|
|
142
|
+
}
|
|
143
|
+
let item = this._items()[index];
|
|
144
|
+
let writeValueBy = this.writeBy();
|
|
145
|
+
if (this.multiple()) {
|
|
146
|
+
item.selected = !item.selected;
|
|
147
|
+
let selectedValues = this._items().filter(x => x.selected).map(x => (x.value));
|
|
148
|
+
this._value.set(selectedValues);
|
|
149
|
+
}
|
|
150
|
+
else {
|
|
151
|
+
if (item.selected) {
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
let itemValue = writeValueBy(item.value);
|
|
155
|
+
this._items().forEach(x => x.selected = false);
|
|
156
|
+
item.selected = true;
|
|
157
|
+
this._value.set(itemValue);
|
|
158
|
+
}
|
|
159
|
+
this._onChangeCallback(this._value());
|
|
160
|
+
}
|
|
161
|
+
writeValue(v) {
|
|
162
|
+
let value;
|
|
163
|
+
if (this.multiple()) {
|
|
164
|
+
if (Array.isArray(v)) {
|
|
165
|
+
value = v;
|
|
166
|
+
}
|
|
167
|
+
else if (v === null || v === undefined) {
|
|
168
|
+
value = [];
|
|
169
|
+
}
|
|
170
|
+
else {
|
|
171
|
+
throw Error('Provide an array or null as the value ng0-list component');
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
else {
|
|
175
|
+
value = v;
|
|
176
|
+
}
|
|
177
|
+
this._value.set(value);
|
|
178
|
+
// Update selection state of items
|
|
179
|
+
let compareBy = this.compareBy();
|
|
180
|
+
if (this.multiple()) {
|
|
181
|
+
this._items().forEach(x => x.selected = value.some(y => compareBy(x.value, y)));
|
|
182
|
+
}
|
|
183
|
+
else {
|
|
184
|
+
this._items().forEach(x => x.selected = compareBy(x.value, value));
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
registerOnChange(fn) {
|
|
188
|
+
this._onChangeCallback = fn;
|
|
189
|
+
}
|
|
190
|
+
registerOnTouched(fn) {
|
|
191
|
+
this._onTouchedCallback = fn;
|
|
192
|
+
}
|
|
193
|
+
setDisabledState(isDisabled) {
|
|
194
|
+
this._isDisabled.set(isDisabled);
|
|
195
|
+
}
|
|
196
|
+
_onKeydown(e, firedByFilter = false) {
|
|
197
|
+
if (this._isDisabled())
|
|
198
|
+
return;
|
|
199
|
+
let optionsCount = this._items().length;
|
|
200
|
+
if (optionsCount == 0) {
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
switch (e.key) {
|
|
204
|
+
case 'ArrowDown':
|
|
205
|
+
if (this._activeOptionIndex() < optionsCount - 1) {
|
|
206
|
+
this.active(this._activeOptionIndex() + 1);
|
|
207
|
+
}
|
|
208
|
+
e.preventDefault();
|
|
209
|
+
break;
|
|
210
|
+
case 'ArrowUp':
|
|
211
|
+
if (this._activeOptionIndex() > 0) {
|
|
212
|
+
this.active(this._activeOptionIndex() - 1);
|
|
213
|
+
}
|
|
214
|
+
e.preventDefault();
|
|
215
|
+
break;
|
|
216
|
+
case 'Enter':
|
|
217
|
+
this.toggleSelection(this._activeOptionIndex());
|
|
218
|
+
e.preventDefault();
|
|
219
|
+
break;
|
|
220
|
+
case 'Home':
|
|
221
|
+
this.active(0);
|
|
222
|
+
e.preventDefault();
|
|
223
|
+
break;
|
|
224
|
+
case 'End':
|
|
225
|
+
this.active(optionsCount - 1);
|
|
226
|
+
e.preventDefault();
|
|
227
|
+
break;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
_loadItems() {
|
|
231
|
+
var r = new DataRequest();
|
|
232
|
+
this.source().load(r).pipe(takeUntilDestroyed(this._destroyRef)).subscribe(res => {
|
|
233
|
+
this._insertItems(0, ...res.data);
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
_listenToDataSourceChanges() {
|
|
237
|
+
this.source().change.subscribe(e => {
|
|
238
|
+
let options = this._items();
|
|
239
|
+
e.changes.forEach(change => {
|
|
240
|
+
switch (change.type) {
|
|
241
|
+
case 'insert':
|
|
242
|
+
this._insertItems(change.index, ...change.items);
|
|
243
|
+
break;
|
|
244
|
+
case 'replace':
|
|
245
|
+
options[change.index].value = change.value;
|
|
246
|
+
break;
|
|
247
|
+
case 'remove':
|
|
248
|
+
options.splice(change.index, change.count);
|
|
249
|
+
}
|
|
250
|
+
});
|
|
251
|
+
// this._changeDetector.markForCheck();
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
_insertItems(index, ...items) {
|
|
255
|
+
// let filter = this.filterBy()()
|
|
256
|
+
let idGenerator = this.idGenerator();
|
|
257
|
+
let compareBy = this.compareBy();
|
|
258
|
+
let value = this._value();
|
|
259
|
+
let isItemSelected = this.multiple() && Array.isArray(value) ?
|
|
260
|
+
(item) => value.some(x => compareBy(x.value, item)) :
|
|
261
|
+
(item) => compareBy(value, item);
|
|
262
|
+
var options = items.map(x => ({
|
|
263
|
+
id: idGenerator ? idGenerator(x) : undefined,
|
|
264
|
+
value: x,
|
|
265
|
+
selected: isItemSelected(x),
|
|
266
|
+
filtered: false,
|
|
267
|
+
}));
|
|
268
|
+
if (Number.isInteger(index)) {
|
|
269
|
+
this._items().splice(index, 0, ...options);
|
|
270
|
+
}
|
|
271
|
+
else {
|
|
272
|
+
this._items().push(...options);
|
|
273
|
+
}
|
|
274
|
+
this._changeDetector.markForCheck();
|
|
275
|
+
}
|
|
276
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.2.1", ngImport: i0, type: ListComponent, deps: [{ token: i0.ElementRef }, { token: i0.Renderer2 }, { token: i0.DestroyRef }], target: i0.ɵɵFactoryTarget.Component });
|
|
277
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.2.1", type: ListComponent, isStandalone: true, selector: "ng0-list", inputs: { source: { classPropertyName: "source", publicName: "source", isSignal: true, isRequired: true, transformFunction: null }, multiple: { classPropertyName: "multiple", publicName: "multiple", isSignal: true, isRequired: false, transformFunction: null }, showIndicator: { classPropertyName: "showIndicator", publicName: "showIndicator", isSignal: true, isRequired: false, transformFunction: null }, compareBy: { classPropertyName: "compareBy", publicName: "compareBy", isSignal: true, isRequired: false, transformFunction: null }, formatBy: { classPropertyName: "formatBy", publicName: "formatBy", isSignal: true, isRequired: false, transformFunction: null }, writeBy: { classPropertyName: "writeBy", publicName: "writeBy", isSignal: true, isRequired: false, transformFunction: null }, filterBy: { classPropertyName: "filterBy", publicName: "filterBy", isSignal: true, isRequired: false, transformFunction: null }, itemClass: { classPropertyName: "itemClass", publicName: "itemClass", isSignal: true, isRequired: false, transformFunction: null }, focus: { classPropertyName: "focus", publicName: "focus", isSignal: true, isRequired: false, transformFunction: null }, idGenerator: { classPropertyName: "idGenerator", publicName: "idGenerator", isSignal: true, isRequired: false, transformFunction: null } }, host: { listeners: { "keydown": "_onKeydown($event)" }, properties: { "class.ng0-list-loading": "source().isLoading()", "attr.aria-activedescendant": "_activeOptionIndex() > -1 ? (_items()[_activeOptionIndex()].id) : undefined", "attr.disabled": "_isDisabled()", "attr.tabindex": "_isDisabled() || focus() === \"none\" ? \"-1\" : \"0\"", "attr.aria-disabled": "_isDisabled()" } }, providers: [{
|
|
278
|
+
provide: NG_VALUE_ACCESSOR,
|
|
279
|
+
useExisting: forwardRef(() => ListComponent),
|
|
280
|
+
multi: true
|
|
281
|
+
}], queries: [{ propertyName: "_itemTemplate", first: true, predicate: TemplateRef, descendants: true }], exportAs: ["ng0List"], ngImport: i0, template: "@for (i of _items(); track $index) {\r\n@if(!i.filtered) {\r\n<div class=\"ng0-list-item\"\r\n [ngClass]=\"itemClass()(i)\"\r\n [attr.id]=\"i.id\"\r\n [class.ng0-list-item-active]=\"$index == _activeOptionIndex()\"\r\n [class.ng0-list-item-selected]=\"i.selected\"\r\n (click)=\"toggleSelection($index);\">\r\n\r\n @if(_itemTemplate) {\r\n <ng-container *ngTemplateOutlet=\"_itemTemplate; context: { $implicit: i}\" />\r\n } @else {\r\n\r\n @if(showIndicator()) {\r\n <input class=\"form-check-input ng0-list-item-indicator\"\r\n [checked]=\"i.selected\"\r\n [attr.type]=\"multiple() ? 'checkbox' : 'radio'\"\r\n [attr.name]=\"i.id\"\r\n [attr.id]=\"i.id\">\r\n }\r\n\r\n {{formatBy()(i.value)}}\r\n\r\n }\r\n</div>\r\n}\r\n}", styles: [":host{display:block;overflow-y:auto;overflow-x:hidden;-webkit-user-select:none;user-select:none}:host.disabled{background-color:var(--bs-secondary-bg)}.ng0-list-item{display:flex;padding-inline-start:.5rem}.ng0-list-item .ng0-list-item-indicator{margin-inline-end:.5rem}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "ngmodule", type: OverlayModule }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
282
|
+
}
|
|
283
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.2.1", ngImport: i0, type: ListComponent, decorators: [{
|
|
284
|
+
type: Component,
|
|
285
|
+
args: [{ selector: 'ng0-list', exportAs: 'ng0List', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, imports: [
|
|
286
|
+
CommonModule,
|
|
287
|
+
OverlayModule,
|
|
288
|
+
], providers: [{
|
|
289
|
+
provide: NG_VALUE_ACCESSOR,
|
|
290
|
+
useExisting: forwardRef(() => ListComponent),
|
|
291
|
+
multi: true
|
|
292
|
+
}], host: {
|
|
293
|
+
'[class.ng0-list-loading]': 'source().isLoading()',
|
|
294
|
+
'[attr.aria-activedescendant]': '_activeOptionIndex() > -1 ? (_items()[_activeOptionIndex()].id) : undefined',
|
|
295
|
+
'[attr.disabled]': '_isDisabled()',
|
|
296
|
+
'[attr.tabindex]': '_isDisabled() || focus() === "none" ? "-1" : "0"',
|
|
297
|
+
'[attr.aria-disabled]': '_isDisabled()'
|
|
298
|
+
}, template: "@for (i of _items(); track $index) {\r\n@if(!i.filtered) {\r\n<div class=\"ng0-list-item\"\r\n [ngClass]=\"itemClass()(i)\"\r\n [attr.id]=\"i.id\"\r\n [class.ng0-list-item-active]=\"$index == _activeOptionIndex()\"\r\n [class.ng0-list-item-selected]=\"i.selected\"\r\n (click)=\"toggleSelection($index);\">\r\n\r\n @if(_itemTemplate) {\r\n <ng-container *ngTemplateOutlet=\"_itemTemplate; context: { $implicit: i}\" />\r\n } @else {\r\n\r\n @if(showIndicator()) {\r\n <input class=\"form-check-input ng0-list-item-indicator\"\r\n [checked]=\"i.selected\"\r\n [attr.type]=\"multiple() ? 'checkbox' : 'radio'\"\r\n [attr.name]=\"i.id\"\r\n [attr.id]=\"i.id\">\r\n }\r\n\r\n {{formatBy()(i.value)}}\r\n\r\n }\r\n</div>\r\n}\r\n}", styles: [":host{display:block;overflow-y:auto;overflow-x:hidden;-webkit-user-select:none;user-select:none}:host.disabled{background-color:var(--bs-secondary-bg)}.ng0-list-item{display:flex;padding-inline-start:.5rem}.ng0-list-item .ng0-list-item-indicator{margin-inline-end:.5rem}\n"] }]
|
|
299
|
+
}], ctorParameters: () => [{ type: i0.ElementRef }, { type: i0.Renderer2 }, { type: i0.DestroyRef }], propDecorators: { _itemTemplate: [{
|
|
300
|
+
type: ContentChild,
|
|
301
|
+
args: [TemplateRef]
|
|
302
|
+
}], _onKeydown: [{
|
|
303
|
+
type: HostListener,
|
|
304
|
+
args: ['keydown', ['$event']]
|
|
305
|
+
}] } });
|
|
306
|
+
|
|
307
|
+
const Items = [ListComponent];
|
|
308
|
+
/**
|
|
309
|
+
* List module.
|
|
310
|
+
*/
|
|
311
|
+
class ListModule {
|
|
312
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.2.1", ngImport: i0, type: ListModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
313
|
+
static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.2.1", ngImport: i0, type: ListModule, imports: [ListComponent], exports: [ListComponent] });
|
|
314
|
+
static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.2.1", ngImport: i0, type: ListModule, imports: [Items] });
|
|
315
|
+
}
|
|
316
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.2.1", ngImport: i0, type: ListModule, decorators: [{
|
|
317
|
+
type: NgModule,
|
|
318
|
+
args: [{
|
|
319
|
+
imports: Items,
|
|
320
|
+
exports: Items
|
|
321
|
+
}]
|
|
322
|
+
}] });
|
|
323
|
+
|
|
324
|
+
// export * from './types';
|
|
325
|
+
|
|
326
|
+
/**
|
|
327
|
+
* Generated bundle index. Do not edit.
|
|
328
|
+
*/
|
|
329
|
+
|
|
330
|
+
export { ListComponent, ListModule };
|
|
331
|
+
//# sourceMappingURL=bootkit-ng0-components-list.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bootkit-ng0-components-list.mjs","sources":["../../../projects/ng0/components/list/list.component.ts","../../../projects/ng0/components/list/list.component.html","../../../projects/ng0/components/list/list.module.ts","../../../projects/ng0/components/list/public-api.ts","../../../projects/ng0/components/list/bootkit-ng0-components-list.ts"],"sourcesContent":["import { Component, ElementRef, Renderer2, input, OnInit, DestroyRef, signal, HostListener, inject, forwardRef, TemplateRef, ContentChild, DOCUMENT, ChangeDetectionStrategy, booleanAttribute, ChangeDetectorRef, effect } from '@angular/core';\r\nimport { CommonModule } from '@angular/common';\r\nimport { dataSourceAttribute, DataRequest, DataSource, DataSourceLike, ValueExtractorAttribute, defaultValueExtractor, stringFilter, FilterPredicate, FilterPredicateAttribute, BooleanValueComparerAttribute } from '@bootkit/ng0/data';\r\nimport { takeUntilDestroyed } from '@angular/core/rxjs-interop';\r\nimport { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';\r\nimport { OverlayModule } from '@angular/cdk/overlay';\r\nimport { _IdGenerator, CssClassLike, CssClassAttribute, IdGenerator, sequentialIdGenerator, } from '@bootkit/ng0/common';\r\nimport { ValueFormatterAttribute, defaultValueFormatter, LocalizationService } from '@bootkit/ng0/localization';\r\nimport { ListItem } from './types';\r\nimport { } from '@bootkit/ng0/data';\r\nimport { defaultBooleanValueComparer } from '@bootkit/ng0/data';\r\n\r\n/**\r\n * Select component that allows users to choose an option from a dropdown list.\r\n */\r\n@Component({\r\n selector: 'ng0-list',\r\n exportAs: 'ng0List',\r\n templateUrl: './list.component.html',\r\n styleUrl: './list.component.scss',\r\n standalone: true,\r\n changeDetection: ChangeDetectionStrategy.OnPush,\r\n imports: [\r\n CommonModule,\r\n OverlayModule,\r\n ],\r\n providers: [{\r\n provide: NG_VALUE_ACCESSOR,\r\n useExisting: forwardRef(() => ListComponent),\r\n multi: true\r\n }],\r\n host: {\r\n '[class.ng0-list-loading]': 'source().isLoading()',\r\n '[attr.aria-activedescendant]': '_activeOptionIndex() > -1 ? (_items()[_activeOptionIndex()].id) : undefined',\r\n '[attr.disabled]': '_isDisabled()',\r\n '[attr.tabindex]': '_isDisabled() || focus() === \"none\" ? \"-1\" : \"0\"',\r\n '[attr.aria-disabled]': '_isDisabled()'\r\n }\r\n})\r\nexport class ListComponent implements OnInit, ControlValueAccessor {\r\n private _document = inject(DOCUMENT);\r\n private _ls = inject(LocalizationService);\r\n private _changeDetector = inject(ChangeDetectorRef);\r\n protected _value = signal<any>(undefined);\r\n private _onChangeCallback!: (value: any) => void;\r\n private _onTouchedCallback!: (value: any) => void;\r\n\r\n protected readonly _items = signal<ListItem[]>([]);\r\n protected readonly _isDisabled = signal<boolean>(false);\r\n protected readonly _activeOptionIndex = signal<number>(-1);\r\n @ContentChild(TemplateRef) protected _itemTemplate?: TemplateRef<any>;\r\n\r\n /**\r\n * The data source for the select component.\r\n * This can be an array of data, a function that returns an observable of data,\r\n * or an instance of DataSource.\r\n */\r\n public readonly source = input.required<DataSource<any>, DataSourceLike<any>>({\r\n transform: v => dataSourceAttribute(v)\r\n });\r\n\r\n /** \r\n * Indicates whether multi selection is enabled or not.\r\n */\r\n public readonly multiple = input(false, {\r\n transform: booleanAttribute\r\n });\r\n\r\n /**\r\n * Indicates whether to show selection indicator (checkbox/radio) next to each item.\r\n * Default is false.\r\n */\r\n public readonly showIndicator = input(false, {\r\n transform: booleanAttribute\r\n });\r\n\r\n /**\r\n * A custom comparer function or the name of a field for comparing two objects.\r\n */\r\n public readonly compareBy = input(defaultBooleanValueComparer, {\r\n transform: BooleanValueComparerAttribute\r\n });\r\n\r\n /**\r\n * Custom format function to convert an item to a string for display.\r\n * Default converts the item to a string using its toString method.\r\n */\r\n public readonly formatBy = input(defaultValueFormatter, {\r\n transform: ValueFormatterAttribute(this._ls.get())\r\n });\r\n\r\n /**\r\n * Custom value extractor function to extract the value of any object while writing values.\r\n */\r\n public readonly writeBy = input(defaultValueExtractor, {\r\n transform: ValueExtractorAttribute\r\n });\r\n\r\n /**\r\n * A custom filter predicate function to filter items based on a search string.\r\n * Default checks if the item's string representation contains the filter string (case-insensitive).\r\n * The filter predicate can be a function or a string representing the property name to filter.\r\n */\r\n public readonly filterBy = input(stringFilter, {\r\n transform: FilterPredicateAttribute\r\n });\r\n\r\n\r\n /**\r\n * CSS class or classes to apply to the list container.\r\n * Default is undefined.\r\n */\r\n public readonly itemClass = input((item) => undefined, {\r\n transform: CssClassAttribute\r\n });\r\n\r\n public readonly focus = input<'none' | 'roving' | 'activeDescendant'>('activeDescendant');\r\n\r\n public readonly idGenerator = input<IdGenerator | undefined>(sequentialIdGenerator('ng0-list-item-'));\r\n\r\n constructor(protected _el: ElementRef<HTMLDivElement>, private _renderer: Renderer2, private _destroyRef: DestroyRef) {\r\n }\r\n\r\n ngOnInit(): void {\r\n this._loadItems();\r\n this._listenToDataSourceChanges();\r\n }\r\n\r\n /**\r\n * Sets an option as active\r\n */\r\n public active(index: number): void {\r\n if (index < 0) {\r\n throw Error();\r\n }\r\n\r\n this._activeOptionIndex.set(index);\r\n // this.scrollItemIntoView(this._activeOptionIndex(), 'nearest');\r\n }\r\n\r\n /**\r\n * Filters the list items based on the provided criteria.\r\n * @param params The filter parameters to apply.\r\n * @returns void\r\n */\r\n public filter(...params: any[]): void {\r\n let filterBy = this.filterBy();\r\n this._items().forEach(x => x.filtered = !filterBy(x.value, ...params));\r\n this._changeDetector.markForCheck();\r\n }\r\n\r\n /**\r\n * Clears any applied filters and shows all items in the list.\r\n * @returns void\r\n */\r\n public clearFilter(): void {\r\n this._items().forEach(x => x.filtered = false);\r\n }\r\n\r\n /**\r\n * Scrolls the item at the specified index into view within the dropdown list.\r\n * @param index The index of the item to scroll into view.\r\n * @param position The vertical alignment of the item after scrolling.\r\n * Can be 'start', 'center', 'end', or 'nearest'.\r\n * Default is 'nearest'.\r\n * @param behavior The scrolling behavior.\r\n */\r\n public scrollItemIntoView(index: number, position?: ScrollLogicalPosition, behavior?: ScrollBehavior) {\r\n let item = this._items()[index];\r\n let elm = this._document.getElementById(item.id) as HTMLUListElement;\r\n elm!.scrollIntoView({ block: position, behavior: behavior });\r\n }\r\n\r\n /**\r\n * Toggles the selection of an option by index\r\n */\r\n public toggleSelection(index: number) {\r\n let optionsCount = this._items().length;\r\n if (optionsCount == 0 || index < 0 || index > optionsCount - 1) {\r\n throw new Error('Index out of range');\r\n }\r\n\r\n let item = this._items()[index];\r\n let writeValueBy = this.writeBy();\r\n\r\n if (this.multiple()) {\r\n item.selected = !item.selected;\r\n let selectedValues = this._items().filter(x => x.selected).map(x => (x.value));\r\n this._value.set(selectedValues);\r\n } else {\r\n if (item.selected) {\r\n return;\r\n }\r\n let itemValue = writeValueBy(item.value);\r\n this._items().forEach(x => x.selected = false);\r\n item.selected = true;\r\n this._value.set(itemValue);\r\n }\r\n\r\n this._onChangeCallback(this._value());\r\n }\r\n\r\n writeValue(v: any): void {\r\n let value;\r\n\r\n if (this.multiple()) {\r\n if (Array.isArray(v)) {\r\n value = v;\r\n } else if (v === null || v === undefined) {\r\n value = [];\r\n } else {\r\n throw Error('Provide an array or null as the value ng0-list component');\r\n }\r\n } else {\r\n value = v;\r\n }\r\n\r\n this._value.set(value);\r\n\r\n // Update selection state of items\r\n let compareBy = this.compareBy();\r\n if (this.multiple()) {\r\n this._items().forEach(x => x.selected = (value as any[]).some(y => compareBy(x.value, y)));\r\n } else {\r\n this._items().forEach(x => x.selected = compareBy(x.value, value));\r\n }\r\n }\r\n\r\n registerOnChange(fn: any): void {\r\n this._onChangeCallback = fn;\r\n }\r\n\r\n registerOnTouched(fn: any): void {\r\n this._onTouchedCallback = fn;\r\n }\r\n\r\n setDisabledState?(isDisabled: boolean): void {\r\n this._isDisabled.set(isDisabled);\r\n }\r\n\r\n @HostListener('keydown', ['$event'])\r\n protected _onKeydown(e: KeyboardEvent, firedByFilter: boolean = false) {\r\n if (this._isDisabled())\r\n return;\r\n\r\n let optionsCount = this._items().length;\r\n if (optionsCount == 0) {\r\n return;\r\n }\r\n\r\n switch (e.key) {\r\n case 'ArrowDown':\r\n if (this._activeOptionIndex() < optionsCount - 1) {\r\n this.active(this._activeOptionIndex() + 1);\r\n }\r\n e.preventDefault();\r\n break;\r\n\r\n case 'ArrowUp':\r\n if (this._activeOptionIndex() > 0) {\r\n this.active(this._activeOptionIndex()! - 1);\r\n }\r\n e.preventDefault();\r\n break;\r\n\r\n case 'Enter':\r\n this.toggleSelection(this._activeOptionIndex());\r\n e.preventDefault();\r\n break;\r\n\r\n case 'Home':\r\n this.active(0);\r\n e.preventDefault();\r\n break;\r\n\r\n case 'End':\r\n this.active(optionsCount - 1);\r\n e.preventDefault();\r\n break;\r\n }\r\n }\r\n\r\n private _loadItems() {\r\n var r = new DataRequest();\r\n this.source().load(r).pipe(takeUntilDestroyed(this._destroyRef)).subscribe(res => {\r\n this._insertItems(0, ...res.data);\r\n });\r\n }\r\n\r\n private _listenToDataSourceChanges() {\r\n this.source().change.subscribe(e => {\r\n let options = this._items();\r\n e.changes.forEach(change => {\r\n switch (change.type) {\r\n case 'insert':\r\n this._insertItems(change.index!, ...change.items);\r\n break;\r\n case 'replace':\r\n options[change.index].value = change.value;\r\n break;\r\n case 'remove':\r\n options.splice(change.index, change.count);\r\n }\r\n });\r\n\r\n // this._changeDetector.markForCheck();\r\n });\r\n }\r\n\r\n private _insertItems(index?: number, ...items: any[]) {\r\n // let filter = this.filterBy()()\r\n let idGenerator = this.idGenerator()\r\n let compareBy = this.compareBy();\r\n let value = this._value();\r\n let isItemSelected = this.multiple() && Array.isArray(value) ?\r\n (item: any) => (value as any[]).some(x => compareBy(x.value, item)) :\r\n (item: any) => compareBy(value, item);\r\n\r\n var options = items.map(x => ({\r\n id: idGenerator ? idGenerator(x) : undefined,\r\n value: x,\r\n selected: isItemSelected(x),\r\n filtered: false,\r\n }) as ListItem)\r\n\r\n if (Number.isInteger(index)) {\r\n this._items().splice(index!, 0, ...options);\r\n } else {\r\n this._items().push(...options);\r\n }\r\n\r\n this._changeDetector.markForCheck();\r\n }\r\n}\r\n","@for (i of _items(); track $index) {\r\n@if(!i.filtered) {\r\n<div class=\"ng0-list-item\"\r\n [ngClass]=\"itemClass()(i)\"\r\n [attr.id]=\"i.id\"\r\n [class.ng0-list-item-active]=\"$index == _activeOptionIndex()\"\r\n [class.ng0-list-item-selected]=\"i.selected\"\r\n (click)=\"toggleSelection($index);\">\r\n\r\n @if(_itemTemplate) {\r\n <ng-container *ngTemplateOutlet=\"_itemTemplate; context: { $implicit: i}\" />\r\n } @else {\r\n\r\n @if(showIndicator()) {\r\n <input class=\"form-check-input ng0-list-item-indicator\"\r\n [checked]=\"i.selected\"\r\n [attr.type]=\"multiple() ? 'checkbox' : 'radio'\"\r\n [attr.name]=\"i.id\"\r\n [attr.id]=\"i.id\">\r\n }\r\n\r\n {{formatBy()(i.value)}}\r\n\r\n }\r\n</div>\r\n}\r\n}","import { NgModule } from '@angular/core';\r\nimport { ListComponent } from './list.component';\r\n\r\nconst Items = [ListComponent]\r\n\r\n/**\r\n * List module.\r\n */\r\n@NgModule({\r\n imports: Items,\r\n exports: Items\r\n})\r\nexport class ListModule { }\r\n","// export * from './types';\r\nexport * from './list.component';\r\nexport * from './list.module';\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;;;;;AAYA;;AAEG;MAyBU,aAAa,CAAA;AAiFA,IAAA,GAAA;AAAyC,IAAA,SAAA;AAA8B,IAAA,WAAA;AAhFrF,IAAA,SAAS,GAAG,MAAM,CAAC,QAAQ,CAAC;AAC5B,IAAA,GAAG,GAAG,MAAM,CAAC,mBAAmB,CAAC;AACjC,IAAA,eAAe,GAAG,MAAM,CAAC,iBAAiB,CAAC;AACzC,IAAA,MAAM,GAAG,MAAM,CAAM,SAAS,kDAAC;AACjC,IAAA,iBAAiB;AACjB,IAAA,kBAAkB;AAEP,IAAA,MAAM,GAAG,MAAM,CAAa,EAAE,kDAAC;AAC/B,IAAA,WAAW,GAAG,MAAM,CAAU,KAAK,uDAAC;AACpC,IAAA,kBAAkB,GAAG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A;gIAaoC,aAAa,EAAA,CAAA;sBAAjD,YAAY;uBAAC,WAAW;gBA+Lf,UAAU,EAAA,CAAA;sBADnB,YAAY;uBAAC,SAAS,EAAE,CAAC,QAAQ,CAAC;;;AE7OvC,MAAM,KAAK,GAAG,CAAC,aAAa,CAAC;AAE7B;;AAEG;MAKU,UAAU,CAAA;uGAAV,UAAU,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,QAAA,EAAA,CAAA;wGAAV,UAAU,EAAA,OAAA,EAAA,CATR,aAAa,CAAA,EAAA,OAAA,EAAA,CAAb,aAAa,CAAA,EAAA,CAAA;AASf,IAAA,OAAA,IAAA,GAAA,EAAA,CAAA,mBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,UAAU,YAHV,KAAK,CAAA,EAAA,CAAA;;2FAGL,UAAU,EAAA,UAAA,EAAA,CAAA;kBAJtB,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;AACN,oBAAA,OAAO,EAAE,KAAK;AACd,oBAAA,OAAO,EAAE;AACZ,iBAAA;;;ACXD;;ACAA;;AAEG;;;;"}
|
|
@@ -3,52 +3,69 @@ import { input, EventEmitter, signal, HostListener, Output, ChangeDetectionStrat
|
|
|
3
3
|
import { CommonModule } from '@angular/common';
|
|
4
4
|
|
|
5
5
|
class ModalComponent {
|
|
6
|
-
|
|
6
|
+
/**
|
|
7
|
+
* Is modal scrollable?
|
|
8
|
+
*/
|
|
9
|
+
scrollable = input(false, ...(ngDevMode ? [{ debugName: "scrollable" }] : []));
|
|
7
10
|
/** Is modal vertically centered? */
|
|
8
|
-
centered = input(false);
|
|
9
|
-
|
|
10
|
-
|
|
11
|
+
centered = input(false, ...(ngDevMode ? [{ debugName: "centered" }] : []));
|
|
12
|
+
/**
|
|
13
|
+
* Size of the modal.
|
|
14
|
+
*/
|
|
15
|
+
size = input('default', ...(ngDevMode ? [{ debugName: "size" }] : []));
|
|
16
|
+
/**
|
|
17
|
+
* Is modal fullscreen?
|
|
18
|
+
*/
|
|
19
|
+
fullscreen = input(...(ngDevMode ? [undefined, { debugName: "fullscreen" }] : []));
|
|
20
|
+
/**
|
|
21
|
+
* Emitted when user clicks the backdrop or presses the escape key.
|
|
22
|
+
*/
|
|
11
23
|
closeRequest = new EventEmitter();
|
|
24
|
+
/**
|
|
25
|
+
* Emitted when the backdrop is clicked.
|
|
26
|
+
*/
|
|
12
27
|
backdropClick = new EventEmitter();
|
|
13
|
-
_modalStatic = signal(false);
|
|
28
|
+
_modalStatic = signal(false, ...(ngDevMode ? [{ debugName: "_modalStatic" }] : []));
|
|
14
29
|
constructor() {
|
|
15
30
|
}
|
|
16
|
-
_onBackdropClick() {
|
|
17
|
-
this.
|
|
18
|
-
this.
|
|
19
|
-
|
|
20
|
-
this._modalStatic.set(false);
|
|
21
|
-
clearTimeout(timeout);
|
|
22
|
-
}, 100);
|
|
31
|
+
_onBackdropClick(event) {
|
|
32
|
+
this.closeRequest.emit({ reason: 'backdrop', event });
|
|
33
|
+
this.backdropClick.emit(event);
|
|
34
|
+
this._shakeModal(); // if user closes the modal, shake will not occure.
|
|
23
35
|
}
|
|
24
|
-
|
|
36
|
+
_onDocumentKeyDown(event) {
|
|
25
37
|
if (event.key === 'Escape') {
|
|
26
|
-
this.closeRequest.emit();
|
|
38
|
+
this.closeRequest.emit({ reason: 'escape', event });
|
|
39
|
+
this._shakeModal();
|
|
27
40
|
}
|
|
28
41
|
}
|
|
29
|
-
|
|
30
|
-
|
|
42
|
+
_shakeModal() {
|
|
43
|
+
this._modalStatic.set(true);
|
|
44
|
+
setTimeout(() => this._modalStatic.set(false), 100);
|
|
45
|
+
}
|
|
46
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.2.1", ngImport: i0, type: ModalComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
47
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "20.2.1", type: ModalComponent, isStandalone: true, selector: "ng0-modal", inputs: { scrollable: { classPropertyName: "scrollable", publicName: "scrollable", isSignal: true, isRequired: false, transformFunction: null }, centered: { classPropertyName: "centered", publicName: "centered", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, fullscreen: { classPropertyName: "fullscreen", publicName: "fullscreen", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { closeRequest: "closeRequest", backdropClick: "backdropClick" }, host: { listeners: { "document:keydown": "_onDocumentKeyDown($event)" } }, exportAs: ["ng0Modal"], ngImport: i0, template: "@let fullscreenValue=fullscreen();\r\n@let sizeValue=size();\r\n\r\n<div class=\"modal d-block\"\r\n (click)=\"$event.target == $event.currentTarget ? _onBackdropClick($event): ''\"\r\n [class.modal-static]=\"_modalStatic()\">\r\n\r\n <div class=\"modal-dialog\"\r\n [class]=\"{\r\n 'modal-dialog-scrollable': scrollable(),\r\n 'modal-dialog-centered': centered(),\r\n 'modal-fullscreen': fullscreenValue == 'always',\r\n 'modal-fullscreen-sm-down': fullscreenValue == 'sm',\r\n 'modal-fullscreen-md-down': fullscreenValue == 'md',\r\n 'modal-fullscreen-lg-down': fullscreenValue == 'lg',\r\n 'modal-fullscreen-xl-down': fullscreenValue == 'xl',\r\n 'modal-fullscreen-xxl-down': fullscreenValue == 'xxl',\r\n 'modal-sm': sizeValue == 'sm',\r\n 'modal-lg': sizeValue == 'lg',\r\n 'modal-xl': sizeValue == 'xl',\r\n }\">\r\n <div class=\"modal-content\">\r\n <ng-content></ng-content>\r\n </div>\r\n </div>\r\n</div>\r\n<div class=\"modal-backdrop fade show\"></div>", dependencies: [{ kind: "ngmodule", type: CommonModule }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
31
48
|
}
|
|
32
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.
|
|
49
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.2.1", ngImport: i0, type: ModalComponent, decorators: [{
|
|
33
50
|
type: Component,
|
|
34
51
|
args: [{ selector: 'ng0-modal', exportAs: 'ng0Modal', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, imports: [
|
|
35
52
|
CommonModule,
|
|
36
|
-
], template: "@let fullscreenValue=fullscreen();\r\n@let sizeValue=size();\r\n\r\n<div class=\"modal d-block\"\r\n (click)=\"$event.target == $event.currentTarget ? _onBackdropClick(): ''\"\r\n [class.modal-static]=\"_modalStatic()\">\r\n\r\n <div class=\"modal-dialog\"\r\n [class]=\"{\r\n 'modal-dialog-scrollable': scrollable(),\r\n 'modal-dialog-centered': centered(),\r\n 'modal-fullscreen': fullscreenValue == 'always',\r\n 'modal-fullscreen-sm-down': fullscreenValue == 'sm',\r\n 'modal-fullscreen-md-down': fullscreenValue == 'md',\r\n 'modal-fullscreen-lg-down': fullscreenValue == 'lg',\r\n 'modal-fullscreen-xl-down': fullscreenValue == 'xl',\r\n 'modal-fullscreen-xxl-down': fullscreenValue == 'xxl',\r\n 'modal-sm': sizeValue == 'sm',\r\n 'modal-lg': sizeValue == 'lg',\r\n 'modal-xl': sizeValue == 'xl',\r\n }\">\r\n <div class=\"modal-content\">\r\n <ng-content></ng-content>\r\n </div>\r\n </div>\r\n</div>\r\n<div class=\"modal-backdrop fade show\"></div>" }]
|
|
53
|
+
], template: "@let fullscreenValue=fullscreen();\r\n@let sizeValue=size();\r\n\r\n<div class=\"modal d-block\"\r\n (click)=\"$event.target == $event.currentTarget ? _onBackdropClick($event): ''\"\r\n [class.modal-static]=\"_modalStatic()\">\r\n\r\n <div class=\"modal-dialog\"\r\n [class]=\"{\r\n 'modal-dialog-scrollable': scrollable(),\r\n 'modal-dialog-centered': centered(),\r\n 'modal-fullscreen': fullscreenValue == 'always',\r\n 'modal-fullscreen-sm-down': fullscreenValue == 'sm',\r\n 'modal-fullscreen-md-down': fullscreenValue == 'md',\r\n 'modal-fullscreen-lg-down': fullscreenValue == 'lg',\r\n 'modal-fullscreen-xl-down': fullscreenValue == 'xl',\r\n 'modal-fullscreen-xxl-down': fullscreenValue == 'xxl',\r\n 'modal-sm': sizeValue == 'sm',\r\n 'modal-lg': sizeValue == 'lg',\r\n 'modal-xl': sizeValue == 'xl',\r\n }\">\r\n <div class=\"modal-content\">\r\n <ng-content></ng-content>\r\n </div>\r\n </div>\r\n</div>\r\n<div class=\"modal-backdrop fade show\"></div>" }]
|
|
37
54
|
}], ctorParameters: () => [], propDecorators: { closeRequest: [{
|
|
38
55
|
type: Output
|
|
39
56
|
}], backdropClick: [{
|
|
40
57
|
type: Output
|
|
41
|
-
}],
|
|
58
|
+
}], _onDocumentKeyDown: [{
|
|
42
59
|
type: HostListener,
|
|
43
60
|
args: ['document:keydown', ['$event']]
|
|
44
61
|
}] } });
|
|
45
62
|
|
|
46
63
|
class ModalModule {
|
|
47
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.
|
|
48
|
-
static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.
|
|
49
|
-
static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.
|
|
64
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.2.1", ngImport: i0, type: ModalModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
65
|
+
static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.2.1", ngImport: i0, type: ModalModule, imports: [ModalComponent], exports: [ModalComponent] });
|
|
66
|
+
static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.2.1", ngImport: i0, type: ModalModule, imports: [ModalComponent] });
|
|
50
67
|
}
|
|
51
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.
|
|
68
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.2.1", ngImport: i0, type: ModalModule, decorators: [{
|
|
52
69
|
type: NgModule,
|
|
53
70
|
args: [{
|
|
54
71
|
imports: [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bootkit-ng0-components-modal.mjs","sources":["../../../projects/ng0/components/modal/modal.component.ts","../../../projects/ng0/components/modal/modal.component.html","../../../projects/ng0/components/modal/modal.module.ts","../../../projects/ng0/components/modal/bootkit-ng0-components-modal.ts"],"sourcesContent":["import { Component, Output, EventEmitter, ChangeDetectionStrategy, input, signal, HostListener } from '@angular/core';\r\nimport { CommonModule } from '@angular/common';\r\nimport { ModalCloseRequest } from './types';\r\n\r\n@Component({\r\n selector: 'ng0-modal',\r\n exportAs: 'ng0Modal',\r\n templateUrl: 'modal.component.html',\r\n standalone: true,\r\n changeDetection: ChangeDetectionStrategy.OnPush,\r\n imports: [\r\n CommonModule,\r\n ]\r\n})\r\nexport class ModalComponent {\r\n public scrollable = input<boolean>(false);\r\n\r\n /** Is modal vertically centered? */\r\n public centered = input<boolean>(false);\r\n public size = input<'sm' | 'default' | 'lg' | 'xl'>('default');\r\n public fullscreen = input<'always' | 'sm' | 'md' | 'lg' | 'xl' | 'xxl'>();\r\n @Output() public closeRequest = new EventEmitter<ModalCloseRequest>();\r\n @Output() public backdropClick = new EventEmitter();\r\n\r\n protected _modalStatic = signal(false);\r\n\r\n constructor() {\r\n }\r\n\r\n protected _onBackdropClick() {\r\n this.
|
|
1
|
+
{"version":3,"file":"bootkit-ng0-components-modal.mjs","sources":["../../../projects/ng0/components/modal/modal.component.ts","../../../projects/ng0/components/modal/modal.component.html","../../../projects/ng0/components/modal/modal.module.ts","../../../projects/ng0/components/modal/bootkit-ng0-components-modal.ts"],"sourcesContent":["import { Component, Output, EventEmitter, ChangeDetectionStrategy, input, signal, HostListener } from '@angular/core';\r\nimport { CommonModule } from '@angular/common';\r\nimport { ModalCloseRequest } from './types';\r\n\r\n@Component({\r\n selector: 'ng0-modal',\r\n exportAs: 'ng0Modal',\r\n templateUrl: 'modal.component.html',\r\n standalone: true,\r\n changeDetection: ChangeDetectionStrategy.OnPush,\r\n imports: [\r\n CommonModule,\r\n ]\r\n})\r\nexport class ModalComponent {\r\n /**\r\n * Is modal scrollable?\r\n */\r\n public scrollable = input<boolean>(false);\r\n\r\n /** Is modal vertically centered? */\r\n public centered = input<boolean>(false);\r\n\r\n /**\r\n * Size of the modal.\r\n */\r\n public size = input<'sm' | 'default' | 'lg' | 'xl'>('default');\r\n\r\n /**\r\n * Is modal fullscreen?\r\n */\r\n public fullscreen = input<'always' | 'sm' | 'md' | 'lg' | 'xl' | 'xxl'>();\r\n\r\n /**\r\n * Emitted when user clicks the backdrop or presses the escape key.\r\n */\r\n @Output() public closeRequest = new EventEmitter<ModalCloseRequest>();\r\n\r\n /**\r\n * Emitted when the backdrop is clicked.\r\n */\r\n @Output() public backdropClick = new EventEmitter<Event>();\r\n\r\n protected _modalStatic = signal(false);\r\n\r\n constructor() {\r\n }\r\n\r\n protected _onBackdropClick(event: MouseEvent) {\r\n this.closeRequest.emit({ reason: 'backdrop', event });\r\n this.backdropClick.emit(event);\r\n this._shakeModal(); // if user closes the modal, shake will not occure.\r\n }\r\n\r\n @HostListener('document:keydown', ['$event'])\r\n private _onDocumentKeyDown(event: KeyboardEvent) {\r\n if (event.key === 'Escape') {\r\n this.closeRequest.emit({ reason: 'escape', event });\r\n this._shakeModal();\r\n }\r\n }\r\n\r\n private _shakeModal() {\r\n this._modalStatic.set(true);\r\n setTimeout(() => this._modalStatic.set(false), 100);\r\n }\r\n}\r\n","@let fullscreenValue=fullscreen();\r\n@let sizeValue=size();\r\n\r\n<div class=\"modal d-block\"\r\n (click)=\"$event.target == $event.currentTarget ? _onBackdropClick($event): ''\"\r\n [class.modal-static]=\"_modalStatic()\">\r\n\r\n <div class=\"modal-dialog\"\r\n [class]=\"{\r\n 'modal-dialog-scrollable': scrollable(),\r\n 'modal-dialog-centered': centered(),\r\n 'modal-fullscreen': fullscreenValue == 'always',\r\n 'modal-fullscreen-sm-down': fullscreenValue == 'sm',\r\n 'modal-fullscreen-md-down': fullscreenValue == 'md',\r\n 'modal-fullscreen-lg-down': fullscreenValue == 'lg',\r\n 'modal-fullscreen-xl-down': fullscreenValue == 'xl',\r\n 'modal-fullscreen-xxl-down': fullscreenValue == 'xxl',\r\n 'modal-sm': sizeValue == 'sm',\r\n 'modal-lg': sizeValue == 'lg',\r\n 'modal-xl': sizeValue == 'xl',\r\n }\">\r\n <div class=\"modal-content\">\r\n <ng-content></ng-content>\r\n </div>\r\n </div>\r\n</div>\r\n<div class=\"modal-backdrop fade show\"></div>","import { NgModule } from '@angular/core';\r\nimport { ModalComponent } from './modal.component';\r\n\r\n@NgModule({\r\n imports: [\r\n ModalComponent,\r\n ],\r\n exports: [\r\n ModalComponent,\r\n ]\r\n})\r\nexport class ModalModule {\r\n}\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;MAca,cAAc,CAAA;AACvB;;AAEG;AACI,IAAA,UAAU,GAAG,KAAK,CAAU,KAAK,sDAAC;;AAGlC,IAAA,QAAQ,GAAG,KAAK,CAAU,KAAK,oDAAC;AAEvC;;AAEG;AACI,IAAA,IAAI,GAAG,KAAK,CAAiC,SAAS,gDAAC;AAE9D;;AAEG;IACI,UAAU,GAAG,KAAK,CAAA,IAAA,SAAA,GAAA,CAAA,SAAA,EAAA,EAAA,SAAA,EAAA,YAAA,EAAA,CAAA,GAAA,EAAA,CAAA,CAAgD;AAEzE;;AAEG;AACc,IAAA,YAAY,GAAG,IAAI,YAAY,EAAqB;AAErE;;AAEG;AACc,IAAA,aAAa,GAAG,IAAI,YAAY,EAAS;AAEhD,IAAA,YAAY,GAAG,MAAM,CAAC,KAAK,wDAAC;AAEtC,IAAA,WAAA,GAAA;IACA;AAEU,IAAA,gBAAgB,CAAC,KAAiB,EAAA;AACxC,QAAA,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC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