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,175 @@
|
|
|
1
|
+
import styles from './EzButton.module.scss';
|
|
2
|
+
import { cx } from '../../utils/cssModules.js';
|
|
3
|
+
import { EzBaseComponent, EzBaseComponentConfig } from '../EzBaseComponent.js';
|
|
4
|
+
|
|
5
|
+
const cls = cx(styles);
|
|
6
|
+
|
|
7
|
+
declare const ez: {
|
|
8
|
+
_createElement(config: unknown): Promise<HTMLElement>;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
const VARIANT_MAP: Record<string, string> = {
|
|
12
|
+
'primary': 'primary',
|
|
13
|
+
'danger': 'danger',
|
|
14
|
+
'success': 'success',
|
|
15
|
+
'warning': 'warning',
|
|
16
|
+
'ghost': 'ghost',
|
|
17
|
+
'text': 'text',
|
|
18
|
+
'outline': 'outline',
|
|
19
|
+
'outline-primary': 'outlinePrimary',
|
|
20
|
+
'outline-danger': 'outlineDanger',
|
|
21
|
+
'outline-success': 'outlineSuccess',
|
|
22
|
+
'outline-warning': 'outlineWarning'
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export interface EzButtonConfig extends EzBaseComponentConfig {
|
|
26
|
+
text?: string;
|
|
27
|
+
icon?: string;
|
|
28
|
+
iconPosition?: 'left' | 'right';
|
|
29
|
+
variant?: 'primary' | 'danger' | 'success' | 'warning' | 'ghost' | 'text' | 'outline' | 'outline-primary' | 'outline-danger' | 'outline-success' | 'outline-warning';
|
|
30
|
+
size?: 'sm' | 'lg';
|
|
31
|
+
block?: boolean;
|
|
32
|
+
loading?: boolean;
|
|
33
|
+
disabled?: boolean;
|
|
34
|
+
htmlType?: 'button' | 'submit' | 'reset';
|
|
35
|
+
type?: 'button' | 'submit' | 'reset';
|
|
36
|
+
onClick?: (e: MouseEvent, component: EzButton) => void;
|
|
37
|
+
tooltip?: string;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export class EzButton extends EzBaseComponent {
|
|
41
|
+
declare config: EzButtonConfig;
|
|
42
|
+
declare el: HTMLButtonElement;
|
|
43
|
+
|
|
44
|
+
private _loading: boolean = false;
|
|
45
|
+
|
|
46
|
+
constructor(config: EzButtonConfig = {}) {
|
|
47
|
+
super(config);
|
|
48
|
+
this.config = config;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
async render(): Promise<HTMLButtonElement> {
|
|
52
|
+
const cfg = this.config;
|
|
53
|
+
|
|
54
|
+
const el = await ez._createElement({
|
|
55
|
+
eztype: 'button',
|
|
56
|
+
cls: this._buildClasses(),
|
|
57
|
+
type: cfg.htmlType || cfg.type || 'button',
|
|
58
|
+
disabled: cfg.disabled || cfg.loading,
|
|
59
|
+
style: cfg.style,
|
|
60
|
+
onClick: cfg.onClick ? (e: MouseEvent) => {
|
|
61
|
+
if (this._loading) return;
|
|
62
|
+
cfg.onClick!(e, this);
|
|
63
|
+
} : undefined,
|
|
64
|
+
items: this._buildItems()
|
|
65
|
+
}) as HTMLButtonElement;
|
|
66
|
+
|
|
67
|
+
if (cfg.loading) {
|
|
68
|
+
this._applyLoadingState(el, true);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
this.applyTooltip(el);
|
|
72
|
+
this.el = el;
|
|
73
|
+
|
|
74
|
+
return el;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
private _buildClasses(): string[] {
|
|
78
|
+
const cfg = this.config;
|
|
79
|
+
const classes: string[] = [cls('button')];
|
|
80
|
+
|
|
81
|
+
if (cfg.variant && VARIANT_MAP[cfg.variant]) {
|
|
82
|
+
classes.push(cls(VARIANT_MAP[cfg.variant]));
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (cfg.size) {
|
|
86
|
+
classes.push(cls(cfg.size));
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if (cfg.block) {
|
|
90
|
+
classes.push(cls('block'));
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if (cfg.icon && !cfg.text) {
|
|
94
|
+
classes.push(cls('iconOnly'));
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
return classes;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
private _buildItems(): unknown[] {
|
|
101
|
+
const cfg = this.config;
|
|
102
|
+
const items: unknown[] = [];
|
|
103
|
+
const iconPosition = cfg.iconPosition || 'left';
|
|
104
|
+
|
|
105
|
+
const textItem = cfg.text ? {
|
|
106
|
+
eztype: 'span',
|
|
107
|
+
cls: cls('buttonText'),
|
|
108
|
+
text: cfg.text
|
|
109
|
+
} : null;
|
|
110
|
+
|
|
111
|
+
const iconItem = cfg.icon ? {
|
|
112
|
+
eztype: 'i',
|
|
113
|
+
cls: [cls('buttonIcon'), cfg.icon].join(' ')
|
|
114
|
+
} : null;
|
|
115
|
+
|
|
116
|
+
if (iconPosition === 'right') {
|
|
117
|
+
if (textItem) items.push(textItem);
|
|
118
|
+
if (iconItem) items.push(iconItem);
|
|
119
|
+
} else {
|
|
120
|
+
if (iconItem) items.push(iconItem);
|
|
121
|
+
if (textItem) items.push(textItem);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
return items;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
private _applyLoadingState(el: HTMLButtonElement, loading: boolean): void {
|
|
128
|
+
const spinnerClass = cls('spinner');
|
|
129
|
+
|
|
130
|
+
if (loading) {
|
|
131
|
+
el.classList.add(cls('loading'));
|
|
132
|
+
el.disabled = true;
|
|
133
|
+
|
|
134
|
+
if (!el.querySelector(`.${spinnerClass}`)) {
|
|
135
|
+
const spinner = document.createElement('span');
|
|
136
|
+
spinner.className = spinnerClass;
|
|
137
|
+
el.insertBefore(spinner, el.firstChild);
|
|
138
|
+
}
|
|
139
|
+
} else {
|
|
140
|
+
el.classList.remove(cls('loading'));
|
|
141
|
+
el.disabled = this.config.disabled || false;
|
|
142
|
+
|
|
143
|
+
const spinner = el.querySelector(`.${spinnerClass}`);
|
|
144
|
+
if (spinner) spinner.remove();
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
setLoading(loading: boolean): void {
|
|
149
|
+
this._loading = loading;
|
|
150
|
+
if (this.el) {
|
|
151
|
+
this._applyLoadingState(this.el, loading);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
isLoading(): boolean {
|
|
156
|
+
return this._loading;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
setDisabled(disabled: boolean): void {
|
|
160
|
+
this.config.disabled = disabled;
|
|
161
|
+
if (this.el && !this._loading) {
|
|
162
|
+
this.el.disabled = disabled;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
setText(text: string): void {
|
|
167
|
+
this.config.text = text;
|
|
168
|
+
if (this.el) {
|
|
169
|
+
const textSpan = this.el.querySelector(`.${cls('buttonText')}`);
|
|
170
|
+
if (textSpan) {
|
|
171
|
+
textSpan.textContent = text;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import styles from './EzButton.module.scss';
|
|
2
|
+
import { cx } from '../../utils/cssModules.js';
|
|
3
|
+
import { EzBaseComponent, EzBaseComponentConfig } from '../EzBaseComponent.js';
|
|
4
|
+
|
|
5
|
+
declare const ez: {
|
|
6
|
+
_createElement(config: unknown, controller?: unknown, parent?: unknown): Promise<HTMLElement>;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
const cls = cx(styles);
|
|
10
|
+
|
|
11
|
+
export interface EzButtonGroupConfig extends EzBaseComponentConfig {
|
|
12
|
+
vertical?: boolean;
|
|
13
|
+
items?: unknown[];
|
|
14
|
+
controller?: string | null;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export class EzButtonGroup extends EzBaseComponent {
|
|
18
|
+
declare config: EzButtonGroupConfig;
|
|
19
|
+
declare el: HTMLDivElement;
|
|
20
|
+
|
|
21
|
+
constructor(config: EzButtonGroupConfig = {}) {
|
|
22
|
+
super(config);
|
|
23
|
+
this.config = config;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
async render(): Promise<HTMLDivElement> {
|
|
27
|
+
const cfg = this.config;
|
|
28
|
+
const el = document.createElement('div');
|
|
29
|
+
|
|
30
|
+
el.classList.add(cls('buttonGroup'));
|
|
31
|
+
|
|
32
|
+
if (cfg.vertical) {
|
|
33
|
+
el.classList.add(cls('buttonGroupVertical'));
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (Array.isArray(cfg.items)) {
|
|
37
|
+
for (const item of cfg.items) {
|
|
38
|
+
const child = await ez._createElement(item, cfg.controller || null, this);
|
|
39
|
+
el.appendChild(child);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
this.applyStyles(el);
|
|
44
|
+
this.el = el;
|
|
45
|
+
|
|
46
|
+
return el;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
// ==========================================================
|
|
2
|
+
// EzCard - Base Card Styles
|
|
3
|
+
// ==========================================================
|
|
4
|
+
|
|
5
|
+
.card {
|
|
6
|
+
background: var(--ez-surface-secondary, #ffffff);
|
|
7
|
+
border: 1px solid var(--ez-border, #e2e8f0);
|
|
8
|
+
border-radius: 12px;
|
|
9
|
+
overflow: hidden;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.header {
|
|
13
|
+
padding: 16px 20px;
|
|
14
|
+
border-bottom: 1px solid var(--ez-border, #e2e8f0);
|
|
15
|
+
display: flex;
|
|
16
|
+
align-items: center;
|
|
17
|
+
justify-content: space-between;
|
|
18
|
+
gap: 16px;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.titleWrapper {
|
|
22
|
+
display: flex;
|
|
23
|
+
flex-direction: column;
|
|
24
|
+
gap: 2px;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.title {
|
|
28
|
+
font-size: 15px;
|
|
29
|
+
font-weight: 600;
|
|
30
|
+
color: var(--ez-text-primary, #1e293b);
|
|
31
|
+
margin: 0;
|
|
32
|
+
line-height: 1.3;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.subtitle {
|
|
36
|
+
font-size: 13px;
|
|
37
|
+
color: var(--ez-text-tertiary, #94a3b8);
|
|
38
|
+
margin: 0;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.actions {
|
|
42
|
+
display: flex;
|
|
43
|
+
gap: 8px;
|
|
44
|
+
flex-wrap: wrap;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.body {
|
|
48
|
+
padding: 20px;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.noPadding {
|
|
52
|
+
padding: 0;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// ==========================================================
|
|
56
|
+
// Variants
|
|
57
|
+
// ==========================================================
|
|
58
|
+
|
|
59
|
+
.elevated {
|
|
60
|
+
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
|
|
61
|
+
border: none;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.flat {
|
|
65
|
+
border: none;
|
|
66
|
+
background: var(--ez-surface-primary, #f8fafc);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.outlined {
|
|
70
|
+
background: transparent;
|
|
71
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { EzBaseComponent, EzBaseComponentConfig } from '../EzBaseComponent.js';
|
|
2
|
+
import styles from './EzCard.module.scss';
|
|
3
|
+
import { cx } from '../../utils/cssModules.js';
|
|
4
|
+
|
|
5
|
+
const cls = cx(styles);
|
|
6
|
+
|
|
7
|
+
declare const ez: {
|
|
8
|
+
_createElement(config: unknown): Promise<HTMLElement>;
|
|
9
|
+
registerComponent(name: string, component: unknown): void;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export interface EzCardConfig extends EzBaseComponentConfig {
|
|
13
|
+
title?: string;
|
|
14
|
+
subtitle?: string;
|
|
15
|
+
headerActions?: unknown[];
|
|
16
|
+
variant?: 'default' | 'bordered' | 'elevated';
|
|
17
|
+
noPadding?: boolean;
|
|
18
|
+
items?: unknown[];
|
|
19
|
+
controller?: string | null;
|
|
20
|
+
css?: unknown;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export class EzCard extends EzBaseComponent {
|
|
24
|
+
declare config: EzCardConfig;
|
|
25
|
+
|
|
26
|
+
constructor(config: EzCardConfig = {}) {
|
|
27
|
+
super(config);
|
|
28
|
+
this.config = config;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
async render(): Promise<HTMLDivElement> {
|
|
32
|
+
const cfg = this.config;
|
|
33
|
+
|
|
34
|
+
const el = await ez._createElement({
|
|
35
|
+
eztype: 'div',
|
|
36
|
+
cls: this._buildClasses(),
|
|
37
|
+
style: cfg.style,
|
|
38
|
+
items: this._buildItems()
|
|
39
|
+
}) as HTMLDivElement;
|
|
40
|
+
|
|
41
|
+
return el;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
private _buildClasses(): string[] {
|
|
45
|
+
const { variant = 'default', cls: userCls } = this.config;
|
|
46
|
+
const classes: string[] = [cls('card')];
|
|
47
|
+
|
|
48
|
+
if (variant !== 'default') {
|
|
49
|
+
classes.push(cls(variant));
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (userCls) {
|
|
53
|
+
if (Array.isArray(userCls)) {
|
|
54
|
+
classes.push(...userCls);
|
|
55
|
+
} else {
|
|
56
|
+
classes.push(userCls);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return classes;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
private _buildItems(): unknown[] {
|
|
64
|
+
const { title, subtitle, headerActions, noPadding, items = [] } = this.config;
|
|
65
|
+
const result: unknown[] = [];
|
|
66
|
+
|
|
67
|
+
// Header (if title or actions exist)
|
|
68
|
+
if (title || (headerActions && headerActions.length > 0)) {
|
|
69
|
+
result.push(this._buildHeader());
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// Body
|
|
73
|
+
result.push({
|
|
74
|
+
eztype: 'div',
|
|
75
|
+
cls: noPadding ? [cls('body'), cls('noPadding')] : cls('body'),
|
|
76
|
+
items: items
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
return result;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
private _buildHeader(): unknown {
|
|
83
|
+
const { title, subtitle, headerActions } = this.config;
|
|
84
|
+
const headerItems: unknown[] = [];
|
|
85
|
+
|
|
86
|
+
// Title wrapper
|
|
87
|
+
if (title) {
|
|
88
|
+
const titleItems: unknown[] = [
|
|
89
|
+
{ eztype: 'h3', cls: cls('title'), text: title }
|
|
90
|
+
];
|
|
91
|
+
|
|
92
|
+
if (subtitle) {
|
|
93
|
+
titleItems.push({ eztype: 'p', cls: cls('subtitle'), text: subtitle });
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
headerItems.push({
|
|
97
|
+
eztype: 'div',
|
|
98
|
+
cls: cls('titleWrapper'),
|
|
99
|
+
items: titleItems
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// Actions
|
|
104
|
+
if (headerActions && headerActions.length > 0) {
|
|
105
|
+
headerItems.push({
|
|
106
|
+
eztype: 'div',
|
|
107
|
+
cls: cls('actions'),
|
|
108
|
+
items: headerActions
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
return {
|
|
113
|
+
eztype: 'div',
|
|
114
|
+
cls: cls('header'),
|
|
115
|
+
items: headerItems
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
ez.registerComponent('EzCard', EzCard);
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { EzChart, EzChartConfig } from './EzChart.js';
|
|
2
|
+
|
|
3
|
+
declare const ez: {
|
|
4
|
+
registerComponent(name: string, component: unknown): void;
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
interface BarDataset {
|
|
8
|
+
data?: number[];
|
|
9
|
+
label?: string;
|
|
10
|
+
borderRadius?: number;
|
|
11
|
+
borderSkipped?: boolean | string;
|
|
12
|
+
backgroundColor?: string | string[];
|
|
13
|
+
borderColor?: string;
|
|
14
|
+
[key: string]: unknown;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface EzBarChartConfig extends EzChartConfig {
|
|
18
|
+
labels?: string[];
|
|
19
|
+
datasets?: BarDataset[];
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export class EzBarChart extends EzChart {
|
|
23
|
+
constructor(config: EzBarChartConfig = {}) {
|
|
24
|
+
const barDefaults: EzChartConfig = {
|
|
25
|
+
type: 'bar',
|
|
26
|
+
showLegend: (config.datasets?.length || 0) > 1,
|
|
27
|
+
...config
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
if (barDefaults.labels && barDefaults.datasets) {
|
|
31
|
+
barDefaults.data = {
|
|
32
|
+
labels: barDefaults.labels,
|
|
33
|
+
datasets: barDefaults.datasets.map((ds) => ({
|
|
34
|
+
borderRadius: 6,
|
|
35
|
+
borderSkipped: false,
|
|
36
|
+
...ds
|
|
37
|
+
}))
|
|
38
|
+
};
|
|
39
|
+
delete barDefaults.labels;
|
|
40
|
+
delete barDefaults.datasets;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
super(barDefaults);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
ez.registerComponent('EzBarChart', EzBarChart);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// ==========================================================
|
|
2
|
+
// EzChart - Chart Container Styles
|
|
3
|
+
// ==========================================================
|
|
4
|
+
|
|
5
|
+
.container {
|
|
6
|
+
position: relative;
|
|
7
|
+
width: 100%;
|
|
8
|
+
height: 280px;
|
|
9
|
+
|
|
10
|
+
canvas {
|
|
11
|
+
width: 100% !important;
|
|
12
|
+
height: 100% !important;
|
|
13
|
+
}
|
|
14
|
+
}
|