zidan-select 2.3.1 → 2.4.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 +171 -83
- package/dist/file/plugin-file-core.css +1 -1
- package/dist/file/plugin-file-core.min.css +1 -1
- package/dist/file/plugin-file-theme.css +1 -1
- package/dist/file/plugin-file-theme.min.css +1 -1
- package/dist/file/zidan-file.d.ts +1 -1
- package/dist/file/zidan-file.js +2 -2
- package/dist/file/zidan-file.min.js +2 -2
- package/dist/plugin-core.css +1 -1
- package/dist/plugin-core.min.css +1 -1
- package/dist/plugin-theme.css +1 -1
- package/dist/plugin-theme.min.css +1 -1
- package/dist/select/plugin-select-core.css +1 -1
- package/dist/select/plugin-select-core.min.css +1 -1
- package/dist/select/plugin-select-theme.css +1 -1
- package/dist/select/plugin-select-theme.min.css +1 -1
- package/dist/select/zidan-select.d.ts +1 -1
- package/dist/select/zidan-select.js +133 -2
- package/dist/select/zidan-select.min.js +2 -2
- package/dist/zidan-form.js +133 -2
- package/dist/zidan-form.min.js +2 -2
- package/docs/build.md +76 -48
- package/docs/comparison.md +3 -3
- package/docs/frameworks.md +19 -13
- package/docs/html-and-wordpress.md +20 -20
- package/docs/index.html +144 -84
- package/docs/options.md +138 -35
- package/docs/validation.html +96 -56
- package/docs/validation.md +7 -7
- package/package.json +4 -3
- package/plugin-core.css +1 -1
- package/plugin-theme.css +1 -1
- package/zidan-form.d.ts +45 -21
- package/zidan-form.js +133 -2
package/README.md
CHANGED
|
@@ -7,8 +7,8 @@ two separate stylesheets.
|
|
|
7
7
|
|
|
8
8
|
[](https://akhtar1985.github.io/zidan-select/)
|
|
9
9
|
[](https://www.npmjs.com/package/zidan-select)
|
|
10
|
-
[](docs/options.
|
|
11
|
-
[](LICENSE)
|
|
10
|
+
[](https://akhtar1985.github.io/zidan-select/docs/options.html)
|
|
11
|
+
[](https://github.com/akhtar1985/zidan-select/blob/main/LICENSE)
|
|
12
12
|
|
|
13
13
|
## Which files should you load?
|
|
14
14
|
|
|
@@ -26,30 +26,31 @@ two separate stylesheets.
|
|
|
26
26
|
Load **one** build per page. A subset is not an add-on: never load it together with the full
|
|
27
27
|
bundle.
|
|
28
28
|
|
|
29
|
-
| Build | JavaScript (CDN) | CSS (CDN) |
|
|
30
|
-
| --- | --- | --- |
|
|
31
|
-
| Full — every control | [zidan-form.js](https://cdn.jsdelivr.net/npm/zidan-select@2.
|
|
32
|
-
| Select-only
|
|
33
|
-
| File-only
|
|
29
|
+
| Build | JavaScript size | JavaScript (CDN) | CSS (CDN) |
|
|
30
|
+
| --- | --- | --- | --- |
|
|
31
|
+
| Full — every control | ≈224 kB raw · ≈131 kB minified | [zidan-form.js](https://cdn.jsdelivr.net/npm/zidan-select@2.4.1/zidan-form.js) | [plugin-core.css](https://cdn.jsdelivr.net/npm/zidan-select@2.4.1/plugin-core.css) + [plugin-theme.css](https://cdn.jsdelivr.net/npm/zidan-select@2.4.1/plugin-theme.css) |
|
|
32
|
+
| Select-only | ≈114 kB raw · ≈68 kB minified | [zidan-select.js](https://cdn.jsdelivr.net/npm/zidan-select@2.4.1/dist/select/zidan-select.js) | [plugin-select-core.css](https://cdn.jsdelivr.net/npm/zidan-select@2.4.1/dist/select/plugin-select-core.css) + [plugin-select-theme.css](https://cdn.jsdelivr.net/npm/zidan-select@2.4.1/dist/select/plugin-select-theme.css) |
|
|
33
|
+
| File-only | ≈86 kB raw · ≈50 kB minified | [zidan-file.js](https://cdn.jsdelivr.net/npm/zidan-select@2.4.1/dist/file/zidan-file.js) | [plugin-file-core.css](https://cdn.jsdelivr.net/npm/zidan-select@2.4.1/dist/file/plugin-file-core.css) + [plugin-file-theme.css](https://cdn.jsdelivr.net/npm/zidan-select@2.4.1/dist/file/plugin-file-theme.css) |
|
|
34
34
|
|
|
35
35
|
Copyable snippets, ESM files and per-file sizes live in
|
|
36
36
|
[Select-only and file-only builds](#select-only-and-file-only-builds); the
|
|
37
37
|
[live demo](https://akhtar1985.github.io/zidan-select/#builds) shows all three side by side.
|
|
38
38
|
|
|
39
39
|
**Build a field visually:** the [field playground](https://akhtar1985.github.io/zidan-select/playground.html)
|
|
40
|
-
|
|
41
|
-
vanilla JavaScript.
|
|
40
|
+
exposes the main options for one control, previews them live and copies supported HTML attributes
|
|
41
|
+
or the equivalent vanilla JavaScript; the [API lab](https://akhtar1985.github.io/zidan-select/#lab)
|
|
42
|
+
covers the complete option, callback, method and event inventory.
|
|
42
43
|
|
|
43
44
|
### Minified CDN URLs
|
|
44
45
|
|
|
45
|
-
|
|
46
|
-
|
|
46
|
+
These are real minified files shipped in the npm package, so jsDelivr and unpkg serve the
|
|
47
|
+
same pinned bytes:
|
|
47
48
|
|
|
48
49
|
| Build | JS (min) | CSS (min) |
|
|
49
50
|
| --- | --- | --- |
|
|
50
|
-
| Full | [zidan-form.min.js](https://cdn.jsdelivr.net/npm/zidan-select@2.
|
|
51
|
-
| Select-only | [zidan-select.min.js](https://cdn.jsdelivr.net/npm/zidan-select@2.
|
|
52
|
-
| File-only | [zidan-file.min.js](https://cdn.jsdelivr.net/npm/zidan-select@2.
|
|
51
|
+
| Full | [zidan-form.min.js](https://cdn.jsdelivr.net/npm/zidan-select@2.4.1/dist/zidan-form.min.js) — ≈131 kB | [plugin-core.min.css](https://cdn.jsdelivr.net/npm/zidan-select@2.4.1/dist/plugin-core.min.css) — ≈31 kB + [plugin-theme.min.css](https://cdn.jsdelivr.net/npm/zidan-select@2.4.1/dist/plugin-theme.min.css) — ≈39 kB |
|
|
52
|
+
| Select-only | [zidan-select.min.js](https://cdn.jsdelivr.net/npm/zidan-select@2.4.1/dist/select/zidan-select.min.js) — ≈68 kB | [plugin-select-core.min.css](https://cdn.jsdelivr.net/npm/zidan-select@2.4.1/dist/select/plugin-select-core.min.css) — ≈9 kB + [plugin-select-theme.min.css](https://cdn.jsdelivr.net/npm/zidan-select@2.4.1/dist/select/plugin-select-theme.min.css) — ≈27 kB |
|
|
53
|
+
| File-only | [zidan-file.min.js](https://cdn.jsdelivr.net/npm/zidan-select@2.4.1/dist/file/zidan-file.min.js) — ≈50 kB | [plugin-file-core.min.css](https://cdn.jsdelivr.net/npm/zidan-select@2.4.1/dist/file/plugin-file-core.min.css) — ≈7 kB + [plugin-file-theme.min.css](https://cdn.jsdelivr.net/npm/zidan-select@2.4.1/dist/file/plugin-file-theme.min.css) — ≈29 kB |
|
|
53
54
|
|
|
54
55
|
- **One file of JS** — `zidan-form.js` (classic script, UMD-ish) + `zidan-form.mjs` (ESM wrapper).
|
|
55
56
|
- **Split CSS** — `plugin-core.css` (structure only) and `plugin-theme.css` (tokens, presets, skins).
|
|
@@ -118,7 +119,7 @@ the same two stylesheets and no dependencies.
|
|
|
118
119
|
**Trade-offs:** smaller community than Select2, no React/Vue component package, and for very
|
|
119
120
|
complex comboboxes (tokenized multi-search, drag-reorder tag editors) Select2 or Tom Select
|
|
120
121
|
still have deeper ecosystems. Full matrix, honest limitations and migration notes:
|
|
121
|
-
**[`docs/comparison.md`](docs/comparison.
|
|
122
|
+
**[`docs/comparison.md`](https://akhtar1985.github.io/zidan-select/docs/comparison.html)**.
|
|
122
123
|
|
|
123
124
|
---
|
|
124
125
|
|
|
@@ -131,24 +132,25 @@ still have deeper ecosystems. Full matrix, honest limitations and migration note
|
|
|
131
132
|
5. [Quick start](#quick-start)
|
|
132
133
|
6. [Input types](#input-types)
|
|
133
134
|
7. [Options & data attributes](#options--data-attributes)
|
|
134
|
-
8. [
|
|
135
|
-
9. [
|
|
136
|
-
10. [
|
|
137
|
-
11. [
|
|
138
|
-
12. [
|
|
139
|
-
13. [
|
|
140
|
-
14. [
|
|
141
|
-
15. [
|
|
142
|
-
16. [
|
|
135
|
+
8. [Remote data (AJAX)](#remote-data-ajax-selects)
|
|
136
|
+
9. [JavaScript API](#javascript-api)
|
|
137
|
+
10. [Themes, layouts & frameworks](#themes-layouts--frameworks)
|
|
138
|
+
11. [Validation libraries](#validation-libraries)
|
|
139
|
+
12. [Form lifecycle & state sync](#form-lifecycle--state-sync)
|
|
140
|
+
13. [React, Next.js, Vue, Angular](#react-nextjs-vue-angular)
|
|
141
|
+
14. [Build & publish](#build--publish)
|
|
142
|
+
15. [Browser support](#browser-support)
|
|
143
|
+
16. [What's new in 2.1–2.3](#whats-new-in-213)
|
|
144
|
+
17. [Migrating from 1.x](#migrating-from-1x)
|
|
143
145
|
|
|
144
146
|
---
|
|
145
147
|
|
|
146
148
|
## Live demo
|
|
147
149
|
|
|
148
|
-
[](https://akhtar1985.github.io/zidan-select/)
|
|
150
|
+
[](https://akhtar1985.github.io/zidan-select/)
|
|
149
151
|
|
|
150
152
|
**Demo:** <https://akhtar1985.github.io/zidan-select/> — deployed from `main` by
|
|
151
|
-
[`.github/workflows/pages.yml`](.github/workflows/pages.yml) on every push.
|
|
153
|
+
[`.github/workflows/pages.yml`](https://github.com/akhtar1985/zidan-select/blob/main/.github/workflows/pages.yml) on every push.
|
|
152
154
|
|
|
153
155
|
Deep links open the matching tab:
|
|
154
156
|
|
|
@@ -168,7 +170,11 @@ A mock **Shopify product page** — variant combobox, quantity stepper, gift-wra
|
|
|
168
170
|
radios, upload dropzone and the Liquid install snippets — runs at
|
|
169
171
|
<https://akhtar1985.github.io/zidan-select/shopify.html>.
|
|
170
172
|
|
|
171
|
-
|
|
173
|
+
A dedicated **[AJAX & remote data demo](https://akhtar1985.github.io/zidan-select/ajax.html)** wires
|
|
174
|
+
`data-zidan-fetch-url` to a real API and shows the hand-written `fetchOptions` contract with live
|
|
175
|
+
paging, abort and cache state.
|
|
176
|
+
|
|
177
|
+
Below the tabs sits the **[controls reference]**(https://akhtar1985.github.io/zidan-select/#controls)**
|
|
172
178
|
— all nine control families on one page with the options you reach for most, the two ways to
|
|
173
179
|
initialise a field and copyable examples, linking into the playground for the rest.
|
|
174
180
|
|
|
@@ -235,13 +241,13 @@ override presets.
|
|
|
235
241
|
|
|
236
242
|
Copyable URLs for the published files (pin the version in production):
|
|
237
243
|
|
|
238
|
-
- `zidan-form.js` — <https://cdn.jsdelivr.net/npm/zidan-select@2.
|
|
239
|
-
- `zidan-form.min.js` — <https://cdn.jsdelivr.net/npm/zidan-select@2.
|
|
240
|
-
- `zidan-form.mjs` — <https://cdn.jsdelivr.net/npm/zidan-select@2.
|
|
241
|
-
- `plugin-core.css` — <https://cdn.jsdelivr.net/npm/zidan-select@2.
|
|
242
|
-
- `plugin-core.min.css` — <https://cdn.jsdelivr.net/npm/zidan-select@2.
|
|
243
|
-
- `plugin-theme.css` — <https://cdn.jsdelivr.net/npm/zidan-select@2.
|
|
244
|
-
- `plugin-theme.min.css` — <https://cdn.jsdelivr.net/npm/zidan-select@2.
|
|
244
|
+
- `zidan-form.js` — <https://cdn.jsdelivr.net/npm/zidan-select@2.4.1/zidan-form.js>
|
|
245
|
+
- `zidan-form.min.js` — <https://cdn.jsdelivr.net/npm/zidan-select@2.4.1/dist/zidan-form.min.js>
|
|
246
|
+
- `zidan-form.mjs` — <https://cdn.jsdelivr.net/npm/zidan-select@2.4.1/zidan-form.mjs>
|
|
247
|
+
- `plugin-core.css` — <https://cdn.jsdelivr.net/npm/zidan-select@2.4.1/plugin-core.css>
|
|
248
|
+
- `plugin-core.min.css` — <https://cdn.jsdelivr.net/npm/zidan-select@2.4.1/dist/plugin-core.min.css>
|
|
249
|
+
- `plugin-theme.css` — <https://cdn.jsdelivr.net/npm/zidan-select@2.4.1/plugin-theme.css>
|
|
250
|
+
- `plugin-theme.min.css` — <https://cdn.jsdelivr.net/npm/zidan-select@2.4.1/dist/plugin-theme.min.css>
|
|
245
251
|
- npm package — <https://www.npmjs.com/package/zidan-select>
|
|
246
252
|
- Source — <https://github.com/akhtar1985/zidan-select>
|
|
247
253
|
|
|
@@ -262,27 +268,28 @@ exactly like the full build.
|
|
|
262
268
|
|
|
263
269
|
Copyable CDN URLs (pin the version):
|
|
264
270
|
|
|
265
|
-
- `zidan-select.js` — <https://cdn.jsdelivr.net/npm/zidan-select@2.
|
|
266
|
-
- `zidan-select.min.js` — <https://cdn.jsdelivr.net/npm/zidan-select@2.
|
|
267
|
-
- `zidan-select.mjs` — <https://cdn.jsdelivr.net/npm/zidan-select@2.
|
|
268
|
-
- `plugin-select-core.css` — <https://cdn.jsdelivr.net/npm/zidan-select@2.
|
|
269
|
-
- `plugin-select-core.min.css` — <https://cdn.jsdelivr.net/npm/zidan-select@2.
|
|
270
|
-
- `plugin-select-theme.css` — <https://cdn.jsdelivr.net/npm/zidan-select@2.
|
|
271
|
-
- `plugin-select-theme.min.css` — <https://cdn.jsdelivr.net/npm/zidan-select@2.
|
|
272
|
-
- `zidan-file.js` — <https://cdn.jsdelivr.net/npm/zidan-select@2.
|
|
273
|
-
- `zidan-file.min.js` — <https://cdn.jsdelivr.net/npm/zidan-select@2.
|
|
274
|
-
- `zidan-file.mjs` — <https://cdn.jsdelivr.net/npm/zidan-select@2.
|
|
275
|
-
- `plugin-file-core.css` — <https://cdn.jsdelivr.net/npm/zidan-select@2.
|
|
276
|
-
- `plugin-file-core.min.css` — <https://cdn.jsdelivr.net/npm/zidan-select@2.
|
|
277
|
-
- `plugin-file-theme.css` — <https://cdn.jsdelivr.net/npm/zidan-select@2.
|
|
278
|
-
- `plugin-file-theme.min.css` — <https://cdn.jsdelivr.net/npm/zidan-select@2.
|
|
279
|
-
|
|
280
|
-
Select / combobox / tags only (≈
|
|
271
|
+
- `zidan-select.js` — <https://cdn.jsdelivr.net/npm/zidan-select@2.4.1/dist/select/zidan-select.js>
|
|
272
|
+
- `zidan-select.min.js` — <https://cdn.jsdelivr.net/npm/zidan-select@2.4.1/dist/select/zidan-select.min.js>
|
|
273
|
+
- `zidan-select.mjs` — <https://cdn.jsdelivr.net/npm/zidan-select@2.4.1/dist/select/zidan-select.mjs>
|
|
274
|
+
- `plugin-select-core.css` — <https://cdn.jsdelivr.net/npm/zidan-select@2.4.1/dist/select/plugin-select-core.css>
|
|
275
|
+
- `plugin-select-core.min.css` — <https://cdn.jsdelivr.net/npm/zidan-select@2.4.1/dist/select/plugin-select-core.min.css>
|
|
276
|
+
- `plugin-select-theme.css` — <https://cdn.jsdelivr.net/npm/zidan-select@2.4.1/dist/select/plugin-select-theme.css>
|
|
277
|
+
- `plugin-select-theme.min.css` — <https://cdn.jsdelivr.net/npm/zidan-select@2.4.1/dist/select/plugin-select-theme.min.css>
|
|
278
|
+
- `zidan-file.js` — <https://cdn.jsdelivr.net/npm/zidan-select@2.4.1/dist/file/zidan-file.js>
|
|
279
|
+
- `zidan-file.min.js` — <https://cdn.jsdelivr.net/npm/zidan-select@2.4.1/dist/file/zidan-file.min.js>
|
|
280
|
+
- `zidan-file.mjs` — <https://cdn.jsdelivr.net/npm/zidan-select@2.4.1/dist/file/zidan-file.mjs>
|
|
281
|
+
- `plugin-file-core.css` — <https://cdn.jsdelivr.net/npm/zidan-select@2.4.1/dist/file/plugin-file-core.css>
|
|
282
|
+
- `plugin-file-core.min.css` — <https://cdn.jsdelivr.net/npm/zidan-select@2.4.1/dist/file/plugin-file-core.min.css>
|
|
283
|
+
- `plugin-file-theme.css` — <https://cdn.jsdelivr.net/npm/zidan-select@2.4.1/dist/file/plugin-file-theme.css>
|
|
284
|
+
- `plugin-file-theme.min.css` — <https://cdn.jsdelivr.net/npm/zidan-select@2.4.1/dist/file/plugin-file-theme.min.css>
|
|
285
|
+
|
|
286
|
+
Select / combobox / tags only (≈114 kB raw / ≈68 kB minified JS, ≈12 → 9 kB core CSS,
|
|
287
|
+
≈32 → 27 kB theme CSS):
|
|
281
288
|
|
|
282
289
|
```html
|
|
283
|
-
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/zidan-select@2.
|
|
284
|
-
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/zidan-select@2.
|
|
285
|
-
<script src="https://cdn.jsdelivr.net/npm/zidan-select@2.
|
|
290
|
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/zidan-select@2.4.1/dist/select/plugin-select-core.css">
|
|
291
|
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/zidan-select@2.4.1/dist/select/plugin-select-theme.css">
|
|
292
|
+
<script src="https://cdn.jsdelivr.net/npm/zidan-select@2.4.1/dist/select/zidan-select.js"></script>
|
|
286
293
|
<script>
|
|
287
294
|
// auto-init covers [data-zidan-select], class="zidan-select", zidan-form scopes
|
|
288
295
|
// and ZIDAN_FORM_CONFIG targets; JS-only options:
|
|
@@ -290,14 +297,15 @@ Select / combobox / tags only (≈104 kB JS, ≈12 kB core CSS, ≈32 kB theme C
|
|
|
290
297
|
</script>
|
|
291
298
|
```
|
|
292
299
|
|
|
293
|
-
File upload only (≈
|
|
300
|
+
File upload only (≈86 kB raw / ≈50 kB minified JS, ≈10 → 7 kB core CSS,
|
|
301
|
+
≈34 → 29 kB theme CSS):
|
|
294
302
|
|
|
295
303
|
```html
|
|
296
|
-
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/zidan-select@2.
|
|
297
|
-
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/zidan-select@2.
|
|
298
|
-
<script src="https://cdn.jsdelivr.net/npm/zidan-select@2.
|
|
304
|
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/zidan-select@2.4.1/dist/file/plugin-file-core.css">
|
|
305
|
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/zidan-select@2.4.1/dist/file/plugin-file-theme.css">
|
|
306
|
+
<script src="https://cdn.jsdelivr.net/npm/zidan-select@2.4.1/dist/file/zidan-file.js"></script>
|
|
299
307
|
<script>
|
|
300
|
-
zidanField('#upload', { variant: 'dropzone',
|
|
308
|
+
zidanField('#upload', { variant: 'dropzone', uploadUrl: '/api/files' });
|
|
301
309
|
</script>
|
|
302
310
|
```
|
|
303
311
|
|
|
@@ -318,7 +326,7 @@ targets apply.
|
|
|
318
326
|
## Quick start
|
|
319
327
|
|
|
320
328
|
> Building a plain HTML page, a WordPress site or a page-builder embed? The
|
|
321
|
-
> [static HTML & WordPress cookbook](docs/html-and-wordpress.
|
|
329
|
+
> [static HTML & WordPress cookbook](https://akhtar1985.github.io/zidan-select/docs/html-and-wordpress.html) has complete copy-paste pages
|
|
322
330
|
> (full, select-only, file-only, ID/class targeting, `functions.php` enqueue).
|
|
323
331
|
|
|
324
332
|
```html
|
|
@@ -413,7 +421,7 @@ the select build enhances selects, the file build enhances file inputs; both und
|
|
|
413
421
|
same config keys, marker classes and JSON attribute.
|
|
414
422
|
|
|
415
423
|
Windows/macOS keyboard behaviour, grouping, search and all select features live in
|
|
416
|
-
[`docs/options.md`](docs/options.
|
|
424
|
+
[`docs/options.md`](https://akhtar1985.github.io/zidan-select/docs/options.html).
|
|
417
425
|
|
|
418
426
|
### JavaScript init: one select by ID or class
|
|
419
427
|
|
|
@@ -428,7 +436,7 @@ argument to `zidanSelect()`:
|
|
|
428
436
|
</select>
|
|
429
437
|
|
|
430
438
|
<!-- select-only build; use zidan-form.js for every control -->
|
|
431
|
-
<script src="https://cdn.jsdelivr.net/npm/zidan-select@2.
|
|
439
|
+
<script src="https://cdn.jsdelivr.net/npm/zidan-select@2.4.1/dist/select/zidan-select.js"></script>
|
|
432
440
|
<script>
|
|
433
441
|
const picker = zidanSelect('#mymov', {
|
|
434
442
|
mode: 'combobox', // 'select' | 'combobox' | 'tags'
|
|
@@ -473,8 +481,8 @@ The file-only build uses the same targeted pattern: `zidanField('#upload', { var
|
|
|
473
481
|
accept: 'image/*', maxFiles: 4 })` and `zidanField('.upload-field', options)`.
|
|
474
482
|
|
|
475
483
|
Every option in JavaScript form — with defaults, callbacks and rendering hooks — is in
|
|
476
|
-
[Select options](docs/options.
|
|
477
|
-
[File upload](docs/options.
|
|
484
|
+
[Select options](https://akhtar1985.github.io/zidan-select/docs/options.html#select-options) and
|
|
485
|
+
[File upload](https://akhtar1985.github.io/zidan-select/docs/options.html#file-upload-variants-uploading--rendering). Try the editable
|
|
478
486
|
options object live in the demo's **Select** tab →
|
|
479
487
|
[Direct JS init](https://akhtar1985.github.io/zidan-select/#select).
|
|
480
488
|
|
|
@@ -654,6 +662,8 @@ and `range`. `data-zidan-validation-icon="true"` adds check/alert glyphs.
|
|
|
654
662
|
|
|
655
663
|
Modes: `stacked`, `split`, `inline`. Press and hold repeats (configurable delay/interval);
|
|
656
664
|
min, max and step are respected. Methods: `stepUp()`, `stepDown()`, `setStepper()`.
|
|
665
|
+
`setStepper()` changes the source attribute; destroy and reinitialise the field to add or remove
|
|
666
|
+
the generated buttons.
|
|
657
667
|
|
|
658
668
|
### Phone formatting
|
|
659
669
|
|
|
@@ -769,7 +779,7 @@ per field; clickable icons call `input.showPicker()` when available.
|
|
|
769
779
|
|
|
770
780
|
### Select options
|
|
771
781
|
|
|
772
|
-
See [`docs/options.md`](docs/options.
|
|
782
|
+
See [`docs/options.md`](https://akhtar1985.github.io/zidan-select/docs/options.html) for the complete table (`mode`, `layout`,
|
|
773
783
|
`themeFramework`, `searchable`, `clearable`, `multiple`, `maxTags`, `suggestions`,
|
|
774
784
|
`fetchOptions`, `debounce`, `minChars`, callbacks, `customClasses`, `scrollbar`, …).
|
|
775
785
|
|
|
@@ -782,9 +792,73 @@ Three behaviours that are easy to miss:
|
|
|
782
792
|
or hide the options. Open the list with a click, `Space`, `Enter` or `↓`.
|
|
783
793
|
- Tags with `allowFreeText: false` accept only values that already exist in the options or
|
|
784
794
|
`suggestions`; anything else is rejected with `"…" is not in the list.`
|
|
785
|
-
- `setValidation('invalid')` (and `data-zidan-validation="invalid"`) is pinned
|
|
786
|
-
`update()`, `refresh()
|
|
787
|
-
|
|
795
|
+
- `setValidation('invalid')` (and `data-zidan-validation="invalid"`) is pinned against
|
|
796
|
+
`update()`, `refresh()` and internal validity mirrors. User input/change/blur or
|
|
797
|
+
`setValidation(null)` releases it; programmatic value helpers that dispatch `change`, and
|
|
798
|
+
applying a non-empty select value, also clear it.
|
|
799
|
+
|
|
800
|
+
---
|
|
801
|
+
|
|
802
|
+
## Remote data (AJAX selects)
|
|
803
|
+
|
|
804
|
+
Two ways to load options over HTTP. Both give you debounce, an `AbortSignal` per request, an LRU
|
|
805
|
+
cache, a **Load more** footer, error retry and the same events.
|
|
806
|
+
|
|
807
|
+
**1. Markup only** — one attribute builds the request:
|
|
808
|
+
|
|
809
|
+
```html
|
|
810
|
+
<select name="product"
|
|
811
|
+
data-zidan-select="combobox"
|
|
812
|
+
data-zidan-fetch-url="/api/products/search"
|
|
813
|
+
data-zidan-fetch-items-path="data.items"
|
|
814
|
+
data-zidan-fetch-total-path="data.total"
|
|
815
|
+
data-zidan-fetch-skip-param="skip"
|
|
816
|
+
data-zidan-fetch-page-size="20">
|
|
817
|
+
</select>
|
|
818
|
+
```
|
|
819
|
+
|
|
820
|
+
That requests `GET /api/products/search?q=…&limit=20&skip=0`, then `skip=20` for the next page,
|
|
821
|
+
and stops once `skip + limit >= data.total`.
|
|
822
|
+
|
|
823
|
+
**2. JavaScript** — `fetchOptions` when the request or the response shape is yours:
|
|
824
|
+
|
|
825
|
+
```js
|
|
826
|
+
const picker = zidanSelect('#owner', {
|
|
827
|
+
mode: 'combobox',
|
|
828
|
+
fetchPageSize: 20,
|
|
829
|
+
fetchOptions: async (query, signal, { page, pageSize }) => {
|
|
830
|
+
const res = await fetch('/api/users?q=' + encodeURIComponent(query)
|
|
831
|
+
+ '&page=' + page + '&size=' + pageSize, { signal });
|
|
832
|
+
const data = await res.json();
|
|
833
|
+
return {
|
|
834
|
+
items: data.rows.map(u => ({ value: u.id, label: u.name })),
|
|
835
|
+
hasMore: data.page + 1 < data.pages
|
|
836
|
+
};
|
|
837
|
+
}
|
|
838
|
+
});
|
|
839
|
+
```
|
|
840
|
+
|
|
841
|
+
| Option | Default | Notes |
|
|
842
|
+
| --- | --- | --- |
|
|
843
|
+
| `fetchUrl` | `null` | Endpoint for the declarative mode (`data-zidan-fetch-url`). |
|
|
844
|
+
| `fetchOptions(query, signal, context)` | — | Return an array, `{ items, hasMore }` or `{ items, total }`; `context` is `{ page, pageSize, append, instance }`. |
|
|
845
|
+
| `fetchPageSize` | `0` | Rows per request; a value above `0` enables paging and the load-more footer. |
|
|
846
|
+
| `fetchQueryParam` | `'q'` | Parameter that carries the search term (`''` omits it). |
|
|
847
|
+
| `fetchPageParam` | `'page'` | 1-based page parameter (`''` omits it). |
|
|
848
|
+
| `fetchSkipParam` | `null` | Send `skip = page × pageSize` instead — for dummyjson/Laravel-style APIs. |
|
|
849
|
+
| `fetchPageSizeParam` | `'limit'` | Parameter that carries `fetchPageSize`. |
|
|
850
|
+
| `fetchItemsPath`, `fetchTotalPath`, `fetchHasMorePath` | `null` | Dot paths into the JSON body (`data.items`, `data.total`). |
|
|
851
|
+
| `fetchMethod`, `fetchHeaders`, `fetchCredentials` | `'GET'`, `null`, `'same-origin'` | Request tuning (JavaScript only). |
|
|
852
|
+
| `debounce`, `minChars` | `250`, `0` | When typing starts a request. |
|
|
853
|
+
| `cacheResults`, `autoLoadMore`, `loadMoreText` | `true`, `true`, `Load more` | Paging behaviour. |
|
|
854
|
+
|
|
855
|
+
Rows map without a mapping function: `value`/`label`, or `id`/`slug`/`code` plus
|
|
856
|
+
`name`/`title`/`full_name`. Instance helpers: `loadMore()`, `hasMoreResults()`,
|
|
857
|
+
`getAsyncState()`, `refreshOptions()`, `clearCache()`; events: `zidan:load-more`, `zidan:error`.
|
|
858
|
+
|
|
859
|
+
**[Live AJAX demo](https://akhtar1985.github.io/zidan-select/ajax.html)** — one card uses the
|
|
860
|
+
attributes above against a public API, the other a hand-written `fetchOptions`, with paging,
|
|
861
|
+
abort and cache state on screen.
|
|
788
862
|
|
|
789
863
|
---
|
|
790
864
|
|
|
@@ -877,7 +951,7 @@ Custom theme — no build step, core never changes:
|
|
|
877
951
|
}
|
|
878
952
|
```
|
|
879
953
|
|
|
880
|
-
Token list, preset details and layout notes: [`docs/theming.md`](docs/theming.
|
|
954
|
+
Token list, preset details and layout notes: [`docs/theming.md`](https://akhtar1985.github.io/zidan-select/docs/theming.html).
|
|
881
955
|
|
|
882
956
|
### Layouts
|
|
883
957
|
|
|
@@ -972,8 +1046,8 @@ form.addEventListener('submit', event => {
|
|
|
972
1046
|
});
|
|
973
1047
|
```
|
|
974
1048
|
|
|
975
|
-
Full recipes: [`docs/validation.md`](docs/validation.
|
|
976
|
-
libraries next to a native form ships as [`docs/validation.html`](docs/validation.html).
|
|
1049
|
+
Full recipes: [`docs/validation.md`](https://akhtar1985.github.io/zidan-select/docs/validation-guide.html). A runnable page that loads all three
|
|
1050
|
+
libraries next to a native form ships as [`docs/validation.html`](https://akhtar1985.github.io/zidan-select/docs/validation.html).
|
|
977
1051
|
|
|
978
1052
|
---
|
|
979
1053
|
|
|
@@ -1008,7 +1082,7 @@ Short version: initialise after mount, call `destroy()` before unmount, push sta
|
|
|
1008
1082
|
be controlled through the instance, because the plugin owns the visible trigger.
|
|
1009
1083
|
|
|
1010
1084
|
Complete, copy-pasteable examples (React 18, Next.js App Router with SSR-safe imports, Vue 3
|
|
1011
|
-
`onMounted`, Angular `ngAfterViewInit` + `ControlValueAccessor` notes): [`docs/frameworks.md`](docs/frameworks.
|
|
1085
|
+
`onMounted`, Angular `ngAfterViewInit` + `ControlValueAccessor` notes): [`docs/frameworks.md`](https://akhtar1985.github.io/zidan-select/docs/frameworks.html).
|
|
1012
1086
|
|
|
1013
1087
|
Next.js CSS imports:
|
|
1014
1088
|
|
|
@@ -1054,9 +1128,10 @@ npm run build # dist/ (+ local .min files when esbuild is installed)
|
|
|
1054
1128
|
| --- | --- |
|
|
1055
1129
|
| `scripts/serve.mjs` | No-dependency demo server on port 4173 (`PORT=8080 npm run dev`). |
|
|
1056
1130
|
| `scripts/build.mjs` | Cleans `dist/`, copies the four assets, writes `dist/zidan-form.cjs`, emits the select-only and file-only bundles with declarations, and minifies every JS/CSS output with esbuild. |
|
|
1057
|
-
| `scripts/test.mjs` | Verifies syntax, that core CSS carries no colour literals, that all presets/adapters exist, the public API is exported, the build artifacts ship, and the playground, README, demo and cookbook stay wired to each other — then runs
|
|
1131
|
+
| `scripts/test.mjs` | Verifies syntax, that core CSS carries no colour literals, that all presets/adapters exist, the public API is exported, the build artifacts ship, and the playground, README, demo and cookbook stay wired to each other — then runs 42 jsdom behaviour suites. |
|
|
1058
1132
|
| `scripts/dom/run.mjs` | jsdom suites for select, fields, uploads, async validation, pagination, RTL, teardown, and the select-only/file-only/minified bundles. |
|
|
1059
1133
|
| `scripts/exa-search.mjs` | Exa web search for docs and release research: `npm run search -- "your question"` (`--num 10` for more results). Reads `EXA_API_KEY`; copy `.env.example` to `.env` (git-ignored) and add a key from https://dashboard.exa.ai/api-keys. |
|
|
1134
|
+
| `scripts/release.mjs` | One-command release: `npm run release -- patch --note "what changed"` bumps every version site, rolls `CHANGELOG.md`, runs the checks, commits and tags `vX.Y.Z`. |
|
|
1060
1135
|
|
|
1061
1136
|
`exa-js` is a dev dependency only, so the published bundle stays dependency-free.
|
|
1062
1137
|
|
|
@@ -1064,19 +1139,32 @@ npm run build # dist/ (+ local .min files when esbuild is installed)
|
|
|
1064
1139
|
files into `dist/` (including both subset folders), so the URLs above work on unpkg, a
|
|
1065
1140
|
self-hosted CDN or jsDelivr without relying on the CDN's auto-minification.
|
|
1066
1141
|
|
|
1067
|
-
|
|
1142
|
+
Releasing is one command:
|
|
1068
1143
|
|
|
1069
1144
|
```bash
|
|
1070
|
-
npm
|
|
1071
|
-
|
|
1072
|
-
npm publish # `files` limits the tarball to JS, CSS, dist, docs, README, LICENSE
|
|
1073
|
-
git push --follow-tags
|
|
1145
|
+
npm run release -- patch --note "Fix the thing that broke" # or minor / major / 2.3.2
|
|
1146
|
+
git push origin main --follow-tags
|
|
1074
1147
|
```
|
|
1075
1148
|
|
|
1149
|
+
`scripts/release.mjs` writes the version into `package.json`, `package-lock.json`, the JS banner
|
|
1150
|
+
and `VERSION`, both CSS banners, the README CDN URLs, the demo pages and the docs; moves
|
|
1151
|
+
`## [Unreleased]` in [`CHANGELOG.md`](https://github.com/akhtar1985/zidan-select/blob/main/CHANGELOG.md) under a dated heading; runs the type check and
|
|
1152
|
+
`npm test`; then commits `Release X.Y.Z` and creates the annotated tag `vX.Y.Z`.
|
|
1153
|
+
`npm run release -- --dry-run` prints the plan without writing anything.
|
|
1154
|
+
|
|
1155
|
+
Pushing the tag runs [`.github/workflows/release.yml`](https://github.com/akhtar1985/zidan-select/blob/main/.github/workflows/release.yml), which
|
|
1156
|
+
publishes to npm through **trusted publishing** (OIDC) with `--provenance` — no token and no local
|
|
1157
|
+
`npm login`, and every tarball carries a provenance attestation. Prereleases go to the `next`
|
|
1158
|
+
dist-tag, and creates the matching **GitHub Release** for the tag using that version's
|
|
1159
|
+
[`CHANGELOG.md`](https://github.com/akhtar1985/zidan-select/blob/main/CHANGELOG.md) section as the
|
|
1160
|
+
body (generated notes only when the section is missing). The workflow refuses a tag that
|
|
1161
|
+
disagrees with `package.json` and refuses to republish a version that already exists on the
|
|
1162
|
+
registry. History lives in [`CHANGELOG.md`](https://github.com/akhtar1985/zidan-select/blob/main/CHANGELOG.md).
|
|
1163
|
+
|
|
1076
1164
|
GitHub Pages serves the repo root: the demo is `index.html` (no build needed), docs live in
|
|
1077
1165
|
`docs/`. Release notes should list theme/layout additions and any token renames.
|
|
1078
1166
|
|
|
1079
|
-
Full checklist, folder tree and release automation notes: [`docs/build.md`](docs/build.
|
|
1167
|
+
Full checklist, folder tree and release automation notes: [`docs/build.md`](https://akhtar1985.github.io/zidan-select/docs/build.html).
|
|
1080
1168
|
|
|
1081
1169
|
---
|
|
1082
1170
|
|
|
@@ -1095,7 +1183,7 @@ Full checklist, folder tree and release automation notes: [`docs/build.md`](docs
|
|
|
1095
1183
|
|
|
1096
1184
|
## What's new in 2.1–2.3
|
|
1097
1185
|
|
|
1098
|
-
**2.
|
|
1186
|
+
**2.4.1** adds the capabilities that were previously the library's biggest gaps:
|
|
1099
1187
|
|
|
1100
1188
|
- **Async validation** — `validate` and `validateDate` may return a Promise. Fields get a
|
|
1101
1189
|
`.zs-field--pending` spinner and `aria-busy`, block form submission through native validity,
|
|
@@ -1113,7 +1201,7 @@ Full checklist, folder tree and release automation notes: [`docs/build.md`](docs
|
|
|
1113
1201
|
declarations for `zidan-select` and `zidan-file`, wired into the exports map.
|
|
1114
1202
|
- **Self-hosted minified bundles** — `npm run build` now emits `.min.js` and `.min.css`
|
|
1115
1203
|
for all three builds, so you can ship from your own CDN with the same files npm exports.
|
|
1116
|
-
- **Automated behaviour tests** — `npm test` builds the subsets and runs
|
|
1204
|
+
- **Automated behaviour tests** — `npm test` builds the subsets and runs 42 jsdom suites
|
|
1117
1205
|
covering select, fields, uploads, async validation, pagination, RTL, teardown and both
|
|
1118
1206
|
subset bundles (including their minified copies).
|
|
1119
1207
|
|
|
@@ -1139,9 +1227,9 @@ Full checklist, folder tree and release automation notes: [`docs/build.md`](docs
|
|
|
1139
1227
|
`renderFile` and `zidan:upload-*` events.
|
|
1140
1228
|
- **Date rules** — weekend and blocked-date rules now write into native validity, so
|
|
1141
1229
|
`form.checkValidity()` and third-party validators see them.
|
|
1142
|
-
- **Docs & demo** — new option tables in [`docs/options.md`](docs/options.
|
|
1143
|
-
[`docs/theming.md`](docs/theming.
|
|
1144
|
-
[`docs/validation.md`](docs/validation.
|
|
1230
|
+
- **Docs & demo** — new option tables in [`docs/options.md`](https://akhtar1985.github.io/zidan-select/docs/options.html), token list in
|
|
1231
|
+
[`docs/theming.md`](https://akhtar1985.github.io/zidan-select/docs/theming.html), validation rules in
|
|
1232
|
+
[`docs/validation.md`](https://akhtar1985.github.io/zidan-select/docs/validation-guide.html), and a live event console on the demo page.
|
|
1145
1233
|
|
|
1146
1234
|
The 2.0 API is unchanged; every addition is opt-in.
|
|
1147
1235
|
|
package/dist/file/zidan-file.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* ZidanForm File-only v2.
|
|
2
|
+
* ZidanForm File-only v2.4.1
|
|
3
3
|
* Zero-dependency drag & drop file upload with variants, previews, limits and progress.
|
|
4
4
|
* Pairs with plugin-file-core.css and plugin-file-theme.css.
|
|
5
5
|
*
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
})(typeof window !== 'undefined' ? window : this, function (global) {
|
|
30
30
|
'use strict';
|
|
31
31
|
|
|
32
|
-
var VERSION = '2.
|
|
32
|
+
var VERSION = '2.4.1';
|
|
33
33
|
|
|
34
34
|
// Loading the file twice (classic script + module wrapper, or two bundles)
|
|
35
35
|
// must not replace the classes and orphan the live instances.
|