svelte-ant-design 0.4.0 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -18,7 +18,7 @@ Ant Design.
18
18
 
19
19
  ## Status
20
20
 
21
- Version `0.4.0`. Available components: `Button`, `Checkbox` (with `CheckboxGroup`), `Input` (with `InputTextArea`, `InputPassword`, `InputSearch` and `InputOTP`), `Switch`. More components are planned.
21
+ Version `0.4.1`. Available components: `Button`, `Checkbox` (with `CheckboxGroup`), `Input` (with `InputTextArea`, `InputPassword`, `InputSearch` and `InputOTP`), `Switch`. More components are planned.
22
22
 
23
23
  ## Installation
24
24
 
@@ -86,13 +86,20 @@ npm install
86
86
  npm run dev # documentation site (SvelteKit, in docs/), with live reload
87
87
  npm test # unit and accessibility tests of the library and of the site content (Vitest)
88
88
  npm run test:coverage
89
- npm run test:e2e # library tests in a real browser (Playwright)
89
+ npm run test:e2e # library tests in Chromium, Firefox and WebKit (Playwright)
90
90
  npm run check # svelte-check (type checking of the library)
91
91
  npm run check:docs # svelte-check of the documentation site
92
92
  npm run lint # ESLint
93
93
  npm run package # build dist/ with svelte-package
94
94
  ```
95
95
 
96
+ The browser tests run in Chromium, Firefox and WebKit. Install them once, and again after Playwright is
97
+ updated (the builds belong to a version of Playwright):
98
+
99
+ ```sh
100
+ npx playwright install chromium firefox webkit # on Linux add --with-deps for the system packages
101
+ ```
102
+
96
103
  The documentation site lives in `docs/` and imports the library from `src/lib`, so its examples
97
104
  always show the code in the repository. To build it the way GitHub Pages serves it and test the result:
98
105
 
@@ -315,6 +315,33 @@
315
315
  --_bar: var(--ads-checkbox-disabled-check-color);
316
316
  }
317
317
 
318
+ /*
319
+ * Forced colors (Windows High Contrast): the system replaces the author's backgrounds, and the bar of an
320
+ * indeterminate box is a background, so it would vanish and the box would look unchecked. The bar and the
321
+ * disabled parts take system colors. The check mark is a border and keeps showing.
322
+ */
323
+ @media (forced-colors: active) {
324
+ .ads-checkbox-indeterminate .ads-checkbox-icon::after {
325
+ background-color: ButtonText;
326
+ }
327
+
328
+ .ads-checkbox-disabled {
329
+ color: GrayText;
330
+ }
331
+
332
+ .ads-checkbox-disabled .ads-checkbox-icon {
333
+ border-color: GrayText;
334
+ }
335
+
336
+ .ads-checkbox-disabled .ads-checkbox-icon::after {
337
+ border-color: GrayText;
338
+ }
339
+
340
+ .ads-checkbox-disabled.ads-checkbox-indeterminate .ads-checkbox-icon::after {
341
+ background-color: GrayText;
342
+ }
343
+ }
344
+
318
345
  @media (prefers-reduced-motion: reduce) {
319
346
  .ads-checkbox-icon,
320
347
  .ads-checkbox-icon::after {
@@ -156,6 +156,7 @@ It darkens the unchecked border (`#737373`) and the checked hover fill (`#0958d9
156
156
  - A group has `role="group"`; name it with `aria-label` or `aria-labelledby`, or wrap it in a `<fieldset>` with a `<legend>`.
157
157
  - A visible `:focus-visible` outline from the design tokens around the box, at least 3:1 against the page.
158
158
  - The border, the check mark, the bar and the focus ring keep at least 3:1 contrast, and the label text 4.5:1, in every state: in the dark theme, and in the light theme when `tokens-accessible.css` is imported (see Colors).
159
+ - In forced-colors modes such as Windows High Contrast the bar of an indeterminate box is drawn in the text color, so it still differs from an unchecked box, and a disabled checkbox uses the disabled color.
159
160
  - Under `prefers-reduced-motion: reduce` the transitions are disabled.
160
161
  - Positions use logical properties, so the checkbox mirrors in right-to-left layouts. Toggling `checked`, `indeterminate` or `disabled` never changes the size of the control or moves its neighbours.
161
162
 
@@ -31,7 +31,9 @@ import 'svelte-ant-design/tokens.css';
31
31
  A field has no label of its own: name it with an external `<label for>` (and the `id` of the field), `aria-label`
32
32
  or `aria-labelledby`.
33
33
 
34
- `onchange` is called on every edit with the new text and the native `input` event, as `onChange` in React:
34
+ `onchange` is called on every edit with the new text and the event of the edit, as `onChange` in React: the native
35
+ `input` event, or `compositionend` when a browser (Firefox, for one) ends an IME composition before its last `input`
36
+ event. The text and the number of calls are the same either way.
35
37
 
36
38
  ```svelte
37
39
  <Input onchange={(value, event) => console.log(value, event.type)} aria-label="Query" />
@@ -79,7 +79,10 @@ interface FieldProps {
79
79
  };
80
80
  /** Character counting configuration (a soft limit, a custom count, cutting). */
81
81
  count?: CountConfig;
82
- /** Called once per user edit, with the new text and the native `input` event. */
82
+ /**
83
+ * Called once per user edit, with the new text and the event of the edit: the native `input` event, or
84
+ * `compositionend` when the browser ends an IME composition before its last `input` event (Firefox does).
85
+ */
83
86
  onchange?: (value: string, event: Event) => void;
84
87
  /** Called when the clear button emptied the text. */
85
88
  onclear?: (event: MouseEvent) => void;
@@ -108,6 +108,7 @@ theme needs no extra file.
108
108
  - A loading switch is not natively disabled: it keeps keyboard focus when loading starts, exposes `aria-busy="true"` and `aria-disabled="true"`, and ignores clicks, Enter and Space. A disabled switch is natively disabled.
109
109
  - A visible `:focus-visible` outline from the design tokens, at least 3:1 against the page.
110
110
  - The track and the handle keep at least 3:1 contrast, and the on/off text 4.5:1, in every state: in the dark theme, and in the light theme when `tokens-accessible.css` is imported (see Colors). For that the accessible light set has a darker off track and does not dim a loading switch.
111
+ - In forced-colors modes such as Windows High Contrast the switch is drawn with system colors: an outlined track when off, a `Highlight` track when on, a disabled switch in the disabled color.
111
112
  - Under `prefers-reduced-motion: reduce`, transitions are disabled and the spinner turns more slowly.
112
113
  - Positions use logical properties, so the switch mirrors in right-to-left layouts.
113
114
 
@@ -302,6 +302,75 @@
302
302
  }
303
303
  }
304
304
 
305
+ /*
306
+ * Forced colors (Windows High Contrast): the system replaces the author's backgrounds, and the track and the
307
+ * handle are both backgrounds, so the switch would vanish. The state is drawn with system colors instead: an
308
+ * outlined track and a handle in the text color when off, a Highlight track and a HighlightText handle when on.
309
+ * Opacity is dropped, so the disabled color alone says that a switch is unavailable. The 1px border is
310
+ * compensated in the handle offsets, so the handle keeps its place and the size of the switch does not change.
311
+ */
312
+ @media (forced-colors: active) {
313
+ .ads-switch {
314
+ --_track: Canvas;
315
+ --_track-hover: Canvas;
316
+ --_track-active: Canvas;
317
+
318
+ border: 1px solid ButtonText;
319
+ color: ButtonText;
320
+ opacity: 1;
321
+ }
322
+
323
+ .ads-switch-checked {
324
+ --_track: Highlight;
325
+ --_track-hover: Highlight;
326
+ --_track-active: Highlight;
327
+
328
+ border-color: Highlight;
329
+ color: HighlightText;
330
+ }
331
+
332
+ /* Chromium puts a Canvas backplate behind forced text; white text on the Highlight track would vanish on it. */
333
+ .ads-switch-content {
334
+ forced-color-adjust: none;
335
+ }
336
+
337
+ .ads-switch-indicator {
338
+ top: calc(var(--ads-switch-padding) - 1px);
339
+ inset-inline-start: calc(var(--ads-switch-padding) - 1px);
340
+ background-color: ButtonText;
341
+ box-shadow: none;
342
+ }
343
+
344
+ .ads-switch-checked .ads-switch-indicator {
345
+ inset-inline-start: calc(100% - var(--_handle) - var(--ads-switch-padding) + 1px);
346
+ background-color: HighlightText;
347
+ }
348
+
349
+ .ads-switch-disabled,
350
+ .ads-switch-loading {
351
+ opacity: 1;
352
+ }
353
+
354
+ .ads-switch-disabled {
355
+ --_track: Canvas;
356
+
357
+ border-color: GrayText;
358
+ color: GrayText;
359
+ }
360
+
361
+ .ads-switch-disabled .ads-switch-indicator {
362
+ background-color: GrayText;
363
+ }
364
+
365
+ .ads-switch-disabled.ads-switch-checked {
366
+ --_track: GrayText;
367
+ }
368
+
369
+ .ads-switch-disabled.ads-switch-checked .ads-switch-indicator {
370
+ background-color: Canvas;
371
+ }
372
+ }
373
+
305
374
  /* Honour the OS "reduce motion" setting: no transitions, a slower spinner. */
306
375
  @media (prefers-reduced-motion: reduce) {
307
376
  .ads-switch,
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export declare const VERSION = "0.4.0";
1
+ export declare const VERSION = "0.4.1";
2
2
  export { default as Button } from './Button/Button.svelte';
3
3
  export { default as Switch } from './Switch/Switch.svelte';
4
4
  export { default as Checkbox } from './Checkbox/Checkbox.svelte';
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // Public API of the library. Components are re-exported from here.
2
- export const VERSION = '0.4.0';
2
+ export const VERSION = '0.4.1';
3
3
  export { default as Button } from './Button/Button.svelte';
4
4
  export { default as Switch } from './Switch/Switch.svelte';
5
5
  export { default as Checkbox } from './Checkbox/Checkbox.svelte';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svelte-ant-design",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "description": "An independent UI component library for Svelte 5, inspired by Ant Design.",
5
5
  "license": "MIT",
6
6
  "repository": {