@piying-lib/angular-daisyui 1.0.4 → 1.0.6
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/extension/index.d.ts +3 -0
- package/fesm2022/piying-lib-angular-daisyui-extension.mjs +66 -51
- package/fesm2022/piying-lib-angular-daisyui-extension.mjs.map +1 -1
- package/fesm2022/piying-lib-angular-daisyui-non-field-control.mjs +3 -2
- package/fesm2022/piying-lib-angular-daisyui-non-field-control.mjs.map +1 -1
- package/package.json +2 -2
package/extension/index.d.ts
CHANGED
|
@@ -165,6 +165,7 @@ declare class TableRowFGC extends PiyingViewGroupBase {
|
|
|
165
165
|
}
|
|
166
166
|
|
|
167
167
|
declare class TableResourceWC {
|
|
168
|
+
#private;
|
|
168
169
|
static __version: number;
|
|
169
170
|
templateRef: _angular_core.Signal<unknown>;
|
|
170
171
|
field$$: _angular_core.Signal<_piying_view_angular.PiResolvedViewFieldConfig>;
|
|
@@ -231,7 +232,9 @@ declare class TableStatusWC {
|
|
|
231
232
|
|
|
232
233
|
declare class TableStatusService {
|
|
233
234
|
expanded: BehaviorSubject<undefined>;
|
|
235
|
+
updateIndex$: _angular_core.WritableSignal<number>;
|
|
234
236
|
toggleExpand(value: any): void;
|
|
237
|
+
needUpdate(): void;
|
|
235
238
|
static ɵfac: _angular_core.ɵɵFactoryDeclaration<TableStatusService, never>;
|
|
236
239
|
static ɵprov: _angular_core.ɵɵInjectableDeclaration<TableStatusService>;
|
|
237
240
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { NgTemplateOutlet, NgClass, JsonPipe } from '@angular/common';
|
|
2
2
|
import * as i0 from '@angular/core';
|
|
3
|
-
import { viewChild, input, inject, computed, Component, model, InjectionToken, Injector, untracked, signal,
|
|
3
|
+
import { viewChild, input, inject, computed, Component, model, InjectionToken, Injector, untracked, signal, Injectable, HostListener, Directive, resource, ElementRef, linkedSignal, NgZone, EventEmitter, TemplateRef, ViewContainerRef, Output, forwardRef, ChangeDetectionStrategy, effect } from '@angular/core';
|
|
4
4
|
import { SelectorlessOutlet } from '@cyia/ngx-common/directive';
|
|
5
5
|
import { StrOrTemplateComponent, isSchema, computedWithPrev, DefaultOptionConvert, transformOption } from '@piying-lib/angular-core';
|
|
6
6
|
import { CssPrefixPipe, MergeClassPipe, TwPrefixPipe } from '@piying-lib/angular-daisyui/pipe';
|
|
@@ -16,7 +16,7 @@ import clsx from 'clsx';
|
|
|
16
16
|
import * as v from 'valibot';
|
|
17
17
|
import { setComponent, NFCSchema, actions } from '@piying/view-angular-core';
|
|
18
18
|
import { ThWC, TdWC } from '@piying-lib/angular-daisyui/wrapper';
|
|
19
|
-
import { Subject, filter,
|
|
19
|
+
import { BehaviorSubject, Subject, filter, Subscription } from 'rxjs';
|
|
20
20
|
import { Directionality } from '@angular/cdk/bidi';
|
|
21
21
|
import { ESCAPE, hasModifierKey } from '@angular/cdk/keycodes';
|
|
22
22
|
import { createRepositionScrollStrategy, createOverlayRef, OverlayConfig, createFlexibleConnectedPositionStrategy } from '@angular/cdk/overlay';
|
|
@@ -379,14 +379,74 @@ function localData(data) {
|
|
|
379
379
|
};
|
|
380
380
|
}
|
|
381
381
|
|
|
382
|
+
class TableStatusService {
|
|
383
|
+
expanded = new BehaviorSubject(undefined);
|
|
384
|
+
updateIndex$ = signal(0, ...(ngDevMode ? [{ debugName: "updateIndex$" }] : []));
|
|
385
|
+
toggleExpand(value) {
|
|
386
|
+
this.expanded.next(value === this.expanded.value ? undefined : value);
|
|
387
|
+
}
|
|
388
|
+
needUpdate() {
|
|
389
|
+
this.updateIndex$.update((a) => ++a);
|
|
390
|
+
}
|
|
391
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.14", ngImport: i0, type: TableStatusService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
392
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.14", ngImport: i0, type: TableStatusService });
|
|
393
|
+
}
|
|
394
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.14", ngImport: i0, type: TableStatusService, decorators: [{
|
|
395
|
+
type: Injectable
|
|
396
|
+
}] });
|
|
397
|
+
|
|
398
|
+
class ExpandRowDirective {
|
|
399
|
+
#field = inject(PI_VIEW_FIELD_TOKEN);
|
|
400
|
+
#status = inject(TableStatusService);
|
|
401
|
+
a(event) {
|
|
402
|
+
if (event.target instanceof HTMLInputElement) {
|
|
403
|
+
return;
|
|
404
|
+
}
|
|
405
|
+
this.#status.toggleExpand(this.#field().context['item$']());
|
|
406
|
+
}
|
|
407
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.14", ngImport: i0, type: ExpandRowDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
408
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.3.14", type: ExpandRowDirective, isStandalone: true, selector: "app-expand", host: { listeners: { "click": "a($event)" } }, ngImport: i0 });
|
|
409
|
+
}
|
|
410
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.14", ngImport: i0, type: ExpandRowDirective, decorators: [{
|
|
411
|
+
type: Directive,
|
|
412
|
+
args: [{
|
|
413
|
+
selector: 'app-expand',
|
|
414
|
+
}]
|
|
415
|
+
}], propDecorators: { a: [{
|
|
416
|
+
type: HostListener,
|
|
417
|
+
args: ['click', ['$event']]
|
|
418
|
+
}] } });
|
|
419
|
+
|
|
420
|
+
// 切换状态演示,继承TABLE_STATUS_TOKEN自定义
|
|
421
|
+
class TableStatusWC {
|
|
422
|
+
static __version = 2;
|
|
423
|
+
templateRef = viewChild.required('templateRef');
|
|
424
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.14", ngImport: i0, type: TableStatusWC, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
425
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "20.3.14", type: TableStatusWC, isStandalone: true, selector: "app-table-status", providers: [TableStatusService, { provide: TABLE_STATUS_TOKEN, useExisting: TableStatusService }], viewQueries: [{ propertyName: "templateRef", first: true, predicate: ["templateRef"], descendants: true, isSignal: true }], ngImport: i0, template: "<ng-template #templateRef let-attr=\"attributes\">\n <ng-container insertField></ng-container>\n</ng-template>\n", dependencies: [{ kind: "directive", type: InsertFieldDirective, selector: "[insertField]", exportAs: ["insertField"] }] });
|
|
426
|
+
}
|
|
427
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.14", ngImport: i0, type: TableStatusWC, decorators: [{
|
|
428
|
+
type: Component,
|
|
429
|
+
args: [{ selector: 'app-table-status', providers: [TableStatusService, { provide: TABLE_STATUS_TOKEN, useExisting: TableStatusService }], imports: [InsertFieldDirective], template: "<ng-template #templateRef let-attr=\"attributes\">\n <ng-container insertField></ng-container>\n</ng-template>\n" }]
|
|
430
|
+
}], propDecorators: { templateRef: [{ type: i0.ViewChild, args: ['templateRef', { isSignal: true }] }] } });
|
|
431
|
+
|
|
382
432
|
class TableResourceWC {
|
|
383
433
|
static __version = 2;
|
|
384
434
|
templateRef = viewChild.required('templateRef');
|
|
385
435
|
field$$ = inject(PI_VIEW_FIELD_TOKEN);
|
|
436
|
+
#status = inject(TableStatusService);
|
|
386
437
|
props$$ = computed(() => this.field$$().props(), ...(ngDevMode ? [{ debugName: "props$$" }] : []));
|
|
438
|
+
#data$$ = computed(() => this.field$$().props()['data'], ...(ngDevMode ? [{ debugName: "#data$$" }] : []));
|
|
387
439
|
rawData$$ = computed(() => {
|
|
388
|
-
const data = this
|
|
389
|
-
|
|
440
|
+
const data = this.#data$$();
|
|
441
|
+
this.#status.updateIndex$();
|
|
442
|
+
return Array.isArray(data) || !data
|
|
443
|
+
? Promise.resolve(localData(data ?? []))
|
|
444
|
+
: data().then((value) => {
|
|
445
|
+
if (Array.isArray(value) || !value) {
|
|
446
|
+
return localData(value ?? []);
|
|
447
|
+
}
|
|
448
|
+
return value;
|
|
449
|
+
});
|
|
390
450
|
}, ...(ngDevMode ? [{ debugName: "rawData$$" }] : []));
|
|
391
451
|
queryParams$$ = computed(() => {
|
|
392
452
|
return this.field$$().props()['queryParams'];
|
|
@@ -401,7 +461,8 @@ class TableResourceWC {
|
|
|
401
461
|
}),
|
|
402
462
|
loader: async (res) => {
|
|
403
463
|
const { params } = res;
|
|
404
|
-
|
|
464
|
+
let dataResult = await params.data;
|
|
465
|
+
return dataResult(res).then((data) => {
|
|
405
466
|
return dataConvert(data);
|
|
406
467
|
});
|
|
407
468
|
},
|
|
@@ -604,52 +665,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.14", ngImpo
|
|
|
604
665
|
}]
|
|
605
666
|
}], ctorParameters: () => [], propDecorators: { templateRef: [{ type: i0.ViewChild, args: ['templateRef', { isSignal: true }] }] } });
|
|
606
667
|
|
|
607
|
-
class TableStatusService {
|
|
608
|
-
expanded = new BehaviorSubject(undefined);
|
|
609
|
-
toggleExpand(value) {
|
|
610
|
-
this.expanded.next(value === this.expanded.value ? undefined : value);
|
|
611
|
-
}
|
|
612
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.14", ngImport: i0, type: TableStatusService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
613
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.14", ngImport: i0, type: TableStatusService });
|
|
614
|
-
}
|
|
615
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.14", ngImport: i0, type: TableStatusService, decorators: [{
|
|
616
|
-
type: Injectable
|
|
617
|
-
}] });
|
|
618
|
-
|
|
619
|
-
class ExpandRowDirective {
|
|
620
|
-
#field = inject(PI_VIEW_FIELD_TOKEN);
|
|
621
|
-
#status = inject(TableStatusService);
|
|
622
|
-
a(event) {
|
|
623
|
-
if (event.target instanceof HTMLInputElement) {
|
|
624
|
-
return;
|
|
625
|
-
}
|
|
626
|
-
this.#status.toggleExpand(this.#field().context['item$']());
|
|
627
|
-
}
|
|
628
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.14", ngImport: i0, type: ExpandRowDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
629
|
-
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.3.14", type: ExpandRowDirective, isStandalone: true, selector: "app-expand", host: { listeners: { "click": "a($event)" } }, ngImport: i0 });
|
|
630
|
-
}
|
|
631
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.14", ngImport: i0, type: ExpandRowDirective, decorators: [{
|
|
632
|
-
type: Directive,
|
|
633
|
-
args: [{
|
|
634
|
-
selector: 'app-expand',
|
|
635
|
-
}]
|
|
636
|
-
}], propDecorators: { a: [{
|
|
637
|
-
type: HostListener,
|
|
638
|
-
args: ['click', ['$event']]
|
|
639
|
-
}] } });
|
|
640
|
-
|
|
641
|
-
// 切换状态演示,继承TABLE_STATUS_TOKEN自定义
|
|
642
|
-
class TableStatusWC {
|
|
643
|
-
static __version = 2;
|
|
644
|
-
templateRef = viewChild.required('templateRef');
|
|
645
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.14", ngImport: i0, type: TableStatusWC, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
646
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "20.3.14", type: TableStatusWC, isStandalone: true, selector: "app-table-status", providers: [TableStatusService, { provide: TABLE_STATUS_TOKEN, useExisting: TableStatusService }], viewQueries: [{ propertyName: "templateRef", first: true, predicate: ["templateRef"], descendants: true, isSignal: true }], ngImport: i0, template: "<ng-template #templateRef let-attr=\"attributes\">\n <ng-container insertField></ng-container>\n</ng-template>\n", dependencies: [{ kind: "directive", type: InsertFieldDirective, selector: "[insertField]", exportAs: ["insertField"] }] });
|
|
647
|
-
}
|
|
648
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.14", ngImport: i0, type: TableStatusWC, decorators: [{
|
|
649
|
-
type: Component,
|
|
650
|
-
args: [{ selector: 'app-table-status', providers: [TableStatusService, { provide: TABLE_STATUS_TOKEN, useExisting: TableStatusService }], imports: [InsertFieldDirective], template: "<ng-template #templateRef let-attr=\"attributes\">\n <ng-container insertField></ng-container>\n</ng-template>\n" }]
|
|
651
|
-
}], propDecorators: { templateRef: [{ type: i0.ViewChild, args: ['templateRef', { isSignal: true }] }] } });
|
|
652
|
-
|
|
653
668
|
class CheckboxTableWC {
|
|
654
669
|
static __version = 2;
|
|
655
670
|
templateRef = viewChild.required('templateRef');
|