@shival99/z-ui 2.1.28 → 2.1.29

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.
Files changed (68) hide show
  1. package/package.json +1 -1
  2. package/types/shival99-z-ui-components-z-select.d.ts +1 -1
  3. package/fesm2022/shival99-z-ui-components-z-autocomplete.mjs +0 -1079
  4. package/fesm2022/shival99-z-ui-components-z-autocomplete.mjs.map +0 -1
  5. package/fesm2022/shival99-z-ui-components-z-drawer.mjs +0 -742
  6. package/fesm2022/shival99-z-ui-components-z-drawer.mjs.map +0 -1
  7. package/fesm2022/shival99-z-ui-components-z-dropdown-menu.mjs +0 -58
  8. package/fesm2022/shival99-z-ui-components-z-dropdown-menu.mjs.map +0 -1
  9. package/fesm2022/shival99-z-ui-components-z-editor.mjs +0 -1750
  10. package/fesm2022/shival99-z-ui-components-z-editor.mjs.map +0 -1
  11. package/fesm2022/shival99-z-ui-components-z-gallery.mjs +0 -2419
  12. package/fesm2022/shival99-z-ui-components-z-gallery.mjs.map +0 -1
  13. package/fesm2022/shival99-z-ui-components-z-kanban.mjs +0 -981
  14. package/fesm2022/shival99-z-ui-components-z-kanban.mjs.map +0 -1
  15. package/fesm2022/shival99-z-ui-components-z-marquee.mjs +0 -70
  16. package/fesm2022/shival99-z-ui-components-z-marquee.mjs.map +0 -1
  17. package/fesm2022/shival99-z-ui-components-z-media-player.mjs +0 -668
  18. package/fesm2022/shival99-z-ui-components-z-media-player.mjs.map +0 -1
  19. package/fesm2022/shival99-z-ui-components-z-menu.mjs +0 -843
  20. package/fesm2022/shival99-z-ui-components-z-menu.mjs.map +0 -1
  21. package/fesm2022/shival99-z-ui-components-z-metric-card.mjs +0 -128
  22. package/fesm2022/shival99-z-ui-components-z-metric-card.mjs.map +0 -1
  23. package/fesm2022/shival99-z-ui-components-z-pagination.mjs +0 -158
  24. package/fesm2022/shival99-z-ui-components-z-pagination.mjs.map +0 -1
  25. package/fesm2022/shival99-z-ui-components-z-qrcode.mjs +0 -383
  26. package/fesm2022/shival99-z-ui-components-z-qrcode.mjs.map +0 -1
  27. package/fesm2022/shival99-z-ui-components-z-radio.mjs +0 -167
  28. package/fesm2022/shival99-z-ui-components-z-radio.mjs.map +0 -1
  29. package/fesm2022/shival99-z-ui-components-z-scrollarea.mjs +0 -131
  30. package/fesm2022/shival99-z-ui-components-z-scrollarea.mjs.map +0 -1
  31. package/fesm2022/shival99-z-ui-components-z-show-more.mjs +0 -121
  32. package/fesm2022/shival99-z-ui-components-z-show-more.mjs.map +0 -1
  33. package/fesm2022/shival99-z-ui-components-z-skeleton-auto.mjs +0 -61
  34. package/fesm2022/shival99-z-ui-components-z-skeleton-auto.mjs.map +0 -1
  35. package/fesm2022/shival99-z-ui-components-z-steps.mjs +0 -396
  36. package/fesm2022/shival99-z-ui-components-z-steps.mjs.map +0 -1
  37. package/fesm2022/shival99-z-ui-components-z-table.mjs +0 -10508
  38. package/fesm2022/shival99-z-ui-components-z-table.mjs.map +0 -1
  39. package/fesm2022/shival99-z-ui-components-z-tabs.mjs +0 -507
  40. package/fesm2022/shival99-z-ui-components-z-tabs.mjs.map +0 -1
  41. package/fesm2022/shival99-z-ui-components-z-tags.mjs +0 -349
  42. package/fesm2022/shival99-z-ui-components-z-tags.mjs.map +0 -1
  43. package/fesm2022/shival99-z-ui-components-z-timeline.mjs +0 -237
  44. package/fesm2022/shival99-z-ui-components-z-timeline.mjs.map +0 -1
  45. package/fesm2022/shival99-z-ui-components-z-upload.mjs +0 -523
  46. package/fesm2022/shival99-z-ui-components-z-upload.mjs.map +0 -1
  47. package/types/shival99-z-ui-components-z-autocomplete.d.ts +0 -290
  48. package/types/shival99-z-ui-components-z-drawer.d.ts +0 -266
  49. package/types/shival99-z-ui-components-z-dropdown-menu.d.ts +0 -54
  50. package/types/shival99-z-ui-components-z-editor.d.ts +0 -337
  51. package/types/shival99-z-ui-components-z-gallery.d.ts +0 -402
  52. package/types/shival99-z-ui-components-z-kanban.d.ts +0 -237
  53. package/types/shival99-z-ui-components-z-marquee.d.ts +0 -35
  54. package/types/shival99-z-ui-components-z-media-player.d.ts +0 -124
  55. package/types/shival99-z-ui-components-z-menu.d.ts +0 -222
  56. package/types/shival99-z-ui-components-z-metric-card.d.ts +0 -67
  57. package/types/shival99-z-ui-components-z-pagination.d.ts +0 -55
  58. package/types/shival99-z-ui-components-z-qrcode.d.ts +0 -76
  59. package/types/shival99-z-ui-components-z-radio.d.ts +0 -69
  60. package/types/shival99-z-ui-components-z-scrollarea.d.ts +0 -46
  61. package/types/shival99-z-ui-components-z-show-more.d.ts +0 -36
  62. package/types/shival99-z-ui-components-z-skeleton-auto.d.ts +0 -35
  63. package/types/shival99-z-ui-components-z-steps.d.ts +0 -106
  64. package/types/shival99-z-ui-components-z-table.d.ts +0 -1924
  65. package/types/shival99-z-ui-components-z-tabs.d.ts +0 -92
  66. package/types/shival99-z-ui-components-z-tags.d.ts +0 -128
  67. package/types/shival99-z-ui-components-z-timeline.d.ts +0 -71
  68. package/types/shival99-z-ui-components-z-upload.d.ts +0 -153
@@ -1,158 +0,0 @@
1
- import * as i0 from '@angular/core';
2
- import { inject, output, model, input, computed, ChangeDetectionStrategy, Component } from '@angular/core';
3
- import * as i1 from '@angular/forms';
4
- import { FormsModule } from '@angular/forms';
5
- import { TranslatePipe } from '@ngx-translate/core';
6
- import { ZButtonComponent } from '@shival99/z-ui/components/z-button';
7
- import { ZButtonGroupComponent } from '@shival99/z-ui/components/z-button-group';
8
- import { ZIconComponent } from '@shival99/z-ui/components/z-icon';
9
- import { ZInputComponent } from '@shival99/z-ui/components/z-input';
10
- import { ZSelectComponent } from '@shival99/z-ui/components/z-select';
11
- import { ZTranslateService } from '@shival99/z-ui/services';
12
-
13
- class ZPaginationComponent {
14
- _zTranslate = inject(ZTranslateService);
15
- zOnPageChange = output();
16
- zPageIndex = model(1, ...(ngDevMode ? [{ debugName: "zPageIndex" }] : []));
17
- zPageSize = model(10, ...(ngDevMode ? [{ debugName: "zPageSize" }] : []));
18
- zTotal = input.required(...(ngDevMode ? [{ debugName: "zTotal" }] : []));
19
- zPageSizeOptions = input([10, 20, 50, 100], ...(ngDevMode ? [{ debugName: "zPageSizeOptions" }] : []));
20
- zShowSizeChanger = input(true, ...(ngDevMode ? [{ debugName: "zShowSizeChanger" }] : []));
21
- zShowQuickJumper = input(false, ...(ngDevMode ? [{ debugName: "zShowQuickJumper" }] : []));
22
- zShowTotal = input(true, ...(ngDevMode ? [{ debugName: "zShowTotal" }] : []));
23
- zSimple = input(false, ...(ngDevMode ? [{ debugName: "zSimple" }] : []));
24
- zSize = input('default', ...(ngDevMode ? [{ debugName: "zSize" }] : []));
25
- zDisabled = input(false, ...(ngDevMode ? [{ debugName: "zDisabled" }] : []));
26
- zTotalLabel = input(null, ...(ngDevMode ? [{ debugName: "zTotalLabel" }] : []));
27
- zPerPageLabel = input(null, ...(ngDevMode ? [{ debugName: "zPerPageLabel" }] : []));
28
- zGoToLabel = input(null, ...(ngDevMode ? [{ debugName: "zGoToLabel" }] : []));
29
- totalLabelText = computed(() => {
30
- this._zTranslate.currentLang();
31
- if (this.zTotalLabel()) {
32
- return this.zTotalLabel().replace('{{total}}', String(this.zTotal()));
33
- }
34
- return this._zTranslate.instant('i18n_z_ui_pagination_total_label', { total: this.zTotal() });
35
- }, ...(ngDevMode ? [{ debugName: "totalLabelText" }] : []));
36
- perPageLabelText = computed(() => {
37
- this._zTranslate.currentLang();
38
- return this.zPerPageLabel() ?? this._zTranslate.instant('i18n_z_ui_pagination_per_page');
39
- }, ...(ngDevMode ? [{ debugName: "perPageLabelText" }] : []));
40
- goToLabelText = computed(() => {
41
- this._zTranslate.currentLang();
42
- return this.zGoToLabel() ?? this._zTranslate.instant('i18n_z_ui_pagination_go_to');
43
- }, ...(ngDevMode ? [{ debugName: "goToLabelText" }] : []));
44
- totalPages = computed(() => {
45
- const total = this.zTotal();
46
- const pageSize = this.zPageSize();
47
- return Math.max(1, Math.ceil(total / pageSize));
48
- }, ...(ngDevMode ? [{ debugName: "totalPages" }] : []));
49
- pageSizeOptions = computed(() => this.zPageSizeOptions().map(size => ({
50
- label: `${size} ${this.perPageLabelText()}`,
51
- value: size,
52
- })), ...(ngDevMode ? [{ debugName: "pageSizeOptions" }] : []));
53
- visiblePages = computed(() => {
54
- const current = this.zPageIndex();
55
- const total = this.totalPages();
56
- const pages = [];
57
- const maxVisible = 5;
58
- if (total <= maxVisible) {
59
- for (let i = 1; i <= total; i++) {
60
- pages.push(i);
61
- }
62
- return pages;
63
- }
64
- pages.push(1);
65
- let startPage = Math.max(2, current - 1);
66
- let endPage = Math.min(total - 1, current + 1);
67
- if (current <= 3) {
68
- endPage = Math.min(total - 1, 3);
69
- }
70
- else if (current >= total - 2) {
71
- startPage = Math.max(2, total - 2);
72
- }
73
- if (startPage > 2) {
74
- pages.push('ellipsis');
75
- }
76
- for (let i = startPage; i <= endPage; i++) {
77
- pages.push(i);
78
- }
79
- if (endPage < total - 1) {
80
- pages.push('ellipsis');
81
- }
82
- pages.push(total);
83
- return pages;
84
- }, ...(ngDevMode ? [{ debugName: "visiblePages" }] : []));
85
- canGoPrev = computed(() => this.zPageIndex() > 1, ...(ngDevMode ? [{ debugName: "canGoPrev" }] : []));
86
- canGoNext = computed(() => this.zPageIndex() < this.totalPages(), ...(ngDevMode ? [{ debugName: "canGoNext" }] : []));
87
- goToPage(page) {
88
- if (page < 1 || page > this.totalPages()) {
89
- return;
90
- }
91
- if (page === this.zPageIndex()) {
92
- return;
93
- }
94
- this.zPageIndex.set(page);
95
- this._emitChange();
96
- }
97
- goToPrev() {
98
- if (!this.canGoPrev()) {
99
- return;
100
- }
101
- this.goToPage(this.zPageIndex() - 1);
102
- }
103
- goToNext() {
104
- if (!this.canGoNext()) {
105
- return;
106
- }
107
- this.goToPage(this.zPageIndex() + 1);
108
- }
109
- onPageSizeChange(size) {
110
- const sizeValue = typeof size === 'object' && size !== null && 'value' in size
111
- ? size.value
112
- : size;
113
- if (!Number.isFinite(sizeValue) || sizeValue <= 0) {
114
- return;
115
- }
116
- this.zPageSize.set(sizeValue);
117
- this.zPageIndex.set(1);
118
- this._emitChange();
119
- }
120
- onQuickJump(event) {
121
- const input = event.target;
122
- const page = parseInt(input.value, 10);
123
- if (isNaN(page) || page < 1 || page > this.totalPages()) {
124
- input.value = String(this.zPageIndex());
125
- return;
126
- }
127
- this.goToPage(page);
128
- }
129
- _emitChange() {
130
- this.zOnPageChange.emit({
131
- pageIndex: this.zPageIndex(),
132
- pageSize: this.zPageSize(),
133
- });
134
- }
135
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.9", ngImport: i0, type: ZPaginationComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
136
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.0.9", type: ZPaginationComponent, isStandalone: true, selector: "z-pagination", inputs: { zPageIndex: { classPropertyName: "zPageIndex", publicName: "zPageIndex", isSignal: true, isRequired: false, transformFunction: null }, zPageSize: { classPropertyName: "zPageSize", publicName: "zPageSize", isSignal: true, isRequired: false, transformFunction: null }, zTotal: { classPropertyName: "zTotal", publicName: "zTotal", isSignal: true, isRequired: true, transformFunction: null }, zPageSizeOptions: { classPropertyName: "zPageSizeOptions", publicName: "zPageSizeOptions", isSignal: true, isRequired: false, transformFunction: null }, zShowSizeChanger: { classPropertyName: "zShowSizeChanger", publicName: "zShowSizeChanger", isSignal: true, isRequired: false, transformFunction: null }, zShowQuickJumper: { classPropertyName: "zShowQuickJumper", publicName: "zShowQuickJumper", isSignal: true, isRequired: false, transformFunction: null }, zShowTotal: { classPropertyName: "zShowTotal", publicName: "zShowTotal", isSignal: true, isRequired: false, transformFunction: null }, zSimple: { classPropertyName: "zSimple", publicName: "zSimple", isSignal: true, isRequired: false, transformFunction: null }, zSize: { classPropertyName: "zSize", publicName: "zSize", isSignal: true, isRequired: false, transformFunction: null }, zDisabled: { classPropertyName: "zDisabled", publicName: "zDisabled", isSignal: true, isRequired: false, transformFunction: null }, zTotalLabel: { classPropertyName: "zTotalLabel", publicName: "zTotalLabel", isSignal: true, isRequired: false, transformFunction: null }, zPerPageLabel: { classPropertyName: "zPerPageLabel", publicName: "zPerPageLabel", isSignal: true, isRequired: false, transformFunction: null }, zGoToLabel: { classPropertyName: "zGoToLabel", publicName: "zGoToLabel", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { zOnPageChange: "zOnPageChange", zPageIndex: "zPageIndexChange", zPageSize: "zPageSizeChange" }, host: { classAttribute: "z-pagination flex items-center gap-2" }, ngImport: i0, template: "@if (zShowTotal()) {\n <span class=\"text-muted-foreground text-sm whitespace-nowrap\">{{ totalLabelText() }}</span>\n}\n\n@if (!zSimple()) {\n <!-- Page Size Selector -->\n @if (zShowSizeChanger()) {\n <z-select\n class=\"w-fit\"\n zSize=\"sm\"\n [zOptions]=\"pageSizeOptions()\"\n [ngModel]=\"zPageSize()\"\n (ngModelChange)=\"onPageSizeChange($event)\"\n [zDisabled]=\"zDisabled()\"\n [zShowSearch]=\"false\" />\n }\n\n <z-button-group class=\"z-pagination-pages\">\n <!-- Prev Button -->\n <z-button zType=\"outline\" zSize=\"sm\" [zDisabled]=\"!canGoPrev() || zDisabled()\" (click)=\"goToPrev()\">\n <z-icon zType=\"lucideChevronLeft\" zSize=\"16\" />\n </z-button>\n\n <!-- Page Numbers -->\n @for (page of visiblePages(); track $index) {\n @if (page === 'ellipsis') {\n <span\n class=\"z-pagination-ellipsis text-muted-foreground border-input flex h-8 w-8 items-center justify-center border-y border-r bg-transparent text-sm\">\n ...\n </span>\n } @else {\n <z-button\n zType=\"outline\"\n [zWave]=\"false\"\n zSize=\"sm\"\n [class]=\"\n page === zPageIndex() ? 'relative min-w-8 overflow-hidden !bg-transparent hover:!bg-transparent' : 'min-w-8'\n \"\n [zDisabled]=\"zDisabled()\"\n (click)=\"goToPage(page)\">\n @if (page === zPageIndex()) {\n <span class=\"bg-primary pointer-events-none absolute inset-[1px] rounded-[1px]\"></span>\n }\n <span [class]=\"page === zPageIndex() ? 'text-primary-foreground relative z-[1]' : ''\">{{ page }}</span>\n </z-button>\n }\n }\n\n <!-- Next Button -->\n <z-button zType=\"outline\" zSize=\"sm\" [zDisabled]=\"!canGoNext() || zDisabled()\" (click)=\"goToNext()\">\n <z-icon zType=\"lucideChevronRight\" zSize=\"16\" />\n </z-button>\n </z-button-group>\n\n <!-- Quick Jumper -->\n @if (zShowQuickJumper()) {\n <div class=\"flex items-center gap-2 text-sm\">\n <span class=\"text-muted-foreground whitespace-nowrap\">{{ goToLabelText() }}</span>\n <z-input\n zType=\"number\"\n zSize=\"sm\"\n class=\"w-14\"\n [ngModel]=\"zPageIndex()\"\n [zMin]=\"1\"\n [zMax]=\"totalPages()\"\n [zDisabled]=\"zDisabled()\"\n (keydown.enter)=\"onQuickJump($event)\"\n (blur)=\"onQuickJump($event)\" />\n </div>\n }\n} @else {\n <!-- Simple Mode -->\n <z-button-group>\n <z-button zType=\"outline\" zSize=\"sm\" [zDisabled]=\"!canGoPrev() || zDisabled()\" (click)=\"goToPrev()\">\n <z-icon zType=\"lucideChevronLeft\" zSize=\"16\" />\n <span class=\"ml-1\">{{ 'i18n_z_ui_pagination_previous' | translate }}</span>\n </z-button>\n\n <span class=\"text-muted-foreground border-input flex h-8 items-center border-y bg-transparent px-3 text-sm\">\n {{ zPageIndex() }} / {{ totalPages() }}\n </span>\n\n <z-button zType=\"outline\" zSize=\"sm\" [zDisabled]=\"!canGoNext() || zDisabled()\" (click)=\"goToNext()\">\n <span class=\"mr-1\">{{ 'i18n_z_ui_pagination_next' | translate }}</span>\n <z-icon zType=\"lucideChevronRight\" zSize=\"16\" />\n </z-button>\n </z-button-group>\n}\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: ZButtonComponent, selector: "z-button, button[z-button], a[z-button]", inputs: ["class", "zType", "zSize", "zShape", "zLabel", "zLoading", "zDisabled", "zTypeIcon", "zAnimatedTypeIcon", "zAnimateIcon", "zAnimationTriggerIcon", "zSizeIcon", "zStrokeWidthIcon", "zWave"], exportAs: ["zButton"] }, { kind: "component", type: ZButtonGroupComponent, selector: "z-button-group", inputs: ["zClass", "zOrientation", "zActive"], outputs: ["zActiveChange", "zActiveIndexChange", "zActiveValueChange"], exportAs: ["zButtonGroup"] }, { kind: "component", type: ZIconComponent, selector: "z-icon, [z-icon]", inputs: ["class", "zType", "zAnimatedType", "zAnimate", "zAnimationTrigger", "zSize", "zStrokeWidth", "zSvg"] }, { kind: "component", type: ZInputComponent, selector: "z-input", inputs: ["class", "zType", "zSize", "zAlign", "zLabel", "zLabelClass", "zPlaceholder", "zRequired", "zDisabled", "zReadonly", "zLoading", "zLoadingOutline", "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", "zColorConfig"], outputs: ["zOnSearch", "zOnChange", "zOnBlur", "zOnFocus", "zOnKeydown", "zOnEnter", "zOnColorCollapse", "zControl", "zEvent"], exportAs: ["zInput"] }, { kind: "component", type: ZSelectComponent, selector: "z-select", inputs: ["class", "zClassSelect", "zMode", "zSize", "zLabel", "zLabelClass", "zPlaceholder", "zRequired", "zDisabled", "zReadonly", "zLoading", "zLoadingOutline", "zPrefix", "zAllowClear", "zShowCheck", "zWrap", "zShowSearch", "zPlaceholderSearch", "zDebounce", "zNotFoundText", "zEmptyText", "zEmptyIcon", "zMaxTagCount", "zDropdownMaxHeight", "zOptionHeight", "zVirtualScroll", "zDynamicSize", "zShowAction", "zOptions", "zConfig", "zTranslateLabels", "zKey", "zSearchServer", "zLoadingMore", "zEnableLoadMore", "zScrollDistance", "zMaxVisible", "zScrollClose", "zSticky", "zPosition", "zSelectedTemplate", "zOptionTemplate", "zActionTemplate", "zAsyncValidators", "zAsyncDebounce", "zAsyncValidateOn", "zValidators"], outputs: ["zOnSearch", "zOnLoadMore", "zOnBlur", "zOnFocus", "zControl", "zEvent"], exportAs: ["zSelect"] }, { kind: "pipe", type: TranslatePipe, name: "translate" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
137
- }
138
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.9", ngImport: i0, type: ZPaginationComponent, decorators: [{
139
- type: Component,
140
- args: [{ selector: 'z-pagination', imports: [
141
- FormsModule,
142
- ZButtonComponent,
143
- ZButtonGroupComponent,
144
- ZIconComponent,
145
- ZInputComponent,
146
- ZSelectComponent,
147
- TranslatePipe,
148
- ], standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, host: {
149
- class: 'z-pagination flex items-center gap-2',
150
- }, template: "@if (zShowTotal()) {\n <span class=\"text-muted-foreground text-sm whitespace-nowrap\">{{ totalLabelText() }}</span>\n}\n\n@if (!zSimple()) {\n <!-- Page Size Selector -->\n @if (zShowSizeChanger()) {\n <z-select\n class=\"w-fit\"\n zSize=\"sm\"\n [zOptions]=\"pageSizeOptions()\"\n [ngModel]=\"zPageSize()\"\n (ngModelChange)=\"onPageSizeChange($event)\"\n [zDisabled]=\"zDisabled()\"\n [zShowSearch]=\"false\" />\n }\n\n <z-button-group class=\"z-pagination-pages\">\n <!-- Prev Button -->\n <z-button zType=\"outline\" zSize=\"sm\" [zDisabled]=\"!canGoPrev() || zDisabled()\" (click)=\"goToPrev()\">\n <z-icon zType=\"lucideChevronLeft\" zSize=\"16\" />\n </z-button>\n\n <!-- Page Numbers -->\n @for (page of visiblePages(); track $index) {\n @if (page === 'ellipsis') {\n <span\n class=\"z-pagination-ellipsis text-muted-foreground border-input flex h-8 w-8 items-center justify-center border-y border-r bg-transparent text-sm\">\n ...\n </span>\n } @else {\n <z-button\n zType=\"outline\"\n [zWave]=\"false\"\n zSize=\"sm\"\n [class]=\"\n page === zPageIndex() ? 'relative min-w-8 overflow-hidden !bg-transparent hover:!bg-transparent' : 'min-w-8'\n \"\n [zDisabled]=\"zDisabled()\"\n (click)=\"goToPage(page)\">\n @if (page === zPageIndex()) {\n <span class=\"bg-primary pointer-events-none absolute inset-[1px] rounded-[1px]\"></span>\n }\n <span [class]=\"page === zPageIndex() ? 'text-primary-foreground relative z-[1]' : ''\">{{ page }}</span>\n </z-button>\n }\n }\n\n <!-- Next Button -->\n <z-button zType=\"outline\" zSize=\"sm\" [zDisabled]=\"!canGoNext() || zDisabled()\" (click)=\"goToNext()\">\n <z-icon zType=\"lucideChevronRight\" zSize=\"16\" />\n </z-button>\n </z-button-group>\n\n <!-- Quick Jumper -->\n @if (zShowQuickJumper()) {\n <div class=\"flex items-center gap-2 text-sm\">\n <span class=\"text-muted-foreground whitespace-nowrap\">{{ goToLabelText() }}</span>\n <z-input\n zType=\"number\"\n zSize=\"sm\"\n class=\"w-14\"\n [ngModel]=\"zPageIndex()\"\n [zMin]=\"1\"\n [zMax]=\"totalPages()\"\n [zDisabled]=\"zDisabled()\"\n (keydown.enter)=\"onQuickJump($event)\"\n (blur)=\"onQuickJump($event)\" />\n </div>\n }\n} @else {\n <!-- Simple Mode -->\n <z-button-group>\n <z-button zType=\"outline\" zSize=\"sm\" [zDisabled]=\"!canGoPrev() || zDisabled()\" (click)=\"goToPrev()\">\n <z-icon zType=\"lucideChevronLeft\" zSize=\"16\" />\n <span class=\"ml-1\">{{ 'i18n_z_ui_pagination_previous' | translate }}</span>\n </z-button>\n\n <span class=\"text-muted-foreground border-input flex h-8 items-center border-y bg-transparent px-3 text-sm\">\n {{ zPageIndex() }} / {{ totalPages() }}\n </span>\n\n <z-button zType=\"outline\" zSize=\"sm\" [zDisabled]=\"!canGoNext() || zDisabled()\" (click)=\"goToNext()\">\n <span class=\"mr-1\">{{ 'i18n_z_ui_pagination_next' | translate }}</span>\n <z-icon zType=\"lucideChevronRight\" zSize=\"16\" />\n </z-button>\n </z-button-group>\n}\n" }]
151
- }], propDecorators: { zOnPageChange: [{ type: i0.Output, args: ["zOnPageChange"] }], zPageIndex: [{ type: i0.Input, args: [{ isSignal: true, alias: "zPageIndex", required: false }] }, { type: i0.Output, args: ["zPageIndexChange"] }], zPageSize: [{ type: i0.Input, args: [{ isSignal: true, alias: "zPageSize", required: false }] }, { type: i0.Output, args: ["zPageSizeChange"] }], zTotal: [{ type: i0.Input, args: [{ isSignal: true, alias: "zTotal", required: true }] }], zPageSizeOptions: [{ type: i0.Input, args: [{ isSignal: true, alias: "zPageSizeOptions", required: false }] }], zShowSizeChanger: [{ type: i0.Input, args: [{ isSignal: true, alias: "zShowSizeChanger", required: false }] }], zShowQuickJumper: [{ type: i0.Input, args: [{ isSignal: true, alias: "zShowQuickJumper", required: false }] }], zShowTotal: [{ type: i0.Input, args: [{ isSignal: true, alias: "zShowTotal", required: false }] }], zSimple: [{ type: i0.Input, args: [{ isSignal: true, alias: "zSimple", required: false }] }], zSize: [{ type: i0.Input, args: [{ isSignal: true, alias: "zSize", required: false }] }], zDisabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "zDisabled", required: false }] }], zTotalLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "zTotalLabel", required: false }] }], zPerPageLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "zPerPageLabel", required: false }] }], zGoToLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "zGoToLabel", required: false }] }] } });
152
-
153
- /**
154
- * Generated bundle index. Do not edit.
155
- */
156
-
157
- export { ZPaginationComponent };
158
- //# sourceMappingURL=shival99-z-ui-components-z-pagination.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"shival99-z-ui-components-z-pagination.mjs","sources":["../../../../libs/core-ui/components/z-pagination/z-pagination.component.ts","../../../../libs/core-ui/components/z-pagination/z-pagination.component.html","../../../../libs/core-ui/components/z-pagination/shival99-z-ui-components-z-pagination.ts"],"sourcesContent":["import { ChangeDetectionStrategy, Component, computed, inject, input, model, output } from '@angular/core';\nimport { FormsModule } from '@angular/forms';\nimport { TranslatePipe } from '@ngx-translate/core';\nimport { ZButtonComponent } from '@shival99/z-ui/components/z-button';\nimport { ZButtonGroupComponent } from '@shival99/z-ui/components/z-button-group';\nimport { ZIconComponent } from '@shival99/z-ui/components/z-icon';\nimport { ZInputComponent } from '@shival99/z-ui/components/z-input';\nimport { ZSelectComponent } from '@shival99/z-ui/components/z-select';\nimport { ZTranslateService } from '@shival99/z-ui/services';\nimport type { ZPageChangeEvent, ZPaginationSize } from './z-pagination.types';\n\n@Component({\n selector: 'z-pagination',\n imports: [\n FormsModule,\n ZButtonComponent,\n ZButtonGroupComponent,\n ZIconComponent,\n ZInputComponent,\n ZSelectComponent,\n TranslatePipe,\n ],\n standalone: true,\n templateUrl: './z-pagination.component.html',\n changeDetection: ChangeDetectionStrategy.OnPush,\n host: {\n class: 'z-pagination flex items-center gap-2',\n },\n})\nexport class ZPaginationComponent {\n private readonly _zTranslate = inject(ZTranslateService);\n\n public readonly zOnPageChange = output<ZPageChangeEvent>();\n\n public readonly zPageIndex = model<number>(1);\n public readonly zPageSize = model<number>(10);\n public readonly zTotal = input.required<number>();\n public readonly zPageSizeOptions = input<number[]>([10, 20, 50, 100]);\n public readonly zShowSizeChanger = input<boolean>(true);\n public readonly zShowQuickJumper = input<boolean>(false);\n public readonly zShowTotal = input<boolean>(true);\n public readonly zSimple = input<boolean>(false);\n public readonly zSize = input<ZPaginationSize>('default');\n public readonly zDisabled = input<boolean>(false);\n\n public readonly zTotalLabel = input<string | null>(null);\n public readonly zPerPageLabel = input<string | null>(null);\n public readonly zGoToLabel = input<string | null>(null);\n\n protected readonly totalLabelText = computed(() => {\n this._zTranslate.currentLang();\n if (this.zTotalLabel()) {\n return this.zTotalLabel()!.replace('{{total}}', String(this.zTotal()));\n }\n return this._zTranslate.instant('i18n_z_ui_pagination_total_label', { total: this.zTotal() });\n });\n\n protected readonly perPageLabelText = computed(() => {\n this._zTranslate.currentLang();\n return this.zPerPageLabel() ?? this._zTranslate.instant('i18n_z_ui_pagination_per_page');\n });\n\n protected readonly goToLabelText = computed(() => {\n this._zTranslate.currentLang();\n return this.zGoToLabel() ?? this._zTranslate.instant('i18n_z_ui_pagination_go_to');\n });\n\n protected readonly totalPages = computed(() => {\n const total = this.zTotal();\n const pageSize = this.zPageSize();\n return Math.max(1, Math.ceil(total / pageSize));\n });\n\n protected readonly pageSizeOptions = computed(() =>\n this.zPageSizeOptions().map(size => ({\n label: `${size} ${this.perPageLabelText()}`,\n value: size,\n }))\n );\n\n protected readonly visiblePages = computed(() => {\n const current = this.zPageIndex();\n const total = this.totalPages();\n const pages: (number | 'ellipsis')[] = [];\n const maxVisible = 5;\n\n if (total <= maxVisible) {\n for (let i = 1; i <= total; i++) {\n pages.push(i);\n }\n return pages;\n }\n\n pages.push(1);\n\n let startPage = Math.max(2, current - 1);\n let endPage = Math.min(total - 1, current + 1);\n\n if (current <= 3) {\n endPage = Math.min(total - 1, 3);\n } else if (current >= total - 2) {\n startPage = Math.max(2, total - 2);\n }\n\n if (startPage > 2) {\n pages.push('ellipsis');\n }\n\n for (let i = startPage; i <= endPage; i++) {\n pages.push(i);\n }\n\n if (endPage < total - 1) {\n pages.push('ellipsis');\n }\n\n pages.push(total);\n\n return pages;\n });\n\n protected readonly canGoPrev = computed(() => this.zPageIndex() > 1);\n protected readonly canGoNext = computed(() => this.zPageIndex() < this.totalPages());\n\n protected goToPage(page: number): void {\n if (page < 1 || page > this.totalPages()) {\n return;\n }\n if (page === this.zPageIndex()) {\n return;\n }\n\n this.zPageIndex.set(page);\n this._emitChange();\n }\n\n protected goToPrev(): void {\n if (!this.canGoPrev()) {\n return;\n }\n this.goToPage(this.zPageIndex() - 1);\n }\n\n protected goToNext(): void {\n if (!this.canGoNext()) {\n return;\n }\n this.goToPage(this.zPageIndex() + 1);\n }\n\n protected onPageSizeChange(size: unknown): void {\n const sizeValue =\n typeof size === 'object' && size !== null && 'value' in size\n ? (size as { value: number }).value\n : (size as number);\n if (!Number.isFinite(sizeValue) || sizeValue <= 0) {\n return;\n }\n\n this.zPageSize.set(sizeValue);\n this.zPageIndex.set(1);\n this._emitChange();\n }\n\n protected onQuickJump(event: Event): void {\n const input = event.target as HTMLInputElement;\n const page = parseInt(input.value, 10);\n\n if (isNaN(page) || page < 1 || page > this.totalPages()) {\n input.value = String(this.zPageIndex());\n return;\n }\n\n this.goToPage(page);\n }\n\n private _emitChange(): void {\n this.zOnPageChange.emit({\n pageIndex: this.zPageIndex(),\n pageSize: this.zPageSize(),\n });\n }\n}\n","@if (zShowTotal()) {\n <span class=\"text-muted-foreground text-sm whitespace-nowrap\">{{ totalLabelText() }}</span>\n}\n\n@if (!zSimple()) {\n <!-- Page Size Selector -->\n @if (zShowSizeChanger()) {\n <z-select\n class=\"w-fit\"\n zSize=\"sm\"\n [zOptions]=\"pageSizeOptions()\"\n [ngModel]=\"zPageSize()\"\n (ngModelChange)=\"onPageSizeChange($event)\"\n [zDisabled]=\"zDisabled()\"\n [zShowSearch]=\"false\" />\n }\n\n <z-button-group class=\"z-pagination-pages\">\n <!-- Prev Button -->\n <z-button zType=\"outline\" zSize=\"sm\" [zDisabled]=\"!canGoPrev() || zDisabled()\" (click)=\"goToPrev()\">\n <z-icon zType=\"lucideChevronLeft\" zSize=\"16\" />\n </z-button>\n\n <!-- Page Numbers -->\n @for (page of visiblePages(); track $index) {\n @if (page === 'ellipsis') {\n <span\n class=\"z-pagination-ellipsis text-muted-foreground border-input flex h-8 w-8 items-center justify-center border-y border-r bg-transparent text-sm\">\n ...\n </span>\n } @else {\n <z-button\n zType=\"outline\"\n [zWave]=\"false\"\n zSize=\"sm\"\n [class]=\"\n page === zPageIndex() ? 'relative min-w-8 overflow-hidden !bg-transparent hover:!bg-transparent' : 'min-w-8'\n \"\n [zDisabled]=\"zDisabled()\"\n (click)=\"goToPage(page)\">\n @if (page === zPageIndex()) {\n <span class=\"bg-primary pointer-events-none absolute inset-[1px] rounded-[1px]\"></span>\n }\n <span [class]=\"page === zPageIndex() ? 'text-primary-foreground relative z-[1]' : ''\">{{ page }}</span>\n </z-button>\n }\n }\n\n <!-- Next Button -->\n <z-button zType=\"outline\" zSize=\"sm\" [zDisabled]=\"!canGoNext() || zDisabled()\" (click)=\"goToNext()\">\n <z-icon zType=\"lucideChevronRight\" zSize=\"16\" />\n </z-button>\n </z-button-group>\n\n <!-- Quick Jumper -->\n @if (zShowQuickJumper()) {\n <div class=\"flex items-center gap-2 text-sm\">\n <span class=\"text-muted-foreground whitespace-nowrap\">{{ goToLabelText() }}</span>\n <z-input\n zType=\"number\"\n zSize=\"sm\"\n class=\"w-14\"\n [ngModel]=\"zPageIndex()\"\n [zMin]=\"1\"\n [zMax]=\"totalPages()\"\n [zDisabled]=\"zDisabled()\"\n (keydown.enter)=\"onQuickJump($event)\"\n (blur)=\"onQuickJump($event)\" />\n </div>\n }\n} @else {\n <!-- Simple Mode -->\n <z-button-group>\n <z-button zType=\"outline\" zSize=\"sm\" [zDisabled]=\"!canGoPrev() || zDisabled()\" (click)=\"goToPrev()\">\n <z-icon zType=\"lucideChevronLeft\" zSize=\"16\" />\n <span class=\"ml-1\">{{ 'i18n_z_ui_pagination_previous' | translate }}</span>\n </z-button>\n\n <span class=\"text-muted-foreground border-input flex h-8 items-center border-y bg-transparent px-3 text-sm\">\n {{ zPageIndex() }} / {{ totalPages() }}\n </span>\n\n <z-button zType=\"outline\" zSize=\"sm\" [zDisabled]=\"!canGoNext() || zDisabled()\" (click)=\"goToNext()\">\n <span class=\"mr-1\">{{ 'i18n_z_ui_pagination_next' | translate }}</span>\n <z-icon zType=\"lucideChevronRight\" zSize=\"16\" />\n </z-button>\n </z-button-group>\n}\n","/**\n * Generated bundle index. Do not edit.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AAa;AACd,qBAAA,EAAA,UAAA,EACW,IAAI,EAAA,eAAA,EAEC,uBAAuB,CAAC,MAAM,EAAA,IAAA,EACzC;AACJ,wBAAA,KAAK,EAAE,sCAAsC;AAC9C,qBAAA,EAAA,QAAA,EAAA,4tGAAA,EAAA;;;AE3BH;;AAEG;;;;"}
@@ -1,383 +0,0 @@
1
- import { isPlatformBrowser } from '@angular/common';
2
- import * as i0 from '@angular/core';
3
- import { input, viewChild, inject, PLATFORM_ID, signal, effect, ViewEncapsulation, ChangeDetectionStrategy, Component } from '@angular/core';
4
- import { TranslatePipe } from '@ngx-translate/core';
5
- import { ZButtonComponent } from '@shival99/z-ui/components/z-button';
6
- import { zTransform } from '@shival99/z-ui/utils';
7
- import * as QRCode from 'qrcode';
8
-
9
- class ZQrCodeComponent {
10
- // Inputs
11
- zValue = input.required(...(ngDevMode ? [{ debugName: "zValue" }] : []));
12
- zSize = input(256, ...(ngDevMode ? [{ debugName: "zSize" }] : []));
13
- zLevel = input('H', ...(ngDevMode ? [{ debugName: "zLevel" }] : []));
14
- zLogo = input('', ...(ngDevMode ? [{ debugName: "zLogo" }] : []));
15
- zLogoSize = input(0.2, ...(ngDevMode ? [{ debugName: "zLogoSize" }] : [])); // 20% of QR size
16
- zLogoBgColor = input('#ffffff', ...(ngDevMode ? [{ debugName: "zLogoBgColor" }] : []));
17
- zLogoBgShape = input('circle', ...(ngDevMode ? [{ debugName: "zLogoBgShape" }] : []));
18
- zLogoPadding = input(4, ...(ngDevMode ? [{ debugName: "zLogoPadding" }] : []));
19
- zFgColor = input('#000000', ...(ngDevMode ? [{ debugName: "zFgColor" }] : []));
20
- zBgColor = input('#ffffff', ...(ngDevMode ? [{ debugName: "zBgColor" }] : []));
21
- zDotStyle = input('square', ...(ngDevMode ? [{ debugName: "zDotStyle" }] : []));
22
- zEyeStyle = input('square', ...(ngDevMode ? [{ debugName: "zEyeStyle" }] : []));
23
- zEyeColor = input('', ...(ngDevMode ? [{ debugName: "zEyeColor" }] : [])); // if empty, falls back to zFgColor
24
- zMargin = input(4, ...(ngDevMode ? [{ debugName: "zMargin" }] : [])); // margin in modules
25
- zFgGradient = input(...(ngDevMode ? [undefined, { debugName: "zFgGradient" }] : []));
26
- zFrame = input('none', ...(ngDevMode ? [{ debugName: "zFrame" }] : []));
27
- zFrameText = input('SCAN ME', ...(ngDevMode ? [{ debugName: "zFrameText" }] : []));
28
- zFrameColor = input('#0f172a', ...(ngDevMode ? [{ debugName: "zFrameColor" }] : []));
29
- zFramePadding = input(12, ...(ngDevMode ? [{ debugName: "zFramePadding" }] : [])); // padding around QR inside frame
30
- zFrameBorderRadius = input(12, ...(ngDevMode ? [{ debugName: "zFrameBorderRadius" }] : [])); // border radius of the frame
31
- zDownloadable = input(false, { ...(ngDevMode ? { debugName: "zDownloadable" } : {}), transform: zTransform }); // toggles hover overlay button
32
- zDownloadButton = input(false, { ...(ngDevMode ? { debugName: "zDownloadButton" } : {}), transform: zTransform }); // toggles standalone button below
33
- zShadow = input(true, { ...(ngDevMode ? { debugName: "zShadow" } : {}), transform: zTransform }); // Bật/tắt đổ bóng khung ngoài
34
- zLoading = input(false, { ...(ngDevMode ? { debugName: "zLoading" } : {}), transform: zTransform });
35
- // DOM references
36
- _canvasRef = viewChild('qrCanvas', ...(ngDevMode ? [{ debugName: "_canvasRef" }] : []));
37
- _platformId = inject(PLATFORM_ID);
38
- // States
39
- downloadText = signal('i18n_z_ui_qrcode_download', ...(ngDevMode ? [{ debugName: "downloadText" }] : []));
40
- constructor() {
41
- // Re-render when any signal inputs change
42
- effect(() => {
43
- if (isPlatformBrowser(this._platformId)) {
44
- void this.renderQrCode();
45
- }
46
- });
47
- }
48
- /**
49
- * Renders the stylized QR code onto the canvas element
50
- */
51
- async renderQrCode() {
52
- const canvas = this._canvasRef()?.nativeElement;
53
- if (!canvas) {
54
- return;
55
- }
56
- const value = this.zValue();
57
- const size = this.zSize();
58
- const level = this.zLevel();
59
- const fgColor = this.zFgColor();
60
- const bgColor = this.zBgColor();
61
- const dotStyle = this.zDotStyle();
62
- const eyeStyle = this.zEyeStyle();
63
- const eyeColorInput = this.zEyeColor();
64
- const logoUrl = this.zLogo();
65
- const frame = this.zFrame();
66
- const dpr = isPlatformBrowser(this._platformId) ? window.devicePixelRatio || 1 : 1;
67
- const framePadding = frame !== 'none' ? this.zFramePadding() : 0;
68
- const frameBorderRadius = this.zFrameBorderRadius();
69
- const bannerHeight = frame === 'text-bottom' || frame === 'text-top' ? 50 : 0;
70
- const cssWidth = size + framePadding * 2;
71
- const cssHeight = size + framePadding * 2 + bannerHeight;
72
- canvas.width = cssWidth * dpr;
73
- canvas.height = cssHeight * dpr;
74
- const ctx = canvas.getContext('2d');
75
- if (!ctx) {
76
- return;
77
- }
78
- ctx.scale(dpr, dpr);
79
- // Clear background
80
- ctx.fillStyle = bgColor;
81
- ctx.fillRect(0, 0, cssWidth, cssHeight);
82
- if (frame !== 'none') {
83
- // Draw rounded frame container
84
- ctx.fillStyle = bgColor;
85
- ctx.beginPath();
86
- this._drawRoundedRectPath(ctx, 0, 0, cssWidth, cssHeight, frameBorderRadius);
87
- ctx.fill();
88
- // Draw border outline
89
- ctx.strokeStyle = this.zFrameColor();
90
- ctx.lineWidth = 1.5;
91
- ctx.beginPath();
92
- this._drawRoundedRectPath(ctx, 0.75, 0.75, cssWidth - 1.5, cssHeight - 1.5, frameBorderRadius);
93
- ctx.stroke();
94
- }
95
- try {
96
- // Create raw QR code matrix
97
- const qr = QRCode.create(value, { errorCorrectionLevel: level });
98
- const moduleCount = qr.modules.size;
99
- const marginModules = this.zMargin();
100
- const drawSize = size;
101
- // Calculate module size
102
- const moduleSize = drawSize / (moduleCount + 2 * marginModules);
103
- const marginOffset = marginModules * moduleSize;
104
- // Draw offsets
105
- let xOffset = 0;
106
- let yOffset = 0;
107
- if (frame !== 'none') {
108
- xOffset = framePadding;
109
- yOffset = frame === 'text-top' ? framePadding + bannerHeight : framePadding;
110
- }
111
- // 1. Prepare foreground style (solid or gradient)
112
- let fillStyle = fgColor;
113
- const gradientOpt = this.zFgGradient();
114
- if (gradientOpt && gradientOpt.colors && gradientOpt.colors.length > 0) {
115
- fillStyle = this._getGradientStyle(ctx, gradientOpt, drawSize, xOffset, yOffset, marginOffset);
116
- }
117
- const eyeColor = eyeColorInput || fillStyle;
118
- // 2. Draw normal modules (skip eyes and central logo)
119
- ctx.fillStyle = fillStyle;
120
- // Calculate logo skip boundary
121
- const hasLogo = !!logoUrl;
122
- const logoModules = Math.ceil(moduleCount * this.zLogoSize());
123
- const logoStart = Math.floor((moduleCount - logoModules) / 2);
124
- const logoEnd = logoStart + logoModules;
125
- for (let r = 0; r < moduleCount; r++) {
126
- for (let c = 0; c < moduleCount; c++) {
127
- // Check if it's top-left, top-right, or bottom-left eye
128
- const isTopLeftEye = r < 7 && c < 7;
129
- const isTopRightEye = r < 7 && c >= moduleCount - 7;
130
- const isBottomLeftEye = r >= moduleCount - 7 && c < 7;
131
- if (isTopLeftEye || isTopRightEye || isBottomLeftEye) {
132
- continue;
133
- }
134
- // Check if overlapping logo area
135
- if (hasLogo && r >= logoStart && r < logoEnd && c >= logoStart && c < logoEnd) {
136
- continue;
137
- }
138
- const isDark = qr.modules.get(r, c) === 1; // standard raw check
139
- if (!isDark) {
140
- continue;
141
- }
142
- const x = xOffset + marginOffset + c * moduleSize;
143
- const y = yOffset + marginOffset + r * moduleSize;
144
- this._drawDot(ctx, x, y, moduleSize, dotStyle);
145
- }
146
- }
147
- // 3. Draw Eyes
148
- const eyeCoords = [
149
- { x: xOffset + marginOffset, y: yOffset + marginOffset }, // Top Left
150
- { x: xOffset + marginOffset + (moduleCount - 7) * moduleSize, y: yOffset + marginOffset }, // Top Right
151
- { x: xOffset + marginOffset, y: yOffset + marginOffset + (moduleCount - 7) * moduleSize }, // Bottom Left
152
- ];
153
- eyeCoords.forEach(coord => {
154
- this._drawEye(ctx, coord.x, coord.y, moduleSize, eyeStyle, eyeColor);
155
- });
156
- // 4. Draw central logo if specified
157
- if (hasLogo) {
158
- await this._drawLogo(ctx, xOffset + marginOffset, yOffset, drawSize, logoUrl);
159
- }
160
- // 5. Draw Frame details
161
- if (frame === 'text-bottom' || frame === 'text-top') {
162
- const bannerY = frame === 'text-bottom' ? framePadding + size : framePadding;
163
- this._drawFrame(ctx, cssWidth, bannerY, bannerHeight, this.zFrameText(), this.zFrameColor());
164
- }
165
- }
166
- catch (err) {
167
- console.error('Error generating QR code:', err);
168
- }
169
- }
170
- /**
171
- * Helper function to get gradient style fill (no else branches)
172
- */
173
- _getGradientStyle(ctx, gradientOpt, drawSize, xOffset, yOffset, marginOffset) {
174
- if (gradientOpt.type === 'radial') {
175
- const cx = drawSize / 2 + xOffset;
176
- const cy = drawSize / 2 + yOffset;
177
- const r = (drawSize / 2) * 1.2;
178
- const grad = ctx.createRadialGradient(cx, cy, 0, cx, cy, r);
179
- gradientOpt.colors.forEach((c, idx) => {
180
- grad.addColorStop(idx / (gradientOpt.colors.length - 1), c);
181
- });
182
- return grad;
183
- }
184
- // Default to linear
185
- const angle = gradientOpt.angle ?? 45;
186
- const rad = (angle * Math.PI) / 180;
187
- const x1 = Math.cos(rad) * 0;
188
- const y1 = Math.sin(rad) * 0;
189
- const x2 = Math.cos(rad) * drawSize + x1;
190
- const y2 = Math.sin(rad) * drawSize + y1;
191
- const grad = ctx.createLinearGradient(x1 + xOffset + marginOffset, y1 + yOffset + marginOffset, x2 + xOffset + marginOffset, y2 + yOffset + marginOffset);
192
- gradientOpt.colors.forEach((c, idx) => {
193
- grad.addColorStop(idx / (gradientOpt.colors.length - 1), c);
194
- });
195
- return grad;
196
- }
197
- /**
198
- * Helper function to draw dynamic dot module style (no else branches)
199
- */
200
- _drawDot(ctx, x, y, moduleSize, dotStyle) {
201
- ctx.beginPath();
202
- if (dotStyle === 'dots') {
203
- ctx.arc(x + moduleSize / 2, y + moduleSize / 2, (moduleSize / 2) * 0.95, 0, Math.PI * 2);
204
- ctx.fill();
205
- return;
206
- }
207
- if (dotStyle === 'rounded') {
208
- this._drawRoundedRectPath(ctx, x + moduleSize * 0.05, y + moduleSize * 0.05, moduleSize * 0.9, moduleSize * 0.9, moduleSize * 0.3);
209
- ctx.fill();
210
- return;
211
- }
212
- // Default to square
213
- ctx.fillRect(x, y, moduleSize, moduleSize);
214
- }
215
- /**
216
- * Helper path function for rounded corners (no else branches)
217
- */
218
- _drawRoundedRectPath(ctx, x, y, w, h, r, counterClockwise = false) {
219
- if (r > w / 2) {
220
- r = w / 2;
221
- }
222
- if (r > h / 2) {
223
- r = h / 2;
224
- }
225
- ctx.moveTo(x + r, y);
226
- if (counterClockwise) {
227
- ctx.lineTo(x + r, y);
228
- ctx.arcTo(x, y, x, y + r, r);
229
- ctx.lineTo(x, y + h - r);
230
- ctx.arcTo(x, x + h, x + r, y + h, r);
231
- ctx.lineTo(x + w - r, y + h);
232
- ctx.arcTo(x + w, y + h, x + w, y + h - r, r);
233
- ctx.lineTo(x + w, y + r);
234
- ctx.arcTo(x + w, y, x + w - r, y, r);
235
- ctx.closePath();
236
- return;
237
- }
238
- ctx.lineTo(x + w - r, y);
239
- ctx.arcTo(x + w, y, x + w, y + r, r);
240
- ctx.lineTo(x + w, y + h - r);
241
- ctx.arcTo(x + w, y + h, x + w - r, y + h, r);
242
- ctx.lineTo(x + r, y + h);
243
- ctx.arcTo(x, y + h, x, y + h - r, r);
244
- ctx.lineTo(x, y + r);
245
- ctx.arcTo(x, y, x + r, y, r);
246
- ctx.closePath();
247
- }
248
- /**
249
- * Draw eye pattern (no else branches)
250
- */
251
- _drawEye(ctx, x, y, moduleSize, style, color) {
252
- ctx.save();
253
- ctx.fillStyle = color;
254
- const outerSize = 7 * moduleSize;
255
- const innerSize = 3 * moduleSize;
256
- const innerOffset = 2 * moduleSize;
257
- if (style === 'circle') {
258
- ctx.beginPath();
259
- ctx.arc(x + outerSize / 2, y + outerSize / 2, outerSize / 2, 0, Math.PI * 2);
260
- ctx.arc(x + outerSize / 2, y + outerSize / 2, outerSize / 2 - moduleSize, 0, Math.PI * 2, true);
261
- ctx.fill();
262
- ctx.beginPath();
263
- ctx.arc(x + outerSize / 2, y + outerSize / 2, innerSize / 2, 0, Math.PI * 2);
264
- ctx.fill();
265
- ctx.restore();
266
- return;
267
- }
268
- if (style === 'rounded') {
269
- const outerRadius = 2 * moduleSize;
270
- const innerRadius = moduleSize;
271
- ctx.beginPath();
272
- this._drawRoundedRectPath(ctx, x, y, outerSize, outerSize, outerRadius);
273
- this._drawRoundedRectPath(ctx, x + moduleSize, y + moduleSize, outerSize - 2 * moduleSize, outerSize - 2 * moduleSize, outerRadius - moduleSize, true);
274
- ctx.fill();
275
- ctx.beginPath();
276
- this._drawRoundedRectPath(ctx, x + innerOffset, y + innerOffset, innerSize, innerSize, innerRadius);
277
- ctx.fill();
278
- ctx.restore();
279
- return;
280
- }
281
- // Default to square
282
- ctx.fillRect(x, y, outerSize, outerSize);
283
- ctx.clearRect(x + moduleSize, y + moduleSize, outerSize - 2 * moduleSize, outerSize - 2 * moduleSize);
284
- ctx.fillRect(x + innerOffset, y + innerOffset, innerSize, innerSize);
285
- ctx.restore();
286
- }
287
- /**
288
- * Load and render the central logo on canvas (no else branches)
289
- */
290
- _drawLogo(ctx, marginOffset, yOffset, drawSize, logoUrl) {
291
- return new Promise(resolve => {
292
- const img = new Image();
293
- img.crossOrigin = 'anonymous'; // prevent tainted canvas
294
- img.src = logoUrl;
295
- img.onload = () => {
296
- const logoBoxSize = drawSize * this.zLogoSize();
297
- const logoBoxX = marginOffset + (drawSize - 2 * marginOffset - logoBoxSize) / 2;
298
- const logoBoxY = marginOffset + (drawSize - 2 * marginOffset - logoBoxSize) / 2 + yOffset;
299
- ctx.save();
300
- // 1. Draw logo mask background (circle or square)
301
- const bgShape = this.zLogoBgShape();
302
- if (bgShape === 'circle') {
303
- ctx.fillStyle = this.zLogoBgColor();
304
- ctx.beginPath();
305
- ctx.arc(logoBoxX + logoBoxSize / 2, logoBoxY + logoBoxSize / 2, logoBoxSize / 2, 0, Math.PI * 2);
306
- ctx.fill();
307
- }
308
- if (bgShape === 'square') {
309
- ctx.fillStyle = this.zLogoBgColor();
310
- ctx.beginPath();
311
- this._drawRoundedRectPath(ctx, logoBoxX, logoBoxY, logoBoxSize, logoBoxSize, logoBoxSize * 0.2);
312
- ctx.fill();
313
- }
314
- // 2. Draw logo image centered
315
- const padding = this.zLogoPadding();
316
- const logoImgSize = logoBoxSize - padding * 2;
317
- const logoImgX = logoBoxX + padding;
318
- const logoImgY = logoBoxY + padding;
319
- if (bgShape === 'circle') {
320
- // Clip to circle so non-circle logos look neat
321
- ctx.beginPath();
322
- ctx.arc(logoBoxX + logoBoxSize / 2, logoBoxY + logoBoxSize / 2, logoImgSize / 2, 0, Math.PI * 2);
323
- ctx.clip();
324
- }
325
- ctx.drawImage(img, logoImgX, logoImgY, logoImgSize, logoImgSize);
326
- ctx.restore();
327
- resolve();
328
- };
329
- img.onerror = () => {
330
- console.warn('Failed to load QR code logo from URL:', logoUrl);
331
- resolve(); // resolve anyway to avoid blocking execution
332
- };
333
- });
334
- }
335
- _drawFrame(ctx, width, bannerY, bannerHeight, text, frameColor) {
336
- ctx.save();
337
- // Draw pill badge for standard frame aesthetic
338
- ctx.fillStyle = frameColor;
339
- const pillWidth = width * 0.75;
340
- const pillHeight = 28;
341
- const pillX = (width - pillWidth) / 2;
342
- const pillY = bannerY + (bannerHeight - pillHeight) / 2;
343
- ctx.beginPath();
344
- this._drawRoundedRectPath(ctx, pillX, pillY, pillWidth, pillHeight, pillHeight / 2);
345
- ctx.fill();
346
- // Render banner text
347
- ctx.fillStyle = '#ffffff';
348
- ctx.font = 'bold 12px var(--font-sans, system-ui, sans-serif)';
349
- ctx.textAlign = 'center';
350
- ctx.textBaseline = 'middle';
351
- ctx.fillText(text, width / 2, pillY + pillHeight / 2);
352
- ctx.restore();
353
- }
354
- /**
355
- * Download the generated canvas QR Code as a PNG image file
356
- */
357
- downloadQr() {
358
- const canvas = this._canvasRef()?.nativeElement;
359
- if (!canvas) {
360
- return;
361
- }
362
- const dataUrl = canvas.toDataURL('image/png');
363
- const link = document.createElement('a');
364
- link.href = dataUrl;
365
- link.download = `qrcode_${Date.now()}.png`;
366
- document.body.appendChild(link);
367
- link.click();
368
- document.body.removeChild(link);
369
- }
370
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.9", ngImport: i0, type: ZQrCodeComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
371
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.0.9", type: ZQrCodeComponent, isStandalone: true, selector: "z-qrcode", inputs: { zValue: { classPropertyName: "zValue", publicName: "zValue", isSignal: true, isRequired: true, transformFunction: null }, zSize: { classPropertyName: "zSize", publicName: "zSize", isSignal: true, isRequired: false, transformFunction: null }, zLevel: { classPropertyName: "zLevel", publicName: "zLevel", isSignal: true, isRequired: false, transformFunction: null }, zLogo: { classPropertyName: "zLogo", publicName: "zLogo", isSignal: true, isRequired: false, transformFunction: null }, zLogoSize: { classPropertyName: "zLogoSize", publicName: "zLogoSize", isSignal: true, isRequired: false, transformFunction: null }, zLogoBgColor: { classPropertyName: "zLogoBgColor", publicName: "zLogoBgColor", isSignal: true, isRequired: false, transformFunction: null }, zLogoBgShape: { classPropertyName: "zLogoBgShape", publicName: "zLogoBgShape", isSignal: true, isRequired: false, transformFunction: null }, zLogoPadding: { classPropertyName: "zLogoPadding", publicName: "zLogoPadding", isSignal: true, isRequired: false, transformFunction: null }, zFgColor: { classPropertyName: "zFgColor", publicName: "zFgColor", isSignal: true, isRequired: false, transformFunction: null }, zBgColor: { classPropertyName: "zBgColor", publicName: "zBgColor", isSignal: true, isRequired: false, transformFunction: null }, zDotStyle: { classPropertyName: "zDotStyle", publicName: "zDotStyle", isSignal: true, isRequired: false, transformFunction: null }, zEyeStyle: { classPropertyName: "zEyeStyle", publicName: "zEyeStyle", isSignal: true, isRequired: false, transformFunction: null }, zEyeColor: { classPropertyName: "zEyeColor", publicName: "zEyeColor", isSignal: true, isRequired: false, transformFunction: null }, zMargin: { classPropertyName: "zMargin", publicName: "zMargin", isSignal: true, isRequired: false, transformFunction: null }, zFgGradient: { classPropertyName: "zFgGradient", publicName: "zFgGradient", isSignal: true, isRequired: false, transformFunction: null }, zFrame: { classPropertyName: "zFrame", publicName: "zFrame", isSignal: true, isRequired: false, transformFunction: null }, zFrameText: { classPropertyName: "zFrameText", publicName: "zFrameText", isSignal: true, isRequired: false, transformFunction: null }, zFrameColor: { classPropertyName: "zFrameColor", publicName: "zFrameColor", isSignal: true, isRequired: false, transformFunction: null }, zFramePadding: { classPropertyName: "zFramePadding", publicName: "zFramePadding", isSignal: true, isRequired: false, transformFunction: null }, zFrameBorderRadius: { classPropertyName: "zFrameBorderRadius", publicName: "zFrameBorderRadius", isSignal: true, isRequired: false, transformFunction: null }, zDownloadable: { classPropertyName: "zDownloadable", publicName: "zDownloadable", isSignal: true, isRequired: false, transformFunction: null }, zDownloadButton: { classPropertyName: "zDownloadButton", publicName: "zDownloadButton", isSignal: true, isRequired: false, transformFunction: null }, zShadow: { classPropertyName: "zShadow", publicName: "zShadow", isSignal: true, isRequired: false, transformFunction: null }, zLoading: { classPropertyName: "zLoading", publicName: "zLoading", isSignal: true, isRequired: false, transformFunction: null } }, viewQueries: [{ propertyName: "_canvasRef", first: true, predicate: ["qrCanvas"], descendants: true, isSignal: true }], ngImport: i0, template: "<div class=\"z-qrcode-container relative flex flex-col items-center\">\n <div\n class=\"z-qrcode-canvas-wrapper relative transition-all duration-200\"\n [class.shadow-md]=\"zShadow()\"\n [style.border-radius.px]=\"zFrame() !== 'none' || zShadow() ? zFrameBorderRadius() : 0\"\n [style.overflow]=\"zFrame() !== 'none' || zShadow() ? 'hidden' : 'visible'\">\n <canvas\n #qrCanvas\n class=\"block\"\n [style.width.px]=\"zFrame() !== 'none' ? zSize() + zFramePadding() * 2 : zSize()\"\n [style.height.px]=\"\n zFrame() !== 'none'\n ? zSize() + zFramePadding() * 2 + (zFrame() === 'text-bottom' || zFrame() === 'text-top' ? 50 : 0)\n : zSize()\n \"></canvas>\n\n @if (zLoading()) {\n <div class=\"absolute inset-0 z-10 flex items-center justify-center bg-white/80 transition-opacity\">\n <svg\n class=\"h-8 w-8 animate-spin text-slate-800\"\n xmlns=\"http://www.w3.org/2000/svg\"\n fill=\"none\"\n viewBox=\"0 0 24 24\">\n <circle class=\"opacity-25\" cx=\"12\" cy=\"12\" r=\"10\" stroke=\"currentColor\" stroke-width=\"4\" />\n <path\n class=\"opacity-75\"\n fill=\"currentColor\"\n d=\"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z\" />\n </svg>\n </div>\n }\n\n @if (zDownloadable() && !zLoading()) {\n <div\n class=\"absolute inset-0 z-10 flex items-center justify-center rounded-md bg-black/45 opacity-0 transition-all duration-200 hover:opacity-100\">\n <button\n z-button\n [zWave]=\"false\"\n zSize=\"sm\"\n (click)=\"downloadQr()\"\n class=\"flex cursor-pointer items-center gap-2 font-semibold select-none\">\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n class=\"h-4 w-4\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n stroke=\"currentColor\"\n stroke-width=\"2.5\">\n <path\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n d=\"M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4\" />\n </svg>\n {{ downloadText() | translate }}\n </button>\n </div>\n }\n </div>\n\n @if (zDownloadButton() && !zLoading()) {\n <div class=\"mt-4\">\n <button\n z-button\n [zWave]=\"false\"\n (click)=\"downloadQr()\"\n class=\"flex cursor-pointer items-center gap-2 font-semibold select-none\">\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n class=\"h-4 w-4\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n stroke=\"currentColor\"\n stroke-width=\"2.5\">\n <path\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n d=\"M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4\" />\n </svg>\n {{ downloadText() | translate }}\n </button>\n </div>\n }\n</div>\n", styles: ["z-qrcode{display:inline-block;line-height:0}z-qrcode .z-qrcode-container{position:relative;display:inline-flex;flex-direction:column;align-items:center;border-radius:inherit}z-qrcode .z-qrcode-canvas-wrapper{position:relative;overflow:hidden;border-radius:inherit}\n"], dependencies: [{ kind: "component", type: ZButtonComponent, selector: "z-button, button[z-button], a[z-button]", inputs: ["class", "zType", "zSize", "zShape", "zLabel", "zLoading", "zDisabled", "zTypeIcon", "zAnimatedTypeIcon", "zAnimateIcon", "zAnimationTriggerIcon", "zSizeIcon", "zStrokeWidthIcon", "zWave"], exportAs: ["zButton"] }, { kind: "pipe", type: TranslatePipe, name: "translate" }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
372
- }
373
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.9", ngImport: i0, type: ZQrCodeComponent, decorators: [{
374
- type: Component,
375
- args: [{ selector: 'z-qrcode', imports: [TranslatePipe, ZButtonComponent], standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, template: "<div class=\"z-qrcode-container relative flex flex-col items-center\">\n <div\n class=\"z-qrcode-canvas-wrapper relative transition-all duration-200\"\n [class.shadow-md]=\"zShadow()\"\n [style.border-radius.px]=\"zFrame() !== 'none' || zShadow() ? zFrameBorderRadius() : 0\"\n [style.overflow]=\"zFrame() !== 'none' || zShadow() ? 'hidden' : 'visible'\">\n <canvas\n #qrCanvas\n class=\"block\"\n [style.width.px]=\"zFrame() !== 'none' ? zSize() + zFramePadding() * 2 : zSize()\"\n [style.height.px]=\"\n zFrame() !== 'none'\n ? zSize() + zFramePadding() * 2 + (zFrame() === 'text-bottom' || zFrame() === 'text-top' ? 50 : 0)\n : zSize()\n \"></canvas>\n\n @if (zLoading()) {\n <div class=\"absolute inset-0 z-10 flex items-center justify-center bg-white/80 transition-opacity\">\n <svg\n class=\"h-8 w-8 animate-spin text-slate-800\"\n xmlns=\"http://www.w3.org/2000/svg\"\n fill=\"none\"\n viewBox=\"0 0 24 24\">\n <circle class=\"opacity-25\" cx=\"12\" cy=\"12\" r=\"10\" stroke=\"currentColor\" stroke-width=\"4\" />\n <path\n class=\"opacity-75\"\n fill=\"currentColor\"\n d=\"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z\" />\n </svg>\n </div>\n }\n\n @if (zDownloadable() && !zLoading()) {\n <div\n class=\"absolute inset-0 z-10 flex items-center justify-center rounded-md bg-black/45 opacity-0 transition-all duration-200 hover:opacity-100\">\n <button\n z-button\n [zWave]=\"false\"\n zSize=\"sm\"\n (click)=\"downloadQr()\"\n class=\"flex cursor-pointer items-center gap-2 font-semibold select-none\">\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n class=\"h-4 w-4\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n stroke=\"currentColor\"\n stroke-width=\"2.5\">\n <path\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n d=\"M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4\" />\n </svg>\n {{ downloadText() | translate }}\n </button>\n </div>\n }\n </div>\n\n @if (zDownloadButton() && !zLoading()) {\n <div class=\"mt-4\">\n <button\n z-button\n [zWave]=\"false\"\n (click)=\"downloadQr()\"\n class=\"flex cursor-pointer items-center gap-2 font-semibold select-none\">\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n class=\"h-4 w-4\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n stroke=\"currentColor\"\n stroke-width=\"2.5\">\n <path\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n d=\"M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4\" />\n </svg>\n {{ downloadText() | translate }}\n </button>\n </div>\n }\n</div>\n", styles: ["z-qrcode{display:inline-block;line-height:0}z-qrcode .z-qrcode-container{position:relative;display:inline-flex;flex-direction:column;align-items:center;border-radius:inherit}z-qrcode .z-qrcode-canvas-wrapper{position:relative;overflow:hidden;border-radius:inherit}\n"] }]
376
- }], ctorParameters: () => [], propDecorators: { zValue: [{ type: i0.Input, args: [{ isSignal: true, alias: "zValue", required: true }] }], zSize: [{ type: i0.Input, args: [{ isSignal: true, alias: "zSize", required: false }] }], zLevel: [{ type: i0.Input, args: [{ isSignal: true, alias: "zLevel", required: false }] }], zLogo: [{ type: i0.Input, args: [{ isSignal: true, alias: "zLogo", required: false }] }], zLogoSize: [{ type: i0.Input, args: [{ isSignal: true, alias: "zLogoSize", required: false }] }], zLogoBgColor: [{ type: i0.Input, args: [{ isSignal: true, alias: "zLogoBgColor", required: false }] }], zLogoBgShape: [{ type: i0.Input, args: [{ isSignal: true, alias: "zLogoBgShape", required: false }] }], zLogoPadding: [{ type: i0.Input, args: [{ isSignal: true, alias: "zLogoPadding", required: false }] }], zFgColor: [{ type: i0.Input, args: [{ isSignal: true, alias: "zFgColor", required: false }] }], zBgColor: [{ type: i0.Input, args: [{ isSignal: true, alias: "zBgColor", required: false }] }], zDotStyle: [{ type: i0.Input, args: [{ isSignal: true, alias: "zDotStyle", required: false }] }], zEyeStyle: [{ type: i0.Input, args: [{ isSignal: true, alias: "zEyeStyle", required: false }] }], zEyeColor: [{ type: i0.Input, args: [{ isSignal: true, alias: "zEyeColor", required: false }] }], zMargin: [{ type: i0.Input, args: [{ isSignal: true, alias: "zMargin", required: false }] }], zFgGradient: [{ type: i0.Input, args: [{ isSignal: true, alias: "zFgGradient", required: false }] }], zFrame: [{ type: i0.Input, args: [{ isSignal: true, alias: "zFrame", required: false }] }], zFrameText: [{ type: i0.Input, args: [{ isSignal: true, alias: "zFrameText", required: false }] }], zFrameColor: [{ type: i0.Input, args: [{ isSignal: true, alias: "zFrameColor", required: false }] }], zFramePadding: [{ type: i0.Input, args: [{ isSignal: true, alias: "zFramePadding", required: false }] }], zFrameBorderRadius: [{ type: i0.Input, args: [{ isSignal: true, alias: "zFrameBorderRadius", required: false }] }], zDownloadable: [{ type: i0.Input, args: [{ isSignal: true, alias: "zDownloadable", required: false }] }], zDownloadButton: [{ type: i0.Input, args: [{ isSignal: true, alias: "zDownloadButton", required: false }] }], zShadow: [{ type: i0.Input, args: [{ isSignal: true, alias: "zShadow", required: false }] }], zLoading: [{ type: i0.Input, args: [{ isSignal: true, alias: "zLoading", required: false }] }], _canvasRef: [{ type: i0.ViewChild, args: ['qrCanvas', { isSignal: true }] }] } });
377
-
378
- /**
379
- * Generated bundle index. Do not edit.
380
- */
381
-
382
- export { ZQrCodeComponent };
383
- //# sourceMappingURL=shival99-z-ui-components-z-qrcode.mjs.map