zidan-select 2.0.1 → 2.1.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.
@@ -17,15 +17,20 @@ if (!api.ZidanForm) {
17
17
  throw new Error('ZidanForm: core script did not initialise (no DOM available?).');
18
18
  }
19
19
 
20
+ const core = api.ZidanForm.api || api;
21
+
20
22
  export const ZidanForm = api.ZidanForm;
21
- export const ZidanSelect = api.ZidanSelect;
22
- export const ZidanCheckbox = api.ZidanCheckbox;
23
- export const ZidanRadioGroup = api.ZidanRadioGroup;
24
- export const ZidanFileUpload = api.ZidanFileUpload;
25
- export const ZidanTextField = api.ZidanTextField;
26
- export const zidanSelect = api.zidanSelect;
27
- export const zidanField = api.zidanField;
28
- export const initZidanSelects = api.initZidanSelects;
29
- export const initZidanForms = api.initZidanForms;
23
+ export const ZidanSelect = core.ZidanSelect;
24
+ export const ZidanCheckbox = core.ZidanCheckbox;
25
+ export const ZidanRadioGroup = core.ZidanRadioGroup;
26
+ export const ZidanFileUpload = core.ZidanFileUpload;
27
+ export const ZidanTextField = core.ZidanTextField;
28
+ export const zidanSelect = core.zidanSelect;
29
+ export const zidanField = core.zidanField;
30
+ export const initZidanSelects = core.initZidanSelects;
31
+ export const initZidanForms = core.initZidanForms;
32
+ export const registerIcon = core.registerIcon;
33
+ export const formatPhone = core.formatPhone;
34
+ export const detectPhoneCountry = core.detectPhoneCountry;
30
35
 
31
36
  export default ZidanForm;
@@ -226,8 +226,9 @@ zidanSelect('#tags', {
226
226
 
227
227
  | Need | API |
228
228
  | --- | --- |
229
- | External value → control | `setValue()` (select/field/radio), `setIndeterminate()`, `clear()` (file) |
229
+ | External value → control | `setValue()` (select/field/radio/range), `stepUp()` / `stepDown()` (stepper), `setPhoneCountry()` / `setPhoneFormat()`, `setIndeterminate()`, `clear()` (file) |
230
230
  | Control → state | `onChange` callback or `zidan:change` event |
231
+ | File upload progress | `zidan:upload-*` events or `getUploadState()` |
231
232
  | Re-render with same instances | `update()` / `ZidanForm.refresh(scope)` |
232
233
  | New nodes from a list re-render | `ZidanForm.observe(scope)` — additions/removals inside the scope; call `destroy()` first when removing the scope itself |
233
234
  | Unmount | `destroy()`, or `ZidanForm.destroyAll()` for a page |
package/docs/index.html CHANGED
@@ -37,8 +37,9 @@
37
37
  <main>
38
38
  <h1>ZidanForm documentation</h1>
39
39
  <p class="lead">
40
- Zero-dependency form enhancement: select, checkbox, switch, radio, file upload and text
41
- inputs. Start with the <a href="../index.html">interactive demo</a>, then dive into the
40
+ Zero-dependency form enhancement: select, checkbox, switch, radio, file upload, text,
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
42
43
  reference.
43
44
  </p>
44
45
  <ul>
package/docs/options.md CHANGED
@@ -11,7 +11,7 @@ Applies to `ZidanCheckbox`, `ZidanRadioGroup`, `ZidanFileUpload`, `ZidanTextFiel
11
11
 
12
12
  | JS option | Data attribute | Type | Default | Notes |
13
13
  | --- | --- | --- | --- | --- |
14
- | `variant` | `data-zidan-variant` | string | `default` | Checkbox: `default`, `switch`, `card`. Radio: `stacked`, `inline`, `card`. |
14
+ | `variant` | `data-zidan-variant` | string | `default` | Checkbox: `default`, `switch`, `card`, `button`, `minimal`. Radio: `stacked`, `inline`, `card`, `button`, `tile`. File: `dropzone`, `button`, `avatar`, `gallery`, `compact`. Range: `default`, `gradient`, `stepped`, `minimal`. |
15
15
  | `layout` | `data-zidan-layout` | string | `stacked` | `stacked`, `inline`, `compact`, `floating`, `outlined`, `card`. |
16
16
  | `theme` | `data-zidan-theme`, `data-zs-theme` | string | `default` | `default`, `modern`, `minimal`, `dark`, `glass`. Resolves element → ancestor → `<html>`. |
17
17
  | `framework` | `data-zidan-framework`, `data-zs-framework` | string | `none` | `none`, `bootstrap`, `tailwind`, `bulma`, `foundation`, `vanilla`. |
@@ -49,6 +49,237 @@ Applies to `ZidanCheckbox`, `ZidanRadioGroup`, `ZidanFileUpload`, `ZidanTextFiel
49
49
  DOM events with the same information: `zidan:init`, `zidan:change`, `zidan:validation`,
50
50
  `zidan:remove`, `zidan:reveal`, `zidan:clear`, `zidan:destroy`, `zidan:error`.
51
51
 
52
+ ## Checkbox, switch & radio variants
53
+
54
+ | Control | Option / attribute | Values | Notes |
55
+ | --- | --- | --- | --- |
56
+ | Checkbox / switch | `variant` / `data-zidan-variant` | `default`, `switch`, `card`, `button`, `minimal` | `button` is a filter-style pill; `minimal` removes the border for dense lists. |
57
+ | Switch | `switchStyle` / `data-zidan-switch-style` | `ios`, `material`, `square`, `labeled`, `icon` | Skin only — combine with `variant="switch"`. |
58
+ | Switch | `onLabel` / `data-zidan-on-label` | string | `labeled` and `icon` styles: checked text. |
59
+ | Switch | `offLabel` / `data-zidan-off-label` | string | `labeled` and `icon` styles: unchecked text. |
60
+ | Checkbox / radio | `description` / `data-zidan-description` | string | Second line under the label (card, tile, button, minimal). |
61
+ | Radio group | `variant` / `data-zidan-variant` | `stacked`, `inline`, `card`, `button`, `tile` | Applies to the `<fieldset>`. |
62
+ | Radio group | `deselectable` / `data-zidan-deselectable` | boolean | Clicking the selected radio clears the group. |
63
+
64
+ `ZidanForm.variants` exposes the accepted names:
65
+ `{ checkbox: [...], switch: [...], radio: [...], file: [...], range: [...] }`.
66
+
67
+ ## Text input: icons
68
+
69
+ Supports `text`, `email`, `password`, `number`, `tel`, `url`, `search`, `date`, `time`,
70
+ `datetime-local`, `month`, `week`, `range`, `color` and `<textarea>`.
71
+
72
+ | JS option | Data attribute | Type | Default | Notes |
73
+ | --- | --- | --- | --- | --- |
74
+ | `autoIcon` | `data-zidan-auto-icon` | boolean | `false` | Uses the built-in icon for the input type (`mail`, `phone`, `calendar`, `clock`, `search`, `link`, `hash`, `palette`). |
75
+ | `icon` | `data-zidan-icon` | string | — | Any registered name, a raw `<path>`/SVG string, or `"auto"` (same as `autoIcon`). |
76
+ | `iconPosition` | `data-zidan-icon-position` | `left` \| `right` | `left` | Right icons sit after suffix/actions. |
77
+ | `iconClickable` | `data-zidan-icon-clickable` | boolean | `false` | Renders a `<button>` and emits `zidan:icon-click`. Date/time pickers are always clickable. |
78
+ | `iconLabel` | `data-zidan-icon-label` | string | — | Accessible name for a decorative/custom icon. |
79
+ | `validationIcon` | `data-zidan-validation-icon` | boolean | `false` | Adds check/alert glyphs driven by `[data-zs-validation]`. |
80
+
81
+ ```html
82
+ <!-- type-based icon -->
83
+ <input type="email" data-zidan="input" data-zidan-auto-icon="true" data-zidan-clear>
84
+
85
+ <!-- custom icon, right side, clickable -->
86
+ <input type="url" data-zidan="input" data-zidan-icon="link"
87
+ data-zidan-icon-position="right" data-zidan-icon-clickable="true"
88
+ data-zidan-icon-label="Open website">
89
+ ```
90
+
91
+ ```js
92
+ // register your own icon (path markup or a full <svg>), then use its name anywhere
93
+ ZidanForm.registerIcon('sparkle', '<path d="M12 3l1.9 5.3L19 10l-5.1 1.7L12 17Z"/>');
94
+ window.registerZidanIcon('heart', '<path d="M12 20s-7-4.4-7-9a4 4 0 0 1 7-2 4 4 0 0 1 7 2c0 4.6-7 9-7 9Z"/>');
95
+ ```
96
+
97
+ Icons are sanitised with `DOMParser`: only SVG shape elements and safe attributes survive.
98
+
99
+ ## Number stepper (− / +)
100
+
101
+ | JS option | Data attribute | Type | Default | Notes |
102
+ | --- | --- | --- | --- | --- |
103
+ | `stepper` | `data-zidan-stepper` | boolean \| mode | `false` | `true` = `stacked`; or `stacked`, `split`, `inline`. Any value except `false`/`"false"` enables it. |
104
+ | `stepperPosition` | `data-zidan-stepper-position` | `left` \| `right` | `right` | `inline` mode only. |
105
+ | `stepperWrap` | `data-zidan-stepper-wrap` | boolean | `false` | Adds a wrapping border around the field (theme hook). |
106
+ | `stepperLongPress` | `data-zidan-stepper-long-press` | boolean | `true` | Press and hold repeats. |
107
+ | `stepperDelay` | `data-zidan-stepper-delay` | number | `420` | Hold delay before repeating, ms. |
108
+ | `stepperInterval` | `data-zidan-stepper-interval` | number | `90` | Repeat interval, ms. |
109
+ | `stepperUpLabel` | `data-zidan-stepper-up-label` | string | `Increase value` | Aria-label of “+”. |
110
+ | `stepperDownLabel` | `data-zidan-stepper-down-label` | string | `Decrease value` | Aria-label of “−”. |
111
+
112
+ ```html
113
+ <input type="number" min="0" max="10" value="3" data-zidan="input"
114
+ data-zidan-stepper="stacked">
115
+ <input type="number" min="0" max="99" data-zidan="input"
116
+ data-zidan-stepper="split">
117
+ <input type="number" step="0.5" data-zidan="input"
118
+ data-zidan-stepper="inline" data-zidan-stepper-position="left">
119
+ ```
120
+
121
+ Methods: `stepUp(times = 1)`, `stepDown(times = 1)`, `setStepper(enabled)`.
122
+ Event: `zidan:step` → `{ value, direction, instance }`.
123
+
124
+ ## Phone formatting
125
+
126
+ | JS option | Data attribute | Type | Default | Notes |
127
+ | --- | --- | --- | --- | --- |
128
+ | `phone` | `data-zidan-phone` | boolean \| object | `false` | Enables formatting. Object form: `{ country, format, showCountry, countries, validate }`. |
129
+ | `phoneCountry` | `data-zidan-phone-country` | ISO-2 | `US` | One of `ZidanForm.phoneCountries`. |
130
+ | `phoneFormat` | `data-zidan-phone-format` | `national` \| `international` \| `e164` | `national` | Three styles per country. |
131
+ | `phoneCountrySelect` | `data-zidan-phone-country-select` | boolean | `true` | Show the native country `<select>`. |
132
+ | `phoneCountries` | `data-zidan-phone-countries` | list | common set | Comma-separated ISO codes for the selector. |
133
+ | `phoneCountryLabel` | — | string | `Country code` | Aria-label for the selector. |
134
+ | `phone.validate` | — | boolean | `true` | Length check per country (uses `messages.phone`). |
135
+
136
+ ```html
137
+ <input type="tel" data-zidan="input" data-zidan-phone="true"
138
+ data-zidan-phone-country="GB" data-zidan-phone-format="international"
139
+ data-zidan-phone-country-select="false">
140
+ ```
141
+
142
+ Methods: `getPhoneCountry()`, `setPhoneCountry('GB')`, `setPhoneFormat('e164')`,
143
+ `formatPhone(value?)`.
144
+ Events: `zidan:phone-country` → `{ country }`, `zidan:phone-format` → `{ format }`.
145
+
146
+ Static helpers:
147
+
148
+ ```js
149
+ ZidanForm.formatPhone('2025550134', 'US', 'e164'); // +12025550134
150
+ ZidanForm.detectPhoneCountry('+44 7700 900123'); // 'GB'
151
+ ```
152
+
153
+ Formatting is caret-safe: digits are re-masked around the caret while typing, and a leading
154
+ national `0` is dropped in international/E.164 output.
155
+
156
+ ## Range inputs
157
+
158
+ | JS option | Data attribute | Type | Default | Notes |
159
+ | --- | --- | --- | --- | --- |
160
+ | `rangeVariant` | `data-zidan-range-variant` | `default` \| `gradient` \| `stepped` \| `minimal` | `default` | Visual skin. |
161
+ | `rangeBubble` | `data-zidan-range-bubble` | boolean | `true` | Floating value bubble above the thumb. |
162
+ | `rangeMinMax` | `data-zidan-range-minmax` | boolean | `true` | Min/max scale under the track. |
163
+ | `rangeTicks` | `data-zidan-range-ticks` | number \| array | `0` | Count (data attribute) or array of values (JS option). |
164
+ | `rangeTickLabels` | `data-zidan-range-tick-labels` | boolean | `false` | Text labels on ticks. |
165
+ | `rangeLabels` | — | object | — | Map `{ value: 'Label' }` used with labeled ticks. |
166
+ | `rangeFormat` | `data-zidan-range-format` | string \| function | — | Template with `{value}`, `{min}`, `{max}` (or `%s`), or `function(value, field)` in JS. |
167
+ | `output` | `data-zidan-output` | selector | — | Mirrors the raw value into a `<output>`/element. |
168
+
169
+ ```html
170
+ <input type="range" min="0" max="1000" step="50" value="400"
171
+ data-zidan="input" data-zidan-range-variant="minimal"
172
+ data-zidan-range-minmax="false" data-zidan-output="#budget">
173
+ ```
174
+
175
+ ```js
176
+ zidanField('#price', {
177
+ rangeVariant: 'gradient',
178
+ rangeTicks: [0, 250, 500, 750, 1000],
179
+ rangeTickLabels: true,
180
+ rangeLabels: { 0: 'Free', 1000: 'Top' },
181
+ rangeFormat: value => '€' + Number(value).toLocaleString('en-US')
182
+ });
183
+ ```
184
+
185
+ The range keeps `input.value` native; only the visual chrome and bubble are added. Instance
186
+ properties `range`, `rangeBubble`, `rangeTicksEl` and `rangeScale` are exposed if you need to
187
+ re-render custom ticks.
188
+
189
+ ## Date & time pickers
190
+
191
+ | JS option | Data attribute | Type | Default | Notes |
192
+ | --- | --- | --- | --- | --- |
193
+ | `pickerButton` | `data-zidan-picker-button` | boolean | `false` | Adds a picker button when no icon is present. |
194
+ | `pickerIcon` | `data-zidan-picker-icon` | string | per type | Any registered icon (default `calendar`/`clock`). |
195
+ | `pickerLabel` | — | string | `Open <type> picker` | Aria-label for the picker button. |
196
+ | `disableWeekends` | `data-zidan-disable-weekends` | boolean | `false` | Sat/Sun fail validation with `messages.weekend`. |
197
+ | `disabledDates` | `data-zidan-disabled-dates` | list \| function | — | Comma-separated ISO dates, array, or `(value, date, field) => true` in JS. |
198
+ | `validateDate` | — | function | — | `(value, date, field) => boolean \| string`; return `false` for `messages.date` or a custom string. |
199
+
200
+ ```html
201
+ <input type="date" value="2026-11-23" data-zidan="input"
202
+ data-zidan-icon="calendar" data-zidan-icon-position="left"
203
+ data-zidan-disable-weekends="true">
204
+ <input type="datetime-local" data-zidan="input" data-zidan-picker-button="true"
205
+ data-zidan-picker-icon="calendar">
206
+ ```
207
+
208
+ Methods: `openPicker()` / `showPicker()`. Event: `zidan:picker` → `{ type }`.
209
+
210
+ The native picker is used via `input.showPicker()` when available; icons keep the native input
211
+ reachable, so form values and validation stay native.
212
+
213
+ ## File upload: variants, uploading & rendering
214
+
215
+ Variants are set with `fileVariant` / `data-zidan-file-variant` (defaults to `dropzone`):
216
+
217
+ | Variant | Design |
218
+ | --- | --- |
219
+ | `dropzone` | Full-width dashed target; thumbnail or extension badge in the list. |
220
+ | `button` | Entire target is a compact button, one row. |
221
+ | `avatar` | Circular 96 px target with a single-image preview (`--zs-avatar-size` to resize). |
222
+ | `gallery` | Wrap target plus a responsive thumbnail grid. |
223
+ | `compact` | One-line target for sidebars; combine with `showFileMeta: false`. |
224
+
225
+ | JS option | Data attribute | Type | Default | Notes |
226
+ | --- | --- | --- | --- | --- |
227
+ | `fileVariant` | `data-zidan-file-variant` | string | `dropzone` | `dropzone`, `button`, `avatar`, `gallery`, `compact`. |
228
+ | `uploadIcon` | `data-zidan-upload-icon` | string | `upload` | Icon in the drop target (any registered name or `icon`). |
229
+ | `upload` / `uploadHandler` | — | function | — | Custom uploader, see contract below. |
230
+ | `uploadUrl` | `data-zidan-upload-url` | string | — | XHR endpoint; `POST` multipart. |
231
+ | `uploadField` | `data-zidan-upload-field` | string | `file` | FormData field name. |
232
+ | `uploadData` | — | object \| function | — | Extra FormData fields (`(file, field) => object`). |
233
+ | `withCredentials` | `data-zidan-with-credentials` | boolean | `false` | XHR credentials. |
234
+ | `uploadHeaders` / `headers` | — | object \| function | — | Extra request headers (`(file, field) => object`). |
235
+ | `simulateUpload` | `data-zidan-simulate-upload` | boolean | `false` | Visual upload only; files never leave the browser. |
236
+ | `simulateDuration` | `data-zidan-simulate-duration` | number | `900` | Simulation length, ms (min 120). |
237
+ | `autoUpload` | `data-zidan-auto-upload` | boolean | `true` | Start uploading as soon as files are picked. |
238
+ | `showFileMeta` | `data-zidan-show-file-meta` | boolean | `true` | Name + size line per file. |
239
+ | `showPreview` / `preview` | `data-zidan-preview` | boolean | `true` | Avatar preview for images. |
240
+ | `replaceTitle` | — | string | `Change image` | Avatar title once a preview exists. |
241
+ | `progressTemplate` | — | string | `Uploading {percent}%` | Progress text template. |
242
+ | `uploadedLabel` | — | string | `Uploaded` | Per-file success text. |
243
+ | `failedLabel` | — | string | `Upload failed` | Per-file error prefix. |
244
+ | `canceledLabel` | — | string | `Upload canceled` | Per-file canceled text. |
245
+ | `cancelLabel` / `retryLabel` | — | string | `Cancel` / `Retry` | Per-file action labels. |
246
+ | `renderFile` | — | function | — | `(itemElement, { file, index, state, field })` after the default row renders. |
247
+
248
+ Custom uploader contract:
249
+
250
+ ```js
251
+ zidanField('#files', {
252
+ upload(context) {
253
+ // context: { file, field, formData, signal, onProgress, complete, fail }
254
+ const xhr = new XMLHttpRequest();
255
+ // ...or return a promise / call context.complete(result) / context.fail(error)
256
+ context.onProgress(40); // 0–99 while working
257
+ fetch('/upload', { method: 'POST', body: context.formData, signal: context.signal })
258
+ .then(res => res.ok ? res.json() : Promise.reject(res.status))
259
+ .then(data => context.complete(data))
260
+ .catch(err => context.fail(err));
261
+ }
262
+ });
263
+ ```
264
+
265
+ - A returned thenable resolves the upload; a non-`undefined` return value becomes the result.
266
+ - Returning nothing means *you* will call `context.complete()` / `context.fail()`.
267
+ - `context.signal` aborts when the user cancels or the field is destroyed.
268
+ - `input.files` is always authoritative; `DataTransfer` rebuilds it on remove/clear.
269
+
270
+ Methods: `getFiles()`, `getUploadState()` (`[{ file, name, size, status, progress, error, result }]`),
271
+ `addFiles(files)`, `replaceFiles(files)`, `removeFile(fileNameOrIndex)`, `clear()`,
272
+ `setVariant(name)`, `setUploader(fnOrUrl)`, `uploadAll()`, `uploadFile(file)`,
273
+ `cancelUpload(file)`, `cancelAll()`, `retryUpload(file)`.
274
+
275
+ Events: `zidan:upload-start` `{ file, name, size }`, `zidan:upload-progress`
276
+ `{ file, name, progress }`, `zidan:upload-success` `{ file, name, result }`,
277
+ `zidan:upload-error` `{ file, name, error, message }`, `zidan:upload-cancel` `{ file, name }`,
278
+ plus the shared `zidan:change`, `zidan:remove` (`{ file, index }`) and `zidan:clear`.
279
+
280
+ Callbacks: `onUploadStart`, `onUploadProgress`, `onUploadSuccess` / `onUpload`,
281
+ `onUploadError`, `onUploadCancel`.
282
+
52
283
  ## Select options
53
284
 
54
285
  `ZidanSelect` keeps its full 1.x option set.
@@ -147,6 +378,12 @@ Every callback receives a single payload object with `instance` and the relevant
147
378
  ZidanForm.themes // ['default','modern','minimal','dark','glass']
148
379
  ZidanForm.frameworks // ['auto','none','vanilla','bootstrap','tailwind','bulma','foundation']
149
380
  ZidanForm.fieldLayouts // ['stacked','inline','card','compact','floating','outlined']
381
+ ZidanForm.variants // { checkbox, switch, radio, file, range } accepted names
382
+ ZidanForm.stepperModes // ['stacked','split','inline']
383
+ ZidanForm.phoneFormats // ['national','international','e164']
384
+ ZidanForm.phoneCountries // { US: { dial, mask, groups, min, max }, … }
385
+ ZidanForm.icons // live icon registry (name → SVG markup)
386
+ ZidanForm.messages // default validation messages
150
387
  ZidanSelect.layouts // five select layouts
151
388
  ZidanSelect.scrollbars // ['default','thin','fancy','hover','hidden']
152
389
  ```
@@ -171,8 +408,15 @@ to any field that should span the row) rather than putting it on a single field.
171
408
  | `setTheme(name)`, `setFramework(name)`, `setLayout(name)` | Scoped restyling. |
172
409
  | `destroy()` | Restores the original DOM and removes every listener. |
173
410
 
174
- Checkbox adds `setIndeterminate(bool)` and `isChecked()`; file adds `clear()` and
175
- `getFiles()`.
411
+ Checkbox adds `setIndeterminate(bool)` and `isChecked()`.
412
+
413
+ Text inputs add `stepUp(times?)`, `stepDown(times?)`, `setStepper(bool)`,
414
+ `getPhoneCountry()`, `setPhoneCountry(iso)`, `setPhoneFormat(format)`, `formatPhone(value?)`
415
+ and `openPicker()` / `showPicker()`.
416
+
417
+ File adds `getFiles()`, `getUploadState()`, `addFiles()`, `replaceFiles()`, `removeFile()`,
418
+ `clear()`, `setVariant()`, `setUploader()`, `uploadAll()`, `uploadFile()`, `cancelUpload()`,
419
+ `cancelAll()` and `retryUpload()`.
176
420
 
177
421
  ### Select
178
422
 
@@ -188,6 +432,18 @@ Checkbox adds `setIndeterminate(bool)` and `isChecked()`; file adds `clear()` an
188
432
  | `zidan:init` | `{ instance, kind \| mode }` |
189
433
  | `zidan:change` | `{ instance, value }`, `{ checked }`, `{ files }` |
190
434
  | `zidan:validation` | `{ instance, state, message? }` |
191
- | `zidan:remove` | `{ instance, file }` (file upload) |
435
+ | `zidan:remove` | `{ instance, file, index? }` (file upload) |
436
+ | `zidan:input` | `{ instance, value }` (text/range) |
437
+ | `zidan:step` | `{ instance, value, direction }` (number stepper) |
438
+ | `zidan:phone-country` | `{ instance, country }` |
439
+ | `zidan:phone-format` | `{ instance, format }` |
440
+ | `zidan:icon-click` | `{ instance, icon, position }` |
441
+ | `zidan:picker` | `{ instance, type }` |
442
+ | `zidan:upload-start` | `{ instance, file, name, size }` |
443
+ | `zidan:upload-progress` | `{ instance, file, name, progress }` |
444
+ | `zidan:upload-success` | `{ instance, file, name, result }` |
445
+ | `zidan:upload-error` | `{ instance, file, name, error, message }` |
446
+ | `zidan:upload-cancel` | `{ instance, file, name }` |
447
+ | `zidan:clear` | `{ instance }` |
192
448
  | `zidan:destroy` | `{ instance }` |
193
449
  | `zidan:error` | `{ error, callback, instance }` |
package/docs/theming.md CHANGED
@@ -96,6 +96,48 @@ Themes and frameworks resolve independently: you can combine `dark` + `bootstrap
96
96
  | `--zs-file-thumb-bg` / `-text` | `#eef1fd` / `#4a5590` |
97
97
  | `--zs-field-gap` | `6px` |
98
98
 
99
+ ### Input icons, stepper, phone, range & upload
100
+
101
+ | Token | Default | Used by |
102
+ | --- | --- | --- |
103
+ | `--zs-icon-color` / `--zs-icon-hover-bg` | muted text / primary-soft | input icons, upload glyph |
104
+ | `--zs-stepper-color` / `--zs-stepper-hover-bg` | text / primary-soft | − / + buttons |
105
+ | `--zs-phone-border` | border colour | country `<select>` separator |
106
+ | `--zs-switch-width-lg` / `-height-lg` | larger track | material/square/labeled styles |
107
+ | `--zs-switch-on-text` / `--zs-switch-off-text` | white / muted | labeled & icon switches |
108
+ | `--zs-radius-pill` | `999px` | button checkbox/radio variants |
109
+ | `--zs-avatar-size` | `96px` | avatar file variant |
110
+ | `--zs-avatar-bg` / `--zs-avatar-border` | primary-soft / border | avatar target & preview fallback |
111
+ | `--zs-range-track` / `--zs-range-fill` | border / primary | default & minimal range |
112
+ | `--zs-range-gradient` | linear-gradient | gradient variant |
113
+ | `--zs-range-thumb-bg` / `-thumb-border` | white / primary | range thumbs |
114
+ | `--zs-range-tick` / `--zs-range-tick-text` | border / muted | tick marks and labels |
115
+ | `--zs-range-bubble-bg` / `-bubble-text` | text / white | value bubble |
116
+ | `--zs-upload-track` / `--zs-upload-bar` / `--zs-upload-success` | border / primary / green | progress bar and states |
117
+
118
+ ### Variant hooks
119
+
120
+ Variants are selected per control and can be restyled with attribute selectors — no JS:
121
+
122
+ ```css
123
+ /* checkbox pill */
124
+ .zs-field[data-zs-variant="button"] .zs-check { --zs-pill-bg: #ecfdf3; }
125
+ /* radio tiles */
126
+ .zs-radio-group[data-zs-variant="tile"] .zs-radio { border-radius: 14px; }
127
+ /* switch skins */
128
+ .zs-field[data-zs-switch-style="ios"] .zs-switch-track::after { box-shadow: 0 1px 3px rgba(0,0,0,.3); }
129
+ /* file variants */
130
+ .zs-field[data-zs-file-variant="avatar"] { --zs-avatar-size: 128px; }
131
+ .zs-field[data-zs-file-variant="gallery"] .zs-file-list { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }
132
+ /* range skins */
133
+ .zs-range[data-zs-range="gradient"] { --zs-range-gradient: linear-gradient(90deg, #22c55e, #eab308); }
134
+ ```
135
+
136
+ `data-zs-file-variant` is set on the field root; the drop target also carries
137
+ `zs-file-drop--<variant>`. `data-zs-range` is set on `.zs-range`, and validation-driven
138
+ icons/progress are keyed off `[data-zs-validation]` and `data-zs-upload-state`.
139
+
140
+
99
141
  ### Scrollbar
100
142
 
101
143
  `--zs-scrollbar-size`, `--zs-scrollbar-thumb`, `--zs-scrollbar-thumb-hover`,
@@ -13,6 +13,7 @@ native validation, `FormData` and third-party validators keep working.
13
13
  | Signal | Written by | Used for |
14
14
  | --- | --- | --- |
15
15
  | `input.validity` | the browser | source of truth |
16
+ | `input.setCustomValidity()` | plugin | phone length, weekends, blocked dates, custom `validate`, file limits |
16
17
  | `aria-invalid` | plugin (`setValidation`) or your validator | screen readers and CSS |
17
18
  | `.zs-field--invalid` / `.zs-field--valid` | plugin | theme states |
18
19
  | `data-zs-validation="valid\|invalid"` | plugin | attribute-based styling |
@@ -27,6 +28,41 @@ It clears the state on `input`/`change` once validity passes, on `form.reset()`,
27
28
  `setValidation(null)` is called. `data-zidan-validation="invalid"` forces the state without
28
29
  native validity.
29
30
 
31
+ ## Built-in rules (written into native validity)
32
+
33
+ These rules call `input.setCustomValidity(message)`, so `form.checkValidity()`,
34
+ `:invalid`, `validationMessage` and third-party validators that read native validity all see
35
+ them. Clearing the value (or fixing it) clears the message.
36
+
37
+ | Control | Rule | Enable with | Message key |
38
+ | --- | --- | --- | --- |
39
+ | `tel` | Length per country (10–11 digits for GB, 10 for US, …) | `data-zidan-phone`, `phone.validate !== false` | `messages.phone` (`{country}`, `{min}`, `{max}`) |
40
+ | `date` | Sat/Sun blocked | `data-zidan-disable-weekends` | `messages.weekend` |
41
+ | `date` | Specific ISO dates blocked | `data-zidan-disabled-dates="2026-12-25,…"` or `disabledDates` function | `messages.dateDisabled` |
42
+ | `date` | Custom date rule | JS `validateDate(value, date, field)` | `messages.date` or the returned string |
43
+ | text / textarea | Custom rule | JS `validate(value, field)` | `messages.generic` or the returned string |
44
+ | file | Count / size / type | `maxFiles`, `maxSize` (or `maxSizeMB`), `accept` | `messages.fileCount`, `fileSize`, `fileType` |
45
+
46
+ ```js
47
+ zidanField('#start', {
48
+ disableWeekends: true,
49
+ disabledDates: ['2026-12-25', '2027-01-01'],
50
+ validateDate(value, date) {
51
+ return date < new Date('2026-11-01') ? 'Pick a date after 1 November.' : true;
52
+ }
53
+ });
54
+ ```
55
+
56
+ Override any message globally before initialising:
57
+
58
+ ```js
59
+ Object.assign(ZidanForm.messages, {
60
+ phone: 'Enter a valid {country} number ({min}–{max} digits).',
61
+ weekend: 'We are closed at weekends — pick a weekday.',
62
+ fileSize: '“{name}” is {size}; the limit is {limit}.'
63
+ });
64
+ ```
65
+
30
66
  ## The hidden-input trap
31
67
 
32
68
  jQuery Validation's default `ignore: ":hidden"` checks `offsetWidth`/`offsetHeight`.
@@ -164,7 +200,8 @@ field instead.
164
200
 
165
201
  ## Preventing double submits
166
202
 
167
- The plugin deliberately does not submit or block forms. Use an idempotent guard:
203
+ The plugin never submits forms. It mirrors state and writes custom rules into native validity,
204
+ so your submit handler stays in charge. Use an idempotent guard:
168
205
 
169
206
  ```js
170
207
  const form = document.getElementById('form');
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "zidan-select",
3
- "version": "2.0.1",
4
- "description": "Zero-dependency form enhancement library: select/combobox/tags, checkboxes, switches, radio groups, drag & drop file upload and text inputs with split core/theme CSS, 5 themes, 5 layouts and framework adapters.",
3
+ "version": "2.1.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 and framework adapters.",
5
5
  "keywords": [
6
6
  "select",
7
7
  "combobox",