zidan-select 2.2.0 → 2.2.2

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 CHANGED
@@ -10,6 +10,47 @@ two separate stylesheets.
10
10
  [![docs](https://img.shields.io/badge/docs-options%20%7C%20API%20%7C%20theming-6b7280)](docs/options.md)
11
11
  [![license](https://img.shields.io/badge/license-MIT-22c55e)](LICENSE)
12
12
 
13
+ ## Which files should you load?
14
+
15
+ > **You do not need to load everything.** Each build is complete and standalone — pick the one
16
+ > that matches your page. The full bundle is only for forms that enhance several inputs at once.
17
+
18
+ - **Only custom select dropdowns** — load **only** the select build's JavaScript and CSS. You do
19
+ not need the full form bundle if you only want styled `<select>` elements.
20
+ - **Only file upload inputs** — load **only** the file upload build's JavaScript and CSS if you
21
+ only want custom file pickers and want the rest of your form left untouched.
22
+ - **All form inputs at once** — load the **complete form bundle** (full JavaScript and CSS) to
23
+ style and enhance every supported input across your form: text fields, selects, file uploads,
24
+ checkboxes and radios.
25
+
26
+ Load **one** build per page. A subset is not an add-on: never load it together with the full
27
+ bundle.
28
+
29
+ | Build | JavaScript (CDN) | CSS (CDN) |
30
+ | --- | --- | --- |
31
+ | Full — every control | [zidan-form.js](https://cdn.jsdelivr.net/npm/zidan-select@2.2.2/zidan-form.js) | [plugin-core.css](https://cdn.jsdelivr.net/npm/zidan-select@2.2.2/plugin-core.css) + [plugin-theme.css](https://cdn.jsdelivr.net/npm/zidan-select@2.2.2/plugin-theme.css) |
32
+ | Select-only — ≈95 kB | [zidan-select.js](https://cdn.jsdelivr.net/npm/zidan-select@2.2.2/dist/select/zidan-select.js) | [plugin-select-core.css](https://cdn.jsdelivr.net/npm/zidan-select@2.2.2/dist/select/plugin-select-core.css) + [plugin-select-theme.css](https://cdn.jsdelivr.net/npm/zidan-select@2.2.2/dist/select/plugin-select-theme.css) |
33
+ | File-only — ≈76 kB | [zidan-file.js](https://cdn.jsdelivr.net/npm/zidan-select@2.2.2/dist/file/zidan-file.js) | [plugin-file-core.css](https://cdn.jsdelivr.net/npm/zidan-select@2.2.2/dist/file/plugin-file-core.css) + [plugin-file-theme.css](https://cdn.jsdelivr.net/npm/zidan-select@2.2.2/dist/file/plugin-file-theme.css) |
34
+
35
+ Copyable snippets, ESM files and per-file sizes live in
36
+ [Select-only and file-only builds](#select-only-and-file-only-builds); the
37
+ [live demo](https://akhtar1985.github.io/zidan-select/#builds) shows all three side by side.
38
+
39
+ **Build a field visually:** the [field playground](https://akhtar1985.github.io/zidan-select/playground.html)
40
+ toggles every option for one control, previews it live and copies the matching HTML attributes or
41
+ vanilla JavaScript.
42
+
43
+ ### Minified CDN URLs
44
+
45
+ jsDelivr minifies these on request from the published sources, so the `.min` files always match
46
+ the pinned version:
47
+
48
+ | Build | JS (min) | CSS (min) |
49
+ | --- | --- | --- |
50
+ | Full | [zidan-form.min.js](https://cdn.jsdelivr.net/npm/zidan-select@2.2.2/zidan-form.min.js) | [plugin-core.min.css](https://cdn.jsdelivr.net/npm/zidan-select@2.2.2/plugin-core.min.css) + [plugin-theme.min.css](https://cdn.jsdelivr.net/npm/zidan-select@2.2.2/plugin-theme.min.css) |
51
+ | Select-only | [zidan-select.min.js](https://cdn.jsdelivr.net/npm/zidan-select@2.2.2/dist/select/zidan-select.min.js) | [plugin-select-core.min.css](https://cdn.jsdelivr.net/npm/zidan-select@2.2.2/dist/select/plugin-select-core.min.css) + [plugin-select-theme.min.css](https://cdn.jsdelivr.net/npm/zidan-select@2.2.2/dist/select/plugin-select-theme.min.css) |
52
+ | File-only | [zidan-file.min.js](https://cdn.jsdelivr.net/npm/zidan-select@2.2.2/dist/file/zidan-file.min.js) | [plugin-file-core.min.css](https://cdn.jsdelivr.net/npm/zidan-select@2.2.2/dist/file/plugin-file-core.min.css) + [plugin-file-theme.min.css](https://cdn.jsdelivr.net/npm/zidan-select@2.2.2/dist/file/plugin-file-theme.min.css) |
53
+
13
54
  - **One file of JS** — `zidan-form.js` (classic script, UMD-ish) + `zidan-form.mjs` (ESM wrapper).
14
55
  - **Split CSS** — `plugin-core.css` (structure only) and `plugin-theme.css` (tokens, presets, skins).
15
56
  - **Opt-in per control** — nothing is touched unless it carries a `data-zidan*` attribute or is
@@ -168,14 +209,18 @@ override presets.
168
209
  | `dist/select/` | Select-only build: `zidan-select.js`, `zidan-select.mjs`, `plugin-select-core.css`, `plugin-select-theme.css`. |
169
210
  | `dist/file/` | File-only build: `zidan-file.js`, `zidan-file.mjs`, `plugin-file-core.css`, `plugin-file-theme.css`. |
170
211
  | `index.html`, `demo.css`, `demo.js` | The tabbed demo / theme showcase (not shipped logic). |
212
+ | `playground.html`, `playground.css`, `playground.js` | Per-field option builder with live preview and copyable HTML / JS output (not shipped logic). |
171
213
  | `docs/` | Comparison, options, validation, frameworks, theming and build guides. |
172
214
 
173
215
  Copyable URLs for the published files (pin the version in production):
174
216
 
175
- - `zidan-form.js` — <https://cdn.jsdelivr.net/npm/zidan-select@2.2.0/zidan-form.js>
176
- - `zidan-form.mjs` — <https://cdn.jsdelivr.net/npm/zidan-select@2.2.0/zidan-form.mjs>
177
- - `plugin-core.css` — <https://cdn.jsdelivr.net/npm/zidan-select@2.2.0/plugin-core.css>
178
- - `plugin-theme.css` — <https://cdn.jsdelivr.net/npm/zidan-select@2.2.0/plugin-theme.css>
217
+ - `zidan-form.js` — <https://cdn.jsdelivr.net/npm/zidan-select@2.2.2/zidan-form.js>
218
+ - `zidan-form.min.js` — <https://cdn.jsdelivr.net/npm/zidan-select@2.2.2/zidan-form.min.js>
219
+ - `zidan-form.mjs` — <https://cdn.jsdelivr.net/npm/zidan-select@2.2.2/zidan-form.mjs>
220
+ - `plugin-core.css` — <https://cdn.jsdelivr.net/npm/zidan-select@2.2.2/plugin-core.css>
221
+ - `plugin-core.min.css` — <https://cdn.jsdelivr.net/npm/zidan-select@2.2.2/plugin-core.min.css>
222
+ - `plugin-theme.css` — <https://cdn.jsdelivr.net/npm/zidan-select@2.2.2/plugin-theme.css>
223
+ - `plugin-theme.min.css` — <https://cdn.jsdelivr.net/npm/zidan-select@2.2.2/plugin-theme.min.css>
179
224
  - npm package — <https://www.npmjs.com/package/zidan-select>
180
225
  - Source — <https://github.com/akhtar1985/zidan-select>
181
226
 
@@ -196,21 +241,27 @@ exactly like the full build.
196
241
 
197
242
  Copyable CDN URLs (pin the version):
198
243
 
199
- - `zidan-select.js` — <https://cdn.jsdelivr.net/npm/zidan-select@2.2.0/dist/select/zidan-select.js>
200
- - `zidan-select.mjs` — <https://cdn.jsdelivr.net/npm/zidan-select@2.2.0/dist/select/zidan-select.mjs>
201
- - `plugin-select-core.css` — <https://cdn.jsdelivr.net/npm/zidan-select@2.2.0/dist/select/plugin-select-core.css>
202
- - `plugin-select-theme.css` — <https://cdn.jsdelivr.net/npm/zidan-select@2.2.0/dist/select/plugin-select-theme.css>
203
- - `zidan-file.js` — <https://cdn.jsdelivr.net/npm/zidan-select@2.2.0/dist/file/zidan-file.js>
204
- - `zidan-file.mjs` — <https://cdn.jsdelivr.net/npm/zidan-select@2.2.0/dist/file/zidan-file.mjs>
205
- - `plugin-file-core.css` — <https://cdn.jsdelivr.net/npm/zidan-select@2.2.0/dist/file/plugin-file-core.css>
206
- - `plugin-file-theme.css` — <https://cdn.jsdelivr.net/npm/zidan-select@2.2.0/dist/file/plugin-file-theme.css>
244
+ - `zidan-select.js` — <https://cdn.jsdelivr.net/npm/zidan-select@2.2.2/dist/select/zidan-select.js>
245
+ - `zidan-select.min.js` — <https://cdn.jsdelivr.net/npm/zidan-select@2.2.2/dist/select/zidan-select.min.js>
246
+ - `zidan-select.mjs` — <https://cdn.jsdelivr.net/npm/zidan-select@2.2.2/dist/select/zidan-select.mjs>
247
+ - `plugin-select-core.css` — <https://cdn.jsdelivr.net/npm/zidan-select@2.2.2/dist/select/plugin-select-core.css>
248
+ - `plugin-select-core.min.css` — <https://cdn.jsdelivr.net/npm/zidan-select@2.2.2/dist/select/plugin-select-core.min.css>
249
+ - `plugin-select-theme.css` — <https://cdn.jsdelivr.net/npm/zidan-select@2.2.2/dist/select/plugin-select-theme.css>
250
+ - `plugin-select-theme.min.css` — <https://cdn.jsdelivr.net/npm/zidan-select@2.2.2/dist/select/plugin-select-theme.min.css>
251
+ - `zidan-file.js` — <https://cdn.jsdelivr.net/npm/zidan-select@2.2.2/dist/file/zidan-file.js>
252
+ - `zidan-file.min.js` — <https://cdn.jsdelivr.net/npm/zidan-select@2.2.2/dist/file/zidan-file.min.js>
253
+ - `zidan-file.mjs` — <https://cdn.jsdelivr.net/npm/zidan-select@2.2.2/dist/file/zidan-file.mjs>
254
+ - `plugin-file-core.css` — <https://cdn.jsdelivr.net/npm/zidan-select@2.2.2/dist/file/plugin-file-core.css>
255
+ - `plugin-file-core.min.css` — <https://cdn.jsdelivr.net/npm/zidan-select@2.2.2/dist/file/plugin-file-core.min.css>
256
+ - `plugin-file-theme.css` — <https://cdn.jsdelivr.net/npm/zidan-select@2.2.2/dist/file/plugin-file-theme.css>
257
+ - `plugin-file-theme.min.css` — <https://cdn.jsdelivr.net/npm/zidan-select@2.2.2/dist/file/plugin-file-theme.min.css>
207
258
 
208
259
  Select / combobox / tags only (≈95 kB JS, ≈12 kB core CSS, ≈32 kB theme CSS):
209
260
 
210
261
  ```html
211
- <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/zidan-select@2.2.0/dist/select/plugin-select-core.css">
212
- <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/zidan-select@2.2.0/dist/select/plugin-select-theme.css">
213
- <script src="https://cdn.jsdelivr.net/npm/zidan-select@2.2.0/dist/select/zidan-select.js"></script>
262
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/zidan-select@2.2.2/dist/select/plugin-select-core.css">
263
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/zidan-select@2.2.2/dist/select/plugin-select-theme.css">
264
+ <script src="https://cdn.jsdelivr.net/npm/zidan-select@2.2.2/dist/select/zidan-select.js"></script>
214
265
  <script>
215
266
  // auto-init covers [data-zidan-select], class="zidan-select", zidan-form scopes
216
267
  // and ZIDAN_FORM_CONFIG targets; JS-only options:
@@ -221,9 +272,9 @@ Select / combobox / tags only (≈95 kB JS, ≈12 kB core CSS, ≈32 kB theme CS
221
272
  File upload only (≈76 kB JS, ≈9 kB core CSS, ≈35 kB theme CSS):
222
273
 
223
274
  ```html
224
- <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/zidan-select@2.2.0/dist/file/plugin-file-core.css">
225
- <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/zidan-select@2.2.0/dist/file/plugin-file-theme.css">
226
- <script src="https://cdn.jsdelivr.net/npm/zidan-select@2.2.0/dist/file/zidan-file.js"></script>
275
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/zidan-select@2.2.2/dist/file/plugin-file-core.css">
276
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/zidan-select@2.2.2/dist/file/plugin-file-theme.css">
277
+ <script src="https://cdn.jsdelivr.net/npm/zidan-select@2.2.2/dist/file/zidan-file.js"></script>
227
278
  <script>
228
279
  zidanField('#upload', { variant: 'dropzone', upload: '/api/files' });
229
280
  </script>
@@ -339,6 +390,69 @@ same config keys, marker classes and JSON attribute.
339
390
  Windows/macOS keyboard behaviour, grouping, search and all select features live in
340
391
  [`docs/options.md`](docs/options.md).
341
392
 
393
+ ### JavaScript init: one select by ID or class
394
+
395
+ You do not need any `data-*` attribute. Pass a selector, an element or a NodeList as the first
396
+ argument to `zidanSelect()`:
397
+
398
+ ```html
399
+ <select id="mymov" name="movie">
400
+ <option value="">Choose a movie…</option>
401
+ <option value="inception" selected>Inception</option>
402
+ <option value="dune">Dune</option>
403
+ </select>
404
+
405
+ <!-- select-only build; use zidan-form.js for every control -->
406
+ <script src="https://cdn.jsdelivr.net/npm/zidan-select@2.2.2/dist/select/zidan-select.js"></script>
407
+ <script>
408
+ const picker = zidanSelect('#mymov', {
409
+ mode: 'combobox', // 'select' | 'combobox' | 'tags'
410
+ label: 'Movie',
411
+ placeholder: 'Search a movie…',
412
+ searchable: true,
413
+ clearable: true,
414
+ maxDropdownHeight: 280,
415
+ noResultsText: 'Nothing matched'
416
+ });
417
+
418
+ // one call for every element with the class; returns an array
419
+ zidanSelect('.mymovclass', { mode: 'select', layout: 'soft-pill' });
420
+ </script>
421
+ ```
422
+
423
+ Plain selects are left alone by auto-init (it only scans `[data-zidan-select]` and
424
+ `.zidan-select`), so this is the clean way to style a single existing field without touching
425
+ its markup. The call returns the instance (or an array for multiple matches).
426
+
427
+ Read the value and the selected `<option>` details:
428
+
429
+ ```js
430
+ picker.getValue(); // 'inception' (array for multiple/tags)
431
+ picker.setValue('dune');
432
+
433
+ const native = document.querySelector('#mymov');
434
+ native.selectedOptions[0]; // the real <option> element
435
+ Array.from(native.selectedOptions).map(option => ({
436
+ value: option.value, label: option.text, disabled: option.disabled
437
+ }));
438
+
439
+ // replace the list (rebuilds the native options too)
440
+ picker.setOptions([
441
+ { value: 'inception', label: 'Inception' },
442
+ { value: 'dune', label: 'Dune', group: 'Villeneuve' },
443
+ { value: 'arrival', label: 'Arrival', disabled: true }
444
+ ]);
445
+ ```
446
+
447
+ The file-only build uses the same targeted pattern: `zidanField('#upload', { variant: 'dropzone',
448
+ accept: 'image/*', maxFiles: 4 })` and `zidanField('.upload-field', options)`.
449
+
450
+ Every option in JavaScript form — with defaults, callbacks and rendering hooks — is in
451
+ [Select options](docs/options.md#select-options) and
452
+ [File upload](docs/options.md#file-upload-variants-uploading--rendering). Try the editable
453
+ options object live in the demo's **Select** tab →
454
+ [Direct JS init](https://akhtar1985.github.io/zidan-select/#select).
455
+
342
456
  ---
343
457
 
344
458
  ## Input types
@@ -879,16 +993,19 @@ The repo is dependency-free and works from source; `npm run build` only assemble
879
993
 
880
994
  ```bash
881
995
  npm run dev # static server → http://localhost:4173
882
- npm test # syntax + split-CSS + API checks (no browser, no deps)
883
- npm run lint # node --check on every script
884
- npm run build # dist/ (+ .min files when esbuild is installed)
996
+ npm test # syntax + split-CSS + API + playground/docs checks (no browser, no deps)
997
+ npm run lint # node --check on every script, playground.js included
998
+ npm run build # dist/ (+ local .min files when esbuild is installed)
885
999
  ```
886
1000
 
887
1001
  | Command | What it does |
888
1002
  | --- | --- |
889
1003
  | `scripts/serve.mjs` | No-dependency demo server on port 4173 (`PORT=8080 npm run dev`). |
890
1004
  | `scripts/build.mjs` | Cleans `dist/`, copies the four assets, writes `dist/zidan-form.cjs`, and minifies with esbuild **if** it is installed. |
891
- | `scripts/test.mjs` | Verifies syntax, that core CSS carries no colour literals, that all presets/adapters exist and the public API is exported. |
1005
+ | `scripts/test.mjs` | Verifies syntax, that core CSS carries no colour literals, that all presets/adapters exist, the public API is exported, and the playground, README and demo stay wired to each other. |
1006
+
1007
+ Minified files on the CDN do not need esbuild: jsDelivr generates `.min.*` from the
1008
+ published sources, so the `@2.2.2` `.min` URLs above stay valid without a local build.
892
1009
 
893
1010
  Publishing:
894
1011
 
@@ -947,6 +1064,19 @@ Full checklist, folder tree and release automation notes: [`docs/build.md`](docs
947
1064
 
948
1065
  The 2.0 API is unchanged; every addition is opt-in.
949
1066
 
1067
+ **2.2.2** adds a per-control [field playground](https://akhtar1985.github.io/zidan-select/playground.html)
1068
+ that previews every option and copies either HTML data attributes or the equivalent vanilla JS,
1069
+ lists the jsDelivr `.min` CDN URLs for all three builds, and states plainly in the README, demo
1070
+ and build guide that a select-only or file-only build is complete on its own — you do not need
1071
+ the full bundle unless one form enhances several input types at once.
1072
+
1073
+ **2.2.1** adds declarative no-JavaScript init — marker classes (`zidan-select`,
1074
+ `zidan-field`, `zidan-form`), ID/CSS targets through `window.ZIDAN_FORM_CONFIG` and
1075
+ `data-zidan-options` JSON — for the full build and both subset bundles, with docs and demo
1076
+ cards. It also restores `getValue()`/`setValue()` on every field, mirrors required-select
1077
+ invalid state to the visible control, rebuilds native options on `setOptions()` and mirrors
1078
+ programmatic range values into `data-zidan-output`.
1079
+
950
1080
  **2.2.0** adds select-only and file-only builds. Each ships a trimmed JS bundle plus matching
951
1081
  core and theme stylesheets, keeps all five preset themes, layouts and the Bootstrap, Tailwind,
952
1082
  Bulma and Foundation adapters, and is generated from the same source by `npm run build`.
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * ZidanForm File-only v2.2.0 — plugin-file-core.css
2
+ * ZidanForm File-only v2.2.2 — plugin-file-core.css
3
3
  * Structure for the file upload control only.
4
4
  * Pairs with zidan-file.js and plugin-file-theme.css.
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * ZidanForm File-only v2.2.0 — plugin-file-theme.css
2
+ * ZidanForm File-only v2.2.2 — plugin-file-theme.css
3
3
  * Tokens, 5 preset themes, field layouts and framework adapters.
4
4
  * Pairs with zidan-file.js and plugin-file-core.css.
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * ZidanForm File-only v2.2.0
2
+ * ZidanForm File-only v2.2.2
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.2.0';
32
+ var VERSION = '2.2.2';
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.
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * ZidanForm Select-only v2.2.0 — plugin-select-core.css
2
+ * ZidanForm Select-only v2.2.2 — plugin-select-core.css
3
3
  * Structure for the select / combobox / tags control only.
4
4
  * Pairs with zidan-select.js and plugin-select-theme.css.
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * ZidanForm Select-only v2.2.0 — plugin-select-theme.css
2
+ * ZidanForm Select-only v2.2.2 — plugin-select-theme.css
3
3
  * Tokens, 5 preset themes, select layouts, scrollbars and framework adapters.
4
4
  * Pairs with zidan-select.js and plugin-select-core.css.
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * ZidanForm Select-only v2.2.0
2
+ * ZidanForm Select-only v2.2.2
3
3
  * Zero-dependency select / combobox / tags enhancement. Every other control family is omitted.
4
4
  * Pairs with plugin-select-core.css and plugin-select-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.2.0';
32
+ var VERSION = '2.2.2';
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.
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * ZidanForm v2.2.0
2
+ * ZidanForm v2.2.2
3
3
  * Zero-dependency form enhancement library: select / combobox / tags,
4
4
  * checkboxes, switches, radio groups, file upload with drag & drop and
5
5
  * upload progress, text / number / phone / date / range inputs and textarea.
@@ -32,7 +32,7 @@
32
32
  })(typeof window !== 'undefined' ? window : this, function (global) {
33
33
  'use strict';
34
34
 
35
- var VERSION = '2.2.0';
35
+ var VERSION = '2.2.2';
36
36
 
37
37
  // Loading the file twice (classic script + module wrapper, or two bundles)
38
38
  // must not replace the classes and orphan the live instances.
package/docs/build.md CHANGED
@@ -13,6 +13,8 @@ zidan-select/
13
13
  ├─ plugin-core.css # structure only
14
14
  ├─ plugin-theme.css # tokens, presets, layouts, framework adapters
15
15
  ├─ index.html # tabbed demo + theme showcase
16
+ ├─ playground.html # per-field option builder
17
+ ├─ playground.css/js # playground-only assets
16
18
  ├─ demo.css / demo.js # demo-only assets
17
19
  ├─ package.json # npm metadata + scripts
18
20
  ├─ scripts/
@@ -24,6 +26,22 @@ zidan-select/
24
26
  └─ LICENSE
25
27
  ```
26
28
 
29
+ ### Which files should you load?
30
+
31
+ **You do not have to load everything.** If the page only needs one control, load only that
32
+ build; the complete form bundle is only for forms that enhance several inputs at once. A subset
33
+ is a standalone build, not an add-on, so never load it together with the full bundle.
34
+
35
+ | If the page only needs… | Load |
36
+ | --- | --- |
37
+ | Custom select dropdowns | `dist/select/zidan-select.js` plus `plugin-select-core.css` and `plugin-select-theme.css`. Every other input stays untouched; the full bundle is not needed. |
38
+ | File uploads | `dist/file/zidan-file.js` plus `plugin-file-core.css` and `plugin-file-theme.css`. The rest of the form is untouched. |
39
+ | Every input at once | `zidan-form.js` plus `plugin-core.css` and `plugin-theme.css`; one `initZidanForms()` call enhances text fields, selects, file uploads, checkboxes and radios together. |
40
+
41
+ Snippets and ESM variants for each row are under
42
+ [Select-only and file-only builds](#select-only-and-file-only-builds); the demo shows all three
43
+ side by side at the [builds section](https://akhtar1985.github.io/zidan-select/#builds).
44
+
27
45
  ## Scripts
28
46
 
29
47
  | Command | Effect |
@@ -66,6 +84,22 @@ npm run build
66
84
  Without esbuild the build still succeeds and prints that minification was skipped. Add
67
85
  `dist/` to `.gitignore`; it is regenerated at publish time.
68
86
 
87
+ ### Minified CDN URLs
88
+
89
+ You do not need esbuild to ship minified files from a CDN. jsDelivr generates `.min.*` on
90
+ request from the published sources, so these URLs track the pinned version even though the npm
91
+ tarball only contains the readable files:
92
+
93
+ | Build | JavaScript | Core CSS | Theme CSS |
94
+ | --- | --- | --- | --- |
95
+ | Full | `/zidan-form.min.js` | `/plugin-core.min.css` | `/plugin-theme.min.css` |
96
+ | Select-only | `/dist/select/zidan-select.min.js` | `/dist/select/plugin-select-core.min.css` | `/dist/select/plugin-select-theme.min.css` |
97
+ | File-only | `/dist/file/zidan-file.min.js` | `/dist/file/plugin-file-core.min.css` | `/dist/file/plugin-file-theme.min.css` |
98
+
99
+ Prepend `https://cdn.jsdelivr.net/npm/zidan-select@2.2.2` to each path. Check the three you use
100
+ with `curl -I` before changing a version, then update the URLs in the README, the demo build
101
+ cards and the playground in the same commit.
102
+
69
103
  ## Select-only and file-only builds
70
104
 
71
105
  `scripts/build.mjs` slices the single source into two smaller distributables. The sections in
@@ -83,7 +117,7 @@ Both theme stylesheets keep the token set, the five preset themes (`default`, `m
83
117
  adapters, so `data-zidan-theme`, `data-zidan-layout` and `data-zidan-framework` behave the same
84
118
  as in the full build.
85
119
 
86
- Approximate v2.2.0 sizes: select ≈95 kB JS + 12 kB core + 32 kB theme; file ≈76 kB JS +
120
+ Approximate v2.2.2 sizes: select ≈95 kB JS + 12 kB core + 32 kB theme; file ≈76 kB JS +
87
121
  9 kB core + 35 kB theme, against ≈194 kB JS + 36 kB core + 47 kB theme for the full build.
88
122
 
89
123
  A page should load **one** flavour: a subset **or** the full build. The `__zidanFormGuard`
@@ -164,16 +198,19 @@ import 'zidan-select/file/css/theme';
164
198
  ## GitHub Pages
165
199
 
166
200
  The demo is static and needs no build. `.github/workflows/pages.yml` assembles `_site/` on every
167
- push to `main` — `index.html`, `demo.css`, `demo.js`, the four library files and `docs/` — then
168
- uploads it with `actions/upload-pages-artifact` and publishes it with `actions/deploy-pages`.
201
+ push to `main` — `index.html`, `playground.html`, `playground.css`, `playground.js`, `demo.css`,
202
+ `demo.js`, the four library files and `docs/` — then uploads it with
203
+ `actions/upload-pages-artifact` and publishes it with `actions/deploy-pages`.
169
204
 
170
205
  One-time setup: **Settings → Pages → Build and deployment → Source: GitHub Actions**.
171
206
 
172
207
  | URL | Serves |
173
208
  | --- | --- |
174
209
  | `https://akhtar1985.github.io/zidan-select/` | The tabbed demo |
210
+ | `https://akhtar1985.github.io/zidan-select/playground.html` | Per-field option playground |
175
211
  | `https://akhtar1985.github.io/zidan-select/docs/` | Documentation index |
176
212
  | `/#select`, `/#check`, `/#file`, `/#inputs`, `/#themes` | Deep links to a demo tab |
213
+ | `/playground.html#select`, `#file`, `#checkbox`, `#radio`, `#text` | Deep links to a playground control |
177
214
 
178
215
  The workflow only copies demo assets, so `scripts/`, `dist/`, `package.json` and local scratch
179
216
  files are never published.
package/docs/index.html CHANGED
@@ -39,14 +39,22 @@
39
39
  <p class="lead">
40
40
  Zero-dependency form enhancement: select, checkbox, switch, radio, file upload, text,
41
41
  number, phone, date and range inputs — with input icons, steppers and upload progress.
42
- Start with the <a href="../index.html">interactive demo</a>, then dive into the
43
- reference.
42
+ Start with the <a href="../index.html">interactive demo</a> or the
43
+ <a href="../playground.html">field playground</a>, then dive into the reference.
44
44
  </p>
45
45
  <a href="../index.html">
46
46
  <img src="demo-inputs.png" alt="Input icons, number stepper, phone formatting and range controls in the ZidanForm demo"
47
47
  style="display:block;width:100%;max-width:640px;margin:0 0 28px;border-radius:14px;border:1px solid #e4e8f1;box-shadow:0 1px 2px rgba(16,19,36,.05)">
48
48
  </a>
49
49
  <ul>
50
+ <li>
51
+ <strong><a href="../playground.html">Field playground</a></strong>
52
+ <span>Pick one control, toggle its options, preview it live and copy the matching HTML attributes or vanilla JavaScript call.</span>
53
+ </li>
54
+ <li>
55
+ <strong><a href="https://github.com/akhtar1985/zidan-select#which-files-should-you-load">Which files should I load?</a></strong>
56
+ <span>Only want a select, or only a file upload? Load only that build — you do not need the full bundle. The complete form JS and CSS is for forms that enhance every input at once.</span>
57
+ </li>
50
58
  <li>
51
59
  <strong><a href="https://github.com/akhtar1985/zidan-select/blob/main/docs/comparison.md">Why ZidanForm &amp; comparison</a></strong>
52
60
  <span>Feature matrix against Select2, Choices.js, Tom Select, Slim Select and Bootstrap, plus benefits, trade-offs and migration notes.</span>
@@ -77,7 +85,8 @@
77
85
  </li>
78
86
  </ul>
79
87
  <footer>
80
- Markdown guides open rendered on GitHub; <a href="../index.html">the demo</a> and the
88
+ Markdown guides open rendered on GitHub; <a href="../index.html">the demo</a>, the
89
+ <a href="../playground.html">field playground</a> and the
81
90
  <a href="validation.html">validation bench</a> run here on GitHub Pages.
82
91
  Source: <a href="https://github.com/akhtar1985/zidan-select">github.com/akhtar1985/zidan-select</a>.
83
92
  </footer>
package/docs/options.md CHANGED
@@ -6,6 +6,65 @@ passed to `initZidanSelects()` / `initZidanForms()` / `zidanSelect()` / `zidanFi
6
6
  `zidanField()` itself accepts any supported `<input>`/`<textarea>`, with or without a
7
7
  `data-zidan*` attribute, which is how JS-only options are applied.
8
8
 
9
+ > **Prefer to click through the options?** The
10
+ > [field playground](https://akhtar1985.github.io/zidan-select/playground.html) exposes every
11
+ > option for one control at a time and copies both the HTML attribute form and the vanilla
12
+ > JavaScript object shown below.
13
+
14
+ ## Direct init by ID or class
15
+
16
+ The first argument of `zidanSelect()` accepts a CSS selector, an element, or a NodeList. Plain
17
+ selects are not auto-initialised, so you can enhance exactly the field you want:
18
+
19
+ ```html
20
+ <select id="mymov">…</select>
21
+ <select class="mymovclass">…</select>
22
+ <select class="mymovclass">…</select>
23
+ ```
24
+
25
+ ```js
26
+ const picker = zidanSelect('#mymov', {
27
+ mode: 'combobox',
28
+ label: 'Movie',
29
+ placeholder: 'Search a movie…',
30
+ searchable: true,
31
+ clearable: true
32
+ });
33
+
34
+ const pickers = zidanSelect('.mymovclass', { mode: 'select', layout: 'soft-pill' });
35
+ // one match → instance, several → array
36
+ ```
37
+
38
+ `initZidanSelects(scope, options)` still bulk-enhances every `[data-zidan-select]` and
39
+ `.zidan-select` inside a scope; use it when the markup can carry attributes. `zidanSelect()`
40
+ is the targeted form for IDs, classes and elements you already have a reference to.
41
+
42
+ ### Read values and option details
43
+
44
+ ```js
45
+ picker.getValue(); // selected value; array for multiple/tags
46
+ picker.setValue('dune');
47
+ picker.getTags(); // tags mode
48
+
49
+ const native = picker.el; // the original <select>
50
+ native.selectedOptions; // selected <option> elements
51
+ Array.from(native.options).map(option => ({
52
+ value: option.value,
53
+ label: option.text,
54
+ disabled: option.disabled,
55
+ group: option.parentElement.tagName === 'OPTGROUP' ? option.parentElement.label : null
56
+ }));
57
+
58
+ picker.setOptions([ // rebuilds listbox and native <option>s
59
+ { value: 'inception', label: 'Inception' },
60
+ { value: 'dune', label: 'Dune', group: 'Villeneuve' },
61
+ { value: 'arrival', label: 'Arrival', disabled: true }
62
+ ]);
63
+ ```
64
+
65
+ Listen to the library callback in the options (`onChange: ({ instance, value }) => …`) or to the
66
+ native `change` event; the native `<select>` always holds the current value.
67
+
9
68
  ## No-JS init (IDs, classes, selectors, JSON)
10
69
 
11
70
  For CMS templates where attributes are limited and custom scripts are unwelcome, init can be
@@ -317,6 +376,60 @@ Variants are set with `fileVariant` / `data-zidan-file-variant` (defaults to `dr
317
376
  | `cancelLabel` / `retryLabel` | — | string | `Cancel` / `Retry` | Per-file action labels. |
318
377
  | `renderFile` | — | function | — | `(itemElement, { file, index, state, field })` after the default row renders. |
319
378
 
379
+ ### Every file option in one object
380
+
381
+ ```js
382
+ const upload = zidanField('#files', {
383
+ /* Target by ID, class or element; no data-* attribute required */
384
+
385
+ /* Variant & copy */
386
+ variant: 'dropzone', // dropzone | button | avatar | gallery | compact
387
+ uploadIcon: 'upload', // any registered icon name or SVG markup
388
+ title: 'Choose a file',
389
+ dropHint: 'Drag & drop or browse',
390
+ layout: 'stacked', // stacked | inline | compact | floating | outlined | card
391
+ theme: 'default',
392
+ framework: 'none',
393
+ label: 'Attachments',
394
+ hint: 'PDF or images up to 5 MB.',
395
+
396
+ /* Rules */
397
+ accept: 'image/*,.pdf', // shown in the hint, checked against the picker
398
+ maxFiles: 4,
399
+ maxSizeMB: 5, // or maxSize: 5242880 (bytes)
400
+ showFileMeta: true,
401
+ showPreview: true,
402
+ replaceTitle: 'Change image',
403
+
404
+ /* Upload pipeline */
405
+ // upload: function (context) { … }, // custom uploader, contract below
406
+ // uploadUrl: '/api/files', // or XHR endpoint
407
+ uploadField: 'file',
408
+ // uploadData: function (file, field) { return { folder: 'avatars' }; },
409
+ // uploadHeaders: function (file, field) { return { 'X-Token': '…' }; },
410
+ withCredentials: false,
411
+ autoUpload: true,
412
+ simulateUpload: false, // visual-only pipeline
413
+ simulateDuration: 900, // ms
414
+
415
+ /* Per-file UI */
416
+ progressTemplate: 'Uploading {percent}%',
417
+ uploadedLabel: 'Uploaded',
418
+ failedLabel: 'Upload failed',
419
+ canceledLabel: 'Upload canceled',
420
+ cancelLabel: 'Cancel',
421
+ retryLabel: 'Retry',
422
+ // renderFile: function (itemElement, state) { … },
423
+
424
+ /* Callbacks — also zidan:upload-start/progress/success/error/cancel */
425
+ onUploadStart: function (event) { console.log('start', event.file); },
426
+ onUploadProgress: function (event) { console.log(event.progress); },
427
+ onUploadSuccess: function (event) { console.log('done', event.result); },
428
+ onUploadError: function (event) { console.log('failed', event.error); },
429
+ onUploadCancel: function (event) { console.log('canceled', event.file); }
430
+ });
431
+ ```
432
+
320
433
  Custom uploader contract:
321
434
 
322
435
  ```js
@@ -435,6 +548,86 @@ Callbacks: `onUploadStart`, `onUploadProgress`, `onUploadSuccess` / `onUpload`,
435
548
  `onInit`, `onChange`, `onSelect`, `onOpen`, `onClose`, `onTagAdd`, `onTagRemove`, `onError`.
436
549
  Every callback receives a single payload object with `instance` and the relevant value(s).
437
550
 
551
+ ### Every select option in one object
552
+
553
+ Copy the block, delete what you do not need. Values shown are the defaults; only clauses that
554
+ change the shape of the result (options, value, callbacks) are commented out.
555
+
556
+ ```js
557
+ const picker = zidanSelect('#mymov', {
558
+ /* Core */
559
+ mode: 'combobox', // 'select' | 'combobox' | 'tags' (default 'select')
560
+ layout: 'classic-clean', // 5 select layouts, see theming.md
561
+ themeFramework: 'none', // 'auto' | 'none' | 'vanilla' | 'bootstrap' | 'tailwind' | 'bulma' | 'foundation'
562
+ theme: 'default', // 'default' | 'modern' | 'minimal' | 'dark' | 'glass'
563
+ // id: 'mymov', // root id prefix; leave unset for class targets
564
+ // name: 'movie', // defaults to the native name
565
+ disabled: false,
566
+ required: false,
567
+ validation: null, // 'valid' | 'invalid' | null
568
+ scrollbar: 'default', // 'default' | 'thin' | 'fancy' | 'hover' | 'hidden'
569
+ customClasses: { root: '', control: '', input: '' },
570
+
571
+ /* Data — omit to use the native <option>s */
572
+ // options: [
573
+ // { value: 'inception', label: 'Inception' },
574
+ // { value: 'dune', label: 'Dune', group: 'Villeneuve' },
575
+ // { value: 'arrival', label: 'Arrival', disabled: true }
576
+ // ],
577
+ // suggestions: ['Interstellar', 'Oppenheimer'],
578
+ // value: 'inception', // string, or array for multiple/tags
579
+ label: 'Movie',
580
+ placeholder: 'Search a movie…',
581
+
582
+ /* Behaviour */
583
+ multiple: false, // mirrors native multiple by default
584
+ searchable: true, // false in plain 'select' mode
585
+ clearable: true,
586
+ closeOnSelect: true, // single mode
587
+ maxDropdownHeight: 280, // px
588
+ noResultsText: 'No results found',
589
+ emptyText: 'No options',
590
+ loadingText: 'Searching…',
591
+ clearText: 'Clear selection',
592
+
593
+ /* Combobox / async */
594
+ // fetchOptions: function (query, signal) {
595
+ // return fetch('/api/movies?q=' + encodeURIComponent(query), { signal: signal })
596
+ // .then(function (response) { return response.json(); });
597
+ // },
598
+ debounce: 250, // ms
599
+ minChars: 0,
600
+ searchValues: true, // match labels and values
601
+
602
+ /* Tags (mode: 'tags') */
603
+ maxTags: Infinity,
604
+ minTagLength: 1,
605
+ maxTagLength: Infinity,
606
+ caseSensitive: false,
607
+ allowFreeText: true,
608
+ delimiters: [','],
609
+ commitOnTab: false,
610
+ commitOnBlur: false,
611
+ valueDelimiter: ',',
612
+
613
+ /* Rendering hooks */
614
+ // filterOption: function (item, query) { return item.label.toLowerCase().includes(query.toLowerCase()); },
615
+ // renderOption: function (item) { return '<strong>' + item.label + '</strong>'; },
616
+ // renderSelected: function (value) { return value; },
617
+ // renderTag: function (tag) { return tag; },
618
+ // validateTag: function (tag) { return tag.length <= 24 || 'Use 24 characters or fewer'; },
619
+ // formatTag: function (tag) { return tag.toUpperCase(); },
620
+
621
+ /* Callbacks — also: onSelect, onOpen, onClose, onTagAdd, onTagRemove, onError */
622
+ onInit: function (event) { console.log('init', event.instance); },
623
+ onChange: function (event) { console.log('value', event.value); }
624
+ });
625
+ ```
626
+
627
+ Data attributes remain available as a 1:1 fallback; the tables above list the matching
628
+ `data-zidan-*` name for each option, and `data-zidan-options` accepts any literal-value subset
629
+ as JSON.
630
+
438
631
  ### DOM data attributes
439
632
 
440
633
  `data-zidan-select`, `data-zidan-mode`, `data-zidan-layout`, `data-zidan-framework`,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "zidan-select",
3
- "version": "2.2.0",
4
- "description": "Zero-dependency form enhancement library: select/combobox/tags, checkboxes, switches, radio groups, drag & drop file upload with progress, text/number/phone/date/range inputs and textarea with input icons and steppers. Split core/theme CSS, 5 themes, 11 layouts, framework adapters, plus select-only and file-only bundles.",
3
+ "version": "2.2.2",
4
+ "description": "Zero-dependency form enhancement library: select/combobox/tags, checkboxes, switches, radio groups, drag & drop file upload with progress, text/number/phone/date/range inputs and textarea with input icons and steppers. Split core/theme CSS, 5 themes, 11 layouts, framework adapters. Load only the select-only or file-only build if that is all you need, or the full form bundle to enhance every input at once.",
5
5
  "keywords": [
6
6
  "select",
7
7
  "combobox",
@@ -79,7 +79,7 @@
79
79
  "dev": "node scripts/serve.mjs",
80
80
  "build": "node scripts/build.mjs",
81
81
  "test": "node scripts/test.mjs",
82
- "lint": "node --check zidan-form.js && node --check demo.js && node --check zidan-form.mjs"
82
+ "lint": "node --check zidan-form.js && node --check demo.js && node --check playground.js && node --check zidan-form.mjs"
83
83
  },
84
84
  "engines": {
85
85
  "node": ">=18"
package/zidan-form.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * ZidanForm v2.2.0
2
+ * ZidanForm v2.2.2
3
3
  * Zero-dependency form enhancement library: select / combobox / tags,
4
4
  * checkboxes, switches, radio groups, file upload with drag & drop and
5
5
  * upload progress, text / number / phone / date / range inputs and textarea.
@@ -32,7 +32,7 @@
32
32
  })(typeof window !== 'undefined' ? window : this, function (global) {
33
33
  'use strict';
34
34
 
35
- var VERSION = '2.2.0';
35
+ var VERSION = '2.2.2';
36
36
 
37
37
  // Loading the file twice (classic script + module wrapper, or two bundles)
38
38
  // must not replace the classes and orphan the live instances.