@shival99/z-ui 1.4.22 → 1.4.24
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.
|
@@ -2,7 +2,7 @@ import { moveItemInArray, CdkDropList, CdkDrag } from '@angular/cdk/drag-drop';
|
|
|
2
2
|
import { ScrollingModule } from '@angular/cdk/scrolling';
|
|
3
3
|
import { NgClass, NgStyle, NgTemplateOutlet } from '@angular/common';
|
|
4
4
|
import * as i0 from '@angular/core';
|
|
5
|
-
import { input, output, computed, ChangeDetectionStrategy, Component,
|
|
5
|
+
import { input, output, computed, ChangeDetectionStrategy, Component, inject, DestroyRef, signal, ElementRef, Renderer2, Directive, NgZone, Pipe, TemplateRef, viewChild, viewChildren, untracked, effect, afterNextRender } from '@angular/core';
|
|
6
6
|
import { TranslatePipe } from '@ngx-translate/core';
|
|
7
7
|
import { injectVirtualizer } from '@shival99/angular-virtual';
|
|
8
8
|
import { ZButtonComponent } from '@shival99/z-ui/components/z-button';
|
|
@@ -23,10 +23,13 @@ import { NgScrollbar } from 'ngx-scrollbar';
|
|
|
23
23
|
import { explicitEffect } from 'ngxtension/explicit-effect';
|
|
24
24
|
import { injectDestroy } from 'ngxtension/inject-destroy';
|
|
25
25
|
import { ZDropdownMenuComponent } from '@shival99/z-ui/components/z-dropdown-menu';
|
|
26
|
+
import { takeUntilDestroyed, toObservable } from '@angular/core/rxjs-interop';
|
|
26
27
|
import * as i1 from '@angular/forms';
|
|
27
28
|
import { FormsModule } from '@angular/forms';
|
|
28
29
|
import { ZCalendarComponent } from '@shival99/z-ui/components/z-calendar';
|
|
29
30
|
import { ZSelectComponent } from '@shival99/z-ui/components/z-select';
|
|
31
|
+
import { ZSwitchComponent } from '@shival99/z-ui/components/z-switch';
|
|
32
|
+
import { Subject, debounceTime, distinctUntilChanged, map, pairwise, filter } from 'rxjs';
|
|
30
33
|
|
|
31
34
|
const Z_DEFAULT_ROW_HEIGHT = 40;
|
|
32
35
|
const Z_DEFAULT_VIRTUAL_OVERSCAN = 5;
|
|
@@ -240,6 +243,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.6", ngImpor
|
|
|
240
243
|
}], propDecorators: { zConfig: [{ type: i0.Input, args: [{ isSignal: true, alias: "zConfig", required: true }] }], zRow: [{ type: i0.Input, args: [{ isSignal: true, alias: "zRow", required: true }] }], zRowId: [{ type: i0.Input, args: [{ isSignal: true, alias: "zRowId", required: true }] }], zDropdownButtonSize: [{ type: i0.Input, args: [{ isSignal: true, alias: "zDropdownButtonSize", required: false }] }], zActionClick: [{ type: i0.Output, args: ["zActionClick"] }] } });
|
|
241
244
|
|
|
242
245
|
class ZTableEditCellComponent {
|
|
246
|
+
_destroyRef = inject(DestroyRef);
|
|
243
247
|
zRow = input.required(...(ngDevMode ? [{ debugName: "zRow" }] : []));
|
|
244
248
|
zRowId = input.required(...(ngDevMode ? [{ debugName: "zRowId" }] : []));
|
|
245
249
|
zRowIndex = input.required(...(ngDevMode ? [{ debugName: "zRowIndex" }] : []));
|
|
@@ -248,8 +252,11 @@ class ZTableEditCellComponent {
|
|
|
248
252
|
zEditConfig = input(...(ngDevMode ? [undefined, { debugName: "zEditConfig" }] : []));
|
|
249
253
|
zChange = output();
|
|
250
254
|
_currentValue = signal(undefined, ...(ngDevMode ? [{ debugName: "_currentValue" }] : []));
|
|
255
|
+
_valueChange$ = new Subject();
|
|
251
256
|
_initialized = false;
|
|
252
|
-
|
|
257
|
+
_pendingBlurValue = undefined;
|
|
258
|
+
_hasPendingBlur = false;
|
|
259
|
+
_inputControl = null;
|
|
253
260
|
editConfig = computed(() => {
|
|
254
261
|
const config = this.zEditConfig();
|
|
255
262
|
if (!config || typeof config === 'boolean') {
|
|
@@ -320,8 +327,30 @@ class ZTableEditCellComponent {
|
|
|
320
327
|
const oldValue = this.zValue();
|
|
321
328
|
this._currentValue.set(newValue);
|
|
322
329
|
this._initialized = true;
|
|
323
|
-
|
|
324
|
-
|
|
330
|
+
const config = this.editConfig();
|
|
331
|
+
if (config?.blurEdit) {
|
|
332
|
+
this._pendingBlurValue = newValue;
|
|
333
|
+
this._hasPendingBlur = true;
|
|
334
|
+
return;
|
|
335
|
+
}
|
|
336
|
+
this._valueChange$.next({ oldValue, newValue });
|
|
337
|
+
}
|
|
338
|
+
onInputControlReady(control) {
|
|
339
|
+
this._inputControl = control;
|
|
340
|
+
this._setupBlurWatcher();
|
|
341
|
+
}
|
|
342
|
+
_handleInputBlur() {
|
|
343
|
+
if (!this._hasPendingBlur)
|
|
344
|
+
return;
|
|
345
|
+
const oldValue = this.zValue();
|
|
346
|
+
this._hasPendingBlur = false;
|
|
347
|
+
this._emitChange(oldValue, this._pendingBlurValue);
|
|
348
|
+
}
|
|
349
|
+
onToggleChange(checked) {
|
|
350
|
+
const oldValue = this.zValue();
|
|
351
|
+
this._currentValue.set(checked);
|
|
352
|
+
this._initialized = true;
|
|
353
|
+
this._emitChange(oldValue, checked);
|
|
325
354
|
}
|
|
326
355
|
onSelectChange(newValue) {
|
|
327
356
|
const oldValue = this.zValue();
|
|
@@ -355,29 +384,26 @@ class ZTableEditCellComponent {
|
|
|
355
384
|
newValue,
|
|
356
385
|
});
|
|
357
386
|
}
|
|
358
|
-
|
|
387
|
+
ngOnInit() {
|
|
359
388
|
const config = this.editConfig();
|
|
360
|
-
const
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
return;
|
|
365
|
-
}
|
|
366
|
-
// Clear previous timeout
|
|
367
|
-
if (this._debounceTimeout) {
|
|
368
|
-
clearTimeout(this._debounceTimeout);
|
|
369
|
-
}
|
|
370
|
-
// Schedule debounced emit
|
|
371
|
-
this._debounceTimeout = setTimeout(() => {
|
|
389
|
+
const debounceMs = config?.debounceTime ?? 0;
|
|
390
|
+
this._valueChange$
|
|
391
|
+
.pipe(debounceTime(debounceMs), distinctUntilChanged((a, b) => a.newValue === b.newValue), takeUntilDestroyed(this._destroyRef))
|
|
392
|
+
.subscribe(({ oldValue, newValue }) => {
|
|
372
393
|
this._emitChange(oldValue, newValue);
|
|
373
|
-
|
|
374
|
-
|
|
394
|
+
});
|
|
395
|
+
this._destroyRef.onDestroy(() => {
|
|
396
|
+
this._valueChange$.complete();
|
|
397
|
+
});
|
|
375
398
|
}
|
|
376
|
-
|
|
377
|
-
if (this.
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
399
|
+
_setupBlurWatcher() {
|
|
400
|
+
if (!this._inputControl || !this.editConfig()?.blurEdit)
|
|
401
|
+
return;
|
|
402
|
+
toObservable(this._inputControl.state)
|
|
403
|
+
.pipe(map(state => state.blurred), pairwise(), filter(([prev, curr]) => !prev && curr), takeUntilDestroyed(this._destroyRef))
|
|
404
|
+
.subscribe(() => {
|
|
405
|
+
this._handleInputBlur();
|
|
406
|
+
});
|
|
381
407
|
}
|
|
382
408
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.6", ngImport: i0, type: ZTableEditCellComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
383
409
|
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.0.6", type: ZTableEditCellComponent, isStandalone: true, selector: "z-table-edit-cell", inputs: { zRow: { classPropertyName: "zRow", publicName: "zRow", isSignal: true, isRequired: true, transformFunction: null }, zRowId: { classPropertyName: "zRowId", publicName: "zRowId", isSignal: true, isRequired: true, transformFunction: null }, zRowIndex: { classPropertyName: "zRowIndex", publicName: "zRowIndex", isSignal: true, isRequired: true, transformFunction: null }, zColumnId: { classPropertyName: "zColumnId", publicName: "zColumnId", isSignal: true, isRequired: true, transformFunction: null }, zValue: { classPropertyName: "zValue", publicName: "zValue", isSignal: true, isRequired: false, transformFunction: null }, zEditConfig: { classPropertyName: "zEditConfig", publicName: "zEditConfig", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { zChange: "zChange" }, host: { classAttribute: "z-table-edit-cell block" }, ngImport: i0, template: `
|
|
@@ -392,6 +418,16 @@ class ZTableEditCellComponent {
|
|
|
392
418
|
/>
|
|
393
419
|
</div>
|
|
394
420
|
}
|
|
421
|
+
@case ('toggle') {
|
|
422
|
+
<div class="flex items-center justify-center">
|
|
423
|
+
<z-switch
|
|
424
|
+
[zSize]="size()"
|
|
425
|
+
[zChecked]="booleanValue()"
|
|
426
|
+
[zDisabled]="isDisabled()"
|
|
427
|
+
(zChange)="onToggleChange($event)"
|
|
428
|
+
/>
|
|
429
|
+
</div>
|
|
430
|
+
}
|
|
395
431
|
@case ('number') {
|
|
396
432
|
<z-input
|
|
397
433
|
zType="number"
|
|
@@ -404,6 +440,7 @@ class ZTableEditCellComponent {
|
|
|
404
440
|
[zDisabled]="isDisabled()"
|
|
405
441
|
[ngModel]="numericValue()"
|
|
406
442
|
(ngModelChange)="onValueChange($event)"
|
|
443
|
+
(zControl)="onInputControlReady($event)"
|
|
407
444
|
class="w-full"
|
|
408
445
|
/>
|
|
409
446
|
}
|
|
@@ -443,6 +480,7 @@ class ZTableEditCellComponent {
|
|
|
443
480
|
[zDisabled]="isDisabled()"
|
|
444
481
|
[ngModel]="stringValue()"
|
|
445
482
|
(ngModelChange)="onValueChange($event)"
|
|
483
|
+
(zControl)="onInputControlReady($event)"
|
|
446
484
|
class="w-full"
|
|
447
485
|
/>
|
|
448
486
|
}
|
|
@@ -454,15 +492,16 @@ class ZTableEditCellComponent {
|
|
|
454
492
|
[zDisabled]="isDisabled()"
|
|
455
493
|
[ngModel]="stringValue()"
|
|
456
494
|
(ngModelChange)="onValueChange($event)"
|
|
495
|
+
(zControl)="onInputControlReady($event)"
|
|
457
496
|
class="w-full"
|
|
458
497
|
/>
|
|
459
498
|
}
|
|
460
499
|
}
|
|
461
|
-
`, isInline: true, styles: [":host{display:block;width:100%}\n"], dependencies: [{ kind: "ngmodule", type: FormsModule }, { 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: ZInputComponent, selector: "z-input", inputs: ["class", "zType", "zSize", "zLabel", "zLabelClass", "zPlaceholder", "zRequired", "zDisabled", "zReadonly", "zPrefix", "zSuffix", "zMin", "zMax", "zStep", "zShowArrows", "zMask", "zDecimalPlaces", "zAllowNegative", "zThousandSeparator", "zDecimalMarker", "zValidators", "zAsyncValidators", "zAsyncDebounce", "zAsyncValidateOn", "zShowPasswordToggle", "zSearch", "zDebounce", "zAutofocus", "zAutoComplete", "zAllowClear", "zAutoSizeContent", "zRows", "zResize", "zMaxLength", "zAutoSuggest"], outputs: ["zOnSearch", "zOnChange", "zControl"], exportAs: ["zInput"] }, { kind: "component", type: ZSelectComponent, selector: "z-select", inputs: ["class", "zMode", "zSize", "zLabel", "zLabelClass", "zPlaceholder", "zRequired", "zDisabled", "zReadonly", "zLoading", "zPrefix", "zAllowClear", "zWrap", "zShowSearch", "zPlaceholderSearch", "zDebounce", "zNotFoundText", "zEmptyText", "zEmptyIcon", "zMaxTagCount", "zDropdownMaxHeight", "zOptionHeight", "zVirtualScroll", "zShowAction", "zOptions", "zTranslateLabels", "zKey", "zSearchServer", "zLoadingMore", "zEnableLoadMore", "zScrollDistance", "zMaxVisible", "zScrollClose", "zSelectedTemplate", "zOptionTemplate", "zActionTemplate", "zAsyncValidators", "zAsyncDebounce", "zAsyncValidateOn", "zValidators"], outputs: ["zOnSearch", "zOnLoadMore", "zControl"], exportAs: ["zSelect"] }, { kind: "component", type: ZCalendarComponent, selector: "z-calendar", inputs: ["class", "zMode", "zSize", "zLabel", "zLabelClass", "zPlaceholder", "zRequired", "zDisabled", "zReadonly", "zShowTime", "zTimeFormat", "zShowHour", "zShowMinute", "zShowSecond", "zQuickSelect", "zAllowClear", "zFormat", "zMinDate", "zMaxDate", "zValueType", "zValidators", "zShowOk", "zOkText", "zShowCancel", "zCancelText", "zDisabledDate", "zScrollClose", "zDefaultTime", "zRangeDefaultTime"], outputs: ["zControl", "zChange"], exportAs: ["zCalendar"] }, { kind: "component", type: ZCheckboxComponent, selector: "z-checkbox", inputs: ["class", "zType", "zSize", "zLabel", "zText", "zDisabled", "zIndeterminate", "zValue", "zOptions", "zOrientation", "zCheckAll", "zCheckAllText", "zChecked", "zGroupValue"], outputs: ["zChange", "zGroupChange", "zControl", "zCheckedChange", "zGroupValueChange"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
500
|
+
`, isInline: true, styles: [":host{display:block;width:100%}\n"], dependencies: [{ kind: "ngmodule", type: FormsModule }, { 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: ZInputComponent, selector: "z-input", inputs: ["class", "zType", "zSize", "zLabel", "zLabelClass", "zPlaceholder", "zRequired", "zDisabled", "zReadonly", "zPrefix", "zSuffix", "zMin", "zMax", "zStep", "zShowArrows", "zMask", "zDecimalPlaces", "zAllowNegative", "zThousandSeparator", "zDecimalMarker", "zValidators", "zAsyncValidators", "zAsyncDebounce", "zAsyncValidateOn", "zShowPasswordToggle", "zSearch", "zDebounce", "zAutofocus", "zAutoComplete", "zAllowClear", "zAutoSizeContent", "zRows", "zResize", "zMaxLength", "zAutoSuggest"], outputs: ["zOnSearch", "zOnChange", "zControl"], exportAs: ["zInput"] }, { kind: "component", type: ZSelectComponent, selector: "z-select", inputs: ["class", "zMode", "zSize", "zLabel", "zLabelClass", "zPlaceholder", "zRequired", "zDisabled", "zReadonly", "zLoading", "zPrefix", "zAllowClear", "zWrap", "zShowSearch", "zPlaceholderSearch", "zDebounce", "zNotFoundText", "zEmptyText", "zEmptyIcon", "zMaxTagCount", "zDropdownMaxHeight", "zOptionHeight", "zVirtualScroll", "zShowAction", "zOptions", "zTranslateLabels", "zKey", "zSearchServer", "zLoadingMore", "zEnableLoadMore", "zScrollDistance", "zMaxVisible", "zScrollClose", "zSelectedTemplate", "zOptionTemplate", "zActionTemplate", "zAsyncValidators", "zAsyncDebounce", "zAsyncValidateOn", "zValidators"], outputs: ["zOnSearch", "zOnLoadMore", "zControl"], exportAs: ["zSelect"] }, { kind: "component", type: ZCalendarComponent, selector: "z-calendar", inputs: ["class", "zMode", "zSize", "zLabel", "zLabelClass", "zPlaceholder", "zRequired", "zDisabled", "zReadonly", "zShowTime", "zTimeFormat", "zShowHour", "zShowMinute", "zShowSecond", "zQuickSelect", "zAllowClear", "zFormat", "zMinDate", "zMaxDate", "zValueType", "zValidators", "zShowOk", "zOkText", "zShowCancel", "zCancelText", "zDisabledDate", "zScrollClose", "zDefaultTime", "zRangeDefaultTime"], outputs: ["zControl", "zChange"], exportAs: ["zCalendar"] }, { kind: "component", type: ZCheckboxComponent, selector: "z-checkbox", inputs: ["class", "zType", "zSize", "zLabel", "zText", "zDisabled", "zIndeterminate", "zValue", "zOptions", "zOrientation", "zCheckAll", "zCheckAllText", "zChecked", "zGroupValue"], outputs: ["zChange", "zGroupChange", "zControl", "zCheckedChange", "zGroupValueChange"] }, { kind: "component", type: ZSwitchComponent, selector: "z-switch", inputs: ["class", "zSize", "zLabel", "zText", "zDisabled", "zLoading", "zTextPosition", "zChecked"], outputs: ["zChange", "zCheckedChange"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
462
501
|
}
|
|
463
502
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.6", ngImport: i0, type: ZTableEditCellComponent, decorators: [{
|
|
464
503
|
type: Component,
|
|
465
|
-
args: [{ selector: 'z-table-edit-cell', imports: [FormsModule, ZInputComponent, ZSelectComponent, ZCalendarComponent, ZCheckboxComponent], standalone: true, template: `
|
|
504
|
+
args: [{ selector: 'z-table-edit-cell', imports: [FormsModule, ZInputComponent, ZSelectComponent, ZCalendarComponent, ZCheckboxComponent, ZSwitchComponent], standalone: true, template: `
|
|
466
505
|
@switch (editType()) {
|
|
467
506
|
@case ('checkbox') {
|
|
468
507
|
<div class="flex items-center justify-center">
|
|
@@ -474,6 +513,16 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.6", ngImpor
|
|
|
474
513
|
/>
|
|
475
514
|
</div>
|
|
476
515
|
}
|
|
516
|
+
@case ('toggle') {
|
|
517
|
+
<div class="flex items-center justify-center">
|
|
518
|
+
<z-switch
|
|
519
|
+
[zSize]="size()"
|
|
520
|
+
[zChecked]="booleanValue()"
|
|
521
|
+
[zDisabled]="isDisabled()"
|
|
522
|
+
(zChange)="onToggleChange($event)"
|
|
523
|
+
/>
|
|
524
|
+
</div>
|
|
525
|
+
}
|
|
477
526
|
@case ('number') {
|
|
478
527
|
<z-input
|
|
479
528
|
zType="number"
|
|
@@ -486,6 +535,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.6", ngImpor
|
|
|
486
535
|
[zDisabled]="isDisabled()"
|
|
487
536
|
[ngModel]="numericValue()"
|
|
488
537
|
(ngModelChange)="onValueChange($event)"
|
|
538
|
+
(zControl)="onInputControlReady($event)"
|
|
489
539
|
class="w-full"
|
|
490
540
|
/>
|
|
491
541
|
}
|
|
@@ -525,6 +575,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.6", ngImpor
|
|
|
525
575
|
[zDisabled]="isDisabled()"
|
|
526
576
|
[ngModel]="stringValue()"
|
|
527
577
|
(ngModelChange)="onValueChange($event)"
|
|
578
|
+
(zControl)="onInputControlReady($event)"
|
|
528
579
|
class="w-full"
|
|
529
580
|
/>
|
|
530
581
|
}
|
|
@@ -536,6 +587,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.6", ngImpor
|
|
|
536
587
|
[zDisabled]="isDisabled()"
|
|
537
588
|
[ngModel]="stringValue()"
|
|
538
589
|
(ngModelChange)="onValueChange($event)"
|
|
590
|
+
(zControl)="onInputControlReady($event)"
|
|
539
591
|
class="w-full"
|
|
540
592
|
/>
|
|
541
593
|
}
|