@shival99/z-ui 1.2.11 → 1.2.12
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/fesm2022/shival99-z-ui-components-z-table.mjs +140 -30
- package/fesm2022/shival99-z-ui-components-z-table.mjs.map +1 -1
- package/fesm2022/shival99-z-ui-i18n.mjs +2 -0
- package/fesm2022/shival99-z-ui-i18n.mjs.map +1 -1
- package/package.json +1 -1
- package/types/shival99-z-ui-components-z-table.d.ts +6 -0
|
@@ -243,9 +243,22 @@ class ZTableFilterComponent {
|
|
|
243
243
|
}
|
|
244
244
|
return null;
|
|
245
245
|
}, ...(ngDevMode ? [{ debugName: "dateRangeValue" }] : []));
|
|
246
|
+
selectValue = computed(() => {
|
|
247
|
+
const value = this.columnFilterValue();
|
|
248
|
+
if (value === null || value === undefined || value === '') {
|
|
249
|
+
return null;
|
|
250
|
+
}
|
|
251
|
+
return value;
|
|
252
|
+
}, ...(ngDevMode ? [{ debugName: "selectValue" }] : []));
|
|
253
|
+
multiSelectValue = computed(() => {
|
|
254
|
+
const value = this.columnFilterValue();
|
|
255
|
+
if (Array.isArray(value)) {
|
|
256
|
+
return value;
|
|
257
|
+
}
|
|
258
|
+
return [];
|
|
259
|
+
}, ...(ngDevMode ? [{ debugName: "multiSelectValue" }] : []));
|
|
246
260
|
selectOptions = computed(() => {
|
|
247
261
|
const columnDef = this._columnDef();
|
|
248
|
-
// Note: 'All' option is handled via zPlaceholder in template
|
|
249
262
|
if (columnDef.filterOptions && columnDef.filterOptions.length > 0) {
|
|
250
263
|
return columnDef.filterOptions;
|
|
251
264
|
}
|
|
@@ -281,6 +294,13 @@ class ZTableFilterComponent {
|
|
|
281
294
|
}
|
|
282
295
|
this.zColumn().setFilterValue(value || undefined);
|
|
283
296
|
}
|
|
297
|
+
onMultiSelectChange(value) {
|
|
298
|
+
if (!value || (Array.isArray(value) && value.length === 0)) {
|
|
299
|
+
this.zColumn().setFilterValue(undefined);
|
|
300
|
+
return;
|
|
301
|
+
}
|
|
302
|
+
this.zColumn().setFilterValue(value);
|
|
303
|
+
}
|
|
284
304
|
onDateChange(value) {
|
|
285
305
|
this.zColumn().setFilterValue(value || undefined);
|
|
286
306
|
}
|
|
@@ -347,13 +367,41 @@ class ZTableFilterComponent {
|
|
|
347
367
|
@case ('select') {
|
|
348
368
|
<z-select
|
|
349
369
|
zSize="sm"
|
|
370
|
+
zAllowClear
|
|
371
|
+
[zWrap]="false"
|
|
350
372
|
[zOptions]="selectOptions()"
|
|
351
|
-
[ngModel]="
|
|
352
|
-
[zPlaceholder]="'
|
|
373
|
+
[ngModel]="selectValue()"
|
|
374
|
+
[zPlaceholder]="'i18n_z_ui_common_select' | translate"
|
|
353
375
|
(ngModelChange)="onSelectChange($event)"
|
|
354
376
|
class="w-full min-w-0"
|
|
355
377
|
/>
|
|
356
378
|
}
|
|
379
|
+
@case ('multi-select') {
|
|
380
|
+
<z-select
|
|
381
|
+
zMode="multiple"
|
|
382
|
+
zSize="sm"
|
|
383
|
+
zAllowClear
|
|
384
|
+
[zWrap]="false"
|
|
385
|
+
[zOptions]="selectOptions()"
|
|
386
|
+
[ngModel]="multiSelectValue()"
|
|
387
|
+
[zPlaceholder]="'i18n_z_ui_common_select' | translate"
|
|
388
|
+
(ngModelChange)="onMultiSelectChange($event)"
|
|
389
|
+
class="w-full min-w-0"
|
|
390
|
+
/>
|
|
391
|
+
}
|
|
392
|
+
@case ('tags') {
|
|
393
|
+
<z-select
|
|
394
|
+
zMode="tags"
|
|
395
|
+
zSize="sm"
|
|
396
|
+
zAllowClear
|
|
397
|
+
[zWrap]="false"
|
|
398
|
+
[zOptions]="selectOptions()"
|
|
399
|
+
[ngModel]="multiSelectValue()"
|
|
400
|
+
[zPlaceholder]="'i18n_z_ui_common_select' | translate"
|
|
401
|
+
(ngModelChange)="onMultiSelectChange($event)"
|
|
402
|
+
class="w-full min-w-0"
|
|
403
|
+
/>
|
|
404
|
+
}
|
|
357
405
|
@case ('number') {
|
|
358
406
|
<z-input
|
|
359
407
|
zType="number"
|
|
@@ -377,15 +425,11 @@ class ZTableFilterComponent {
|
|
|
377
425
|
/>
|
|
378
426
|
}
|
|
379
427
|
}
|
|
380
|
-
`, isInline: true, 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", "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", "zLocale", "zShowOk", "zOkText", "zShowCancel", "zCancelText", "zDisabledDate"], outputs: ["zControl", "zChange"], exportAs: ["zCalendar"] }, { kind: "pipe", type: TranslatePipe, name: "translate" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
428
|
+
`, isInline: true, styles: [":host{color:var(--foreground);font-weight:450;font-style:normal;text-decoration:none;text-transform:none;letter-spacing:normal}\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", "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", "zLocale", "zShowOk", "zOkText", "zShowCancel", "zCancelText", "zDisabledDate"], outputs: ["zControl", "zChange"], exportAs: ["zCalendar"] }, { kind: "pipe", type: TranslatePipe, name: "translate" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
381
429
|
}
|
|
382
430
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.6", ngImport: i0, type: ZTableFilterComponent, decorators: [{
|
|
383
431
|
type: Component,
|
|
384
|
-
args: [{
|
|
385
|
-
selector: 'z-table-filter',
|
|
386
|
-
imports: [FormsModule, ZInputComponent, ZSelectComponent, ZCalendarComponent, TranslatePipe],
|
|
387
|
-
standalone: true,
|
|
388
|
-
template: `
|
|
432
|
+
args: [{ selector: 'z-table-filter', imports: [FormsModule, ZInputComponent, ZSelectComponent, ZCalendarComponent, TranslatePipe], standalone: true, template: `
|
|
389
433
|
@switch (filterType()) {
|
|
390
434
|
@case ('range') {
|
|
391
435
|
<div class="flex gap-1">
|
|
@@ -434,13 +478,41 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.6", ngImpor
|
|
|
434
478
|
@case ('select') {
|
|
435
479
|
<z-select
|
|
436
480
|
zSize="sm"
|
|
481
|
+
zAllowClear
|
|
482
|
+
[zWrap]="false"
|
|
437
483
|
[zOptions]="selectOptions()"
|
|
438
|
-
[ngModel]="
|
|
439
|
-
[zPlaceholder]="'
|
|
484
|
+
[ngModel]="selectValue()"
|
|
485
|
+
[zPlaceholder]="'i18n_z_ui_common_select' | translate"
|
|
440
486
|
(ngModelChange)="onSelectChange($event)"
|
|
441
487
|
class="w-full min-w-0"
|
|
442
488
|
/>
|
|
443
489
|
}
|
|
490
|
+
@case ('multi-select') {
|
|
491
|
+
<z-select
|
|
492
|
+
zMode="multiple"
|
|
493
|
+
zSize="sm"
|
|
494
|
+
zAllowClear
|
|
495
|
+
[zWrap]="false"
|
|
496
|
+
[zOptions]="selectOptions()"
|
|
497
|
+
[ngModel]="multiSelectValue()"
|
|
498
|
+
[zPlaceholder]="'i18n_z_ui_common_select' | translate"
|
|
499
|
+
(ngModelChange)="onMultiSelectChange($event)"
|
|
500
|
+
class="w-full min-w-0"
|
|
501
|
+
/>
|
|
502
|
+
}
|
|
503
|
+
@case ('tags') {
|
|
504
|
+
<z-select
|
|
505
|
+
zMode="tags"
|
|
506
|
+
zSize="sm"
|
|
507
|
+
zAllowClear
|
|
508
|
+
[zWrap]="false"
|
|
509
|
+
[zOptions]="selectOptions()"
|
|
510
|
+
[ngModel]="multiSelectValue()"
|
|
511
|
+
[zPlaceholder]="'i18n_z_ui_common_select' | translate"
|
|
512
|
+
(ngModelChange)="onMultiSelectChange($event)"
|
|
513
|
+
class="w-full min-w-0"
|
|
514
|
+
/>
|
|
515
|
+
}
|
|
444
516
|
@case ('number') {
|
|
445
517
|
<z-input
|
|
446
518
|
zType="number"
|
|
@@ -464,12 +536,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.6", ngImpor
|
|
|
464
536
|
/>
|
|
465
537
|
}
|
|
466
538
|
}
|
|
467
|
-
`,
|
|
468
|
-
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
469
|
-
host: {
|
|
539
|
+
`, changeDetection: ChangeDetectionStrategy.OnPush, host: {
|
|
470
540
|
class: 'z-table-filter block',
|
|
471
|
-
},
|
|
472
|
-
}]
|
|
541
|
+
}, styles: [":host{color:var(--foreground);font-weight:450;font-style:normal;text-decoration:none;text-transform:none;letter-spacing:normal}\n"] }]
|
|
473
542
|
}], propDecorators: { zColumn: [{ type: i0.Input, args: [{ isSignal: true, alias: "zColumn", required: true }] }], zTable: [{ type: i0.Input, args: [{ isSignal: true, alias: "zTable", required: true }] }] } });
|
|
474
543
|
|
|
475
544
|
const Z_DEFAULT_ROW_HEIGHT = 40;
|
|
@@ -881,6 +950,22 @@ function columnConfigToColumnDef(config) {
|
|
|
881
950
|
return cellValue === filterValue;
|
|
882
951
|
};
|
|
883
952
|
}
|
|
953
|
+
if (filterConfig?.type === 'multi-select' || filterConfig?.type === 'tags') {
|
|
954
|
+
columnDef.filterFn = (row, columnId, filterValue) => {
|
|
955
|
+
if (!filterValue || (Array.isArray(filterValue) && filterValue.length === 0)) {
|
|
956
|
+
return true;
|
|
957
|
+
}
|
|
958
|
+
const cellValue = row.getValue(columnId);
|
|
959
|
+
if (!Array.isArray(filterValue)) {
|
|
960
|
+
return cellValue === filterValue;
|
|
961
|
+
}
|
|
962
|
+
const filterSet = new Set(filterValue);
|
|
963
|
+
if (Array.isArray(cellValue)) {
|
|
964
|
+
return cellValue.some(cv => filterSet.has(cv));
|
|
965
|
+
}
|
|
966
|
+
return filterSet.has(cellValue);
|
|
967
|
+
};
|
|
968
|
+
}
|
|
884
969
|
if (config.columns && config.columns.length > 0) {
|
|
885
970
|
columnDef.columns = config.columns.map(subConfig => columnConfigToColumnDef(subConfig));
|
|
886
971
|
}
|
|
@@ -1929,6 +2014,8 @@ class ZTableComponent {
|
|
|
1929
2014
|
_columnPinVersion = signal(0, ...(ngDevMode ? [{ debugName: "_columnPinVersion" }] : []));
|
|
1930
2015
|
_dataForceUpdate = signal(0, ...(ngDevMode ? [{ debugName: "_dataForceUpdate" }] : []));
|
|
1931
2016
|
_configLoadedFromCache = signal(false, ...(ngDevMode ? [{ debugName: "_configLoadedFromCache" }] : []));
|
|
2017
|
+
_columnConfigCache = new Map();
|
|
2018
|
+
_lastColumnsRef = null;
|
|
1932
2019
|
pinnedColumnIds = computed(() => {
|
|
1933
2020
|
this._columnPinVersion();
|
|
1934
2021
|
return this.columnOrder().filter(id => {
|
|
@@ -2146,23 +2233,37 @@ class ZTableComponent {
|
|
|
2146
2233
|
virtualRowHeight = computed(() => this._virtualConfig().rowHeight ?? Z_DEFAULT_ROW_HEIGHT, ...(ngDevMode ? [{ debugName: "virtualRowHeight" }] : []));
|
|
2147
2234
|
groupSize = computed(() => this._virtualConfig().groupSize ?? Z_DEFAULT_GROUP_SIZE, ...(ngDevMode ? [{ debugName: "groupSize" }] : []));
|
|
2148
2235
|
groupHeight = computed(() => this.groupSize() * this.virtualRowHeight(), ...(ngDevMode ? [{ debugName: "groupHeight" }] : []));
|
|
2236
|
+
_dynamicGroupsVersion = signal(0, ...(ngDevMode ? [{ debugName: "_dynamicGroupsVersion" }] : []));
|
|
2149
2237
|
dynamicGroups = computed(() => {
|
|
2150
2238
|
if (!this.isVirtual()) {
|
|
2151
2239
|
return [];
|
|
2152
2240
|
}
|
|
2153
|
-
this.
|
|
2154
|
-
this.
|
|
2155
|
-
this.sorting();
|
|
2156
|
-
this.pagination();
|
|
2157
|
-
const rows = untracked(() => this.table.getRowModel().rows);
|
|
2241
|
+
this._dynamicGroupsVersion();
|
|
2242
|
+
const { rows } = this.table.getRowModel();
|
|
2158
2243
|
const rowHeight = this.virtualRowHeight();
|
|
2244
|
+
if (!this.hasBodyRowSpan()) {
|
|
2245
|
+
const size = this.groupSize();
|
|
2246
|
+
const groups = [];
|
|
2247
|
+
const totalGroups = Math.ceil(rows.length / size);
|
|
2248
|
+
for (let j = 0; j < totalGroups; j++) {
|
|
2249
|
+
const startIndex = j * size;
|
|
2250
|
+
const endIndex = Math.min(startIndex + size - 1, rows.length - 1);
|
|
2251
|
+
groups.push({
|
|
2252
|
+
startIndex,
|
|
2253
|
+
endIndex,
|
|
2254
|
+
rowCount: endIndex - startIndex + 1,
|
|
2255
|
+
height: (endIndex - startIndex + 1) * rowHeight,
|
|
2256
|
+
});
|
|
2257
|
+
}
|
|
2258
|
+
return groups;
|
|
2259
|
+
}
|
|
2159
2260
|
const groups = [];
|
|
2160
2261
|
let i = 0;
|
|
2161
2262
|
while (i < rows.length) {
|
|
2162
2263
|
const startIndex = i;
|
|
2163
2264
|
let maxRowSpan = 1;
|
|
2164
2265
|
const row = rows[i];
|
|
2165
|
-
const cells =
|
|
2266
|
+
const cells = row.getAllCells();
|
|
2166
2267
|
for (const cell of cells) {
|
|
2167
2268
|
const columnConfig = this._findColumnConfig(cell.column.id);
|
|
2168
2269
|
const rowSpanValue = getBodyRowSpan(columnConfig, cell.getContext());
|
|
@@ -2485,7 +2586,6 @@ class ZTableComponent {
|
|
|
2485
2586
|
const cfg = this.zConfig();
|
|
2486
2587
|
const initial = cfg.initialState;
|
|
2487
2588
|
untracked(() => {
|
|
2488
|
-
// Skip if config was already loaded from cache
|
|
2489
2589
|
if (this._configLoadedFromCache()) {
|
|
2490
2590
|
return;
|
|
2491
2591
|
}
|
|
@@ -2591,13 +2691,13 @@ class ZTableComponent {
|
|
|
2591
2691
|
}
|
|
2592
2692
|
return;
|
|
2593
2693
|
}
|
|
2594
|
-
|
|
2694
|
+
queueMicrotask(() => {
|
|
2595
2695
|
const wrapperEl = this.tbodyWrapper()?.nativeElement;
|
|
2596
2696
|
if (wrapperEl) {
|
|
2597
2697
|
wrapperEl.scrollTop = 0;
|
|
2598
2698
|
wrapperEl.scrollLeft = this._savedScrollLeft();
|
|
2599
2699
|
}
|
|
2600
|
-
}
|
|
2700
|
+
});
|
|
2601
2701
|
});
|
|
2602
2702
|
explicitEffect([
|
|
2603
2703
|
this.columnOrder,
|
|
@@ -2856,10 +2956,10 @@ class ZTableComponent {
|
|
|
2856
2956
|
pagination: this.pagination(),
|
|
2857
2957
|
},
|
|
2858
2958
|
});
|
|
2859
|
-
|
|
2959
|
+
queueMicrotask(() => {
|
|
2860
2960
|
this._checkVerticalScroll();
|
|
2861
2961
|
this._checkHorizontalScroll();
|
|
2862
|
-
}
|
|
2962
|
+
});
|
|
2863
2963
|
});
|
|
2864
2964
|
}
|
|
2865
2965
|
toggleHeaderFooterShadow() {
|
|
@@ -3088,8 +3188,16 @@ class ZTableComponent {
|
|
|
3088
3188
|
}
|
|
3089
3189
|
}
|
|
3090
3190
|
_findColumnConfig(columnId) {
|
|
3091
|
-
const
|
|
3092
|
-
|
|
3191
|
+
const { columns } = this.zConfig();
|
|
3192
|
+
if (columns !== this._lastColumnsRef) {
|
|
3193
|
+
this._columnConfigCache.clear();
|
|
3194
|
+
this._lastColumnsRef = columns;
|
|
3195
|
+
}
|
|
3196
|
+
if (this._columnConfigCache.has(columnId)) {
|
|
3197
|
+
return this._columnConfigCache.get(columnId);
|
|
3198
|
+
}
|
|
3199
|
+
const findInColumns = (cols) => {
|
|
3200
|
+
for (const col of cols) {
|
|
3093
3201
|
if (col.id === columnId) {
|
|
3094
3202
|
return col;
|
|
3095
3203
|
}
|
|
@@ -3102,7 +3210,9 @@ class ZTableComponent {
|
|
|
3102
3210
|
}
|
|
3103
3211
|
return undefined;
|
|
3104
3212
|
};
|
|
3105
|
-
|
|
3213
|
+
const result = findInColumns(columns);
|
|
3214
|
+
this._columnConfigCache.set(columnId, result);
|
|
3215
|
+
return result;
|
|
3106
3216
|
}
|
|
3107
3217
|
_filterVisibleColumns(columns) {
|
|
3108
3218
|
return columns
|