@ngflux/ngflux 1.0.0
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/README.md +64 -0
- package/fesm2022/ngflux-ngflux.mjs +738 -0
- package/fesm2022/ngflux-ngflux.mjs.map +1 -0
- package/package.json +27 -0
- package/scss/_functions.scss +7 -0
- package/scss/_index.scss +4 -0
- package/scss/_mixins.scss +16 -0
- package/scss/_root.scss +13 -0
- package/scss/_system.scss +3 -0
- package/scss/_variables.scss +95 -0
- package/scss/features/_index.scss +4 -0
- package/scss/features/dialog.scss +73 -0
- package/scss/features/icons.scss +27 -0
- package/scss/features/loading.scss +7 -0
- package/scss/features/main.scss +5 -0
- package/types/ngflux-ngflux.d.ts +254 -0
|
@@ -0,0 +1,738 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { InjectionToken, signal, computed, Injectable, inject, effect, Injector, viewChild, ViewContainerRef, HostListener, Component, input, ElementRef, HostBinding, makeEnvironmentProviders, output, model, untracked } from '@angular/core';
|
|
3
|
+
import { AsyncSubject } from 'rxjs';
|
|
4
|
+
import { NgClass } from '@angular/common';
|
|
5
|
+
import * as i1 from '@angular/forms';
|
|
6
|
+
import { FormsModule } from '@angular/forms';
|
|
7
|
+
|
|
8
|
+
const NGF_CONFIG = new InjectionToken('ngf-config');
|
|
9
|
+
|
|
10
|
+
const NGF_DIALOG_DATA = new InjectionToken('ngf-dialog-data');
|
|
11
|
+
|
|
12
|
+
class NgFluxLoadingInternal {
|
|
13
|
+
entries = signal([], ...(ngDevMode ? [{ debugName: "entries" }] : /* istanbul ignore next */ []));
|
|
14
|
+
count = computed(() => this.entries().length, ...(ngDevMode ? [{ debugName: "count" }] : /* istanbul ignore next */ []));
|
|
15
|
+
isLoading = computed(() => this.count() > 0, ...(ngDevMode ? [{ debugName: "isLoading" }] : /* istanbul ignore next */ []));
|
|
16
|
+
entry = computed(() => {
|
|
17
|
+
const entries = this.entries();
|
|
18
|
+
return entries.at(entries.length - 1);
|
|
19
|
+
}, ...(ngDevMode ? [{ debugName: "entry" }] : /* istanbul ignore next */ []));
|
|
20
|
+
start = (text = '') => this.entries.update(v => {
|
|
21
|
+
const entries = Array.from(v);
|
|
22
|
+
entries.push({ text });
|
|
23
|
+
return entries;
|
|
24
|
+
});
|
|
25
|
+
stop = () => this.entries.update(v => {
|
|
26
|
+
const entries = Array.from(v);
|
|
27
|
+
entries.pop();
|
|
28
|
+
return entries;
|
|
29
|
+
});
|
|
30
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: NgFluxLoadingInternal, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
31
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: NgFluxLoadingInternal, providedIn: 'root' });
|
|
32
|
+
}
|
|
33
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: NgFluxLoadingInternal, decorators: [{
|
|
34
|
+
type: Injectable,
|
|
35
|
+
args: [{ providedIn: 'root' }]
|
|
36
|
+
}] });
|
|
37
|
+
|
|
38
|
+
class NgFluxLoading {
|
|
39
|
+
internal = inject(NgFluxLoadingInternal);
|
|
40
|
+
data = computed(() => this.internal.entry(), ...(ngDevMode ? [{ debugName: "data" }] : /* istanbul ignore next */ []));
|
|
41
|
+
isLoading = computed(() => this.internal.isLoading(), ...(ngDevMode ? [{ debugName: "isLoading" }] : /* istanbul ignore next */ []));
|
|
42
|
+
start(text = '') {
|
|
43
|
+
this.internal.start(text);
|
|
44
|
+
}
|
|
45
|
+
stop() {
|
|
46
|
+
this.internal.stop();
|
|
47
|
+
}
|
|
48
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: NgFluxLoading, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
49
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: NgFluxLoading, providedIn: 'root' });
|
|
50
|
+
}
|
|
51
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: NgFluxLoading, decorators: [{
|
|
52
|
+
type: Injectable,
|
|
53
|
+
args: [{ providedIn: 'root' }]
|
|
54
|
+
}] });
|
|
55
|
+
|
|
56
|
+
class NgFluxDialogInternal {
|
|
57
|
+
list = signal([], ...(ngDevMode ? [{ debugName: "list" }] : /* istanbul ignore next */ []));
|
|
58
|
+
count = computed(() => this.list().length, ...(ngDevMode ? [{ debugName: "count" }] : /* istanbul ignore next */ []));
|
|
59
|
+
isOpen = computed(() => this.count() > 0, ...(ngDevMode ? [{ debugName: "isOpen" }] : /* istanbul ignore next */ []));
|
|
60
|
+
active = computed(() => {
|
|
61
|
+
const entries = this.cloneList();
|
|
62
|
+
if (!entries.length)
|
|
63
|
+
return null;
|
|
64
|
+
const lastIndex = entries.length - 1;
|
|
65
|
+
return entries[lastIndex];
|
|
66
|
+
}, ...(ngDevMode ? [{ debugName: "active" }] : /* istanbul ignore next */ []));
|
|
67
|
+
root = signal(null, ...(ngDevMode ? [{ debugName: "root" }] : /* istanbul ignore next */ []));
|
|
68
|
+
constructor() {
|
|
69
|
+
const body = document.querySelector('body');
|
|
70
|
+
effect(() => {
|
|
71
|
+
const isOpen = this.isOpen();
|
|
72
|
+
body?.classList.toggle('ngf-dialog-open', isOpen);
|
|
73
|
+
});
|
|
74
|
+
window.addEventListener('popstate', e => {
|
|
75
|
+
const active = this.active();
|
|
76
|
+
if (!active)
|
|
77
|
+
return;
|
|
78
|
+
history.forward();
|
|
79
|
+
const config = active.config;
|
|
80
|
+
if (config.closeOnBackBtn) {
|
|
81
|
+
active.send({ name: 'backButton.close' });
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
cloneList = () => Array.from(this.list());
|
|
86
|
+
indexOf = (item) => {
|
|
87
|
+
const entries = this.list();
|
|
88
|
+
return entries.indexOf(item);
|
|
89
|
+
};
|
|
90
|
+
focus = () => {
|
|
91
|
+
const item = this.active();
|
|
92
|
+
item?.focus();
|
|
93
|
+
};
|
|
94
|
+
add = (...items) => {
|
|
95
|
+
const entries = this.cloneList();
|
|
96
|
+
entries.push(...items);
|
|
97
|
+
this.list.set(entries);
|
|
98
|
+
// ====================
|
|
99
|
+
history.pushState(null, '', location.href);
|
|
100
|
+
};
|
|
101
|
+
remove = (item) => {
|
|
102
|
+
history.back();
|
|
103
|
+
const entries = this.cloneList();
|
|
104
|
+
const index = this.indexOf(item);
|
|
105
|
+
entries.splice(index, 1);
|
|
106
|
+
this.list.set(entries);
|
|
107
|
+
};
|
|
108
|
+
closeAll = () => {
|
|
109
|
+
const entries = this.cloneList();
|
|
110
|
+
while (entries.length) {
|
|
111
|
+
const instance = entries.pop();
|
|
112
|
+
instance?.close(false);
|
|
113
|
+
}
|
|
114
|
+
this.list.set(entries);
|
|
115
|
+
};
|
|
116
|
+
clear = () => {
|
|
117
|
+
this.list.set([]);
|
|
118
|
+
};
|
|
119
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: NgFluxDialogInternal, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
120
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: NgFluxDialogInternal, providedIn: 'root' });
|
|
121
|
+
}
|
|
122
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: NgFluxDialogInternal, decorators: [{
|
|
123
|
+
type: Injectable,
|
|
124
|
+
args: [{ providedIn: 'root' }]
|
|
125
|
+
}], ctorParameters: () => [] });
|
|
126
|
+
|
|
127
|
+
const NGF_DIALOG_CONTENT = new InjectionToken('ngf-dialog-content');
|
|
128
|
+
const NGF_DIALOG_CONFIG = new InjectionToken('ngf-dialog-config');
|
|
129
|
+
const NGF_DIALOG_INSTANCE = new InjectionToken('ngf-dialog-instance');
|
|
130
|
+
const NGF_DIALOG_CLOSE_FN = new InjectionToken('ngf-dialog-close-fn');
|
|
131
|
+
|
|
132
|
+
class NgFluxDialogComponent {
|
|
133
|
+
injector = inject(Injector);
|
|
134
|
+
instance = inject(NgFluxDialogInstance);
|
|
135
|
+
onClosed = inject(NGF_DIALOG_CLOSE_FN);
|
|
136
|
+
content = inject(NGF_DIALOG_CONTENT);
|
|
137
|
+
config = inject(NGF_DIALOG_CONFIG);
|
|
138
|
+
viewContainer = viewChild.required('container', { read: ViewContainerRef });
|
|
139
|
+
componentRef;
|
|
140
|
+
data;
|
|
141
|
+
constructor() {
|
|
142
|
+
const { injector, content, config } = this;
|
|
143
|
+
effect((onCleanup) => {
|
|
144
|
+
const viewContainer = this.viewContainer();
|
|
145
|
+
const newInjector = Injector.create({
|
|
146
|
+
parent: injector,
|
|
147
|
+
providers: [
|
|
148
|
+
{ provide: NGF_DIALOG_DATA, useValue: config?.data ?? null },
|
|
149
|
+
]
|
|
150
|
+
});
|
|
151
|
+
this.componentRef = viewContainer.createComponent(content, {
|
|
152
|
+
injector: newInjector,
|
|
153
|
+
});
|
|
154
|
+
const { nativeElement } = this.componentRef.location;
|
|
155
|
+
nativeElement.tabIndex = -1;
|
|
156
|
+
nativeElement.classList.add('ngf-dialog-box');
|
|
157
|
+
nativeElement.focus();
|
|
158
|
+
nativeElement.addEventListener('click', this.onComponentClick);
|
|
159
|
+
nativeElement.addEventListener('animationend', this.onAnimationComplete);
|
|
160
|
+
onCleanup(() => {
|
|
161
|
+
nativeElement.removeEventListener('click', this.onComponentClick);
|
|
162
|
+
nativeElement.removeEventListener('animationend', this.onAnimationComplete);
|
|
163
|
+
});
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
onBackdropClick(e) {
|
|
167
|
+
const { instance } = this;
|
|
168
|
+
instance.send({
|
|
169
|
+
name: 'backdrop.close',
|
|
170
|
+
value: false,
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
onComponentClick = (e) => {
|
|
174
|
+
e.stopPropagation();
|
|
175
|
+
};
|
|
176
|
+
onAnimationComplete = (e) => {
|
|
177
|
+
switch (e.animationName) {
|
|
178
|
+
case 'ngfDialogOpen':
|
|
179
|
+
{ }
|
|
180
|
+
break;
|
|
181
|
+
case 'ngfDialogClose':
|
|
182
|
+
{
|
|
183
|
+
this.onClosed(this.data);
|
|
184
|
+
}
|
|
185
|
+
break;
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
focus() {
|
|
189
|
+
const ref = this.componentRef.location;
|
|
190
|
+
ref.nativeElement.focus();
|
|
191
|
+
}
|
|
192
|
+
close(data) {
|
|
193
|
+
this.data = data;
|
|
194
|
+
const ref = this.componentRef.location;
|
|
195
|
+
ref.nativeElement.classList.add('close');
|
|
196
|
+
}
|
|
197
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: NgFluxDialogComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
198
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "21.2.14", type: NgFluxDialogComponent, isStandalone: true, selector: "ngf-dialog", host: { listeners: { "click": "onBackdropClick($event)" } }, viewQueries: [{ propertyName: "viewContainer", first: true, predicate: ["container"], descendants: true, read: ViewContainerRef, isSignal: true }], ngImport: i0, template: "<div class=\"wrapper\">\n <div class=\"content\">\n <ng-template #container></ng-template>\n </div>\n</div>\n", styles: [":host{display:block;position:fixed;background-color:var(--ngf-dialog-backdrop-color)!important;visibility:visible!important;z-index:var(--ngf-dialog-z-index)!important;inset:0}:host>.wrapper{display:block;width:100%!important;height:100%!important;overflow:hidden auto}:host>.wrapper>.content{display:flex;flex-direction:column;justify-content:center;align-items:center;min-width:100%;min-height:100%}\n"] });
|
|
199
|
+
}
|
|
200
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: NgFluxDialogComponent, decorators: [{
|
|
201
|
+
type: Component,
|
|
202
|
+
args: [{ selector: 'ngf-dialog', imports: [], template: "<div class=\"wrapper\">\n <div class=\"content\">\n <ng-template #container></ng-template>\n </div>\n</div>\n", styles: [":host{display:block;position:fixed;background-color:var(--ngf-dialog-backdrop-color)!important;visibility:visible!important;z-index:var(--ngf-dialog-z-index)!important;inset:0}:host>.wrapper{display:block;width:100%!important;height:100%!important;overflow:hidden auto}:host>.wrapper>.content{display:flex;flex-direction:column;justify-content:center;align-items:center;min-width:100%;min-height:100%}\n"] }]
|
|
203
|
+
}], ctorParameters: () => [], propDecorators: { viewContainer: [{ type: i0.ViewChild, args: ['container', { ...{ read: ViewContainerRef }, isSignal: true }] }], onBackdropClick: [{
|
|
204
|
+
type: HostListener,
|
|
205
|
+
args: ['click', ['$event']]
|
|
206
|
+
}] } });
|
|
207
|
+
|
|
208
|
+
class NgFluxDialogRef {
|
|
209
|
+
onClosed;
|
|
210
|
+
constructor(onClosed) {
|
|
211
|
+
this.onClosed = onClosed;
|
|
212
|
+
}
|
|
213
|
+
close = (value) => this.onClosed({
|
|
214
|
+
name: 'close',
|
|
215
|
+
value,
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
class NgFluxDialogInstance {
|
|
220
|
+
viewContainer;
|
|
221
|
+
component;
|
|
222
|
+
injector;
|
|
223
|
+
onClosed;
|
|
224
|
+
config;
|
|
225
|
+
xDialogComponentRef = null;
|
|
226
|
+
xClosing = new AsyncSubject();
|
|
227
|
+
xAfterClosed = new AsyncSubject();
|
|
228
|
+
events = {
|
|
229
|
+
closing: this.xClosing.asObservable(),
|
|
230
|
+
closed: this.xAfterClosed.asObservable(),
|
|
231
|
+
};
|
|
232
|
+
constructor(viewContainer, component, injector, onClosed, config) {
|
|
233
|
+
this.viewContainer = viewContainer;
|
|
234
|
+
this.component = component;
|
|
235
|
+
this.injector = injector;
|
|
236
|
+
this.onClosed = onClosed;
|
|
237
|
+
this.config = config;
|
|
238
|
+
const dialogRef = new NgFluxDialogRef(this.onCommand);
|
|
239
|
+
const newInjector = Injector.create({
|
|
240
|
+
parent: injector,
|
|
241
|
+
providers: [
|
|
242
|
+
{ provide: NgFluxDialogRef, useValue: dialogRef },
|
|
243
|
+
{ provide: NGF_DIALOG_CONFIG, useValue: config },
|
|
244
|
+
{ provide: NGF_DIALOG_CONTENT, useValue: component },
|
|
245
|
+
{ provide: NGF_DIALOG_CLOSE_FN, useValue: this.afterClosedFn },
|
|
246
|
+
{ provide: NgFluxDialogInstance, useValue: this }
|
|
247
|
+
],
|
|
248
|
+
});
|
|
249
|
+
this.xDialogComponentRef = viewContainer.createComponent(NgFluxDialogComponent, {
|
|
250
|
+
injector: newInjector,
|
|
251
|
+
index: undefined
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
onCommand = (cmd) => {
|
|
255
|
+
const { config } = this;
|
|
256
|
+
switch (cmd.name) {
|
|
257
|
+
case 'esc.close':
|
|
258
|
+
{
|
|
259
|
+
if (config.closeOnEsc)
|
|
260
|
+
this.close();
|
|
261
|
+
}
|
|
262
|
+
break;
|
|
263
|
+
case 'backdrop.close':
|
|
264
|
+
{
|
|
265
|
+
if (config.backdropClose)
|
|
266
|
+
this.close();
|
|
267
|
+
}
|
|
268
|
+
break;
|
|
269
|
+
case 'backButton.close':
|
|
270
|
+
{
|
|
271
|
+
if (config.closeOnBackBtn)
|
|
272
|
+
this.close();
|
|
273
|
+
}
|
|
274
|
+
break;
|
|
275
|
+
case 'close':
|
|
276
|
+
{
|
|
277
|
+
this.close(cmd.value);
|
|
278
|
+
}
|
|
279
|
+
break;
|
|
280
|
+
}
|
|
281
|
+
};
|
|
282
|
+
afterClosedFn = (data) => {
|
|
283
|
+
const { xDialogComponentRef } = this;
|
|
284
|
+
xDialogComponentRef.destroy();
|
|
285
|
+
this.xAfterClosed.next(data ?? null);
|
|
286
|
+
this.xAfterClosed.complete();
|
|
287
|
+
this.onClosed(this);
|
|
288
|
+
};
|
|
289
|
+
focus() {
|
|
290
|
+
const { xDialogComponentRef: { instance } } = this;
|
|
291
|
+
instance.focus();
|
|
292
|
+
}
|
|
293
|
+
close(data) {
|
|
294
|
+
const { xDialogComponentRef } = this;
|
|
295
|
+
this.xClosing.next(data ?? null);
|
|
296
|
+
this.xClosing.complete();
|
|
297
|
+
xDialogComponentRef.instance.close(data);
|
|
298
|
+
}
|
|
299
|
+
send(cmd) {
|
|
300
|
+
this.onCommand(cmd);
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
class NgFluxDialogHeaderComponent {
|
|
305
|
+
config = inject(NGF_DIALOG_CONFIG);
|
|
306
|
+
dialogRef = inject(NgFluxDialogRef);
|
|
307
|
+
icon = input(...(ngDevMode ? [undefined, { debugName: "icon" }] : /* istanbul ignore next */ []));
|
|
308
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: NgFluxDialogHeaderComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
309
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.14", type: NgFluxDialogHeaderComponent, isStandalone: true, selector: "ngf-dialog-header", inputs: { icon: { classPropertyName: "icon", publicName: "icon", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: "@if (icon(); as ico) {\n <div class=\"left\">\n <i [ngClass]=\"ico\"></i>\n </div>\n}\n\n<div class=\"middle\">\n <ng-content></ng-content>\n</div>\n\n@if (config.closeBtn) {\n <div class=\"right\" title=\"Close\" (click)=\"dialogRef.close()\">\n <i class=\"ngf-icon close\"></i>\n </div>\n}\n", styles: [":host{display:flex;flex-direction:row;position:sticky;background-color:var(--ngf-dialog-background-color)!important;border-bottom:var(--ngf-dialog-border)!important;min-height:50px;top:0}:host>.left{display:flex;flex-direction:row;justify-content:center;align-items:center;padding:10px}:host>.middle{display:flex;flex-direction:column;justify-content:center;align-items:start;overflow:hidden;text-overflow:ellipsis;padding:10px 20px;flex:1 0 0;width:0px}:host>.right{display:flex;flex-direction:row;justify-content:center;align-items:center;cursor:pointer;padding:10px}\n"], dependencies: [{ kind: "directive", type: NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }] });
|
|
310
|
+
}
|
|
311
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: NgFluxDialogHeaderComponent, decorators: [{
|
|
312
|
+
type: Component,
|
|
313
|
+
args: [{ selector: 'ngf-dialog-header', imports: [
|
|
314
|
+
NgClass,
|
|
315
|
+
], template: "@if (icon(); as ico) {\n <div class=\"left\">\n <i [ngClass]=\"ico\"></i>\n </div>\n}\n\n<div class=\"middle\">\n <ng-content></ng-content>\n</div>\n\n@if (config.closeBtn) {\n <div class=\"right\" title=\"Close\" (click)=\"dialogRef.close()\">\n <i class=\"ngf-icon close\"></i>\n </div>\n}\n", styles: [":host{display:flex;flex-direction:row;position:sticky;background-color:var(--ngf-dialog-background-color)!important;border-bottom:var(--ngf-dialog-border)!important;min-height:50px;top:0}:host>.left{display:flex;flex-direction:row;justify-content:center;align-items:center;padding:10px}:host>.middle{display:flex;flex-direction:column;justify-content:center;align-items:start;overflow:hidden;text-overflow:ellipsis;padding:10px 20px;flex:1 0 0;width:0px}:host>.right{display:flex;flex-direction:row;justify-content:center;align-items:center;cursor:pointer;padding:10px}\n"] }]
|
|
316
|
+
}], propDecorators: { icon: [{ type: i0.Input, args: [{ isSignal: true, alias: "icon", required: false }] }] } });
|
|
317
|
+
|
|
318
|
+
class NgFluxDialogBodyComponent {
|
|
319
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: NgFluxDialogBodyComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
320
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "21.2.14", type: NgFluxDialogBodyComponent, isStandalone: true, selector: "ngf-dialog-body", ngImport: i0, template: "<ng-content></ng-content>\n", styles: [":host{display:block;padding:20px}\n"] });
|
|
321
|
+
}
|
|
322
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: NgFluxDialogBodyComponent, decorators: [{
|
|
323
|
+
type: Component,
|
|
324
|
+
args: [{ selector: 'ngf-dialog-body', imports: [], template: "<ng-content></ng-content>\n", styles: [":host{display:block;padding:20px}\n"] }]
|
|
325
|
+
}] });
|
|
326
|
+
|
|
327
|
+
class NgFluxDialogFooterComponent {
|
|
328
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: NgFluxDialogFooterComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
329
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "21.2.14", type: NgFluxDialogFooterComponent, isStandalone: true, selector: "ngf-dialog-footer", ngImport: i0, template: "<ng-content></ng-content>\n", styles: [":host{display:flex;flex-direction:row;align-items:center;justify-content:end;position:sticky;background-color:var(--ngf-dialog-background-color)!important;border-top:var(--ngf-dialog-border)!important;padding:7px 15px;bottom:0;gap:10px}\n"] });
|
|
330
|
+
}
|
|
331
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: NgFluxDialogFooterComponent, decorators: [{
|
|
332
|
+
type: Component,
|
|
333
|
+
args: [{ selector: 'ngf-dialog-footer', imports: [], template: "<ng-content></ng-content>\n", styles: [":host{display:flex;flex-direction:row;align-items:center;justify-content:end;position:sticky;background-color:var(--ngf-dialog-background-color)!important;border-top:var(--ngf-dialog-border)!important;padding:7px 15px;bottom:0;gap:10px}\n"] }]
|
|
334
|
+
}] });
|
|
335
|
+
|
|
336
|
+
class NgFluxButton {
|
|
337
|
+
ref = inject(ElementRef);
|
|
338
|
+
icon = input(...(ngDevMode ? [undefined, { debugName: "icon" }] : /* istanbul ignore next */ []));
|
|
339
|
+
theme = input(...(ngDevMode ? [undefined, { debugName: "theme" }] : /* istanbul ignore next */ []));
|
|
340
|
+
type = input(...(ngDevMode ? [undefined, { debugName: "type" }] : /* istanbul ignore next */ []));
|
|
341
|
+
size = input(...(ngDevMode ? [undefined, { debugName: "size" }] : /* istanbul ignore next */ []));
|
|
342
|
+
direction = input(...(ngDevMode ? [undefined, { debugName: "direction" }] : /* istanbul ignore next */ []));
|
|
343
|
+
block = input(false, ...(ngDevMode ? [{ debugName: "block" }] : /* istanbul ignore next */ []));
|
|
344
|
+
disabled = input(false, ...(ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []));
|
|
345
|
+
btnClassNames = computed(() => {
|
|
346
|
+
const names = [];
|
|
347
|
+
const direction = this.direction() ?? 'normal';
|
|
348
|
+
if (direction === 'reversed')
|
|
349
|
+
names.push(direction);
|
|
350
|
+
return names;
|
|
351
|
+
}, ...(ngDevMode ? [{ debugName: "btnClassNames" }] : /* istanbul ignore next */ []));
|
|
352
|
+
classNames = computed(() => [
|
|
353
|
+
this.theme() ?? 'default',
|
|
354
|
+
this.size() ?? 'md',
|
|
355
|
+
].join(' '), ...(ngDevMode ? [{ debugName: "classNames" }] : /* istanbul ignore next */ []));
|
|
356
|
+
get bindClass() { return this.classNames(); }
|
|
357
|
+
get isBlock() { return this.block(); }
|
|
358
|
+
get isDisabled() { return this.disabled(); }
|
|
359
|
+
constructor() {
|
|
360
|
+
const { ref: { nativeElement } } = this;
|
|
361
|
+
nativeElement.tabIndex = 1;
|
|
362
|
+
}
|
|
363
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: NgFluxButton, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
364
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.14", type: NgFluxButton, isStandalone: true, selector: "ngf-button", inputs: { icon: { classPropertyName: "icon", publicName: "icon", isSignal: true, isRequired: false, transformFunction: null }, theme: { classPropertyName: "theme", publicName: "theme", isSignal: true, isRequired: false, transformFunction: null }, type: { classPropertyName: "type", publicName: "type", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, direction: { classPropertyName: "direction", publicName: "direction", isSignal: true, isRequired: false, transformFunction: null }, block: { classPropertyName: "block", publicName: "block", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class": "this.bindClass", "class.block": "this.isBlock", "class.disabled": "this.isDisabled" } }, ngImport: i0, template: "<button [type]=\"type()\" [disabled]=\"disabled()\">\n <div class=\"wrapper\" [ngClass]=\"btnClassNames()\">\n @if (icon(); as ico) {\n <div class=\"icon\">\n <i [ngClass]=\"ico\"></i>\n </div>\n }\n\n <div class=\"content\">\n <div>\n <ng-content></ng-content>\n </div>\n </div>\n </div>\n</button>\n", styles: [":host{display:inline-block;border:1px solid rgba(0,0,0,.2);border-radius:3px;cursor:pointer;font-size:1rem;overflow:clip}:host.block{display:block}:host.disabled{opacity:.5!important;-webkit-user-select:none!important;user-select:none!important;cursor:not-allowed}:host.xs{font-size:.6rem}:host.sm{font-size:.8rem}:host.md{font-size:1rem}:host.lg{font-size:1.25rem}:host.xl{font-size:1.5rem}:host.default{background-color:var(--ngf-default)!important;color:var(--ngf-default-fg)!important}:host.primary{background-color:var(--ngf-primary)!important;color:var(--ngf-primary-fg)!important}:host.secondary{background-color:var(--ngf-secondary)!important;color:var(--ngf-secondary-fg)!important}:host.error{background-color:var(--ngf-error)!important;color:var(--ngf-error-fg)!important}:host.danger{background-color:var(--ngf-danger)!important;color:var(--ngf-danger-fg)!important}:host.success{background-color:var(--ngf-success)!important;color:var(--ngf-success-fg)!important}:host.warning{background-color:var(--ngf-warning)!important;color:var(--ngf-warning-fg)!important}:host.info{background-color:var(--ngf-info)!important;color:var(--ngf-info-fg)!important}:host.light{background-color:var(--ngf-light)!important;color:var(--ngf-light-fg)!important}:host.dark{background-color:var(--ngf-dark)!important;color:var(--ngf-dark-fg)!important}:host>button{display:block;padding:0!important;background-color:transparent;border:none!important;width:100%!important;cursor:inherit!important;color:inherit!important;font-weight:500;font-size:1em}:host>button:focus{outline:none!important}:host .wrapper{display:flex;flex-direction:var(--flex-direction)!important;--flex-direction: row;--icon-border-left: none;--icon-border-right: 1px solid rgba(0, 0, 0, .2)}:host .wrapper.reversed{--flex-direction: row-reverse;--icon-border-left: 1px solid rgba(0, 0, 0, .2);--icon-border-right: none}:host .wrapper>.icon{display:flex;flex-direction:column;justify-content:center;align-items:center;font-size:1.05em;border-left:var(--icon-border-left)!important;border-right:var(--icon-border-right)!important;padding:0 .5em}:host .wrapper>.content{display:block;flex-grow:1;padding:.5em 1em;white-space:nowrap!important;text-align:center!important;text-overflow:ellipsis;overflow:hidden}\n"], dependencies: [{ kind: "directive", type: NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }] });
|
|
365
|
+
}
|
|
366
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: NgFluxButton, decorators: [{
|
|
367
|
+
type: Component,
|
|
368
|
+
args: [{ selector: 'ngf-button', imports: [NgClass], template: "<button [type]=\"type()\" [disabled]=\"disabled()\">\n <div class=\"wrapper\" [ngClass]=\"btnClassNames()\">\n @if (icon(); as ico) {\n <div class=\"icon\">\n <i [ngClass]=\"ico\"></i>\n </div>\n }\n\n <div class=\"content\">\n <div>\n <ng-content></ng-content>\n </div>\n </div>\n </div>\n</button>\n", styles: [":host{display:inline-block;border:1px solid rgba(0,0,0,.2);border-radius:3px;cursor:pointer;font-size:1rem;overflow:clip}:host.block{display:block}:host.disabled{opacity:.5!important;-webkit-user-select:none!important;user-select:none!important;cursor:not-allowed}:host.xs{font-size:.6rem}:host.sm{font-size:.8rem}:host.md{font-size:1rem}:host.lg{font-size:1.25rem}:host.xl{font-size:1.5rem}:host.default{background-color:var(--ngf-default)!important;color:var(--ngf-default-fg)!important}:host.primary{background-color:var(--ngf-primary)!important;color:var(--ngf-primary-fg)!important}:host.secondary{background-color:var(--ngf-secondary)!important;color:var(--ngf-secondary-fg)!important}:host.error{background-color:var(--ngf-error)!important;color:var(--ngf-error-fg)!important}:host.danger{background-color:var(--ngf-danger)!important;color:var(--ngf-danger-fg)!important}:host.success{background-color:var(--ngf-success)!important;color:var(--ngf-success-fg)!important}:host.warning{background-color:var(--ngf-warning)!important;color:var(--ngf-warning-fg)!important}:host.info{background-color:var(--ngf-info)!important;color:var(--ngf-info-fg)!important}:host.light{background-color:var(--ngf-light)!important;color:var(--ngf-light-fg)!important}:host.dark{background-color:var(--ngf-dark)!important;color:var(--ngf-dark-fg)!important}:host>button{display:block;padding:0!important;background-color:transparent;border:none!important;width:100%!important;cursor:inherit!important;color:inherit!important;font-weight:500;font-size:1em}:host>button:focus{outline:none!important}:host .wrapper{display:flex;flex-direction:var(--flex-direction)!important;--flex-direction: row;--icon-border-left: none;--icon-border-right: 1px solid rgba(0, 0, 0, .2)}:host .wrapper.reversed{--flex-direction: row-reverse;--icon-border-left: 1px solid rgba(0, 0, 0, .2);--icon-border-right: none}:host .wrapper>.icon{display:flex;flex-direction:column;justify-content:center;align-items:center;font-size:1.05em;border-left:var(--icon-border-left)!important;border-right:var(--icon-border-right)!important;padding:0 .5em}:host .wrapper>.content{display:block;flex-grow:1;padding:.5em 1em;white-space:nowrap!important;text-align:center!important;text-overflow:ellipsis;overflow:hidden}\n"] }]
|
|
369
|
+
}], ctorParameters: () => [], propDecorators: { icon: [{ type: i0.Input, args: [{ isSignal: true, alias: "icon", required: false }] }], theme: [{ type: i0.Input, args: [{ isSignal: true, alias: "theme", required: false }] }], type: [{ type: i0.Input, args: [{ isSignal: true, alias: "type", required: false }] }], size: [{ type: i0.Input, args: [{ isSignal: true, alias: "size", required: false }] }], direction: [{ type: i0.Input, args: [{ isSignal: true, alias: "direction", required: false }] }], block: [{ type: i0.Input, args: [{ isSignal: true, alias: "block", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], bindClass: [{
|
|
370
|
+
type: HostBinding,
|
|
371
|
+
args: ['class']
|
|
372
|
+
}], isBlock: [{
|
|
373
|
+
type: HostBinding,
|
|
374
|
+
args: ['class.block']
|
|
375
|
+
}], isDisabled: [{
|
|
376
|
+
type: HostBinding,
|
|
377
|
+
args: ['class.disabled']
|
|
378
|
+
}] } });
|
|
379
|
+
|
|
380
|
+
class NgFluxAlertDialog {
|
|
381
|
+
config = inject(NGF_CONFIG);
|
|
382
|
+
dialogRef = inject(NgFluxDialogRef);
|
|
383
|
+
options = inject(NGF_DIALOG_DATA);
|
|
384
|
+
buttons = computed(() => {
|
|
385
|
+
const config = this.config.dialog?.alert || {};
|
|
386
|
+
return this.options.buttons ?? [
|
|
387
|
+
Object.assign({
|
|
388
|
+
text: 'Okay',
|
|
389
|
+
theme: 'primary',
|
|
390
|
+
onClick: (e, btn, ref) => ref.close(),
|
|
391
|
+
}, config.okayButton),
|
|
392
|
+
];
|
|
393
|
+
}, ...(ngDevMode ? [{ debugName: "buttons" }] : /* istanbul ignore next */ []));
|
|
394
|
+
onButtonClick(e, btn) {
|
|
395
|
+
const { dialogRef } = this;
|
|
396
|
+
if (btn.onClick) {
|
|
397
|
+
btn.onClick(e, btn, dialogRef);
|
|
398
|
+
}
|
|
399
|
+
else {
|
|
400
|
+
dialogRef.close();
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: NgFluxAlertDialog, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
404
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.14", type: NgFluxAlertDialog, isStandalone: true, selector: "ngf-dialog-box-alert", ngImport: i0, template: "<ngf-dialog-header>\n <h1 ngf-dialog-title>{{ options.title }}</h1>\n</ngf-dialog-header>\n\n<ngf-dialog-body>\n <div [innerHTML]=\"options.content\"></div>\n</ngf-dialog-body>\n\n<ngf-dialog-footer>\n @for (btn of buttons(); track $index) {\n @switch (btn) {\n @case ('flex') {<div ngf-flex-x></div>}\n\n @default {\n <ngf-button [theme]=\"btn.theme\" [size]=\"btn.size\" [direction]=\"btn.direction\" (click)=\"onButtonClick($event, btn)\">\n <span>{{ btn.text }}</span>\n </ngf-button>\n }\n }\n }\n</ngf-dialog-footer>\n", styles: [":host{display:block;width:90%;max-width:500px;background-color:#fff}\n"], dependencies: [{ kind: "component", type: NgFluxButton, selector: "ngf-button", inputs: ["icon", "theme", "type", "size", "direction", "block", "disabled"] }, { kind: "component", type: NgFluxDialogHeaderComponent, selector: "ngf-dialog-header", inputs: ["icon"] }, { kind: "component", type: NgFluxDialogBodyComponent, selector: "ngf-dialog-body" }, { kind: "component", type: NgFluxDialogFooterComponent, selector: "ngf-dialog-footer" }] });
|
|
405
|
+
}
|
|
406
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: NgFluxAlertDialog, decorators: [{
|
|
407
|
+
type: Component,
|
|
408
|
+
args: [{ selector: 'ngf-dialog-box-alert', imports: [
|
|
409
|
+
NgFluxButton,
|
|
410
|
+
NgFluxDialogHeaderComponent,
|
|
411
|
+
NgFluxDialogBodyComponent,
|
|
412
|
+
NgFluxDialogFooterComponent,
|
|
413
|
+
], template: "<ngf-dialog-header>\n <h1 ngf-dialog-title>{{ options.title }}</h1>\n</ngf-dialog-header>\n\n<ngf-dialog-body>\n <div [innerHTML]=\"options.content\"></div>\n</ngf-dialog-body>\n\n<ngf-dialog-footer>\n @for (btn of buttons(); track $index) {\n @switch (btn) {\n @case ('flex') {<div ngf-flex-x></div>}\n\n @default {\n <ngf-button [theme]=\"btn.theme\" [size]=\"btn.size\" [direction]=\"btn.direction\" (click)=\"onButtonClick($event, btn)\">\n <span>{{ btn.text }}</span>\n </ngf-button>\n }\n }\n }\n</ngf-dialog-footer>\n", styles: [":host{display:block;width:90%;max-width:500px;background-color:#fff}\n"] }]
|
|
414
|
+
}] });
|
|
415
|
+
|
|
416
|
+
class NgFluxConfirmDialog {
|
|
417
|
+
config = inject(NGF_CONFIG);
|
|
418
|
+
dialogRef = inject(NgFluxDialogRef);
|
|
419
|
+
options = inject(NGF_DIALOG_DATA);
|
|
420
|
+
buttons = computed(() => {
|
|
421
|
+
const config = this.config.dialog?.prompt ?? {};
|
|
422
|
+
return [
|
|
423
|
+
this.options.cancelButton ?? Object.assign({
|
|
424
|
+
text: 'Cancel',
|
|
425
|
+
theme: 'dark',
|
|
426
|
+
onClick: (e, btn, dialogRef) => dialogRef.close(),
|
|
427
|
+
}, config.cancelButton),
|
|
428
|
+
this.options.okayButton ?? Object.assign({
|
|
429
|
+
text: 'Okay',
|
|
430
|
+
theme: 'primary',
|
|
431
|
+
onClick: (e, btn, dialogRef) => dialogRef.close(true),
|
|
432
|
+
}, config.submitButton),
|
|
433
|
+
];
|
|
434
|
+
}, ...(ngDevMode ? [{ debugName: "buttons" }] : /* istanbul ignore next */ []));
|
|
435
|
+
onButtonClick(e, btn) {
|
|
436
|
+
btn.onClick?.call(null, e, btn, this.dialogRef);
|
|
437
|
+
}
|
|
438
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: NgFluxConfirmDialog, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
439
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.14", type: NgFluxConfirmDialog, isStandalone: true, selector: "ngf-dialog-box-confirm", ngImport: i0, template: "<ngf-dialog-header>\n <h1 ngf-dialog-title>{{ options.title }}</h1>\n</ngf-dialog-header>\n\n<ngf-dialog-body>\n <div [innerHTML]=\"options.content\"></div>\n</ngf-dialog-body>\n\n<ngf-dialog-footer>\n @for (btn of buttons(); track $index) {\n <ngf-button [theme]=\"btn.theme\" (click)=\"onButtonClick($event, btn)\">\n <span>{{ btn.text }}</span>\n </ngf-button>\n }\n</ngf-dialog-footer>\n", styles: [":host{display:block;width:90%;max-width:500px;background-color:#fff}\n"], dependencies: [{ kind: "component", type: NgFluxButton, selector: "ngf-button", inputs: ["icon", "theme", "type", "size", "direction", "block", "disabled"] }, { kind: "component", type: NgFluxDialogHeaderComponent, selector: "ngf-dialog-header", inputs: ["icon"] }, { kind: "component", type: NgFluxDialogFooterComponent, selector: "ngf-dialog-footer" }, { kind: "component", type: NgFluxDialogBodyComponent, selector: "ngf-dialog-body" }] });
|
|
440
|
+
}
|
|
441
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: NgFluxConfirmDialog, decorators: [{
|
|
442
|
+
type: Component,
|
|
443
|
+
args: [{ selector: 'ngf-dialog-box-confirm', imports: [
|
|
444
|
+
NgFluxButton,
|
|
445
|
+
NgFluxDialogHeaderComponent,
|
|
446
|
+
NgFluxDialogFooterComponent,
|
|
447
|
+
NgFluxDialogBodyComponent,
|
|
448
|
+
], template: "<ngf-dialog-header>\n <h1 ngf-dialog-title>{{ options.title }}</h1>\n</ngf-dialog-header>\n\n<ngf-dialog-body>\n <div [innerHTML]=\"options.content\"></div>\n</ngf-dialog-body>\n\n<ngf-dialog-footer>\n @for (btn of buttons(); track $index) {\n <ngf-button [theme]=\"btn.theme\" (click)=\"onButtonClick($event, btn)\">\n <span>{{ btn.text }}</span>\n </ngf-button>\n }\n</ngf-dialog-footer>\n", styles: [":host{display:block;width:90%;max-width:500px;background-color:#fff}\n"] }]
|
|
449
|
+
}] });
|
|
450
|
+
|
|
451
|
+
class NgFluxPromptDialog {
|
|
452
|
+
config = inject(NGF_CONFIG);
|
|
453
|
+
dialogRef = inject(NgFluxDialogRef);
|
|
454
|
+
options = inject(NGF_DIALOG_DATA);
|
|
455
|
+
text = signal('', ...(ngDevMode ? [{ debugName: "text" }] : /* istanbul ignore next */ []));
|
|
456
|
+
value = computed(() => this.text().trim(), ...(ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []));
|
|
457
|
+
buttons = computed(() => {
|
|
458
|
+
const config = this.config.dialog?.prompt ?? {};
|
|
459
|
+
const value = this.value();
|
|
460
|
+
return [
|
|
461
|
+
this.options.cancelButton ?? Object.assign({
|
|
462
|
+
text: 'Cancel',
|
|
463
|
+
theme: 'dark',
|
|
464
|
+
onClick: (e, btn, dialogRef) => dialogRef.close(),
|
|
465
|
+
}, config.cancelButton),
|
|
466
|
+
this.options.submitButton ?? Object.assign({
|
|
467
|
+
text: 'Submit',
|
|
468
|
+
theme: 'primary',
|
|
469
|
+
onClick: (e, btn, dialogRef) => dialogRef.close(value),
|
|
470
|
+
disabled: () => !value,
|
|
471
|
+
}, config.submitButton),
|
|
472
|
+
];
|
|
473
|
+
}, ...(ngDevMode ? [{ debugName: "buttons" }] : /* istanbul ignore next */ []));
|
|
474
|
+
onButtonClick(e, btn) {
|
|
475
|
+
btn.onClick?.call(null, e, btn, this.dialogRef);
|
|
476
|
+
}
|
|
477
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: NgFluxPromptDialog, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
478
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.14", type: NgFluxPromptDialog, isStandalone: true, selector: "ngf-dialog-box-prompt", ngImport: i0, template: "<ngf-dialog-header>\n <h1 ngf-dialog-title>{{ options.title }}</h1>\n</ngf-dialog-header>\n\n<ngf-dialog-body>\n <div class=\"content\" [innerHTML]=\"options.content\"></div>\n <input type=\"text\" name=\"text\" [(ngModel)]=\"text\">\n</ngf-dialog-body>\n\n<ngf-dialog-footer>\n @for (btn of buttons(); track $index) {\n <ngf-button [theme]=\"btn.theme\" (click)=\"onButtonClick($event, btn)\" [disabled]=\"btn.disabled?.() ?? false\">\n <span>{{ btn.text }}</span>\n </ngf-button>\n }\n</ngf-dialog-footer>\n", styles: [":host{display:block;width:90%;max-width:350px;background-color:#fff}:host .content{margin:0 0 10px}:host input{display:block;width:100%!important;border:1px solid #DDD;background-color:#fff;padding:10px 15px;font-size:1.2rem}:host input:focus{outline:2px solid #DDD;box-shadow:none!important}\n"], dependencies: [{ kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "component", type: NgFluxButton, selector: "ngf-button", inputs: ["icon", "theme", "type", "size", "direction", "block", "disabled"] }, { kind: "component", type: NgFluxDialogHeaderComponent, selector: "ngf-dialog-header", inputs: ["icon"] }, { kind: "component", type: NgFluxDialogFooterComponent, selector: "ngf-dialog-footer" }, { kind: "component", type: NgFluxDialogBodyComponent, selector: "ngf-dialog-body" }] });
|
|
479
|
+
}
|
|
480
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: NgFluxPromptDialog, decorators: [{
|
|
481
|
+
type: Component,
|
|
482
|
+
args: [{ selector: 'ngf-dialog-box-prompt', imports: [
|
|
483
|
+
FormsModule,
|
|
484
|
+
NgFluxButton,
|
|
485
|
+
NgFluxDialogHeaderComponent,
|
|
486
|
+
NgFluxDialogFooterComponent,
|
|
487
|
+
NgFluxDialogBodyComponent,
|
|
488
|
+
], template: "<ngf-dialog-header>\n <h1 ngf-dialog-title>{{ options.title }}</h1>\n</ngf-dialog-header>\n\n<ngf-dialog-body>\n <div class=\"content\" [innerHTML]=\"options.content\"></div>\n <input type=\"text\" name=\"text\" [(ngModel)]=\"text\">\n</ngf-dialog-body>\n\n<ngf-dialog-footer>\n @for (btn of buttons(); track $index) {\n <ngf-button [theme]=\"btn.theme\" (click)=\"onButtonClick($event, btn)\" [disabled]=\"btn.disabled?.() ?? false\">\n <span>{{ btn.text }}</span>\n </ngf-button>\n }\n</ngf-dialog-footer>\n", styles: [":host{display:block;width:90%;max-width:350px;background-color:#fff}:host .content{margin:0 0 10px}:host input{display:block;width:100%!important;border:1px solid #DDD;background-color:#fff;padding:10px 15px;font-size:1.2rem}:host input:focus{outline:2px solid #DDD;box-shadow:none!important}\n"] }]
|
|
489
|
+
}] });
|
|
490
|
+
|
|
491
|
+
class NgFluxDialog {
|
|
492
|
+
internal = inject(NgFluxDialogInternal);
|
|
493
|
+
open(component, config) {
|
|
494
|
+
config ??= {};
|
|
495
|
+
config.backdropClose ??= true;
|
|
496
|
+
config.closeBtn ??= true;
|
|
497
|
+
config.closeOnBackBtn ??= true;
|
|
498
|
+
config.closeOnEsc ??= true;
|
|
499
|
+
const { internal } = this;
|
|
500
|
+
const root = internal.root();
|
|
501
|
+
if (!root)
|
|
502
|
+
throw new Error('"ngf-dialog-root" component not found. ' +
|
|
503
|
+
'Use "<ngf-root></ngf-root>" in your root component to enable all NgFlux features or ' +
|
|
504
|
+
'add "<ngf-dialog-root></ngf-dialog-root>" to your root component to enable the NgFluxDialog feature.');
|
|
505
|
+
const onClosed = (ins) => {
|
|
506
|
+
internal.remove(ins);
|
|
507
|
+
};
|
|
508
|
+
const instance = new NgFluxDialogInstance(root.viewContainer(), component, root.injector, onClosed, config);
|
|
509
|
+
internal.add(instance);
|
|
510
|
+
return instance.events;
|
|
511
|
+
}
|
|
512
|
+
closeAll = () => this.internal.closeAll();
|
|
513
|
+
alert(title, content, buttons) {
|
|
514
|
+
const data = { title, content, buttons };
|
|
515
|
+
const dialog = this.open(NgFluxAlertDialog, {
|
|
516
|
+
closeOnBackBtn: false,
|
|
517
|
+
backdropClose: false,
|
|
518
|
+
closeOnEsc: false,
|
|
519
|
+
data
|
|
520
|
+
});
|
|
521
|
+
return dialog.closed;
|
|
522
|
+
}
|
|
523
|
+
success(title, message, buttons) {
|
|
524
|
+
message = `<div class="mbi-success">${message}</div>`;
|
|
525
|
+
return this.alert(title, message, buttons);
|
|
526
|
+
}
|
|
527
|
+
error(title, message, buttons) {
|
|
528
|
+
message = `<div class="mbi-error">${message}</div>`;
|
|
529
|
+
return this.alert(title, message, buttons);
|
|
530
|
+
}
|
|
531
|
+
confirm(data) {
|
|
532
|
+
const dialog = this.open(NgFluxConfirmDialog, {
|
|
533
|
+
closeOnBackBtn: false,
|
|
534
|
+
backdropClose: false,
|
|
535
|
+
closeOnEsc: false,
|
|
536
|
+
data
|
|
537
|
+
});
|
|
538
|
+
return dialog.closed;
|
|
539
|
+
}
|
|
540
|
+
prompt(data) {
|
|
541
|
+
const dialog = this.open(NgFluxPromptDialog, {
|
|
542
|
+
closeOnBackBtn: false,
|
|
543
|
+
backdropClose: false,
|
|
544
|
+
closeOnEsc: false,
|
|
545
|
+
data
|
|
546
|
+
});
|
|
547
|
+
return dialog.closed;
|
|
548
|
+
}
|
|
549
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: NgFluxDialog, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
550
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: NgFluxDialog, providedIn: 'root' });
|
|
551
|
+
}
|
|
552
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: NgFluxDialog, decorators: [{
|
|
553
|
+
type: Injectable,
|
|
554
|
+
args: [{ providedIn: 'root' }]
|
|
555
|
+
}] });
|
|
556
|
+
|
|
557
|
+
const provideNgFlux = (config) => {
|
|
558
|
+
config ??= {};
|
|
559
|
+
return makeEnvironmentProviders([
|
|
560
|
+
{ provide: NGF_CONFIG, useValue: config },
|
|
561
|
+
NgFluxDialog,
|
|
562
|
+
NgFluxDialogInternal,
|
|
563
|
+
NgFluxLoading,
|
|
564
|
+
NgFluxLoadingInternal,
|
|
565
|
+
]);
|
|
566
|
+
};
|
|
567
|
+
|
|
568
|
+
class NgFluxDialogRootComponent {
|
|
569
|
+
internal = inject(NgFluxDialogInternal);
|
|
570
|
+
injector = inject(Injector);
|
|
571
|
+
viewContainer = viewChild.required('container', { read: ViewContainerRef });
|
|
572
|
+
constructor() {
|
|
573
|
+
const { internal } = this;
|
|
574
|
+
internal.root.set(this);
|
|
575
|
+
}
|
|
576
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: NgFluxDialogRootComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
577
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "21.2.14", type: NgFluxDialogRootComponent, isStandalone: true, selector: "ngf-dialog-root", viewQueries: [{ propertyName: "viewContainer", first: true, predicate: ["container"], descendants: true, read: ViewContainerRef, isSignal: true }], ngImport: i0, template: "<ng-template #container></ng-template>\n", styles: [":host{display:block;width:0px;height:0px;visibility:hidden}\n"] });
|
|
578
|
+
}
|
|
579
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: NgFluxDialogRootComponent, decorators: [{
|
|
580
|
+
type: Component,
|
|
581
|
+
args: [{ selector: 'ngf-dialog-root', imports: [], template: "<ng-template #container></ng-template>\n", styles: [":host{display:block;width:0px;height:0px;visibility:hidden}\n"] }]
|
|
582
|
+
}], ctorParameters: () => [], propDecorators: { viewContainer: [{ type: i0.ViewChild, args: ['container', { ...{ read: ViewContainerRef }, isSignal: true }] }] } });
|
|
583
|
+
|
|
584
|
+
class NgFluxLoadingComponent {
|
|
585
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: NgFluxLoadingComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
586
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "21.2.14", type: NgFluxLoadingComponent, isStandalone: true, selector: "ngf-loading", ngImport: i0, template: "<svg viewBox=\"25 25 50 50\">\n <circle r=\"20\" cy=\"50\" cx=\"50\"></circle>\n</svg>\n", styles: [":host{display:block}:host svg{width:3.25em;transform-origin:center;animation:rotate4 2s linear infinite}:host circle{fill:none;stroke:var(--ngf-loading-foreground)!important;stroke-width:5;stroke-dasharray:1,200;stroke-dashoffset:0;stroke-linecap:round;animation:dash4 1.5s ease-in-out infinite}@keyframes rotate4{to{transform:rotate(360deg)}}@keyframes dash4{0%{stroke-dasharray:1,200;stroke-dashoffset:0}50%{stroke-dasharray:90,200;stroke-dashoffset:-35px}to{stroke-dashoffset:-125px}}\n"] });
|
|
587
|
+
}
|
|
588
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: NgFluxLoadingComponent, decorators: [{
|
|
589
|
+
type: Component,
|
|
590
|
+
args: [{ selector: 'ngf-loading', imports: [], template: "<svg viewBox=\"25 25 50 50\">\n <circle r=\"20\" cy=\"50\" cx=\"50\"></circle>\n</svg>\n", styles: [":host{display:block}:host svg{width:3.25em;transform-origin:center;animation:rotate4 2s linear infinite}:host circle{fill:none;stroke:var(--ngf-loading-foreground)!important;stroke-width:5;stroke-dasharray:1,200;stroke-dashoffset:0;stroke-linecap:round;animation:dash4 1.5s ease-in-out infinite}@keyframes rotate4{to{transform:rotate(360deg)}}@keyframes dash4{0%{stroke-dasharray:1,200;stroke-dashoffset:0}50%{stroke-dasharray:90,200;stroke-dashoffset:-35px}to{stroke-dashoffset:-125px}}\n"] }]
|
|
591
|
+
}] });
|
|
592
|
+
|
|
593
|
+
class NgFluxLoadingRootComponent {
|
|
594
|
+
config = inject(NGF_CONFIG);
|
|
595
|
+
internal = inject(NgFluxLoadingInternal);
|
|
596
|
+
injector = inject(Injector);
|
|
597
|
+
get isLoading() { return this.internal.isLoading(); }
|
|
598
|
+
viewContainer = viewChild.required('container', { read: ViewContainerRef });
|
|
599
|
+
componentRef;
|
|
600
|
+
constructor() {
|
|
601
|
+
const { config, injector } = this;
|
|
602
|
+
effect(() => {
|
|
603
|
+
const viewContainer = this.viewContainer();
|
|
604
|
+
const component = config.loading?.component ?? NgFluxLoadingComponent;
|
|
605
|
+
const newInjector = Injector.create({
|
|
606
|
+
parent: injector,
|
|
607
|
+
providers: [],
|
|
608
|
+
});
|
|
609
|
+
this.componentRef = viewContainer.createComponent(component, {
|
|
610
|
+
injector: newInjector,
|
|
611
|
+
});
|
|
612
|
+
});
|
|
613
|
+
}
|
|
614
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: NgFluxLoadingRootComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
615
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "21.2.14", type: NgFluxLoadingRootComponent, isStandalone: true, selector: "ngf-loading-root", host: { properties: { "class.show": "this.isLoading" } }, viewQueries: [{ propertyName: "viewContainer", first: true, predicate: ["container"], descendants: true, read: ViewContainerRef, isSignal: true }], ngImport: i0, template: "<div class=\"wrapper\">\n <ng-template #container></ng-template>\n</div>\n", styles: [":host{display:none;position:fixed;z-index:var(--ngf-loading-z-index)!important;inset:0}:host.show{display:block}:host>.wrapper{display:flex;flex-direction:column;justify-content:center;align-items:center;background-color:var(--ngf-loading-background)!important;height:100%!important;width:100%!important}\n"] });
|
|
616
|
+
}
|
|
617
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: NgFluxLoadingRootComponent, decorators: [{
|
|
618
|
+
type: Component,
|
|
619
|
+
args: [{ selector: 'ngf-loading-root', imports: [], template: "<div class=\"wrapper\">\n <ng-template #container></ng-template>\n</div>\n", styles: [":host{display:none;position:fixed;z-index:var(--ngf-loading-z-index)!important;inset:0}:host.show{display:block}:host>.wrapper{display:flex;flex-direction:column;justify-content:center;align-items:center;background-color:var(--ngf-loading-background)!important;height:100%!important;width:100%!important}\n"] }]
|
|
620
|
+
}], ctorParameters: () => [], propDecorators: { isLoading: [{
|
|
621
|
+
type: HostBinding,
|
|
622
|
+
args: ['class.show']
|
|
623
|
+
}], viewContainer: [{ type: i0.ViewChild, args: ['container', { ...{ read: ViewContainerRef }, isSignal: true }] }] } });
|
|
624
|
+
|
|
625
|
+
class NgFluxRootComponent {
|
|
626
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: NgFluxRootComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
627
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "21.2.14", type: NgFluxRootComponent, isStandalone: true, selector: "ngf-root", ngImport: i0, template: "<ng-content></ng-content>\n\n<ngf-dialog-root></ngf-dialog-root>\n<ngf-loading-root></ngf-loading-root>\n", styles: [""], dependencies: [{ kind: "component", type: NgFluxDialogRootComponent, selector: "ngf-dialog-root" }, { kind: "component", type: NgFluxLoadingRootComponent, selector: "ngf-loading-root" }] });
|
|
628
|
+
}
|
|
629
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: NgFluxRootComponent, decorators: [{
|
|
630
|
+
type: Component,
|
|
631
|
+
args: [{ selector: 'ngf-root', imports: [
|
|
632
|
+
NgFluxDialogRootComponent,
|
|
633
|
+
NgFluxLoadingRootComponent,
|
|
634
|
+
], template: "<ng-content></ng-content>\n\n<ngf-dialog-root></ngf-dialog-root>\n<ngf-loading-root></ngf-loading-root>\n" }]
|
|
635
|
+
}] });
|
|
636
|
+
|
|
637
|
+
class NgFluxPaginationInfo {
|
|
638
|
+
data = input.required(...(ngDevMode ? [{ debugName: "data" }] : /* istanbul ignore next */ []));
|
|
639
|
+
callback = output();
|
|
640
|
+
limit = model.required(...(ngDevMode ? [{ debugName: "limit" }] : /* istanbul ignore next */ []));
|
|
641
|
+
limitEntries = input.required(...(ngDevMode ? [{ debugName: "limitEntries" }] : /* istanbul ignore next */ []));
|
|
642
|
+
info = computed(() => {
|
|
643
|
+
const data = this.data();
|
|
644
|
+
const from = data.from.toLocaleString();
|
|
645
|
+
const to = data.to.toLocaleString();
|
|
646
|
+
const total = data.total.toLocaleString();
|
|
647
|
+
return `${from} - ${to} of ${total}`;
|
|
648
|
+
}, ...(ngDevMode ? [{ debugName: "info" }] : /* istanbul ignore next */ []));
|
|
649
|
+
disablePrev = computed(() => {
|
|
650
|
+
const data = this.data();
|
|
651
|
+
return data.currentPage <= 1;
|
|
652
|
+
}, ...(ngDevMode ? [{ debugName: "disablePrev" }] : /* istanbul ignore next */ []));
|
|
653
|
+
disableNext = computed(() => {
|
|
654
|
+
const data = this.data();
|
|
655
|
+
return data.currentPage >= data.lastPage;
|
|
656
|
+
}, ...(ngDevMode ? [{ debugName: "disableNext" }] : /* istanbul ignore next */ []));
|
|
657
|
+
prev() {
|
|
658
|
+
const data = this.data();
|
|
659
|
+
this.callback.emit({
|
|
660
|
+
page: data.currentPage - 1,
|
|
661
|
+
limit: data.perPage,
|
|
662
|
+
});
|
|
663
|
+
}
|
|
664
|
+
next() {
|
|
665
|
+
const data = this.data();
|
|
666
|
+
this.callback.emit({
|
|
667
|
+
page: data.currentPage + 1,
|
|
668
|
+
limit: data.perPage,
|
|
669
|
+
});
|
|
670
|
+
}
|
|
671
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: NgFluxPaginationInfo, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
672
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.14", type: NgFluxPaginationInfo, isStandalone: true, selector: "ngf-pagination-info", inputs: { data: { classPropertyName: "data", publicName: "data", isSignal: true, isRequired: true, transformFunction: null }, limit: { classPropertyName: "limit", publicName: "limit", isSignal: true, isRequired: true, transformFunction: null }, limitEntries: { classPropertyName: "limitEntries", publicName: "limitEntries", isSignal: true, isRequired: true, transformFunction: null } }, outputs: { callback: "callback", limit: "limitChange" }, ngImport: i0, template: "<div class=\"wrapper\">\n <div class=\"block limit\">\n <div>Per page</div>\n <select name=\"\" id=\"\" [(ngModel)]=\"limit\">\n @for (entry of limitEntries(); track $index) {\n <option [value]=\"entry\">{{ entry }}</option>\n }\n </select>\n </div>\n\n <div class=\"block info\">\n <div>{{ info() }}</div>\n </div>\n\n <div class=\"block nav\">\n <button (click)=\"prev()\" [disabled]=\"disablePrev()\">\n <i class=\"ngf-icon chevron-left\"></i>\n </button>\n\n <button (click)=\"next()\" [disabled]=\"disableNext()\">\n <i class=\"ngf-icon chevron-right\"></i>\n </button>\n </div>\n</div>\n", styles: [":host{display:block;container:pagination/inline-size}:host .wrapper{display:flex;flex-direction:column;font-family:Poppins,sans-serif;align-items:end;text-align:center;font-size:.8rem;gap:5px}@container pagination (min-width: 400px){:host .wrapper{flex-direction:row;justify-content:end;align-items:center;gap:15px}}:host .wrapper .block{display:flex;flex-direction:row;justify-content:center;align-items:center;gap:5px}:host .wrapper .limit>select{display:block;padding:2px 5px;font-size:inherit;outline:none!important;width:50px}:host .wrapper .nav>button{display:block;background-color:transparent;box-shadow:none!important;outline:none!important;cursor:pointer;border:none;padding:0}:host .wrapper .nav>button:disabled{cursor:default;color:#aaa}\n"], dependencies: [{ kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1.NgSelectOption, selector: "option", inputs: ["ngValue", "value"] }, { kind: "directive", type: i1.ɵNgSelectMultipleOption, selector: "option", inputs: ["ngValue", "value"] }, { kind: "directive", type: i1.SelectControlValueAccessor, selector: "select:not([multiple])[formControlName],select:not([multiple])[formControl],select:not([multiple])[ngModel]", inputs: ["compareWith"] }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }] });
|
|
673
|
+
}
|
|
674
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: NgFluxPaginationInfo, decorators: [{
|
|
675
|
+
type: Component,
|
|
676
|
+
args: [{ selector: 'ngf-pagination-info', imports: [
|
|
677
|
+
FormsModule,
|
|
678
|
+
], template: "<div class=\"wrapper\">\n <div class=\"block limit\">\n <div>Per page</div>\n <select name=\"\" id=\"\" [(ngModel)]=\"limit\">\n @for (entry of limitEntries(); track $index) {\n <option [value]=\"entry\">{{ entry }}</option>\n }\n </select>\n </div>\n\n <div class=\"block info\">\n <div>{{ info() }}</div>\n </div>\n\n <div class=\"block nav\">\n <button (click)=\"prev()\" [disabled]=\"disablePrev()\">\n <i class=\"ngf-icon chevron-left\"></i>\n </button>\n\n <button (click)=\"next()\" [disabled]=\"disableNext()\">\n <i class=\"ngf-icon chevron-right\"></i>\n </button>\n </div>\n</div>\n", styles: [":host{display:block;container:pagination/inline-size}:host .wrapper{display:flex;flex-direction:column;font-family:Poppins,sans-serif;align-items:end;text-align:center;font-size:.8rem;gap:5px}@container pagination (min-width: 400px){:host .wrapper{flex-direction:row;justify-content:end;align-items:center;gap:15px}}:host .wrapper .block{display:flex;flex-direction:row;justify-content:center;align-items:center;gap:5px}:host .wrapper .limit>select{display:block;padding:2px 5px;font-size:inherit;outline:none!important;width:50px}:host .wrapper .nav>button{display:block;background-color:transparent;box-shadow:none!important;outline:none!important;cursor:pointer;border:none;padding:0}:host .wrapper .nav>button:disabled{cursor:default;color:#aaa}\n"] }]
|
|
679
|
+
}], propDecorators: { data: [{ type: i0.Input, args: [{ isSignal: true, alias: "data", required: true }] }], callback: [{ type: i0.Output, args: ["callback"] }], limit: [{ type: i0.Input, args: [{ isSignal: true, alias: "limit", required: true }] }, { type: i0.Output, args: ["limitChange"] }], limitEntries: [{ type: i0.Input, args: [{ isSignal: true, alias: "limitEntries", required: true }] }] } });
|
|
680
|
+
|
|
681
|
+
class NgFluxPagination {
|
|
682
|
+
config = inject(NGF_CONFIG);
|
|
683
|
+
data = input.required(...(ngDevMode ? [{ debugName: "data" }] : /* istanbul ignore next */ []));
|
|
684
|
+
preload = input(this.config.pagination?.preload ?? false, ...(ngDevMode ? [{ debugName: "preload" }] : /* istanbul ignore next */ []));
|
|
685
|
+
transform = input(...(ngDevMode ? [undefined, { debugName: "transform" }] : /* istanbul ignore next */ []));
|
|
686
|
+
limit = model(this.config.pagination?.limit ?? 10, ...(ngDevMode ? [{ debugName: "limit" }] : /* istanbul ignore next */ []));
|
|
687
|
+
limitEntries = input(this.config.pagination?.limitEntries ?? [5, 10, 20, 30, 40, 50], ...(ngDevMode ? [{ debugName: "limitEntries" }] : /* istanbul ignore next */ []));
|
|
688
|
+
callback = output();
|
|
689
|
+
value = computed(() => {
|
|
690
|
+
const { config } = this;
|
|
691
|
+
const data = this.data();
|
|
692
|
+
const transform = this.transform() ?? config.pagination?.transform;
|
|
693
|
+
if (!transform)
|
|
694
|
+
return data;
|
|
695
|
+
return {
|
|
696
|
+
currentPage: transform.getCurrentPage(data),
|
|
697
|
+
lastPage: transform.getLastPage(data),
|
|
698
|
+
perPage: transform.getPerPage(data),
|
|
699
|
+
from: transform.getFrom(data),
|
|
700
|
+
to: transform.getTo(data),
|
|
701
|
+
total: transform.getTotal(data),
|
|
702
|
+
data: transform.getData(data),
|
|
703
|
+
};
|
|
704
|
+
}, ...(ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []));
|
|
705
|
+
constructor() {
|
|
706
|
+
let init = false;
|
|
707
|
+
effect(() => {
|
|
708
|
+
const limit = Number(this.limit());
|
|
709
|
+
const preload = untracked(this.preload);
|
|
710
|
+
const { currentPage: page } = untracked(this.value);
|
|
711
|
+
if (preload || init) {
|
|
712
|
+
this.callback.emit({ limit, page });
|
|
713
|
+
}
|
|
714
|
+
init = true;
|
|
715
|
+
});
|
|
716
|
+
}
|
|
717
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: NgFluxPagination, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
718
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "21.2.14", type: NgFluxPagination, isStandalone: true, selector: "ngf-pagination", inputs: { data: { classPropertyName: "data", publicName: "data", isSignal: true, isRequired: true, transformFunction: null }, preload: { classPropertyName: "preload", publicName: "preload", isSignal: true, isRequired: false, transformFunction: null }, transform: { classPropertyName: "transform", publicName: "transform", isSignal: true, isRequired: false, transformFunction: null }, limit: { classPropertyName: "limit", publicName: "limit", isSignal: true, isRequired: false, transformFunction: null }, limitEntries: { classPropertyName: "limitEntries", publicName: "limitEntries", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { limit: "limitChange", callback: "callback" }, ngImport: i0, template: "<ngf-pagination-info\n [data]=\"value()\"\n [(limit)]=\"limit\"\n [limitEntries]=\"limitEntries()\"\n (callback)=\"callback.emit($event)\"\n></ngf-pagination-info>\n\n<div class=\"content\">\n <ng-content></ng-content>\n</div>\n\n<ngf-pagination-info\n [data]=\"value()\"\n [(limit)]=\"limit\"\n [limitEntries]=\"limitEntries()\"\n (callback)=\"callback.emit($event)\"\n></ngf-pagination-info>\n", styles: [":host{display:block}:host>.content{margin:20px 0}\n"], dependencies: [{ kind: "component", type: NgFluxPaginationInfo, selector: "ngf-pagination-info", inputs: ["data", "limit", "limitEntries"], outputs: ["callback", "limitChange"] }] });
|
|
719
|
+
}
|
|
720
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: NgFluxPagination, decorators: [{
|
|
721
|
+
type: Component,
|
|
722
|
+
args: [{ selector: 'ngf-pagination', imports: [
|
|
723
|
+
NgFluxPaginationInfo,
|
|
724
|
+
], template: "<ngf-pagination-info\n [data]=\"value()\"\n [(limit)]=\"limit\"\n [limitEntries]=\"limitEntries()\"\n (callback)=\"callback.emit($event)\"\n></ngf-pagination-info>\n\n<div class=\"content\">\n <ng-content></ng-content>\n</div>\n\n<ngf-pagination-info\n [data]=\"value()\"\n [(limit)]=\"limit\"\n [limitEntries]=\"limitEntries()\"\n (callback)=\"callback.emit($event)\"\n></ngf-pagination-info>\n", styles: [":host{display:block}:host>.content{margin:20px 0}\n"] }]
|
|
725
|
+
}], ctorParameters: () => [], propDecorators: { data: [{ type: i0.Input, args: [{ isSignal: true, alias: "data", required: true }] }], preload: [{ type: i0.Input, args: [{ isSignal: true, alias: "preload", required: false }] }], transform: [{ type: i0.Input, args: [{ isSignal: true, alias: "transform", required: false }] }], limit: [{ type: i0.Input, args: [{ isSignal: true, alias: "limit", required: false }] }, { type: i0.Output, args: ["limitChange"] }], limitEntries: [{ type: i0.Input, args: [{ isSignal: true, alias: "limitEntries", required: false }] }], callback: [{ type: i0.Output, args: ["callback"] }] } });
|
|
726
|
+
|
|
727
|
+
// export * from './pagination/info/info.component';
|
|
728
|
+
|
|
729
|
+
/*
|
|
730
|
+
* Public API Surface of ngflux
|
|
731
|
+
*/
|
|
732
|
+
|
|
733
|
+
/**
|
|
734
|
+
* Generated bundle index. Do not edit.
|
|
735
|
+
*/
|
|
736
|
+
|
|
737
|
+
export { NGF_CONFIG, NGF_DIALOG_DATA, NgFluxButton, NgFluxDialog, NgFluxDialogBodyComponent, NgFluxDialogFooterComponent, NgFluxDialogHeaderComponent, NgFluxDialogInstance, NgFluxDialogRef, NgFluxDialogRootComponent, NgFluxLoading, NgFluxLoadingRootComponent, NgFluxPagination, NgFluxRootComponent, provideNgFlux };
|
|
738
|
+
//# sourceMappingURL=ngflux-ngflux.mjs.map
|