@canonical/react-ds-global 0.30.0 → 0.32.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 (110) hide show
  1. package/dist/esm/lib/component/Accordion/common/Item/styles.css +127 -9
  2. package/dist/esm/lib/component/Badge/styles.css +25 -24
  3. package/dist/esm/lib/component/Breadcrumbs/Breadcrumbs.js +2 -2
  4. package/dist/esm/lib/component/Breadcrumbs/common/Item/Item.js +12 -2
  5. package/dist/esm/lib/component/Breadcrumbs/common/Item/Item.js.map +1 -1
  6. package/dist/esm/lib/component/Breadcrumbs/common/Item/styles.css +17 -5
  7. package/dist/esm/lib/component/Breadcrumbs/styles.css +3 -0
  8. package/dist/esm/lib/component/Button/Button.js +4 -5
  9. package/dist/esm/lib/component/Button/Button.js.map +1 -1
  10. package/dist/esm/lib/component/Button/styles.css +99 -17
  11. package/dist/esm/lib/component/Card/Card.js +7 -0
  12. package/dist/esm/lib/component/Card/Card.js.map +1 -1
  13. package/dist/esm/lib/component/Card/common/Content/styles.css +7 -3
  14. package/dist/esm/lib/component/Card/common/Footer/Footer.js +1 -1
  15. package/dist/esm/lib/component/Card/common/Footer/styles.css +12 -2
  16. package/dist/esm/lib/component/Card/styles.css +52 -14
  17. package/dist/esm/lib/component/Chip/styles.css +3 -0
  18. package/dist/esm/lib/component/ContextualMenu/ContextualMenu.js +11 -8
  19. package/dist/esm/lib/component/ContextualMenu/ContextualMenu.js.map +1 -1
  20. package/dist/esm/lib/component/ContextualMenu/common/Item/styles.css +31 -3
  21. package/dist/esm/lib/component/ContextualMenu/common/SubMenu/SubMenu.js +24 -5
  22. package/dist/esm/lib/component/ContextualMenu/common/SubMenu/SubMenu.js.map +1 -1
  23. package/dist/esm/lib/component/Tabs/common/Item/styles.css +12 -0
  24. package/dist/esm/lib/component/Tooltip/Tooltip.js +1 -1
  25. package/dist/esm/lib/component/Tooltip/index.js +0 -1
  26. package/dist/esm/lib/component/Tooltip/index.js.map +1 -1
  27. package/dist/esm/lib/component/Tooltip/styles.css +17 -0
  28. package/dist/esm/lib/component/Tooltip/withTooltip.js +70 -7
  29. package/dist/esm/lib/component/Tooltip/withTooltip.js.map +1 -1
  30. package/dist/esm/lib/group/Cards/Cards.js +49 -0
  31. package/dist/esm/lib/group/Cards/Cards.js.map +1 -0
  32. package/dist/esm/lib/group/Cards/index.js +3 -0
  33. package/dist/esm/lib/group/Cards/index.js.map +1 -0
  34. package/dist/esm/lib/group/Cards/styles.css +55 -0
  35. package/dist/esm/lib/group/Cards/types.js.map +1 -0
  36. package/dist/esm/lib/group/index.js +1 -0
  37. package/dist/esm/lib/group/index.js.map +1 -1
  38. package/dist/esm/lib/hooks/index.js +1 -0
  39. package/dist/esm/lib/hooks/index.js.map +1 -1
  40. package/dist/esm/lib/hooks/useContextualMenu/useContextualMenu.js +6 -0
  41. package/dist/esm/lib/hooks/useContextualMenu/useContextualMenu.js.map +1 -1
  42. package/dist/esm/lib/hooks/useIsMounted/index.js +3 -0
  43. package/dist/esm/lib/hooks/useIsMounted/index.js.map +1 -0
  44. package/dist/esm/lib/hooks/useIsMounted/types.js +2 -0
  45. package/dist/esm/lib/hooks/useIsMounted/types.js.map +1 -0
  46. package/dist/esm/lib/hooks/useIsMounted/useIsMounted.js +21 -0
  47. package/dist/esm/lib/hooks/useIsMounted/useIsMounted.js.map +1 -0
  48. package/dist/esm/lib/hooks/useWindowFitment/readingDirection.js +19 -4
  49. package/dist/esm/lib/hooks/useWindowFitment/readingDirection.js.map +1 -1
  50. package/dist/types/lib/component/Breadcrumbs/Breadcrumbs.d.ts +2 -2
  51. package/dist/types/lib/component/Breadcrumbs/common/Item/Item.d.ts.map +1 -1
  52. package/dist/types/lib/component/Breadcrumbs/common/Item/types.d.ts +5 -0
  53. package/dist/types/lib/component/Breadcrumbs/common/Item/types.d.ts.map +1 -1
  54. package/dist/types/lib/component/Breadcrumbs/types.d.ts +15 -0
  55. package/dist/types/lib/component/Breadcrumbs/types.d.ts.map +1 -1
  56. package/dist/types/lib/component/Button/Button.d.ts.map +1 -1
  57. package/dist/types/lib/component/Button/types.d.ts +7 -5
  58. package/dist/types/lib/component/Button/types.d.ts.map +1 -1
  59. package/dist/types/lib/component/Card/Card.d.ts +7 -0
  60. package/dist/types/lib/component/Card/Card.d.ts.map +1 -1
  61. package/dist/types/lib/component/Card/common/Footer/Footer.d.ts +1 -1
  62. package/dist/types/lib/component/Card/common/Footer/types.d.ts +1 -1
  63. package/dist/types/lib/component/Card/common/Footer/types.d.ts.map +1 -1
  64. package/dist/types/lib/component/ContextualMenu/ContextualMenu.d.ts.map +1 -1
  65. package/dist/types/lib/component/ContextualMenu/common/SubMenu/SubMenu.d.ts.map +1 -1
  66. package/dist/types/lib/component/Tooltip/Tooltip.d.ts +1 -1
  67. package/dist/types/lib/component/Tooltip/index.d.ts +0 -1
  68. package/dist/types/lib/component/Tooltip/index.d.ts.map +1 -1
  69. package/dist/types/lib/component/Tooltip/types.d.ts +60 -0
  70. package/dist/types/lib/component/Tooltip/types.d.ts.map +1 -1
  71. package/dist/types/lib/component/Tooltip/withTooltip.d.ts +10 -12
  72. package/dist/types/lib/component/Tooltip/withTooltip.d.ts.map +1 -1
  73. package/dist/types/lib/group/Cards/Cards.d.ts +40 -0
  74. package/dist/types/lib/group/Cards/Cards.d.ts.map +1 -0
  75. package/dist/types/lib/group/Cards/index.d.ts +3 -0
  76. package/dist/types/lib/group/Cards/index.d.ts.map +1 -0
  77. package/dist/types/lib/group/Cards/types.d.ts +14 -0
  78. package/dist/types/lib/group/Cards/types.d.ts.map +1 -0
  79. package/dist/types/lib/group/index.d.ts +1 -0
  80. package/dist/types/lib/group/index.d.ts.map +1 -1
  81. package/dist/types/lib/hooks/index.d.ts +1 -0
  82. package/dist/types/lib/hooks/index.d.ts.map +1 -1
  83. package/dist/types/lib/hooks/useContextualMenu/useContextualMenu.d.ts.map +1 -1
  84. package/dist/types/lib/hooks/useIsMounted/index.d.ts +3 -0
  85. package/dist/types/lib/hooks/useIsMounted/index.d.ts.map +1 -0
  86. package/dist/types/lib/hooks/useIsMounted/types.d.ts +6 -0
  87. package/dist/types/lib/hooks/useIsMounted/types.d.ts.map +1 -0
  88. package/dist/types/lib/hooks/useIsMounted/useIsMounted.d.ts +15 -0
  89. package/dist/types/lib/hooks/useIsMounted/useIsMounted.d.ts.map +1 -0
  90. package/dist/types/lib/hooks/useWindowFitment/readingDirection.d.ts +12 -4
  91. package/dist/types/lib/hooks/useWindowFitment/readingDirection.d.ts.map +1 -1
  92. package/dist/types/lib/types/link.d.ts +1 -1
  93. package/package.json +16 -16
  94. package/dist/esm/lib/component/Tooltip/common/TooltipArea/TooltipArea.js +0 -62
  95. package/dist/esm/lib/component/Tooltip/common/TooltipArea/TooltipArea.js.map +0 -1
  96. package/dist/esm/lib/component/Tooltip/common/TooltipArea/index.js +0 -2
  97. package/dist/esm/lib/component/Tooltip/common/TooltipArea/index.js.map +0 -1
  98. package/dist/esm/lib/component/Tooltip/common/TooltipArea/styles.css +0 -13
  99. package/dist/esm/lib/component/Tooltip/common/TooltipArea/types.js.map +0 -1
  100. package/dist/esm/lib/component/Tooltip/common/index.js +0 -2
  101. package/dist/esm/lib/component/Tooltip/common/index.js.map +0 -1
  102. package/dist/types/lib/component/Tooltip/common/TooltipArea/TooltipArea.d.ts +0 -10
  103. package/dist/types/lib/component/Tooltip/common/TooltipArea/TooltipArea.d.ts.map +0 -1
  104. package/dist/types/lib/component/Tooltip/common/TooltipArea/index.d.ts +0 -3
  105. package/dist/types/lib/component/Tooltip/common/TooltipArea/index.d.ts.map +0 -1
  106. package/dist/types/lib/component/Tooltip/common/TooltipArea/types.d.ts +0 -47
  107. package/dist/types/lib/component/Tooltip/common/TooltipArea/types.d.ts.map +0 -1
  108. package/dist/types/lib/component/Tooltip/common/index.d.ts +0 -2
  109. package/dist/types/lib/component/Tooltip/common/index.d.ts.map +0 -1
  110. /package/dist/esm/lib/{component/Tooltip/common/TooltipArea → group/Cards}/types.js +0 -0
@@ -7,6 +7,15 @@
7
7
  * container (no step) and reads as flush. It stays delimited by its border,
8
8
  * radius, and the dividers between its sections. Colour tokens follow the Figma
9
9
  * spec.
10
+ *
11
+ * ── A Card is a grid participant ────────────────────────────────────────────
12
+ * A Card always lives inside a grid (standalone: wrap it in a `.grid`; in bulk:
13
+ * use the `Cards` group). It carries all of its OWN grid logic here. The card is
14
+ * a ROW SUBGRID spanning FOUR section tracks — image / header / content / footer
15
+ * — inheriting them from the parent so several cards can line their sections up
16
+ * across a row. A card that omits a section simply leaves that track empty for
17
+ * itself; the four-track vocabulary is fixed because a Card only ever has those
18
+ * four section types. `Cards` supplies the shared tracks and the column flow.
10
19
  */
11
20
  :root {
12
21
  --card-color-border: var(--color-border-muted);
@@ -16,26 +25,55 @@
16
25
  }
17
26
 
18
27
  .ds.card {
19
- display: flex;
20
- flex-direction: column;
28
+ /* One grid item spanning `--card-span` parent columns and its four section
29
+ * rows; a ROW subgrid so its sections snap to the parent's four shared tracks
30
+ * (that is the cross-card alignment). The parent (a `.grid` or the `Cards`
31
+ * group) owns the four row tracks. */
32
+ grid-column: span var(--card-span, 1);
33
+ grid-row: span 4;
34
+ display: grid;
35
+ grid-template-rows: subgrid;
36
+ grid-template-columns: minmax(0, 1fr);
21
37
 
22
38
  /* No background of its own: the card is not a surface, so it inherits its
23
39
  container's background and blends with the surface it sits on. */
24
-
25
40
  border: var(--card-border-width) solid var(--card-color-border);
26
41
  border-radius: var(--card-border-radius);
27
-
28
42
  /* Clip section corners (e.g. full-bleed images) to the card radius. */
29
43
  overflow: hidden;
44
+ }
45
+
46
+ /* Place each section on its fixed row track, spanning the card's single column.
47
+ * DOM order matches track order: image (1) / header (2) / content (3) /
48
+ * footer (4). An absent section leaves its track empty for this card only. */
49
+ .ds.card > .card-image {
50
+ grid-row: 1;
51
+ grid-column: 1 / -1;
52
+ }
53
+ .ds.card > .card-header {
54
+ grid-row: 2;
55
+ grid-column: 1 / -1;
56
+ }
57
+ .ds.card > .card-content {
58
+ grid-row: 3;
59
+ grid-column: 1 / -1;
60
+ }
61
+ .ds.card > .card-footer {
62
+ grid-row: 4;
63
+ grid-column: 1 / -1;
64
+ }
65
+
66
+ /* Section separators: a divider between adjacent sections. The card frame
67
+ * provides the outer border, so the last section has none. The header is NOT a
68
+ * separate visual section — no divider is drawn under it and it merges with the
69
+ * content that follows. Media (Image) stays full-bleed; the content-bearing
70
+ * sections pad themselves. */
71
+ .ds.card > :is(.card-content, .card-footer, .card-image):not(:last-child) {
72
+ border-block-end: var(--card-border-width) solid var(--card-color-border);
73
+ }
30
74
 
31
- /* Section separators: a divider between adjacent sections. The card frame
32
- already provides the outer border, so the last section has none. The card
33
- itself applies NO general padding — only the content-bearing sections
34
- (Content, Header, Footer) pad themselves; media (Image) stays full-bleed. */
35
- &
36
- > :is(.card-header, .card-content, .card-footer, .card-image):not(
37
- :last-child
38
- ) {
39
- border-block-end: var(--card-border-width) solid var(--card-color-border);
40
- }
75
+ /* Collapse the header/content seam so title and content read as one region
76
+ (raw 0: unthemable by design). */
77
+ .ds.card > .card-header:has(+ .card-content) {
78
+ padding-block-end: 0;
41
79
  }
@@ -99,6 +99,9 @@
99
99
 
100
100
  /* Context-specific styling for badges within chips */
101
101
  & .ds.badge {
102
+ /** Pull the badge closer to the edge of a chip */
103
+ --badge-chip-margin-tweak: var(--dimension-025);
104
+
102
105
  align-self: center;
103
106
  margin-left: var(--spacing-horizontal-small);
104
107
  margin-right: var(--badge-chip-margin-tweak);
@@ -2,7 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { getItemId } from "@canonical/utils";
3
3
  import { useMemo } from "react";
4
4
  import { createPortal } from "react-dom";
5
- import { MENU_PLACEMENT, useContextualMenu } from "../../hooks/index.js";
5
+ import { MENU_ROOT_PLACEMENT, useContextualMenu, useIsMounted, } from "../../hooks/index.js";
6
6
  import MenuContext from "./common/MenuContext.js";
7
7
  import SubMenu from "./common/SubMenu/index.js";
8
8
  import "./styles.css";
@@ -22,13 +22,18 @@ const ContextualMenu = ({ trigger, groups, label, className, preferredDirections
22
22
  // and the open effect keys on the annotated root, so a fresh object each
23
23
  // render re-fires that effect every render → dispatch → re-render → freeze.
24
24
  const root = useMemo(() => ({ key: "contextual-menu-root", items: groups }), [groups]);
25
+ // Portal only after mount so the server and first client render agree —
26
+ // `typeof window` is already truthy on the first client render, which would
27
+ // portal the menu on render 0 and mismatch the inline server output.
28
+ const mounted = useIsMounted();
25
29
  const menu = useContextualMenu({
26
30
  root,
27
31
  isOpen: open,
28
- // Open toward the trigger's leading edge, top-aligned, flipping side/
29
- // alignment as space runs out. MENU_PLACEMENT is logical (inline-*), so the
30
- // hook mirrors it in RTL automatically — no direction read here.
31
- preferredDirections: preferredDirections ?? MENU_PLACEMENT,
32
+ // Open BELOW the trigger, leading-aligned, flipping above then to the side
33
+ // as space runs out (design review). MENU_ROOT_PLACEMENT is logical, so the
34
+ // hook mirrors alignment in RTL automatically — no direction read here.
35
+ // (Submenus keep the side-opening MENU_PLACEMENT — see SubMenu.)
36
+ preferredDirections: preferredDirections ?? MENU_ROOT_PLACEMENT,
32
37
  distance,
33
38
  gutter,
34
39
  maxWidth,
@@ -86,9 +91,7 @@ const ContextualMenu = ({ trigger, groups, label, className, preferredDirections
86
91
  // SubMenu renders the item and, if it is a submenu parent, its
87
92
  // nested popup (recursively). Leaves render as a plain item.
88
93
  _jsx(SubMenu, { item: item }, getItemId(item)))) }, getItemId(group)))) }));
89
- return (_jsx(MenuContext.Provider, { value: menuContextValue, children: _jsxs("div", { className: [componentCssClassName, className].filter(Boolean).join(" "), ref: targetRef, ...props, children: [_jsx("button", { type: "button", id: triggerId, className: "trigger", ...triggerProps, children: trigger }), typeof window !== "undefined"
90
- ? createPortal(menuElement, document.body)
91
- : menuElement] }) }));
94
+ return (_jsx(MenuContext.Provider, { value: menuContextValue, children: _jsxs("div", { className: [componentCssClassName, className].filter(Boolean).join(" "), ...props, children: [_jsx("button", { type: "button", id: triggerId, className: "trigger", ref: targetRef, ...triggerProps, children: trigger }), mounted ? createPortal(menuElement, document.body) : menuElement] }) }));
92
95
  };
93
96
  export default ContextualMenu;
94
97
  //# sourceMappingURL=ContextualMenu.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ContextualMenu.js","sourceRoot":"","sources":["../../../../../src/lib/component/ContextualMenu/ContextualMenu.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE7C,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAChC,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzE,OAAO,WAAW,MAAM,yBAAyB,CAAC;AAClD,OAAO,OAAO,MAAM,2BAA2B,CAAC;AAEhD,OAAO,cAAc,CAAC;AAEtB,MAAM,qBAAqB,GAAG,oBAAoB,CAAC;AAEnD;;;;;;;;GAQG;AACH,MAAM,cAAc,GAAG,CAAC,EACtB,OAAO,EACP,MAAM,EACN,KAAK,EACL,SAAS,EACT,mBAAmB,EACnB,QAAQ,EACR,MAAM,EACN,QAAQ,EACR,OAAO,EACP,IAAI,EACJ,QAAQ,EACR,IAAI,EACJ,YAAY,EACZ,GAAG,KAAK,EACY,EAAsB,EAAE;IAC5C,0EAA0E;IAC1E,4EAA4E;IAC5E,yEAAyE;IACzE,4EAA4E;IAC5E,MAAM,IAAI,GAAG,OAAO,CAClB,GAAG,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,sBAAsB,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,EACtD,CAAC,MAAM,CAAC,CACT,CAAC;IACF,MAAM,IAAI,GAAG,iBAAiB,CAAC;QAC7B,IAAI;QACJ,MAAM,EAAE,IAAI;QACZ,sEAAsE;QACtE,4EAA4E;QAC5E,iEAAiE;QACjE,mBAAmB,EAAE,mBAAmB,IAAI,cAAc;QAC1D,QAAQ;Q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file":"ContextualMenu.js","sourceRoot":"","sources":["../../../../../src/lib/component/ContextualMenu/ContextualMenu.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE7C,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAChC,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EACL,mBAAmB,EACnB,iBAAiB,EACjB,YAAY,GACb,MAAM,sBAAsB,CAAC;AAC9B,OAAO,WAAW,MAAM,yBAAyB,CAAC;AAClD,OAAO,OAAO,MAAM,2BAA2B,CAAC;AAEhD,OAAO,cAAc,CAAC;AAEtB,MAAM,qBAAqB,GAAG,oBAAoB,CAAC;AAEnD;;;;;;;;GAQG;AACH,MAAM,cAAc,GAAG,CAAC,EACtB,OAAO,EACP,MAAM,EACN,KAAK,EACL,SAAS,EACT,mBAAmB,EACnB,QAAQ,EACR,MAAM,EACN,QAAQ,EACR,OAAO,EACP,IAAI,EACJ,QAAQ,EACR,IAAI,EACJ,YAAY,EACZ,GAAG,KAAK,EACY,EAAsB,EAAE;IAC5C,0EAA0E;IAC1E,4EAA4E;IAC5E,yEAAyE;IACzE,4EAA4E;IAC5E,MAAM,IAAI,GAAG,OAAO,CAClB,GAAG,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,sBAAsB,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,EACtD,CAAC,MAAM,CAAC,CACT,CAAC;IACF,wEAAwE;IACxE,4EAA4E;IAC5E,qEAAqE;IACrE,MAAM,OAAO,GAAG,YAAY,EAAE,CAAC;IAC/B,MAAM,IAAI,GAAG,iBAAiB,CAAC;QAC7B,IAAI;QACJ,MAAM,EAAE,IAAI;QACZ,2EAA2E;QAC3E,4EAA4E;QAC5E,wEAAwE;QACxE,iEAAiE;QACjE,mBAAmB,EAAE,mBAAmB,IAAI,mBAAmB;QAC/D,QAAQ;QACR,MAAM;QACN,QAAQ;QACR,OAAO,EAAE,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gap: icon<->text and text<->caret (per the spec). */
20
20
  --contextual-menu-item-gap: var(--dimension-050);
21
+ /* De-emphasised slot text (badge / shortcut) — muted, matching
22
+ KeyboardKey / Tabs. */
23
+ --contextual-menu-item-slot-color: var(--color-text-muted);
24
+ /* Keyboard focus ring (Button precedent) — the semantic focus-ring colour,
25
+ with a currentColor backstop should the theme layer not be loaded. */
26
+ --contextual-menu-item-focus-ring-color: var(--color-focusRing, currentColor);
27
+ --contextual-menu-item-focus-ring-width: var(
28
+ --dimension-stroke-thickness-large
29
+ );
21
30
  }
22
31
 
23
32
  .ds.contextual-menu-item {
@@ -29,7 +38,9 @@
29
38
  padding-inline: var(--contextual-menu-item-padding-inline);
30
39
  color: var(--contextual-menu-item-color-text);
31
40
  background-color: var(--contextual-menu-item-color-background);
32
- line-height: var(--line-height-text, var(--dimension-300));
41
+ /* The --dimension-300 (24px) fallback is load-bearing: the typography var's
42
+ --number-line-height-* reference is unresolved in the built tokens. */
43
+ line-height: var(--typography-text-primary-line-height, var(--dimension-300));
33
44
  cursor: pointer;
34
45
  user-select: none;
35
46
 
@@ -38,13 +49,25 @@
38
49
  }
39
50
 
40
51
  /* The highlighted (roving) item shows the active fill — matching the Figma
41
- "Active" state — so keyboard focus is visible without a separate outline. */
52
+ "Active" state. */
42
53
  &:focus-visible,
43
54
  &[tabindex="0"] {
44
55
  background-color: var(--contextual-menu-item-color-background-active);
45
56
  outline: none;
46
57
  }
47
58
 
59
+ /* The active fill alone is ~1.2:1 against the resting item — below the 3:1
60
+ non-text minimum — so keyboard focus additionally draws a ring (WCAG
61
+ 1.4.11 / 2.4.13). Inset (negative offset) so the popup surface's
62
+ `overflow-y: auto` never clips it; :focus-visible only, so pointer users
63
+ keep the quiet Figma look. Deliberately diverges from the Figma "Active"
64
+ state, which fails WCAG. */
65
+ &:focus-visible {
66
+ outline: var(--contextual-menu-item-focus-ring-width) solid
67
+ var(--contextual-menu-item-focus-ring-color);
68
+ outline-offset: calc(-1 * var(--contextual-menu-item-focus-ring-width));
69
+ }
70
+
48
71
  > .label {
49
72
  flex: 1 1 auto;
50
73
  }
@@ -53,7 +76,7 @@
53
76
  > .slot {
54
77
  flex: 0 0 auto;
55
78
  margin-inline-start: auto;
56
- opacity: 0.7;
79
+ color: var(--contextual-menu-item-slot-color);
57
80
  }
58
81
 
59
82
  /* The submenu caret sits on the trailing edge in a fixed icon box (Figma:
@@ -81,6 +104,11 @@
81
104
  background-color: var(--contextual-menu-item-color-background);
82
105
  cursor: not-allowed;
83
106
  pointer-events: none;
107
+
108
+ /* The slot follows the disabled text colour instead of staying muted. */
109
+ > .slot {
110
+ color: inherit;
111
+ }
84
112
  }
85
113
  }
86
114
 
@@ -1,8 +1,8 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { getItemId } from "@canonical/utils";
3
- import { useEffect, useRef, useState } from "react";
3
+ import { useEffect, useId, useRef, useState } from "react";
4
4
  import { createPortal } from "react-dom";
5
- import { MENU_PLACEMENT, useWindowFitment } from "../../../../hooks/index.js";
5
+ import { MENU_PLACEMENT, useIsMounted, useWindowFitment, } from "../../../../hooks/index.js";
6
6
  import Item from "../Item/index.js";
7
7
  import { useMenuContext } from "../MenuContext.js";
8
8
  /**
@@ -40,9 +40,16 @@ const SubMenuParent = ({ item }) => {
40
40
  const keyboardOpen = status.inHighlightedBranch && !status.highlighted;
41
41
  const [hovered, setHovered] = useState(false);
42
42
  const open = keyboardOpen || hovered;
43
+ // Portal only after mount so the server and first client render agree —
44
+ // `typeof window` is already truthy on the first client render.
45
+ const mounted = useIsMounted();
43
46
  // MENU_PLACEMENT is a stable module constant and logical, so the hook mirrors
44
47
  // it in RTL from this item's own writing direction — no per-submenu dir read.
45
48
  const { targetRef, popupRef, popupPositionStyle, bestPosition } = useWindowFitment({ preferredDirections: MENU_PLACEMENT, autoFit: true });
49
+ // A stable, instance-unique id for the submenu surface so the parent item
50
+ // can reference the popup it controls (item keys are only unique within one
51
+ // menu, so useId rather than the item id).
52
+ const submenuId = useId();
46
53
  // The item carries both the roving props and the fitment target ref. The
47
54
  // tree's getItemProps already returns a `ref` (it registers the node for
48
55
  // roving focus); COMPOSE ours with it rather than replacing it, or the
@@ -51,6 +58,14 @@ const SubMenuParent = ({ item }) => {
51
58
  const navRef = baseItemProps.ref;
52
59
  const itemProps = {
53
60
  ...baseItemProps,
61
+ // The composed `aria-expanded` (from getMenuItemProps) tracks only the
62
+ // keyboard highlight branch: it reports false for a HOVER-opened submenu
63
+ // and true for a merely-highlighted parent whose popup is not even
64
+ // mounted. Override with the REAL open state (WCAG 4.1.2 name/role/value).
65
+ "aria-expanded": open,
66
+ // Point at the popup only while it exists — the surface is unmounted when
67
+ // closed, and a dangling IDREF is invalid ARIA.
68
+ "aria-controls": open ? submenuId : undefined,
54
69
  ref: (node) => {
55
70
  targetRef.current = node;
56
71
  if (typeof navRef === "function")
@@ -92,16 +107,20 @@ const SubMenuParent = ({ item }) => {
92
107
  bestPosition?.positionName,
93
108
  ]
94
109
  .filter(Boolean)
95
- .join(" "), "aria-hidden": false, "data-positioned": bestPosition ? "true" : undefined, style: popupPositionStyle, ref: (el) => {
110
+ .join(" "), id: submenuId, "aria-hidden": false, "data-positioned": bestPosition ? "true" : undefined, style: popupPositionStyle, ...menuProps,
111
+ // After the spread so this composing callback wins over menuProps.ref
112
+ // (later JSX props override earlier ones): it captures the surface for
113
+ // the keyboard-open focus effect AND forwards to the tree's ref.
114
+ ref: (el) => {
96
115
  surfaceRef.current = el;
97
116
  if (typeof menuProps.ref === "function")
98
117
  menuProps.ref(el);
99
118
  else if (menuProps.ref)
100
119
  menuProps.ref.current = el;
101
- }, ...menuProps, children: children.map((child) => (
120
+ }, children: children.map((child) => (
102
121
  // Recurse: a submenu child may itself be a submenu parent.
103
122
  _jsx(SubMenu, { item: child }, getItemId(child)))) })) : null;
104
- return (_jsxs("div", { className: "submenu-anchor", onPointerEnter: () => setHovered(true), onPointerLeave: () => setHovered(false), children: [_jsx(Item, { item: item, itemProps: itemProps, onSelect: () => onSelectItem(item) }), submenuSurface && typeof window !== "undefined"
123
+ return (_jsxs("div", { className: "submenu-anchor", onPointerEnter: () => setHovered(true), onPointerLeave: () => setHovered(false), children: [_jsx(Item, { item: item, itemProps: itemProps, onSelect: () => onSelectItem(item) }), submenuSurface && mounted
105
124
  ? createPortal(submenuSurface, document.body)
106
125
  : null] }));
107
126
  };
@@ -1 +1 @@
1
- {"version":3,"file":"SubMenu.js","sourceRoot":"","sources":["../../../../../../../src/lib/component/ContextualMenu/common/SubMenu/SubMenu.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE7C,OAAO,EAAqB,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACvE,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAE9E,OAAO,IAAI,MAAM,kBAAkB,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnD;;;;;;GAMG;AACH,MAAM,OAAO,GAAG,CAAC,EAAE,IAAI,EAA6B,EAAgB,EAAE;IACpE,MAAM,EAAE,YAAY,EAAE,YAAY,EAAE,GAAG,cAAc,EAAE,CAAC;IAExD,IAAI,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,CAAC;QACvB,OAAO,KAAC,aAAa,IAAC,IAAI,EAAE,IAAI,GAAI,CAAC;IACvC,CAAC;IAED,OAAO,CACL,KAAC,IAAI,IACH,IAAI,EAAE,IAAI,EACV,SAAS,EAAE,YAAY,CAAC,IAAI,CAAC,EAC7B,QAAQ,EAAE,GAAG,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,GAClC,CACH,CAAC;AACJ,CAAC,CAAC;AAEF;;;;;;;;;GASG;AACH,MAAM,aAAa,GAAG,CAAC,EAAE,IAAI,EAA6B,EAAgB,E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,OAAO,GAAG,EAAE,CAAC;QACxE,CAAC,KACG,SAAS,YAEZ,QAAQ,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC;QACvB,2DAA2D;QAC3D,KAAC,OAAO,IAAwB,IAAI,EAAE,KAAK,IAA7B,SAAS,CAAC,KAAK,CAAC,CAAiB,CAChD,CAAC,GACE,CACP,CAAC,CAAC,CAAC,IAAI,CAAC;IAET,OAAO,CACL,eACE,SAAS,EAAC,gBAAgB,EAC1B,cAAc,EAAE,GAAG,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,EACtC,cAAc,EAAE,GAAG,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC,aAEvC,KAAC,IAAI,IACH,IAAI,EAAE,IAAI,EACV,SAAS,EAAE,SAAS,EACpB,QAAQ,EAAE,GAAG,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,GAClC,EACD,cAAc,IAAI,OAAO,MAAM,KAAK,WAAW;gBAC9C,CAAC,CAAC,YAAY,CAAC,cAAc,EAAE,QAAQ,CAAC,IAAI,CAAC;gBAC7C,CAAC,CAAC,IAAI,IACJ,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,OAAO,CAAC"}
1
+ {"version":3,"file":"SubMenu.js","sourceRoot":"","sources":["../../../../../../../src/lib/component/ContextualMenu/common/SubMenu/SubMenu.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE7C,OAAO,EAAqB,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC9E,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EACL,cAAc,EACd,YAAY,EACZ,gBAAgB,GACjB,MAAM,4BAA4B,CAAC;AAEpC,OAAO,IAAI,MAAM,kBAAkB,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnD;;;;;;GAMG;AACH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EAC1B,cAAc,EAAE,GAAG,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,EACtC,cAAc,EAAE,GAAG,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC,aAEvC,KAAC,IAAI,IACH,IAAI,EAAE,IAAI,EACV,SAAS,EAAE,SAAS,EACpB,QAAQ,EAAE,GAAG,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,GAClC,EACD,cAAc,IAAI,OAAO;gBACxB,CAAC,CAAC,YAAY,CAAC,cAAc,EAAE,QAAQ,CAAC,IAAI,CAAC;gBAC7C,CAAC,CAAC,IAAI,IACJ,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,OAAO,CAAC"}
@@ -15,6 +15,8 @@
15
15
  --tabs-tab-padding-inline: var(--space-200); /* 16px */
16
16
  /* 5bU = 40px tab height on the 8px baseline grid. */
17
17
  --tabs-tab-min-block-size: calc(var(--baseline-height) * 5);
18
+ --tabs-tab-focus-ring-width: var(--dimension-strokeThickness-large, 2px);
19
+ --tabs-tab-focus-ring-color: var(--color-focusRing);
18
20
  }
19
21
 
20
22
  .ds.tabs-item {
@@ -38,6 +40,16 @@
38
40
  /* Transparent underline reserved so the row never shifts when a border
39
41
  appears on hover/active. */
40
42
  border-bottom: var(--tabs-tab-border-width) solid transparent;
43
+
44
+ /* Keyboard focus: a design-system focus ring (design review) instead of the
45
+ UA default outline. Inset offset so the ring hugs the tab and the row's
46
+ `overflow` never clips it; :focus-visible only, so pointer clicks stay
47
+ quiet. */
48
+ &:focus-visible {
49
+ outline: var(--tabs-tab-focus-ring-width) solid
50
+ var(--tabs-tab-focus-ring-color);
51
+ outline-offset: calc(-1 * var(--tabs-tab-focus-ring-width));
52
+ }
41
53
  }
42
54
 
43
55
  /* Hover: a muted bottom border hints the tab is navigable, and settles faster
@@ -6,7 +6,7 @@ const componentCssClassName = "ds tooltip contrasted";
6
6
  /**
7
7
  * The Tooltip component renders the message part of a tooltip. It has no
8
8
  * interactivity or positioning logic and is generally consumed via
9
- * TooltipArea or the withTooltip HOC.
9
+ * the withTooltip HOC.
10
10
  *
11
11
  * @implements ds:global.component.tooltip
12
12
  */
@@ -1,4 +1,3 @@
1
- export * from "./common/index.js";
2
1
  export { default as Tooltip } from "./Tooltip.js";
3
2
  export { default as withTooltip } from "./withTooltip.js";
4
3
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/lib/component/Tooltip/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,cAAc,CAAC;AAElD,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,kBAAkB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/lib/component/Tooltip/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,cAAc,CAAC;AAElD,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,kBAAkB,CAAC"}
@@ -1,3 +1,20 @@
1
+ /* The tooltip engine wrapper (rendered by `withTooltip`) — a relatively
2
+ positioned inline span around the target. The `.target` child carries the
3
+ measuring ref and strips margins from its content so placement is exact. */
4
+ .ds.tooltip-area {
5
+ position: relative;
6
+ & .target {
7
+ cursor: pointer;
8
+ position: relative;
9
+ display: inline-block;
10
+
11
+ & > * {
12
+ /* biome-ignore lint/complexity/noImportantStyles: The tooltip targets must have no margin in order for tooltip placements to work correctly */
13
+ margin: 0 !important;
14
+ }
15
+ }
16
+ }
17
+
1
18
  /* Component tokens — sourced from @canonical/design-tokens.
2
19
  The tooltip runs on the `contrasted` surface so its colours invert against
3
20
  the ambient theme (dark chip on a light UI, light chip on a dark UI). The
@@ -1,14 +1,77 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { TooltipArea } from "./common/TooltipArea/index.js";
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { createPortal } from "react-dom";
3
+ import { useDisclosure, useIsMounted } from "../../hooks/index.js";
4
+ import Tooltip from "./Tooltip.js";
5
+ import "./styles.css";
6
+ const componentCssClassName = "ds tooltip-area";
3
7
  /**
4
- * A higher-order component that wraps a component with a tooltip.
5
- * @param Component The component function to wrap. If you need to use a Node instead of a function, use [`TooltipArea`](/?path=/docs/tooltip-withtooltip--docs) instead.
6
- * @param Message The content of the tooltip
7
- * @param popupProps Tooltip options forwarded to the underlying `TooltipArea`
8
+ * The tooltip engine: wraps a target element with a hover/focus tooltip. It
9
+ * drives {@link useDisclosure} in `hover` mode, portals the message to the
10
+ * client only, positions it against the target span, and points the arrow. This
11
+ * is the shared implementation that {@link withTooltip} builds on — it renders
12
+ * the wrapped component as its `children` target.
13
+ */
14
+ const TooltipEngine = ({ children, style, className, Message, icon, open, distance = "6px", targetElementId, targetElementClassName, targetElementStyle, messageElementClassName, messageElementStyle, parentElement, autoFit, ...props }) => {
15
+ const { targetRef, popupRef, popupPositionStyle, popupId, isOpen, bestPosition, arrowOffset, getToggleProps, getContentProps,
16
+ // `open` is the public alias for the hook's controlled `isOpen`; when set it
17
+ // overrides hover/focus so the tooltip stays in the given state.
18
+ } = useDisclosure({
19
+ distance,
20
+ autoFit,
21
+ ...props,
22
+ isOpen: open ?? props.isOpen,
23
+ mode: "hover",
24
+ });
25
+ const triggerProps = getToggleProps();
26
+ const contentProps = getContentProps();
27
+ // The message is portalled to the client only. Rendering it on the server (or
28
+ // on the first client render) would differ from the post-mount portal output
29
+ // and force a hydration mismatch + full re-mount — which resets the fitment
30
+ // refs to null and re-triggers the unpositioned first frame. Deferring to a
31
+ // mounted gate makes the server and first client render identical (nothing
32
+ // at the call site); the tooltip mounts once, cleanly, after hydration.
33
+ const mounted = useIsMounted();
34
+ // The always-on arrow offset keeps the arrow pointing at the target centre
35
+ // for every placement, not only when auto-fit clamps.
36
+ const arrowStyle = arrowOffset
37
+ ? {
38
+ [arrowOffset.axis === "x"
39
+ ? "--tooltip-arrow-offset-left"
40
+ : "--tooltip-arrow-offset-top"]: `${arrowOffset.offset}px`,
41
+ }
42
+ : {};
43
+ const TooltipMessageElement = (_jsx(Tooltip, { id: popupId, className: [bestPosition?.positionName, messageElementClassName]
44
+ .filter(Boolean)
45
+ .join(" "), icon: icon, onPointerEnter: contentProps.onPointerEnter, ref: popupRef, style: {
46
+ ...messageElementStyle,
47
+ ...popupPositionStyle,
48
+ ...arrowStyle,
49
+ },
50
+ // Reveal only once a position has been resolved. Until `bestPosition`
51
+ // exists the popup would render at the fallback top:0/left:0 with no
52
+ // placement class (and so no arrow); gating the reveal on it means that
53
+ // unpositioned frame stays `visibility:hidden` and never paints — no
54
+ // visible 0,0 flash, and the open fade always runs from an anchored spot.
55
+ isOpen: isOpen && Boolean(bestPosition), children: Message }));
56
+ return (
57
+ // biome-ignore lint/a11y/noStaticElementInteractions: the wrapper forwards pointer/focus to the tooltip trigger
58
+ _jsxs("span", { className: [componentCssClassName, className].filter(Boolean).join(" "), style: style, onFocus: triggerProps.onFocus, onBlur: triggerProps.onBlur, onPointerEnter: triggerProps.onPointerEnter, onPointerLeave: triggerProps.onPointerLeave, children: [_jsx("span", { id: targetElementId, style: targetElementStyle, className: ["target", targetElementClassName].filter(Boolean).join(" "), ref: targetRef, "aria-describedby": popupId, children: children }), mounted
59
+ ? createPortal(TooltipMessageElement, parentElement || document.body)
60
+ : null] }));
61
+ };
62
+ /**
63
+ * A higher-order component that wraps a component with a tooltip. It is the
64
+ * single public tooltip primitive: it owns the engine (hover-mode
65
+ * {@link useDisclosure}, client-only portal, arrow positioning) and renders the
66
+ * wrapped component as the tooltip target.
67
+ * @param Component The component type to wrap.
68
+ * @param Message The content of the tooltip.
69
+ * @param popupProps Tooltip options — positioning, sizing, timing, plus `open`,
70
+ * `icon`, `distance`, `autoFit`, `messageElementStyle`, etc.
8
71
  */
9
72
  const withTooltip = (Component, Message, popupProps = {}) => {
10
73
  const WrappedComponent = (props) => {
11
- return (_jsx(TooltipArea, { Message: Message, ...popupProps, children: _jsx(Component, { ...props }) }));
74
+ return (_jsx(TooltipEngine, { Message: Message, ...popupProps, children: _jsx(Component, { ...props }) }));
12
75
  };
13
76
  // Set the displayName for easier debugging
14
77
  WrappedComponent.displayName = `withTooltip(${Component.displayName || Component.name || "Component"})`;
@@ -1 +1 @@
1
- {"version":3,"file":"withTooltip.js","sourceRoot":"","sources":["../../../../../src/lib/component/Tooltip/withTooltip.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAW5D;;;;;GAKG;AACH,MAAM,WAAW,GAAG,CAClB,SAAgC,EAChC,OAAkB,EAClB,aAAiC,EAAE,EACvB,EAAE;IACd,MAAM,gBAAgB,GAAG,CAAC,KAAa,EAAwB,EAAE;QAC/D,OAAO,CACL,KAAC,WAAW,IAAC,OAAO,EAAE,OAAO,KAAM,UAAU,YAC3C,KAAC,SAAS,OAAK,KAAK,GAAI,GACZ,CACf,CAAC;IACJ,CAAC,CAAC;IAEF,2CAA2C;IAC3C,gBAAgB,CAAC,WAAW,GAAG,eAC7B,SAAS,CAAC,WAAW,IAAI,SAAS,CAAC,IAAI,IAAI,WAC7C,GAAG,CAAC;IAEJ,OAAO,gBAAgB,CAAC;AAC1B,CAAC,CAAC;AAEF,eAAe,WAAW,CAAC"}
1
+ {"version":3,"file":"withTooltip.js","sourceRoot":"","sources":["../../../../../src/lib/component/Tooltip/withTooltip.tsx"],"names":[],"mappings":";AAOA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACnE,OAAO,OAAO,MAAM,cAAc,CAAC;AAGnC,OAAO,cAAc,CAAC;AAEtB,MAAM,qBAAqB,GAAG,iBAAiB,CAAC;AAEhD;;;;;;GAMG;AACH,MAAM,aAAa,GAAG,CAAC,EACrB,QAAQ,EACR,KAAK,EACL,SAA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AA2C;IAC3C,gBAAgB,CAAC,WAAW,GAAG,eAC7B,SAAS,CAAC,WAAW,IAAI,SAAS,CAAC,IAAI,IAAI,WAC7C,GAAG,CAAC;IAEJ,OAAO,gBAAgB,CAAC;AAC1B,CAAC,CAAC;AAEF,eAAe,WAAW,CAAC"}
@@ -0,0 +1,49 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import "./styles.css";
3
+ const componentCssClassName = "ds cards subgrid";
4
+ /**
5
+ * Cards — lays out a set of `Card`s on a shared grid so that not only the cards
6
+ * themselves, but each card's SECTIONS (image, header, content, footer) line up
7
+ * across the row.
8
+ *
9
+ * @remarks
10
+ * **Requires a top-level grid.** `Cards` is a `.subgrid`: it inherits the column
11
+ * tracks of the nearest parent `.grid` rather than defining its own. Wrap it in
12
+ * a `.grid` (e.g. the `grid()` storybook decorator or the `grid` addon param,
13
+ * the same way Accordion or a form field opts in). Outside a grid it degrades to
14
+ * a plain block — still renders, just without column alignment.
15
+ *
16
+ * **Two-level subgrid.** The parent grid supplies the columns; `Cards` inherits
17
+ * them and defines the shared section ROW tracks; each `Card` spans `cardSpan`
18
+ * columns and is itself a row-subgrid, so its sections snap to the shared
19
+ * tracks. See `styles.css` for the full model.
20
+ *
21
+ * **`cardSpan`** is the number of master columns each card spans (not a pixel
22
+ * width) — use multiples of 2/4 so cards tile evenly into the 4/8/12-column
23
+ * responsive grid.
24
+ *
25
+ * @example
26
+ * ```tsx
27
+ * // inside a `.grid` context (decorator/addon)
28
+ * <Cards cardSpan={4}>
29
+ * <Card>…</Card>
30
+ * <Card>…</Card>
31
+ * <Card>…</Card>
32
+ * </Cards>
33
+ * ```
34
+ *
35
+ * @implements dso:global.group.cards
36
+ * @returns {ReactElement} the Cards group
37
+ */
38
+ const Cards = ({ className, children, cardSpan = 1, style, ...props }) => {
39
+ // Guard the column span: a 0/negative/NaN/non-integer would produce an invalid
40
+ // `span …` and break the layout. At least 1.
41
+ const span = Math.max(1, Math.floor(Number(cardSpan) || 1));
42
+ const cardsStyle = {
43
+ ...style,
44
+ "--card-span": span,
45
+ };
46
+ return (_jsx("div", { className: [componentCssClassName, className].filter(Boolean).join(" "), style: cardsStyle, ...props, children: children }));
47
+ };
48
+ export default Cards;
49
+ //# sourceMappingURL=Cards.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Cards.js","sourceRoot":"","sources":["../../../../../src/lib/group/Cards/Cards.tsx"],"names":[],"mappings":";AAEA,OAAO,cAAc,CAAC;AAEtB,MAAM,qBAAqB,GAAG,kBAAkB,CAAC;AAEjD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,MAAM,KAAK,GAAG,CAAC,EACb,SAAS,EACT,QAAQ,EACR,QAAQ,GAAG,CAAC,EACZ,KAAK,EACL,GAAG,KAAK,EACG,EAAgB,EAAE;IAC7B,+EAA+E;IAC/E,6CAA6C;IAC7C,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAE5D,MAAM,UAAU,GAAkB;QAChC,GAAG,KAAK;QACR,aAAa,EAAE,IAAI;KACH,CAAC;IAEnB,OAAO,CACL,cACE,SAAS,EAAE,CAAC,qBAAqB,EAAE,SAAS,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EACvE,KAAK,EAAE,UAAU,KACb,KAAK,YAER,QAAQ,GACL,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,KAAK,CAAC"}
@@ -0,0 +1,3 @@
1
+ // Generated by @canonical/summon-component:react v0.1.0
2
+ export { default as Cards } from "./Cards.js";
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/lib/group/Cards/index.ts"],"names":[],"mappings":"AAAA,wDAAwD;AAExD,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,YAAY,CAAC"}
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Cards — a group that lays out `Card`s on a shared grid so their sections line
3
+ * up ACROSS the row, not just within each card.
4
+ *
5
+ * ── How the alignment works ─────────────────────────────────────────────────
6
+ * A plain grid of cards only matches heights by luck — a two-line card and a
7
+ * one-line card end up different heights. `Cards` fixes that: it defines FOUR
8
+ * shared section row tracks (image / header / content / footer), and each `Card`
9
+ * is a ROW SUBGRID that spans those four tracks (its own grid logic — see the
10
+ * Card styles). So the tallest section in a track sizes it for every card on the
11
+ * band, and footers pin to a common bottom line. The four-track vocabulary is
12
+ * fixed because a Card only ever has those four section types; a card missing a
13
+ * section just leaves that track empty for itself.
14
+ *
15
+ * Cards are single grid items (each spans `--card-span` columns × 4 rows) and
16
+ * auto-place in DOM order, so they tile into columns and wrap to a fresh
17
+ * four-row band when the row is full — no overlap.
18
+ *
19
+ * ── Requires a top-level grid ───────────────────────────────────────────────
20
+ * `Cards` is a `.subgrid`: it inherits the column tracks of the nearest parent
21
+ * `.grid` (via the `grid` story param / addon). Outside a grid it degrades to a
22
+ * plain block.
23
+ *
24
+ * ── --card-span (columns per card) ──────────────────────────────────────────
25
+ * `--card-span` (the `cardSpan` prop) is the NUMBER OF PARENT COLUMNS each card
26
+ * spans — not a pixel width. `1` (default) packs the most cards per row; use 2
27
+ * or 4 for fewer, wider cards on the 4/8/12-column responsive grid.
28
+ */
29
+
30
+ .ds.cards {
31
+ display: grid;
32
+ grid-template-columns: subgrid;
33
+ /* The Cards container itself always spans the full master grid; `--card-span`
34
+ * (the per-card column span) inherits down to each Card, it is NOT the
35
+ * container's own span. */
36
+ grid-column: 1 / -1;
37
+
38
+ /* The four shared section tracks (image / header / content / footer), repeated
39
+ * for every wrapped band via `grid-auto-rows`. They are ALL `auto`, so each
40
+ * track sizes to the tallest of that section across the row — every card takes
41
+ * its intrinsic height plus only the extra needed to align with the tallest
42
+ * card on the band (no `1fr`, which would stretch a card to fill surplus
43
+ * container height). Cards each `span 4` rows and auto-place across the columns
44
+ * (DOM order), wrapping to the next band. */
45
+ grid-auto-flow: row;
46
+ grid-auto-rows: auto;
47
+
48
+ /* Bands take their intrinsic height and pack to the top — never stretch to
49
+ * fill a taller container. */
50
+ align-self: start;
51
+ align-content: start;
52
+
53
+ gap: var(--grid-row-gap, var(--grid-gutter))
54
+ var(--grid-column-gap, var(--grid-gutter));
55
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../src/lib/group/Cards/types.ts"],"names":[],"mappings":""}
@@ -1,3 +1,4 @@
1
1
  // ds:Group tier barrel: sets of components that operate together.
2
+ export * from "./Cards/index.js";
2
3
  export * from "./KeyboardKeys/index.js";
3
4
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/lib/group/index.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAClE,cAAc,yBAAyB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/lib/group/index.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAElE,cAAc,kBAAkB,CAAC;AACjC,cAAc,yBAAyB,CAAC"}
@@ -1,6 +1,7 @@
1
1
  export * from "./useContextualMenu/index.js";
2
2
  export * from "./useDelayedToggle/index.js";
3
3
  export * from "./useDisclosure/index.js";
4
+ export * from "./useIsMounted/index.js";
4
5
  export * from "./useResizeObserver/index.js";
5
6
  export * from "./useWindowDimensions/index.js";
6
7
  export * from "./useWindowFitment/index.js";