zidan-select 2.4.0 → 2.4.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/docs/options.md CHANGED
@@ -7,9 +7,10 @@ passed to `initZidanSelects()` / `initZidanForms()` / `zidanSelect()` / `zidanFi
7
7
  `data-zidan*` attribute, which is how JS-only options are applied.
8
8
 
9
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.
10
+ > [field playground](https://akhtar1985.github.io/zidan-select/playground.html) exposes the main
11
+ > options for one control at a time and copies both supported HTML attributes and vanilla
12
+ > JavaScript. The [API lab](https://akhtar1985.github.io/zidan-select/#lab) exercises the complete
13
+ > option, callback, method and event inventory.
13
14
 
14
15
  ## Direct init by ID or class
15
16
 
@@ -131,13 +132,18 @@ Applies to `ZidanCheckbox`, `ZidanRadioGroup`, `ZidanFileUpload`, `ZidanTextFiel
131
132
 
132
133
  | JS option | Data attribute | Type | Default | Notes |
133
134
  | --- | --- | --- | --- | --- |
134
- | `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`. |
135
+ | `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 uses `rangeVariant`. |
135
136
  | `layout` | `data-zidan-layout` | string | `stacked` | `stacked`, `inline`, `compact`, `floating`, `outlined`, `card`. |
136
137
  | `theme` | `data-zidan-theme`, `data-zs-theme` | string | `default` | `default`, `modern`, `minimal`, `dark`, `glass`. Resolves element → ancestor → `<html>`. |
137
138
  | `framework` | `data-zidan-framework`, `data-zs-framework` | string | `none` | `none`, `bootstrap`, `tailwind`, `bulma`, `foundation`, `vanilla`. |
138
139
  | `label` | `data-zidan-label` | string | — | Used when the markup has no `<label>`; a generated label is `<label for>`. If the markup already has a `<label>`, the generated one replaces it and the original is hidden until `destroy()`. |
139
140
  | `hint` | `data-zidan-hint` | string | — | Rendered under the control and linked via `aria-describedby`. |
140
- | `validation` | `data-zidan-validation` | `valid` \| `invalid` | — | Initial state; later states come from validity or `setValidation()`. A preset `invalid` is pinned: it survives initialisation and programmatic `update()`/`refresh()`/`setValue()` until the user edits the control or you pass `setValidation(null)`. |
141
+ | `description` | `data-zidan-description` | string | — | Second line for card, tile, button and minimal checkbox/radio variants. |
142
+ | `descriptions` | — | object | — | Radio group: `{ value: 'Description' }` fallback descriptions. |
143
+ | `messages` | — | object | — | Override built-in validation messages, including `required`, `phone`, `weekend` and `generic`. |
144
+ | `validate(value, field, context)` | — | function | — | Custom rule for text, checkbox, radio or file fields. Return `true`, `false`, a message string, Error or Promise; `context` is `{ signal, field, instance }`. |
145
+ | `showValidState` | — | boolean | `false` | Show a positive state after a successful async rule. |
146
+ | `validation` | `data-zidan-validation` | `valid` \| `invalid` | — | Initial state; later states come from validity or `setValidation()`. A preset `invalid` survives `update()` / `refresh()` and internal mirrors until user input/change/blur or `setValidation(null)`; programmatic value helpers that dispatch `change`, and a non-empty select value, also clear it. |
141
147
  | `alwaysValidate` | — | boolean | `false` | Mark invalid as soon as native validity fails instead of on blur. |
142
148
  | `indeterminate` | `data-zidan-indeterminate` | boolean | `false` | Checkbox starts mixed. |
143
149
  | `clearable` | `data-zidan-clear` | boolean | `search` only | Clear button for text inputs and textarea. |
@@ -163,11 +169,22 @@ Applies to `ZidanCheckbox`, `ZidanRadioGroup`, `ZidanFileUpload`, `ZidanTextFiel
163
169
  | --- | --- |
164
170
  | `onInit` | `{ instance, variant?, type? }` |
165
171
  | `onChange` | `{ instance, value }` (text/radio), `{ instance, checked, value }` (checkbox), `{ instance, files }` (file) |
166
- | `onValidation` | `{ instance, state }` where `state` is `valid`, `invalid` or `null` |
167
- | `onRemove` | `{ instance, file }` |
168
-
169
- DOM events with the same information: `zidan:init`, `zidan:change`, `zidan:validation`,
170
- `zidan:remove`, `zidan:reveal`, `zidan:clear`, `zidan:destroy`, `zidan:error`.
172
+ | `onInput` | `{ instance, value }` (text/range) |
173
+ | `onValidation` | `{ instance, state, message? }` where `state` is `valid`, `invalid` or `null` |
174
+ | `onIconClick` | `{ instance, icon, position }` |
175
+ | `onStep` | `{ instance, value, direction }` |
176
+ | `onPicker` | `{ instance, type }` |
177
+ | `onPhoneCountry` | `{ instance, country }` |
178
+ | `onPhoneFormat` | `{ instance, format }` |
179
+ | `onRemove` | `{ instance, file, index }` |
180
+ | `onUploadStart` / `onUploadProgress` / `onUploadSuccess` | `{ instance, file, name, ... }` with size, progress or result |
181
+ | `onUpload` | Alias of `onUploadSuccess`. |
182
+ | `onUploadError` / `onUploadCancel` | `{ instance, file, name, error?, message? }` |
183
+
184
+ DOM events with the same information: `zidan:init`, `zidan:change`, `zidan:input`,
185
+ `zidan:validation`, `zidan:async-validation`, `zidan:remove`, `zidan:reveal`, `zidan:clear`,
186
+ `zidan:icon-click`, `zidan:step`, `zidan:picker`, `zidan:phone-country`, `zidan:phone-format`,
187
+ `zidan:upload-*`, `zidan:destroy` and `zidan:error`.
171
188
 
172
189
  ## Checkbox, switch & radio variants
173
190
 
@@ -241,6 +258,7 @@ Icons are sanitised with `DOMParser`: only SVG shape elements and safe attribute
241
258
  | `stepperInterval` | `data-zidan-stepper-interval` | number | `90` | Repeat interval, ms. |
242
259
  | `stepperUpLabel` | `data-zidan-stepper-up-label` | string | `Increase value` | Aria-label of “+”. |
243
260
  | `stepperDownLabel` | `data-zidan-stepper-down-label` | string | `Decrease value` | Aria-label of “−”. |
261
+ | `stepperStep` | — | number | native `step` | Increment used by the stepper buttons and `stepUp()` / `stepDown()`. |
244
262
 
245
263
  ```html
246
264
  <input type="number" min="0" max="10" value="3" data-zidan="input"
@@ -252,6 +270,8 @@ Icons are sanitised with `DOMParser`: only SVG shape elements and safe attribute
252
270
  ```
253
271
 
254
272
  Methods: `stepUp(times = 1)`, `stepDown(times = 1)`, `setStepper(enabled)`.
273
+ `setStepper()` toggles the source attribute; destroy and reinitialise the field to add or remove
274
+ the generated stepper buttons.
255
275
  Event: `zidan:step` → `{ value, direction, instance }`.
256
276
 
257
277
  ## Phone formatting
@@ -524,6 +544,7 @@ Callbacks: `onUploadStart`, `onUploadProgress`, `onUploadSuccess` / `onUpload`,
524
544
  | `suggestions` | — | Tags suggestions. |
525
545
  | `value` | — | Initial value(s). |
526
546
  | `label` | `data-zidan-label` | Floating label text. An author `<label>` for the same control is hidden while the field is enhanced and restored by `destroy()`. |
547
+ | `ariaLabel` | — | Accessible name for the generated combobox input; defaults to `label`. |
527
548
  | `placeholder` | `data-zidan-placeholder` | Trigger placeholder. |
528
549
 
529
550
  ### Behaviour
@@ -591,9 +612,11 @@ users.refreshOptions(); // clears the cache and refetches page 0
591
612
  users.clearCache(); // drop cached pages only
592
613
  ```
593
614
 
594
- `fetchOptions` may also reject: the current list stays on screen, the footer shows the error
595
- and clicking it retries. Appended fetches emit `zidan:load-more` with `{ page, query }`;
596
- failures emit the usual `zidan:error`.
615
+ `fetchOptions` may also reject: an initial failure shows an error state and
616
+ `getAsyncState().error` keeps the message; call `refreshOptions()` to retry. If an appended page
617
+ fails, the rows already loaded stay visible and the footer shows the error; clicking it retries.
618
+ Appended fetches emit `zidan:load-more` with `{ page, query }`; failures emit the usual
619
+ `zidan:error`.
597
620
 
598
621
  The cache size is global: `ZidanSelect.cacheLimit = 50` pages (least-recently-used eviction).
599
622
 
@@ -643,16 +666,26 @@ control shows `"…" is not in the list.` through the tag error slot. Leave the
643
666
  | Option | Signature |
644
667
  | --- | --- |
645
668
  | `filterOption(item, query)` | return boolean |
646
- | `renderOption(item, index)` | HTML string or element |
647
- | `renderSelected(value)` | HTML string or element |
648
- | `renderTag(tag)` | HTML string or element |
649
- | `validateTag(tag)` | boolean or message string |
650
- | `formatTag(tag)` | display string |
669
+ | `renderOption(item, context)` | HTML string or element; `context` is `{ index, selected, active, query, instance }`. |
670
+ | `renderSelected(item, context)` | HTML string or element; `context` is `{ index, instance }`. |
671
+ | `renderTag(item, context)` | HTML string or element; `context` is `{ index, instance, disabled }`. |
672
+ | `validateTag(tag, tags, context)` | boolean or message string; `tag` is the formatted string, `tags` is the current tag list. |
673
+ | `formatTag(tag, context)` | display string; `context` is `{ instance, tags }`. |
651
674
 
652
675
  ### Select callbacks
653
676
 
654
- `onInit`, `onChange`, `onSelect`, `onOpen`, `onClose`, `onTagAdd`, `onTagRemove`, `onLoadMore`, `onError`.
655
- Every callback receives a single payload object with `instance` and the relevant value(s).
677
+ | Callback | Payload |
678
+ | --- | --- |
679
+ | `onInit` | `{ instance, mode, value }` |
680
+ | `onChange` | `{ instance, value, previousValue? }` |
681
+ | `onSelect` | `{ instance, value, item }` |
682
+ | `onOpen` / `onClose` | `{ instance }` |
683
+ | `onTagAdd` | `{ instance, tag, value }` |
684
+ | `onTagRemove` | `{ instance, tag, value }` |
685
+ | `onLoadMore` | `{ instance, page, query }` |
686
+ | `onError` | `{ instance, message, error?, callback? }` |
687
+
688
+ Every callback receives a single payload object.
656
689
 
657
690
  ### Every select option in one object
658
691
 
@@ -683,6 +716,7 @@ const picker = zidanSelect('#mymov', {
683
716
  // suggestions: ['Interstellar', 'Oppenheimer'],
684
717
  // value: 'inception', // string, or array for multiple/tags
685
718
  label: 'Movie',
719
+ ariaLabel: 'Choose a movie',
686
720
  placeholder: 'Search a movie…',
687
721
 
688
722
  /* Behaviour */
@@ -702,6 +736,17 @@ const picker = zidanSelect('#mymov', {
702
736
  // .then(function (response) { return response.json(); }); // items[] or { items, hasMore }
703
737
  // },
704
738
  fetchPageSize: 0, // >0 enables paged responses, load-more and scroll auto-load
739
+ fetchUrl: null, // declarative AJAX endpoint; no fetchOptions needed
740
+ fetchQueryParam: 'q', // '' omits the search parameter
741
+ fetchPageParam: 'page', // 1-based; '' omits it
742
+ fetchSkipParam: null, // e.g. 'skip' sends page × fetchPageSize
743
+ fetchPageSizeParam: 'limit', // '' omits the page-size parameter
744
+ fetchItemsPath: null, // e.g. 'data.items'; common array names are auto-detected
745
+ fetchTotalPath: null, // row count used to calculate hasMore
746
+ fetchHasMorePath: null, // boolean path used instead of a total
747
+ fetchMethod: 'GET',
748
+ fetchHeaders: null, // e.g. { Authorization: 'Bearer …' }
749
+ fetchCredentials: 'same-origin', // 'omit' | 'same-origin' | 'include'
705
750
  autoLoadMore: true,
706
751
  cacheResults: true, // ZidanSelect.cacheLimit = 50 pages, LRU
707
752
  loadMoreText: 'Load more',
@@ -722,15 +767,24 @@ const picker = zidanSelect('#mymov', {
722
767
 
723
768
  /* Rendering hooks */
724
769
  // filterOption: function (item, query) { return item.label.toLowerCase().includes(query.toLowerCase()); },
725
- // renderOption: function (item) { return '<strong>' + item.label + '</strong>'; },
726
- // renderSelected: function (value) { return value; },
727
- // renderTag: function (tag) { return tag; },
728
- // validateTag: function (tag) { return tag.length <= 24 || 'Use 24 characters or fewer'; },
729
- // formatTag: function (tag) { return tag.toUpperCase(); },
770
+ // renderOption: function (item, context) {
771
+ // return (context.selected ? '✓ ' : '') + item.label;
772
+ // },
773
+ // renderSelected: function (item, context) { return '◉ ' + item.label; },
774
+ // renderTag: function (item, context) { return String(item.label).toUpperCase(); },
775
+ // validateTag: function (tag, tags, context) { return tag.length <= 24 || 'Use 24 characters or fewer'; },
776
+ // formatTag: function (tag, context) { return tag.toUpperCase(); },
730
777
 
731
- /* Callbacks — also: onSelect, onOpen, onClose, onTagAdd, onTagRemove, onLoadMore, onError */
778
+ /* Callbacks */
732
779
  onInit: function (event) { console.log('init', event.instance); },
733
- onChange: function (event) { console.log('value', event.value); }
780
+ onChange: function (event) { console.log('value', event.value); },
781
+ // onSelect: function (event) { console.log('selected', event.item); },
782
+ // onOpen: function (event) { console.log('opened', event.instance); },
783
+ // onClose: function (event) { console.log('closed', event.instance); },
784
+ // onTagAdd: function (event) { console.log('tag added', event.tag); },
785
+ // onTagRemove: function (event) { console.log('tag removed', event.tag); },
786
+ // onLoadMore: function (event) { console.log('loading page', event.page); },
787
+ // onError: function (event) { console.log('error', event.message); }
734
788
  });
735
789
  ```
736
790
 
@@ -748,8 +802,12 @@ as JSON.
748
802
  `data-zidan-multiple`, `data-zidan-searchable`, `data-zidan-clearable`, `data-zidan-disabled`,
749
803
  `data-zidan-allow-free-text`, `data-zidan-max-tags`, `data-zidan-min-tag-length`,
750
804
  `data-zidan-max-tag-length`, `data-zidan-case-sensitive`, `data-zidan-validation`,
751
- `data-zidan-scrollbar`, and the JSON escape hatch `data-zidan-options` (any JS option that
752
- takes a literal value). Marker classes: `zidan-select`, `zidan-field`, `zidan-form`.
805
+ `data-zidan-scrollbar`, `data-zidan-fetch-url`, `data-zidan-fetch-method`,
806
+ `data-zidan-fetch-query-param`, `data-zidan-fetch-page-param`, `data-zidan-fetch-skip-param`,
807
+ `data-zidan-fetch-page-size`, `data-zidan-fetch-page-size-param`, `data-zidan-fetch-items-path`,
808
+ `data-zidan-fetch-total-path`, `data-zidan-fetch-has-more-path`, and the JSON escape hatch
809
+ `data-zidan-options` (any JS option that takes a literal value). Marker classes:
810
+ `zidan-select`, `zidan-field`, `zidan-form`.
753
811
 
754
812
  ## Defaults
755
813
 
@@ -782,12 +840,17 @@ to any field that should span the row) rather than putting it on a single field.
782
840
  | `getValue()` | Text/textarea value, checked value, radio value or selected files. |
783
841
  | `setValue(v)` | Writes to the native control and re-renders. |
784
842
  | `update()` / `refresh()` | Re-read native state (checked, disabled, validity, value). |
785
- | `setValidation('valid'\|'invalid'\|null)` | Mirrors state to classes and `aria-invalid`. A public `'invalid'` call pins the state, so `update()`/`refresh()`/`setValue()` keep it until the user edits the control or you clear it. |
843
+ | `validationTargets()` | Native element(s) whose constraints are mirrored. |
844
+ | `setValidation('valid'\|'invalid'\|null)` | Mirrors state to classes and `aria-invalid`. A public `'invalid'` call survives `update()` / `refresh()` and internal mirrors; user input/change/blur, value helpers that dispatch `change`, a non-empty select value, or another public state call clears/replaces it. |
786
845
  | `getValidation()` | Current validation state. |
846
+ | `setError(message)` / `clearError()` | Set or clear the rendered error and invalid state. |
847
+ | `checkAsync()` | Promise resolving to the custom-rule result; runs pending state and stale guards. |
848
+ | `validate()` | Promise resolving to overall validity after native and custom rules. |
849
+ | `isPending()` | Whether an async rule is currently running. |
787
850
  | `setTheme(name)`, `setFramework(name)`, `setLayout(name)` | Scoped restyling. |
788
851
  | `destroy()` | Restores the original DOM and removes every listener. |
789
852
 
790
- Checkbox adds `setIndeterminate(bool)` and `isChecked()`.
853
+ Checkbox adds `setIndeterminate(bool)`, `setChecked(bool)` and `isChecked()`.
791
854
 
792
855
  Text inputs add `stepUp(times?)`, `stepDown(times?)`, `setStepper(bool)`,
793
856
  `getPhoneCountry()`, `setPhoneCountry(iso)`, `setPhoneFormat(format)`, `formatPhone(value?)`
@@ -802,18 +865,26 @@ File adds `getFiles()`, `getUploadState()`, `addFiles()`, `replaceFiles()`, `rem
802
865
  `open()`, `close()`, `toggle()`, `isOpen()`, `getValue()`, `setValue()`, `clear()`,
803
866
  `setOptions(items)`, `addTag()`, `removeTag()`, `getTags()`, `enable()`, `disable()`,
804
867
  `setLayout()`, `setFramework()`, `setScrollbar()`, `setValidation()`, `refresh()`,
868
+ `loadMore()`, `hasMoreResults()`, `getAsyncState()`, `refreshOptions()`, `clearCache()`,
805
869
  `on(event, handler)`, `off(event, handler)`, `announce(message)`, `destroy()`.
806
870
 
807
871
  ## Events
808
872
 
809
873
  | Event | Detail |
810
874
  | --- | --- |
811
- | `zidan:init` | `{ instance, kind \| mode }` |
812
- | `zidan:change` | `{ instance, value }`, `{ checked }`, `{ files }` |
875
+ | `zidan:init` | `{ instance, kind \| mode, ... }` |
876
+ | `zidan:change` | `{ instance, value, previousValue? }`, `{ checked }`, `{ files }` |
877
+ | `zidan:input` | `{ instance, value }` (text/range) |
813
878
  | `zidan:validation` | `{ instance, state, message? }` |
879
+ | `zidan:async-validation` | `{ instance, valid, message, error? }` |
880
+ | `zidan:open` / `zidan:close` | `{ instance }` (select) |
881
+ | `zidan:select` | `{ instance, value, item }` (select) |
882
+ | `zidan:no-results` | `{ instance, query }` (select) |
883
+ | `zidan:tag-add` / `zidan:tag-remove` | `{ instance, tag, value }` (select tags) |
884
+ | `zidan:load-more` | `{ instance, page, query }` (select pagination) |
885
+ | `zidan:reveal` | `{ instance, visible }` (password) |
814
886
  | `zidan:remove` | `{ instance, file, index? }` (file upload) |
815
- | `zidan:input` | `{ instance, value }` (text/range) |
816
- | `zidan:step` | `{ instance, value, direction }` (number stepper) |
887
+ | `zidan:step` | `{ instance, value, direction, step }` (number stepper) |
817
888
  | `zidan:phone-country` | `{ instance, country }` |
818
889
  | `zidan:phone-format` | `{ instance, format }` |
819
890
  | `zidan:icon-click` | `{ instance, icon, position }` |
@@ -12,70 +12,91 @@
12
12
  <meta property="og:url" content="https://akhtar1985.github.io/zidan-select/docs/validation.html">
13
13
  <meta property="og:image" content="https://akhtar1985.github.io/zidan-select/docs/demo-inputs.png">
14
14
  <meta name="twitter:card" content="summary_large_image">
15
+ <meta name="theme-color" content="#4f6bed">
16
+ <meta property="og:site_name" content="ZidanForm">
17
+ <meta property="og:image" content="https://akhtar1985.github.io/zidan-select/docs/demo-inputs.png">
18
+ <meta name="twitter:card" content="summary_large_image">
15
19
  <link rel="stylesheet" href="../plugin-core.css">
16
20
  <link rel="stylesheet" href="../plugin-theme.css">
17
- <style>
18
- * { box-sizing: border-box; }
19
- body {
20
- margin: 0;
21
- padding: 40px 22px 70px;
22
- font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
23
- color: #101324;
24
- background: #f5f6fb;
25
- line-height: 1.55;
26
- }
27
- main { max-width: 900px; margin: 0 auto; }
28
- h1 { margin: 0 0 6px; font-size: 1.9rem; letter-spacing: -0.02em; }
29
- .lead { margin: 0 0 26px; color: #525a70; }
30
- .grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); gap: 16px; }
31
- .card {
32
- background: #fff;
33
- border: 1px solid #e4e8f1;
34
- border-radius: 16px;
35
- padding: 20px;
36
- box-shadow: 0 1px 2px rgba(16, 19, 36, 0.05);
37
- }
38
- .card h2 { margin: 0 0 2px; font-size: 1rem; }
39
- .card p { margin: 0 0 16px; font-size: 0.8125rem; color: #6b7385; }
40
- .card form { display: flex; flex-direction: column; gap: 14px; }
41
- .status { margin-top: 12px; font-size: 0.8125rem; color: #067647; min-height: 20px; }
42
- .status[data-state="error"] { color: #b42318; }
43
- .status[data-state="missing"] { color: #b45309; }
44
- button.submit {
45
- align-self: flex-start;
46
- font: inherit;
47
- font-size: 0.85rem;
48
- font-weight: 600;
49
- padding: 9px 16px;
50
- border-radius: 999px;
51
- border: 0;
52
- color: #fff;
53
- background: linear-gradient(140deg, #4f6bed, #6f5cf0);
54
- cursor: pointer;
55
- }
56
- label.error { color: #b42318; font-size: 0.75rem; }
57
- .just-validate-error-label { color: #b42318; font-size: 0.75rem; margin-top: 4px; }
58
- .parsley-errors-list { color: #b42318; font-size: 0.75rem; list-style: none; padding: 0; margin: 4px 0 0; }
59
- .back { display: inline-block; margin-bottom: 18px; font-size: 0.85rem; color: #4f6bed; }
60
- </style>
21
+ <link rel="stylesheet" href="../demo.css">
22
+ <link rel="stylesheet" href="../nav.css">
23
+ <link rel="stylesheet" href="../docs.css">
61
24
  </head>
62
25
  <body>
63
- <main>
64
- <a class="back" href="index.html">← documentation</a>
65
- <h1>Validation-library test bench</h1>
66
- <p class="lead">
67
- The same plugin markup under four validators. Everything is loaded from a CDN, so this
68
- page also works as a smoke test: submit each empty form, then fill it in.
69
- </p>
26
+ <a class="skip-link" href="#docs-main">Skip to content</a>
27
+ <div class="bg-orbs" aria-hidden="true"><span class="orb"></span></div>
70
28
 
71
- <div class="grid">
29
+ <header class="site-header">
30
+ <a class="brand" href="../index.html">
31
+ <span class="logo-mark" aria-hidden="true">Z</span>
32
+ <span>
33
+ <span class="brand-name">ZidanForm</span>
34
+ <span class="brand-sub">v2.4.2 · zero dependencies</span>
35
+ </span>
36
+ </a>
37
+ <button class="nav-toggle" type="button" aria-expanded="false" aria-controls="site-nav">
38
+ <span class="nav-toggle-bars" aria-hidden="true"><span></span><span></span><span></span></span>
39
+ <span>Menu</span>
40
+ </button>
41
+ <nav class="header-nav" id="site-nav" aria-label="Project links">
42
+ <a href="../index.html">Demo</a>
43
+ <a href="../advanced.html">Advanced</a>
44
+ <a href="../playground.html">Playground</a>
45
+ <a href="../ajax.html">AJAX</a>
46
+ <a href="../shopify.html">Shopify</a>
47
+ <a href="../index.html#compare">Compare</a>
48
+ <a href="../index.html#faq">FAQ</a>
49
+ <details class="nav-docs">
50
+ <summary>Docs</summary>
51
+ <div class="nav-docs-panel">
52
+ <a href="index.html">Documentation index</a>
53
+ <a href="options.html">Options &amp; data attributes</a>
54
+ <a href="comparison.html">Why &amp; comparison</a>
55
+ <a href="frameworks.html">Frameworks</a>
56
+ <a href="html-and-wordpress.html">HTML &amp; WordPress</a>
57
+ <a href="validation-guide.html">Validation</a>
58
+ <a href="validation.html" aria-current="page">Validation test bench</a>
59
+ <a href="theming.html">Theming</a>
60
+ <a href="build.html">Build &amp; publish</a>
61
+ </div>
62
+ </details>
63
+ <a href="https://github.com/akhtar1985/zidan-select">GitHub</a>
64
+ <a href="https://www.npmjs.com/package/zidan-select">npm</a>
65
+ <label class="sr-only" for="quick-theme">Page theme</label>
66
+ <select id="quick-theme" aria-label="Page theme">
67
+ <option value="default">Default theme</option>
68
+ <option value="modern">Modern</option>
69
+ <option value="minimal">Minimal</option>
70
+ <option value="dark">Dark</option>
71
+ <option value="glass">Glass</option>
72
+ </select>
73
+ </nav>
74
+ </header>
75
+
76
+ <main id="docs-main" class="wrap docs-main">
77
+ <section class="hero docs-hero" aria-labelledby="docs-title">
78
+ <p class="eyebrow"><span class="eyebrow-dot" aria-hidden="true"></span> Validation · live test bench</p>
79
+ <h1 id="docs-title">One form, <span>four validators.</span></h1>
80
+ <p class="doc-blurb">
81
+ The same plugin markup under native HTML5, jQuery Validation, JustValidate and Parsley.
82
+ Everything is loaded from a CDN, so this page also works as a smoke test: submit each
83
+ empty form, then fill it in.
84
+ </p>
85
+ <div class="hero-actions">
86
+ <a class="btn btn-primary" href="validation-guide.html">Read the validation guide</a>
87
+ <a class="btn" href="index.html">All documentation</a>
88
+ <a class="btn" href="../playground.html">Field playground</a>
89
+ </div>
90
+ </section>
91
+
92
+ <div class="validation-grid">
72
93
  <section class="card">
73
94
  <h2>Native HTML5</h2>
74
95
  <p>Constraint validation and <code>aria-invalid</code> mirroring.</p>
75
96
  <form id="form-native" novalidate>
76
97
  <input name="email" type="email" required data-zidan="input" data-zidan-label="Email">
77
98
  <label><input type="checkbox" name="terms" required data-zidan="checkbox" data-zidan-label="Accept terms"> Accept terms</label>
78
- <button class="submit" type="submit">Submit</button>
99
+ <button class="btn btn-primary" type="submit">Submit</button>
79
100
  </form>
80
101
  <p class="status" id="native-status" role="status"></p>
81
102
  </section>
@@ -86,7 +107,7 @@
86
107
  <form id="form-jquery">
87
108
  <input name="email" id="jq-email" type="email" required data-zidan="input" data-zidan-label="Email">
88
109
  <input name="name" id="jq-name" required minlength="3" data-zidan="input" data-zidan-label="Name">
89
- <button class="submit" type="submit">Submit</button>
110
+ <button class="btn btn-primary" type="submit">Submit</button>
90
111
  </form>
91
112
  <p class="status" id="jquery-status" role="status"></p>
92
113
  </section>
@@ -97,7 +118,7 @@
97
118
  <form id="form-justvalidate">
98
119
  <input name="email" id="jv-email" data-zidan="input" data-zidan-label="Email">
99
120
  <input name="name" id="jv-name" data-zidan="input" data-zidan-label="Name">
100
- <button class="submit" type="submit">Submit</button>
121
+ <button class="btn btn-primary" type="submit">Submit</button>
101
122
  </form>
102
123
  <p class="status" id="justvalidate-status" role="status"></p>
103
124
  </section>
@@ -110,13 +131,32 @@
110
131
  data-zidan="input" data-zidan-label="Email">
111
132
  <input name="name" id="parsley-name" data-parsley-required data-parsley-minlength="3"
112
133
  data-zidan="input" data-zidan-label="Name">
113
- <button class="submit" type="submit">Submit</button>
134
+ <button class="btn btn-primary" type="submit">Submit</button>
114
135
  </form>
115
136
  <p class="status" id="parsley-status" role="status"></p>
116
137
  </section>
117
138
  </div>
139
+
140
+ <p class="doc-source-note">
141
+ The native controls stay reachable for each validator. Read the
142
+ <a href="validation-guide.html">validation compatibility guide</a> for configuration and
143
+ double-submit patterns.
144
+ </p>
118
145
  </main>
119
146
 
147
+ <footer class="site-footer">
148
+ <div class="wrap">
149
+ <p>
150
+ <strong>ZidanForm</strong> — MIT licensed, no dependencies.
151
+ <a href="../index.html">Demo</a> ·
152
+ <a href="../playground.html">Playground</a> ·
153
+ <a href="index.html">Documentation</a> ·
154
+ <a href="https://github.com/akhtar1985/zidan-select">GitHub</a>
155
+ </p>
156
+ </div>
157
+ </footer>
158
+
159
+ <script src="../nav.js"></script>
120
160
  <script src="../zidan-form.js"></script>
121
161
  <script src="https://code.jquery.com/jquery-3.7.1.min.js"></script>
122
162
  <script src="https://cdn.jsdelivr.net/npm/jquery-validation@1.20.0/dist/jquery.validate.min.js"></script>
@@ -30,12 +30,12 @@ It clears the state on `input`/`change` once validity passes, on `form.reset()`,
30
30
  native validity.
31
31
 
32
32
  A state set through the public `setValidation('invalid')` (and a preset
33
- `data-zidan-validation="invalid"`) is **pinned**: re-rendering the field — `update()`,
34
- `refresh()`, `setValue()`, an option chosen in a select, an async rule that resolves clean —
35
- will not clear it. That is what makes a server-side error survive until the user actually
36
- touches the control. The pin is released by the next `input`, `change` or `blur` from the user,
37
- or by `setValidation(null)` / `setValidation('valid')`. Internal mirrors pass a second argument
38
- (`setValidation(state, true)`) so they never pin a state themselves.
33
+ `data-zidan-validation="invalid"`) is **pinned against re-renders**: `update()`, `refresh()`
34
+ and internal validity mirrors or async re-checks do not clear it. The pin is released by the
35
+ next `input`, `change` or `blur`, or by `setValidation(null)` / `setValidation('valid')`.
36
+ Programmatic value helpers can release it too: field `setValue()` / `setChecked()` dispatch
37
+ `change`, and applying a non-empty select value clears the select's invalid option. Internal
38
+ mirrors pass a second argument (`setValidation(state, true)`) so they never pin a state.
39
39
 
40
40
  ## Built-in rules (written into native validity)
41
41
 
@@ -104,7 +104,7 @@ email.isPending(); // true while the request is in flight
104
104
 
105
105
  Submission is blocked while pending because the native control carries the pending message;
106
106
  listen for `zidan:async-validation` if you need your own spinner or toast. `destroy()` aborts
107
- any in-flight check, and `field.reset()` clears the pending state.
107
+ any in-flight check, and `form.reset()` clears the pending state.
108
108
 
109
109
  ## The hidden-input trap
110
110
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zidan-select",
3
- "version": "2.4.0",
3
+ "version": "2.4.2",
4
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",
@@ -102,7 +102,7 @@
102
102
  "test": "node scripts/test.mjs",
103
103
  "types": "tsc -p tsconfig.types.json",
104
104
  "prepublishOnly": "npm run build && npm run types && npm test",
105
- "lint": "node --check zidan-form.js && node --check demo.js && node --check advanced.js && node --check playground.js && node --check nav.js && node --check zidan-form.mjs",
105
+ "lint": "node --check zidan-form.js && node --check demo.js && node --check lab.js && node --check advanced.js && node --check ajax.js && node --check playground.js && node --check nav.js && node --check scripts/docs.mjs && node --check zidan-form.mjs",
106
106
  "release": "node scripts/release.mjs",
107
107
  "search": "node scripts/exa-search.mjs"
108
108
  },
package/plugin-core.css CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * ZidanForm v2.4.0 — plugin-core.css
2
+ * ZidanForm v2.4.2 — plugin-core.css
3
3
  * Structure and mechanics only: layout, positioning, visibility, focus
4
4
  * plumbing and accessible native-input handling. No colours, borders colours,
5
5
  * shadows or decorative skin — load plugin-theme.css (or your own theme) for
package/plugin-theme.css CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * ZidanForm v2.4.0 — plugin-theme.css
2
+ * ZidanForm v2.4.2 — plugin-theme.css
3
3
  * Design tokens, paint, state colours, preset themes (default, modern,
4
4
  * minimal, dark, glass), the five select layouts and framework adapters
5
5
  * (bootstrap, tailwind, bulma, foundation).
package/zidan-form.d.ts CHANGED
@@ -59,19 +59,19 @@ export type FetchOptions = (
59
59
  export interface SelectCallbacks {
60
60
  filterOption?(item: SelectItem, query: string, context: { instance: ZidanSelect; mode: SelectMode; caseSensitive: boolean; selected: boolean }): boolean;
61
61
  renderOption?(item: SelectItem, context: { index: number; selected: boolean; active: boolean; query: string; instance: ZidanSelect }): string | Node | null | undefined;
62
- renderSelected?(item: SelectItem, instance: ZidanSelect): string | Node | null | undefined;
63
- renderTag?(item: SelectItem, instance: ZidanSelect): string | Node | null | undefined;
64
- validateTag?(tag: string, tags: string[], context: { instance: ZidanSelect }): boolean | string | void;
65
- formatTag?(tag: string, instance: ZidanSelect): string;
62
+ renderSelected?(item: Pick<SelectItem, 'value' | 'label'>, context: { index: number; instance: ZidanSelect }): string | Node | null | undefined;
63
+ renderTag?(item: Pick<SelectItem, 'value' | 'label'>, context: { index: number; instance: ZidanSelect; disabled: boolean }): string | Node | null | undefined;
64
+ validateTag?(tag: string, tags: SelectItem[], context: { instance: ZidanSelect }): boolean | string | void;
65
+ formatTag?(tag: string, context: { instance: ZidanSelect; tags: SelectItem[] }): string;
66
66
  onInit?(detail: { instance: ZidanSelect; mode: SelectMode; value: unknown }): void;
67
- onChange?(detail: { value: string | string[]; previousValue?: string | string[]; item?: SelectItem; instance: ZidanSelect }): void;
68
- onSelect?(detail: { value: string | string[]; item: SelectItem; instance: ZidanSelect }): void;
67
+ onChange?(detail: { value: unknown; previousValue?: unknown; item?: SelectItem; instance: ZidanSelect }): void;
68
+ onSelect?(detail: { value: unknown; item: SelectItem; instance: ZidanSelect }): void;
69
69
  onOpen?(detail: { instance: ZidanSelect }): void;
70
70
  onClose?(detail: { instance: ZidanSelect }): void;
71
- onTagAdd?(detail: { tag: string; tags: string[]; instance: ZidanSelect }): void;
72
- onTagRemove?(detail: { tag: string; tags: string[]; instance: ZidanSelect }): void;
71
+ onTagAdd?(detail: { tag: string; value: SelectItem[]; instance: ZidanSelect }): void;
72
+ onTagRemove?(detail: { tag: string; value: SelectItem[]; instance: ZidanSelect }): void;
73
73
  onLoadMore?(detail: { page: number; query: string; instance: ZidanSelect }): void;
74
- onError?(detail: { error: unknown; message: string; instance: ZidanSelect }): void;
74
+ onError?(detail: { error?: unknown; message: string; instance: ZidanSelect }): void;
75
75
  }
76
76
 
77
77
  export interface SelectOptions extends SelectCallbacks {
@@ -86,6 +86,7 @@ export interface SelectOptions extends SelectCallbacks {
86
86
  options?: SelectItemInput[] | null;
87
87
  value?: string | string[] | null;
88
88
  label?: string | null;
89
+ ariaLabel?: string;
89
90
  placeholder?: string | null;
90
91
  multiple?: boolean;
91
92
  searchable?: boolean;
@@ -226,16 +227,21 @@ export interface FileFieldOptions extends FieldOptions {
226
227
 
227
228
  export interface TextFieldOptions extends FieldOptions {
228
229
  icon?: string;
229
- iconPosition?: 'start' | 'end';
230
+ iconPosition?: 'left' | 'right';
230
231
  prefix?: string;
231
232
  suffix?: string;
232
233
  clearable?: boolean;
233
- counter?: boolean;
234
- counterMax?: number;
234
+ counter?: number;
235
235
  output?: HTMLOutputElement | string;
236
- stepper?: boolean;
237
- stepperMode?: string;
238
- phone?: boolean;
236
+ stepper?: boolean | string;
237
+ stepperStep?: number;
238
+ phone?: boolean | {
239
+ country?: string;
240
+ format?: PhoneFormat;
241
+ showCountry?: boolean;
242
+ countries?: string[];
243
+ validate?: boolean;
244
+ };
239
245
  phoneCountry?: string;
240
246
  phoneFormat?: PhoneFormat;
241
247
  rangeVariant?: 'default' | 'gradient' | 'stepped' | 'minimal';
@@ -308,8 +314,8 @@ export class ZidanSelect {
308
314
  setValue(value: string | number | Array<string | number> | null, options?: { silent?: boolean }): this;
309
315
  clear(): this;
310
316
  setOptions(options: SelectItemInput[] | null): this;
311
- addTag(label: string, data?: unknown): this;
312
- removeTag(index: number): this;
317
+ addTag(label: string, data?: unknown): boolean;
318
+ removeTag(tagOrIndex: string | number): boolean;
313
319
  getTags(): SelectItem[];
314
320
  enable(): this;
315
321
  disable(): this;
@@ -361,7 +367,7 @@ export class ZidanFileUpload extends ZidanFieldBase {
361
367
  getUploadState(): UploadState[];
362
368
  addFiles(files: File[] | FileList): this;
363
369
  replaceFiles(files: File[] | FileList): this;
364
- removeFile(index: number): this;
370
+ removeFile(index: number | File): this;
365
371
  clear(): this;
366
372
  uploadAll(): this | Promise<boolean>;
367
373
  uploadFile(file: File): this | Promise<unknown>;
@@ -369,7 +375,7 @@ export class ZidanFileUpload extends ZidanFieldBase {
369
375
  cancelAll(): this;
370
376
  retryUpload(file: File): this;
371
377
  setVariant(variant: string): this;
372
- setUploader(handler: UploadHandler | null): this;
378
+ setUploader(handler: UploadHandler | string | null): this;
373
379
  }
374
380
 
375
381
  export class ZidanTextField extends ZidanFieldBase {
@@ -378,8 +384,8 @@ export class ZidanTextField extends ZidanFieldBase {
378
384
  stepUp(times?: number): this;
379
385
  stepDown(times?: number): this;
380
386
  setStepper(enabled: boolean): this;
381
- openPicker(): void;
382
- showPicker(): void;
387
+ openPicker(): this;
388
+ showPicker(): this;
383
389
  getPhoneCountry(): string;
384
390
  setPhoneCountry(iso: string): this;
385
391
  setPhoneFormat(format: PhoneFormat): this;