zidan-select 2.0.2 → 2.1.1
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 +274 -30
- package/dist/plugin-core.css +535 -1
- package/dist/plugin-theme.css +417 -5
- package/dist/zidan-form.js +1767 -103
- package/dist/zidan-form.mjs +14 -9
- package/docs/build.md +14 -3
- package/docs/demo-inputs.png +0 -0
- package/docs/demo.png +0 -0
- package/docs/frameworks.md +2 -1
- package/docs/index.html +15 -9
- package/docs/options.md +260 -4
- package/docs/theming.md +42 -0
- package/docs/validation.md +38 -1
- package/package.json +2 -2
- package/plugin-core.css +535 -1
- package/plugin-theme.css +417 -5
- package/zidan-form.js +1767 -103
- package/zidan-form.mjs +14 -9
package/README.md
CHANGED
|
@@ -6,7 +6,8 @@ switch, radio, file and text inputs **in place** — real form values, `FormData
|
|
|
6
6
|
two separate stylesheets.
|
|
7
7
|
|
|
8
8
|
[](https://akhtar1985.github.io/zidan-select/)
|
|
9
|
-
[](https://www.npmjs.com/package/zidan-select)
|
|
10
|
+
[](docs/options.md)
|
|
10
11
|
[](LICENSE)
|
|
11
12
|
|
|
12
13
|
- **One file of JS** — `zidan-form.js` (classic script, UMD-ish) + `zidan-form.mjs` (ESM wrapper).
|
|
@@ -19,6 +20,14 @@ two separate stylesheets.
|
|
|
19
20
|
- **5 select layouts** `classic-clean · floating-label · soft-pill · bordered-brutalist · glass-elevated`.
|
|
20
21
|
- **Field layouts** `stacked · inline · compact · floating · outlined · card`.
|
|
21
22
|
- **Framework adapters** standalone, Bootstrap 5, Tailwind CSS, Bulma, Foundation.
|
|
23
|
+
- **Input add-ons (2.1)** — opt-in icons for any input type, a − / + number stepper in three
|
|
24
|
+
modes, phone formatting (national / international / E.164, caret-safe), rich range skins
|
|
25
|
+
with ticks/bubble/formatters, weekend/date rules and a full upload pipeline.
|
|
26
|
+
- **More skins** — checkbox `default · switch · card · button · minimal`; five switch styles
|
|
27
|
+
(`ios · material · square · labeled · icon`); radio `stacked · inline · card · button · tile`
|
|
28
|
+
with click-to-deselect; file `dropzone · button · avatar · gallery · compact`.
|
|
29
|
+
- **Upload API** — `simulateUpload`, custom `upload()` handler, XHR `uploadUrl`, progress,
|
|
30
|
+
cancel, retry, `getUploadState()`, per-file `renderFile` hook.
|
|
22
31
|
- WAI-ARIA labels, focus management, keyboard support throughout, `prefers-reduced-motion`.
|
|
23
32
|
|
|
24
33
|
---
|
|
@@ -57,19 +66,44 @@ limitations and migration notes: **[`docs/comparison.md`](docs/comparison.md)**.
|
|
|
57
66
|
|
|
58
67
|
## Contents
|
|
59
68
|
|
|
60
|
-
1. [
|
|
61
|
-
2. [
|
|
62
|
-
3. [
|
|
63
|
-
4. [
|
|
64
|
-
5. [
|
|
65
|
-
6. [
|
|
66
|
-
7. [
|
|
67
|
-
8. [
|
|
68
|
-
9. [
|
|
69
|
-
10. [
|
|
70
|
-
11. [
|
|
71
|
-
12. [
|
|
72
|
-
13. [
|
|
69
|
+
1. [Live demo](#live-demo)
|
|
70
|
+
2. [Install](#install)
|
|
71
|
+
3. [Why ZidanForm](#why-zidanform)
|
|
72
|
+
4. [Quick start](#quick-start)
|
|
73
|
+
5. [Input types](#input-types)
|
|
74
|
+
6. [Options & data attributes](#options--data-attributes)
|
|
75
|
+
7. [JavaScript API](#javascript-api)
|
|
76
|
+
8. [Themes, layouts & frameworks](#themes-layouts--frameworks)
|
|
77
|
+
9. [Validation libraries](#validation-libraries)
|
|
78
|
+
10. [Form lifecycle & state sync](#form-lifecycle--state-sync)
|
|
79
|
+
11. [React, Next.js, Vue, Angular](#react-nextjs-vue-angular)
|
|
80
|
+
12. [Build & publish](#build--publish)
|
|
81
|
+
13. [Browser support](#browser-support)
|
|
82
|
+
14. [What's new in 2.1](#whats-new-in-21)
|
|
83
|
+
15. [Migrating from 1.x](#migrating-from-1x)
|
|
84
|
+
|
|
85
|
+
---
|
|
86
|
+
|
|
87
|
+
## Live demo
|
|
88
|
+
|
|
89
|
+
[](https://akhtar1985.github.io/zidan-select/)
|
|
90
|
+
|
|
91
|
+
**Demo:** <https://akhtar1985.github.io/zidan-select/> — deployed from `main` by
|
|
92
|
+
[`.github/workflows/pages.yml`](.github/workflows/pages.yml) on every push.
|
|
93
|
+
|
|
94
|
+
Deep links open the matching tab:
|
|
95
|
+
|
|
96
|
+
| Tab | Direct link |
|
|
97
|
+
| --- | --- |
|
|
98
|
+
| All inputs | <https://akhtar1985.github.io/zidan-select/#all> |
|
|
99
|
+
| Select / combobox / tags | <https://akhtar1985.github.io/zidan-select/#select> |
|
|
100
|
+
| Checkbox, switch & radio | <https://akhtar1985.github.io/zidan-select/#check> |
|
|
101
|
+
| File upload variants & progress | <https://akhtar1985.github.io/zidan-select/#file> |
|
|
102
|
+
| Icons, stepper, phone, range, date & time | <https://akhtar1985.github.io/zidan-select/#inputs> |
|
|
103
|
+
| Themes & layouts | <https://akhtar1985.github.io/zidan-select/#themes> |
|
|
104
|
+
|
|
105
|
+
The page also has a live **event console** (below the tabs) that shows every `zidan:*` event as
|
|
106
|
+
you interact, and the **Embed & share** tab for copying snippets.
|
|
73
107
|
|
|
74
108
|
---
|
|
75
109
|
|
|
@@ -115,6 +149,18 @@ override presets.
|
|
|
115
149
|
| `index.html`, `demo.css`, `demo.js` | The tabbed demo / theme showcase (not shipped logic). |
|
|
116
150
|
| `docs/` | Comparison, options, validation, frameworks, theming and build guides. |
|
|
117
151
|
|
|
152
|
+
Copyable URLs for the published files (pin the version in production):
|
|
153
|
+
|
|
154
|
+
- `zidan-form.js` — <https://cdn.jsdelivr.net/npm/zidan-select@2.1.1/zidan-form.js>
|
|
155
|
+
- `zidan-form.mjs` — <https://cdn.jsdelivr.net/npm/zidan-select@2.1.1/zidan-form.mjs>
|
|
156
|
+
- `plugin-core.css` — <https://cdn.jsdelivr.net/npm/zidan-select@2.1.1/plugin-core.css>
|
|
157
|
+
- `plugin-theme.css` — <https://cdn.jsdelivr.net/npm/zidan-select@2.1.1/plugin-theme.css>
|
|
158
|
+
- npm package — <https://www.npmjs.com/package/zidan-select>
|
|
159
|
+
- Source — <https://github.com/akhtar1985/zidan-select>
|
|
160
|
+
|
|
161
|
+
The demo page loads these same four files from the repository root, so it always exercises the
|
|
162
|
+
exact code that ships.
|
|
163
|
+
|
|
118
164
|
---
|
|
119
165
|
|
|
120
166
|
## Quick start
|
|
@@ -196,6 +242,38 @@ Windows/macOS keyboard behaviour, grouping, search and all select features live
|
|
|
196
242
|
The mixed state paints a bar and clears as soon as the user clicks, exactly like a native
|
|
197
243
|
checkbox.
|
|
198
244
|
|
|
245
|
+
### Checkbox, switch & radio — extra skins
|
|
246
|
+
|
|
247
|
+
```html
|
|
248
|
+
<!-- filter-style pill and dense minimal row -->
|
|
249
|
+
<label><input type="checkbox" data-zidan="checkbox" data-zidan-variant="button" data-zidan-label="Email"> Email</label>
|
|
250
|
+
<label><input type="checkbox" data-zidan="checkbox" data-zidan-variant="minimal" data-zidan-label="Compact row"> Compact row</label>
|
|
251
|
+
|
|
252
|
+
<!-- five switch skins -->
|
|
253
|
+
<label><input type="checkbox" data-zidan="checkbox" data-zidan-variant="switch"
|
|
254
|
+
data-zidan-switch-style="ios" data-zidan-label="iOS"> iOS</label>
|
|
255
|
+
<label><input type="checkbox" data-zidan="checkbox" data-zidan-variant="switch"
|
|
256
|
+
data-zidan-switch-style="labeled"
|
|
257
|
+
data-zidan-on-label="YES" data-zidan-off-label="NO"> Labeled</label>
|
|
258
|
+
|
|
259
|
+
<!-- pill radios and description tiles, click-to-clear -->
|
|
260
|
+
<fieldset data-zidan="radio-group" data-zidan-variant="button">
|
|
261
|
+
<legend>View</legend>
|
|
262
|
+
<label><input type="radio" name="view" value="day" checked> Day</label>
|
|
263
|
+
<label><input type="radio" name="view" value="week"> Week</label>
|
|
264
|
+
</fieldset>
|
|
265
|
+
<fieldset data-zidan="radio-group" data-zidan-variant="tile" data-zidan-deselectable="true">
|
|
266
|
+
<legend>Workspace</legend>
|
|
267
|
+
<label><input type="radio" name="workspace" value="design"
|
|
268
|
+
data-zidan-description="Boards, docs and feedback."> Design</label>
|
|
269
|
+
<label><input type="radio" name="workspace" value="build"
|
|
270
|
+
data-zidan-description="Repos, pipelines and previews."> Build</label>
|
|
271
|
+
</fieldset>
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
`data-zidan-description` adds a second line to card/tile/button/minimal labels.
|
|
275
|
+
`data-zidan-deselectable="true"` lets a click on the checked radio clear the group.
|
|
276
|
+
|
|
199
277
|
### Radio groups
|
|
200
278
|
|
|
201
279
|
```html
|
|
@@ -206,23 +284,47 @@ checkbox.
|
|
|
206
284
|
</fieldset>
|
|
207
285
|
```
|
|
208
286
|
|
|
209
|
-
Variants: `stacked`, `inline`, `card`. Radios share a native `name`, so arrow
|
|
210
|
-
and Space keep browser semantics; the wrapper adds `role="radiogroup"` when missing.
|
|
287
|
+
Variants: `stacked`, `inline`, `card`, `button`, `tile`. Radios share a native `name`, so arrow
|
|
288
|
+
keys, Home/End and Space keep browser semantics; the wrapper adds `role="radiogroup"` when missing.
|
|
211
289
|
|
|
212
|
-
### File upload
|
|
290
|
+
### File upload — variants, progress and the upload API
|
|
213
291
|
|
|
214
292
|
```html
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
data-zidan-max-files="3"
|
|
218
|
-
data-zidan-max-size="1048576"
|
|
293
|
+
<!-- drop target -->
|
|
294
|
+
<input type="file" name="docs" multiple accept="image/*,.pdf" data-zidan="file"
|
|
295
|
+
data-zidan-max-files="3" data-zidan-max-size="1048576"
|
|
219
296
|
data-zidan-title="Drop documents here">
|
|
297
|
+
|
|
298
|
+
<!-- other designs -->
|
|
299
|
+
<input type="file" data-zidan="file" data-zidan-file-variant="button" data-zidan-upload-icon="document">
|
|
300
|
+
<input type="file" accept="image/*" data-zidan="file" data-zidan-file-variant="avatar">
|
|
301
|
+
<input type="file" multiple accept="image/*" data-zidan="file" data-zidan-file-variant="gallery">
|
|
302
|
+
<input type="file" data-zidan="file" data-zidan-file-variant="compact"
|
|
303
|
+
data-zidan-show-file-meta="false">
|
|
304
|
+
|
|
305
|
+
<!-- simulated progress (no network) -->
|
|
306
|
+
<input type="file" multiple data-zidan="file" data-zidan-simulate-upload="true"
|
|
307
|
+
data-zidan-simulate-duration="1800">
|
|
220
308
|
```
|
|
221
309
|
|
|
310
|
+
- Variants: `dropzone`, `button`, `avatar`, `gallery`, `compact`.
|
|
222
311
|
- Native `input.files` is the source of truth; removing a file rebuilds it with `DataTransfer`.
|
|
223
|
-
- Drag & drop, click to pick, thumbnails for images, extension badges otherwise.
|
|
224
312
|
- `maxFiles`, `maxSize` (bytes) / `maxSizeMB`, `accept` are validated with a live status message.
|
|
225
|
-
-
|
|
313
|
+
- Real uploads: set `data-zidan-upload-url` (XHR multipart) or pass `upload(context)` in JS.
|
|
314
|
+
- Progress, cancel, retry, `getUploadState()`, `renderFile(item, info)` and `zidan:upload-*`
|
|
315
|
+
events are all available; files stay put during `simulateUpload`.
|
|
316
|
+
|
|
317
|
+
```js
|
|
318
|
+
zidanField('#files', {
|
|
319
|
+
upload(context) {
|
|
320
|
+
// context: { file, field, formData, signal, onProgress, complete, fail }
|
|
321
|
+
fetch('/upload', { method: 'POST', body: context.formData, signal: context.signal })
|
|
322
|
+
.then(res => res.ok ? res.json() : Promise.reject(res.status))
|
|
323
|
+
.then(context.complete)
|
|
324
|
+
.catch(context.fail);
|
|
325
|
+
}
|
|
326
|
+
});
|
|
327
|
+
```
|
|
226
328
|
|
|
227
329
|
### Text inputs & textarea
|
|
228
330
|
|
|
@@ -236,12 +338,91 @@ and Space keep browser semantics; the wrapper adds `role="radiogroup"` when miss
|
|
|
236
338
|
data-zidan-counter="140" data-zidan-clear></textarea>
|
|
237
339
|
|
|
238
340
|
<input type="text" data-zidan="input" data-zidan-layout="floating" data-zidan-label="Company">
|
|
239
|
-
<input type="range" data-zidan="input" data-zidan-label="Budget" data-zidan-output="#budget-out">
|
|
240
341
|
```
|
|
241
342
|
|
|
242
343
|
Supported types: `text`, `email`, `password`, `number`, `tel`, `url`, `search`, `date`,
|
|
243
344
|
`time`, `datetime-local`, `month`, `week`, `range`, `color`, plus `<textarea>`.
|
|
244
|
-
|
|
345
|
+
|
|
346
|
+
### Input icons
|
|
347
|
+
|
|
348
|
+
```html
|
|
349
|
+
<!-- automatic icon for the input type -->
|
|
350
|
+
<input type="email" data-zidan="input" data-zidan-auto-icon="true" data-zidan-clear>
|
|
351
|
+
|
|
352
|
+
<!-- choose an icon and the side; clickable ones emit zidan:icon-click -->
|
|
353
|
+
<input type="url" data-zidan="input" data-zidan-icon="link"
|
|
354
|
+
data-zidan-icon-position="right" data-zidan-icon-clickable="true"
|
|
355
|
+
data-zidan-icon-label="Open website">
|
|
356
|
+
```
|
|
357
|
+
|
|
358
|
+
```js
|
|
359
|
+
ZidanForm.registerIcon('sparkle', '<path d="M12 3l1.9 5.3L19 10l-5.1 1.7L12 17Z"/>');
|
|
360
|
+
```
|
|
361
|
+
|
|
362
|
+
Works for `text`, `email`, `password`, `number`, `tel`, `url`, `search`, all date/time types
|
|
363
|
+
and `range`. `data-zidan-validation-icon="true"` adds check/alert glyphs.
|
|
364
|
+
|
|
365
|
+
### Number stepper
|
|
366
|
+
|
|
367
|
+
```html
|
|
368
|
+
<input type="number" min="0" max="10" value="3" data-zidan="input"
|
|
369
|
+
data-zidan-stepper="stacked">
|
|
370
|
+
<input type="number" min="0" max="99" data-zidan="input" data-zidan-stepper="split">
|
|
371
|
+
<input type="number" step="0.5" data-zidan="input" data-zidan-stepper="inline"
|
|
372
|
+
data-zidan-stepper-position="left" data-zidan-stepper-long-press="true">
|
|
373
|
+
```
|
|
374
|
+
|
|
375
|
+
Modes: `stacked`, `split`, `inline`. Press and hold repeats (configurable delay/interval);
|
|
376
|
+
min, max and step are respected. Methods: `stepUp()`, `stepDown()`, `setStepper()`.
|
|
377
|
+
|
|
378
|
+
### Phone formatting
|
|
379
|
+
|
|
380
|
+
```html
|
|
381
|
+
<input type="tel" data-zidan="input" data-zidan-phone="true"
|
|
382
|
+
data-zidan-phone-country="GB" data-zidan-phone-format="international">
|
|
383
|
+
<input type="tel" data-zidan="input" data-zidan-phone="true"
|
|
384
|
+
data-zidan-phone-country="US" data-zidan-phone-format="national"
|
|
385
|
+
data-zidan-phone-country-select="false">
|
|
386
|
+
```
|
|
387
|
+
|
|
388
|
+
Three styles per country: `national`, `international`, `e164`. The optional country `<select>`
|
|
389
|
+
changes both the dial code and the mask; typing re-formats around the caret. Static helpers:
|
|
390
|
+
`ZidanForm.formatPhone(value, 'US', 'e164')` and `ZidanForm.detectPhoneCountry(value)`.
|
|
391
|
+
|
|
392
|
+
### Range inputs
|
|
393
|
+
|
|
394
|
+
```html
|
|
395
|
+
<input type="range" min="0" max="1000" step="50" value="400"
|
|
396
|
+
data-zidan="input" data-zidan-range-variant="minimal"
|
|
397
|
+
data-zidan-range-bubble="true" data-zidan-range-minmax="false"
|
|
398
|
+
data-zidan-output="#budget-out">
|
|
399
|
+
```
|
|
400
|
+
|
|
401
|
+
```js
|
|
402
|
+
zidanField('#price', {
|
|
403
|
+
rangeTicks: [0, 250, 500, 750, 1000],
|
|
404
|
+
rangeTickLabels: true,
|
|
405
|
+
rangeLabels: { 0: 'Free', 1000: 'Top' },
|
|
406
|
+
rangeFormat: value => '€' + Number(value).toLocaleString('en-US')
|
|
407
|
+
});
|
|
408
|
+
```
|
|
409
|
+
|
|
410
|
+
Variants: `default`, `gradient`, `stepped`, `minimal`. Bubble, min/max scale, ticks and labels
|
|
411
|
+
can each be toggled; `rangeFormat` accepts a template (`{value}`, `{min}`, `{max}`) or a function.
|
|
412
|
+
|
|
413
|
+
### Date & time pickers
|
|
414
|
+
|
|
415
|
+
```html
|
|
416
|
+
<input type="date" data-zidan="input" data-zidan-icon="calendar"
|
|
417
|
+
data-zidan-icon-position="right" data-zidan-disable-weekends="true">
|
|
418
|
+
|
|
419
|
+
<input type="datetime-local" data-zidan="input" data-zidan-picker-button="true"
|
|
420
|
+
data-zidan-picker-icon="calendar">
|
|
421
|
+
```
|
|
422
|
+
|
|
423
|
+
`data-zidan-disable-weekends` and `data-zidan-disabled-dates` (ISO list or JS function) are
|
|
424
|
+
written into native validity, so `checkValidity()` blocks them. Change the picker icon and side
|
|
425
|
+
per field; clickable icons call `input.showPicker()` when available.
|
|
245
426
|
|
|
246
427
|
---
|
|
247
428
|
|
|
@@ -251,7 +432,7 @@ Range inputs can mirror their value into any element with `data-zidan-output`.
|
|
|
251
432
|
|
|
252
433
|
| Option | Data attribute | Type | Default | Description |
|
|
253
434
|
| --- | --- | --- | --- | --- |
|
|
254
|
-
| `variant` | `data-zidan-variant` | string | `default` | Checkbox `default/switch/card`; radio `stacked/inline/card`. |
|
|
435
|
+
| `variant` | `data-zidan-variant` | string | `default` | Checkbox `default/switch/card/button/minimal`; radio `stacked/inline/card/button/tile`; file `dropzone/button/avatar/gallery/compact`; range `default/gradient/stepped/minimal`. |
|
|
255
436
|
| `layout` | `data-zidan-layout` | string | `stacked` | `stacked`, `inline`, `compact`, `floating`, `outlined`, `card`. |
|
|
256
437
|
| `theme` | `data-zidan-theme` | string | `default` | `default`, `modern`, `minimal`, `dark`, `glass`. |
|
|
257
438
|
| `framework` | `data-zidan-framework` | string | `none` | `none`, `bootstrap`, `tailwind`, `bulma`, `foundation`. |
|
|
@@ -264,8 +445,26 @@ Range inputs can mirror their value into any element with `data-zidan-output`.
|
|
|
264
445
|
| `prefix` / `suffix` | `data-zidan-prefix` / `-suffix` | string | — | Static adornments. |
|
|
265
446
|
| `counter` | `data-zidan-counter` | number | `maxlength` | Character limit for the counter; overrides `maxlength`. |
|
|
266
447
|
| `output` | `data-zidan-output` | selector | — | Range value is mirrored into this element. |
|
|
448
|
+
| `autoIcon` / `icon` | `data-zidan-auto-icon` / `data-zidan-icon` | boolean / string | `false` / — | Type-based or custom input icon (any registered name). |
|
|
449
|
+
| `iconPosition` / `iconClickable` | `data-zidan-icon-position` / `-icon-clickable` | `left`\|`right` / boolean | `left` / `false` | Side and behaviour of the icon. |
|
|
450
|
+
| `validationIcon` | `data-zidan-validation-icon` | boolean | `false` | Check/alert glyphs tied to validation state. |
|
|
451
|
+
| `stepper` | `data-zidan-stepper` | boolean \| `stacked`\|`split`\|`inline` | `false` | Number − / + controls. |
|
|
452
|
+
| `stepperPosition` / `stepperLongPress` | `data-zidan-stepper-position` / `-long-press` | `left`\|`right` / boolean | `right` / `true` | Inline side and hold-to-repeat. |
|
|
453
|
+
| `stepperDelay` / `stepperInterval` | `data-zidan-stepper-delay` / `-interval` | number | `420` / `90` | Repeat timing in ms. |
|
|
454
|
+
| `phone` / `phoneCountry` / `phoneFormat` | `data-zidan-phone` / `-phone-country` / `-phone-format` | boolean / ISO-2 / `national`\|`international`\|`e164` | — / `US` / `national` | Phone formatting and validation. |
|
|
455
|
+
| `phoneCountrySelect` / `phoneCountries` | `data-zidan-phone-country-select` / `-phone-countries` | boolean / list | `true` / common set | Country selector. |
|
|
456
|
+
| `rangeVariant` / `rangeBubble` / `rangeMinMax` | `data-zidan-range-variant` / `-range-bubble` / `-range-minmax` | string / boolean / boolean | `default` / `true` / `true` | Range skin and chrome. |
|
|
457
|
+
| `rangeTicks` / `rangeTickLabels` / `rangeLabels` / `rangeFormat` | `data-zidan-range-ticks` / `-range-tick-labels` / — / `-range-format` | number\|array / boolean / object / string\|function | `0` / `false` / — / — | Ticks, labels and value formatter. |
|
|
458
|
+
| `pickerButton` / `pickerIcon` | `data-zidan-picker-button` / `-picker-icon` | boolean / string | `false` / per type | Date/time picker button and icon. |
|
|
459
|
+
| `disableWeekends` / `disabledDates` | `data-zidan-disable-weekends` / `-disabled-dates` | boolean / list\|function | `false` / — | Date rules written into native validity. |
|
|
267
460
|
| `title` | `data-zidan-title` | string | `Choose a file` | File dropzone title. |
|
|
268
461
|
| `dropHint` | `data-zidan-drop-hint` | string | — | File dropzone subtitle. |
|
|
462
|
+
| `fileVariant` / `uploadIcon` | `data-zidan-file-variant` / `-upload-icon` | string | `dropzone` / `upload` | Upload design and icon. |
|
|
463
|
+
| `upload` / `uploadHandler` / `uploadUrl` | `data-zidan-upload-url` | function / string | — | Custom uploader or XHR endpoint. |
|
|
464
|
+
| `uploadField` / `uploadData` / `uploadHeaders` | `data-zidan-upload-field` | string / object\|function / object\|function | `file` / — / — | FormData and request extras. |
|
|
465
|
+
| `simulateUpload` / `simulateDuration` / `autoUpload` | `data-zidan-simulate-upload` / `-simulate-duration` / `-auto-upload` | boolean / number / boolean | `false` / `900` / `true` | Visual upload mode and timing. |
|
|
466
|
+
| `showFileMeta` / `showPreview` / `replaceTitle` | `data-zidan-show-file-meta` / `-preview` | boolean / boolean / string | `true` / `true` / `Change image` | Per-file rows and avatar preview. |
|
|
467
|
+
| `renderFile` | — | function | — | `(itemEl, { file, index, state, field })` hook. |
|
|
269
468
|
| `maxFiles` | `data-zidan-max-files` | number | — | File count limit. |
|
|
270
469
|
| `maxSize` | `data-zidan-max-size` | number | — | Bytes per file. |
|
|
271
470
|
| `maxSizeMB` | `data-zidan-max-size-mb` | number | — | Per-file limit in megabytes; `2` = 2 MB, decimals allowed. Ignored when `maxSize` is set. |
|
|
@@ -313,15 +512,32 @@ Per-select instance: `open()`, `close()`, `toggle()`, `isOpen()`, `getValue()`,
|
|
|
313
512
|
Per-field instance: `getValue()`, `setValue(v)`, `update()`, `refresh()`,
|
|
314
513
|
`setValidation(state)`, `getValidation()`, `setTheme()`, `setFramework()`, `setLayout()`,
|
|
315
514
|
`destroy()`, plus `setIndeterminate()`/`isChecked()` (checkbox), `setValue()` (radio group),
|
|
316
|
-
|
|
515
|
+
`stepUp()`/`stepDown()`/`setStepper()` (number), `getPhoneCountry()`/`setPhoneCountry()`/
|
|
516
|
+
`setPhoneFormat()`/`formatPhone()` (phone), `openPicker()`/`showPicker()` (date/time),
|
|
517
|
+
and `getFiles()`/`getUploadState()`/`addFiles()`/`replaceFiles()`/`removeFile()`/`clear()`/
|
|
518
|
+
`setVariant()`/`setUploader()`/`uploadAll()`/`uploadFile()`/`cancelUpload()`/`cancelAll()`/
|
|
519
|
+
`retryUpload()` (file).
|
|
317
520
|
|
|
318
|
-
Events bubble from the wrapper
|
|
319
|
-
|
|
521
|
+
Events bubble from the wrapper:
|
|
522
|
+
|
|
523
|
+
| Event | Detail |
|
|
524
|
+
| --- | --- |
|
|
525
|
+
| `zidan:change` | `{ instance, kind, value }`, `{ checked }` or `{ files }` |
|
|
526
|
+
| `zidan:validation` | `{ instance, state, message? }` |
|
|
527
|
+
| `zidan:step` | `{ instance, value, direction }` (number stepper) |
|
|
528
|
+
| `zidan:phone-country` / `zidan:phone-format` | `{ country }` / `{ format }` |
|
|
529
|
+
| `zidan:icon-click` | `{ instance, icon, position }` |
|
|
530
|
+
| `zidan:picker` | `{ instance, type }` |
|
|
531
|
+
| `zidan:upload-start` / `-progress` / `-success` / `-error` / `-cancel` | file state, name, progress/result/message |
|
|
532
|
+
| `zidan:remove` / `zidan:clear` / `zidan:init` / `zidan:destroy` / `zidan:error` | lifecycle |
|
|
320
533
|
|
|
321
534
|
```js
|
|
322
535
|
document.addEventListener('zidan:change', event => {
|
|
323
536
|
console.log(event.detail.kind, event.detail.value || event.detail.checked);
|
|
324
537
|
});
|
|
538
|
+
document.addEventListener('zidan:upload-progress', event => {
|
|
539
|
+
console.log(event.detail.name, event.detail.progress + '%');
|
|
540
|
+
});
|
|
325
541
|
```
|
|
326
542
|
|
|
327
543
|
---
|
|
@@ -563,9 +779,37 @@ Full checklist, folder tree and release automation notes: [`docs/build.md`](docs
|
|
|
563
779
|
|
|
564
780
|
---
|
|
565
781
|
|
|
782
|
+
## What's new in 2.1
|
|
783
|
+
|
|
784
|
+
- **Input icons** — `data-zidan-auto-icon`, `data-zidan-icon`, left/right placement,
|
|
785
|
+
clickable icons and `ZidanForm.registerIcon()` for custom artwork.
|
|
786
|
+
- **Number stepper** — stacked, split and inline − / + controls with hold-to-repeat,
|
|
787
|
+
min/max/step support and `stepUp()` / `stepDown()`.
|
|
788
|
+
- **Phone formatting** — country selector plus `national`, `international` and `e164` masks,
|
|
789
|
+
caret-safe while typing, with `setPhoneCountry()` / `setPhoneFormat()`.
|
|
790
|
+
- **Range skins** — `gradient`, `stepped`, `minimal`; bubble, min/max scale, tick arrays,
|
|
791
|
+
labels and string/function formatters.
|
|
792
|
+
- **More skins** — checkbox `button` / `minimal`; switch `ios/material/square/labeled/icon`
|
|
793
|
+
with YES/NO labels; radio `button` / `tile` with descriptions and deselect.
|
|
794
|
+
- **File variants & uploads** — `dropzone/button/avatar/gallery/compact`, progress, cancel,
|
|
795
|
+
retry, simulated uploads, XHR or custom `upload()` handlers, `getUploadState()`,
|
|
796
|
+
`renderFile` and `zidan:upload-*` events.
|
|
797
|
+
- **Date rules** — weekend and blocked-date rules now write into native validity, so
|
|
798
|
+
`form.checkValidity()` and third-party validators see them.
|
|
799
|
+
- **Docs & demo** — new option tables in [`docs/options.md`](docs/options.md), token list in
|
|
800
|
+
[`docs/theming.md`](docs/theming.md), validation rules in
|
|
801
|
+
[`docs/validation.md`](docs/validation.md), and a live event console on the demo page.
|
|
802
|
+
|
|
803
|
+
The 2.0 API is unchanged; every addition is opt-in.
|
|
804
|
+
|
|
805
|
+
**2.1.1** is a documentation-only patch: it ships this README, the GitHub Pages deployment, the
|
|
806
|
+
demo screenshots and the copyable CDN URLs. No JavaScript or CSS behaviour changed.
|
|
807
|
+
|
|
808
|
+
---
|
|
809
|
+
|
|
566
810
|
## Migrating from 1.x
|
|
567
811
|
|
|
568
|
-
| 1.x | 2.
|
|
812
|
+
| 1.x | 2.x |
|
|
569
813
|
| --- | --- |
|
|
570
814
|
| `ZidanSelect.js` | `zidan-form.js` (same select engine inside; `window.ZidanSelect` kept as alias) |
|
|
571
815
|
| `ZidanSelect.mjs` | `zidan-form.mjs` |
|