@canonical/react-ds-global 0.48.0 → 0.50.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.
Files changed (54) hide show
  1. package/dist/esm/lib/_work_in_progress/Announcement/styles.css +4 -4
  2. package/dist/esm/lib/_work_in_progress/Label/styles.css +1 -7
  3. package/dist/esm/lib/component/Accordion/common/Item/styles.css +5 -6
  4. package/dist/esm/lib/component/Accordion/styles.css +3 -9
  5. package/dist/esm/lib/component/Breadcrumbs/common/Item/styles.css +6 -14
  6. package/dist/esm/lib/component/Breadcrumbs/styles.css +2 -9
  7. package/dist/esm/lib/component/Button/Button.js +28 -12
  8. package/dist/esm/lib/component/Button/Button.js.map +1 -1
  9. package/dist/esm/lib/component/Button/styles.css +48 -18
  10. package/dist/esm/lib/component/Card/common/Content/styles.css +4 -5
  11. package/dist/esm/lib/component/Card/common/Header/styles.css +1 -2
  12. package/dist/esm/lib/component/Card/styles.css +1 -2
  13. package/dist/esm/lib/component/ContextualMenu/common/Item/styles.css +6 -9
  14. package/dist/esm/lib/component/ContextualMenu/styles.css +6 -7
  15. package/dist/esm/lib/component/Icon/styles.css +3 -7
  16. package/dist/esm/lib/component/InlineCode/styles.css +2 -3
  17. package/dist/esm/lib/component/KeyboardKey/styles.css +6 -8
  18. package/dist/esm/lib/component/Tabs/common/Item/styles.css +1 -1
  19. package/dist/esm/lib/component/Tabs/styles.css +4 -8
  20. package/dist/esm/lib/component/Tile/common/Content/styles.css +2 -5
  21. package/dist/esm/lib/component/Tile/common/Header/styles.css +3 -6
  22. package/dist/esm/lib/component/Tile/styles.css +1 -5
  23. package/dist/esm/lib/component/Tooltip/Tooltip.js.map +1 -1
  24. package/dist/esm/lib/component/Tooltip/TooltipEngine.js +91 -15
  25. package/dist/esm/lib/component/Tooltip/TooltipEngine.js.map +1 -1
  26. package/dist/esm/lib/component/Tooltip/hooks/useTooltipState.js +89 -0
  27. package/dist/esm/lib/component/Tooltip/hooks/useTooltipState.js.map +1 -0
  28. package/dist/esm/lib/component/Tooltip/styles.css +151 -80
  29. package/dist/esm/lib/component/Tooltip/withTooltip.js +3 -3
  30. package/dist/esm/lib/group/KeyboardKeys/styles.css +1 -1
  31. package/dist/esm/lib/hooks/useWindowFitment/useWindowFitment.js +172 -173
  32. package/dist/esm/lib/hooks/useWindowFitment/useWindowFitment.js.map +1 -1
  33. package/dist/esm/lib/pattern/Modal/common/Content/styles.css +3 -6
  34. package/dist/esm/lib/pattern/Modal/common/Footer/styles.css +1 -1
  35. package/dist/esm/lib/pattern/Modal/common/Header/styles.css +3 -9
  36. package/dist/esm/lib/pattern/Modal/styles.css +14 -20
  37. package/dist/esm/lib/pattern/Timeline/common/Content/styles.css +1 -4
  38. package/dist/esm/lib/pattern/Timeline/common/Event/styles.css +6 -13
  39. package/dist/esm/lib/pattern/Timeline/styles.css +1 -4
  40. package/dist/types/lib/component/Button/Button.d.ts +4 -1
  41. package/dist/types/lib/component/Button/Button.d.ts.map +1 -1
  42. package/dist/types/lib/component/Button/types.d.ts +15 -4
  43. package/dist/types/lib/component/Button/types.d.ts.map +1 -1
  44. package/dist/types/lib/component/Tooltip/Tooltip.d.ts.map +1 -1
  45. package/dist/types/lib/component/Tooltip/TooltipEngine.d.ts +6 -4
  46. package/dist/types/lib/component/Tooltip/TooltipEngine.d.ts.map +1 -1
  47. package/dist/types/lib/component/Tooltip/hooks/useTooltipState.d.ts +17 -0
  48. package/dist/types/lib/component/Tooltip/hooks/useTooltipState.d.ts.map +1 -0
  49. package/dist/types/lib/component/Tooltip/types.d.ts +27 -2
  50. package/dist/types/lib/component/Tooltip/types.d.ts.map +1 -1
  51. package/dist/types/lib/component/Tooltip/withTooltip.d.ts +3 -3
  52. package/dist/types/lib/hooks/useWindowFitment/useWindowFitment.d.ts +22 -1
  53. package/dist/types/lib/hooks/useWindowFitment/useWindowFitment.d.ts.map +1 -1
  54. package/package.json +23 -14
@@ -8,8 +8,11 @@ import "./styles.css";
8
8
  *
9
9
  * `import { Button } from "@canonical/react-ds-global";`
10
10
  *
11
+ * Fragments: renders the button plus, when `loading` is controlled, a sibling
12
+ * status region, so the component has no single root element.
13
+ *
11
14
  * @implements ds:global.component.button
12
15
  */
13
- declare const Button: ({ id, className, children, style, importance, anticipation, variant, icon, loading, disabled, ...props }: Props) => React.ReactElement;
16
+ declare const Button: ({ id, className, children, style, importance, anticipation, variant, icon, loading, loadingLabel, disabled, onClick, ...props }: Props) => React.ReactElement;
14
17
  export default Button;
15
18
  //# sourceMappingURL=Button.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../../../../../src/lib/component/Button/Button.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AACpC,OAAO,cAAc,CAAC;AAItB;;;;;;;;GAQG;AACH,QAAA,MAAM,MAAM,6GAYT,KAAK,KAAG,KAAK,CAAC,YA2DhB,CAAC;eAEa,MAAM"}
1
+ {"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../../../../../src/lib/component/Button/Button.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AACpC,OAAO,cAAc,CAAC;AAItB;;;;;;;;;;;GAWG;AACH,QAAA,MAAM,MAAM,oIAcT,KAAK,KAAG,KAAK,CAAC,YAqFhB,CAAC;eAEa,MAAM"}
@@ -43,12 +43,23 @@ type OwnProps = {
43
43
  */
44
44
  icon?: IconName;
45
45
  /**
46
- * Whether the button is in a loading (busy) state. Replaces the leading icon
47
- * with a Spinner, marks the button `aria-busy`, and disables interaction so
48
- * the action cannot be triggered again while it is in flight.
49
- * @default false
46
+ * Whether the button is in a loading (busy) state. Overlays a Spinner,
47
+ * marks the button `aria-busy` and `aria-disabled`, and blocks activation
48
+ * (clicks and form submission) so the action cannot be triggered again
49
+ * while it is in flight. The button stays focusable, so keyboard focus is
50
+ * not lost when loading starts.
51
+ *
52
+ * Passing `loading` (even as `false`) also renders a visually hidden
53
+ * `role="status"` region after the button that announces `loadingLabel`
54
+ * while loading. Pass it from the first render so the region exists before
55
+ * it is needed.
50
56
  */
51
57
  loading?: boolean;
58
+ /**
59
+ * Text announced by assistive technology when `loading` becomes true.
60
+ * @default "Loading"
61
+ */
62
+ loadingLabel?: string;
52
63
  };
53
64
  type Props = OwnProps & Omit<ComponentProps<"button">, keyof OwnProps>;
54
65
  export type { Props as default };
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/lib/component/Button/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvD;;;;;GAKG;AACH,KAAK,QAAQ,GAAG;IACd;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB;;;;;OAKG;IACH,UAAU,CAAC,EAAE,cAAc,CAAC,YAAY,CAAC,CAAC;IAC1C;;;;;OAKG;IACH,YAAY,CAAC,EAAE,cAAc,CAAC,cAAc,CAAC,CAAC;IAC9C;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;;OAKG;IACH,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB;;;;;OAKG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC;AAEF,KAAK,KAAK,GAAG,QAAQ,GAAG,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,EAAE,MAAM,QAAQ,CAAC,CAAC;AAEvE,YAAY,EAAE,KAAK,IAAI,OAAO,EAAE,CAAC"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/lib/component/Button/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvD;;;;;GAKG;AACH,KAAK,QAAQ,GAAG;IACd;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB;;;;;OAKG;IACH,UAAU,CAAC,EAAE,cAAc,CAAC,YAAY,CAAC,CAAC;IAC1C;;;;;OAKG;IACH,YAAY,CAAC,EAAE,cAAc,CAAC,cAAc,CAAC,CAAC;IAC9C;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;;OAKG;IACH,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB;;;;;;;;;;;OAWG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,KAAK,KAAK,GAAG,QAAQ,GAAG,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,EAAE,MAAM,QAAQ,CAAC,CAAC;AAEvE,YAAY,EAAE,KAAK,IAAI,OAAO,EAAE,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"Tooltip.d.ts","sourceRoot":"","sources":["../../../../../src/lib/component/Tooltip/Tooltip.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAM/C;;;;;;GAMG;AACH,QAAA,MAAM,OAAO,mEAQV,YAAY,KAAG,KAAK,CAAC,YA6BvB,CAAC;eAEa,OAAO"}
1
+ {"version":3,"file":"Tooltip.d.ts","sourceRoot":"","sources":["../../../../../src/lib/component/Tooltip/Tooltip.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAM/C;;;;;;GAMG;AACH,QAAA,MAAM,OAAO,mEAQV,YAAY,KAAG,KAAK,CAAC,YA8BvB,CAAC;eAEa,OAAO"}
@@ -1,16 +1,18 @@
1
- import type { ReactElement } from "react";
1
+ import { type ReactElement } from "react";
2
2
  import type { TooltipEngineProps } from "./types.js";
3
3
  import "./styles.css";
4
4
  /**
5
5
  * The tooltip engine: wraps a target element with a hover/focus tooltip. It
6
- * drives {@link useDisclosure} in `hover` mode, portals the message to the
7
- * client only, positions it against the target span, and points the arrow.
6
+ * opens after a delay on hover or keyboard focus, closes on pointer leave,
7
+ * blur or Escape, keeps only one tooltip open at a time, portals the message
8
+ * to the client only, positions it against the target span, and points the
9
+ * arrow. Touch input never opens it.
8
10
  * {@link withTooltip} builds on this; render it directly when the message
9
11
  * must follow prop state (e.g. a toggle whose tooltip names the current
10
12
  * action).
11
13
  *
12
14
  * `import { TooltipEngine } from "@canonical/react-ds-global";`
13
15
  */
14
- declare const TooltipEngine: ({ children, style, className, Message, icon, open, distance, targetElementId, targetElementClassName, targetElementStyle, messageElementClassName, messageElementStyle, parentElement, autoFit, ...props }: TooltipEngineProps) => ReactElement;
16
+ declare const TooltipEngine: ({ children, style, className, Message, icon, open: openProp, isOpen: isOpenProp, activateDelay, deactivateDelay, onShow, onHide, onEnter, onLeave, onFocus, onBlur, closeOnEscape, closeOnOutsideClick: _closeOnOutsideClick, returnFocus: _returnFocus, distance, gutter, maxWidth, autoFit, targetElementId, targetElementClassName, targetElementStyle, messageElementClassName, messageElementStyle, parentElement, ...props }: TooltipEngineProps) => ReactElement;
15
17
  export default TooltipEngine;
16
18
  //# sourceMappingURL=TooltipEngine.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"TooltipEngine.d.ts","sourceRoot":"","sources":["../../../../../src/lib/component/Tooltip/TooltipEngine.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAiB,YAAY,EAAE,MAAM,OAAO,CAAC;AAIzD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAErD,OAAO,cAAc,CAAC;AAItB;;;;;;;;;GASG;AACH,QAAA,MAAM,aAAa,+MAgBhB,kBAAkB,KAAG,YAgGvB,CAAC;eAEa,aAAa"}
1
+ {"version":3,"file":"TooltipEngine.d.ts","sourceRoot":"","sources":["../../../../../src/lib/component/Tooltip/TooltipEngine.tsx"],"names":[],"mappings":"AAAA,OAAO,EAML,KAAK,YAAY,EAKlB,MAAM,OAAO,CAAC;AASf,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAErD,OAAO,cAAc,CAAC;AAOtB;;;;;;;;;;;GAWG;AACH,QAAA,MAAM,aAAa,uaA8BhB,kBAAkB,KAAG,YAsLvB,CAAC;eAEa,aAAa"}
@@ -0,0 +1,17 @@
1
+ import type { UseTooltipStateProps, UseTooltipStateResult } from "../types.js";
2
+ /**
3
+ * Manages the open state of one hover/focus tooltip.
4
+ *
5
+ * Opening and closing are delayed, and a close scheduled before the open
6
+ * delay elapses cancels the open. While another tooltip is open, a new one
7
+ * opens immediately and the previous one closes without its exit transition,
8
+ * so moving the pointer from one trigger to the next feels continuous.
9
+ *
10
+ * @param activateDelay Delay in milliseconds before opening. Defaults to 400.
11
+ * @param deactivateDelay Delay in milliseconds before closing. Defaults to 400.
12
+ * @param onShow Called when the tooltip opens.
13
+ * @param onHide Called when the tooltip closes.
14
+ */
15
+ declare const useTooltipState: ({ activateDelay, deactivateDelay, onShow, onHide, }: UseTooltipStateProps) => UseTooltipStateResult;
16
+ export default useTooltipState;
17
+ //# sourceMappingURL=useTooltipState.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useTooltipState.d.ts","sourceRoot":"","sources":["../../../../../../src/lib/component/Tooltip/hooks/useTooltipState.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAY/E;;;;;;;;;;;;GAYG;AACH,QAAA,MAAM,eAAe,wDAKlB,oBAAoB,KAAG,qBAmEzB,CAAC;eAEa,eAAe"}
@@ -19,7 +19,7 @@ export interface TooltipEngineProps extends Omit<UseDisclosureProps, "mode"> {
19
19
  Message: ReactNode;
20
20
  /**
21
21
  * An optional leading icon for the tooltip, rendered before the message
22
- * (Figma: 16px glyph, dimension-100 gap). Purely decorative.
22
+ * (16px glyph, dimension-100 gap). Purely decorative.
23
23
  */
24
24
  icon?: ReactNode;
25
25
  /**
@@ -51,6 +51,31 @@ export interface TooltipEngineProps extends Omit<UseDisclosureProps, "mode"> {
51
51
  */
52
52
  parentElement?: HTMLElement;
53
53
  }
54
+ export interface UseTooltipStateProps {
55
+ /** Delay in milliseconds before opening. Defaults to 400. */
56
+ activateDelay?: number;
57
+ /** Delay in milliseconds before closing. Defaults to 400. */
58
+ deactivateDelay?: number;
59
+ /** Called when the tooltip opens. */
60
+ onShow?: () => void;
61
+ /** Called when the tooltip closes. */
62
+ onHide?: () => void;
63
+ }
64
+ export interface UseTooltipStateResult {
65
+ /** Whether the tooltip is open. */
66
+ isOpen: boolean;
67
+ /**
68
+ * Whether the last close skipped the exit transition, because another
69
+ * tooltip opened in its place.
70
+ */
71
+ skipTransition: boolean;
72
+ /** Opens after the activate delay, or at once while another tooltip is open. */
73
+ scheduleShow: () => void;
74
+ /** Closes after the deactivate delay, cancelling a pending open. */
75
+ scheduleHide: () => void;
76
+ /** Closes at once. */
77
+ hide: () => void;
78
+ }
54
79
  /**
55
80
  * The tooltip options for {@link withTooltip}: everything the tooltip engine
56
81
  * accepts except the wrapped content and the message (which are supplied
@@ -64,7 +89,7 @@ type OwnProps = {
64
89
  children: ReactNode;
65
90
  /**
66
91
  * An optional leading icon, rendered before the text and top-aligned with the
67
- * first line (Figma: 16px glyph, dimension-100 gap). Pass any glyph node
92
+ * first line (16px glyph, dimension-100 gap). Pass any glyph node
68
93
  * (e.g. an `<Icon>` or inline SVG).
69
94
  */
70
95
  icon?: ReactNode;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/lib/component/Tooltip/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACtE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE/D;;;;;;GAMG;AACH,MAAM,WAAW,kBAAmB,SAAQ,IAAI,CAAC,kBAAkB,EAAE,MAAM,CAAC;IAC1E;;;OAGG;IACH,QAAQ,EAAE,SAAS,CAAC;IACpB;;OAEG;IACH,OAAO,EAAE,SAAS,CAAC;IACnB;;;OAGG;IACH,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB;;;;;OAKG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,yCAAyC;IACzC,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,6CAA6C;IAC7C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,uCAAuC;IACvC,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,+CAA+C;IAC/C,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,iDAAiD;IACjD,kBAAkB,CAAC,EAAE,aAAa,CAAC;IACnC,wDAAwD;IACxD,uBAAuB,CAAC,EAAE,MAAM,CAAC;IACjC,oDAAoD;IACpD,mBAAmB,CAAC,EAAE,aAAa,CAAC;IACpC;;;;;OAKG;IACH,aAAa,CAAC,EAAE,WAAW,CAAC;CAC7B;AAED;;;;;;GAMG;AACH,MAAM,MAAM,kBAAkB,GAAG,IAAI,CACnC,kBAAkB,EAClB,UAAU,GAAG,SAAS,CACvB,CAAC;AACF,KAAK,QAAQ,GAAG;IACd,qBAAqB;IACrB,QAAQ,EAAE,SAAS,CAAC;IACpB;;;;OAIG;IACH,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,yCAAyC;IACzC,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,iCAAiC;IACjC,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,YAAY,GAAG,QAAQ,GACjC,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE,MAAM,QAAQ,CAAC,CAAC"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/lib/component/Tooltip/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACtE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE/D;;;;;;GAMG;AACH,MAAM,WAAW,kBAAmB,SAAQ,IAAI,CAAC,kBAAkB,EAAE,MAAM,CAAC;IAC1E;;;OAGG;IACH,QAAQ,EAAE,SAAS,CAAC;IACpB;;OAEG;IACH,OAAO,EAAE,SAAS,CAAC;IACnB;;;OAGG;IACH,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB;;;;;OAKG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,yCAAyC;IACzC,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,6CAA6C;IAC7C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,uCAAuC;IACvC,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,+CAA+C;IAC/C,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,iDAAiD;IACjD,kBAAkB,CAAC,EAAE,aAAa,CAAC;IACnC,wDAAwD;IACxD,uBAAuB,CAAC,EAAE,MAAM,CAAC;IACjC,oDAAoD;IACpD,mBAAmB,CAAC,EAAE,aAAa,CAAC;IACpC;;;;;OAKG;IACH,aAAa,CAAC,EAAE,WAAW,CAAC;CAC7B;AAED,MAAM,WAAW,oBAAoB;IACnC,6DAA6D;IAC7D,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,6DAA6D;IAC7D,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,qCAAqC;IACrC,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,sCAAsC;IACtC,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;CACrB;AAED,MAAM,WAAW,qBAAqB;IACpC,mCAAmC;IACnC,MAAM,EAAE,OAAO,CAAC;IAChB;;;OAGG;IACH,cAAc,EAAE,OAAO,CAAC;IACxB,gFAAgF;IAChF,YAAY,EAAE,MAAM,IAAI,CAAC;IACzB,oEAAoE;IACpE,YAAY,EAAE,MAAM,IAAI,CAAC;IACzB,sBAAsB;IACtB,IAAI,EAAE,MAAM,IAAI,CAAC;CAClB;AAED;;;;;;GAMG;AACH,MAAM,MAAM,kBAAkB,GAAG,IAAI,CACnC,kBAAkB,EAClB,UAAU,GAAG,SAAS,CACvB,CAAC;AACF,KAAK,QAAQ,GAAG;IACd,qBAAqB;IACrB,QAAQ,EAAE,SAAS,CAAC;IACpB;;;;OAIG;IACH,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,yCAAyC;IACzC,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,iCAAiC;IACjC,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,YAAY,GAAG,QAAQ,GACjC,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE,MAAM,QAAQ,CAAC,CAAC"}
@@ -2,9 +2,9 @@ import type { ComponentType, FC, ReactNode } from "react";
2
2
  import type { WithTooltipOptions } from "./types.js";
3
3
  /**
4
4
  * A higher-order component that wraps a component with a tooltip. It is the
5
- * single public tooltip primitive: it owns the engine (hover-mode
6
- * {@link useDisclosure}, client-only portal, arrow positioning) and renders
7
- * the wrapped component as the tooltip target.
5
+ * single public tooltip primitive: it owns the engine (hover and focus
6
+ * behaviour, client-only portal, arrow positioning) and renders the wrapped
7
+ * component as the tooltip target.
8
8
  *
9
9
  * `Message` is fixed at wrap time — not reactive to the wrapped component's
10
10
  * props. When the message must follow prop state (e.g. a toggle whose
@@ -1,4 +1,4 @@
1
- import type { ArrowOffset, UseWindowFitmentProps, UseWindowFitmentResult, WindowFitmentAlign, WindowFitmentDirection, WindowFitmentPlacement, WindowFitmentSide } from "./types.js";
1
+ import type { ArrowOffset, BestPosition, UseWindowFitmentProps, UseWindowFitmentResult, WindowFitmentAlign, WindowFitmentDirection, WindowFitmentPlacement, WindowFitmentSide } from "./types.js";
2
2
  /** A resolved PHYSICAL placement — what the fitment core consumes internally. */
3
3
  type PhysicalPlacement = {
4
4
  direction: WindowFitmentDirection;
@@ -46,6 +46,27 @@ popupPosition?: {
46
46
  top: number;
47
47
  left: number;
48
48
  }) => ArrowOffset;
49
+ /** The usable bounds of the window, after the `gutter` prop. */
50
+ type FitmentBounds = {
51
+ top: number;
52
+ left: number;
53
+ right: number;
54
+ bottom: number;
55
+ };
56
+ /**
57
+ * Find the best position for the popup based on the preferred directions.
58
+ * @param targetRect The bounding client rect of the target element.
59
+ * @param popupRect The bounding client rect of the popup element.
60
+ * @param placements The physical placements to try, in order.
61
+ * @param options The distance, the usable bounds, and whether to auto-fit.
62
+ * @returns The best absolute position for the popup.
63
+ * @throws When `placements` is empty.
64
+ */
65
+ export declare const findBestPosition: (targetRect: DOMRect, popupRect: DOMRect, placements: PhysicalPlacement[], { distance, bounds, autoFit, }: {
66
+ distance: number;
67
+ bounds: FitmentBounds;
68
+ autoFit: boolean;
69
+ }) => BestPosition;
49
70
  declare const useWindowFitment: <TTarget extends HTMLElement = HTMLElement, TPopup extends HTMLElement = HTMLDivElement>({ preferredDirections, distance, gutter, maxWidth, resizeDelay, scrollDelay, isOpen, onBestPositionChange, autoFit, direction: directionProp, }: UseWindowFitmentProps) => UseWindowFitmentResult<TTarget, TPopup>;
50
71
  export default useWindowFitment;
51
72
  //# sourceMappingURL=useWindowFitment.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useWindowFitment.d.ts","sourceRoot":"","sources":["../../../../../src/lib/hooks/useWindowFitment/useWindowFitment.tsx"],"names":[],"mappings":"AAWA,OAAO,KAAK,EACV,WAAW,EAGX,qBAAqB,EACrB,sBAAsB,EACtB,kBAAkB,EAClB,sBAAsB,EACtB,sBAAsB,EACtB,iBAAiB,EAClB,MAAM,YAAY,CAAC;AAEpB,iFAAiF;AACjF,KAAK,iBAAiB,GAAG;IACvB,SAAS,EAAE,sBAAsB,CAAC;IAClC,KAAK,EAAE,kBAAkB,CAAC;CAC3B,CAAC;AAEF,+EAA+E;AAC/E,eAAO,MAAM,WAAW,UACf,iBAAiB,GAAG,sBAAsB,KAChD,sBACmE,CAAC;AAEvE;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,uBAAuB,cACvB,sBAAsB,OAC5B,KAAK,GAAG,KAAK,KACjB,iBAgCF,CAAC;AAcF;;;;;;;;;GASG;AACH,eAAO,MAAM,kBAAkB,cAClB,sBAAsB,cACrB,OAAO,aACR,OAAO;AAClB;;;;;;;;GAQG;gBACY;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,KAI3C,WAmBF,CAAC;AAUF,QAAA,MAAM,gBAAgB,GACpB,OAAO,SAAS,WAAW,GAAG,WAAW,EACzC,MAAM,SAAS,WAAW,GAAG,cAAc,mJAY1C,qBAAqB,KAAG,sBAAsB,CAAC,OAAO,EAAE,MAAM,CAyahE,CAAC;eAEa,gBAAgB"}
1
+ {"version":3,"file":"useWindowFitment.d.ts","sourceRoot":"","sources":["../../../../../src/lib/hooks/useWindowFitment/useWindowFitment.tsx"],"names":[],"mappings":"AAUA,OAAO,KAAK,EACV,WAAW,EACX,YAAY,EAEZ,qBAAqB,EACrB,sBAAsB,EACtB,kBAAkB,EAClB,sBAAsB,EACtB,sBAAsB,EACtB,iBAAiB,EAClB,MAAM,YAAY,CAAC;AAEpB,iFAAiF;AACjF,KAAK,iBAAiB,GAAG;IACvB,SAAS,EAAE,sBAAsB,CAAC;IAClC,KAAK,EAAE,kBAAkB,CAAC;CAC3B,CAAC;AAEF,+EAA+E;AAC/E,eAAO,MAAM,WAAW,UACf,iBAAiB,GAAG,sBAAsB,KAChD,sBACmE,CAAC;AAEvE;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,uBAAuB,cACvB,sBAAsB,OAC5B,KAAK,GAAG,KAAK,KACjB,iBAgCF,CAAC;AAcF;;;;;;;;;GASG;AACH,eAAO,MAAM,kBAAkB,cAClB,sBAAsB,cACrB,OAAO,aACR,OAAO;AAClB;;;;;;;;GAQG;gBACY;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,KAI3C,WAmBF,CAAC;AAEF,gEAAgE;AAChE,KAAK,aAAa,GAAG;IACnB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AA2GF;;;;;;;;GAQG;AACH,eAAO,MAAM,gBAAgB,eACf,OAAO,aACR,OAAO,cACN,iBAAiB,EAAE,kCAK5B;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,aAAa,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,KAC/D,YAsFF,CAAC;AAUF,QAAA,MAAM,gBAAgB,GACpB,OAAO,SAAS,WAAW,GAAG,WAAW,EACzC,MAAM,SAAS,WAAW,GAAG,cAAc,mJAY1C,qBAAqB,KAAG,sBAAsB,CAAC,OAAO,EAAE,MAAM,CAuNhE,CAAC;eAEa,gBAAgB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@canonical/react-ds-global",
3
- "version": "0.48.0",
3
+ "version": "0.50.0",
4
4
  "type": "module",
5
5
  "main": "dist/esm/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -56,10 +56,10 @@
56
56
  "test:vitest:watch": "vitest"
57
57
  },
58
58
  "dependencies": {
59
- "@canonical/ds-assets": "^0.48.0",
60
- "@canonical/ds-utils": "^0.48.0",
61
- "@canonical/react-hooks": "^0.48.0",
62
- "@canonical/styles": "^0.48.0",
59
+ "@canonical/ds-assets": "^0.50.0",
60
+ "@canonical/ds-utils": "^0.50.0",
61
+ "@canonical/react-hooks": "^0.50.0",
62
+ "@canonical/styles": "^0.50.0",
63
63
  "react": "^19.2.4",
64
64
  "react-dom": "^19.2.4"
65
65
  },
@@ -67,14 +67,14 @@
67
67
  "@biomejs/biome": "2.6.9",
68
68
  "@canonical/biome-config": "0.47.0",
69
69
  "@canonical/design-tokens": "0.46.0",
70
- "@canonical/ds-types": "^0.48.0",
71
- "@canonical/router-core": "^0.48.0",
72
- "@canonical/router-react": "^0.48.0",
73
- "@canonical/storybook-addon-utils": "^0.48.0",
74
- "@canonical/storybook-config": "^0.48.0",
75
- "@canonical/storybook-helpers": "^0.48.0",
76
- "@canonical/typescript-config-react": "^0.48.0",
77
- "@canonical/vitest-config-react": "^0.48.0",
70
+ "@canonical/ds-types": "^0.50.0",
71
+ "@canonical/router-core": "^0.50.0",
72
+ "@canonical/router-react": "^0.50.0",
73
+ "@canonical/storybook-addon-utils": "^0.50.0",
74
+ "@canonical/storybook-config": "^0.50.0",
75
+ "@canonical/storybook-helpers": "^0.50.0",
76
+ "@canonical/typescript-config-react": "^0.50.0",
77
+ "@canonical/vitest-config-react": "^0.50.0",
78
78
  "@canonical/webarchitect": "0.46.0",
79
79
  "@chromatic-com/storybook": "^5.0.1",
80
80
  "@storybook/addon-docs": "^10.6.0",
@@ -93,5 +93,14 @@
93
93
  "vite": "^8.0.1",
94
94
  "vitest": "^5.0.0"
95
95
  },
96
- "gitHead": "aee4aebab851f90159776a7ba658d0c62e0d2bf4"
96
+ "chromatic": {
97
+ "secret": "CHROMATIC_TOKEN_CANONICAL_REACT_DS_GLOBAL",
98
+ "externals": [
99
+ "configs/storybook/**",
100
+ "packages/ds-assets/**",
101
+ "packages/styles/**/!(*.test.*|*.stories.*|*.md|*.mdx)",
102
+ "packages/runtime/ds-utils/**/!(*.test.*|*.stories.*|*.md|*.mdx)"
103
+ ]
104
+ },
105
+ "gitHead": "4a2ca02b4767a0ee8e58a679281194fdc316fd71"
97
106
  }