ezfw-core 1.0.12 → 1.0.14

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/README.md ADDED
@@ -0,0 +1,196 @@
1
+ <p align="center">
2
+ <img src="https://unpkg.com/ezfw-core/assets/ezfw-logo.png" alt="Ez Framework" width="280">
3
+ </p>
4
+
5
+ <p align="center">
6
+ A declarative component framework for building modern web applications with minimal boilerplate.
7
+ </p>
8
+
9
+ <p align="center">
10
+ <a href="https://www.npmjs.com/package/ezfw-core"><img src="https://img.shields.io/npm/v/ezfw-core.svg" alt="npm version"></a>
11
+ <a href="https://www.npmjs.com/package/ezfw-core"><img src="https://img.shields.io/npm/dm/ezfw-core.svg" alt="npm downloads"></a>
12
+ <a href="https://github.com/user/ez/blob/main/LICENSE"><img src="https://img.shields.io/npm/l/ezfw-core.svg" alt="license"></a>
13
+ </p>
14
+
15
+ ## Quick Start
16
+
17
+ ```bash
18
+ # Install CLI globally
19
+ npm i -g ezfw
20
+
21
+ # Create a new project
22
+ ezfw new my-app
23
+
24
+ # Start development server
25
+ cd my-app
26
+ npm run dev
27
+ ```
28
+
29
+ ## Why Ez?
30
+
31
+ - **Declarative** - Define UI as plain JavaScript objects, no JSX or templates
32
+ - **Reactive** - Built-in state management with signals
33
+ - **Zero Config** - Works out of the box with Vite
34
+ - **CSS Modules** - Scoped styles by default
35
+ - **Type Safe** - Written in TypeScript
36
+
37
+ ## Example
38
+
39
+ ```javascript
40
+ // Define a view
41
+ ez.define('Counter', {
42
+ controller: 'Counter',
43
+ items: [
44
+ { eztype: 'h1', bind: { text: 'count' } },
45
+ {
46
+ eztype: 'EzButton',
47
+ text: 'Increment',
48
+ onClick: 'increment'
49
+ }
50
+ ]
51
+ });
52
+
53
+ // Define controller with reactive state
54
+ ez.defineController('CounterController', {
55
+ state: { count: 0 },
56
+ increment() {
57
+ this.state.count++;
58
+ }
59
+ });
60
+
61
+ // Register route
62
+ ez.route('/', 'Counter');
63
+ ```
64
+
65
+ ## Components
66
+
67
+ | Component | Description |
68
+ |-----------|-------------|
69
+ | `EzButton` | Buttons with variants (primary, secondary, danger, etc.) |
70
+ | `EzInput` | Text input with validation support |
71
+ | `EzSelect` | Dropdown select with search |
72
+ | `EzCheckbox` | Checkbox with label |
73
+ | `EzRadio` | Radio button groups |
74
+ | `EzSwitch` | Toggle switch |
75
+ | `EzTextarea` | Multi-line text input |
76
+ | `EzDatePicker` | Date picker with calendar |
77
+ | `EzTimePicker` | Time picker |
78
+ | `EzGrid` | Data grid with sorting, filtering, pagination |
79
+ | `EzDataView` | Grid/Cards view switcher |
80
+ | `EzForm` | Form with validation |
81
+ | `EzTabPanel` | Tabbed interface |
82
+ | `EzCard` | Content card |
83
+ | `EzPanel` | Collapsible panel |
84
+ | `EzDialog` | Modal dialogs |
85
+ | `EzTooltip` | Tooltips |
86
+ | `EzDropdown` | Dropdown menus |
87
+ | `EzAvatar` | User avatars |
88
+ | `EzBadge` | Status badges |
89
+ | `EzSkeleton` | Loading skeletons |
90
+ | `EzChart` | Charts (Line, Bar, Doughnut) |
91
+
92
+ ## Features
93
+
94
+ ### Routing
95
+
96
+ ```javascript
97
+ ez.route('/users', 'UserList');
98
+ ez.route('/users/:id', 'UserDetail');
99
+ ```
100
+
101
+ ### Data Binding
102
+
103
+ ```javascript
104
+ {
105
+ eztype: 'span',
106
+ bind: {
107
+ text: 'user.name',
108
+ cls: () => ctrl.state.active ? 'active' : ''
109
+ }
110
+ }
111
+ ```
112
+
113
+ ### Forms & Validation
114
+
115
+ ```javascript
116
+ {
117
+ eztype: 'EzForm',
118
+ ref: 'myForm',
119
+ items: [
120
+ {
121
+ eztype: 'EzInput',
122
+ name: 'email',
123
+ validators: ['required', 'email']
124
+ }
125
+ ]
126
+ }
127
+
128
+ // In controller
129
+ const form = ez._refs.myForm;
130
+ if (form.validate()) {
131
+ const data = form.getFormData();
132
+ }
133
+ ```
134
+
135
+ ### Grid with Remote Data
136
+
137
+ ```javascript
138
+ {
139
+ eztype: 'EzGrid',
140
+ remote: {
141
+ api: 'v1/users',
142
+ autoLoad: true
143
+ },
144
+ columns: [
145
+ { text: 'Name', index: 'name', flex: 1 },
146
+ { text: 'Email', index: 'email', flex: 2 }
147
+ ]
148
+ }
149
+ ```
150
+
151
+ ### Dialogs
152
+
153
+ ```javascript
154
+ // Alert
155
+ await ez.dialog.alert('Operation completed');
156
+
157
+ // Confirm
158
+ const confirmed = await ez.dialog.confirm('Are you sure?');
159
+
160
+ // Custom dialog
161
+ const result = await ez.dialog.open({
162
+ title: 'Edit User',
163
+ items: [
164
+ { eztype: 'EzForm', /* ... */ }
165
+ ],
166
+ buttons: [
167
+ { text: 'Cancel', variant: 'secondary', value: false },
168
+ { text: 'Save', variant: 'primary', value: true }
169
+ ]
170
+ });
171
+ ```
172
+
173
+ ## Project Structure
174
+
175
+ ```
176
+ my-app/
177
+ ├── index.html
178
+ ├── index.js # App entry point
179
+ ├── vite.config.js
180
+ └── app/
181
+ ├── routes.js # Route definitions
182
+ └── views/
183
+ └── Home/
184
+ ├── Home.js
185
+ ├── Home.module.scss
186
+ └── HomeController.js
187
+ ```
188
+
189
+ ## Requirements
190
+
191
+ - Node.js >= 18
192
+ - Vite >= 5
193
+
194
+ ## License
195
+
196
+ MIT
Binary file
Binary file
@@ -132,11 +132,16 @@ export class EzDialog extends EzBaseComponent {
132
132
  dialog.appendChild(body);
133
133
 
134
134
  // Footer with buttons
135
- if (buttons && buttons.length > 0) {
135
+ let buttonList = buttons;
136
+ if (typeof buttons === 'function') {
137
+ buttonList = buttons(_dialogInstance);
138
+ }
139
+
140
+ if (Array.isArray(buttonList) && buttonList.length > 0) {
136
141
  const footer = document.createElement('div');
137
142
  footer.className = css('footer');
138
143
 
139
- for (const btn of buttons) {
144
+ for (const btn of buttonList) {
140
145
  const buttonConfig = {
141
146
  eztype: 'EzButton',
142
147
  text: btn.text,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ezfw-core",
3
- "version": "1.0.12",
3
+ "version": "1.0.14",
4
4
  "description": "Ez Framework - A declarative component framework for building modern web applications",
5
5
  "type": "module",
6
6
  "main": "./core/ez.ts",
@@ -17,6 +17,7 @@
17
17
  "./*": "./*"
18
18
  },
19
19
  "files": [
20
+ "assets",
20
21
  "core",
21
22
  "components",
22
23
  "services",
@@ -33,6 +33,9 @@ export class EzDialogService {
33
33
 
34
34
  setTimeout(() => {
35
35
  dialogInstance._el?.remove();
36
+ if (config.onDestroy) {
37
+ config.onDestroy();
38
+ }
36
39
  }, 200);
37
40
  }
38
41