@canonical/react-ds-global 0.37.0 → 0.38.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 (192) hide show
  1. package/README.md +72 -0
  2. package/dist/esm/lib/_work_in_progress/Announcement/styles.css +51 -47
  3. package/dist/esm/lib/_work_in_progress/CategoriesSection/common/Category/styles.css +21 -17
  4. package/dist/esm/lib/_work_in_progress/CategoriesSection/styles.css +16 -12
  5. package/dist/esm/lib/_work_in_progress/ChatSection/styles.css +22 -18
  6. package/dist/esm/lib/_work_in_progress/DescriptionSection/styles.css +14 -10
  7. package/dist/esm/lib/_work_in_progress/IconSection/styles.css +18 -14
  8. package/dist/esm/lib/_work_in_progress/Label/styles.css +36 -32
  9. package/dist/esm/lib/_work_in_progress/Link/styles.css +32 -28
  10. package/dist/esm/lib/_work_in_progress/Rule/styles.css +21 -14
  11. package/dist/esm/lib/_work_in_progress/Section/styles.css +66 -62
  12. package/dist/esm/lib/_work_in_progress/SkipLink/styles.css +35 -32
  13. package/dist/esm/lib/_work_in_progress/TSection/styles.css +26 -22
  14. package/dist/esm/lib/_work_in_progress/grid/ApplicationLayout/ApplicationLayout.js +4 -1
  15. package/dist/esm/lib/_work_in_progress/grid/ApplicationLayout/ApplicationLayout.js.map +1 -1
  16. package/dist/esm/lib/_work_in_progress/grid/ApplicationLayout/styles.css +21 -17
  17. package/dist/esm/lib/_work_in_progress/grid/GridCard/GridCard.js +4 -1
  18. package/dist/esm/lib/_work_in_progress/grid/GridCard/GridCard.js.map +1 -1
  19. package/dist/esm/lib/_work_in_progress/grid/GridCard/styles.css +8 -4
  20. package/dist/esm/lib/_work_in_progress/grid/InnerGridDemo/styles.css +38 -33
  21. package/dist/esm/lib/_work_in_progress/grid/SettingsView/SettingsView.js +4 -1
  22. package/dist/esm/lib/_work_in_progress/grid/SettingsView/SettingsView.js.map +1 -1
  23. package/dist/esm/lib/_work_in_progress/grid/SettingsView/styles.css +23 -19
  24. package/dist/esm/lib/component/Accordion/common/Item/styles.css +305 -299
  25. package/dist/esm/lib/component/Accordion/styles.css +35 -31
  26. package/dist/esm/lib/component/Badge/hooks/useBadge.js +1 -1
  27. package/dist/esm/lib/component/Badge/hooks/useBadge.js.map +1 -1
  28. package/dist/esm/lib/component/Badge/styles.css +45 -41
  29. package/dist/esm/lib/component/Breadcrumbs/Breadcrumbs.js +1 -1
  30. package/dist/esm/lib/component/Breadcrumbs/Breadcrumbs.js.map +1 -1
  31. package/dist/esm/lib/component/Breadcrumbs/common/Item/styles.css +69 -65
  32. package/dist/esm/lib/component/Breadcrumbs/styles.css +30 -26
  33. package/dist/esm/lib/component/Button/styles.css +293 -260
  34. package/dist/esm/lib/component/Card/common/Content/styles.css +27 -23
  35. package/dist/esm/lib/component/Card/common/Footer/styles.css +30 -26
  36. package/dist/esm/lib/component/Card/common/Header/styles.css +25 -21
  37. package/dist/esm/lib/component/Card/common/Image/styles.css +8 -4
  38. package/dist/esm/lib/component/Card/styles.css +77 -73
  39. package/dist/esm/lib/component/Chip/Chip.js.map +1 -1
  40. package/dist/esm/lib/component/Chip/styles.css +105 -101
  41. package/dist/esm/lib/component/ContextualMenu/ContextualMenu.js +29 -20
  42. package/dist/esm/lib/component/ContextualMenu/ContextualMenu.js.map +1 -1
  43. package/dist/esm/lib/component/ContextualMenu/common/Item/Item.js +25 -2
  44. package/dist/esm/lib/component/ContextualMenu/common/Item/Item.js.map +1 -1
  45. package/dist/esm/lib/component/ContextualMenu/common/Item/styles.css +116 -106
  46. package/dist/esm/lib/component/ContextualMenu/common/SubMenu/SubMenu.js +29 -9
  47. package/dist/esm/lib/component/ContextualMenu/common/SubMenu/SubMenu.js.map +1 -1
  48. package/dist/esm/lib/component/ContextualMenu/styles.css +74 -72
  49. package/dist/esm/lib/component/Icon/styles.css +24 -20
  50. package/dist/esm/lib/component/InlineCode/styles.css +19 -15
  51. package/dist/esm/lib/component/KeyboardKey/styles.css +44 -40
  52. package/dist/esm/lib/component/Popover/Popover.js.map +1 -1
  53. package/dist/esm/lib/component/Popover/styles.css +59 -52
  54. package/dist/esm/lib/component/Tabs/common/Item/styles.css +80 -76
  55. package/dist/esm/lib/component/Tabs/styles.css +36 -32
  56. package/dist/esm/lib/component/Tile/common/Content/styles.css +28 -24
  57. package/dist/esm/lib/component/Tile/common/Header/styles.css +28 -24
  58. package/dist/esm/lib/component/Tile/styles.css +31 -27
  59. package/dist/esm/lib/component/Tooltip/styles.css +213 -208
  60. package/dist/esm/lib/group/Cards/styles.css +26 -22
  61. package/dist/esm/lib/group/KeyboardKeys/styles.css +14 -10
  62. package/dist/esm/lib/hooks/useContextualMenu/index.js +1 -0
  63. package/dist/esm/lib/hooks/useContextualMenu/index.js.map +1 -1
  64. package/dist/esm/lib/hooks/useContextualMenu/isMenuSeparator.js +11 -0
  65. package/dist/esm/lib/hooks/useContextualMenu/isMenuSeparator.js.map +1 -0
  66. package/dist/esm/lib/hooks/useContextualMenu/useContextualMenu.js +54 -34
  67. package/dist/esm/lib/hooks/useContextualMenu/useContextualMenu.js.map +1 -1
  68. package/dist/esm/lib/hooks/useDisclosure/useDisclosure.js.map +1 -1
  69. package/dist/esm/lib/hooks/useWindowDimensions/useWindowDimensions.js +1 -1
  70. package/dist/esm/lib/hooks/useWindowDimensions/useWindowDimensions.js.map +1 -1
  71. package/dist/esm/lib/hooks/useWindowFitment/useWindowFitment.js +3 -0
  72. package/dist/esm/lib/hooks/useWindowFitment/useWindowFitment.js.map +1 -1
  73. package/dist/esm/lib/index.css +79 -0
  74. package/dist/esm/lib/pattern/Modal/Context.js +10 -0
  75. package/dist/esm/lib/pattern/Modal/Context.js.map +1 -0
  76. package/dist/esm/lib/pattern/Modal/Provider.js +103 -0
  77. package/dist/esm/lib/pattern/Modal/Provider.js.map +1 -0
  78. package/dist/esm/lib/pattern/Modal/common/Content/Content.js +15 -0
  79. package/dist/esm/lib/pattern/Modal/common/Content/Content.js.map +1 -0
  80. package/dist/esm/lib/pattern/Modal/common/Content/index.js +3 -0
  81. package/dist/esm/lib/pattern/Modal/common/Content/index.js.map +1 -0
  82. package/dist/esm/lib/pattern/Modal/common/Content/styles.css +37 -0
  83. package/dist/esm/lib/pattern/Modal/common/Content/types.js +2 -0
  84. package/dist/esm/lib/pattern/Modal/common/Content/types.js.map +1 -0
  85. package/dist/esm/lib/pattern/Modal/common/Footer/Footer.js +16 -0
  86. package/dist/esm/lib/pattern/Modal/common/Footer/Footer.js.map +1 -0
  87. package/dist/esm/lib/pattern/Modal/common/Footer/index.js +3 -0
  88. package/dist/esm/lib/pattern/Modal/common/Footer/index.js.map +1 -0
  89. package/dist/esm/lib/pattern/Modal/common/Footer/styles.css +57 -0
  90. package/dist/esm/lib/pattern/Modal/common/Footer/types.js +2 -0
  91. package/dist/esm/lib/pattern/Modal/common/Footer/types.js.map +1 -0
  92. package/dist/esm/lib/pattern/Modal/common/Header/Header.js +27 -0
  93. package/dist/esm/lib/pattern/Modal/common/Header/Header.js.map +1 -0
  94. package/dist/esm/lib/pattern/Modal/common/Header/index.js +3 -0
  95. package/dist/esm/lib/pattern/Modal/common/Header/index.js.map +1 -0
  96. package/dist/esm/lib/pattern/Modal/common/Header/styles.css +79 -0
  97. package/dist/esm/lib/pattern/Modal/common/Header/types.js +2 -0
  98. package/dist/esm/lib/pattern/Modal/common/Header/types.js.map +1 -0
  99. package/dist/esm/lib/pattern/Modal/common/index.js +5 -0
  100. package/dist/esm/lib/pattern/Modal/common/index.js.map +1 -0
  101. package/dist/esm/lib/pattern/Modal/hooks/useModalContext.js +11 -0
  102. package/dist/esm/lib/pattern/Modal/hooks/useModalContext.js.map +1 -0
  103. package/dist/esm/lib/pattern/Modal/hooks/useModalState.js +15 -0
  104. package/dist/esm/lib/pattern/Modal/hooks/useModalState.js.map +1 -0
  105. package/dist/esm/lib/pattern/Modal/index.js +4 -0
  106. package/dist/esm/lib/pattern/Modal/index.js.map +1 -0
  107. package/dist/esm/lib/pattern/Modal/styles.css +119 -0
  108. package/dist/esm/lib/pattern/Modal/types.js +2 -0
  109. package/dist/esm/lib/pattern/Modal/types.js.map +1 -0
  110. package/dist/esm/lib/pattern/Modal/withModal.js +102 -0
  111. package/dist/esm/lib/pattern/Modal/withModal.js.map +1 -0
  112. package/dist/esm/lib/pattern/Timeline/common/Content/styles.css +16 -12
  113. package/dist/esm/lib/pattern/Timeline/common/Event/styles.css +116 -112
  114. package/dist/esm/lib/pattern/Timeline/styles.css +16 -12
  115. package/dist/esm/lib/pattern/index.js +1 -0
  116. package/dist/esm/lib/pattern/index.js.map +1 -1
  117. package/dist/esm/lib/subcomponent/Spinner/styles.css +38 -34
  118. package/dist/types/lib/_work_in_progress/grid/ApplicationLayout/ApplicationLayout.d.ts.map +1 -1
  119. package/dist/types/lib/_work_in_progress/grid/GridCard/GridCard.d.ts.map +1 -1
  120. package/dist/types/lib/_work_in_progress/grid/SettingsView/SettingsView.d.ts.map +1 -1
  121. package/dist/types/lib/component/Badge/types.d.ts +1 -1
  122. package/dist/types/lib/component/Badge/types.d.ts.map +1 -1
  123. package/dist/types/lib/component/Breadcrumbs/types.d.ts +2 -2
  124. package/dist/types/lib/component/Breadcrumbs/types.d.ts.map +1 -1
  125. package/dist/types/lib/component/Chip/Chip.d.ts +2 -2
  126. package/dist/types/lib/component/Chip/Chip.d.ts.map +1 -1
  127. package/dist/types/lib/component/Chip/types.d.ts +10 -8
  128. package/dist/types/lib/component/Chip/types.d.ts.map +1 -1
  129. package/dist/types/lib/component/ContextualMenu/ContextualMenu.d.ts +4 -4
  130. package/dist/types/lib/component/ContextualMenu/ContextualMenu.d.ts.map +1 -1
  131. package/dist/types/lib/component/ContextualMenu/common/Item/Item.d.ts.map +1 -1
  132. package/dist/types/lib/component/ContextualMenu/common/MenuContext.d.ts +1 -1
  133. package/dist/types/lib/component/ContextualMenu/common/MenuContext.d.ts.map +1 -1
  134. package/dist/types/lib/component/ContextualMenu/common/SubMenu/SubMenu.d.ts +9 -7
  135. package/dist/types/lib/component/ContextualMenu/common/SubMenu/SubMenu.d.ts.map +1 -1
  136. package/dist/types/lib/component/ContextualMenu/types.d.ts +14 -6
  137. package/dist/types/lib/component/ContextualMenu/types.d.ts.map +1 -1
  138. package/dist/types/lib/component/Tabs/types.d.ts +2 -2
  139. package/dist/types/lib/component/Tabs/types.d.ts.map +1 -1
  140. package/dist/types/lib/hooks/useContextualMenu/index.d.ts +1 -0
  141. package/dist/types/lib/hooks/useContextualMenu/index.d.ts.map +1 -1
  142. package/dist/types/lib/hooks/useContextualMenu/isMenuSeparator.d.ts +13 -0
  143. package/dist/types/lib/hooks/useContextualMenu/isMenuSeparator.d.ts.map +1 -0
  144. package/dist/types/lib/hooks/useContextualMenu/types.d.ts +45 -15
  145. package/dist/types/lib/hooks/useContextualMenu/types.d.ts.map +1 -1
  146. package/dist/types/lib/hooks/useContextualMenu/useContextualMenu.d.ts +5 -6
  147. package/dist/types/lib/hooks/useContextualMenu/useContextualMenu.d.ts.map +1 -1
  148. package/dist/types/lib/hooks/useDisclosure/types.d.ts +7 -2
  149. package/dist/types/lib/hooks/useDisclosure/types.d.ts.map +1 -1
  150. package/dist/types/lib/hooks/useDisclosure/useDisclosure.d.ts +1 -1
  151. package/dist/types/lib/hooks/useDisclosure/useDisclosure.d.ts.map +1 -1
  152. package/dist/types/lib/hooks/useWindowFitment/types.d.ts +12 -3
  153. package/dist/types/lib/hooks/useWindowFitment/types.d.ts.map +1 -1
  154. package/dist/types/lib/hooks/useWindowFitment/useWindowFitment.d.ts +1 -1
  155. package/dist/types/lib/hooks/useWindowFitment/useWindowFitment.d.ts.map +1 -1
  156. package/dist/types/lib/pattern/Modal/Context.d.ts +10 -0
  157. package/dist/types/lib/pattern/Modal/Context.d.ts.map +1 -0
  158. package/dist/types/lib/pattern/Modal/Provider.d.ts +63 -0
  159. package/dist/types/lib/pattern/Modal/Provider.d.ts.map +1 -0
  160. package/dist/types/lib/pattern/Modal/common/Content/Content.d.ts +17 -0
  161. package/dist/types/lib/pattern/Modal/common/Content/Content.d.ts.map +1 -0
  162. package/dist/types/lib/pattern/Modal/common/Content/index.d.ts +3 -0
  163. package/dist/types/lib/pattern/Modal/common/Content/index.d.ts.map +1 -0
  164. package/dist/types/lib/pattern/Modal/common/Content/types.d.ts +15 -0
  165. package/dist/types/lib/pattern/Modal/common/Content/types.d.ts.map +1 -0
  166. package/dist/types/lib/pattern/Modal/common/Footer/Footer.d.ts +18 -0
  167. package/dist/types/lib/pattern/Modal/common/Footer/Footer.d.ts.map +1 -0
  168. package/dist/types/lib/pattern/Modal/common/Footer/index.d.ts +3 -0
  169. package/dist/types/lib/pattern/Modal/common/Footer/index.d.ts.map +1 -0
  170. package/dist/types/lib/pattern/Modal/common/Footer/types.d.ts +16 -0
  171. package/dist/types/lib/pattern/Modal/common/Footer/types.d.ts.map +1 -0
  172. package/dist/types/lib/pattern/Modal/common/Header/Header.d.ts +24 -0
  173. package/dist/types/lib/pattern/Modal/common/Header/Header.d.ts.map +1 -0
  174. package/dist/types/lib/pattern/Modal/common/Header/index.d.ts +3 -0
  175. package/dist/types/lib/pattern/Modal/common/Header/index.d.ts.map +1 -0
  176. package/dist/types/lib/pattern/Modal/common/Header/types.d.ts +36 -0
  177. package/dist/types/lib/pattern/Modal/common/Header/types.d.ts.map +1 -0
  178. package/dist/types/lib/pattern/Modal/common/index.d.ts +4 -0
  179. package/dist/types/lib/pattern/Modal/common/index.d.ts.map +1 -0
  180. package/dist/types/lib/pattern/Modal/hooks/useModalContext.d.ts +4 -0
  181. package/dist/types/lib/pattern/Modal/hooks/useModalContext.d.ts.map +1 -0
  182. package/dist/types/lib/pattern/Modal/hooks/useModalState.d.ts +10 -0
  183. package/dist/types/lib/pattern/Modal/hooks/useModalState.d.ts.map +1 -0
  184. package/dist/types/lib/pattern/Modal/index.d.ts +4 -0
  185. package/dist/types/lib/pattern/Modal/index.d.ts.map +1 -0
  186. package/dist/types/lib/pattern/Modal/types.d.ts +122 -0
  187. package/dist/types/lib/pattern/Modal/types.d.ts.map +1 -0
  188. package/dist/types/lib/pattern/Modal/withModal.d.ts +74 -0
  189. package/dist/types/lib/pattern/Modal/withModal.d.ts.map +1 -0
  190. package/dist/types/lib/pattern/index.d.ts +1 -0
  191. package/dist/types/lib/pattern/index.d.ts.map +1 -1
  192. package/package.json +28 -18
@@ -1,231 +1,236 @@
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;
1
+ /* Layer: ds.components.global (@canonical/styles README, "Cascade layers"). */
10
2
 
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;
3
+ @layer ds.components.global {
4
+ /* The tooltip engine wrapper (rendered by `withTooltip`) — a relatively
5
+ positioned inline span around the target. The `.target` child carries the
6
+ measuring ref and strips margins from its content so placement is exact. */
7
+ .ds.tooltip-area {
8
+ position: relative;
9
+ & .target {
10
+ cursor: pointer;
11
+ position: relative;
12
+ display: inline-block;
13
+
14
+ & > * {
15
+ /* biome-ignore lint/complexity/noImportantStyles: The tooltip targets must have no margin in order for tooltip placements to work correctly */
16
+ margin: 0 !important;
17
+ }
14
18
  }
15
19
  }
16
- }
17
-
18
- /* Component tokens — sourced from @canonical/design-tokens.
19
- The tooltip runs on the `contrasted` surface so its colours invert against
20
- the ambient theme (dark chip on a light UI, light chip on a dark UI). The
21
- surface channels (--surface-color-*) are read directly on the .contrasted
22
- element below, NOT via a :root intermediate (which would see them unset and
23
- fall back to the base colour). */
24
- :root {
25
- --tooltip-border-radius: 0;
26
- --tooltip-margin-left: 0;
27
- --tooltip-margin-bottom: 0;
28
- /* Figma: py = dimension-100 (8px), px = dimension-200 (16px). */
29
- --tooltip-padding-vertical: var(--dimension-100);
30
- --tooltip-padding-horizontal: var(--dimension-200);
31
- --tooltip-border-width: 0;
32
- /* Figma: text-secondary (14px / 20px line-height). */
33
- --tooltip-font-size: var(--font-size-small, 14px);
34
- --tooltip-font-weight: var(--font-weight-default);
35
- --tooltip-line-height: var(--line-height-small, 20px);
36
- --tooltip-max-width: 284px;
37
- /* Gap between an optional leading icon and the text (dimension-100). */
38
- --tooltip-gap: var(--dimension-100);
39
-
40
- /* Arrow geometry, independent of `distance` (the gap to the trigger).
41
- Figma: 14px base (dimension-175) across the edge, 8px depth pointing out. */
42
- --tooltip-arrow-width: var(--dimension-175, 14px);
43
- --tooltip-arrow-depth: var(--dimension-100, 8px);
44
-
45
- /* Duration of the open/close fade. */
46
- --tooltip-motion-duration: 0.1s;
47
- }
48
20
 
49
- /* component variables
50
- --tooltip-color-background: background color of the tooltip
51
- --tooltip-color-text: text color of the tooltip
52
- --tooltip-color-border: border color of the tooltip
53
-
54
- --tooltip-margin-left: left margin of the tooltip
55
- --tooltip-margin-bottom: bottom margin of the tooltip
56
- --tooltip-padding-vertical: vertical padding of the tooltip
57
- --tooltip-padding-horizontal: horizontal padding of the tooltip
58
- --tooltip-font-size: font size of the tooltip
59
- --tooltip-font-weight: font weight of the tooltip
60
- --tooltip-line-height: line height of the tooltip
61
-
62
- --tooltip-spacing-arrow-size: size of the arrow (independent of `distance`)
63
-
64
- --tooltip-arrow-offset-left: offset of the arrow along the x-axis (top/bottom placements)
65
- --tooltip-arrow-offset-top: offset of the arrow along the y-axis (left/right placements)
66
- */
67
-
68
- .ds.tooltip {
69
- /* The tooltip's own background colour, read from the contrasted surface on
70
- this element (so the arrow, which reuses it, is coloured correctly too). */
71
- --tooltip-color-background: var(
72
- --surface-color-background,
73
- var(--color-background)
74
- );
75
- --tooltip-color-text: var(--surface-color-text, var(--color-text));
76
-
77
- /* Figma arrow: 14px across the edge (base), 8px deep (point). The base is
78
- built from two half-width transparent borders; the depth from the coloured
79
- border on the pointing side. */
80
- --tooltip-arrow-half-width: calc(var(--tooltip-arrow-width) / 2);
81
- /* Centre of the edge. `left`/`top` positions the ZERO-width pseudo-element's
82
- origin, but its two half-width side borders render the triangle from that
83
- origin OUTWARD, so the visible apex sits half-a-width past `left`. To centre
84
- the apex on the box we therefore pull the origin back by half-width:
85
- `50% - half-width`. (Verified by pixel measurement: plain `50%` renders the
86
- apex +7px off-centre.) The magnetic offset then shifts from this centre. */
87
- --tooltip-arrow-middle: calc(50% - var(--tooltip-arrow-half-width));
88
- --tooltip-arrow-edge: calc(-1 * var(--tooltip-arrow-depth));
89
- --tooltip-arrow-offset-left: 0px;
90
- --tooltip-arrow-offset-top: 0px;
91
-
92
- color: var(--tooltip-color-text);
93
- background-color: var(--tooltip-color-background);
94
- border-color: var(--tooltip-color-background);
95
- border-style: solid;
96
- border-radius: var(--tooltip-border-radius);
97
- border-width: var(--tooltip-border-width, 1px);
98
- font-size: var(--tooltip-font-size, var(--font-size-small));
99
- font-weight: var(--tooltip-font-weight, var(--font-weight-default));
100
- line-height: var(--tooltip-line-height, var(--line-height-small));
101
- margin-block-end: var(--tooltip-margin-bottom, 0);
102
- margin-inline-end: var(--tooltip-margin-left, 0);
103
- padding-block: var(--tooltip-padding-vertical, 5px);
104
- padding-inline: var(--tooltip-padding-horizontal, 10px);
105
- text-align: left;
106
- text-decoration: initial;
107
- pointer-events: auto;
108
- /* The box stays `inline-block` — it is the positioning context for the arrow
109
- `::before`, and its `50%` centring must resolve against this box. The
110
- icon+text layout lives in an inner `.content` flex row so the pseudo-element
111
- is never a flex item (which would shift the arrow and reserve gap for it). */
112
- display: inline-block;
113
- max-width: var(--tooltip-max-width);
114
- position: fixed;
115
- /* MUST stay `visible`: the arrow is a `::before` positioned just outside the
116
- box (e.g. bottom: -8px). Any `overflow: auto | hidden | clip` clips it and
117
- the triangle disappears entirely. */
118
- overflow: visible;
119
-
120
- /* Inner row: optional leading icon before the text, top-aligned with the
121
- first line (Figma). Without an icon it is just the text. */
122
- & > .content {
123
- display: flex;
124
- align-items: flex-start;
125
- gap: var(--tooltip-gap);
21
+ /* Component tokens — sourced from @canonical/design-tokens.
22
+ The tooltip runs on the `contrasted` surface so its colours invert against
23
+ the ambient theme (dark chip on a light UI, light chip on a dark UI). The
24
+ surface channels (--surface-color-*) are read directly on the .contrasted
25
+ element below, NOT via a :root intermediate (which would see them unset and
26
+ fall back to the base colour). */
27
+ :root {
28
+ --tooltip-border-radius: 0;
29
+ --tooltip-margin-left: 0;
30
+ --tooltip-margin-bottom: 0;
31
+ /* Figma: py = dimension-100 (8px), px = dimension-200 (16px). */
32
+ --tooltip-padding-vertical: var(--dimension-100);
33
+ --tooltip-padding-horizontal: var(--dimension-200);
34
+ --tooltip-border-width: 0;
35
+ /* Figma: text-secondary (14px / 20px line-height). */
36
+ --tooltip-font-size: var(--font-size-small, 14px);
37
+ --tooltip-font-weight: var(--font-weight-default);
38
+ --tooltip-line-height: var(--line-height-small, 20px);
39
+ --tooltip-max-width: 284px;
40
+ /* Gap between an optional leading icon and the text (dimension-100). */
41
+ --tooltip-gap: var(--dimension-100);
42
+
43
+ /* Arrow geometry, independent of `distance` (the gap to the trigger).
44
+ Figma: 14px base (dimension-175) across the edge, 8px depth pointing out. */
45
+ --tooltip-arrow-width: var(--dimension-175, 14px);
46
+ --tooltip-arrow-depth: var(--dimension-100, 8px);
47
+
48
+ /* Duration of the open/close fade. */
49
+ --tooltip-motion-duration: 0.1s;
126
50
  }
127
51
 
128
- /* Leading icon: fixed 16px box, top-aligned with the first text line, purely
129
- decorative (the text carries the meaning). */
130
- & .icon {
131
- flex: 0 0 auto;
132
- display: inline-flex;
133
- align-items: center;
134
- justify-content: center;
135
- inline-size: var(--dimension-200, 16px);
136
- block-size: var(--tooltip-line-height, 20px);
137
-
138
- & > svg {
139
- inline-size: var(--dimension-200, 16px);
140
- block-size: var(--dimension-200, 16px);
141
- }
142
- }
52
+ /* component variables
53
+ --tooltip-color-background: background color of the tooltip
54
+ --tooltip-color-text: text color of the tooltip
55
+ --tooltip-color-border: border color of the tooltip
143
56
 
144
- /* The text wraps at max-width (Figma shows multi-line) while honouring any
145
- explicit newlines in the message. */
146
- & .text {
147
- white-space: pre-wrap;
148
- }
57
+ --tooltip-margin-left: left margin of the tooltip
58
+ --tooltip-margin-bottom: bottom margin of the tooltip
59
+ --tooltip-padding-vertical: vertical padding of the tooltip
60
+ --tooltip-padding-horizontal: horizontal padding of the tooltip
61
+ --tooltip-font-size: font size of the tooltip
62
+ --tooltip-font-weight: font weight of the tooltip
63
+ --tooltip-line-height: line height of the tooltip
149
64
 
150
- /*
151
- CSS-only enter/exit animation. `allow-discrete` lets `visibility` (a discrete
152
- property) transition alongside `opacity`, and `@starting-style` gives the
153
- opening frame a starting opacity so the fade-in runs. No JavaScript timing.
65
+ --tooltip-spacing-arrow-size: size of the arrow (independent of `distance`)
66
+
67
+ --tooltip-arrow-offset-left: offset of the arrow along the x-axis (top/bottom placements)
68
+ --tooltip-arrow-offset-top: offset of the arrow along the y-axis (left/right placements)
154
69
  */
155
- opacity: 0;
156
- visibility: hidden;
157
- transition:
158
- opacity var(--tooltip-motion-duration) ease-in-out,
159
- visibility var(--tooltip-motion-duration) allow-discrete;
160
-
161
- &[aria-hidden="false"] {
162
- opacity: 1;
70
+
71
+ .ds.tooltip {
72
+ /* The tooltip's own background colour, read from the contrasted surface on
73
+ this element (so the arrow, which reuses it, is coloured correctly too). */
74
+ --tooltip-color-background: var(
75
+ --surface-color-background,
76
+ var(--color-background)
77
+ );
78
+ --tooltip-color-text: var(--surface-color-text, var(--color-text));
79
+
80
+ /* Figma arrow: 14px across the edge (base), 8px deep (point). The base is
81
+ built from two half-width transparent borders; the depth from the coloured
82
+ border on the pointing side. */
83
+ --tooltip-arrow-half-width: calc(var(--tooltip-arrow-width) / 2);
84
+ /* Centre of the edge. `left`/`top` positions the ZERO-width pseudo-element's
85
+ origin, but its two half-width side borders render the triangle from that
86
+ origin OUTWARD, so the visible apex sits half-a-width past `left`. To centre
87
+ the apex on the box we therefore pull the origin back by half-width:
88
+ `50% - half-width`. (Verified by pixel measurement: plain `50%` renders the
89
+ apex +7px off-centre.) The magnetic offset then shifts from this centre. */
90
+ --tooltip-arrow-middle: calc(50% - var(--tooltip-arrow-half-width));
91
+ --tooltip-arrow-edge: calc(-1 * var(--tooltip-arrow-depth));
92
+ --tooltip-arrow-offset-left: 0px;
93
+ --tooltip-arrow-offset-top: 0px;
94
+
95
+ color: var(--tooltip-color-text);
96
+ background-color: var(--tooltip-color-background);
97
+ border-color: var(--tooltip-color-background);
98
+ border-style: solid;
99
+ border-radius: var(--tooltip-border-radius);
100
+ border-width: var(--tooltip-border-width, 1px);
101
+ font-size: var(--tooltip-font-size, var(--font-size-small));
102
+ font-weight: var(--tooltip-font-weight, var(--font-weight-default));
103
+ line-height: var(--tooltip-line-height, var(--line-height-small));
104
+ margin-block-end: var(--tooltip-margin-bottom, 0);
105
+ margin-inline-end: var(--tooltip-margin-left, 0);
106
+ padding-block: var(--tooltip-padding-vertical, 5px);
107
+ padding-inline: var(--tooltip-padding-horizontal, 10px);
108
+ text-align: left;
109
+ text-decoration: initial;
163
110
  pointer-events: auto;
164
- visibility: visible;
111
+ /* The box stays `inline-block` — it is the positioning context for the arrow
112
+ `::before`, and its `50%` centring must resolve against this box. The
113
+ icon+text layout lives in an inner `.content` flex row so the pseudo-element
114
+ is never a flex item (which would shift the arrow and reserve gap for it). */
115
+ display: inline-block;
116
+ max-width: var(--tooltip-max-width);
117
+ position: fixed;
118
+ /* MUST stay `visible`: the arrow is a `::before` positioned just outside the
119
+ box (e.g. bottom: -8px). Any `overflow: auto | hidden | clip` clips it and
120
+ the triangle disappears entirely. */
121
+ overflow: visible;
122
+
123
+ /* Inner row: optional leading icon before the text, top-aligned with the
124
+ first line (Figma). Without an icon it is just the text. */
125
+ & > .content {
126
+ display: flex;
127
+ align-items: flex-start;
128
+ gap: var(--tooltip-gap);
129
+ }
165
130
 
166
- @starting-style {
167
- opacity: 0;
131
+ /* Leading icon: fixed 16px box, top-aligned with the first text line, purely
132
+ decorative (the text carries the meaning). */
133
+ & .icon {
134
+ flex: 0 0 auto;
135
+ display: inline-flex;
136
+ align-items: center;
137
+ justify-content: center;
138
+ inline-size: var(--dimension-200, 16px);
139
+ block-size: var(--tooltip-line-height, 20px);
140
+
141
+ & > svg {
142
+ inline-size: var(--dimension-200, 16px);
143
+ block-size: var(--dimension-200, 16px);
144
+ }
168
145
  }
169
- }
170
146
 
171
- &[aria-hidden="true"] {
147
+ /* The text wraps at max-width (Figma shows multi-line) while honouring any
148
+ explicit newlines in the message. */
149
+ & .text {
150
+ white-space: pre-wrap;
151
+ }
152
+
153
+ /*
154
+ CSS-only enter/exit animation. `allow-discrete` lets `visibility` (a discrete
155
+ property) transition alongside `opacity`, and `@starting-style` gives the
156
+ opening frame a starting opacity so the fade-in runs. No JavaScript timing.
157
+ */
172
158
  opacity: 0;
173
- pointer-events: none;
174
159
  visibility: hidden;
175
- }
160
+ transition:
161
+ opacity var(--tooltip-motion-duration) ease-in-out,
162
+ visibility var(--tooltip-motion-duration) allow-discrete;
163
+
164
+ &[aria-hidden="false"] {
165
+ opacity: 1;
166
+ pointer-events: auto;
167
+ visibility: visible;
168
+
169
+ @starting-style {
170
+ opacity: 0;
171
+ }
172
+ }
176
173
 
177
- @media (prefers-reduced-motion: reduce) {
178
- transition: none;
179
- }
174
+ &[aria-hidden="true"] {
175
+ opacity: 0;
176
+ pointer-events: none;
177
+ visibility: hidden;
178
+ }
180
179
 
181
- /*
182
- The arrow is a CSS border-triangle: 14px across the edge (two
183
- half-width transparent borders) and 8px deep (the coloured border on the
184
- pointing side). The always-on offset shifts it along the edge so the tip
185
- stays pinned to the trigger centre for every placement — including after a
186
- resize or scroll reposition (the offset is recomputed live).
187
- */
188
- &::before {
189
- content: "";
190
- width: 0;
191
- height: 0;
192
- position: absolute;
193
- transform: translateX(var(--tooltip-arrow-offset-left))
194
- translateY(var(--tooltip-arrow-offset-top));
195
- }
180
+ @media (prefers-reduced-motion: reduce) {
181
+ transition: none;
182
+ }
196
183
 
197
- /* Placed above the trigger → arrow points down, on the tooltip's bottom edge. */
198
- &.top::before {
199
- border-inline: var(--tooltip-arrow-half-width) solid transparent;
200
- border-top: var(--tooltip-arrow-depth) solid var(--tooltip-color-background);
201
- bottom: var(--tooltip-arrow-edge);
202
- left: var(--tooltip-arrow-middle);
203
- }
184
+ /*
185
+ The arrow is a CSS border-triangle: 14px across the edge (two
186
+ half-width transparent borders) and 8px deep (the coloured border on the
187
+ pointing side). The always-on offset shifts it along the edge so the tip
188
+ stays pinned to the trigger centre for every placement — including after a
189
+ resize or scroll reposition (the offset is recomputed live).
190
+ */
191
+ &::before {
192
+ content: "";
193
+ width: 0;
194
+ height: 0;
195
+ position: absolute;
196
+ transform: translateX(var(--tooltip-arrow-offset-left))
197
+ translateY(var(--tooltip-arrow-offset-top));
198
+ }
204
199
 
205
- /* Placed below → arrow points up, on the top edge. */
206
- &.bottom::before {
207
- border-inline: var(--tooltip-arrow-half-width) solid transparent;
208
- border-bottom: var(--tooltip-arrow-depth) solid
209
- var(--tooltip-color-background);
210
- top: var(--tooltip-arrow-edge);
211
- left: var(--tooltip-arrow-middle);
212
- }
200
+ /* Placed above the trigger → arrow points down, on the tooltip's bottom edge. */
201
+ &.top::before {
202
+ border-inline: var(--tooltip-arrow-half-width) solid transparent;
203
+ border-top: var(--tooltip-arrow-depth) solid
204
+ var(--tooltip-color-background);
205
+ bottom: var(--tooltip-arrow-edge);
206
+ left: var(--tooltip-arrow-middle);
207
+ }
213
208
 
214
- /* Placed left → arrow points right, on the right edge. */
215
- &.left::before {
216
- border-block: var(--tooltip-arrow-half-width) solid transparent;
217
- border-left: var(--tooltip-arrow-depth) solid
218
- var(--tooltip-color-background);
219
- right: var(--tooltip-arrow-edge);
220
- top: var(--tooltip-arrow-middle);
221
- }
209
+ /* Placed below → arrow points up, on the top edge. */
210
+ &.bottom::before {
211
+ border-inline: var(--tooltip-arrow-half-width) solid transparent;
212
+ border-bottom: var(--tooltip-arrow-depth) solid
213
+ var(--tooltip-color-background);
214
+ top: var(--tooltip-arrow-edge);
215
+ left: var(--tooltip-arrow-middle);
216
+ }
217
+
218
+ /* Placed left → arrow points right, on the right edge. */
219
+ &.left::before {
220
+ border-block: var(--tooltip-arrow-half-width) solid transparent;
221
+ border-left: var(--tooltip-arrow-depth) solid
222
+ var(--tooltip-color-background);
223
+ right: var(--tooltip-arrow-edge);
224
+ top: var(--tooltip-arrow-middle);
225
+ }
222
226
 
223
- /* Placed right → arrow points left, on the left edge. */
224
- &.right::before {
225
- border-block: var(--tooltip-arrow-half-width) solid transparent;
226
- border-right: var(--tooltip-arrow-depth) solid
227
- var(--tooltip-color-background);
228
- left: var(--tooltip-arrow-edge);
229
- top: var(--tooltip-arrow-middle);
227
+ /* Placed right → arrow points left, on the left edge. */
228
+ &.right::before {
229
+ border-block: var(--tooltip-arrow-half-width) solid transparent;
230
+ border-right: var(--tooltip-arrow-depth) solid
231
+ var(--tooltip-color-background);
232
+ left: var(--tooltip-arrow-edge);
233
+ top: var(--tooltip-arrow-middle);
234
+ }
230
235
  }
231
236
  }
@@ -25,31 +25,35 @@
25
25
  * `--card-span` (the `cardSpan` prop) is the NUMBER OF PARENT COLUMNS each card
26
26
  * spans — not a pixel width. `1` (default) packs the most cards per row; use 2
27
27
  * or 4 for fewer, wider cards on the 4/8/12-column responsive grid.
28
+ *
29
+ * Layer: ds.components.global (@canonical/styles README, "Cascade layers").
28
30
  */
29
31
 
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;
32
+ @layer ds.components.global {
33
+ .ds.cards {
34
+ display: grid;
35
+ grid-template-columns: subgrid;
36
+ /* The Cards container itself always spans the full master grid; `--card-span`
37
+ * (the per-card column span) inherits down to each Card, it is NOT the
38
+ * container's own span. */
39
+ grid-column: 1 / -1;
37
40
 
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;
41
+ /* The four shared section tracks (image / header / content / footer), repeated
42
+ * for every wrapped band via `grid-auto-rows`. They are ALL `auto`, so each
43
+ * track sizes to the tallest of that section across the row — every card takes
44
+ * its intrinsic height plus only the extra needed to align with the tallest
45
+ * card on the band (no `1fr`, which would stretch a card to fill surplus
46
+ * container height). Cards each `span 4` rows and auto-place across the columns
47
+ * (DOM order), wrapping to the next band. */
48
+ grid-auto-flow: row;
49
+ grid-auto-rows: auto;
47
50
 
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;
51
+ /* Bands take their intrinsic height and pack to the top — never stretch to
52
+ * fill a taller container. */
53
+ align-self: start;
54
+ align-content: start;
52
55
 
53
- gap: var(--grid-row-gap, var(--grid-gutter))
54
- var(--grid-column-gap, var(--grid-gutter));
56
+ gap: var(--grid-row-gap, var(--grid-gutter))
57
+ var(--grid-column-gap, var(--grid-gutter));
58
+ }
55
59
  }
@@ -1,12 +1,16 @@
1
- :root {
2
- /* Figma (node 6004-72): 2px between adjacent keys in a chord. */
3
- --keyboard-keys-gap: var(--dimension-025);
4
- --keyboard-keys-margin-inline: var(--dimension-050);
5
- }
1
+ /* Layer: ds.components.global (@canonical/styles README, "Cascade layers"). */
2
+
3
+ @layer ds.components.global {
4
+ :root {
5
+ /* Figma (node 6004-72): 2px between adjacent keys in a chord. */
6
+ --keyboard-keys-gap: var(--dimension-025);
7
+ --keyboard-keys-margin-inline: var(--dimension-050);
8
+ }
6
9
 
7
- .ds.keyboard-keys {
8
- display: inline-flex;
9
- align-items: center;
10
- gap: var(--keyboard-keys-gap);
11
- margin-inline: var(--keyboard-keys-margin-inline);
10
+ .ds.keyboard-keys {
11
+ display: inline-flex;
12
+ align-items: center;
13
+ gap: var(--keyboard-keys-gap);
14
+ margin-inline: var(--keyboard-keys-margin-inline);
15
+ }
12
16
  }
@@ -1,3 +1,4 @@
1
+ export { default as isMenuSeparator } from "./isMenuSeparator.js";
1
2
  export * from "./types.js";
2
3
  export { default as useContextualMenu } from "./useContextualMenu.js";
3
4
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/lib/hooks/useContextualMenu/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,wBAAwB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/lib/hooks/useContextualMenu/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAClE,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,wBAAwB,CAAC"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Narrow a menu entry (raw or annotated) to a separator via its `type`
3
+ * discriminant. In the false branch the entry narrows to a `MenuItem`, so
4
+ * render code can branch between a divider and an interactive item.
5
+ *
6
+ * @param entry The menu entry to test.
7
+ * @returns Whether the entry is a separator.
8
+ */
9
+ const isMenuSeparator = (entry) => "type" in entry && entry.type === "separator";
10
+ export default isMenuSeparator;
11
+ //# sourceMappingURL=isMenuSeparator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isMenuSeparator.js","sourceRoot":"","sources":["../../../../../src/lib/hooks/useContextualMenu/isMenuSeparator.ts"],"names":[],"mappings":"AAGA;;;;;;;GAOG;AACH,MAAM,eAAe,GAAG,CACtB,KAAmC,EACY,EAAE,CACjD,MAAM,IAAI,KAAK,IAAI,KAAK,CAAC,IAAI,KAAK,WAAW,CAAC;AAEhD,eAAe,eAAe,CAAC"}