@human-kit/ui 1.4.1 → 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.
@@ -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}
@@ -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. */
@@ -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,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@human-kit/ui",
3
- "version": "1.4.1",
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>",