ezfw-core 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/EzBaseComponent.ts +648 -0
- package/components/EzComponent.ts +89 -0
- package/components/EzInput.module.scss +183 -0
- package/components/EzInput.ts +104 -0
- package/components/EzLabel.ts +22 -0
- package/components/EzOutlet.ts +181 -0
- package/components/HtmlWrapper.ts +305 -0
- package/components/avatar/EzAvatar.module.scss +200 -0
- package/components/avatar/EzAvatar.ts +130 -0
- package/components/badge/EzBadge.module.scss +202 -0
- package/components/badge/EzBadge.ts +77 -0
- package/components/button/EzButton.module.scss +402 -0
- package/components/button/EzButton.ts +175 -0
- package/components/button/EzButtonGroup.ts +48 -0
- package/components/card/EzCard.module.scss +71 -0
- package/components/card/EzCard.ts +120 -0
- package/components/chart/EzBarChart.ts +47 -0
- package/components/chart/EzChart.module.scss +14 -0
- package/components/chart/EzChart.ts +279 -0
- package/components/chart/EzDoughnutChart.ts +47 -0
- package/components/chart/EzLineChart.ts +53 -0
- package/components/checkbox/EzCheckbox.module.scss +145 -0
- package/components/checkbox/EzCheckbox.ts +115 -0
- package/components/dataview/EzDataView.module.scss +115 -0
- package/components/dataview/EzDataView.ts +355 -0
- package/components/dataview/modes/EzDataViewCards.ts +322 -0
- package/components/dataview/modes/EzDataViewGrid.ts +76 -0
- package/components/datepicker/EzDatePicker.module.scss +348 -0
- package/components/datepicker/EzDatePicker.ts +519 -0
- package/components/dialog/EzDialog.module.scss +180 -0
- package/components/dropdown/EzDropdown.module.scss +107 -0
- package/components/dropdown/EzDropdown.ts +235 -0
- package/components/feed/EzActivityFeed.module.scss +90 -0
- package/components/feed/EzActivityFeed.ts +78 -0
- package/components/form/EzForm.ts +364 -0
- package/components/form/EzValidators.test.js +421 -0
- package/components/form/EzValidators.ts +202 -0
- package/components/grid/EzGrid.scss +88 -0
- package/components/grid/EzGrid.ts +1085 -0
- package/components/grid/EzGridContainer.ts +104 -0
- package/components/grid/body/EzGridBody.scss +283 -0
- package/components/grid/body/EzGridBody.ts +549 -0
- package/components/grid/body/EzGridCell.ts +211 -0
- package/components/grid/body/EzGridRow.ts +196 -0
- package/components/grid/filter/EzGridFilters.scss +78 -0
- package/components/grid/filter/EzGridFilters.ts +285 -0
- package/components/grid/footer/EzGridFooter.scss +136 -0
- package/components/grid/footer/EzGridFooter.ts +448 -0
- package/components/grid/header/EzGridHeader.scss +199 -0
- package/components/grid/header/EzGridHeader.ts +430 -0
- package/components/grid/query/EzGridQuery.ts +81 -0
- package/components/grid/state/EzGridColumns.ts +155 -0
- package/components/grid/state/EzGridController.ts +470 -0
- package/components/grid/state/EzGridLifecycle.ts +136 -0
- package/components/grid/state/EzGridNormalizers.test.js +273 -0
- package/components/grid/state/EzGridNormalizers.ts +162 -0
- package/components/grid/state/EzGridParts.ts +233 -0
- package/components/grid/state/EzGridPersistence.ts +140 -0
- package/components/grid/state/EzGridRemote.test.js +573 -0
- package/components/grid/state/EzGridRemote.ts +335 -0
- package/components/grid/state/EzGridSelection.ts +231 -0
- package/components/grid/state/EzGridSort.ts +286 -0
- package/components/grid/title/EzGridActionBar.ts +98 -0
- package/components/grid/title/EzGridTitle.ts +114 -0
- package/components/grid/title/EzGridTitleBar.scss +65 -0
- package/components/grid/title/EzGridTitleBar.ts +87 -0
- package/components/grid/types.ts +607 -0
- package/components/panel/EzPanel.module.scss +133 -0
- package/components/panel/EzPanel.ts +147 -0
- package/components/radio/EzRadio.module.scss +190 -0
- package/components/radio/EzRadio.ts +149 -0
- package/components/select/EzSelect.module.scss +153 -0
- package/components/select/EzSelect.ts +238 -0
- package/components/skeleton/EzSkeleton.module.scss +95 -0
- package/components/skeleton/EzSkeleton.ts +70 -0
- package/components/store/EzStore.ts +344 -0
- package/components/switch/EzSwitch.module.scss +164 -0
- package/components/switch/EzSwitch.ts +117 -0
- package/components/tabs/EzTabPanel.module.scss +181 -0
- package/components/tabs/EzTabPanel.ts +402 -0
- package/components/textarea/EzTextarea.module.scss +131 -0
- package/components/textarea/EzTextarea.ts +161 -0
- package/components/timepicker/EzTimePicker.module.scss +282 -0
- package/components/timepicker/EzTimePicker.ts +540 -0
- package/components/toast/EzToast.module.scss +291 -0
- package/components/tooltip/EzTooltip.module.scss +124 -0
- package/components/tooltip/EzTooltip.ts +153 -0
- package/core/EzComponentTypes.ts +693 -0
- package/core/EzError.ts +63 -0
- package/core/EzModel.ts +268 -0
- package/core/EzTypes.ts +328 -0
- package/core/eventBus.ts +284 -0
- package/core/ez.ts +617 -0
- package/core/loader.ts +725 -0
- package/core/renderer.ts +1010 -0
- package/core/router.ts +490 -0
- package/core/services.ts +124 -0
- package/core/state.ts +142 -0
- package/core/utils.ts +81 -0
- package/package.json +51 -0
- package/services/RouteUI.js +17 -0
- package/services/crypto.js +64 -0
- package/services/dialog.js +222 -0
- package/services/fetchApi.js +63 -0
- package/services/firebase.js +30 -0
- package/services/toast.js +214 -0
- package/template/doc/EzDocs.js +15 -0
- package/template/doc/EzDocs.module.scss +627 -0
- package/template/doc/EzDocsController.js +164 -0
- package/template/doc/data/activityfeed/EzActivityFeedDoc.js +42 -0
- package/template/doc/data/avatar/EzAvatarDoc.js +71 -0
- package/template/doc/data/badge/EzBadgeDoc.js +92 -0
- package/template/doc/data/button/EzButtonDoc.js +77 -0
- package/template/doc/data/buttongroup/EzButtonGroupDoc.js +102 -0
- package/template/doc/data/card/EzCardDoc.js +39 -0
- package/template/doc/data/chart/EzChartDoc.js +60 -0
- package/template/doc/data/checkbox/EzCheckboxDoc.js +67 -0
- package/template/doc/data/component/EzComponentDoc.js +34 -0
- package/template/doc/data/cssmodules/CSSModulesDoc.js +70 -0
- package/template/doc/data/datepicker/EzDatePickerDoc.js +126 -0
- package/template/doc/data/dialog/EzDialogDoc.js +217 -0
- package/template/doc/data/dropdown/EzDropdownDoc.js +178 -0
- package/template/doc/data/form/EzFormDoc.js +90 -0
- package/template/doc/data/grid/EzGridDoc.js +99 -0
- package/template/doc/data/input/EzInputDoc.js +92 -0
- package/template/doc/data/label/EzLabelDoc.js +40 -0
- package/template/doc/data/model/EzModelDoc.js +53 -0
- package/template/doc/data/outlet/EzOutletDoc.js +63 -0
- package/template/doc/data/panel/EzPanelDoc.js +214 -0
- package/template/doc/data/radio/EzRadioDoc.js +174 -0
- package/template/doc/data/router/EzRouterDoc.js +75 -0
- package/template/doc/data/select/EzSelectDoc.js +37 -0
- package/template/doc/data/skeleton/EzSkeletonDoc.js +149 -0
- package/template/doc/data/switch/EzSwitchDoc.js +82 -0
- package/template/doc/data/tabpanel/EzTabPanelDoc.js +44 -0
- package/template/doc/data/textarea/EzTextareaDoc.js +131 -0
- package/template/doc/data/timepicker/EzTimePickerDoc.js +107 -0
- package/template/doc/data/tooltip/EzTooltipDoc.js +193 -0
- package/template/doc/data/validators/EzValidatorsDoc.js +37 -0
- package/template/doc/sidebar/EzDocsSidebar.js +32 -0
- package/template/doc/sidebar/category/EzDocsCategory.js +33 -0
- package/template/doc/sidebar/item/EzDocsComponentItem.js +24 -0
- package/template/doc/viewer/EzDocsViewer.js +18 -0
- package/template/doc/viewer/codepanel/EzDocsCodePanel.js +51 -0
- package/template/doc/viewer/content/EzDocsContent.js +315 -0
- package/template/doc/viewer/header/EzDocsViewerHeader.js +46 -0
- package/template/doc/viewer/showcase/EzDocsShowcase.js +59 -0
- package/template/doc/viewer/showcase/EzDocsShowcaseSection.js +25 -0
- package/template/doc/viewer/showcase/EzDocsVariantItem.js +29 -0
- package/template/doc/welcome/EzDocsWelcome.js +48 -0
- package/themes/ez-theme.scss +179 -0
- package/themes/nature-fresh.scss +169 -0
- package/types/global.d.ts +21 -0
- package/utils/cssModules.js +81 -0
|
@@ -0,0 +1,322 @@
|
|
|
1
|
+
import { EzBaseComponent, EzBaseComponentConfig } from '../../EzBaseComponent.js';
|
|
2
|
+
|
|
3
|
+
declare const ez: {
|
|
4
|
+
_createChildElements(items: unknown[], controller: string | null, state: unknown): Promise<Node[]>;
|
|
5
|
+
define(name: string, component: unknown): void;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
interface EzStore {
|
|
9
|
+
state: {
|
|
10
|
+
data: unknown[];
|
|
11
|
+
loading: boolean;
|
|
12
|
+
page: number;
|
|
13
|
+
pageSize: number;
|
|
14
|
+
total: number;
|
|
15
|
+
};
|
|
16
|
+
on(event: string, callback: (...args: unknown[]) => void): () => void;
|
|
17
|
+
load(): Promise<void>;
|
|
18
|
+
reload(): Promise<void>;
|
|
19
|
+
getTotalPages(): number;
|
|
20
|
+
isFirstPage(): boolean;
|
|
21
|
+
isLastPage(): boolean;
|
|
22
|
+
goToFirstPage(): void;
|
|
23
|
+
goToPrevPage(): void;
|
|
24
|
+
goToNextPage(): void;
|
|
25
|
+
goToLastPage(): void;
|
|
26
|
+
setPageSize(size: number): void;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
interface CardsConfig {
|
|
30
|
+
columns?: number | 'auto';
|
|
31
|
+
minWidth?: number;
|
|
32
|
+
gap?: number;
|
|
33
|
+
itemRender?: (item: unknown, index: number, meta: { isFirst: boolean; isLast: boolean; isEven: boolean }) => unknown;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface EzDataViewCardsConfig extends EzBaseComponentConfig {
|
|
37
|
+
store?: EzStore;
|
|
38
|
+
cardsConfig?: CardsConfig;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export class EzDataViewCards extends EzBaseComponent {
|
|
42
|
+
declare config: EzDataViewCardsConfig;
|
|
43
|
+
declare el: HTMLElement;
|
|
44
|
+
|
|
45
|
+
private _store: EzStore | null;
|
|
46
|
+
private _cardsConfig: CardsConfig;
|
|
47
|
+
private _unsubscribers: (() => void)[] = [];
|
|
48
|
+
private _cardsContainer: HTMLElement | null = null;
|
|
49
|
+
private _footerEl: HTMLElement | null = null;
|
|
50
|
+
private _btnFirst: HTMLButtonElement | null = null;
|
|
51
|
+
private _btnPrev: HTMLButtonElement | null = null;
|
|
52
|
+
private _btnNext: HTMLButtonElement | null = null;
|
|
53
|
+
private _btnLast: HTMLButtonElement | null = null;
|
|
54
|
+
private _pageIndicator: HTMLElement | null = null;
|
|
55
|
+
private _pageInfoEl: HTMLElement | null = null;
|
|
56
|
+
|
|
57
|
+
constructor(config: EzDataViewCardsConfig = {}) {
|
|
58
|
+
super(config);
|
|
59
|
+
|
|
60
|
+
this.config = config;
|
|
61
|
+
this._store = config.store || null;
|
|
62
|
+
this._cardsConfig = config.cardsConfig || {};
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
async render(): Promise<HTMLElement> {
|
|
66
|
+
const el = document.createElement('div');
|
|
67
|
+
el.className = 'ez-dataview-cards';
|
|
68
|
+
el.style.display = 'flex';
|
|
69
|
+
el.style.flexDirection = 'column';
|
|
70
|
+
el.style.flex = '1';
|
|
71
|
+
el.style.minHeight = '0';
|
|
72
|
+
el.style.overflow = 'hidden';
|
|
73
|
+
|
|
74
|
+
this._cardsContainer = document.createElement('div');
|
|
75
|
+
this._cardsContainer.className = 'ez-dataview-cards-grid';
|
|
76
|
+
this._applyGridStyles();
|
|
77
|
+
|
|
78
|
+
this._footerEl = document.createElement('div');
|
|
79
|
+
this._footerEl.className = 'ez-dataview-cards-footer';
|
|
80
|
+
this._footerEl.style.padding = '12px 16px';
|
|
81
|
+
this._footerEl.style.borderTop = '1px solid var(--ez-border)';
|
|
82
|
+
this._footerEl.style.display = 'flex';
|
|
83
|
+
this._footerEl.style.alignItems = 'center';
|
|
84
|
+
this._footerEl.style.gap = '16px';
|
|
85
|
+
|
|
86
|
+
el.appendChild(this._cardsContainer);
|
|
87
|
+
el.appendChild(this._footerEl);
|
|
88
|
+
|
|
89
|
+
if (this._store) {
|
|
90
|
+
this._unsubscribers.push(
|
|
91
|
+
this._store.on('datachange', () => this._renderCards()),
|
|
92
|
+
this._store.on('loadingchange', (loading: unknown) => this._onLoadingChange(loading as boolean)),
|
|
93
|
+
this._store.on('pagechange', () => this._updateFooter())
|
|
94
|
+
);
|
|
95
|
+
|
|
96
|
+
if (this._store.state.data.length > 0) {
|
|
97
|
+
await this._renderCards();
|
|
98
|
+
} else if (!this._store.state.loading) {
|
|
99
|
+
this._store.load();
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
await this._renderFooter();
|
|
104
|
+
|
|
105
|
+
this.el = el;
|
|
106
|
+
return el;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
private _applyGridStyles(): void {
|
|
110
|
+
if (!this._cardsContainer) return;
|
|
111
|
+
|
|
112
|
+
const { columns = 'auto', minWidth = 300, gap = 16 } = this._cardsConfig;
|
|
113
|
+
|
|
114
|
+
const gridTemplate = columns === 'auto'
|
|
115
|
+
? `repeat(auto-fill, minmax(${minWidth}px, 1fr))`
|
|
116
|
+
: `repeat(${columns}, 1fr)`;
|
|
117
|
+
|
|
118
|
+
this._cardsContainer.style.display = 'grid';
|
|
119
|
+
this._cardsContainer.style.gridTemplateColumns = gridTemplate;
|
|
120
|
+
this._cardsContainer.style.gap = `${gap}px`;
|
|
121
|
+
this._cardsContainer.style.padding = '16px';
|
|
122
|
+
this._cardsContainer.style.flex = '1';
|
|
123
|
+
this._cardsContainer.style.overflowY = 'auto';
|
|
124
|
+
this._cardsContainer.style.minHeight = '0';
|
|
125
|
+
this._cardsContainer.style.alignContent = 'start';
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
private _onLoadingChange(loading: boolean): void {
|
|
129
|
+
if (loading) {
|
|
130
|
+
this._showLoading();
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
private _showLoading(): void {
|
|
135
|
+
if (!this._cardsContainer) return;
|
|
136
|
+
this._cardsContainer.innerHTML = `
|
|
137
|
+
<div style="grid-column: 1 / -1; text-align: center; padding: 60px 20px; color: var(--ez-text-tertiary);">
|
|
138
|
+
Loading...
|
|
139
|
+
</div>
|
|
140
|
+
`;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
private async _renderCards(): Promise<void> {
|
|
144
|
+
if (!this._cardsContainer) return;
|
|
145
|
+
|
|
146
|
+
this._cardsContainer.innerHTML = '';
|
|
147
|
+
|
|
148
|
+
const data = this._store?.state.data || [];
|
|
149
|
+
const { itemRender } = this._cardsConfig;
|
|
150
|
+
|
|
151
|
+
if (!itemRender || data.length === 0) {
|
|
152
|
+
this._cardsContainer.innerHTML = `
|
|
153
|
+
<div style="grid-column: 1 / -1; text-align: center; padding: 60px 20px; color: var(--ez-text-tertiary);">
|
|
154
|
+
No items to display
|
|
155
|
+
</div>
|
|
156
|
+
`;
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
const cardConfigs = data.map((item, index) => {
|
|
161
|
+
return itemRender(item, index, {
|
|
162
|
+
isFirst: index === 0,
|
|
163
|
+
isLast: index === data.length - 1,
|
|
164
|
+
isEven: index % 2 === 0
|
|
165
|
+
});
|
|
166
|
+
}).filter(Boolean);
|
|
167
|
+
|
|
168
|
+
const children = await ez._createChildElements(cardConfigs, null, null);
|
|
169
|
+
|
|
170
|
+
for (const child of children) {
|
|
171
|
+
if (child instanceof Node) {
|
|
172
|
+
this._cardsContainer.appendChild(child);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
this._updateFooter();
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
private async _renderFooter(): Promise<void> {
|
|
180
|
+
if (!this._footerEl || !this._store) return;
|
|
181
|
+
|
|
182
|
+
const store = this._store;
|
|
183
|
+
|
|
184
|
+
const footerItems = [
|
|
185
|
+
{
|
|
186
|
+
eztype: 'EzComponent',
|
|
187
|
+
layout: 'hbox',
|
|
188
|
+
style: { gap: '4px' },
|
|
189
|
+
items: [
|
|
190
|
+
{
|
|
191
|
+
eztype: 'EzButton',
|
|
192
|
+
text: '«',
|
|
193
|
+
size: 'sm',
|
|
194
|
+
variant: 'ghost',
|
|
195
|
+
onClick: () => store.goToFirstPage(),
|
|
196
|
+
_ezAfterRender: (el: HTMLButtonElement) => { this._btnFirst = el; }
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
eztype: 'EzButton',
|
|
200
|
+
text: '‹',
|
|
201
|
+
size: 'sm',
|
|
202
|
+
variant: 'ghost',
|
|
203
|
+
onClick: () => store.goToPrevPage(),
|
|
204
|
+
_ezAfterRender: (el: HTMLButtonElement) => { this._btnPrev = el; }
|
|
205
|
+
},
|
|
206
|
+
{
|
|
207
|
+
eztype: 'span',
|
|
208
|
+
style: { padding: '0 12px', fontSize: '13px', lineHeight: '28px' },
|
|
209
|
+
text: `${store.state.page} / ${store.getTotalPages()}`,
|
|
210
|
+
_ezAfterRender: (el: HTMLElement) => { this._pageIndicator = el; }
|
|
211
|
+
},
|
|
212
|
+
{
|
|
213
|
+
eztype: 'EzButton',
|
|
214
|
+
text: '›',
|
|
215
|
+
size: 'sm',
|
|
216
|
+
variant: 'ghost',
|
|
217
|
+
onClick: () => store.goToNextPage(),
|
|
218
|
+
_ezAfterRender: (el: HTMLButtonElement) => { this._btnNext = el; }
|
|
219
|
+
},
|
|
220
|
+
{
|
|
221
|
+
eztype: 'EzButton',
|
|
222
|
+
text: '»',
|
|
223
|
+
size: 'sm',
|
|
224
|
+
variant: 'ghost',
|
|
225
|
+
onClick: () => store.goToLastPage(),
|
|
226
|
+
_ezAfterRender: (el: HTMLButtonElement) => { this._btnLast = el; }
|
|
227
|
+
}
|
|
228
|
+
]
|
|
229
|
+
},
|
|
230
|
+
{ eztype: 'EzComponent', flex: 1 },
|
|
231
|
+
{
|
|
232
|
+
eztype: 'EzComponent',
|
|
233
|
+
layout: 'hbox',
|
|
234
|
+
style: { alignItems: 'center', gap: '8px' },
|
|
235
|
+
items: [
|
|
236
|
+
{
|
|
237
|
+
eztype: 'span',
|
|
238
|
+
text: 'Per page:',
|
|
239
|
+
style: { fontSize: '13px', color: 'var(--ez-text-secondary)' }
|
|
240
|
+
},
|
|
241
|
+
{
|
|
242
|
+
eztype: 'EzSelect',
|
|
243
|
+
size: 'sm',
|
|
244
|
+
options: [10, 25, 50, 100],
|
|
245
|
+
value: store.state.pageSize,
|
|
246
|
+
onChange: (val: string) => store.setPageSize(parseInt(val, 10))
|
|
247
|
+
}
|
|
248
|
+
]
|
|
249
|
+
},
|
|
250
|
+
{
|
|
251
|
+
eztype: 'span',
|
|
252
|
+
style: { fontSize: '13px', color: 'var(--ez-text-secondary)' },
|
|
253
|
+
_ezAfterRender: (el: HTMLElement) => {
|
|
254
|
+
this._pageInfoEl = el;
|
|
255
|
+
this._updatePageInfo();
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
];
|
|
259
|
+
|
|
260
|
+
const children = await ez._createChildElements(footerItems, null, null);
|
|
261
|
+
|
|
262
|
+
for (const child of children) {
|
|
263
|
+
if (child instanceof Node) {
|
|
264
|
+
this._footerEl.appendChild(child);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
this._updateButtonStates();
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
private _updateFooter(): void {
|
|
272
|
+
this._updatePageIndicator();
|
|
273
|
+
this._updatePageInfo();
|
|
274
|
+
this._updateButtonStates();
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
private _updatePageIndicator(): void {
|
|
278
|
+
if (this._pageIndicator && this._store) {
|
|
279
|
+
this._pageIndicator.textContent = `${this._store.state.page} / ${this._store.getTotalPages()}`;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
private _updatePageInfo(): void {
|
|
284
|
+
if (this._pageInfoEl && this._store) {
|
|
285
|
+
const { page, pageSize, total } = this._store.state;
|
|
286
|
+
const start = total === 0 ? 0 : (page - 1) * pageSize + 1;
|
|
287
|
+
const end = Math.min(page * pageSize, total);
|
|
288
|
+
this._pageInfoEl.textContent = `${start} - ${end} of ${total}`;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
private _updateButtonStates(): void {
|
|
293
|
+
if (!this._store) return;
|
|
294
|
+
|
|
295
|
+
const isFirst = this._store.isFirstPage();
|
|
296
|
+
const isLast = this._store.isLastPage();
|
|
297
|
+
|
|
298
|
+
if (this._btnFirst) this._btnFirst.disabled = isFirst;
|
|
299
|
+
if (this._btnPrev) this._btnPrev.disabled = isFirst;
|
|
300
|
+
if (this._btnNext) this._btnNext.disabled = isLast;
|
|
301
|
+
if (this._btnLast) this._btnLast.disabled = isLast;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
async refresh(): Promise<void> {
|
|
305
|
+
if (this._store) {
|
|
306
|
+
await this._store.reload();
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
destroy(): void {
|
|
311
|
+
for (const unsub of this._unsubscribers) {
|
|
312
|
+
if (typeof unsub === 'function') {
|
|
313
|
+
unsub();
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
this._unsubscribers = [];
|
|
317
|
+
|
|
318
|
+
super.destroy();
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
ez.define('EzDataViewCards', EzDataViewCards);
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { EzBaseComponent, EzBaseComponentConfig } from '../../EzBaseComponent.js';
|
|
2
|
+
|
|
3
|
+
declare const ez: {
|
|
4
|
+
_createChildElements(items: unknown[], controller: string | null, state: unknown): Promise<Node[]>;
|
|
5
|
+
define(name: string, component: unknown): void;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
interface EzGridInstance {
|
|
9
|
+
[key: string]: unknown;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
interface EzDataViewInstance {
|
|
13
|
+
_gridInstance?: EzGridInstance;
|
|
14
|
+
[key: string]: unknown;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
interface GridConfig {
|
|
18
|
+
[key: string]: unknown;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface EzDataViewGridConfig extends EzBaseComponentConfig {
|
|
22
|
+
gridConfig?: GridConfig;
|
|
23
|
+
dataView?: EzDataViewInstance;
|
|
24
|
+
model?: string;
|
|
25
|
+
remote?: unknown;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export class EzDataViewGrid extends EzBaseComponent {
|
|
29
|
+
declare config: EzDataViewGridConfig;
|
|
30
|
+
declare el: HTMLElement;
|
|
31
|
+
|
|
32
|
+
private _gridInstance: EzGridInstance | null = null;
|
|
33
|
+
|
|
34
|
+
constructor(config: EzDataViewGridConfig = {}) {
|
|
35
|
+
super(config);
|
|
36
|
+
this.config = config;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
async render(): Promise<HTMLElement> {
|
|
40
|
+
const { gridConfig = {}, dataView, model, remote } = this.config;
|
|
41
|
+
|
|
42
|
+
const gridCfg = {
|
|
43
|
+
eztype: 'EzGrid',
|
|
44
|
+
flex: 1,
|
|
45
|
+
model,
|
|
46
|
+
remote,
|
|
47
|
+
autoLoad: true,
|
|
48
|
+
...gridConfig,
|
|
49
|
+
title: null,
|
|
50
|
+
_ezAfterRender: (_el: HTMLElement, instance: EzGridInstance) => {
|
|
51
|
+
this._gridInstance = instance;
|
|
52
|
+
if (dataView) {
|
|
53
|
+
dataView._gridInstance = instance;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
const children = await ez._createChildElements([gridCfg], null, null);
|
|
59
|
+
|
|
60
|
+
if (children[0] instanceof Node) {
|
|
61
|
+
this.el = children[0] as HTMLElement;
|
|
62
|
+
return this.el;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const el = document.createElement('div');
|
|
66
|
+
el.textContent = 'Failed to render grid';
|
|
67
|
+
this.el = el;
|
|
68
|
+
return el;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
getGridInstance(): EzGridInstance | null {
|
|
72
|
+
return this._gridInstance;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
ez.define('EzDataViewGrid', EzDataViewGrid);
|