zidan-select 2.3.0 → 2.4.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.
- package/README.md +186 -72
- 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 +233 -8
- package/dist/select/zidan-select.min.js +2 -2
- package/dist/zidan-form.js +383 -55
- package/dist/zidan-form.min.js +2 -2
- package/docs/build.md +66 -40
- package/docs/html-and-wordpress.md +20 -20
- package/docs/index.html +20 -8
- package/docs/options.md +76 -11
- package/docs/validation.md +8 -0
- package/package.json +6 -2
- package/plugin-core.css +109 -1
- package/plugin-theme.css +1 -1
- package/zidan-form.d.ts +28 -1
- package/zidan-form.js +383 -55
package/docs/build.md
CHANGED
|
@@ -13,8 +13,11 @@ zidan-select/
|
|
|
13
13
|
├─ plugin-core.css # structure only
|
|
14
14
|
├─ plugin-theme.css # tokens, presets, layouts, framework adapters
|
|
15
15
|
├─ index.html # tabbed demo + theme showcase
|
|
16
|
+
├─ advanced.html # advanced options + HTML/JS reference
|
|
17
|
+
├─ advanced.css/js # advanced-page-only assets
|
|
16
18
|
├─ playground.html # per-field option builder
|
|
17
19
|
├─ playground.css/js # playground-only assets
|
|
20
|
+
├─ nav.css / nav.js # shared demo header and mobile menu
|
|
18
21
|
├─ robots.txt # Pages crawler directives + sitemap pointer
|
|
19
22
|
├─ sitemap.xml # public Pages URLs
|
|
20
23
|
├─ demo.css / demo.js # demo-only assets
|
|
@@ -22,8 +25,11 @@ zidan-select/
|
|
|
22
25
|
├─ scripts/
|
|
23
26
|
│ ├─ serve.mjs # dependency-free dev server (port 4173)
|
|
24
27
|
│ ├─ build.mjs # assembles dist/ and the select/file subset bundles
|
|
25
|
-
│
|
|
28
|
+
│ ├─ test.mjs # syntax / split-CSS / API checks
|
|
29
|
+
│ └─ release.mjs # one-command version bump, changelog roll, commit and tag
|
|
26
30
|
├─ docs/ # comparison, options, validation, frameworks, theming, build
|
|
31
|
+
├─ .github/workflows/ # pages.yml (demo) and release.yml (npm publish with provenance)
|
|
32
|
+
├─ CHANGELOG.md
|
|
27
33
|
├─ README.md
|
|
28
34
|
└─ LICENSE
|
|
29
35
|
```
|
|
@@ -52,6 +58,7 @@ side by side at the [builds section](https://akhtar1985.github.io/zidan-select/#
|
|
|
52
58
|
| `npm test` | `node --check` on every script, asserts `plugin-core.css` has no colour literals, checks all presets/adapters and the exported API. |
|
|
53
59
|
| `npm run lint` | Syntax check only. |
|
|
54
60
|
| `npm run build` | Cleans `dist/`, copies the four assets, writes `dist/zidan-form.cjs`, generates the select-only and file-only bundles, and minifies **if** esbuild is installed. |
|
|
61
|
+
| `npm run release -- patch` | Bumps every version site, rolls `CHANGELOG.md`, runs the checks, commits and tags `vX.Y.Z`. |
|
|
55
62
|
|
|
56
63
|
There is no watch task: the JS and CSS are the distributables, so edit and reload. `npm run
|
|
57
64
|
dev` sends `Cache-Control: no-store`, which is enough for the demo.
|
|
@@ -96,7 +103,7 @@ Without esbuild the build still succeeds and prints that minification was skippe
|
|
|
96
103
|
| Select-only | `/dist/select/zidan-select.min.js` | `/dist/select/plugin-select-core.min.css` | `/dist/select/plugin-select-theme.min.css` |
|
|
97
104
|
| File-only | `/dist/file/zidan-file.min.js` | `/dist/file/plugin-file-core.min.css` | `/dist/file/plugin-file-theme.min.css` |
|
|
98
105
|
|
|
99
|
-
Prepend `https://cdn.jsdelivr.net/npm/zidan-select@2.
|
|
106
|
+
Prepend `https://cdn.jsdelivr.net/npm/zidan-select@2.4.0` to each path (or your own origin).
|
|
100
107
|
These are real files in the npm tarball, so unpkg and self-hosted CDNs serve the same bytes;
|
|
101
108
|
jsDelivr additionally auto-minifies the readable root files, but do not rely on that trick.
|
|
102
109
|
Check the three you use with `curl -I` before changing a version, then update the URLs in the
|
|
@@ -119,7 +126,7 @@ Both theme stylesheets keep the token set, the five preset themes (`default`, `m
|
|
|
119
126
|
adapters, so `data-zidan-theme`, `data-zidan-layout` and `data-zidan-framework` behave the same
|
|
120
127
|
as in the full build.
|
|
121
128
|
|
|
122
|
-
Approximate v2.
|
|
129
|
+
Approximate v2.4.0 sizes (readable → minified): select ≈104 → 62 kB JS, 12 → 9 kB core CSS,
|
|
123
130
|
32 → 27 kB theme; file ≈82 → 49 kB JS, 9 → 7 kB core, 34 → 29 kB theme; full ≈208 → 123 kB
|
|
124
131
|
JS, 38 → 29 kB core, 47 → 39 kB theme.
|
|
125
132
|
|
|
@@ -147,25 +154,63 @@ abort the build instead of producing a partial bundle.
|
|
|
147
154
|
|
|
148
155
|
## Versioning
|
|
149
156
|
|
|
150
|
-
Semantic versioning, with the
|
|
157
|
+
Semantic versioning, with the history in [`CHANGELOG.md`](../CHANGELOG.md):
|
|
151
158
|
|
|
152
159
|
- **patch** — bug fixes, no token/API changes.
|
|
153
160
|
- **minor** — new themes, layouts, adapters, options (backwards compatible).
|
|
154
161
|
- **major** — renamed tokens, removed attributes, changed defaults.
|
|
155
162
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
163
|
+
The runtime guard (`__zidanFormGuard`) compares `VERSION` in `zidan-form.js`, so the version
|
|
164
|
+
constant, the `package.json` field, the lockfile and the CSS banners must always agree —
|
|
165
|
+
`npm test` fails when they drift.
|
|
166
|
+
|
|
167
|
+
## Releasing
|
|
168
|
+
|
|
169
|
+
```bash
|
|
170
|
+
npm run release -- patch --note "Fix the thing that broke" # or: minor | major | 2.3.2
|
|
171
|
+
git push origin main --follow-tags
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
`scripts/release.mjs` is the whole release:
|
|
175
|
+
|
|
176
|
+
1. writes the new version into `package.json`, `package-lock.json`, the banner and `VERSION` in
|
|
177
|
+
`zidan-form.js`, both CSS banners, the README CDN URLs, `index.html`, `advanced.html`,
|
|
178
|
+
`docs/build.md` and `docs/html-and-wordpress.md`;
|
|
179
|
+
2. moves `## [Unreleased]` in `CHANGELOG.md` under `## [X.Y.Z] - YYYY-MM-DD` — write your notes
|
|
180
|
+
there, or pass `--note "…"`; it refuses to cut a release with no notes;
|
|
181
|
+
3. runs `npm run types && npm test`;
|
|
182
|
+
4. commits `Release X.Y.Z` and creates the annotated tag `vX.Y.Z`.
|
|
183
|
+
|
|
184
|
+
Flags: `--dry-run` (print the plan, write nothing), `--no-commit` (edit files and the changelog
|
|
185
|
+
only), `--skip-checks`. It requires a clean tracked working tree, so the release commit holds only
|
|
186
|
+
the bump, and it refuses a version that is already tagged.
|
|
187
|
+
|
|
188
|
+
Pushing the tag starts `.github/workflows/release.yml`. Nothing else to run.
|
|
159
189
|
|
|
160
190
|
## Publishing to npm
|
|
161
191
|
|
|
192
|
+
Publishing happens in CI:
|
|
193
|
+
|
|
194
|
+
| Trigger | What happens |
|
|
195
|
+
| --- | --- |
|
|
196
|
+
| Tag `vX.Y.Z` pushed | Verifies the tag against `package.json`, refuses an existing version, runs `prepublishOnly` (types → build → test), publishes with `--provenance`. |
|
|
197
|
+
| **Actions → Publish to npm → Run workflow** | The same job without a tag, for publishing the version already committed. |
|
|
198
|
+
|
|
199
|
+
Authentication is **npm trusted publishing** over OIDC: the job requests `id-token: write` and
|
|
200
|
+
needs no token secret. One-time setup on npmjs.com — **zidan-select → Settings → Trusted
|
|
201
|
+
publishing → GitHub Actions**, owner `akhtar1985`, repository `zidan-select`, workflow
|
|
202
|
+
`release.yml`, environment left empty. Requires npm 11.5.1+; the workflow runs `node-version: 24`.
|
|
203
|
+
|
|
204
|
+
Without trusted publishing, create a granular access token with read+write on `zidan-select`,
|
|
205
|
+
store it as the `NPM_TOKEN` repository secret, and uncomment the `NODE_AUTH_TOKEN` env block at
|
|
206
|
+
the bottom of the workflow. Remove it once OIDC works.
|
|
207
|
+
|
|
208
|
+
Manual publishing remains a last resort:
|
|
209
|
+
|
|
162
210
|
```bash
|
|
163
211
|
npm login
|
|
164
212
|
npm test
|
|
165
|
-
npm version minor -m "release: v%s"
|
|
166
|
-
npm run build
|
|
167
213
|
npm publish # tarball limited by package.json "files"
|
|
168
|
-
git push --follow-tags
|
|
169
214
|
```
|
|
170
215
|
|
|
171
216
|
First publish: `npm publish --access public`. Scoped forks need `--access public` on every
|
|
@@ -201,8 +246,9 @@ import 'zidan-select/file/css/theme';
|
|
|
201
246
|
## GitHub Pages
|
|
202
247
|
|
|
203
248
|
The demo is static and needs no build. `.github/workflows/pages.yml` assembles `_site/` on every
|
|
204
|
-
push to `main` — `index.html`, `
|
|
205
|
-
`
|
|
249
|
+
push to `main` — `index.html`, `advanced.html`, `playground.html`, `shopify.html`, `advanced.css`,
|
|
250
|
+
`advanced.js`, `playground.css`, `playground.js`, `demo.css`, `demo.js`, `nav.css`, `nav.js`, `robots.txt`,
|
|
251
|
+
`sitemap.xml`, the four library files and `docs/` — then uploads it with
|
|
206
252
|
`actions/upload-pages-artifact` and publishes it with `actions/deploy-pages`.
|
|
207
253
|
|
|
208
254
|
One-time setup: **Settings → Pages → Build and deployment → Source: GitHub Actions**.
|
|
@@ -210,40 +256,20 @@ One-time setup: **Settings → Pages → Build and deployment → Source: GitHub
|
|
|
210
256
|
| URL | Serves |
|
|
211
257
|
| --- | --- |
|
|
212
258
|
| `https://akhtar1985.github.io/zidan-select/` | The tabbed demo |
|
|
259
|
+
| `https://akhtar1985.github.io/zidan-select/advanced.html` | Advanced options and API reference |
|
|
213
260
|
| `https://akhtar1985.github.io/zidan-select/playground.html` | Per-field option playground |
|
|
261
|
+
| `https://akhtar1985.github.io/zidan-select/shopify.html` | Shopify product-page demo |
|
|
214
262
|
| `https://akhtar1985.github.io/zidan-select/docs/` | Documentation index |
|
|
215
263
|
| `/#select`, `/#check`, `/#file`, `/#inputs`, `/#themes` | Deep links to a demo tab |
|
|
216
264
|
| `/playground.html#select`, `#file`, `#checkbox`, `#radio`, `#text` | Deep links to a playground control |
|
|
217
|
-
| `/robots.txt`, `/sitemap.xml` | Crawler directives and the
|
|
265
|
+
| `/robots.txt`, `/sitemap.xml` | Crawler directives and the public page URLs |
|
|
218
266
|
|
|
219
267
|
The workflow only copies demo assets, so `scripts/`, `dist/`, `package.json` and local scratch
|
|
220
268
|
files are never published.
|
|
221
269
|
|
|
222
|
-
## Release automation
|
|
223
|
-
|
|
224
|
-
```yaml
|
|
225
|
-
# .github/workflows/publish.yml
|
|
226
|
-
name: publish
|
|
227
|
-
on:
|
|
228
|
-
release:
|
|
229
|
-
types: [published]
|
|
230
|
-
jobs:
|
|
231
|
-
npm:
|
|
232
|
-
runs-on: ubuntu-latest
|
|
233
|
-
permissions:
|
|
234
|
-
contents: read
|
|
235
|
-
id-token: write
|
|
236
|
-
steps:
|
|
237
|
-
- uses: actions/checkout@v4
|
|
238
|
-
- uses: actions/setup-node@v4
|
|
239
|
-
with:
|
|
240
|
-
node-version: 20
|
|
241
|
-
registry-url: https://registry.npmjs.org
|
|
242
|
-
- run: npm test
|
|
243
|
-
- run: npm run build
|
|
244
|
-
- run: npm publish --provenance --access public
|
|
245
|
-
env:
|
|
246
|
-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
247
|
-
```
|
|
270
|
+
## Release automation
|
|
248
271
|
|
|
249
|
-
|
|
272
|
+
[`.github/workflows/release.yml`](../.github/workflows/release.yml) is the complete workflow:
|
|
273
|
+
tag-triggered, provenance-enabled, dist-tag aware (`latest`, or `next` for prereleases), with
|
|
274
|
+
guards against a mismatched tag and a duplicate version. It installs the dev tooling with
|
|
275
|
+
`npm ci` only to build and test — the published package still has no runtime dependencies.
|
|
@@ -33,15 +33,15 @@ colours), `plugin-theme.css` carries colours, presets and skins.
|
|
|
33
33
|
| File uploads only | `dist/file/zidan-file.js` + `plugin-file-core.css` + `plugin-file-theme.css` |
|
|
34
34
|
| Several control types together | `zidan-form.js` + `plugin-core.css` + `plugin-theme.css` |
|
|
35
35
|
|
|
36
|
-
Pinned CDN URLs (replace `2.
|
|
36
|
+
Pinned CDN URLs (replace `2.4.0` when you upgrade):
|
|
37
37
|
|
|
38
38
|
| Build | JavaScript | CSS |
|
|
39
39
|
| --- | --- | --- |
|
|
40
|
-
| Full | `https://cdn.jsdelivr.net/npm/zidan-select@2.
|
|
41
|
-
| Select-only | `https://cdn.jsdelivr.net/npm/zidan-select@2.
|
|
42
|
-
| File-only | `https://cdn.jsdelivr.net/npm/zidan-select@2.
|
|
40
|
+
| Full | `https://cdn.jsdelivr.net/npm/zidan-select@2.4.0/zidan-form.js` | `…@2.4.0/plugin-core.css` + `…@2.4.0/plugin-theme.css` |
|
|
41
|
+
| Select-only | `https://cdn.jsdelivr.net/npm/zidan-select@2.4.0/dist/select/zidan-select.js` | `…@2.4.0/dist/select/plugin-select-core.css` + `…plugin-select-theme.css` |
|
|
42
|
+
| File-only | `https://cdn.jsdelivr.net/npm/zidan-select@2.4.0/dist/file/zidan-file.js` | `…@2.4.0/dist/file/plugin-file-core.css` + `…plugin-file-theme.css` |
|
|
43
43
|
|
|
44
|
-
Prefer self-hosting? Download the same files (`npm pack zidan-select@2.
|
|
44
|
+
Prefer self-hosting? Download the same files (`npm pack zidan-select@2.4.0`, or the raw files
|
|
45
45
|
from GitHub) and keep them next to your page:
|
|
46
46
|
|
|
47
47
|
```
|
|
@@ -174,8 +174,8 @@ see the native `FormData`.
|
|
|
174
174
|
<title>ZidanForm static example</title>
|
|
175
175
|
|
|
176
176
|
<!-- structure first, theme second -->
|
|
177
|
-
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/zidan-select@2.
|
|
178
|
-
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/zidan-select@2.
|
|
177
|
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/zidan-select@2.4.0/plugin-core.css">
|
|
178
|
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/zidan-select@2.4.0/plugin-theme.css">
|
|
179
179
|
</head>
|
|
180
180
|
<body>
|
|
181
181
|
|
|
@@ -251,7 +251,7 @@ see the native `FormData`.
|
|
|
251
251
|
</form>
|
|
252
252
|
</main>
|
|
253
253
|
|
|
254
|
-
<script src="https://cdn.jsdelivr.net/npm/zidan-select@2.
|
|
254
|
+
<script src="https://cdn.jsdelivr.net/npm/zidan-select@2.4.0/zidan-form.js"></script>
|
|
255
255
|
<script>
|
|
256
256
|
// Demo only: show the native FormData instead of navigating away.
|
|
257
257
|
document.querySelector('.zidan-form').addEventListener('submit', function (event) {
|
|
@@ -289,9 +289,9 @@ and `ZidanSelect`; `zidanField` does not exist here.
|
|
|
289
289
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
290
290
|
<title>Select-only example</title>
|
|
291
291
|
<link rel="stylesheet"
|
|
292
|
-
href="https://cdn.jsdelivr.net/npm/zidan-select@2.
|
|
292
|
+
href="https://cdn.jsdelivr.net/npm/zidan-select@2.4.0/dist/select/plugin-select-core.css">
|
|
293
293
|
<link rel="stylesheet"
|
|
294
|
-
href="https://cdn.jsdelivr.net/npm/zidan-select@2.
|
|
294
|
+
href="https://cdn.jsdelivr.net/npm/zidan-select@2.4.0/dist/select/plugin-select-theme.css">
|
|
295
295
|
</head>
|
|
296
296
|
<body style="max-width:520px;margin:40px auto;padding:0 20px">
|
|
297
297
|
|
|
@@ -311,7 +311,7 @@ and `ZidanSelect`; `zidanField` does not exist here.
|
|
|
311
311
|
</select>
|
|
312
312
|
</p>
|
|
313
313
|
|
|
314
|
-
<script src="https://cdn.jsdelivr.net/npm/zidan-select@2.
|
|
314
|
+
<script src="https://cdn.jsdelivr.net/npm/zidan-select@2.4.0/dist/select/zidan-select.js"></script>
|
|
315
315
|
<script>
|
|
316
316
|
zidanSelect('#country', {
|
|
317
317
|
mode: 'combobox',
|
|
@@ -342,9 +342,9 @@ Only uploads on this page? Load the file-only build. It exposes `zidanField`,
|
|
|
342
342
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
343
343
|
<title>File upload example</title>
|
|
344
344
|
<link rel="stylesheet"
|
|
345
|
-
href="https://cdn.jsdelivr.net/npm/zidan-select@2.
|
|
345
|
+
href="https://cdn.jsdelivr.net/npm/zidan-select@2.4.0/dist/file/plugin-file-core.css">
|
|
346
346
|
<link rel="stylesheet"
|
|
347
|
-
href="https://cdn.jsdelivr.net/npm/zidan-select@2.
|
|
347
|
+
href="https://cdn.jsdelivr.net/npm/zidan-select@2.4.0/dist/file/plugin-file-theme.css">
|
|
348
348
|
</head>
|
|
349
349
|
<body style="max-width:520px;margin:40px auto;padding:0 20px">
|
|
350
350
|
|
|
@@ -356,7 +356,7 @@ Only uploads on this page? Load the file-only build. It exposes `zidanField`,
|
|
|
356
356
|
<input id="shots" type="file" name="shots" multiple accept="image/*">
|
|
357
357
|
</form>
|
|
358
358
|
|
|
359
|
-
<script src="https://cdn.jsdelivr.net/npm/zidan-select@2.
|
|
359
|
+
<script src="https://cdn.jsdelivr.net/npm/zidan-select@2.4.0/dist/file/zidan-file.js"></script>
|
|
360
360
|
<script>
|
|
361
361
|
zidanField('#cv', {
|
|
362
362
|
variant: 'dropzone',
|
|
@@ -475,9 +475,9 @@ add_action('wp_enqueue_scripts', function () {
|
|
|
475
475
|
|
|
476
476
|
$base = get_stylesheet_directory_uri() . '/assets/zidan';
|
|
477
477
|
|
|
478
|
-
wp_enqueue_style('zidan-core', $base . '/plugin-core.css', array(), '2.
|
|
479
|
-
wp_enqueue_style('zidan-theme', $base . '/plugin-theme.css', array('zidan-core'), '2.
|
|
480
|
-
wp_enqueue_script('zidan-form', $base . '/zidan-form.js', array(), '2.
|
|
478
|
+
wp_enqueue_style('zidan-core', $base . '/plugin-core.css', array(), '2.4.0');
|
|
479
|
+
wp_enqueue_style('zidan-theme', $base . '/plugin-theme.css', array('zidan-core'), '2.4.0');
|
|
480
|
+
wp_enqueue_script('zidan-form', $base . '/zidan-form.js', array(), '2.4.0', true);
|
|
481
481
|
|
|
482
482
|
// Optional: configure fields by ID/class without inline HTML scripts.
|
|
483
483
|
wp_add_inline_script('zidan-form', "window.ZIDAN_FORM_CONFIG = {
|
|
@@ -552,9 +552,9 @@ Shopify has its own section: [9. Shopify](#9-shopify).
|
|
|
552
552
|
```html
|
|
553
553
|
<!-- inside one embed block: markup first, script last -->
|
|
554
554
|
<select class="zidan-select" data-zidan-options='{"mode":"combobox"}'>…</select>
|
|
555
|
-
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/zidan-select@2.
|
|
556
|
-
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/zidan-select@2.
|
|
557
|
-
<script src="https://cdn.jsdelivr.net/npm/zidan-select@2.
|
|
555
|
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/zidan-select@2.4.0/plugin-core.css">
|
|
556
|
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/zidan-select@2.4.0/plugin-theme.css">
|
|
557
|
+
<script src="https://cdn.jsdelivr.net/npm/zidan-select@2.4.0/zidan-form.js"></script>
|
|
558
558
|
```
|
|
559
559
|
|
|
560
560
|
For the single-select case, the select-only build is smaller: swap in the
|
package/docs/index.html
CHANGED
|
@@ -56,12 +56,24 @@
|
|
|
56
56
|
style="display:block;width:100%;max-width:640px;margin:0 0 28px;border-radius:14px;border:1px solid #e4e8f1;box-shadow:0 1px 2px rgba(16,19,36,.05)">
|
|
57
57
|
</a>
|
|
58
58
|
<ul>
|
|
59
|
+
<li>
|
|
60
|
+
<strong><a href="../advanced.html">Advanced options & API reference</a></strong>
|
|
61
|
+
<span>Initialization and option precedence, async select pagination, tags, Promise validation, uploads, events, lifecycle, RTL, TypeScript and copyable HTML/JavaScript examples.</span>
|
|
62
|
+
</li>
|
|
59
63
|
<li>
|
|
60
64
|
<strong><a href="../playground.html">Field playground</a></strong>
|
|
61
65
|
<span>Pick one control, toggle its options, preview it live and copy the matching HTML attributes or vanilla JavaScript call.</span>
|
|
62
66
|
</li>
|
|
63
67
|
<li>
|
|
64
|
-
<strong><a href="
|
|
68
|
+
<strong><a href="../ajax.html">AJAX & remote data demo</a></strong>
|
|
69
|
+
<span>Declarative <code>data-zidan-fetch-url</code> against a real API, plus a hand-written <code>fetchOptions</code> example with paging, abort and cache state on screen.</span>
|
|
70
|
+
</li>
|
|
71
|
+
<li>
|
|
72
|
+
<strong><a href="../index.html#controls">Controls & options reference</a></strong>
|
|
73
|
+
<span>Every control family in one place: the options you reach for most, the two ways to initialise a field, and live examples — with links into the playground for the remaining options and the advanced reference for callbacks and the API.</span>
|
|
74
|
+
</li>
|
|
75
|
+
<li>
|
|
76
|
+
<strong><a href="html-and-wordpress.html">Static HTML & WordPress cookbook</a></strong>
|
|
65
77
|
<span>Complete copy-paste pages for plain HTML, select-only and file-only builds, ID/class targeting, WordPress <code>functions.php</code>, Shopify <code>asset_url</code> + Liquid sections, and troubleshooting for page builders and caching plugins.</span>
|
|
66
78
|
</li>
|
|
67
79
|
<li>
|
|
@@ -73,31 +85,31 @@
|
|
|
73
85
|
<span>Only want a select, or only a file upload? Load only that build — you do not need the full bundle. The complete form JS and CSS is for forms that enhance every input at once.</span>
|
|
74
86
|
</li>
|
|
75
87
|
<li>
|
|
76
|
-
<strong><a href="
|
|
88
|
+
<strong><a href="comparison.html">Why ZidanForm & comparison</a></strong>
|
|
77
89
|
<span>Feature matrix against Select2, Choices.js, Tom Select, Slim Select and Bootstrap, plus benefits, trade-offs and migration notes.</span>
|
|
78
90
|
</li>
|
|
79
91
|
<li>
|
|
80
|
-
<strong><a href="
|
|
92
|
+
<strong><a href="options.html">Options & data attributes</a></strong>
|
|
81
93
|
<span>Every JS option, data attribute, callback, event and instance method — remote pagination and cache controls, no-JS init by marker class, form scope, <code>data-zidan-options</code> JSON and config targets, in the full build and both subsets. TypeScript declarations ship with the package.</span>
|
|
82
94
|
</li>
|
|
83
95
|
<li>
|
|
84
|
-
<strong><a href="
|
|
96
|
+
<strong><a href="validation-guide.html">Validation compatibility</a></strong>
|
|
85
97
|
<span>Native constraint validation, jQuery Validation, JustValidate, Parsley and double-submit guards. <a href="validation.html">Runnable test bench →</a></span>
|
|
86
98
|
</li>
|
|
87
99
|
<li>
|
|
88
|
-
<strong><a href="
|
|
100
|
+
<strong><a href="theming.html">Theming</a></strong>
|
|
89
101
|
<span>Token reference, five presets, layouts, framework adapters and custom themes.</span>
|
|
90
102
|
</li>
|
|
91
103
|
<li>
|
|
92
|
-
<strong><a href="
|
|
104
|
+
<strong><a href="frameworks.html">Framework integration</a></strong>
|
|
93
105
|
<span>React, Next.js (with SSR), Vue, Angular and state-sync patterns.</span>
|
|
94
106
|
</li>
|
|
95
107
|
<li>
|
|
96
|
-
<strong><a href="
|
|
108
|
+
<strong><a href="build.html#select-only-and-file-only-builds">Select-only & file-only builds</a></strong>
|
|
97
109
|
<span>Trimmed JS and matching CSS for pages that only need a select or a file upload, with every theme and framework adapter included.</span>
|
|
98
110
|
</li>
|
|
99
111
|
<li>
|
|
100
|
-
<strong><a href="
|
|
112
|
+
<strong><a href="build.html">Build & publish</a></strong>
|
|
101
113
|
<span>Repository layout, scripts, dist output, npm publishing and GitHub Pages.</span>
|
|
102
114
|
</li>
|
|
103
115
|
</ul>
|
package/docs/options.md
CHANGED
|
@@ -135,9 +135,9 @@ Applies to `ZidanCheckbox`, `ZidanRadioGroup`, `ZidanFileUpload`, `ZidanTextFiel
|
|
|
135
135
|
| `layout` | `data-zidan-layout` | string | `stacked` | `stacked`, `inline`, `compact`, `floating`, `outlined`, `card`. |
|
|
136
136
|
| `theme` | `data-zidan-theme`, `data-zs-theme` | string | `default` | `default`, `modern`, `minimal`, `dark`, `glass`. Resolves element → ancestor → `<html>`. |
|
|
137
137
|
| `framework` | `data-zidan-framework`, `data-zs-framework` | string | `none` | `none`, `bootstrap`, `tailwind`, `bulma`, `foundation`, `vanilla`. |
|
|
138
|
-
| `label` | `data-zidan-label` | string | — | Used when the markup has no `<label>`; a generated label is `<label for>`. |
|
|
138
|
+
| `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
139
|
| `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()`. |
|
|
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
141
|
| `alwaysValidate` | — | boolean | `false` | Mark invalid as soon as native validity fails instead of on blur. |
|
|
142
142
|
| `indeterminate` | `data-zidan-indeterminate` | boolean | `false` | Checkbox starts mixed. |
|
|
143
143
|
| `clearable` | `data-zidan-clear` | boolean | `search` only | Clear button for text inputs and textarea. |
|
|
@@ -145,7 +145,7 @@ Applies to `ZidanCheckbox`, `ZidanRadioGroup`, `ZidanFileUpload`, `ZidanTextFiel
|
|
|
145
145
|
| `prefix` | `data-zidan-prefix` | string | — | Static text before the input. |
|
|
146
146
|
| `suffix` | `data-zidan-suffix` | string | — | Static text after the input. |
|
|
147
147
|
| `counter` | `data-zidan-counter` | number | `maxlength` | Counter maximum; wins over the `maxlength` default. |
|
|
148
|
-
| `output` | `data-zidan-output` | selector | — | Range value is mirrored into this element. |
|
|
148
|
+
| `output` | `data-zidan-output` | selector | — | Range display value (formatted when `rangeFormat` is set) is mirrored into this element. |
|
|
149
149
|
| `title` | `data-zidan-title` | string | `Choose a file` | Dropzone headline. |
|
|
150
150
|
| `dropHint` | `data-zidan-drop-hint` | string | — | Dropzone subtitle. |
|
|
151
151
|
| `accept` | native `accept` | string | — | Validated on top of the native picker filter and shown in the dropzone hint. |
|
|
@@ -291,13 +291,17 @@ national `0` is dropped in international/E.164 output.
|
|
|
291
291
|
| JS option | Data attribute | Type | Default | Notes |
|
|
292
292
|
| --- | --- | --- | --- | --- |
|
|
293
293
|
| `rangeVariant` | `data-zidan-range-variant` | `default` \| `gradient` \| `stepped` \| `minimal` | `default` | Visual skin. |
|
|
294
|
-
| `rangeBubble` | `data-zidan-range-bubble` | boolean | `true` |
|
|
295
|
-
| `
|
|
296
|
-
| `
|
|
297
|
-
| `
|
|
294
|
+
| `rangeBubble` | `data-zidan-range-bubble` | boolean | `true` | Master switch for the floating value bubble. |
|
|
295
|
+
| `rangeBubbleMode` | `data-zidan-range-bubble-mode` | `always` \| `active` \| `never` | `always` | `active` shows the bubble only on hover, focus or drag. |
|
|
296
|
+
| `rangeBubblePosition` | `data-zidan-range-bubble-position` | `top` \| `bottom` | `top` | Bubble above the track or below the ticks/scale. |
|
|
297
|
+
| `rangeFill` | `data-zidan-range-fill` | boolean | `true` | Coloured progress fill; `false` keeps the neutral track (gradient skin keeps its gradient). |
|
|
298
|
+
| `rangeMinMax` | `data-zidan-range-minmax` | boolean | `true` | Min/max scale under the track. Hidden automatically when labeled ticks cover both ends, so 0 and the max print once. |
|
|
299
|
+
| `rangeMinLabel` / `rangeMaxLabel` | `data-zidan-range-min-label` / `-range-max-label` | string | — | Custom text for the scale ends (e.g. `Low` / `High`); `rangeFormat` is used when unset. |
|
|
300
|
+
| `rangeTicks` | `data-zidan-range-ticks` | number \| array \| string | `0` | Count, JS array, JSON array or comma list (`0,250,500`). Values are absolute and out-of-range ones sit at the nearest end. |
|
|
301
|
+
| `rangeTickLabels` | `data-zidan-range-tick-labels` | boolean | `false` | Text labels on ticks. Labels at both ends replace the min/max scale. |
|
|
298
302
|
| `rangeLabels` | — | object | — | Map `{ value: 'Label' }` used with labeled ticks. |
|
|
299
303
|
| `rangeFormat` | `data-zidan-range-format` | string \| function | — | Template with `{value}`, `{min}`, `{max}` (or `%s`), or `function(value, field)` in JS. |
|
|
300
|
-
| `output` | `data-zidan-output` | selector | — | Mirrors the
|
|
304
|
+
| `output` | `data-zidan-output` | selector | — | Mirrors the display value (formatted when `rangeFormat` is set) into a `<output>`/element; `input.value` keeps the raw value. |
|
|
301
305
|
|
|
302
306
|
```html
|
|
303
307
|
<input type="range" min="0" max="1000" step="50" value="400"
|
|
@@ -313,12 +317,36 @@ zidanField('#price', {
|
|
|
313
317
|
rangeLabels: { 0: 'Free', 1000: 'Top' },
|
|
314
318
|
rangeFormat: value => '€' + Number(value).toLocaleString('en-US')
|
|
315
319
|
});
|
|
320
|
+
|
|
321
|
+
zidanField('#delivery', {
|
|
322
|
+
rangeBubbleMode: 'active', // 'always' | 'active' | 'never'
|
|
323
|
+
rangeBubblePosition: 'bottom', // 'top' | 'bottom'
|
|
324
|
+
rangeFill: false, // neutral track, no progress colour
|
|
325
|
+
rangeTicks: '0,10,20,30', // count, array, JSON or comma list
|
|
326
|
+
rangeTickLabels: true,
|
|
327
|
+
rangeMinLabel: 'Low',
|
|
328
|
+
rangeMaxLabel: 'High'
|
|
329
|
+
});
|
|
316
330
|
```
|
|
317
331
|
|
|
318
332
|
The range keeps `input.value` native; only the visual chrome and bubble are added. Instance
|
|
319
333
|
properties `range`, `rangeBubble`, `rangeTicksEl` and `rangeScale` are exposed if you need to
|
|
320
334
|
re-render custom ticks.
|
|
321
335
|
|
|
336
|
+
Labeled ticks and the scale do not stack: when `rangeTickLabels` is on and the tick values
|
|
337
|
+
include both `min` and `max`, the scale row (`.zs-range-scale`) gets `zs-range-scale--hidden`
|
|
338
|
+
and the tick labels are the single endpoint readout. `rangeLabels` entries win over
|
|
339
|
+
`rangeFormat` for that value. Endpoint labels carry `zs-range-tick--start` / `--end` and the
|
|
340
|
+
bubble gets `zs-range-bubble--start` / `--end`, so both stay inside the track at 0 and max,
|
|
341
|
+
including in RTL. Without a scale row (`.zs-range--labels-no-scale`) the label height is
|
|
342
|
+
reserved so labels cannot overlap the next element.
|
|
343
|
+
|
|
344
|
+
Bubble behaviour is controlled by `rangeBubbleMode` (`always` / `active` / `never`) and
|
|
345
|
+
`rangeBubblePosition` (`top` / `bottom`), the coloured progress by `rangeFill`, and the scale
|
|
346
|
+
ends by `rangeMinLabel` / `rangeMaxLabel`. `rangeFill: false` keeps the neutral track but not
|
|
347
|
+
the gradient skin, and `rangeFormat` also feeds `aria-valuetext` so assistive tech reads the
|
|
348
|
+
formatted value.
|
|
349
|
+
|
|
322
350
|
## Date & time pickers
|
|
323
351
|
|
|
324
352
|
| JS option | Data attribute | Type | Default | Notes |
|
|
@@ -495,7 +523,7 @@ Callbacks: `onUploadStart`, `onUploadProgress`, `onUploadSuccess` / `onUpload`,
|
|
|
495
523
|
| `options` | — | Array of strings or `{value,label,disabled,group}`. |
|
|
496
524
|
| `suggestions` | — | Tags suggestions. |
|
|
497
525
|
| `value` | — | Initial value(s). |
|
|
498
|
-
| `label` | `data-zidan-label` | Floating label text. |
|
|
526
|
+
| `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()`. |
|
|
499
527
|
| `placeholder` | `data-zidan-placeholder` | Trigger placeholder. |
|
|
500
528
|
|
|
501
529
|
### Behaviour
|
|
@@ -503,7 +531,7 @@ Callbacks: `onUploadStart`, `onUploadProgress`, `onUploadSuccess` / `onUpload`,
|
|
|
503
531
|
| Option | Data attribute | Default | Description |
|
|
504
532
|
| --- | --- | --- | --- |
|
|
505
533
|
| `multiple` | `data-zidan-multiple` | from `multiple` | Multi-select. |
|
|
506
|
-
| `searchable` | `data-zidan-searchable` | `true` except plain select | Type-to-filter. |
|
|
534
|
+
| `searchable` | `data-zidan-searchable` | `true` except plain select | Type-to-filter. With `searchable: false` in `select` mode the text field is `readOnly`, so typing can never filter or hide the list — open it with a click, `Space`, `Enter` or `↓`. |
|
|
507
535
|
| `clearable` | `data-zidan-clearable` | `false` | Clear button. |
|
|
508
536
|
| `closeOnSelect` | — | single: `true` | Close after choosing. |
|
|
509
537
|
| `maxDropdownHeight` | — | `280` | Listbox max height in px. |
|
|
@@ -518,6 +546,15 @@ Callbacks: `onUploadStart`, `onUploadProgress`, `onUploadSuccess` / `onUpload`,
|
|
|
518
546
|
| --- | --- | --- |
|
|
519
547
|
| `fetchOptions(query, signal, context)` | — | Return an array of items, or a page `{ items, hasMore }` (or `{ items, total }`). `signal` aborts stale requests; `context` is `{ page, pageSize, append, instance }`. |
|
|
520
548
|
| `fetchPageSize` | `0` | Page size handed to `fetchOptions`. `0` keeps the legacy single-request behaviour. |
|
|
549
|
+
| `fetchUrl` | `null` | **Declarative AJAX.** GET this URL and the select builds its own `fetchOptions` — no JavaScript needed. Attribute: `data-zidan-fetch-url`. |
|
|
550
|
+
| `fetchQueryParam` | `'q'` | Query-string parameter that receives the search term (`''` omits it). |
|
|
551
|
+
| `fetchPageParam` | `'page'` | 1-based page number sent with every request (`''` omits it). |
|
|
552
|
+
| `fetchSkipParam` | `null` | Send `skip = page × pageSize` instead of `fetchPageParam`, for APIs that page by offset (dummyjson, Laravel, many REST APIs). |
|
|
553
|
+
| `fetchPageSizeParam` | `'limit'` | Parameter that receives `fetchPageSize`. |
|
|
554
|
+
| `fetchItemsPath` | `null` | Dot path to the array of rows in the JSON body (`products`, `data.items`). Without it the plugin looks for `items`, `data`, `results`, `options`, `rows`, `products` or `records`. |
|
|
555
|
+
| `fetchTotalPath` | `null` | Dot path to the total row count; with `fetchPageSize` it decides `hasMore`. Falls back to a top-level `total`. |
|
|
556
|
+
| `fetchHasMorePath` | `null` | Dot path to a boolean instead of a count. |
|
|
557
|
+
| `fetchMethod`, `fetchHeaders`, `fetchCredentials` | `'GET'`, `null`, `'same-origin'` | Request tuning for `fetchUrl` (JavaScript only). |
|
|
521
558
|
| `autoLoadMore` | `true` | Scrolling near the dropdown bottom fetches the next page automatically. |
|
|
522
559
|
| `loadMoreText` | `Load more` | Label of the footer button rendered while `hasMore` is true. |
|
|
523
560
|
| `cacheResults` | `true` | Cache pages per query + page. Clear with `select.clearCache()`. |
|
|
@@ -560,6 +597,29 @@ failures emit the usual `zidan:error`.
|
|
|
560
597
|
|
|
561
598
|
The cache size is global: `ZidanSelect.cacheLimit = 50` pages (least-recently-used eviction).
|
|
562
599
|
|
|
600
|
+
### AJAX from markup only
|
|
601
|
+
|
|
602
|
+
One URL is enough to turn a combobox into a remote search. The plugin sends the query, page
|
|
603
|
+
and page size, reads the rows out of the JSON, and keeps every other behaviour (debounce,
|
|
604
|
+
abort, cache, load-more, errors) identical to a hand-written `fetchOptions`.
|
|
605
|
+
|
|
606
|
+
```html
|
|
607
|
+
<select id="product" name="product"
|
|
608
|
+
data-zidan-select="combobox"
|
|
609
|
+
data-zidan-fetch-url="/api/products/search"
|
|
610
|
+
data-zidan-fetch-items-path="data.items"
|
|
611
|
+
data-zidan-fetch-total-path="data.total"
|
|
612
|
+
data-zidan-fetch-skip-param="skip"
|
|
613
|
+
data-zidan-fetch-page-size="20">
|
|
614
|
+
</select>
|
|
615
|
+
```
|
|
616
|
+
|
|
617
|
+
That markup calls `GET /api/products/search?q=…&limit=20&skip=0`, then `skip=20` for the next
|
|
618
|
+
page, and stops when `skip + limit >= data.total`. Rows map automatically: `value` / `label`, or
|
|
619
|
+
`id` / `slug` / `code` for the value and `name` / `title` / `full_name` for the label. A live page
|
|
620
|
+
with both modes, against a real API and a static JSON file, ships as
|
|
621
|
+
[`ajax.html`](https://akhtar1985.github.io/zidan-select/ajax.html).
|
|
622
|
+
|
|
563
623
|
### Tags
|
|
564
624
|
|
|
565
625
|
| Option | Data attribute | Default |
|
|
@@ -573,6 +633,11 @@ The cache size is global: `ZidanSelect.cacheLimit = 50` pages (least-recently-us
|
|
|
573
633
|
| `commitOnTab` / `commitOnBlur` | — | `false` |
|
|
574
634
|
| `valueDelimiter` | — | `,` |
|
|
575
635
|
|
|
636
|
+
With `allowFreeText: false` a tag you type must match an option or a `suggestions` entry by
|
|
637
|
+
value or label (`caseSensitive` respected). Anything else is rejected: no tag is added and the
|
|
638
|
+
control shows `"…" is not in the list.` through the tag error slot. Leave the option at its
|
|
639
|
+
`true` default for free-form tags.
|
|
640
|
+
|
|
576
641
|
### Rendering hooks
|
|
577
642
|
|
|
578
643
|
| Option | Signature |
|
|
@@ -717,7 +782,7 @@ to any field that should span the row) rather than putting it on a single field.
|
|
|
717
782
|
| `getValue()` | Text/textarea value, checked value, radio value or selected files. |
|
|
718
783
|
| `setValue(v)` | Writes to the native control and re-renders. |
|
|
719
784
|
| `update()` / `refresh()` | Re-read native state (checked, disabled, validity, value). |
|
|
720
|
-
| `setValidation('valid'\|'invalid'\|null)` | Mirrors state to classes and `aria-invalid`. |
|
|
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. |
|
|
721
786
|
| `getValidation()` | Current validation state. |
|
|
722
787
|
| `setTheme(name)`, `setFramework(name)`, `setLayout(name)` | Scoped restyling. |
|
|
723
788
|
| `destroy()` | Restores the original DOM and removes every listener. |
|
package/docs/validation.md
CHANGED
|
@@ -29,6 +29,14 @@ It clears the state on `input`/`change` once validity passes, on `form.reset()`,
|
|
|
29
29
|
`setValidation(null)` is called. `data-zidan-validation="invalid"` forces the state without
|
|
30
30
|
native validity.
|
|
31
31
|
|
|
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.
|
|
39
|
+
|
|
32
40
|
## Built-in rules (written into native validity)
|
|
33
41
|
|
|
34
42
|
These rules call `input.setCustomValidity(message)`, so `form.checkValidity()`,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zidan-select",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.0",
|
|
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",
|
|
@@ -101,7 +101,10 @@
|
|
|
101
101
|
"build": "node scripts/build.mjs",
|
|
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",
|
|
106
|
+
"release": "node scripts/release.mjs",
|
|
107
|
+
"search": "node scripts/exa-search.mjs"
|
|
105
108
|
},
|
|
106
109
|
"engines": {
|
|
107
110
|
"node": ">=18"
|
|
@@ -111,6 +114,7 @@
|
|
|
111
114
|
},
|
|
112
115
|
"devDependencies": {
|
|
113
116
|
"esbuild": "^0.21.5",
|
|
117
|
+
"exa-js": "2.29.0",
|
|
114
118
|
"jsdom": "^24.1.3",
|
|
115
119
|
"typescript": "^5.9.3"
|
|
116
120
|
}
|