zidan-select 2.1.2 → 2.2.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 CHANGED
@@ -40,11 +40,18 @@ the same two stylesheets and no dependencies.
40
40
  | | ZidanForm | Select2 | Choices.js | Tom Select | Slim Select |
41
41
  | --- | --- | --- | --- | --- | --- |
42
42
  | Runtime dependencies | **None** | jQuery | None | None | None |
43
- | Controls covered | **Select, checkbox, switch, radio, file, text** | Select / tags | Select, text, tags | Select / tags | Select |
44
- | Drag & drop file upload | **Built in** | — | — | — | — |
43
+ | Controls covered | **Select, checkbox, switch, radio, file, text, phone, stepper, range, date/time** | Select / tags | Select, text, tags | Select / tags | Select |
44
+ | Input icons & adornments | **Auto, custom SVG, left/right, clickable** | — | — | — | — |
45
+ | Phone number formatting | **Per country, 3 styles each** | — | — | — | — |
46
+ | Number stepper & range skins | **3 stepper layouts, 3 range skins** | — | — | — | — |
47
+ | File upload variants & progress | **Dropzone, button, avatar, gallery, compact** | — | — | — | — |
48
+ | Text input utilities | **Clear, reveal, prefix/suffix, counter** | — | — | — | — |
49
+ | Built-in validation rules | **Every type, date rules, validation icons** | — | — | — | — |
45
50
  | Split structure / theme CSS | **Yes** | Partial | Partial | Partial | Partial |
51
+ | Select-only / file-only builds | **Yes, with matching CSS** | Core is select-only | Core is select + text | Core is select-only | Core is select-only |
46
52
  | Validation coexistence tested | **Native, jQuery Validation, JustValidate, Parsley** | — | — | — | — |
47
53
  | CSS-framework adapters | **Bootstrap, Tailwind, Bulma, Foundation** | — | — | — | — |
54
+ | Framework support | **React, Next.js, Vue, Svelte, Angular guides** | Community wrappers | Community wrappers | Community wrappers | Community wrappers |
48
55
 
49
56
  **Benefits**
50
57
 
@@ -68,19 +75,20 @@ limitations and migration notes: **[`docs/comparison.md`](docs/comparison.md)**.
68
75
 
69
76
  1. [Live demo](#live-demo)
70
77
  2. [Install](#install)
71
- 3. [Why ZidanForm](#why-zidanform)
72
- 4. [Quick start](#quick-start)
73
- 5. [Input types](#input-types)
74
- 6. [Options & data attributes](#options--data-attributes)
75
- 7. [JavaScript API](#javascript-api)
76
- 8. [Themes, layouts & frameworks](#themes-layouts--frameworks)
77
- 9. [Validation libraries](#validation-libraries)
78
- 10. [Form lifecycle & state sync](#form-lifecycle--state-sync)
79
- 11. [React, Next.js, Vue, Angular](#react-nextjs-vue-angular)
80
- 12. [Build & publish](#build--publish)
81
- 13. [Browser support](#browser-support)
82
- 14. [What's new in 2.1](#whats-new-in-21)
83
- 15. [Migrating from 1.x](#migrating-from-1x)
78
+ 3. [Select-only & file-only builds](#select-only-and-file-only-builds)
79
+ 4. [Why ZidanForm](#why-zidanform)
80
+ 5. [Quick start](#quick-start)
81
+ 6. [Input types](#input-types)
82
+ 7. [Options & data attributes](#options--data-attributes)
83
+ 8. [JavaScript API](#javascript-api)
84
+ 9. [Themes, layouts & frameworks](#themes-layouts--frameworks)
85
+ 10. [Validation libraries](#validation-libraries)
86
+ 11. [Form lifecycle & state sync](#form-lifecycle--state-sync)
87
+ 12. [React, Next.js, Vue, Angular](#react-nextjs-vue-angular)
88
+ 13. [Build & publish](#build--publish)
89
+ 14. [Browser support](#browser-support)
90
+ 15. [What's new in 2.1–2.2](#whats-new-in-2122)
91
+ 16. [Migrating from 1.x](#migrating-from-1x)
84
92
 
85
93
  ---
86
94
 
@@ -127,6 +135,17 @@ import 'zidan-select/css/theme';
127
135
  const { ZidanForm, initZidanForms, initZidanSelects } = require('zidan-select');
128
136
  ```
129
137
 
138
+ ```js
139
+ // Select-only or file-only bundles (matching JS + CSS)
140
+ import { ZidanSelect } from 'zidan-select/select';
141
+ import 'zidan-select/select/css/core';
142
+ import 'zidan-select/select/css/theme';
143
+
144
+ import { ZidanFileUpload, zidanField } from 'zidan-select/file';
145
+ import 'zidan-select/file/css/core';
146
+ import 'zidan-select/file/css/theme';
147
+ ```
148
+
130
149
  ### CDN
131
150
 
132
151
  ```html
@@ -146,21 +165,82 @@ override presets.
146
165
  | `zidan-form.mjs` | ES module wrapper around the same file. |
147
166
  | `plugin-core.css` | Layout, positioning, native-input handling, mechanics. **No colours, shadows or skins.** |
148
167
  | `plugin-theme.css` | Tokens, colours, states, presets, layout skins, framework adapters. |
168
+ | `dist/select/` | Select-only build: `zidan-select.js`, `zidan-select.mjs`, `plugin-select-core.css`, `plugin-select-theme.css`. |
169
+ | `dist/file/` | File-only build: `zidan-file.js`, `zidan-file.mjs`, `plugin-file-core.css`, `plugin-file-theme.css`. |
149
170
  | `index.html`, `demo.css`, `demo.js` | The tabbed demo / theme showcase (not shipped logic). |
150
171
  | `docs/` | Comparison, options, validation, frameworks, theming and build guides. |
151
172
 
152
173
  Copyable URLs for the published files (pin the version in production):
153
174
 
154
- - `zidan-form.js` — <https://cdn.jsdelivr.net/npm/zidan-select@2.1.2/zidan-form.js>
155
- - `zidan-form.mjs` — <https://cdn.jsdelivr.net/npm/zidan-select@2.1.2/zidan-form.mjs>
156
- - `plugin-core.css` — <https://cdn.jsdelivr.net/npm/zidan-select@2.1.2/plugin-core.css>
157
- - `plugin-theme.css` — <https://cdn.jsdelivr.net/npm/zidan-select@2.1.2/plugin-theme.css>
175
+ - `zidan-form.js` — <https://cdn.jsdelivr.net/npm/zidan-select@2.2.1/zidan-form.js>
176
+ - `zidan-form.mjs` — <https://cdn.jsdelivr.net/npm/zidan-select@2.2.1/zidan-form.mjs>
177
+ - `plugin-core.css` — <https://cdn.jsdelivr.net/npm/zidan-select@2.2.1/plugin-core.css>
178
+ - `plugin-theme.css` — <https://cdn.jsdelivr.net/npm/zidan-select@2.2.1/plugin-theme.css>
158
179
  - npm package — <https://www.npmjs.com/package/zidan-select>
159
180
  - Source — <https://github.com/akhtar1985/zidan-select>
160
181
 
161
182
  The demo page loads these same four files from the repository root, so it always exercises the
162
183
  exact code that ships.
163
184
 
185
+ ### Select-only and file-only builds
186
+
187
+ Only need one control family? Load a trimmed bundle instead of the full library. Each bundle
188
+ ships matching structure and theme stylesheets and keeps the five preset themes, the layouts and
189
+ the Bootstrap, Tailwind, Bulma and Foundation adapters, so theme and framework attributes behave
190
+ exactly like the full build.
191
+
192
+ | Build | JS | ESM | Core CSS | Theme CSS |
193
+ | --- | --- | --- | --- | --- |
194
+ | Select / combobox / tags | `dist/select/zidan-select.js` | `dist/select/zidan-select.mjs` | `dist/select/plugin-select-core.css` | `dist/select/plugin-select-theme.css` |
195
+ | File upload | `dist/file/zidan-file.js` | `dist/file/zidan-file.mjs` | `dist/file/plugin-file-core.css` | `dist/file/plugin-file-theme.css` |
196
+
197
+ Copyable CDN URLs (pin the version):
198
+
199
+ - `zidan-select.js` — <https://cdn.jsdelivr.net/npm/zidan-select@2.2.1/dist/select/zidan-select.js>
200
+ - `zidan-select.mjs` — <https://cdn.jsdelivr.net/npm/zidan-select@2.2.1/dist/select/zidan-select.mjs>
201
+ - `plugin-select-core.css` — <https://cdn.jsdelivr.net/npm/zidan-select@2.2.1/dist/select/plugin-select-core.css>
202
+ - `plugin-select-theme.css` — <https://cdn.jsdelivr.net/npm/zidan-select@2.2.1/dist/select/plugin-select-theme.css>
203
+ - `zidan-file.js` — <https://cdn.jsdelivr.net/npm/zidan-select@2.2.1/dist/file/zidan-file.js>
204
+ - `zidan-file.mjs` — <https://cdn.jsdelivr.net/npm/zidan-select@2.2.1/dist/file/zidan-file.mjs>
205
+ - `plugin-file-core.css` — <https://cdn.jsdelivr.net/npm/zidan-select@2.2.1/dist/file/plugin-file-core.css>
206
+ - `plugin-file-theme.css` — <https://cdn.jsdelivr.net/npm/zidan-select@2.2.1/dist/file/plugin-file-theme.css>
207
+
208
+ Select / combobox / tags only (≈95 kB JS, ≈12 kB core CSS, ≈32 kB theme CSS):
209
+
210
+ ```html
211
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/zidan-select@2.2.1/dist/select/plugin-select-core.css">
212
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/zidan-select@2.2.1/dist/select/plugin-select-theme.css">
213
+ <script src="https://cdn.jsdelivr.net/npm/zidan-select@2.2.1/dist/select/zidan-select.js"></script>
214
+ <script>
215
+ // auto-init covers [data-zidan-select], class="zidan-select", zidan-form scopes
216
+ // and ZIDAN_FORM_CONFIG targets; JS-only options:
217
+ zidanSelect('#country', { mode: 'select' });
218
+ </script>
219
+ ```
220
+
221
+ File upload only (≈76 kB JS, ≈9 kB core CSS, ≈35 kB theme CSS):
222
+
223
+ ```html
224
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/zidan-select@2.2.1/dist/file/plugin-file-core.css">
225
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/zidan-select@2.2.1/dist/file/plugin-file-theme.css">
226
+ <script src="https://cdn.jsdelivr.net/npm/zidan-select@2.2.1/dist/file/zidan-file.js"></script>
227
+ <script>
228
+ zidanField('#upload', { variant: 'dropzone', upload: '/api/files' });
229
+ </script>
230
+ ```
231
+
232
+ Framework and theme options are unchanged: `data-zidan-framework="bootstrap|tailwind|bulma|foundation"`,
233
+ `data-zidan-theme`, `data-zidan-layout` and the framework adapter CSS all ship in each subset.
234
+ Load a subset **instead of** `zidan-form.js`, not together with it — the guard keeps the first
235
+ initialised copy. If one page needs select *and* file upload, use the full build. The select
236
+ bundle exposes `ZidanSelect`, `zidanSelect`, `initZidanSelects`; the file bundle exposes
237
+ `ZidanFileUpload`, `zidanField`, `initZidanForms`.
238
+
239
+ Declarative init ships in both subsets too: `class="zidan-select"` (or a `zidan-form` wrapper)
240
+ works with no JS in the select build, and `class="zidan-field"` / a `zidan-form` wrapper works
241
+ with no JS in the file build. The same [`window.ZIDAN_FORM_CONFIG`](#no-javascript-init-ids-classes--json-cms-friendly)
242
+ targets apply.
243
+
164
244
  ---
165
245
 
166
246
  ## Quick start
@@ -198,8 +278,8 @@ exact code that ships.
198
278
  </script>
199
279
  ```
200
280
 
201
- Auto-init runs on `DOMContentLoaded` for `[data-zidan-select]` and `[data-zidan*]` unless
202
- disabled:
281
+ Auto-init runs on `DOMContentLoaded` for `[data-zidan-select]`, `[data-zidan*]`, the marker
282
+ classes described below and any configured targets, unless disabled:
203
283
 
204
284
  ```html
205
285
  <html data-zidan-auto-init="false">
@@ -209,6 +289,53 @@ disabled:
209
289
  window.ZIDAN_SELECT_CONFIG = { autoInit: false };
210
290
  ```
211
291
 
292
+ ### No-JavaScript init: IDs, classes & JSON (CMS-friendly)
293
+
294
+ Some CMS platforms and page builders hide per-element options or strip custom scripts. Three
295
+ declarative paths need no wiring call, and all three behave the same in the full build, the
296
+ select-only bundle and the file-only bundle:
297
+
298
+ | Path | Markup | Enhanced |
299
+ | --- | --- | --- |
300
+ | Marker class | `<select class="zidan-select">`, `<input class="zidan-field">` | That control. `zidan-field` covers file, checkbox and text/textarea inputs; radio groups go on the `<fieldset class="zidan-field">`. |
301
+ | Form wrapper | `<form class="zidan-form">` (or `data-zidan-form` on any element) | Every `<select>` and every `<input type="file">` inside, marked or not. |
302
+ | Config targets | `window.ZIDAN_FORM_CONFIG` | Anything matching an ID, class or full CSS selector. |
303
+
304
+ `data-zidan-options` passes plain options as JSON, so a CMS field can expose a single attribute.
305
+ It works on selects and every field type:
306
+
307
+ ```html
308
+ <select class="zidan-select" multiple
309
+ data-zidan-options='{"mode":"tags","maxTags":3,"placeholder":"Type and press Enter"}'>…</select>
310
+ <input type="file" class="zidan-field"
311
+ data-zidan-options='{"variant":"dropzone","title":"Attach a document"}'>
312
+ ```
313
+
314
+ Reach controls by ID or any selector — define the config **before** the library script runs
315
+ (before `DOMContentLoaded`):
316
+
317
+ ```html
318
+ <script>
319
+ window.ZIDAN_FORM_CONFIG = {
320
+ targets: ['#country', 'select.product-variants',
321
+ { selector: '#brands', options: { mode: 'tags', maxTags: 3 } }],
322
+ fieldTargets: [
323
+ { selector: '#avatar', options: { variant: 'avatar' } },
324
+ { selector: 'input[name="email"]', options: { icon: 'mail' } }
325
+ ],
326
+ formTargets: ['#checkout'] // extra form scopes
327
+ };
328
+ </script>
329
+ <script src="zidan-form.js"></script>
330
+ ```
331
+
332
+ `targets` and `fieldTargets` accept a selector string or `{ selector, options }`; per-target
333
+ options win over `data-zidan-options`, which wins over data attributes. `ZIDAN_SELECT_CONFIG`
334
+ still works as an alias of `ZIDAN_FORM_CONFIG`. JSON can only carry literal values — callbacks,
335
+ upload functions and custom icon markup still need a small JS block. Trimmed bundles:
336
+ the select build enhances selects, the file build enhances file inputs; both understand the
337
+ same config keys, marker classes and JSON attribute.
338
+
212
339
  Windows/macOS keyboard behaviour, grouping, search and all select features live in
213
340
  [`docs/options.md`](docs/options.md).
214
341
 
@@ -357,8 +484,21 @@ Supported types: `text`, `email`, `password`, `number`, `tel`, `url`, `search`,
357
484
 
358
485
  ```js
359
486
  ZidanForm.registerIcon('sparkle', '<path d="M12 3l1.9 5.3L19 10l-5.1 1.7L12 17Z"/>');
487
+
488
+ // or configure a plain input entirely from JavaScript
489
+ zidanField('#brand', {
490
+ icon: 'palette',
491
+ iconPosition: 'right',
492
+ iconClickable: true,
493
+ iconLabel: 'Pick a brand colour'
494
+ });
360
495
  ```
361
496
 
497
+ Built-in names: `text`, `mail`, `phone`, `user`, `lock`, `search`, `calendar`, `clock`, `link`,
498
+ `hash`, `palette`, `sliders`, `file`, `upload`, `eye`, `eye-off`, `check`, `x`, `plus`, `minus`,
499
+ `chevron-*`, `alert`, `info`, `globe`, `map-pin`, `image`, `refresh`, `trash`. Raw `<path>` or
500
+ `<svg>` markup is accepted too.
501
+
362
502
  Works for `text`, `email`, `password`, `number`, `tel`, `url`, `search`, all date/time types
363
503
  and `range`. `data-zidan-validation-icon="true"` adds check/alert glyphs.
364
504
 
@@ -779,8 +919,13 @@ Full checklist, folder tree and release automation notes: [`docs/build.md`](docs
779
919
 
780
920
  ---
781
921
 
782
- ## What's new in 2.1
922
+ ## What's new in 2.1–2.2
783
923
 
924
+ - **Subset builds** — select-only and file-only JS bundles with matching core/theme CSS in
925
+ `dist/select/` and `dist/file/`; themes, layouts and framework adapters included.
926
+ - **No-JS init** — `zidan-select` / `zidan-field` marker classes, `zidan-form` wrapper scopes,
927
+ `data-zidan-options` JSON and `window.ZIDAN_FORM_CONFIG` targets for ID/CSS-selector setup in
928
+ CMS builds. Works in the full build and both subsets.
784
929
  - **Input icons** — `data-zidan-auto-icon`, `data-zidan-icon`, left/right placement,
785
930
  clickable icons and `ZidanForm.registerIcon()` for custom artwork.
786
931
  - **Number stepper** — stacked, split and inline − / + controls with hold-to-repeat,
@@ -802,6 +947,21 @@ Full checklist, folder tree and release automation notes: [`docs/build.md`](docs
802
947
 
803
948
  The 2.0 API is unchanged; every addition is opt-in.
804
949
 
950
+ **2.2.1** adds declarative no-JavaScript init — marker classes (`zidan-select`,
951
+ `zidan-field`, `zidan-form`), ID/CSS targets through `window.ZIDAN_FORM_CONFIG` and
952
+ `data-zidan-options` JSON — for the full build and both subset bundles, with docs and demo
953
+ cards. It also restores `getValue()`/`setValue()` on every field, mirrors required-select
954
+ invalid state to the visible control, rebuilds native options on `setOptions()` and mirrors
955
+ programmatic range values into `data-zidan-output`.
956
+
957
+ **2.2.0** adds select-only and file-only builds. Each ships a trimmed JS bundle plus matching
958
+ core and theme stylesheets, keeps all five preset themes, layouts and the Bootstrap, Tailwind,
959
+ Bulma and Foundation adapters, and is generated from the same source by `npm run build`.
960
+ The full build is unchanged. This release also fixes the duplicate calendar/clock indicator on
961
+ date, time, datetime-local, month and week fields when a custom icon or picker button is used,
962
+ adds the icon demo card (auto, built-in, registered and JavaScript-only icons), and lists every
963
+ 2.1 capability in the comparison tables.
964
+
805
965
  **2.1.2** is a documentation-only patch: it ships this README, the GitHub Pages deployment, the
806
966
  demo screenshots and the copyable CDN URLs. No JavaScript or CSS behaviour changed.
807
967