zidan-select 2.3.0 → 2.3.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 +75 -40
- package/dist/file/plugin-file-core.css +8 -1
- package/dist/file/plugin-file-core.min.css +2 -2
- package/dist/file/plugin-file-theme.css +1 -1
- package/dist/file/plugin-file-theme.min.css +1 -1
- package/dist/file/zidan-file.d.ts +1 -1
- package/dist/file/zidan-file.js +94 -25
- package/dist/file/zidan-file.min.js +2 -2
- package/dist/plugin-core.css +109 -1
- package/dist/plugin-core.min.css +2 -2
- package/dist/plugin-theme.css +1 -1
- package/dist/plugin-theme.min.css +1 -1
- package/dist/select/plugin-select-core.css +1 -1
- package/dist/select/plugin-select-core.min.css +1 -1
- package/dist/select/plugin-select-theme.css +1 -1
- package/dist/select/plugin-select-theme.min.css +1 -1
- package/dist/select/zidan-select.d.ts +1 -1
- package/dist/select/zidan-select.js +102 -8
- package/dist/select/zidan-select.min.js +2 -2
- package/dist/zidan-form.js +252 -55
- package/dist/zidan-form.min.js +2 -2
- package/docs/build.md +11 -5
- package/docs/html-and-wordpress.md +20 -20
- package/docs/index.html +8 -0
- package/docs/options.md +44 -11
- package/docs/validation.md +8 -0
- package/package.json +5 -2
- package/plugin-core.css +109 -1
- package/plugin-theme.css +1 -1
- package/zidan-form.d.ts +10 -1
- package/zidan-form.js +252 -55
package/README.md
CHANGED
|
@@ -28,9 +28,9 @@ bundle.
|
|
|
28
28
|
|
|
29
29
|
| Build | JavaScript (CDN) | CSS (CDN) |
|
|
30
30
|
| --- | --- | --- |
|
|
31
|
-
| Full — every control | [zidan-form.js](https://cdn.jsdelivr.net/npm/zidan-select@2.3.
|
|
32
|
-
| Select-only — ≈104 kB | [zidan-select.js](https://cdn.jsdelivr.net/npm/zidan-select@2.3.
|
|
33
|
-
| File-only — ≈82 kB | [zidan-file.js](https://cdn.jsdelivr.net/npm/zidan-select@2.3.
|
|
31
|
+
| Full — every control | [zidan-form.js](https://cdn.jsdelivr.net/npm/zidan-select@2.3.1/zidan-form.js) | [plugin-core.css](https://cdn.jsdelivr.net/npm/zidan-select@2.3.1/plugin-core.css) + [plugin-theme.css](https://cdn.jsdelivr.net/npm/zidan-select@2.3.1/plugin-theme.css) |
|
|
32
|
+
| Select-only — ≈104 kB | [zidan-select.js](https://cdn.jsdelivr.net/npm/zidan-select@2.3.1/dist/select/zidan-select.js) | [plugin-select-core.css](https://cdn.jsdelivr.net/npm/zidan-select@2.3.1/dist/select/plugin-select-core.css) + [plugin-select-theme.css](https://cdn.jsdelivr.net/npm/zidan-select@2.3.1/dist/select/plugin-select-theme.css) |
|
|
33
|
+
| File-only — ≈82 kB | [zidan-file.js](https://cdn.jsdelivr.net/npm/zidan-select@2.3.1/dist/file/zidan-file.js) | [plugin-file-core.css](https://cdn.jsdelivr.net/npm/zidan-select@2.3.1/dist/file/plugin-file-core.css) + [plugin-file-theme.css](https://cdn.jsdelivr.net/npm/zidan-select@2.3.1/dist/file/plugin-file-theme.css) |
|
|
34
34
|
|
|
35
35
|
Copyable snippets, ESM files and per-file sizes live in
|
|
36
36
|
[Select-only and file-only builds](#select-only-and-file-only-builds); the
|
|
@@ -47,9 +47,9 @@ the pinned version:
|
|
|
47
47
|
|
|
48
48
|
| Build | JS (min) | CSS (min) |
|
|
49
49
|
| --- | --- | --- |
|
|
50
|
-
| Full | [zidan-form.min.js](https://cdn.jsdelivr.net/npm/zidan-select@2.3.
|
|
51
|
-
| Select-only | [zidan-select.min.js](https://cdn.jsdelivr.net/npm/zidan-select@2.3.
|
|
52
|
-
| File-only | [zidan-file.min.js](https://cdn.jsdelivr.net/npm/zidan-select@2.3.
|
|
50
|
+
| Full | [zidan-form.min.js](https://cdn.jsdelivr.net/npm/zidan-select@2.3.1/dist/zidan-form.min.js) | [plugin-core.min.css](https://cdn.jsdelivr.net/npm/zidan-select@2.3.1/dist/plugin-core.min.css) + [plugin-theme.min.css](https://cdn.jsdelivr.net/npm/zidan-select@2.3.1/dist/plugin-theme.min.css) |
|
|
51
|
+
| Select-only | [zidan-select.min.js](https://cdn.jsdelivr.net/npm/zidan-select@2.3.1/dist/select/zidan-select.min.js) | [plugin-select-core.min.css](https://cdn.jsdelivr.net/npm/zidan-select@2.3.1/dist/select/plugin-select-core.min.css) + [plugin-select-theme.min.css](https://cdn.jsdelivr.net/npm/zidan-select@2.3.1/dist/select/plugin-select-theme.min.css) |
|
|
52
|
+
| File-only | [zidan-file.min.js](https://cdn.jsdelivr.net/npm/zidan-select@2.3.1/dist/file/zidan-file.min.js) | [plugin-file-core.min.css](https://cdn.jsdelivr.net/npm/zidan-select@2.3.1/dist/file/plugin-file-core.min.css) + [plugin-file-theme.min.css](https://cdn.jsdelivr.net/npm/zidan-select@2.3.1/dist/file/plugin-file-theme.min.css) |
|
|
53
53
|
|
|
54
54
|
- **One file of JS** — `zidan-form.js` (classic script, UMD-ish) + `zidan-form.mjs` (ESM wrapper).
|
|
55
55
|
- **Split CSS** — `plugin-core.css` (structure only) and `plugin-theme.css` (tokens, presets, skins).
|
|
@@ -168,6 +168,10 @@ A mock **Shopify product page** — variant combobox, quantity stepper, gift-wra
|
|
|
168
168
|
radios, upload dropzone and the Liquid install snippets — runs at
|
|
169
169
|
<https://akhtar1985.github.io/zidan-select/shopify.html>.
|
|
170
170
|
|
|
171
|
+
Below the tabs sits the **[controls reference](https://akhtar1985.github.io/zidan-select/#controls)**
|
|
172
|
+
— all nine control families on one page with the options you reach for most, the two ways to
|
|
173
|
+
initialise a field and copyable examples, linking into the playground for the rest.
|
|
174
|
+
|
|
171
175
|
---
|
|
172
176
|
|
|
173
177
|
## Install
|
|
@@ -222,20 +226,22 @@ override presets.
|
|
|
222
226
|
| `plugin-theme.css` | Tokens, colours, states, presets, layout skins, framework adapters. |
|
|
223
227
|
| `dist/select/` | Select-only build: `zidan-select.js`, `zidan-select.mjs`, `plugin-select-core.css`, `plugin-select-theme.css`. |
|
|
224
228
|
| `dist/file/` | File-only build: `zidan-file.js`, `zidan-file.mjs`, `plugin-file-core.css`, `plugin-file-theme.css`. |
|
|
225
|
-
| `index.html`, `demo.css`, `demo.js` | The tabbed demo / theme showcase (not shipped logic). |
|
|
229
|
+
| `index.html`, `demo.css`, `demo.js` | The tabbed demo / theme showcase plus the controls reference section (not shipped logic). |
|
|
230
|
+
| `advanced.html`, `advanced.css`, `advanced.js` | Advanced reference: init and precedence, async paging, Promise validation, uploads, events, RTL and TypeScript, with copyable HTML/JS examples (not shipped logic). |
|
|
226
231
|
| `playground.html`, `playground.css`, `playground.js` | Per-field option builder with live preview and copyable HTML / JS output (not shipped logic). |
|
|
232
|
+
| `nav.css`, `nav.js` | Shared header, navigation and mobile menu button for the demo pages (not shipped logic). |
|
|
227
233
|
| `robots.txt`, `sitemap.xml` | Crawler directives and the public page list for GitHub Pages (not shipped on npm). |
|
|
228
234
|
| `docs/` | Comparison, options, validation, frameworks, theming, build and the static HTML/WordPress cookbook. |
|
|
229
235
|
|
|
230
236
|
Copyable URLs for the published files (pin the version in production):
|
|
231
237
|
|
|
232
|
-
- `zidan-form.js` — <https://cdn.jsdelivr.net/npm/zidan-select@2.3.
|
|
233
|
-
- `zidan-form.min.js` — <https://cdn.jsdelivr.net/npm/zidan-select@2.3.
|
|
234
|
-
- `zidan-form.mjs` — <https://cdn.jsdelivr.net/npm/zidan-select@2.3.
|
|
235
|
-
- `plugin-core.css` — <https://cdn.jsdelivr.net/npm/zidan-select@2.3.
|
|
236
|
-
- `plugin-core.min.css` — <https://cdn.jsdelivr.net/npm/zidan-select@2.3.
|
|
237
|
-
- `plugin-theme.css` — <https://cdn.jsdelivr.net/npm/zidan-select@2.3.
|
|
238
|
-
- `plugin-theme.min.css` — <https://cdn.jsdelivr.net/npm/zidan-select@2.3.
|
|
238
|
+
- `zidan-form.js` — <https://cdn.jsdelivr.net/npm/zidan-select@2.3.1/zidan-form.js>
|
|
239
|
+
- `zidan-form.min.js` — <https://cdn.jsdelivr.net/npm/zidan-select@2.3.1/dist/zidan-form.min.js>
|
|
240
|
+
- `zidan-form.mjs` — <https://cdn.jsdelivr.net/npm/zidan-select@2.3.1/zidan-form.mjs>
|
|
241
|
+
- `plugin-core.css` — <https://cdn.jsdelivr.net/npm/zidan-select@2.3.1/plugin-core.css>
|
|
242
|
+
- `plugin-core.min.css` — <https://cdn.jsdelivr.net/npm/zidan-select@2.3.1/dist/plugin-core.min.css>
|
|
243
|
+
- `plugin-theme.css` — <https://cdn.jsdelivr.net/npm/zidan-select@2.3.1/plugin-theme.css>
|
|
244
|
+
- `plugin-theme.min.css` — <https://cdn.jsdelivr.net/npm/zidan-select@2.3.1/dist/plugin-theme.min.css>
|
|
239
245
|
- npm package — <https://www.npmjs.com/package/zidan-select>
|
|
240
246
|
- Source — <https://github.com/akhtar1985/zidan-select>
|
|
241
247
|
|
|
@@ -256,27 +262,27 @@ exactly like the full build.
|
|
|
256
262
|
|
|
257
263
|
Copyable CDN URLs (pin the version):
|
|
258
264
|
|
|
259
|
-
- `zidan-select.js` — <https://cdn.jsdelivr.net/npm/zidan-select@2.3.
|
|
260
|
-
- `zidan-select.min.js` — <https://cdn.jsdelivr.net/npm/zidan-select@2.3.
|
|
261
|
-
- `zidan-select.mjs` — <https://cdn.jsdelivr.net/npm/zidan-select@2.3.
|
|
262
|
-
- `plugin-select-core.css` — <https://cdn.jsdelivr.net/npm/zidan-select@2.3.
|
|
263
|
-
- `plugin-select-core.min.css` — <https://cdn.jsdelivr.net/npm/zidan-select@2.3.
|
|
264
|
-
- `plugin-select-theme.css` — <https://cdn.jsdelivr.net/npm/zidan-select@2.3.
|
|
265
|
-
- `plugin-select-theme.min.css` — <https://cdn.jsdelivr.net/npm/zidan-select@2.3.
|
|
266
|
-
- `zidan-file.js` — <https://cdn.jsdelivr.net/npm/zidan-select@2.3.
|
|
267
|
-
- `zidan-file.min.js` — <https://cdn.jsdelivr.net/npm/zidan-select@2.3.
|
|
268
|
-
- `zidan-file.mjs` — <https://cdn.jsdelivr.net/npm/zidan-select@2.3.
|
|
269
|
-
- `plugin-file-core.css` — <https://cdn.jsdelivr.net/npm/zidan-select@2.3.
|
|
270
|
-
- `plugin-file-core.min.css` — <https://cdn.jsdelivr.net/npm/zidan-select@2.3.
|
|
271
|
-
- `plugin-file-theme.css` — <https://cdn.jsdelivr.net/npm/zidan-select@2.3.
|
|
272
|
-
- `plugin-file-theme.min.css` — <https://cdn.jsdelivr.net/npm/zidan-select@2.3.
|
|
265
|
+
- `zidan-select.js` — <https://cdn.jsdelivr.net/npm/zidan-select@2.3.1/dist/select/zidan-select.js>
|
|
266
|
+
- `zidan-select.min.js` — <https://cdn.jsdelivr.net/npm/zidan-select@2.3.1/dist/select/zidan-select.min.js>
|
|
267
|
+
- `zidan-select.mjs` — <https://cdn.jsdelivr.net/npm/zidan-select@2.3.1/dist/select/zidan-select.mjs>
|
|
268
|
+
- `plugin-select-core.css` — <https://cdn.jsdelivr.net/npm/zidan-select@2.3.1/dist/select/plugin-select-core.css>
|
|
269
|
+
- `plugin-select-core.min.css` — <https://cdn.jsdelivr.net/npm/zidan-select@2.3.1/dist/select/plugin-select-core.min.css>
|
|
270
|
+
- `plugin-select-theme.css` — <https://cdn.jsdelivr.net/npm/zidan-select@2.3.1/dist/select/plugin-select-theme.css>
|
|
271
|
+
- `plugin-select-theme.min.css` — <https://cdn.jsdelivr.net/npm/zidan-select@2.3.1/dist/select/plugin-select-theme.min.css>
|
|
272
|
+
- `zidan-file.js` — <https://cdn.jsdelivr.net/npm/zidan-select@2.3.1/dist/file/zidan-file.js>
|
|
273
|
+
- `zidan-file.min.js` — <https://cdn.jsdelivr.net/npm/zidan-select@2.3.1/dist/file/zidan-file.min.js>
|
|
274
|
+
- `zidan-file.mjs` — <https://cdn.jsdelivr.net/npm/zidan-select@2.3.1/dist/file/zidan-file.mjs>
|
|
275
|
+
- `plugin-file-core.css` — <https://cdn.jsdelivr.net/npm/zidan-select@2.3.1/dist/file/plugin-file-core.css>
|
|
276
|
+
- `plugin-file-core.min.css` — <https://cdn.jsdelivr.net/npm/zidan-select@2.3.1/dist/file/plugin-file-core.min.css>
|
|
277
|
+
- `plugin-file-theme.css` — <https://cdn.jsdelivr.net/npm/zidan-select@2.3.1/dist/file/plugin-file-theme.css>
|
|
278
|
+
- `plugin-file-theme.min.css` — <https://cdn.jsdelivr.net/npm/zidan-select@2.3.1/dist/file/plugin-file-theme.min.css>
|
|
273
279
|
|
|
274
280
|
Select / combobox / tags only (≈104 kB JS, ≈12 kB core CSS, ≈32 kB theme CSS):
|
|
275
281
|
|
|
276
282
|
```html
|
|
277
|
-
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/zidan-select@2.3.
|
|
278
|
-
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/zidan-select@2.3.
|
|
279
|
-
<script src="https://cdn.jsdelivr.net/npm/zidan-select@2.3.
|
|
283
|
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/zidan-select@2.3.1/dist/select/plugin-select-core.css">
|
|
284
|
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/zidan-select@2.3.1/dist/select/plugin-select-theme.css">
|
|
285
|
+
<script src="https://cdn.jsdelivr.net/npm/zidan-select@2.3.1/dist/select/zidan-select.js"></script>
|
|
280
286
|
<script>
|
|
281
287
|
// auto-init covers [data-zidan-select], class="zidan-select", zidan-form scopes
|
|
282
288
|
// and ZIDAN_FORM_CONFIG targets; JS-only options:
|
|
@@ -287,9 +293,9 @@ Select / combobox / tags only (≈104 kB JS, ≈12 kB core CSS, ≈32 kB theme C
|
|
|
287
293
|
File upload only (≈82 kB JS, ≈9 kB core CSS, ≈34 kB theme CSS):
|
|
288
294
|
|
|
289
295
|
```html
|
|
290
|
-
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/zidan-select@2.3.
|
|
291
|
-
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/zidan-select@2.3.
|
|
292
|
-
<script src="https://cdn.jsdelivr.net/npm/zidan-select@2.3.
|
|
296
|
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/zidan-select@2.3.1/dist/file/plugin-file-core.css">
|
|
297
|
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/zidan-select@2.3.1/dist/file/plugin-file-theme.css">
|
|
298
|
+
<script src="https://cdn.jsdelivr.net/npm/zidan-select@2.3.1/dist/file/zidan-file.js"></script>
|
|
293
299
|
<script>
|
|
294
300
|
zidanField('#upload', { variant: 'dropzone', upload: '/api/files' });
|
|
295
301
|
</script>
|
|
@@ -422,7 +428,7 @@ argument to `zidanSelect()`:
|
|
|
422
428
|
</select>
|
|
423
429
|
|
|
424
430
|
<!-- select-only build; use zidan-form.js for every control -->
|
|
425
|
-
<script src="https://cdn.jsdelivr.net/npm/zidan-select@2.3.
|
|
431
|
+
<script src="https://cdn.jsdelivr.net/npm/zidan-select@2.3.1/dist/select/zidan-select.js"></script>
|
|
426
432
|
<script>
|
|
427
433
|
const picker = zidanSelect('#mymov', {
|
|
428
434
|
mode: 'combobox', // 'select' | 'combobox' | 'tags'
|
|
@@ -679,10 +685,24 @@ zidanField('#price', {
|
|
|
679
685
|
rangeLabels: { 0: 'Free', 1000: 'Top' },
|
|
680
686
|
rangeFormat: value => '€' + Number(value).toLocaleString('en-US')
|
|
681
687
|
});
|
|
688
|
+
|
|
689
|
+
zidanField('#delivery', {
|
|
690
|
+
rangeBubbleMode: 'active', // always | active | never
|
|
691
|
+
rangeBubblePosition: 'bottom', // top | bottom
|
|
692
|
+
rangeFill: false, // no progress colour
|
|
693
|
+
rangeTicks: '0,10,20,30', // count, array, JSON or comma list
|
|
694
|
+
rangeTickLabels: true,
|
|
695
|
+
rangeMinLabel: 'Low',
|
|
696
|
+
rangeMaxLabel: 'High'
|
|
697
|
+
});
|
|
682
698
|
```
|
|
683
699
|
|
|
684
|
-
Variants: `default`, `gradient`, `stepped`, `minimal`. Bubble
|
|
685
|
-
|
|
700
|
+
Variants: `default`, `gradient`, `stepped`, `minimal`. Bubble (always / on hover-focus / never,
|
|
701
|
+
top or bottom), fill, min/max scale, custom scale ends, ticks and labels can each be set;
|
|
702
|
+
`rangeFormat` accepts a template (`{value}`, `{min}`, `{max}`) or a function and also feeds
|
|
703
|
+
`aria-valuetext`. Labeled ticks at both ends replace the min/max scale (classes
|
|
704
|
+
`zs-range-scale--hidden` and `zs-range-tick--start` / `--end`), so the start and end numbers
|
|
705
|
+
are printed once. `output` receives the formatted display value; `input.value` keeps the raw one.
|
|
686
706
|
|
|
687
707
|
### Date & time pickers
|
|
688
708
|
|
|
@@ -718,7 +738,7 @@ per field; clickable icons call `input.showPicker()` when available.
|
|
|
718
738
|
| `reveal` | `data-zidan-reveal` | boolean | `false` | Password show/hide. |
|
|
719
739
|
| `prefix` / `suffix` | `data-zidan-prefix` / `-suffix` | string | — | Static adornments. |
|
|
720
740
|
| `counter` | `data-zidan-counter` | number | `maxlength` | Character limit for the counter; overrides `maxlength`. |
|
|
721
|
-
| `output` | `data-zidan-output` | selector | — | Range value is mirrored into this element. |
|
|
741
|
+
| `output` | `data-zidan-output` | selector | — | Range display value (formatted when `rangeFormat` is set) is mirrored into this element. |
|
|
722
742
|
| `autoIcon` / `icon` | `data-zidan-auto-icon` / `data-zidan-icon` | boolean / string | `false` / — | Type-based or custom input icon (any registered name). |
|
|
723
743
|
| `iconPosition` / `iconClickable` | `data-zidan-icon-position` / `-icon-clickable` | `left`\|`right` / boolean | `left` / `false` | Side and behaviour of the icon. |
|
|
724
744
|
| `validationIcon` | `data-zidan-validation-icon` | boolean | `false` | Check/alert glyphs tied to validation state. |
|
|
@@ -728,7 +748,9 @@ per field; clickable icons call `input.showPicker()` when available.
|
|
|
728
748
|
| `phone` / `phoneCountry` / `phoneFormat` | `data-zidan-phone` / `-phone-country` / `-phone-format` | boolean / ISO-2 / `national`\|`international`\|`e164` | — / `US` / `national` | Phone formatting and validation. |
|
|
729
749
|
| `phoneCountrySelect` / `phoneCountries` | `data-zidan-phone-country-select` / `-phone-countries` | boolean / list | `true` / common set | Country selector. |
|
|
730
750
|
| `rangeVariant` / `rangeBubble` / `rangeMinMax` | `data-zidan-range-variant` / `-range-bubble` / `-range-minmax` | string / boolean / boolean | `default` / `true` / `true` | Range skin and chrome. |
|
|
731
|
-
| `
|
|
751
|
+
| `rangeBubbleMode` / `rangeBubblePosition` / `rangeFill` | `data-zidan-range-bubble-mode` / `-range-bubble-position` / `-range-fill` | `always`\|`active`\|`never` / `top`\|`bottom` / boolean | `always` / `top` / `true` | Bubble visibility and side, progress fill. |
|
|
752
|
+
| `rangeTicks` / `rangeTickLabels` / `rangeLabels` / `rangeFormat` | `data-zidan-range-ticks` / `-range-tick-labels` / — / `-range-format` | number\|array\|string / boolean / object / string\|function | `0` / `false` / — / — | Ticks (count, array, JSON or comma list), labels and value formatter. |
|
|
753
|
+
| `rangeMinLabel` / `rangeMaxLabel` | `data-zidan-range-min-label` / `-range-max-label` | string | — | Custom text for the scale ends. |
|
|
732
754
|
| `pickerButton` / `pickerIcon` | `data-zidan-picker-button` / `-picker-icon` | boolean / string | `false` / per type | Date/time picker button and icon. |
|
|
733
755
|
| `disableWeekends` / `disabledDates` | `data-zidan-disable-weekends` / `-disabled-dates` | boolean / list\|function | `false` / — | Date rules written into native validity. |
|
|
734
756
|
| `title` | `data-zidan-title` | string | `Choose a file` | File dropzone title. |
|
|
@@ -754,6 +776,16 @@ See [`docs/options.md`](docs/options.md) for the complete table (`mode`, `layout
|
|
|
754
776
|
Validation state options on both layers: **the plugin never submits or blocks a form** — it
|
|
755
777
|
mirrors state and lets your validator decide.
|
|
756
778
|
|
|
779
|
+
Three behaviours that are easy to miss:
|
|
780
|
+
|
|
781
|
+
- `searchable: false` in `select` mode makes the trigger `readOnly`, so typing can never filter
|
|
782
|
+
or hide the options. Open the list with a click, `Space`, `Enter` or `↓`.
|
|
783
|
+
- Tags with `allowFreeText: false` accept only values that already exist in the options or
|
|
784
|
+
`suggestions`; anything else is rejected with `"…" is not in the list.`
|
|
785
|
+
- `setValidation('invalid')` (and `data-zidan-validation="invalid"`) is pinned: it survives
|
|
786
|
+
`update()`, `refresh()`, `setValue()` and async re-checks until the user edits the control or
|
|
787
|
+
you call `setValidation(null)`.
|
|
788
|
+
|
|
757
789
|
---
|
|
758
790
|
|
|
759
791
|
## JavaScript API
|
|
@@ -1024,6 +1056,9 @@ npm run build # dist/ (+ local .min files when esbuild is installed)
|
|
|
1024
1056
|
| `scripts/build.mjs` | Cleans `dist/`, copies the four assets, writes `dist/zidan-form.cjs`, emits the select-only and file-only bundles with declarations, and minifies every JS/CSS output with esbuild. |
|
|
1025
1057
|
| `scripts/test.mjs` | Verifies syntax, that core CSS carries no colour literals, that all presets/adapters exist, the public API is exported, the build artifacts ship, and the playground, README, demo and cookbook stay wired to each other — then runs 19 jsdom behaviour suites. |
|
|
1026
1058
|
| `scripts/dom/run.mjs` | jsdom suites for select, fields, uploads, async validation, pagination, RTL, teardown, and the select-only/file-only/minified bundles. |
|
|
1059
|
+
| `scripts/exa-search.mjs` | Exa web search for docs and release research: `npm run search -- "your question"` (`--num 10` for more results). Reads `EXA_API_KEY`; copy `.env.example` to `.env` (git-ignored) and add a key from https://dashboard.exa.ai/api-keys. |
|
|
1060
|
+
|
|
1061
|
+
`exa-js` is a dev dependency only, so the published bundle stays dependency-free.
|
|
1027
1062
|
|
|
1028
1063
|
**Minified files ship in the package.** `npm run build` writes real `.min.js` / `.min.css`
|
|
1029
1064
|
files into `dist/` (including both subset folders), so the URLs above work on unpkg, a
|
|
@@ -1060,7 +1095,7 @@ Full checklist, folder tree and release automation notes: [`docs/build.md`](docs
|
|
|
1060
1095
|
|
|
1061
1096
|
## What's new in 2.1–2.3
|
|
1062
1097
|
|
|
1063
|
-
**2.3.
|
|
1098
|
+
**2.3.1** adds the capabilities that were previously the library's biggest gaps:
|
|
1064
1099
|
|
|
1065
1100
|
- **Async validation** — `validate` and `validateDate` may return a Promise. Fields get a
|
|
1066
1101
|
`.zs-field--pending` spinner and `aria-busy`, block form submission through native validity,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* ZidanForm File-only v2.3.
|
|
2
|
+
* ZidanForm File-only v2.3.1 — 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
|
*
|
|
@@ -87,6 +87,13 @@
|
|
|
87
87
|
letter-spacing: 0.01em;
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
+
/* The plugin renders its own label and hides the author's original one. Author
|
|
91
|
+
rules such as `.field-label { display:block }` would otherwise beat the
|
|
92
|
+
browser's [hidden] default and show both labels at once. */
|
|
93
|
+
[data-zs-hidden-label] {
|
|
94
|
+
display: none !important;
|
|
95
|
+
}
|
|
96
|
+
|
|
90
97
|
.zs-field__hint {
|
|
91
98
|
margin: 0;
|
|
92
99
|
font-size: 0.75rem;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* ZidanForm File-only v2.3.
|
|
2
|
+
* ZidanForm File-only v2.3.1 — 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
|
*
|
|
6
6
|
* Generated by scripts/build.mjs — edit the shared stylesheets instead.
|
|
7
7
|
* https://github.com/akhtar1985/zidan-select
|
|
8
8
|
* MIT License © akhtar1985
|
|
9
|
-
*/.zs-root,.zs-field,.zs-radio-group{position:relative;display:block;width:100%;box-sizing:border-box;font-family:var(--zs-font-family, inherit);font-size:var(--zs-font-size, .9375rem);line-height:var(--zs-line-height, 1.4);-webkit-tap-highlight-color:transparent}.zs-root *,.zs-root *:before,.zs-root *:after,.zs-field *,.zs-field *:before,.zs-field *:after,.zs-radio-group *,.zs-radio-group *:before,.zs-radio-group *:after{box-sizing:border-box}.zs-field{position:relative;display:flex;flex-direction:column;gap:var(--zs-field-gap, 6px)}.zs-field--pending:after{content:"";position:absolute;top:2px;inset-inline-end:0;width:.85em;height:.85em;border-width:2px;border-style:solid;border-color:transparent;border-radius:50%;animation:zs-field-spin .7s linear infinite;pointer-events:none}@keyframes zs-field-spin{to{transform:rotate(360deg)}}@media (prefers-reduced-motion: reduce){.zs-field--pending:after{animation-duration:2s}}.zs-field[data-zs-layout=inline]{flex-direction:row;align-items:center;flex-wrap:wrap;gap:10px}.zs-field__label{display:block;font-size:var(--zs-label-size, .8125rem);font-weight:600;letter-spacing:.01em}.zs-field__hint{margin:0;font-size:.75rem}.zs-field__meta{display:flex;align-items:baseline;justify-content:space-between;gap:10px}.zs-field__error{margin:0;font-size:.75rem;line-height:1.35}.zs-field__error[hidden]{display:none}.zs-counter{margin-inline-start:auto;font-size:.75rem;font-variant-numeric:tabular-nums;white-space:nowrap}.zs-native-input{position:absolute;width:1px;height:1px;margin:0;padding:0;border:0;opacity:0;overflow:hidden;clip-path:inset(50%);white-space:nowrap}.zs-field--inline .zs-check,.zs-field--inline .zs-radio{margin:0}.zs-field--file .zs-file-drop{position:relative;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:4px;padding:22px 16px;min-height:128px;text-align:center;border-width:1.5px;border-style:dashed;border-radius:var(--zs-radius, 10px);cursor:pointer;transition:border-color .15s ease,background-color .15s ease}.zs-file-icon{display:inline-flex;align-items:center;justify-content:center;width:34px;height:34px;margin-bottom:4px;border-radius:50%}.zs-file-drop-title{font-weight:600}.zs-file-drop-hint{font-size:.75rem}.zs-file-list{display:flex;flex-direction:column;gap:6px;margin:0;padding:0;list-style:none}.zs-file-list[hidden]{display:none}.zs-file-item{display:flex;align-items:center;gap:10px;padding:8px 10px;border-width:var(--zs-border-width, 1px);border-style:solid;border-radius:var(--zs-radius, 10px)}.zs-file-thumb{flex:0 0 auto;display:inline-flex;align-items:center;justify-content:center;width:38px;height:38px;overflow:hidden;border-radius:8px;font-size:.625rem;font-weight:700;letter-spacing:.02em}.zs-file-thumb img{width:100%;height:100%;object-fit:cover;display:block}.zs-file-info{display:flex;flex-direction:column;min-width:0;flex:1 1 auto}.zs-file-name{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:.8125rem;font-weight:600}.zs-file-size{font-size:.6875rem}.zs-file-remove{flex:0 0 auto;width:26px;height:26px;padding:0;border:0;border-radius:50%;font-size:1rem;line-height:1;cursor:pointer;transition:background-color .15s ease}.zs-file-meta-row{display:flex;align-items:center;justify-content:space-between;gap:10px;min-height:20px}.zs-file-status{font-size:.75rem}.zs-file-clear{margin-inline-start:auto;padding:2px 8px;border-width:1px;border-style:solid;border-radius:999px;font-size:.6875rem;font-weight:600;cursor:pointer}.zs-file-clear[hidden]{display:none}.zs-field--file .zs-file-drop--button,.zs-field--file .zs-file-drop--compact{flex-direction:row;align-items:center;justify-content:flex-start;gap:8px;min-height:0;padding:10px 14px;text-align:start;border-style:solid}.zs-field--file .zs-file-drop--compact{padding:6px 10px}.zs-field--file .zs-file-drop--button .zs-file-icon,.zs-field--file .zs-file-drop--compact .zs-file-icon{margin:0;width:24px;height:24px}.zs-field--file .zs-file-drop--button .zs-file-drop-hint,.zs-field--file .zs-file-drop--compact .zs-file-drop-hint{margin-inline-start:auto}.zs-field--file .zs-file-drop--avatar{flex:0 0 auto;width:var(--zs-avatar-size, 96px);height:var(--zs-avatar-size, 96px);min-height:0;padding:0;overflow:hidden;border-style:solid;border-radius:50%}.zs-field--file .zs-file-drop--avatar .zs-file-drop-title,.zs-field--file .zs-file-drop--avatar .zs-file-drop-hint{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;border:0}.zs-field--file .zs-file-drop--avatar .zs-file-icon{margin:0}.zs-file-avatar{position:absolute;inset:0;display:block}.zs-file-avatar[hidden]{display:none}.zs-file-avatar img{width:100%;height:100%;object-fit:cover;display:block}.zs-file-drop--has-preview .zs-file-icon{display:none}.zs-field--file .zs-file-drop--gallery{flex-direction:row;flex-wrap:wrap;justify-content:center;gap:6px;min-height:88px;padding:14px}.zs-field[data-zs-file-variant=gallery] .zs-file-list{display:grid;grid-template-columns:repeat(auto-fill,minmax(120px,1fr));gap:8px}.zs-field[data-zs-file-variant=gallery] .zs-file-item{flex-direction:column;align-items:stretch;gap:6px;padding:6px}.zs-field[data-zs-file-variant=gallery] .zs-file-thumb{width:100%;height:86px;border-radius:6px}.zs-field[data-zs-file-variant=gallery] .zs-file-actions{justify-content:flex-end}.zs-field[data-zs-file-variant=gallery] .zs-file-upload-state{flex-wrap:wrap}.zs-file-upload-state{display:flex;align-items:center;gap:6px;font-size:.6875rem}.zs-file-progress{position:relative;display:inline-block;flex:1 1 58px;height:4px;min-width:44px;overflow:hidden;border-radius:999px}.zs-file-progress-bar{display:block;height:100%;width:0;border-radius:inherit;transition:width .12s linear}.zs-file-actions{flex:0 0 auto;display:inline-flex;align-items:center;gap:4px}.zs-file-cancel,.zs-file-retry{padding:2px 6px;border:0;border-radius:5px;font:inherit;font-size:.6875rem;font-weight:600;cursor:pointer}.zs-form-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(var(--zs-grid-min, 230px),1fr));gap:var(--zs-grid-gap, 16px);align-items:start}.zs-form-grid>.zs-full{grid-column:1 / -1}.zs-check input:focus-visible+.zs-check-box,.zs-check input:focus-visible+.zs-switch-track,.zs-radio input:focus-visible+.zs-radio-dot{outline:2px solid transparent;outline-offset:2px}.zs-input-native:focus-visible,.zs-file-input:focus-visible{outline:none}@media (prefers-reduced-motion: reduce){.zs-root,.zs-root *,.zs-root *:before,.zs-root *:after,.zs-field,.zs-field *,.zs-field *:before,.zs-field *:after,.zs-radio-group,.zs-radio-group *{animation-duration:.001ms!important;animation-iteration-count:1!important;transition-duration:.001ms!important;scroll-behavior:auto!important}.zs-root .zs-spinner{animation-duration:1.2s!important;animation-iteration-count:infinite!important}}
|
|
9
|
+
*/.zs-root,.zs-field,.zs-radio-group{position:relative;display:block;width:100%;box-sizing:border-box;font-family:var(--zs-font-family, inherit);font-size:var(--zs-font-size, .9375rem);line-height:var(--zs-line-height, 1.4);-webkit-tap-highlight-color:transparent}.zs-root *,.zs-root *:before,.zs-root *:after,.zs-field *,.zs-field *:before,.zs-field *:after,.zs-radio-group *,.zs-radio-group *:before,.zs-radio-group *:after{box-sizing:border-box}.zs-field{position:relative;display:flex;flex-direction:column;gap:var(--zs-field-gap, 6px)}.zs-field--pending:after{content:"";position:absolute;top:2px;inset-inline-end:0;width:.85em;height:.85em;border-width:2px;border-style:solid;border-color:transparent;border-radius:50%;animation:zs-field-spin .7s linear infinite;pointer-events:none}@keyframes zs-field-spin{to{transform:rotate(360deg)}}@media (prefers-reduced-motion: reduce){.zs-field--pending:after{animation-duration:2s}}.zs-field[data-zs-layout=inline]{flex-direction:row;align-items:center;flex-wrap:wrap;gap:10px}.zs-field__label{display:block;font-size:var(--zs-label-size, .8125rem);font-weight:600;letter-spacing:.01em}[data-zs-hidden-label]{display:none!important}.zs-field__hint{margin:0;font-size:.75rem}.zs-field__meta{display:flex;align-items:baseline;justify-content:space-between;gap:10px}.zs-field__error{margin:0;font-size:.75rem;line-height:1.35}.zs-field__error[hidden]{display:none}.zs-counter{margin-inline-start:auto;font-size:.75rem;font-variant-numeric:tabular-nums;white-space:nowrap}.zs-native-input{position:absolute;width:1px;height:1px;margin:0;padding:0;border:0;opacity:0;overflow:hidden;clip-path:inset(50%);white-space:nowrap}.zs-field--inline .zs-check,.zs-field--inline .zs-radio{margin:0}.zs-field--file .zs-file-drop{position:relative;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:4px;padding:22px 16px;min-height:128px;text-align:center;border-width:1.5px;border-style:dashed;border-radius:var(--zs-radius, 10px);cursor:pointer;transition:border-color .15s ease,background-color .15s ease}.zs-file-icon{display:inline-flex;align-items:center;justify-content:center;width:34px;height:34px;margin-bottom:4px;border-radius:50%}.zs-file-drop-title{font-weight:600}.zs-file-drop-hint{font-size:.75rem}.zs-file-list{display:flex;flex-direction:column;gap:6px;margin:0;padding:0;list-style:none}.zs-file-list[hidden]{display:none}.zs-file-item{display:flex;align-items:center;gap:10px;padding:8px 10px;border-width:var(--zs-border-width, 1px);border-style:solid;border-radius:var(--zs-radius, 10px)}.zs-file-thumb{flex:0 0 auto;display:inline-flex;align-items:center;justify-content:center;width:38px;height:38px;overflow:hidden;border-radius:8px;font-size:.625rem;font-weight:700;letter-spacing:.02em}.zs-file-thumb img{width:100%;height:100%;object-fit:cover;display:block}.zs-file-info{display:flex;flex-direction:column;min-width:0;flex:1 1 auto}.zs-file-name{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:.8125rem;font-weight:600}.zs-file-size{font-size:.6875rem}.zs-file-remove{flex:0 0 auto;width:26px;height:26px;padding:0;border:0;border-radius:50%;font-size:1rem;line-height:1;cursor:pointer;transition:background-color .15s ease}.zs-file-meta-row{display:flex;align-items:center;justify-content:space-between;gap:10px;min-height:20px}.zs-file-status{font-size:.75rem}.zs-file-clear{margin-inline-start:auto;padding:2px 8px;border-width:1px;border-style:solid;border-radius:999px;font-size:.6875rem;font-weight:600;cursor:pointer}.zs-file-clear[hidden]{display:none}.zs-field--file .zs-file-drop--button,.zs-field--file .zs-file-drop--compact{flex-direction:row;align-items:center;justify-content:flex-start;gap:8px;min-height:0;padding:10px 14px;text-align:start;border-style:solid}.zs-field--file .zs-file-drop--compact{padding:6px 10px}.zs-field--file .zs-file-drop--button .zs-file-icon,.zs-field--file .zs-file-drop--compact .zs-file-icon{margin:0;width:24px;height:24px}.zs-field--file .zs-file-drop--button .zs-file-drop-hint,.zs-field--file .zs-file-drop--compact .zs-file-drop-hint{margin-inline-start:auto}.zs-field--file .zs-file-drop--avatar{flex:0 0 auto;width:var(--zs-avatar-size, 96px);height:var(--zs-avatar-size, 96px);min-height:0;padding:0;overflow:hidden;border-style:solid;border-radius:50%}.zs-field--file .zs-file-drop--avatar .zs-file-drop-title,.zs-field--file .zs-file-drop--avatar .zs-file-drop-hint{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;border:0}.zs-field--file .zs-file-drop--avatar .zs-file-icon{margin:0}.zs-file-avatar{position:absolute;inset:0;display:block}.zs-file-avatar[hidden]{display:none}.zs-file-avatar img{width:100%;height:100%;object-fit:cover;display:block}.zs-file-drop--has-preview .zs-file-icon{display:none}.zs-field--file .zs-file-drop--gallery{flex-direction:row;flex-wrap:wrap;justify-content:center;gap:6px;min-height:88px;padding:14px}.zs-field[data-zs-file-variant=gallery] .zs-file-list{display:grid;grid-template-columns:repeat(auto-fill,minmax(120px,1fr));gap:8px}.zs-field[data-zs-file-variant=gallery] .zs-file-item{flex-direction:column;align-items:stretch;gap:6px;padding:6px}.zs-field[data-zs-file-variant=gallery] .zs-file-thumb{width:100%;height:86px;border-radius:6px}.zs-field[data-zs-file-variant=gallery] .zs-file-actions{justify-content:flex-end}.zs-field[data-zs-file-variant=gallery] .zs-file-upload-state{flex-wrap:wrap}.zs-file-upload-state{display:flex;align-items:center;gap:6px;font-size:.6875rem}.zs-file-progress{position:relative;display:inline-block;flex:1 1 58px;height:4px;min-width:44px;overflow:hidden;border-radius:999px}.zs-file-progress-bar{display:block;height:100%;width:0;border-radius:inherit;transition:width .12s linear}.zs-file-actions{flex:0 0 auto;display:inline-flex;align-items:center;gap:4px}.zs-file-cancel,.zs-file-retry{padding:2px 6px;border:0;border-radius:5px;font:inherit;font-size:.6875rem;font-weight:600;cursor:pointer}.zs-form-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(var(--zs-grid-min, 230px),1fr));gap:var(--zs-grid-gap, 16px);align-items:start}.zs-form-grid>.zs-full{grid-column:1 / -1}.zs-check input:focus-visible+.zs-check-box,.zs-check input:focus-visible+.zs-switch-track,.zs-radio input:focus-visible+.zs-radio-dot{outline:2px solid transparent;outline-offset:2px}.zs-input-native:focus-visible,.zs-file-input:focus-visible{outline:none}@media (prefers-reduced-motion: reduce){.zs-root,.zs-root *,.zs-root *:before,.zs-root *:after,.zs-field,.zs-field *,.zs-field *:before,.zs-field *:after,.zs-radio-group,.zs-radio-group *{animation-duration:.001ms!important;animation-iteration-count:1!important;transition-duration:.001ms!important;scroll-behavior:auto!important}.zs-root .zs-spinner{animation-duration:1.2s!important;animation-iteration-count:infinite!important}}
|
package/dist/file/zidan-file.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* ZidanForm File-only v2.3.
|
|
2
|
+
* ZidanForm File-only v2.3.1
|
|
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.3.
|
|
32
|
+
var VERSION = '2.3.1';
|
|
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.
|
|
@@ -426,6 +426,24 @@
|
|
|
426
426
|
return list.indexOf(candidate) === -1 ? fallback : candidate;
|
|
427
427
|
}
|
|
428
428
|
|
|
429
|
+
/* rangeTicks: JS array, JSON array, comma list or a tick count */
|
|
430
|
+
function parseRangeTicks(value) {
|
|
431
|
+
if (Array.isArray(value)) return value.slice();
|
|
432
|
+
if (typeof value === 'string') {
|
|
433
|
+
var raw = value.trim();
|
|
434
|
+
if (raw.charAt(0) === '[') {
|
|
435
|
+
try {
|
|
436
|
+
var parsed = JSON.parse(raw);
|
|
437
|
+
if (Array.isArray(parsed)) return parsed;
|
|
438
|
+
} catch (err) { /* fall back to the tick count */ }
|
|
439
|
+
} else if (raw.indexOf(',') !== -1) {
|
|
440
|
+
return raw.split(',').map(function (part) { return Number(part.trim()); })
|
|
441
|
+
.filter(function (number) { return isFinite(number); });
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
return value;
|
|
445
|
+
}
|
|
446
|
+
|
|
429
447
|
/* theme/framework/layout resolution shared by every field and the select */
|
|
430
448
|
function resolveScope(node, options) {
|
|
431
449
|
var opts = options || {};
|
|
@@ -472,6 +490,8 @@
|
|
|
472
490
|
var RADIO_VARIANTS = ['stacked', 'inline', 'card', 'button', 'tile'];
|
|
473
491
|
var FILE_VARIANTS = ['dropzone', 'button', 'avatar', 'gallery', 'compact'];
|
|
474
492
|
var RANGE_VARIANTS = ['default', 'gradient', 'stepped', 'minimal'];
|
|
493
|
+
var RANGE_BUBBLE_MODES = ['always', 'active', 'never'];
|
|
494
|
+
var RANGE_BUBBLE_POSITIONS = ['top', 'bottom'];
|
|
475
495
|
|
|
476
496
|
function textWithout(rootNode, skip) {
|
|
477
497
|
var out = '';
|
|
@@ -510,6 +530,7 @@
|
|
|
510
530
|
this.destroyed = false;
|
|
511
531
|
this._listeners = [];
|
|
512
532
|
this._cleanups = [];
|
|
533
|
+
this._describedByBefore = [];
|
|
513
534
|
this.formEl = target.form || (target.closest ? target.closest('form') : null);
|
|
514
535
|
var scope = resolveScope(target, this.opts);
|
|
515
536
|
this.theme = scope.theme;
|
|
@@ -641,11 +662,12 @@
|
|
|
641
662
|
this._setCustomValidity(message && custom ? message : '');
|
|
642
663
|
if (message) {
|
|
643
664
|
if (show) this.setError(message);
|
|
644
|
-
else this.setValidation('invalid');
|
|
665
|
+
else this.setValidation('invalid', true);
|
|
645
666
|
return this;
|
|
646
667
|
}
|
|
647
668
|
if (this.errorMessage) this.setError(null);
|
|
648
|
-
|
|
669
|
+
/* keep an initial or manually set invalid state until the user interacts */
|
|
670
|
+
if (this.validation === 'invalid' && !this._presetValidation) this.setValidation(null, true);
|
|
649
671
|
return this;
|
|
650
672
|
};
|
|
651
673
|
|
|
@@ -710,6 +732,22 @@
|
|
|
710
732
|
return Promise.resolve(!result.error);
|
|
711
733
|
};
|
|
712
734
|
|
|
735
|
+
ZidanFieldBase.prototype._trackDescribedBy = function (input) {
|
|
736
|
+
if (!input || !input.getAttribute) return;
|
|
737
|
+
for (var i = 0; i < this._describedByBefore.length; i += 1) {
|
|
738
|
+
if (this._describedByBefore[i][0] === input) return;
|
|
739
|
+
}
|
|
740
|
+
this._describedByBefore.push([input, input.getAttribute('aria-describedby')]);
|
|
741
|
+
};
|
|
742
|
+
|
|
743
|
+
ZidanFieldBase.prototype._addDescribedBy = function (input, id) {
|
|
744
|
+
if (!input || !input.getAttribute || !id) return;
|
|
745
|
+
this._trackDescribedBy(input);
|
|
746
|
+
var current = (input.getAttribute('aria-describedby') || '').split(/\s+/).filter(Boolean);
|
|
747
|
+
if (current.indexOf(id) === -1) current.push(id);
|
|
748
|
+
input.setAttribute('aria-describedby', current.join(' '));
|
|
749
|
+
};
|
|
750
|
+
|
|
713
751
|
ZidanFieldBase.prototype._syncDescribedBy = function () {
|
|
714
752
|
if (!this.el || !this.el.getAttribute) return;
|
|
715
753
|
var errorId = this.id + '-error';
|
|
@@ -718,6 +756,7 @@
|
|
|
718
756
|
var targets = this.validationTargets();
|
|
719
757
|
targets.forEach(function (input) {
|
|
720
758
|
if (!input || !input.getAttribute) return;
|
|
759
|
+
this._trackDescribedBy(input);
|
|
721
760
|
var current = (input.getAttribute('aria-describedby') || '').split(/\s+/).filter(Boolean);
|
|
722
761
|
var next = current.filter(function (id) { return id !== errorId && id !== hintId; });
|
|
723
762
|
if (hintId) next.push(hintId);
|
|
@@ -785,10 +824,17 @@
|
|
|
785
824
|
});
|
|
786
825
|
self.on(input, 'blur', function () {
|
|
787
826
|
self.touched = true;
|
|
827
|
+
self._presetValidation = false;
|
|
828
|
+
self._mirrorValidity();
|
|
829
|
+
});
|
|
830
|
+
self.on(input, 'input', function () {
|
|
831
|
+
self._presetValidation = false;
|
|
832
|
+
self._mirrorValidity();
|
|
833
|
+
});
|
|
834
|
+
self.on(input, 'change', function () {
|
|
835
|
+
self._presetValidation = false;
|
|
788
836
|
self._mirrorValidity();
|
|
789
837
|
});
|
|
790
|
-
self.on(input, 'input', function () { self._mirrorValidity(); });
|
|
791
|
-
self.on(input, 'change', function () { self._mirrorValidity(); });
|
|
792
838
|
});
|
|
793
839
|
this.on(this.formEl, 'reset', function () {
|
|
794
840
|
global.setTimeout(function () {
|
|
@@ -837,8 +883,10 @@
|
|
|
837
883
|
return true;
|
|
838
884
|
};
|
|
839
885
|
|
|
840
|
-
ZidanFieldBase.prototype.setValidation = function (state) {
|
|
886
|
+
ZidanFieldBase.prototype.setValidation = function (state, internal) {
|
|
841
887
|
this.validation = VALIDATION_STATES.indexOf(state) === -1 ? null : state;
|
|
888
|
+
/* public calls pin the state; internal mirrors may clear it again */
|
|
889
|
+
if (!internal) this._presetValidation = this.validation === 'invalid';
|
|
842
890
|
var invalid = this.validation === 'invalid' || !!this.errorMessage;
|
|
843
891
|
if (this.root) {
|
|
844
892
|
this.root.classList.toggle('zs-field--invalid', invalid);
|
|
@@ -929,7 +977,16 @@
|
|
|
929
977
|
this._cleanups.forEach(function (fn) { fn(); });
|
|
930
978
|
this._cleanups.length = 0;
|
|
931
979
|
this.emit('destroy', {});
|
|
932
|
-
|
|
980
|
+
/* radio groups use the author's <fieldset> as their root: removing it would
|
|
981
|
+
delete the original radios too, so only remove roots the field created. */
|
|
982
|
+
if (this.root && this.root !== this.el && this.root.parentNode) this.root.parentNode.removeChild(this.root);
|
|
983
|
+
this._describedByBefore.forEach(function (entry) {
|
|
984
|
+
var input = entry[0];
|
|
985
|
+
if (!input || !input.getAttribute) return;
|
|
986
|
+
if (entry[1] === null || entry[1] === undefined) input.removeAttribute('aria-describedby');
|
|
987
|
+
else input.setAttribute('aria-describedby', entry[1]);
|
|
988
|
+
});
|
|
989
|
+
this._describedByBefore = [];
|
|
933
990
|
if (this.el.__zidanField === this) delete this.el.__zidanField;
|
|
934
991
|
ZidanForm._unregister(this);
|
|
935
992
|
return this;
|
|
@@ -1104,6 +1161,22 @@
|
|
|
1104
1161
|
|
|
1105
1162
|
self.on(clearBtn, 'click', function () { self.clear(); });
|
|
1106
1163
|
|
|
1164
|
+
/* Delegated once: the list is rebuilt on every upload progress tick, so
|
|
1165
|
+
per-item listeners would grow without bound. */
|
|
1166
|
+
self.on(list, 'click', function (event) {
|
|
1167
|
+
var button = event.target && event.target.closest ? event.target.closest('button') : null;
|
|
1168
|
+
if (!button || !list.contains(button)) return;
|
|
1169
|
+
var item = button.closest('.zs-file-item');
|
|
1170
|
+
var index = item ? parseInt(item.getAttribute('data-zs-file-index'), 10) : -1;
|
|
1171
|
+
var file = index >= 0 ? self.getFiles()[index] : null;
|
|
1172
|
+
if (!file) return;
|
|
1173
|
+
event.preventDefault();
|
|
1174
|
+
event.stopPropagation();
|
|
1175
|
+
if (button.classList.contains('zs-file-cancel')) self.cancelUpload(file);
|
|
1176
|
+
else if (button.classList.contains('zs-file-retry')) self.retryUpload(file);
|
|
1177
|
+
else if (button.classList.contains('zs-file-remove')) self.removeFile(file);
|
|
1178
|
+
});
|
|
1179
|
+
|
|
1107
1180
|
this._bindValidity();
|
|
1108
1181
|
this.on(this.formEl, 'reset', function () {
|
|
1109
1182
|
global.setTimeout(function () {
|
|
@@ -1400,6 +1473,7 @@
|
|
|
1400
1473
|
var state = self._stateFor(file, false) || { status: 'idle', progress: 0, error: '', result: null };
|
|
1401
1474
|
var item = el('li', 'zs-file-item');
|
|
1402
1475
|
item.setAttribute('data-zs-upload-state', state.status);
|
|
1476
|
+
item.setAttribute('data-zs-file-index', String(index));
|
|
1403
1477
|
|
|
1404
1478
|
var thumb = el('span', 'zs-file-thumb');
|
|
1405
1479
|
if (/^image\//.test(file.type)) {
|
|
@@ -1449,30 +1523,15 @@
|
|
|
1449
1523
|
if (state.status === 'uploading') {
|
|
1450
1524
|
var cancel = el('button', 'zs-file-cancel', { type: 'button', 'aria-label': 'Cancel upload of ' + file.name });
|
|
1451
1525
|
cancel.textContent = opts.cancelLabel || 'Cancel';
|
|
1452
|
-
self.on(cancel, 'click', function (event) {
|
|
1453
|
-
event.preventDefault();
|
|
1454
|
-
event.stopPropagation();
|
|
1455
|
-
self.cancelUpload(file);
|
|
1456
|
-
});
|
|
1457
1526
|
actions.appendChild(cancel);
|
|
1458
1527
|
} else if (state.status === 'error' || state.status === 'canceled') {
|
|
1459
1528
|
var retry = el('button', 'zs-file-retry', { type: 'button', 'aria-label': 'Retry upload of ' + file.name });
|
|
1460
1529
|
retry.textContent = opts.retryLabel || 'Retry';
|
|
1461
|
-
self.on(retry, 'click', function (event) {
|
|
1462
|
-
event.preventDefault();
|
|
1463
|
-
event.stopPropagation();
|
|
1464
|
-
self.retryUpload(file);
|
|
1465
|
-
});
|
|
1466
1530
|
actions.appendChild(retry);
|
|
1467
1531
|
}
|
|
1468
1532
|
|
|
1469
1533
|
var remove = el('button', 'zs-file-remove', { type: 'button', 'aria-label': 'Remove ' + file.name });
|
|
1470
1534
|
remove.textContent = '\u00d7';
|
|
1471
|
-
self.on(remove, 'click', function (event) {
|
|
1472
|
-
event.preventDefault();
|
|
1473
|
-
event.stopPropagation();
|
|
1474
|
-
self.removeFile(file);
|
|
1475
|
-
});
|
|
1476
1535
|
actions.appendChild(remove);
|
|
1477
1536
|
|
|
1478
1537
|
item.appendChild(thumb);
|
|
@@ -1810,7 +1869,11 @@
|
|
|
1810
1869
|
// (output, counter, clearable, …) work without a data attribute
|
|
1811
1870
|
var kind = fieldKindFor(node) || inferredTextKind(node);
|
|
1812
1871
|
if (!kind) return;
|
|
1813
|
-
if (kind === 'radio'
|
|
1872
|
+
if (kind === 'radio' || kind === 'radio-group') {
|
|
1873
|
+
if (/^INPUT$/i.test(node.tagName)) {
|
|
1874
|
+
node = node.closest ? node.closest('fieldset, [data-zidan-radio-group]') : null;
|
|
1875
|
+
if (!node) return;
|
|
1876
|
+
}
|
|
1814
1877
|
kind = 'radio-group';
|
|
1815
1878
|
}
|
|
1816
1879
|
var instance = createField(node, kind, options || {});
|
|
@@ -1825,7 +1888,13 @@
|
|
|
1825
1888
|
if (!isElement(node) || node.__zidanField) return;
|
|
1826
1889
|
var kind = fieldKindFor(node);
|
|
1827
1890
|
if (!kind) return;
|
|
1828
|
-
if (kind === 'radio'
|
|
1891
|
+
if (kind === 'radio' || kind === 'radio-group') {
|
|
1892
|
+
if (/^INPUT$/i.test(node.tagName)) {
|
|
1893
|
+
node = node.closest ? node.closest('fieldset, [data-zidan-radio-group]') : null;
|
|
1894
|
+
if (!node) return;
|
|
1895
|
+
}
|
|
1896
|
+
kind = 'radio-group';
|
|
1897
|
+
}
|
|
1829
1898
|
var instance = createField(node, kind, options || {});
|
|
1830
1899
|
if (instance) instances.push(instance);
|
|
1831
1900
|
});
|