@human-kit/ui 1.4.0 → 1.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (26) hide show
  1. package/dist/autocomplete/status/autocomplete-status.svelte +1 -3
  2. package/dist/button/root/button-root.svelte +5 -3
  3. package/dist/clock/wheel-column/clock-wheel-column.svelte +3 -7
  4. package/dist/combobox/status/combobox-status.svelte +1 -3
  5. package/dist/datepicker/popover/date-picker-popover.svelte +1 -0
  6. package/dist/datepicker/root/context.d.ts +6 -0
  7. package/dist/datepicker/root/date-picker-root.svelte +5 -0
  8. package/dist/daterangepicker/popover/date-range-picker-popover.svelte +1 -0
  9. package/dist/daterangepicker/root/context.d.ts +6 -0
  10. package/dist/daterangepicker/root/date-range-picker-root.svelte +5 -0
  11. package/dist/dropzone/dropzone.svelte +2 -5
  12. package/dist/popover/content/README.md +1 -0
  13. package/dist/popover/content/popover-content.svelte +7 -1
  14. package/dist/popover/content/popover-content.svelte.d.ts +5 -0
  15. package/dist/primitives/visually-hidden.d.ts +15 -0
  16. package/dist/primitives/visually-hidden.js +15 -0
  17. package/dist/table/column-resizer/table-column-resizer.svelte +1 -1
  18. package/dist/table/root/table-root.svelte +1 -1
  19. package/dist/timepicker/popover/time-picker-popover.svelte +1 -0
  20. package/dist/timepicker/root/context.d.ts +6 -0
  21. package/dist/timepicker/root/time-picker-root.svelte +3 -0
  22. package/dist/toast/viewport/toast-viewport.svelte +1 -1
  23. package/dist/transfer-list/status/transfer-list-status.svelte +1 -3
  24. package/package.json +1 -1
  25. package/dist/table/utils/visually-hidden-style.d.ts +0 -1
  26. package/dist/table/utils/visually-hidden-style.js +0 -1
@@ -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');
@@ -79,6 +79,7 @@
79
79
  >
80
80
  <Popover.Content
81
81
  id={dialogId}
82
+ anchorRef={datePicker.fieldRef}
82
83
  class={className}
83
84
  aria-label={resolvedAriaLabel}
84
85
  onmousedown={composeEventHandlers(handlePointerDown, onMouseDownExternal ?? undefined)}
@@ -19,6 +19,12 @@ export type DatePickerContext = {
19
19
  maxValue: DatePickerDateValue | undefined;
20
20
  triggerRef: HTMLElement | null;
21
21
  setTriggerRef: (element: HTMLElement | null) => void;
22
+ /**
23
+ * What the popover is placed against: the root, which holds the whole field. The trigger is
24
+ * only a part of it, and a popover anchored to a small button inside a field landed a pixel
25
+ * under the field's own bottom edge, its border running beside the field's.
26
+ */
27
+ fieldRef: HTMLElement | null;
22
28
  setFocusVisible: (visible: boolean) => void;
23
29
  syncFocusWithin: () => void;
24
30
  setActiveSegment: (segment: Exclude<DatePickerSegmentType, 'literal'> | null) => void;
@@ -90,6 +90,7 @@
90
90
  const instanceId = untrack(() => id) ?? generatedInstanceId;
91
91
 
92
92
  let triggerRef: HTMLElement | null = $state(null);
93
+ let fieldRef: HTMLDivElement | null = $state(null);
93
94
  let openInternal = $state((() => defaultOpen)());
94
95
  let focusVisible = $state(false);
95
96
  let focusWithin = $state(false);
@@ -419,6 +420,9 @@
419
420
  return triggerRef;
420
421
  },
421
422
  setTriggerRef,
423
+ get fieldRef() {
424
+ return fieldRef;
425
+ },
422
426
  setFocusVisible,
423
427
  syncFocusWithin,
424
428
  setActiveSegment,
@@ -453,6 +457,7 @@
453
457
  </script>
454
458
 
455
459
  <div
460
+ bind:this={fieldRef}
456
461
  id={instanceId}
457
462
  class={className}
458
463
  role={ariaLabel ? 'group' : undefined}
@@ -82,6 +82,7 @@
82
82
  >
83
83
  <Popover.Content
84
84
  id={dialogId}
85
+ anchorRef={dateRangePicker.fieldRef}
85
86
  class={className}
86
87
  aria-label={resolvedAriaLabel}
87
88
  onmousedown={composeEventHandlers(handlePointerDown, onMouseDownExternal ?? undefined)}
@@ -29,6 +29,12 @@ export type DateRangePickerContext = {
29
29
  maxValue: DatePickerDateValue | undefined;
30
30
  triggerRef: HTMLElement | null;
31
31
  setTriggerRef: (element: HTMLElement | null) => void;
32
+ /**
33
+ * What the popover is placed against: the root, which holds the whole field. The trigger is
34
+ * only a part of it, and a popover anchored to a small button inside a field landed a pixel
35
+ * under the field's own bottom edge, its border running beside the field's.
36
+ */
37
+ fieldRef: HTMLElement | null;
32
38
  setFocusVisible: (visible: boolean) => void;
33
39
  syncFocusWithin: () => void;
34
40
  setActiveSegment: (part: DateRangePickerRangePart, segment: Exclude<DatePickerSegmentType, 'literal'> | null) => void;
@@ -97,6 +97,7 @@
97
97
  const instanceId = untrack(() => id) ?? generatedInstanceId;
98
98
 
99
99
  let triggerRef: HTMLElement | null = $state(null);
100
+ let fieldRef: HTMLDivElement | null = $state(null);
100
101
  let openInternal = $state((() => defaultOpen)());
101
102
  let focusVisible = $state(false);
102
103
  let focusWithin = $state(false);
@@ -664,6 +665,9 @@
664
665
  return triggerRef;
665
666
  },
666
667
  setTriggerRef,
668
+ get fieldRef() {
669
+ return fieldRef;
670
+ },
667
671
  setFocusVisible,
668
672
  syncFocusWithin,
669
673
  setActiveSegment,
@@ -698,6 +702,7 @@
698
702
  </script>
699
703
 
700
704
  <div
705
+ bind:this={fieldRef}
701
706
  id={instanceId}
702
707
  class={className}
703
708
  role={ariaLabel ? 'group' : undefined}
@@ -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
  >
@@ -13,6 +13,7 @@ Description: Floating panel rendered in a portal. Supports context mode (`Popove
13
13
  | `placement` | `ExtendedPlacement` | `'bottom'` | Preferred floating placement. |
14
14
  | `shouldFlip` | `boolean` | `true` | Enables automatic fallback placement when space is limited. |
15
15
  | `boundaryElement` | `Element \| null` | `null` | Optional boundary element for positioning constraints. |
16
+ | `anchorRef` | `HTMLElement \| null` | `null` | Element the panel is placed against, if not the trigger (a picker's field). |
16
17
  | `children` | `Snippet` | `undefined` | Rendered popover panel content. |
17
18
  | `class` | `string` | `''` | CSS class names for the panel element. |
18
19
  | `nonModal` | `boolean` | `false` | Disables modal behaviors (focus trap, scroll lock, outside aria hiding). |
@@ -37,6 +37,11 @@
37
37
  shouldFlip?: boolean;
38
38
  /** The element that gives the limits of the position. */
39
39
  boundaryElement?: Element | null;
40
+ /**
41
+ * The element the panel is placed against, when it is not the trigger: a picker's whole field,
42
+ * whose button is only a small part of it. The trigger still owns the focus and the open state.
43
+ */
44
+ anchorRef?: HTMLElement | null;
40
45
  /** The content of the popover. */
41
46
  children?: Snippet;
42
47
  /** The CSS class names of the popover container. */
@@ -70,6 +75,7 @@
70
75
  placement = 'bottom',
71
76
  shouldFlip = true,
72
77
  boundaryElement = null,
78
+ anchorRef = null,
73
79
  children,
74
80
  class: className = '',
75
81
  nonModal = false,
@@ -332,7 +338,7 @@
332
338
  data-exiting={presence.isExiting || undefined}
333
339
  data-placement={resolvedPlacement}
334
340
  use:floating={{
335
- anchor: triggerRef,
341
+ anchor: anchorRef ?? triggerRef,
336
342
  offset,
337
343
  placement,
338
344
  shouldFlip,
@@ -16,6 +16,11 @@ type PopoverContentProps = {
16
16
  shouldFlip?: boolean;
17
17
  /** The element that gives the limits of the position. */
18
18
  boundaryElement?: Element | null;
19
+ /**
20
+ * The element the panel is placed against, when it is not the trigger: a picker's whole field,
21
+ * whose button is only a small part of it. The trigger still owns the focus and the open state.
22
+ */
23
+ anchorRef?: HTMLElement | null;
19
24
  /** The content of the popover. */
20
25
  children?: Snippet;
21
26
  /** The CSS class names of the popover container. */
@@ -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,
@@ -73,6 +73,7 @@
73
73
  >
74
74
  <Popover.Content
75
75
  id={dialogId}
76
+ anchorRef={timePicker.fieldRef}
76
77
  class={className}
77
78
  aria-label={ariaLabel}
78
79
  onmousedown={composeEventHandlers(handlePointerDown, onMouseDownExternal ?? undefined)}
@@ -18,6 +18,12 @@ export type TimePickerContext = {
18
18
  triggerRef: HTMLElement | null;
19
19
  activeSegment: Exclude<TimePickerSegmentType, 'literal'> | null;
20
20
  setTriggerRef: (element: HTMLElement | null) => void;
21
+ /**
22
+ * What the popover is placed against: the root, which holds the whole field. The trigger is
23
+ * only a part of it, and a popover anchored to a small button inside a field landed a pixel
24
+ * under the field's own bottom edge, its border running beside the field's.
25
+ */
26
+ fieldRef: HTMLElement | null;
21
27
  setFocusVisible: (visible: boolean) => void;
22
28
  syncFocusWithin: () => void;
23
29
  setActiveSegment: (segment: Exclude<TimePickerSegmentType, 'literal'> | null) => void;
@@ -399,6 +399,9 @@
399
399
  return activeSegment;
400
400
  },
401
401
  setTriggerRef,
402
+ get fieldRef() {
403
+ return rootRef;
404
+ },
402
405
  setFocusVisible,
403
406
  syncFocusWithin,
404
407
  setActiveSegment,
@@ -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.2",
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;';