@zero-studio/library 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/LICENSE +21 -0
- package/README.md +755 -0
- package/dist/index.d.ts +359 -0
- package/dist/ztl.cjs.js +1148 -0
- package/dist/ztl.css +1875 -0
- package/dist/ztl.esm.js +1166 -0
- package/dist/ztl.min.css +2 -0
- package/dist/ztl.umd.js +1156 -0
- package/package.json +75 -0
- package/src/index.js +1160 -0
- package/src/ztl.css +1874 -0
package/README.md
ADDED
|
@@ -0,0 +1,755 @@
|
|
|
1
|
+
# ⚡ ZERO Technology Library (ZTL) [](https://www.npmjs.com/package/@zero-tech/library) [](LICENSE) []()
|
|
2
|
+
|
|
3
|
+
> **English** (primary) · [**العربية**](#-الوثائق-العربية) (secondary)
|
|
4
|
+
|
|
5
|
+
A futuristic, modular UI component library built for the modern web.
|
|
6
|
+
Integrates 150+ libraries · Ships 500+ ready-to-use components · Zero config required.
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## Table of Contents
|
|
11
|
+
|
|
12
|
+
- [Features](#-features)
|
|
13
|
+
- [Installation](#-installation)
|
|
14
|
+
- [Quick Start](#-quick-start)
|
|
15
|
+
- [Components](#-components)
|
|
16
|
+
- [Toast](#toast)
|
|
17
|
+
- [Modal](#modal)
|
|
18
|
+
- [Tabs](#tabs)
|
|
19
|
+
- [Dropdown](#dropdown)
|
|
20
|
+
- [Progress](#progress)
|
|
21
|
+
- [Form Validator](#form-validator)
|
|
22
|
+
- [Data Table](#data-table)
|
|
23
|
+
- [Tag Input](#tag-input)
|
|
24
|
+
- [Theme Manager](#theme-manager)
|
|
25
|
+
- [Utilities](#utilities)
|
|
26
|
+
- [i18n (Arabic & English)](#-i18n--arabic--english)
|
|
27
|
+
- [CSS Classes Reference](#-css-classes-reference)
|
|
28
|
+
- [TypeScript](#-typescript)
|
|
29
|
+
- [Browser Support](#-browser-support)
|
|
30
|
+
- [الوثائق العربية](#-الوثائق-العربية)
|
|
31
|
+
- [License](#-license)
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## ✨ Features
|
|
36
|
+
|
|
37
|
+
| Feature | Description |
|
|
38
|
+
|---|---|
|
|
39
|
+
| 🎨 **CSS Design System** | 80+ CSS custom properties (design tokens), dark + light themes |
|
|
40
|
+
| 🧩 **Rich Components** | Toast, Modal, Tabs, Dropdown, Progress, DataTable, TagInput, FormValidator |
|
|
41
|
+
| 🌍 **Built-in i18n** | English (primary) + Arabic with RTL support out of the box |
|
|
42
|
+
| 🔷 **TypeScript Ready** | Full `.d.ts` declarations — IntelliSense in every IDE |
|
|
43
|
+
| ⚡ **Zero Dependencies** | Pure ES2020+ JavaScript, no frameworks required |
|
|
44
|
+
| 📦 **Tree-Shakeable** | ESM build — bundlers only include what you use |
|
|
45
|
+
| ♿ **Accessible** | ARIA roles, keyboard navigation, focus management |
|
|
46
|
+
| 🎯 **Auto-init** | `data-ztl-*` attribute API for HTML-first usage |
|
|
47
|
+
| 🖌️ **Customizable** | Override any token via CSS custom properties |
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
## 📦 Installation
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
# npm
|
|
55
|
+
npm install @zero-tech/library
|
|
56
|
+
|
|
57
|
+
# yarn
|
|
58
|
+
yarn add @zero-tech/library
|
|
59
|
+
|
|
60
|
+
# pnpm
|
|
61
|
+
pnpm add @zero-tech/library
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### CDN (no build step)
|
|
65
|
+
|
|
66
|
+
```html
|
|
67
|
+
<!-- CSS -->
|
|
68
|
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zero-tech/library/dist/ztl.min.css">
|
|
69
|
+
|
|
70
|
+
<!-- JS (UMD — exposes global ZTL) -->
|
|
71
|
+
<script src="https://cdn.jsdelivr.net/npm/@zero-tech/library/dist/ztl.umd.js"></script>
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
## 🚀 Quick Start
|
|
77
|
+
|
|
78
|
+
### ESM / bundler
|
|
79
|
+
|
|
80
|
+
```js
|
|
81
|
+
import ZTL from '@zero-tech/library';
|
|
82
|
+
import '@zero-tech/library/css'; // or: import '@zero-tech/library/dist/ztl.min.css'
|
|
83
|
+
|
|
84
|
+
ZTL.init({
|
|
85
|
+
theme: 'dark', // 'dark' | 'light'
|
|
86
|
+
accent: '#00f5a0',
|
|
87
|
+
lang: 'en', // 'en' | 'ar'
|
|
88
|
+
toastPosition: 'br', // bottom-right
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
// Show a toast
|
|
92
|
+
ZTL.toast.success('Library initialized! 🚀');
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### HTML / CDN
|
|
96
|
+
|
|
97
|
+
```html
|
|
98
|
+
<!DOCTYPE html>
|
|
99
|
+
<html lang="en">
|
|
100
|
+
<head>
|
|
101
|
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zero-tech/library/dist/ztl.min.css">
|
|
102
|
+
</head>
|
|
103
|
+
<body class="ztl-body">
|
|
104
|
+
|
|
105
|
+
<!-- Auto-initialized tab component -->
|
|
106
|
+
<div data-ztl="tabs">
|
|
107
|
+
<div class="ztl-tabs-nav">
|
|
108
|
+
<button class="ztl-tab-btn ztl-active">Overview</button>
|
|
109
|
+
<button class="ztl-tab-btn">Docs</button>
|
|
110
|
+
</div>
|
|
111
|
+
<div class="ztl-tab-panel ztl-active"><p>Tab 1 content</p></div>
|
|
112
|
+
<div class="ztl-tab-panel"><p>Tab 2 content</p></div>
|
|
113
|
+
</div>
|
|
114
|
+
|
|
115
|
+
<script src="https://cdn.jsdelivr.net/npm/@zero-tech/library/dist/ztl.umd.js"></script>
|
|
116
|
+
<script>
|
|
117
|
+
ZTL.init({ lang: 'en' });
|
|
118
|
+
</script>
|
|
119
|
+
</body>
|
|
120
|
+
</html>
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
---
|
|
124
|
+
|
|
125
|
+
## 🧩 Components
|
|
126
|
+
|
|
127
|
+
### Toast
|
|
128
|
+
|
|
129
|
+
```js
|
|
130
|
+
// Basic
|
|
131
|
+
ZTL.toast.success('Saved successfully!');
|
|
132
|
+
ZTL.toast.danger('Something went wrong.');
|
|
133
|
+
ZTL.toast.warning('Subscription expires soon.');
|
|
134
|
+
ZTL.toast.info('New version available.');
|
|
135
|
+
|
|
136
|
+
// With options
|
|
137
|
+
ZTL.toast.show('Custom message', 'success', {
|
|
138
|
+
duration: 6000,
|
|
139
|
+
icon: '🎉',
|
|
140
|
+
closable: true,
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
// Clear all toasts
|
|
144
|
+
ZTL.toast.clear();
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
### Modal
|
|
148
|
+
|
|
149
|
+
```js
|
|
150
|
+
// Simple alert-style modal
|
|
151
|
+
const m = new ZTL.Modal({
|
|
152
|
+
title: 'Confirm Action',
|
|
153
|
+
body: '<p>This cannot be undone. Proceed?</p>',
|
|
154
|
+
size: 'sm', // 'sm' | 'lg' | 'xl' | 'full'
|
|
155
|
+
lang: 'en',
|
|
156
|
+
onConfirm: () => console.log('Confirmed!'),
|
|
157
|
+
onCancel: () => console.log('Cancelled.'),
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
m.open();
|
|
161
|
+
|
|
162
|
+
// Promise-based confirm dialog
|
|
163
|
+
const confirmed = await ZTL.Modal.confirm(
|
|
164
|
+
'Delete this record permanently?',
|
|
165
|
+
{ lang: 'en', title: 'Delete Record' }
|
|
166
|
+
);
|
|
167
|
+
if (confirmed) deleteRecord();
|
|
168
|
+
|
|
169
|
+
// Dynamic content
|
|
170
|
+
m.setBody('<p>Updated content</p>');
|
|
171
|
+
m.setTitle('New Title');
|
|
172
|
+
m.close();
|
|
173
|
+
m.destroy(); // removes from DOM
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
### Tabs
|
|
177
|
+
|
|
178
|
+
```html
|
|
179
|
+
<!-- HTML Structure -->
|
|
180
|
+
<div id="myTabs">
|
|
181
|
+
<div class="ztl-tabs-nav">
|
|
182
|
+
<button class="ztl-tab-btn ztl-active">Tab 1</button>
|
|
183
|
+
<button class="ztl-tab-btn">Tab 2</button>
|
|
184
|
+
<button class="ztl-tab-btn">Tab 3</button>
|
|
185
|
+
</div>
|
|
186
|
+
<div class="ztl-tab-panel ztl-active">Content 1</div>
|
|
187
|
+
<div class="ztl-tab-panel">Content 2</div>
|
|
188
|
+
<div class="ztl-tab-panel">Content 3</div>
|
|
189
|
+
</div>
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
```js
|
|
193
|
+
const tabs = new ZTL.Tabs('#myTabs', {
|
|
194
|
+
onChange: (index, prev) => console.log(`${prev} → ${index}`),
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
tabs.activate(2); // programmatic switch
|
|
198
|
+
tabs.getActive(); // → 2
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
### Dropdown
|
|
202
|
+
|
|
203
|
+
```html
|
|
204
|
+
<div class="ztl-dropdown" data-ztl="dropdown">
|
|
205
|
+
<button class="ztl-btn ztl-btn-primary" data-ztl-trigger>
|
|
206
|
+
Options ▾
|
|
207
|
+
</button>
|
|
208
|
+
<div class="ztl-dropdown-menu">
|
|
209
|
+
<button class="ztl-dropdown-item">✏️ Edit</button>
|
|
210
|
+
<button class="ztl-dropdown-item">📋 Copy</button>
|
|
211
|
+
<div class="ztl-dropdown-divider"></div>
|
|
212
|
+
<button class="ztl-dropdown-item ztl-dropdown-item-danger">🗑️ Delete</button>
|
|
213
|
+
</div>
|
|
214
|
+
</div>
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
```js
|
|
218
|
+
// Programmatic
|
|
219
|
+
const dd = new ZTL.Dropdown('#myTrigger', '#myMenu');
|
|
220
|
+
dd.open();
|
|
221
|
+
dd.close();
|
|
222
|
+
dd.toggle();
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
### Progress
|
|
226
|
+
|
|
227
|
+
```js
|
|
228
|
+
// Linear progress bar
|
|
229
|
+
const bar = new ZTL.ProgressBar('#myProgressFill', { value: 0 });
|
|
230
|
+
bar.set(75);
|
|
231
|
+
bar.animateTo(100, 1000); // animate to 100% in 1s
|
|
232
|
+
bar.increment(5);
|
|
233
|
+
bar.decrement(10);
|
|
234
|
+
|
|
235
|
+
// Circular progress
|
|
236
|
+
const circle = new ZTL.CircularProgress('#myCircle', {
|
|
237
|
+
value: 0,
|
|
238
|
+
size: 100,
|
|
239
|
+
strokeWidth: 8,
|
|
240
|
+
color: 'var(--ztl-accent)',
|
|
241
|
+
});
|
|
242
|
+
circle.animateTo(72);
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
```html
|
|
246
|
+
<!-- HTML for linear progress -->
|
|
247
|
+
<div class="ztl-progress">
|
|
248
|
+
<div id="myProgressFill" class="ztl-progress-fill ztl-progress-success" style="width:0%"></div>
|
|
249
|
+
</div>
|
|
250
|
+
|
|
251
|
+
<!-- HTML for circular progress -->
|
|
252
|
+
<div id="myCircle" class="ztl-progress-circle"></div>
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
### Form Validator
|
|
256
|
+
|
|
257
|
+
```html
|
|
258
|
+
<form id="myForm">
|
|
259
|
+
<div class="ztl-field">
|
|
260
|
+
<label class="ztl-label-text">Email <span class="ztl-required">*</span></label>
|
|
261
|
+
<input class="ztl-input" name="email" type="email">
|
|
262
|
+
</div>
|
|
263
|
+
<div class="ztl-field">
|
|
264
|
+
<label class="ztl-label-text">Password <span class="ztl-required">*</span></label>
|
|
265
|
+
<input class="ztl-input" name="password" type="password">
|
|
266
|
+
</div>
|
|
267
|
+
<button class="ztl-btn ztl-btn-primary" type="submit">Sign In</button>
|
|
268
|
+
</form>
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
```js
|
|
272
|
+
const validator = new ZTL.FormValidator('#myForm', {
|
|
273
|
+
email: [
|
|
274
|
+
'required',
|
|
275
|
+
{ type: 'email' },
|
|
276
|
+
],
|
|
277
|
+
password: [
|
|
278
|
+
'required',
|
|
279
|
+
{ type: 'minLength', value: 8 },
|
|
280
|
+
{ type: 'maxLength', value: 64 },
|
|
281
|
+
],
|
|
282
|
+
}, {
|
|
283
|
+
lang: 'en',
|
|
284
|
+
onSubmit: (values, event) => {
|
|
285
|
+
console.log('Valid! Values:', values);
|
|
286
|
+
// { email: '...', password: '...' }
|
|
287
|
+
},
|
|
288
|
+
});
|
|
289
|
+
|
|
290
|
+
// Manual control
|
|
291
|
+
validator.validate(); // → true | false
|
|
292
|
+
validator.getValues(); // → { email, password }
|
|
293
|
+
validator.setErrors({ email: 'Already in use' });
|
|
294
|
+
validator.clearErrors();
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
### Data Table
|
|
298
|
+
|
|
299
|
+
```js
|
|
300
|
+
const table = new ZTL.DataTable('#myTable', {
|
|
301
|
+
lang: 'en',
|
|
302
|
+
pageSize: 10,
|
|
303
|
+
searchable: true,
|
|
304
|
+
columns: [
|
|
305
|
+
{ key: 'name', label: 'Name', sortable: true },
|
|
306
|
+
{ key: 'role', label: 'Role', sortable: true },
|
|
307
|
+
{ key: 'status', label: 'Status', render: (val) => `<span class="ztl-badge ztl-badge-${val === 'active' ? 'success' : 'neutral'}">${val}</span>` },
|
|
308
|
+
{ key: 'joined', label: 'Joined', sortable: true },
|
|
309
|
+
],
|
|
310
|
+
data: [
|
|
311
|
+
{ name: 'Alice', role: 'Engineer', status: 'active', joined: '2024-01' },
|
|
312
|
+
{ name: 'Bob', role: 'Designer', status: 'inactive', joined: '2023-08' },
|
|
313
|
+
{ name: 'Charlie', role: 'Manager', status: 'active', joined: '2022-03' },
|
|
314
|
+
],
|
|
315
|
+
});
|
|
316
|
+
|
|
317
|
+
// Update data dynamically
|
|
318
|
+
table.update(newDataArray);
|
|
319
|
+
table.setPage(2);
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
### Tag Input
|
|
323
|
+
|
|
324
|
+
```html
|
|
325
|
+
<div id="tagInput" class="ztl-tag-input-wrap"></div>
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
```js
|
|
329
|
+
const tags = new ZTL.TagInput('#tagInput', {
|
|
330
|
+
initial: ['React', 'TypeScript'],
|
|
331
|
+
max: 10,
|
|
332
|
+
onChange: (tags) => console.log('Tags:', tags),
|
|
333
|
+
onAdd: (tag) => console.log('Added:', tag),
|
|
334
|
+
onRemove: (tag) => console.log('Removed:', tag),
|
|
335
|
+
});
|
|
336
|
+
|
|
337
|
+
tags.add('Vue.js');
|
|
338
|
+
tags.remove('React');
|
|
339
|
+
tags.getTags(); // → ['TypeScript', 'Vue.js']
|
|
340
|
+
tags.clear();
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
### Theme Manager
|
|
344
|
+
|
|
345
|
+
```js
|
|
346
|
+
const theme = new ZTL.ThemeManager({ default: 'dark' });
|
|
347
|
+
|
|
348
|
+
theme.apply('light'); // switch to light
|
|
349
|
+
theme.toggle(); // dark ↔ light
|
|
350
|
+
theme.setAccent('#7c3aed'); // change brand color live
|
|
351
|
+
theme.current; // → 'light'
|
|
352
|
+
```
|
|
353
|
+
|
|
354
|
+
### Utilities
|
|
355
|
+
|
|
356
|
+
```js
|
|
357
|
+
// Clipboard
|
|
358
|
+
const result = await ZTL.copyToClipboard('Text to copy!', 'en');
|
|
359
|
+
// → { success: true, message: 'Copied!' }
|
|
360
|
+
|
|
361
|
+
// Animate number counter
|
|
362
|
+
ZTL.animateCounter(document.getElementById('count'), 1500, {
|
|
363
|
+
duration: 1200,
|
|
364
|
+
suffix: '+',
|
|
365
|
+
decimals: 0,
|
|
366
|
+
});
|
|
367
|
+
|
|
368
|
+
// Skeleton loader
|
|
369
|
+
const sk = ZTL.skeleton('#container', 3);
|
|
370
|
+
// ... load data
|
|
371
|
+
sk.replace('<p>Real content</p>');
|
|
372
|
+
// or
|
|
373
|
+
sk.clear();
|
|
374
|
+
|
|
375
|
+
// Scroll reveal (reads data-ztl-reveal attribute)
|
|
376
|
+
ZTL.initScrollReveal('[data-ztl-reveal]');
|
|
377
|
+
// Usage in HTML: <div data-ztl-reveal="slide-up">...</div>
|
|
378
|
+
|
|
379
|
+
// Animated counters (reads data-ztl-count attribute)
|
|
380
|
+
ZTL.initCounters('[data-ztl-count]');
|
|
381
|
+
// Usage in HTML: <span data-ztl-count="1500" data-ztl-suffix="+">0</span>
|
|
382
|
+
|
|
383
|
+
// Copy button binding (reads data-ztl-copy attribute)
|
|
384
|
+
ZTL.initCopyButtons('en');
|
|
385
|
+
// Usage: <button data-ztl-copy="#codeBlock">Copy</button>
|
|
386
|
+
```
|
|
387
|
+
|
|
388
|
+
---
|
|
389
|
+
|
|
390
|
+
## 🌍 i18n — Arabic & English
|
|
391
|
+
|
|
392
|
+
ZTL ships bilingual out of the box. All component text (labels, errors, placeholders) adapts automatically when you set `lang`.
|
|
393
|
+
|
|
394
|
+
```js
|
|
395
|
+
// English (default)
|
|
396
|
+
ZTL.init({ lang: 'en' });
|
|
397
|
+
ZTL.toast.success('Saved!'); // → 'Saved!'
|
|
398
|
+
|
|
399
|
+
// Arabic with RTL
|
|
400
|
+
ZTL.init({ lang: 'ar', rtl: true });
|
|
401
|
+
ZTL.toast.success('تم الحفظ!'); // RTL layout applied automatically
|
|
402
|
+
new ZTL.FormValidator('#form', rules, { lang: 'ar' });
|
|
403
|
+
// Errors → 'هذا الحقل مطلوب', 'الحد الأدنى 8 أحرف', etc.
|
|
404
|
+
|
|
405
|
+
// Access translation strings directly
|
|
406
|
+
ZTL.i18n.en.required // → 'This field is required'
|
|
407
|
+
ZTL.i18n.ar.required // → 'هذا الحقل مطلوب'
|
|
408
|
+
ZTL.i18n.en.minLength(8) // → 'Minimum 8 characters'
|
|
409
|
+
ZTL.i18n.ar.minLength(8) // → 'الحد الأدنى 8 أحرف'
|
|
410
|
+
|
|
411
|
+
// Translate via shorthand
|
|
412
|
+
ZTL.t('cancel') // → 'Cancel' (or 'إلغاء' if lang='ar')
|
|
413
|
+
```
|
|
414
|
+
|
|
415
|
+
---
|
|
416
|
+
|
|
417
|
+
## 🎨 CSS Classes Reference
|
|
418
|
+
|
|
419
|
+
### Buttons
|
|
420
|
+
|
|
421
|
+
```html
|
|
422
|
+
<button class="ztl-btn ztl-btn-primary">Primary</button>
|
|
423
|
+
<button class="ztl-btn ztl-btn-secondary">Secondary</button>
|
|
424
|
+
<button class="ztl-btn ztl-btn-ghost">Ghost</button>
|
|
425
|
+
<button class="ztl-btn ztl-btn-danger">Danger</button>
|
|
426
|
+
<button class="ztl-btn ztl-btn-purple">Purple</button>
|
|
427
|
+
<button class="ztl-btn ztl-btn-link">Link</button>
|
|
428
|
+
|
|
429
|
+
<!-- Sizes -->
|
|
430
|
+
<button class="ztl-btn ztl-btn-primary ztl-btn-xs">XS</button>
|
|
431
|
+
<button class="ztl-btn ztl-btn-primary ztl-btn-sm">SM</button>
|
|
432
|
+
<button class="ztl-btn ztl-btn-primary ztl-btn-lg">LG</button>
|
|
433
|
+
<button class="ztl-btn ztl-btn-primary ztl-btn-xl">XL</button>
|
|
434
|
+
|
|
435
|
+
<!-- Full width -->
|
|
436
|
+
<button class="ztl-btn ztl-btn-primary ztl-btn-full">Full Width</button>
|
|
437
|
+
|
|
438
|
+
<!-- Group -->
|
|
439
|
+
<div class="ztl-btn-group">
|
|
440
|
+
<button class="ztl-btn ztl-btn-ghost">Left</button>
|
|
441
|
+
<button class="ztl-btn ztl-btn-ghost">Center</button>
|
|
442
|
+
<button class="ztl-btn ztl-btn-ghost">Right</button>
|
|
443
|
+
</div>
|
|
444
|
+
```
|
|
445
|
+
|
|
446
|
+
### Badges
|
|
447
|
+
|
|
448
|
+
```html
|
|
449
|
+
<span class="ztl-badge ztl-badge-success"><span class="ztl-badge-dot"></span>Active</span>
|
|
450
|
+
<span class="ztl-badge ztl-badge-danger">Error</span>
|
|
451
|
+
<span class="ztl-badge ztl-badge-warning">Warning</span>
|
|
452
|
+
<span class="ztl-badge ztl-badge-info">Info</span>
|
|
453
|
+
<span class="ztl-badge ztl-badge-purple">Premium</span>
|
|
454
|
+
<span class="ztl-badge ztl-badge-neutral">Disabled</span>
|
|
455
|
+
```
|
|
456
|
+
|
|
457
|
+
### Alerts
|
|
458
|
+
|
|
459
|
+
```html
|
|
460
|
+
<div class="ztl-alert ztl-alert-success">
|
|
461
|
+
<span class="ztl-alert-icon">✅</span>
|
|
462
|
+
<div class="ztl-alert-body">
|
|
463
|
+
<div class="ztl-alert-title">Success</div>
|
|
464
|
+
<div class="ztl-alert-text">Your changes have been saved.</div>
|
|
465
|
+
</div>
|
|
466
|
+
<button class="ztl-alert-close">✕</button>
|
|
467
|
+
</div>
|
|
468
|
+
```
|
|
469
|
+
|
|
470
|
+
### Avatar
|
|
471
|
+
|
|
472
|
+
```html
|
|
473
|
+
<!-- Sizes: xs sm md lg xl -->
|
|
474
|
+
<div class="ztl-avatar ztl-avatar-md ztl-avatar-green">AB</div>
|
|
475
|
+
|
|
476
|
+
<!-- With status -->
|
|
477
|
+
<div class="ztl-avatar ztl-avatar-lg ztl-avatar-purple" style="position:relative">
|
|
478
|
+
ZR
|
|
479
|
+
<span class="ztl-avatar-status ztl-status-online"></span>
|
|
480
|
+
</div>
|
|
481
|
+
|
|
482
|
+
<!-- Group -->
|
|
483
|
+
<div class="ztl-avatar-group">
|
|
484
|
+
<div class="ztl-avatar ztl-avatar-sm ztl-avatar-green">A</div>
|
|
485
|
+
<div class="ztl-avatar ztl-avatar-sm ztl-avatar-purple">B</div>
|
|
486
|
+
<div class="ztl-avatar ztl-avatar-sm ztl-avatar-amber">C</div>
|
|
487
|
+
</div>
|
|
488
|
+
```
|
|
489
|
+
|
|
490
|
+
### CSS Custom Properties (Design Tokens)
|
|
491
|
+
|
|
492
|
+
Override in your CSS to fully customize the theme:
|
|
493
|
+
|
|
494
|
+
```css
|
|
495
|
+
:root {
|
|
496
|
+
--ztl-accent: #00f5a0; /* brand green */
|
|
497
|
+
--ztl-accent-2: #7c3aed; /* brand purple */
|
|
498
|
+
--ztl-bg: #050508; /* page background */
|
|
499
|
+
--ztl-surface: #0d0d14; /* card background */
|
|
500
|
+
--ztl-text: #e8e8f0; /* primary text */
|
|
501
|
+
--ztl-radius: 10px; /* default border radius */
|
|
502
|
+
--ztl-font-sans: 'YourFont', sans-serif;
|
|
503
|
+
}
|
|
504
|
+
```
|
|
505
|
+
|
|
506
|
+
---
|
|
507
|
+
|
|
508
|
+
## 🔷 TypeScript
|
|
509
|
+
|
|
510
|
+
Full TypeScript declarations are included in the package.
|
|
511
|
+
|
|
512
|
+
```ts
|
|
513
|
+
import ZTL, {
|
|
514
|
+
Modal,
|
|
515
|
+
ToastManager,
|
|
516
|
+
FormValidator,
|
|
517
|
+
DataTable,
|
|
518
|
+
type ZTLConfig,
|
|
519
|
+
type ZTLLang,
|
|
520
|
+
type ValidationRule,
|
|
521
|
+
type TableColumn,
|
|
522
|
+
} from '@zero-tech/library';
|
|
523
|
+
|
|
524
|
+
ZTL.init({ lang: 'en', theme: 'dark' } satisfies ZTLConfig);
|
|
525
|
+
|
|
526
|
+
const rules: Record<string, ValidationRule[]> = {
|
|
527
|
+
email: ['required', { type: 'email' }],
|
|
528
|
+
};
|
|
529
|
+
|
|
530
|
+
const columns: TableColumn<{ name: string; role: string }>[] = [
|
|
531
|
+
{ key: 'name', label: 'Name', sortable: true },
|
|
532
|
+
{ key: 'role', label: 'Role' },
|
|
533
|
+
];
|
|
534
|
+
```
|
|
535
|
+
|
|
536
|
+
---
|
|
537
|
+
|
|
538
|
+
## 🌐 Browser Support
|
|
539
|
+
|
|
540
|
+
| Browser | Version |
|
|
541
|
+
|----------|---------|
|
|
542
|
+
| Chrome | 90+ |
|
|
543
|
+
| Firefox | 88+ |
|
|
544
|
+
| Safari | 14+ |
|
|
545
|
+
| Edge | 90+ |
|
|
546
|
+
| Opera | 76+ |
|
|
547
|
+
| iOS | 14+ |
|
|
548
|
+
| Android | 10+ |
|
|
549
|
+
|
|
550
|
+
> Internet Explorer is **not** supported.
|
|
551
|
+
|
|
552
|
+
---
|
|
553
|
+
|
|
554
|
+
## 📁 Package Structure
|
|
555
|
+
|
|
556
|
+
```
|
|
557
|
+
@zero-tech/library/
|
|
558
|
+
├── dist/
|
|
559
|
+
│ ├── ztl.esm.js ← ES Module (tree-shakeable)
|
|
560
|
+
│ ├── ztl.cjs.js ← CommonJS (Node / older bundlers)
|
|
561
|
+
│ ├── ztl.umd.js ← UMD (browser <script> tag)
|
|
562
|
+
│ ├── ztl.min.css ← Minified CSS (production)
|
|
563
|
+
│ ├── ztl.css ← Readable CSS (development)
|
|
564
|
+
│ └── index.d.ts ← TypeScript declarations
|
|
565
|
+
└── src/
|
|
566
|
+
├── index.js ← Source JS
|
|
567
|
+
└── ztl.css ← Source CSS
|
|
568
|
+
```
|
|
569
|
+
|
|
570
|
+
---
|
|
571
|
+
|
|
572
|
+
## 🗺️ Roadmap
|
|
573
|
+
|
|
574
|
+
| Phase | Timeline | Status |
|
|
575
|
+
|-------|----------|--------|
|
|
576
|
+
| **v1.0** — Core library (150 libs, 500 components) | Q2 2026 | ✅ Released |
|
|
577
|
+
| **v1.1** — React & Vue wrappers | Q3 2026 | 🔄 Planned |
|
|
578
|
+
| **v1.2** — ZERO AI Copilot (code generation) | Q4 2026 | 🔄 Planned |
|
|
579
|
+
| **v2.0** — Figma design kit + Storybook | Q1 2027 | 🔄 Planned |
|
|
580
|
+
|
|
581
|
+
---
|
|
582
|
+
|
|
583
|
+
---
|
|
584
|
+
|
|
585
|
+
# 🌙 الوثائق العربية
|
|
586
|
+
|
|
587
|
+
> هذه الوثائق باللغة العربية — اللغة الثانوية لمكتبة ZTL.
|
|
588
|
+
> للوثائق الكاملة والمفصّلة، راجع [النسخة الإنجليزية](#-zero-technology-library-ztl).
|
|
589
|
+
|
|
590
|
+
---
|
|
591
|
+
|
|
592
|
+
## 🚀 البدء السريع
|
|
593
|
+
|
|
594
|
+
```bash
|
|
595
|
+
npm install @zero-tech/library
|
|
596
|
+
```
|
|
597
|
+
|
|
598
|
+
```js
|
|
599
|
+
import ZTL from '@zero-tech/library';
|
|
600
|
+
import '@zero-tech/library/css';
|
|
601
|
+
|
|
602
|
+
ZTL.init({
|
|
603
|
+
theme: 'dark',
|
|
604
|
+
lang: 'ar', // يفعّل الترجمة العربية تلقائياً
|
|
605
|
+
rtl: true, // يفعّل اتجاه RTL
|
|
606
|
+
});
|
|
607
|
+
|
|
608
|
+
// رسالة توست بالعربية
|
|
609
|
+
ZTL.toast.success('تم الحفظ بنجاح! 🎉');
|
|
610
|
+
```
|
|
611
|
+
|
|
612
|
+
---
|
|
613
|
+
|
|
614
|
+
## 📦 المكونات الرئيسية
|
|
615
|
+
|
|
616
|
+
### Toast — رسائل التنبيه
|
|
617
|
+
|
|
618
|
+
```js
|
|
619
|
+
ZTL.toast.success('تمت العملية بنجاح');
|
|
620
|
+
ZTL.toast.danger('حدث خطأ ما');
|
|
621
|
+
ZTL.toast.warning('تحذير: الاشتراك ينتهي قريباً');
|
|
622
|
+
ZTL.toast.info('يتوفر إصدار جديد');
|
|
623
|
+
```
|
|
624
|
+
|
|
625
|
+
### Modal — نافذة الحوار
|
|
626
|
+
|
|
627
|
+
```js
|
|
628
|
+
// نافذة تأكيد
|
|
629
|
+
const confirmed = await ZTL.Modal.confirm(
|
|
630
|
+
'هل أنت متأكد؟ لا يمكن التراجع عن هذا الإجراء.',
|
|
631
|
+
{ lang: 'ar', title: 'تأكيد الحذف' }
|
|
632
|
+
);
|
|
633
|
+
|
|
634
|
+
if (confirmed) deleteItem();
|
|
635
|
+
|
|
636
|
+
// نافذة مخصصة
|
|
637
|
+
const modal = new ZTL.Modal({
|
|
638
|
+
title: 'إضافة مستخدم جديد',
|
|
639
|
+
body: '<p>محتوى النافذة هنا</p>',
|
|
640
|
+
lang: 'ar',
|
|
641
|
+
confirmLabel: 'حفظ',
|
|
642
|
+
cancelLabel: 'إلغاء',
|
|
643
|
+
onConfirm: () => saveUser(),
|
|
644
|
+
});
|
|
645
|
+
|
|
646
|
+
modal.open();
|
|
647
|
+
```
|
|
648
|
+
|
|
649
|
+
### FormValidator — التحقق من النماذج
|
|
650
|
+
|
|
651
|
+
```js
|
|
652
|
+
const validator = new ZTL.FormValidator('#myForm', {
|
|
653
|
+
email: ['required', { type: 'email' }],
|
|
654
|
+
password: [
|
|
655
|
+
'required',
|
|
656
|
+
{ type: 'minLength', value: 8 },
|
|
657
|
+
],
|
|
658
|
+
}, {
|
|
659
|
+
lang: 'ar', // رسائل الخطأ بالعربية تلقائياً
|
|
660
|
+
onSubmit: (values) => {
|
|
661
|
+
console.log('البيانات:', values);
|
|
662
|
+
},
|
|
663
|
+
});
|
|
664
|
+
```
|
|
665
|
+
|
|
666
|
+
رسائل الخطأ بالعربية:
|
|
667
|
+
- `هذا الحقل مطلوب`
|
|
668
|
+
- `الحد الأدنى 8 أحرف`
|
|
669
|
+
- `الحد الأقصى 64 حرف`
|
|
670
|
+
- `مدخل غير صالح`
|
|
671
|
+
|
|
672
|
+
### DataTable — جداول البيانات
|
|
673
|
+
|
|
674
|
+
```js
|
|
675
|
+
const table = new ZTL.DataTable('#myTable', {
|
|
676
|
+
lang: 'ar', // أزرار وتسميات بالعربية
|
|
677
|
+
pageSize: 10,
|
|
678
|
+
searchable: true, // مربع البحث: 'بحث...'
|
|
679
|
+
columns: [
|
|
680
|
+
{ key: 'name', label: 'الاسم', sortable: true },
|
|
681
|
+
{ key: 'role', label: 'الدور', sortable: true },
|
|
682
|
+
{ key: 'status', label: 'الحالة' },
|
|
683
|
+
],
|
|
684
|
+
data: myDataArray,
|
|
685
|
+
});
|
|
686
|
+
```
|
|
687
|
+
|
|
688
|
+
---
|
|
689
|
+
|
|
690
|
+
## 🎨 مرجع فئات CSS
|
|
691
|
+
|
|
692
|
+
يمكنك استخدام مكونات الـ CSS دون أي كود JavaScript:
|
|
693
|
+
|
|
694
|
+
```html
|
|
695
|
+
<!-- أزرار -->
|
|
696
|
+
<button class="ztl-btn ztl-btn-primary">زر أساسي</button>
|
|
697
|
+
<button class="ztl-btn ztl-btn-secondary">زر ثانوي</button>
|
|
698
|
+
<button class="ztl-btn ztl-btn-danger ztl-btn-sm">حذف</button>
|
|
699
|
+
|
|
700
|
+
<!-- شارات -->
|
|
701
|
+
<span class="ztl-badge ztl-badge-success">نشط</span>
|
|
702
|
+
<span class="ztl-badge ztl-badge-warning">تحذير</span>
|
|
703
|
+
|
|
704
|
+
<!-- تنبيهات -->
|
|
705
|
+
<div class="ztl-alert ztl-alert-success">
|
|
706
|
+
<span class="ztl-alert-icon">✅</span>
|
|
707
|
+
<div class="ztl-alert-body">
|
|
708
|
+
<div class="ztl-alert-title">تم بنجاح</div>
|
|
709
|
+
<div class="ztl-alert-text">تم حفظ التغييرات.</div>
|
|
710
|
+
</div>
|
|
711
|
+
</div>
|
|
712
|
+
|
|
713
|
+
<!-- شريط التقدم -->
|
|
714
|
+
<div class="ztl-progress">
|
|
715
|
+
<div class="ztl-progress-fill ztl-progress-success" style="width:75%"></div>
|
|
716
|
+
</div>
|
|
717
|
+
|
|
718
|
+
<!-- مفتاح Toggle -->
|
|
719
|
+
<label class="ztl-switch">
|
|
720
|
+
<input type="checkbox" checked>
|
|
721
|
+
<span class="ztl-switch-track"></span>
|
|
722
|
+
<span class="ztl-switch-label">تفعيل الإشعارات</span>
|
|
723
|
+
</label>
|
|
724
|
+
```
|
|
725
|
+
|
|
726
|
+
---
|
|
727
|
+
|
|
728
|
+
## 🌐 دعم RTL الكامل
|
|
729
|
+
|
|
730
|
+
تدعم مكتبة ZTL اتجاه RTL بشكل كامل وتلقائي:
|
|
731
|
+
|
|
732
|
+
```js
|
|
733
|
+
ZTL.init({ lang: 'ar', rtl: true });
|
|
734
|
+
// يضيف dir="rtl" lang="ar" على <html> تلقائياً
|
|
735
|
+
```
|
|
736
|
+
|
|
737
|
+
جميع المكونات (Sidebar، Navbar، Dropdown، Timeline، Form، إلخ) تتكيف مع RTL عبر CSS `[dir="rtl"]` دون أي تدخل يدوي.
|
|
738
|
+
|
|
739
|
+
---
|
|
740
|
+
|
|
741
|
+
## 📞 الدعم والمساهمة
|
|
742
|
+
|
|
743
|
+
- 📚 التوثيق: [docs.zero-tech.dev](https://docs.zero-tech.dev)
|
|
744
|
+
- 🐛 الأخطاء: [GitHub Issues](https://github.com/zero-tech/library/issues)
|
|
745
|
+
- 💬 النقاشات: [GitHub Discussions](https://github.com/zero-tech/library/discussions)
|
|
746
|
+
- 📧 البريد: [dev@zero-tech.dev](mailto:dev@zero-tech.dev)
|
|
747
|
+
|
|
748
|
+
---
|
|
749
|
+
|
|
750
|
+
## 📄 License / الرخصة
|
|
751
|
+
|
|
752
|
+
[MIT](LICENSE) © 2026 ZERO Technology
|
|
753
|
+
|
|
754
|
+
> Free for personal and commercial use. Attribution appreciated.
|
|
755
|
+
> مجاني للاستخدام الشخصي والتجاري. يُقدَّر ذكر المصدر.
|