zidan-select 2.3.1 → 2.4.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/README.md +147 -68
- 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 +57 -37
- package/docs/html-and-wordpress.md +20 -20
- package/docs/index.html +12 -8
- package/docs/options.md +32 -0
- package/package.json +3 -2
- package/plugin-core.css +1 -1
- package/plugin-theme.css +1 -1
- package/zidan-form.d.ts +18 -0
- 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
|
|
|
@@ -28,9 +28,9 @@ bundle.
|
|
|
28
28
|
|
|
29
29
|
| Build | JavaScript (CDN) | CSS (CDN) |
|
|
30
30
|
| --- | --- | --- |
|
|
31
|
-
| Full — every control | [zidan-form.js](https://cdn.jsdelivr.net/npm/zidan-select@2.
|
|
32
|
-
| Select-only — ≈104 kB | [zidan-select.js](https://cdn.jsdelivr.net/npm/zidan-select@2.
|
|
33
|
-
| File-only — ≈82 kB | [zidan-file.js](https://cdn.jsdelivr.net/npm/zidan-select@2.
|
|
31
|
+
| Full — every control | [zidan-form.js](https://cdn.jsdelivr.net/npm/zidan-select@2.4.0/zidan-form.js) | [plugin-core.css](https://cdn.jsdelivr.net/npm/zidan-select@2.4.0/plugin-core.css) + [plugin-theme.css](https://cdn.jsdelivr.net/npm/zidan-select@2.4.0/plugin-theme.css) |
|
|
32
|
+
| Select-only — ≈104 kB | [zidan-select.js](https://cdn.jsdelivr.net/npm/zidan-select@2.4.0/dist/select/zidan-select.js) | [plugin-select-core.css](https://cdn.jsdelivr.net/npm/zidan-select@2.4.0/dist/select/plugin-select-core.css) + [plugin-select-theme.css](https://cdn.jsdelivr.net/npm/zidan-select@2.4.0/dist/select/plugin-select-theme.css) |
|
|
33
|
+
| File-only — ≈82 kB | [zidan-file.js](https://cdn.jsdelivr.net/npm/zidan-select@2.4.0/dist/file/zidan-file.js) | [plugin-file-core.css](https://cdn.jsdelivr.net/npm/zidan-select@2.4.0/dist/file/plugin-file-core.css) + [plugin-file-theme.css](https://cdn.jsdelivr.net/npm/zidan-select@2.4.0/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
|
|
@@ -47,9 +47,9 @@ the pinned version:
|
|
|
47
47
|
|
|
48
48
|
| Build | JS (min) | CSS (min) |
|
|
49
49
|
| --- | --- | --- |
|
|
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.
|
|
50
|
+
| Full | [zidan-form.min.js](https://cdn.jsdelivr.net/npm/zidan-select@2.4.0/dist/zidan-form.min.js) | [plugin-core.min.css](https://cdn.jsdelivr.net/npm/zidan-select@2.4.0/dist/plugin-core.min.css) + [plugin-theme.min.css](https://cdn.jsdelivr.net/npm/zidan-select@2.4.0/dist/plugin-theme.min.css) |
|
|
51
|
+
| Select-only | [zidan-select.min.js](https://cdn.jsdelivr.net/npm/zidan-select@2.4.0/dist/select/zidan-select.min.js) | [plugin-select-core.min.css](https://cdn.jsdelivr.net/npm/zidan-select@2.4.0/dist/select/plugin-select-core.min.css) + [plugin-select-theme.min.css](https://cdn.jsdelivr.net/npm/zidan-select@2.4.0/dist/select/plugin-select-theme.min.css) |
|
|
52
|
+
| File-only | [zidan-file.min.js](https://cdn.jsdelivr.net/npm/zidan-select@2.4.0/dist/file/zidan-file.min.js) | [plugin-file-core.min.css](https://cdn.jsdelivr.net/npm/zidan-select@2.4.0/dist/file/plugin-file-core.min.css) + [plugin-file-theme.min.css](https://cdn.jsdelivr.net/npm/zidan-select@2.4.0/dist/file/plugin-file-theme.min.css) |
|
|
53
53
|
|
|
54
54
|
- **One file of JS** — `zidan-form.js` (classic script, UMD-ish) + `zidan-form.mjs` (ESM wrapper).
|
|
55
55
|
- **Split CSS** — `plugin-core.css` (structure only) and `plugin-theme.css` (tokens, presets, skins).
|
|
@@ -118,7 +118,7 @@ the same two stylesheets and no dependencies.
|
|
|
118
118
|
**Trade-offs:** smaller community than Select2, no React/Vue component package, and for very
|
|
119
119
|
complex comboboxes (tokenized multi-search, drag-reorder tag editors) Select2 or Tom Select
|
|
120
120
|
still have deeper ecosystems. Full matrix, honest limitations and migration notes:
|
|
121
|
-
**[`docs/comparison.md`](docs/comparison.
|
|
121
|
+
**[`docs/comparison.md`](https://akhtar1985.github.io/zidan-select/docs/comparison.html)**.
|
|
122
122
|
|
|
123
123
|
---
|
|
124
124
|
|
|
@@ -131,24 +131,25 @@ still have deeper ecosystems. Full matrix, honest limitations and migration note
|
|
|
131
131
|
5. [Quick start](#quick-start)
|
|
132
132
|
6. [Input types](#input-types)
|
|
133
133
|
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. [
|
|
134
|
+
8. [Remote data (AJAX)](#remote-data-ajax-selects)
|
|
135
|
+
9. [JavaScript API](#javascript-api)
|
|
136
|
+
10. [Themes, layouts & frameworks](#themes-layouts--frameworks)
|
|
137
|
+
11. [Validation libraries](#validation-libraries)
|
|
138
|
+
12. [Form lifecycle & state sync](#form-lifecycle--state-sync)
|
|
139
|
+
13. [React, Next.js, Vue, Angular](#react-nextjs-vue-angular)
|
|
140
|
+
14. [Build & publish](#build--publish)
|
|
141
|
+
15. [Browser support](#browser-support)
|
|
142
|
+
16. [What's new in 2.1–2.3](#whats-new-in-213)
|
|
143
|
+
17. [Migrating from 1.x](#migrating-from-1x)
|
|
143
144
|
|
|
144
145
|
---
|
|
145
146
|
|
|
146
147
|
## Live demo
|
|
147
148
|
|
|
148
|
-
[](https://akhtar1985.github.io/zidan-select/)
|
|
149
|
+
[](https://akhtar1985.github.io/zidan-select/)
|
|
149
150
|
|
|
150
151
|
**Demo:** <https://akhtar1985.github.io/zidan-select/> — deployed from `main` by
|
|
151
|
-
[`.github/workflows/pages.yml`](.github/workflows/pages.yml) on every push.
|
|
152
|
+
[`.github/workflows/pages.yml`](https://github.com/akhtar1985/zidan-select/blob/main/.github/workflows/pages.yml) on every push.
|
|
152
153
|
|
|
153
154
|
Deep links open the matching tab:
|
|
154
155
|
|
|
@@ -168,7 +169,11 @@ A mock **Shopify product page** — variant combobox, quantity stepper, gift-wra
|
|
|
168
169
|
radios, upload dropzone and the Liquid install snippets — runs at
|
|
169
170
|
<https://akhtar1985.github.io/zidan-select/shopify.html>.
|
|
170
171
|
|
|
171
|
-
|
|
172
|
+
A dedicated **[AJAX & remote data demo](https://akhtar1985.github.io/zidan-select/ajax.html)** wires
|
|
173
|
+
`data-zidan-fetch-url` to a real API and shows the hand-written `fetchOptions` contract with live
|
|
174
|
+
paging, abort and cache state.
|
|
175
|
+
|
|
176
|
+
Below the tabs sits the **[controls reference]**(https://akhtar1985.github.io/zidan-select/#controls)**
|
|
172
177
|
— all nine control families on one page with the options you reach for most, the two ways to
|
|
173
178
|
initialise a field and copyable examples, linking into the playground for the rest.
|
|
174
179
|
|
|
@@ -235,13 +240,13 @@ override presets.
|
|
|
235
240
|
|
|
236
241
|
Copyable URLs for the published files (pin the version in production):
|
|
237
242
|
|
|
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.
|
|
243
|
+
- `zidan-form.js` — <https://cdn.jsdelivr.net/npm/zidan-select@2.4.0/zidan-form.js>
|
|
244
|
+
- `zidan-form.min.js` — <https://cdn.jsdelivr.net/npm/zidan-select@2.4.0/dist/zidan-form.min.js>
|
|
245
|
+
- `zidan-form.mjs` — <https://cdn.jsdelivr.net/npm/zidan-select@2.4.0/zidan-form.mjs>
|
|
246
|
+
- `plugin-core.css` — <https://cdn.jsdelivr.net/npm/zidan-select@2.4.0/plugin-core.css>
|
|
247
|
+
- `plugin-core.min.css` — <https://cdn.jsdelivr.net/npm/zidan-select@2.4.0/dist/plugin-core.min.css>
|
|
248
|
+
- `plugin-theme.css` — <https://cdn.jsdelivr.net/npm/zidan-select@2.4.0/plugin-theme.css>
|
|
249
|
+
- `plugin-theme.min.css` — <https://cdn.jsdelivr.net/npm/zidan-select@2.4.0/dist/plugin-theme.min.css>
|
|
245
250
|
- npm package — <https://www.npmjs.com/package/zidan-select>
|
|
246
251
|
- Source — <https://github.com/akhtar1985/zidan-select>
|
|
247
252
|
|
|
@@ -262,27 +267,27 @@ exactly like the full build.
|
|
|
262
267
|
|
|
263
268
|
Copyable CDN URLs (pin the version):
|
|
264
269
|
|
|
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.
|
|
270
|
+
- `zidan-select.js` — <https://cdn.jsdelivr.net/npm/zidan-select@2.4.0/dist/select/zidan-select.js>
|
|
271
|
+
- `zidan-select.min.js` — <https://cdn.jsdelivr.net/npm/zidan-select@2.4.0/dist/select/zidan-select.min.js>
|
|
272
|
+
- `zidan-select.mjs` — <https://cdn.jsdelivr.net/npm/zidan-select@2.4.0/dist/select/zidan-select.mjs>
|
|
273
|
+
- `plugin-select-core.css` — <https://cdn.jsdelivr.net/npm/zidan-select@2.4.0/dist/select/plugin-select-core.css>
|
|
274
|
+
- `plugin-select-core.min.css` — <https://cdn.jsdelivr.net/npm/zidan-select@2.4.0/dist/select/plugin-select-core.min.css>
|
|
275
|
+
- `plugin-select-theme.css` — <https://cdn.jsdelivr.net/npm/zidan-select@2.4.0/dist/select/plugin-select-theme.css>
|
|
276
|
+
- `plugin-select-theme.min.css` — <https://cdn.jsdelivr.net/npm/zidan-select@2.4.0/dist/select/plugin-select-theme.min.css>
|
|
277
|
+
- `zidan-file.js` — <https://cdn.jsdelivr.net/npm/zidan-select@2.4.0/dist/file/zidan-file.js>
|
|
278
|
+
- `zidan-file.min.js` — <https://cdn.jsdelivr.net/npm/zidan-select@2.4.0/dist/file/zidan-file.min.js>
|
|
279
|
+
- `zidan-file.mjs` — <https://cdn.jsdelivr.net/npm/zidan-select@2.4.0/dist/file/zidan-file.mjs>
|
|
280
|
+
- `plugin-file-core.css` — <https://cdn.jsdelivr.net/npm/zidan-select@2.4.0/dist/file/plugin-file-core.css>
|
|
281
|
+
- `plugin-file-core.min.css` — <https://cdn.jsdelivr.net/npm/zidan-select@2.4.0/dist/file/plugin-file-core.min.css>
|
|
282
|
+
- `plugin-file-theme.css` — <https://cdn.jsdelivr.net/npm/zidan-select@2.4.0/dist/file/plugin-file-theme.css>
|
|
283
|
+
- `plugin-file-theme.min.css` — <https://cdn.jsdelivr.net/npm/zidan-select@2.4.0/dist/file/plugin-file-theme.min.css>
|
|
279
284
|
|
|
280
285
|
Select / combobox / tags only (≈104 kB JS, ≈12 kB core CSS, ≈32 kB theme CSS):
|
|
281
286
|
|
|
282
287
|
```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.
|
|
288
|
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/zidan-select@2.4.0/dist/select/plugin-select-core.css">
|
|
289
|
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/zidan-select@2.4.0/dist/select/plugin-select-theme.css">
|
|
290
|
+
<script src="https://cdn.jsdelivr.net/npm/zidan-select@2.4.0/dist/select/zidan-select.js"></script>
|
|
286
291
|
<script>
|
|
287
292
|
// auto-init covers [data-zidan-select], class="zidan-select", zidan-form scopes
|
|
288
293
|
// and ZIDAN_FORM_CONFIG targets; JS-only options:
|
|
@@ -293,9 +298,9 @@ Select / combobox / tags only (≈104 kB JS, ≈12 kB core CSS, ≈32 kB theme C
|
|
|
293
298
|
File upload only (≈82 kB JS, ≈9 kB core CSS, ≈34 kB theme CSS):
|
|
294
299
|
|
|
295
300
|
```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.
|
|
301
|
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/zidan-select@2.4.0/dist/file/plugin-file-core.css">
|
|
302
|
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/zidan-select@2.4.0/dist/file/plugin-file-theme.css">
|
|
303
|
+
<script src="https://cdn.jsdelivr.net/npm/zidan-select@2.4.0/dist/file/zidan-file.js"></script>
|
|
299
304
|
<script>
|
|
300
305
|
zidanField('#upload', { variant: 'dropzone', upload: '/api/files' });
|
|
301
306
|
</script>
|
|
@@ -318,7 +323,7 @@ targets apply.
|
|
|
318
323
|
## Quick start
|
|
319
324
|
|
|
320
325
|
> Building a plain HTML page, a WordPress site or a page-builder embed? The
|
|
321
|
-
> [static HTML & WordPress cookbook](docs/html-and-wordpress.
|
|
326
|
+
> [static HTML & WordPress cookbook](https://akhtar1985.github.io/zidan-select/docs/html-and-wordpress.html) has complete copy-paste pages
|
|
322
327
|
> (full, select-only, file-only, ID/class targeting, `functions.php` enqueue).
|
|
323
328
|
|
|
324
329
|
```html
|
|
@@ -413,7 +418,7 @@ the select build enhances selects, the file build enhances file inputs; both und
|
|
|
413
418
|
same config keys, marker classes and JSON attribute.
|
|
414
419
|
|
|
415
420
|
Windows/macOS keyboard behaviour, grouping, search and all select features live in
|
|
416
|
-
[`docs/options.md`](docs/options.
|
|
421
|
+
[`docs/options.md`](https://akhtar1985.github.io/zidan-select/docs/options.html).
|
|
417
422
|
|
|
418
423
|
### JavaScript init: one select by ID or class
|
|
419
424
|
|
|
@@ -428,7 +433,7 @@ argument to `zidanSelect()`:
|
|
|
428
433
|
</select>
|
|
429
434
|
|
|
430
435
|
<!-- select-only build; use zidan-form.js for every control -->
|
|
431
|
-
<script src="https://cdn.jsdelivr.net/npm/zidan-select@2.
|
|
436
|
+
<script src="https://cdn.jsdelivr.net/npm/zidan-select@2.4.0/dist/select/zidan-select.js"></script>
|
|
432
437
|
<script>
|
|
433
438
|
const picker = zidanSelect('#mymov', {
|
|
434
439
|
mode: 'combobox', // 'select' | 'combobox' | 'tags'
|
|
@@ -473,8 +478,8 @@ The file-only build uses the same targeted pattern: `zidanField('#upload', { var
|
|
|
473
478
|
accept: 'image/*', maxFiles: 4 })` and `zidanField('.upload-field', options)`.
|
|
474
479
|
|
|
475
480
|
Every option in JavaScript form — with defaults, callbacks and rendering hooks — is in
|
|
476
|
-
[Select options](docs/options.
|
|
477
|
-
[File upload](docs/options.
|
|
481
|
+
[Select options](https://akhtar1985.github.io/zidan-select/docs/options.html#select-options) and
|
|
482
|
+
[File upload](https://akhtar1985.github.io/zidan-select/docs/options.html#file-upload-variants-uploading--rendering). Try the editable
|
|
478
483
|
options object live in the demo's **Select** tab →
|
|
479
484
|
[Direct JS init](https://akhtar1985.github.io/zidan-select/#select).
|
|
480
485
|
|
|
@@ -769,7 +774,7 @@ per field; clickable icons call `input.showPicker()` when available.
|
|
|
769
774
|
|
|
770
775
|
### Select options
|
|
771
776
|
|
|
772
|
-
See [`docs/options.md`](docs/options.
|
|
777
|
+
See [`docs/options.md`](https://akhtar1985.github.io/zidan-select/docs/options.html) for the complete table (`mode`, `layout`,
|
|
773
778
|
`themeFramework`, `searchable`, `clearable`, `multiple`, `maxTags`, `suggestions`,
|
|
774
779
|
`fetchOptions`, `debounce`, `minChars`, callbacks, `customClasses`, `scrollbar`, …).
|
|
775
780
|
|
|
@@ -788,6 +793,69 @@ Three behaviours that are easy to miss:
|
|
|
788
793
|
|
|
789
794
|
---
|
|
790
795
|
|
|
796
|
+
## Remote data (AJAX selects)
|
|
797
|
+
|
|
798
|
+
Two ways to load options over HTTP. Both give you debounce, an `AbortSignal` per request, an LRU
|
|
799
|
+
cache, a **Load more** footer, error retry and the same events.
|
|
800
|
+
|
|
801
|
+
**1. Markup only** — one attribute builds the request:
|
|
802
|
+
|
|
803
|
+
```html
|
|
804
|
+
<select name="product"
|
|
805
|
+
data-zidan-select="combobox"
|
|
806
|
+
data-zidan-fetch-url="/api/products/search"
|
|
807
|
+
data-zidan-fetch-items-path="data.items"
|
|
808
|
+
data-zidan-fetch-total-path="data.total"
|
|
809
|
+
data-zidan-fetch-skip-param="skip"
|
|
810
|
+
data-zidan-fetch-page-size="20">
|
|
811
|
+
</select>
|
|
812
|
+
```
|
|
813
|
+
|
|
814
|
+
That requests `GET /api/products/search?q=…&limit=20&skip=0`, then `skip=20` for the next page,
|
|
815
|
+
and stops once `skip + limit >= data.total`.
|
|
816
|
+
|
|
817
|
+
**2. JavaScript** — `fetchOptions` when the request or the response shape is yours:
|
|
818
|
+
|
|
819
|
+
```js
|
|
820
|
+
const picker = zidanSelect('#owner', {
|
|
821
|
+
mode: 'combobox',
|
|
822
|
+
fetchPageSize: 20,
|
|
823
|
+
fetchOptions: async (query, signal, { page, pageSize }) => {
|
|
824
|
+
const res = await fetch('/api/users?q=' + encodeURIComponent(query)
|
|
825
|
+
+ '&page=' + page + '&size=' + pageSize, { signal });
|
|
826
|
+
const data = await res.json();
|
|
827
|
+
return {
|
|
828
|
+
items: data.rows.map(u => ({ value: u.id, label: u.name })),
|
|
829
|
+
hasMore: data.page + 1 < data.pages
|
|
830
|
+
};
|
|
831
|
+
}
|
|
832
|
+
});
|
|
833
|
+
```
|
|
834
|
+
|
|
835
|
+
| Option | Default | Notes |
|
|
836
|
+
| --- | --- | --- |
|
|
837
|
+
| `fetchUrl` | `null` | Endpoint for the declarative mode (`data-zidan-fetch-url`). |
|
|
838
|
+
| `fetchOptions(query, signal, context)` | — | Return an array, `{ items, hasMore }` or `{ items, total }`; `context` is `{ page, pageSize, append, instance }`. |
|
|
839
|
+
| `fetchPageSize` | `0` | Rows per request; a value above `0` enables paging and the load-more footer. |
|
|
840
|
+
| `fetchQueryParam` | `'q'` | Parameter that carries the search term (`''` omits it). |
|
|
841
|
+
| `fetchPageParam` | `'page'` | 1-based page parameter (`''` omits it). |
|
|
842
|
+
| `fetchSkipParam` | `null` | Send `skip = page × pageSize` instead — for dummyjson/Laravel-style APIs. |
|
|
843
|
+
| `fetchPageSizeParam` | `'limit'` | Parameter that carries `fetchPageSize`. |
|
|
844
|
+
| `fetchItemsPath`, `fetchTotalPath`, `fetchHasMorePath` | `null` | Dot paths into the JSON body (`data.items`, `data.total`). |
|
|
845
|
+
| `fetchMethod`, `fetchHeaders`, `fetchCredentials` | `'GET'`, `null`, `'same-origin'` | Request tuning (JavaScript only). |
|
|
846
|
+
| `debounce`, `minChars` | `250`, `0` | When typing starts a request. |
|
|
847
|
+
| `cacheResults`, `autoLoadMore`, `loadMoreText` | `true`, `true`, `Load more` | Paging behaviour. |
|
|
848
|
+
|
|
849
|
+
Rows map without a mapping function: `value`/`label`, or `id`/`slug`/`code` plus
|
|
850
|
+
`name`/`title`/`full_name`. Instance helpers: `loadMore()`, `hasMoreResults()`,
|
|
851
|
+
`getAsyncState()`, `refreshOptions()`, `clearCache()`; events: `zidan:load-more`, `zidan:error`.
|
|
852
|
+
|
|
853
|
+
**[Live AJAX demo](https://akhtar1985.github.io/zidan-select/ajax.html)** — one card uses the
|
|
854
|
+
attributes above against a public API, the other a hand-written `fetchOptions`, with paging,
|
|
855
|
+
abort and cache state on screen.
|
|
856
|
+
|
|
857
|
+
---
|
|
858
|
+
|
|
791
859
|
## JavaScript API
|
|
792
860
|
|
|
793
861
|
```js
|
|
@@ -877,7 +945,7 @@ Custom theme — no build step, core never changes:
|
|
|
877
945
|
}
|
|
878
946
|
```
|
|
879
947
|
|
|
880
|
-
Token list, preset details and layout notes: [`docs/theming.md`](docs/theming.
|
|
948
|
+
Token list, preset details and layout notes: [`docs/theming.md`](https://akhtar1985.github.io/zidan-select/docs/theming.html).
|
|
881
949
|
|
|
882
950
|
### Layouts
|
|
883
951
|
|
|
@@ -972,8 +1040,8 @@ form.addEventListener('submit', event => {
|
|
|
972
1040
|
});
|
|
973
1041
|
```
|
|
974
1042
|
|
|
975
|
-
Full recipes: [`docs/validation.md`](docs/validation.
|
|
976
|
-
libraries next to a native form ships as [`docs/validation.html`](docs/validation.html).
|
|
1043
|
+
Full recipes: [`docs/validation.md`](https://akhtar1985.github.io/zidan-select/docs/validation-guide.html). A runnable page that loads all three
|
|
1044
|
+
libraries next to a native form ships as [`docs/validation.html`](https://akhtar1985.github.io/zidan-select/docs/validation.html).
|
|
977
1045
|
|
|
978
1046
|
---
|
|
979
1047
|
|
|
@@ -1008,7 +1076,7 @@ Short version: initialise after mount, call `destroy()` before unmount, push sta
|
|
|
1008
1076
|
be controlled through the instance, because the plugin owns the visible trigger.
|
|
1009
1077
|
|
|
1010
1078
|
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.
|
|
1079
|
+
`onMounted`, Angular `ngAfterViewInit` + `ControlValueAccessor` notes): [`docs/frameworks.md`](https://akhtar1985.github.io/zidan-select/docs/frameworks.html).
|
|
1012
1080
|
|
|
1013
1081
|
Next.js CSS imports:
|
|
1014
1082
|
|
|
@@ -1057,6 +1125,7 @@ npm run build # dist/ (+ local .min files when esbuild is installed)
|
|
|
1057
1125
|
| `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 19 jsdom behaviour suites. |
|
|
1058
1126
|
| `scripts/dom/run.mjs` | jsdom suites for select, fields, uploads, async validation, pagination, RTL, teardown, and the select-only/file-only/minified bundles. |
|
|
1059
1127
|
| `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. |
|
|
1128
|
+
| `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
1129
|
|
|
1061
1130
|
`exa-js` is a dev dependency only, so the published bundle stays dependency-free.
|
|
1062
1131
|
|
|
@@ -1064,19 +1133,29 @@ npm run build # dist/ (+ local .min files when esbuild is installed)
|
|
|
1064
1133
|
files into `dist/` (including both subset folders), so the URLs above work on unpkg, a
|
|
1065
1134
|
self-hosted CDN or jsDelivr without relying on the CDN's auto-minification.
|
|
1066
1135
|
|
|
1067
|
-
|
|
1136
|
+
Releasing is one command:
|
|
1068
1137
|
|
|
1069
1138
|
```bash
|
|
1070
|
-
npm
|
|
1071
|
-
|
|
1072
|
-
npm publish # `files` limits the tarball to JS, CSS, dist, docs, README, LICENSE
|
|
1073
|
-
git push --follow-tags
|
|
1139
|
+
npm run release -- patch --note "Fix the thing that broke" # or minor / major / 2.3.2
|
|
1140
|
+
git push origin main --follow-tags
|
|
1074
1141
|
```
|
|
1075
1142
|
|
|
1143
|
+
`scripts/release.mjs` writes the version into `package.json`, `package-lock.json`, the JS banner
|
|
1144
|
+
and `VERSION`, both CSS banners, the README CDN URLs, the demo pages and the docs; moves
|
|
1145
|
+
`## [Unreleased]` in [`CHANGELOG.md`](https://github.com/akhtar1985/zidan-select/blob/main/CHANGELOG.md) under a dated heading; runs the type check and
|
|
1146
|
+
`npm test`; then commits `Release X.Y.Z` and creates the annotated tag `vX.Y.Z`.
|
|
1147
|
+
`npm run release -- --dry-run` prints the plan without writing anything.
|
|
1148
|
+
|
|
1149
|
+
Pushing the tag runs [`.github/workflows/release.yml`](https://github.com/akhtar1985/zidan-select/blob/main/.github/workflows/release.yml), which
|
|
1150
|
+
publishes to npm through **trusted publishing** (OIDC) with `--provenance` — no token and no local
|
|
1151
|
+
`npm login`, and every tarball carries a provenance attestation. Prereleases go to the `next`
|
|
1152
|
+
dist-tag. The workflow refuses a tag that disagrees with `package.json` and refuses to republish a
|
|
1153
|
+
version that already exists on the registry. History lives in [`CHANGELOG.md`](https://github.com/akhtar1985/zidan-select/blob/main/CHANGELOG.md).
|
|
1154
|
+
|
|
1076
1155
|
GitHub Pages serves the repo root: the demo is `index.html` (no build needed), docs live in
|
|
1077
1156
|
`docs/`. Release notes should list theme/layout additions and any token renames.
|
|
1078
1157
|
|
|
1079
|
-
Full checklist, folder tree and release automation notes: [`docs/build.md`](docs/build.
|
|
1158
|
+
Full checklist, folder tree and release automation notes: [`docs/build.md`](https://akhtar1985.github.io/zidan-select/docs/build.html).
|
|
1080
1159
|
|
|
1081
1160
|
---
|
|
1082
1161
|
|
|
@@ -1095,7 +1174,7 @@ Full checklist, folder tree and release automation notes: [`docs/build.md`](docs
|
|
|
1095
1174
|
|
|
1096
1175
|
## What's new in 2.1–2.3
|
|
1097
1176
|
|
|
1098
|
-
**2.
|
|
1177
|
+
**2.4.0** adds the capabilities that were previously the library's biggest gaps:
|
|
1099
1178
|
|
|
1100
1179
|
- **Async validation** — `validate` and `validateDate` may return a Promise. Fields get a
|
|
1101
1180
|
`.zs-field--pending` spinner and `aria-busy`, block form submission through native validity,
|
|
@@ -1139,9 +1218,9 @@ Full checklist, folder tree and release automation notes: [`docs/build.md`](docs
|
|
|
1139
1218
|
`renderFile` and `zidan:upload-*` events.
|
|
1140
1219
|
- **Date rules** — weekend and blocked-date rules now write into native validity, so
|
|
1141
1220
|
`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.
|
|
1221
|
+
- **Docs & demo** — new option tables in [`docs/options.md`](https://akhtar1985.github.io/zidan-select/docs/options.html), token list in
|
|
1222
|
+
[`docs/theming.md`](https://akhtar1985.github.io/zidan-select/docs/theming.html), validation rules in
|
|
1223
|
+
[`docs/validation.md`](https://akhtar1985.github.io/zidan-select/docs/validation-guide.html), and a live event console on the demo page.
|
|
1145
1224
|
|
|
1146
1225
|
The 2.0 API is unchanged; every addition is opt-in.
|
|
1147
1226
|
|
package/dist/file/zidan-file.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* ZidanForm File-only v2.
|
|
2
|
+
* ZidanForm File-only v2.4.0
|
|
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.0';
|
|
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.
|