@human-kit/ui 1.4.0 → 1.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.
@@ -1,5 +1,6 @@
1
1
  <script lang="ts">
2
2
  import { useAutocompleteContext } from '../root/context';
3
+ import { visuallyHiddenStyle } from '../../primitives/visually-hidden';
3
4
 
4
5
  /**
5
6
  * Autocomplete.Status - Visually-hidden live region that announces the number
@@ -15,9 +16,6 @@
15
16
  count === 0 ? 'No results available' : `${count} result${count === 1 ? '' : 's'} available`
16
17
  }: AutocompleteStatusProps = $props();
17
18
 
18
- const visuallyHiddenStyle =
19
- 'position:fixed;top:0;left:0;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0;';
20
-
21
19
  const ctx = useAutocompleteContext();
22
20
  const message = $derived(formatMessage(ctx.visibleCount));
23
21
  </script>
@@ -7,6 +7,7 @@
7
7
  } from '../../primitives/input-modality';
8
8
  import { watchFocusVisible } from '../../primitives/focus-visible.svelte';
9
9
  import { cn } from '../../utils/cn';
10
+ import { visuallyHiddenStyle } from '../../primitives/visually-hidden';
10
11
 
11
12
  export type ButtonRenderState = {
12
13
  hovered: boolean;
@@ -429,13 +430,14 @@
429
430
  <!--
430
431
  The polite live region is a sibling of the button, not a child: inside the button its text
431
432
  would be concatenated into the button's computed accessible name ("Saving Saving, pending").
432
- Visually hidden via inline styles because the library is headless.
433
+ Visually hidden with the shared fixed-position style: an absolute one inside a scroll
434
+ container made Chrome promote the sticky content around it to its own layer, which blurred
435
+ its text.
433
436
  -->
434
437
  <span
435
438
  data-button-live-region="true"
436
439
  role="status"
437
440
  aria-live="polite"
438
441
  aria-atomic="true"
439
- style="position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0;"
440
- >{pendingAnnouncement}</span
442
+ style={visuallyHiddenStyle}>{pendingAnnouncement}</span
441
443
  >
@@ -2,6 +2,7 @@
2
2
  import type { Snippet } from 'svelte';
3
3
  import type { HTMLAttributes } from 'svelte/elements';
4
4
  import { resolveLocalizedString } from '../../internal/localized-strings';
5
+ import { visuallyHiddenStyle } from '../../primitives/visually-hidden';
5
6
  import { useClockContext, type ClockEditableSegmentType } from '../root/context';
6
7
  import TimePickerWheelItem from '../wheel-item/clock-wheel-item.svelte';
7
8
  import { useWheelScroll, type WheelScrollBehavior } from '../hooks/use-wheel-scroll.svelte';
@@ -506,18 +507,13 @@
506
507
  >
507
508
  <div data-wheel-spacer="top" style={`height:${spacerHeight}px`}></div>
508
509
  <!--
509
- Visually-hidden live region using inline styles so the headless library
510
+ Visually-hidden live region using the shared inline style so the headless library
510
511
  does not depend on an external `sr-only` utility class (e.g. Tailwind).
511
512
  Kept in addition to aria-valuetext: valuetext changes are only announced
512
513
  while the spinbutton has DOM focus, whereas this also covers pointer and
513
514
  touch scrolling without focus.
514
515
  -->
515
- <span
516
- role="status"
517
- aria-live="polite"
518
- style="position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;border:0"
519
- >{valueText}</span
520
- >
516
+ <span role="status" aria-live="polite" style={visuallyHiddenStyle}>{valueText}</span>
521
517
  {#each options as option, index (option.value)}
522
518
  {#if children}
523
519
  {@render children(option, selectedValue === option.value)}
@@ -3,6 +3,7 @@
3
3
  import { resolveLocalizedString } from '../../internal/localized-strings';
4
4
  import { useLocaleContextOptional } from '../../locale-provider/context';
5
5
  import { useComboBoxContext } from '../root/context';
6
+ import { visuallyHiddenStyle } from '../../primitives/visually-hidden';
6
7
 
7
8
  /**
8
9
  * ComboBox.Status - Visually-hidden live region that announces the number of
@@ -25,9 +26,6 @@
25
26
 
26
27
  const ctx = useComboBoxContext();
27
28
 
28
- const visuallyHiddenStyle =
29
- 'position:fixed;top:0;left:0;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0;';
30
-
31
29
  const defaultMessage = $derived.by(() => {
32
30
  const count = ctx.visibleCount;
33
31
  if (count === 0) return resolveLocalizedString($localeStore, 'combobox.noResults');
@@ -2,6 +2,7 @@
2
2
  import { untrack, type Snippet } from 'svelte';
3
3
  import type { HTMLButtonAttributes } from 'svelte/elements';
4
4
  import { shouldShowFocusVisible, trackInteractionModality } from '../primitives/input-modality';
5
+ import { visuallyHiddenStyle } from '../primitives/visually-hidden';
5
6
  import type { ClassValue } from '../utils/cn';
6
7
  import { composeEventHandlers } from '../utils/compose-event-handlers';
7
8
 
@@ -315,10 +316,6 @@
315
316
  onchange={handleInputChange}
316
317
  />
317
318
 
318
- <span
319
- role="status"
320
- aria-live="polite"
321
- aria-atomic="true"
322
- style="position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0;"
319
+ <span role="status" aria-live="polite" aria-atomic="true" style={visuallyHiddenStyle}
323
320
  >{announcement}</span
324
321
  >
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Inline style for content that only assistive technology reads, such as a live region.
3
+ * Inline, because the library is headless and must not depend on an `sr-only` class.
4
+ *
5
+ * `position: fixed`, not `absolute`: an absolutely positioned element inside a scroll container
6
+ * that is not itself positioned is laid out against an ancestor outside the scroller. While the
7
+ * container scrolls, Chrome then promotes the content around it (a sticky header, say) to its own
8
+ * compositing layer to keep the element in place, and that layer drops subpixel anti-aliasing
9
+ * from its text. A fixed element is laid out against the viewport and never escapes a scroller.
10
+ *
11
+ * Native form controls that stand in for a custom one (a hidden `<input>` or `<select>`) keep
12
+ * their own absolute style: the browser anchors its validation bubble to them, so they have to
13
+ * stay where the visible control is.
14
+ */
15
+ export declare const visuallyHiddenStyle = "position:fixed;top:0;left:0;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0;";
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Inline style for content that only assistive technology reads, such as a live region.
3
+ * Inline, because the library is headless and must not depend on an `sr-only` class.
4
+ *
5
+ * `position: fixed`, not `absolute`: an absolutely positioned element inside a scroll container
6
+ * that is not itself positioned is laid out against an ancestor outside the scroller. While the
7
+ * container scrolls, Chrome then promotes the content around it (a sticky header, say) to its own
8
+ * compositing layer to keep the element in place, and that layer drops subpixel anti-aliasing
9
+ * from its text. A fixed element is laid out against the viewport and never escapes a scroller.
10
+ *
11
+ * Native form controls that stand in for a custom one (a hidden `<input>` or `<select>`) keep
12
+ * their own absolute style: the browser anchors its validation bubble to them, so they have to
13
+ * stay where the visible control is.
14
+ */
15
+ export const visuallyHiddenStyle = 'position:fixed;top:0;left:0;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0;';
@@ -10,7 +10,7 @@
10
10
  useTableContext
11
11
  } from '../root/context.svelte';
12
12
  import type { TableColumnResizerProps } from '../types.js';
13
- import { visuallyHiddenStyle } from '../utils/visually-hidden-style';
13
+ import { visuallyHiddenStyle } from '../../primitives/visually-hidden';
14
14
  import {
15
15
  shouldShowFocusVisible,
16
16
  trackInteractionModality
@@ -22,7 +22,7 @@
22
22
  trackInteractionModality
23
23
  } from '../../primitives/input-modality';
24
24
  import { watchFocusVisible } from '../../primitives/focus-visible.svelte';
25
- import { visuallyHiddenStyle } from '../utils/visually-hidden-style';
25
+ import { visuallyHiddenStyle } from '../../primitives/visually-hidden';
26
26
  import type { TableRootProps } from '../types.js';
27
27
  import {
28
28
  createTableContext,
@@ -8,7 +8,7 @@
8
8
  import { getFocusableElements } from '../../primitives/focus-trap';
9
9
  import { shouldShowFocusVisible } from '../../primitives/input-modality';
10
10
  import { SWIPE_IGNORE_ATTRIBUTE } from '../../primitives/swipe-gesture';
11
- import { visuallyHiddenStyle } from '../../table/utils/visually-hidden-style';
11
+ import { visuallyHiddenStyle } from '../../primitives/visually-hidden';
12
12
  import { useToastProviderContext } from '../provider/context';
13
13
  import type { ToastItem } from '../provider/toast-manager.svelte';
14
14
  import type { ToastViewportProps } from '../types.js';
@@ -4,6 +4,7 @@
4
4
  import { useLocaleContextOptional } from '../../locale-provider/context';
5
5
  import { useTransferListContext } from '../root/context';
6
6
  import type { TransferListMoveDetails } from '../root/types';
7
+ import { visuallyHiddenStyle } from '../../primitives/visually-hidden';
7
8
 
8
9
  /**
9
10
  * TransferList.Status - Visually-hidden live region that announces each move.
@@ -25,9 +26,6 @@
25
26
 
26
27
  const ctx = useTransferListContext('TransferList.Status');
27
28
 
28
- const visuallyHiddenStyle =
29
- 'position:fixed;top:0;left:0;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0;';
30
-
31
29
  const message = $derived.by(() => {
32
30
  const move = ctx.lastMove;
33
31
  if (!move) return '';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@human-kit/ui",
3
- "version": "1.4.0",
3
+ "version": "1.4.1",
4
4
  "description": "Accessible, typed UI components for Svelte 5 — shipped as native ESM with per-component subpath exports so bundlers only include what you import.",
5
5
  "license": "MIT",
6
6
  "author": "Agustin Delgado <agustindariodelgado@gmail.com>",
@@ -1 +0,0 @@
1
- export declare const visuallyHiddenStyle = "position:fixed;top:0;left:0;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0;";
@@ -1 +0,0 @@
1
- export const visuallyHiddenStyle = 'position:fixed;top:0;left:0;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0;';