@canonical/react-ds-global 0.42.0 → 0.44.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 (25) hide show
  1. package/README.md +9 -9
  2. package/dist/esm/lib/_work_in_progress/Announcement/styles.css +1 -1
  3. package/dist/esm/lib/component/Accordion/common/Item/styles.css +11 -0
  4. package/dist/esm/lib/pattern/Modal/common/Header/Header.js +1 -1
  5. package/dist/esm/lib/pattern/Modal/common/Header/Header.js.map +1 -1
  6. package/dist/esm/lib/pattern/Timeline/utils/buildFilterOptions.js +13 -0
  7. package/dist/esm/lib/pattern/Timeline/utils/buildFilterOptions.js.map +1 -0
  8. package/dist/esm/lib/pattern/Timeline/utils/formatRelative.js +37 -0
  9. package/dist/esm/lib/pattern/Timeline/utils/formatRelative.js.map +1 -0
  10. package/dist/esm/lib/pattern/Timeline/utils/index.js +4 -0
  11. package/dist/esm/lib/pattern/Timeline/utils/index.js.map +1 -0
  12. package/dist/esm/lib/pattern/Timeline/utils/resolveMarkerSizes.js +67 -0
  13. package/dist/esm/lib/pattern/Timeline/utils/resolveMarkerSizes.js.map +1 -0
  14. package/dist/types/lib/pattern/Modal/common/Header/Header.d.ts.map +1 -1
  15. package/dist/types/lib/pattern/Timeline/types.d.ts +77 -1
  16. package/dist/types/lib/pattern/Timeline/types.d.ts.map +1 -1
  17. package/dist/types/lib/pattern/Timeline/utils/buildFilterOptions.d.ts +4 -0
  18. package/dist/types/lib/pattern/Timeline/utils/buildFilterOptions.d.ts.map +1 -0
  19. package/dist/types/lib/pattern/Timeline/utils/formatRelative.d.ts +3 -0
  20. package/dist/types/lib/pattern/Timeline/utils/formatRelative.d.ts.map +1 -0
  21. package/dist/types/lib/pattern/Timeline/utils/index.d.ts +4 -0
  22. package/dist/types/lib/pattern/Timeline/utils/index.d.ts.map +1 -0
  23. package/dist/types/lib/pattern/Timeline/utils/resolveMarkerSizes.d.ts +7 -0
  24. package/dist/types/lib/pattern/Timeline/utils/resolveMarkerSizes.d.ts.map +1 -0
  25. package/package.json +21 -21
package/README.md CHANGED
@@ -9,10 +9,16 @@ Universal React components for the Pragma design system. This package provides f
9
9
  ## Installation
10
10
 
11
11
  ```bash
12
- bun add @canonical/react-ds-global
12
+ bun add @canonical/react-ds-global @canonical/styles
13
13
  ```
14
14
 
15
- The package depends on `@canonical/styles` for CSS.
15
+ Import the design system's styles **first** in your application's entry, before anything that imports a component:
16
+
17
+ ```ts
18
+ import "@canonical/styles";
19
+ ```
20
+
21
+ Each component brings its own stylesheet when you import it.
16
22
 
17
23
  ## Usage
18
24
 
@@ -49,12 +55,6 @@ The modifier classes integrate with CSS custom properties defined in `@canonical
49
55
 
50
56
  ## Styles
51
57
 
52
- Import the main styles package in your application entry point:
53
-
54
- ```tsx
55
- import "@canonical/styles";
56
- ```
57
-
58
58
  `@canonical/styles` provides the global design tokens (colour, spacing, typography). Each component in this package co-locates its own component-level tokens in a `styles.css` file next to the component source. These component tokens reference the global tokens from `@canonical/design-tokens` and are included automatically when the component is imported.
59
59
 
60
60
  ### How component CSS reaches the page
@@ -173,4 +173,4 @@ bun run storybook
173
173
 
174
174
  ## Component Specifications
175
175
 
176
- Component specifications are defined in the [Design System Ontology](https://github.com/canonical/design-system).
176
+ Component specifications are defined in the [Design System Ontology](https://github.com/canonical/pragma-core/tree/main/packages/semantics/design-system).
@@ -73,7 +73,7 @@
73
73
  font-weight: var(--typography-heading-6-font-weight);
74
74
  /*
75
75
  TODO: Uncomment after line-height bug in typography tokens is addressed
76
- See https://github.com/canonical/pragma/pull/961#issuecomment-5421532811
76
+ See https://github.com/canonical/pragma-web/pull/961#issuecomment-5421532811
77
77
  */
78
78
  /* line-height: var(--typography-heading-6-line-height); */
79
79
  }
@@ -71,6 +71,8 @@
71
71
  }
72
72
 
73
73
  .ds.accordion-item {
74
+ box-sizing: border-box;
75
+
74
76
  /* Inline (side) borders — off by default, see the token above. */
75
77
  border-inline: var(--accordion-item-border-inline);
76
78
 
@@ -84,6 +86,7 @@
84
86
  chevron column keeps all headings left-aligned; align-items:center centres
85
87
  the fixed chevron on the header line. */
86
88
  .ds.accordion-item > .header {
89
+ box-sizing: border-box;
87
90
  display: flex;
88
91
  flex-direction: row;
89
92
  align-items: center;
@@ -228,11 +231,19 @@
228
231
  }
229
232
  }
230
233
 
234
+ /* Chromium 131+ wraps non-<summary> children in an internal ::details-content
235
+ pseudo-element. Seal its box model so child elements inheriting box-sizing
236
+ (e.g. Vanilla components or host resets) receive border-box. */
237
+ .ds.accordion-item::details-content {
238
+ box-sizing: border-box;
239
+ }
240
+
231
241
  /* Content panel. Uses `.editorial` (a prose context) rather than `.p`, so the
232
242
  wrapper doesn't add baseline padding that would double up with content that
233
243
  is already `.p`. The wrapper owns its own vertical padding in baseline
234
244
  multiples, and is indented inline to align under the heading. */
235
245
  .ds.accordion-item > .content {
246
+ box-sizing: border-box;
236
247
  color: var(--accordion-item-color-text);
237
248
 
238
249
  padding-block: var(--accordion-item-content-padding-block);
@@ -20,7 +20,7 @@ const componentCssClassName = "ds modal-header";
20
20
  */
21
21
  const Header = ({ children, titleId, undismissible = false, dismissLabel = "Close", onDismiss, className, ...props }) => {
22
22
  const modal = useModalContext();
23
- return (_jsxs("header", { className: [componentCssClassName, className].filter(Boolean).join(" "), ...props, children: [_jsx("span", { className: "title", id: titleId ?? modal.titleId, children: children }), !undismissible && (_jsx(Button, { className: "close", importance: "tertiary", icon: "close", "aria-label": dismissLabel, onClick: onDismiss ?? modal.onDismiss }))] }));
23
+ return (_jsxs("header", { className: [componentCssClassName, className].filter(Boolean).join(" "), ...props, children: [_jsx("span", { className: "title", id: titleId ?? modal.titleId, children: children }), !undismissible && (_jsx(Button, { type: "button", className: "close", importance: "tertiary", icon: "close", "aria-label": dismissLabel, onClick: onDismiss ?? modal.onDismiss }))] }));
24
24
  };
25
25
  Header.displayName = "Modal.Header";
26
26
  export default Header;
@@ -1 +1 @@
1
- {"version":3,"file":"Header.js","sourceRoot":"","sources":["../../../../../../../src/lib/pattern/Modal/common/Header/Header.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,MAAM,EAAE,MAAM,uCAAuC,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAEjE,OAAO,cAAc,CAAC;AAEtB,MAAM,qBAAqB,GAAG,iBAAiB,CAAC;AAEhD;;;;;;;;;;;;;;GAcG;AACH,MAAM,MAAM,GAAG,CAAC,EACd,QAAQ,EACR,OAAO,EACP,aAAa,GAAG,KAAK,EACrB,YAAY,GAAG,OAAO,EACtB,SAAS,EACT,SAAS,EACT,GAAG,KAAK,EACI,EAAsB,EAAE;IACpC,MAAM,KAAK,GAAG,eAAe,EAAE,CAAC;IAEhC,OAAO,CACL,kBACE,SAAS,EAAE,CAAC,qBAAqB,EAAE,SAAS,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,KACnE,KAAK,aAET,eAAM,SAAS,EAAC,OAAO,EAAC,EAAE,EAAE,OAAO,IAAI,KAAK,CAAC,OAAO,YACjD,QAAQ,GACJ,EACN,CAAC,aAAa,IAAI,CACjB,KAAC,MAAM,IACL,SAAS,EAAC,OAAO,EACjB,UAAU,EAAC,UAAU,EACrB,IAAI,EAAC,OAAO,gBACA,YAAY,EACxB,OAAO,EAAE,SAAS,IAAI,KAAK,CAAC,SAAS,GACrC,CACH,IACM,CACV,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,WAAW,GAAG,cAAc,CAAC;AAEpC,eAAe,MAAM,CAAC"}
1
+ {"version":3,"file":"Header.js","sourceRoot":"","sources":["../../../../../../../src/lib/pattern/Modal/common/Header/Header.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,MAAM,EAAE,MAAM,uCAAuC,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAEjE,OAAO,cAAc,CAAC;AAEtB,MAAM,qBAAqB,GAAG,iBAAiB,CAAC;AAEhD;;;;;;;;;;;;;;GAcG;AACH,MAAM,MAAM,GAAG,CAAC,EACd,QAAQ,EACR,OAAO,EACP,aAAa,GAAG,KAAK,EACrB,YAAY,GAAG,OAAO,EACtB,SAAS,EACT,SAAS,EACT,GAAG,KAAK,EACI,EAAsB,EAAE;IACpC,MAAM,KAAK,GAAG,eAAe,EAAE,CAAC;IAEhC,OAAO,CACL,kBACE,SAAS,EAAE,CAAC,qBAAqB,EAAE,SAAS,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,KACnE,KAAK,aAET,eAAM,SAAS,EAAC,OAAO,EAAC,EAAE,EAAE,OAAO,IAAI,KAAK,CAAC,OAAO,YACjD,QAAQ,GACJ,EACN,CAAC,aAAa,IAAI,CACjB,KAAC,MAAM,IACL,IAAI,EAAC,QAAQ,EACb,SAAS,EAAC,OAAO,EACjB,UAAU,EAAC,UAAU,EACrB,IAAI,EAAC,OAAO,gBACA,YAAY,EACxB,OAAO,EAAE,SAAS,IAAI,KAAK,CAAC,SAAS,GACrC,CACH,IACM,CACV,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,WAAW,GAAG,cAAc,CAAC;AAEpC,eAAe,MAAM,CAAC"}
@@ -0,0 +1,13 @@
1
+ /** Unique filter options in first-seen order; label from the first carrier. */
2
+ export default function buildFilterOptions(items, getValue, getLabel) {
3
+ const labels = new Map();
4
+ for (const item of items) {
5
+ const value = getValue(item);
6
+ if (value === undefined || labels.has(value)) {
7
+ continue;
8
+ }
9
+ labels.set(value, getLabel(item) ?? value);
10
+ }
11
+ return [...labels.entries()].map(([value, label]) => ({ value, label }));
12
+ }
13
+ //# sourceMappingURL=buildFilterOptions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buildFilterOptions.js","sourceRoot":"","sources":["../../../../../../src/lib/pattern/Timeline/utils/buildFilterOptions.ts"],"names":[],"mappings":"AAEA,+EAA+E;AAC/E,MAAM,CAAC,OAAO,UAAU,kBAAkB,CACxC,KAA8B,EAC9B,QAAoD,EACpD,QAAoD;IAEpD,MAAM,MAAM,GAAG,IAAI,GAAG,EAAkB,CAAC;IACzC,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,MAAM,KAAK,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC;QAC7B,IAAI,KAAK,KAAK,SAAS,IAAI,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;YAC7C,SAAS;QACX,CAAC;QACD,MAAM,CAAC,GAAG,CAAC,KAAK,EAAE,QAAQ,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC,CAAC;IAC7C,CAAC;IACD,OAAO,CAAC,GAAG,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;AAC3E,CAAC"}
@@ -0,0 +1,37 @@
1
+ const DIVISIONS = [
2
+ { amount: 60, unit: "second" },
3
+ { amount: 60, unit: "minute" },
4
+ { amount: 24, unit: "hour" },
5
+ { amount: 7, unit: "day" },
6
+ { amount: 4.34524, unit: "week" },
7
+ { amount: 12, unit: "month" },
8
+ { amount: Number.POSITIVE_INFINITY, unit: "year" },
9
+ ];
10
+ const formatterCache = new Map();
11
+ function getFormatter(locale) {
12
+ let formatter = formatterCache.get(locale);
13
+ if (!formatter) {
14
+ formatter = new Intl.RelativeTimeFormat(locale, { numeric: "auto" });
15
+ formatterCache.set(locale, formatter);
16
+ }
17
+ return formatter;
18
+ }
19
+ /** Format an ISO timestamp relative to `now` (e.g. "2 hours ago"). */
20
+ export default function formatRelative(iso, now, locale) {
21
+ const timestamp = Date.parse(iso);
22
+ if (Number.isNaN(timestamp) || Number.isNaN(now)) {
23
+ return "";
24
+ }
25
+ let duration = (timestamp - now) / 1000;
26
+ // Round before choosing the unit, so 59.6 s is "1 minute ago" (and the
27
+ // same at the hour, day and week limits) rather than "60 seconds ago".
28
+ for (const division of DIVISIONS) {
29
+ const rounded = Math.round(duration);
30
+ if (Math.abs(rounded) < division.amount) {
31
+ return getFormatter(locale).format(rounded, division.unit);
32
+ }
33
+ duration /= division.amount;
34
+ }
35
+ return "";
36
+ }
37
+ //# sourceMappingURL=formatRelative.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formatRelative.js","sourceRoot":"","sources":["../../../../../../src/lib/pattern/Timeline/utils/formatRelative.ts"],"names":[],"mappings":"AAEA,MAAM,SAAS,GAAwB;IACrC,EAAE,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;IAC9B,EAAE,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;IAC9B,EAAE,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE;IAC5B,EAAE,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE;IAC1B,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE;IACjC,EAAE,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE;IAC7B,EAAE,MAAM,EAAE,MAAM,CAAC,iBAAiB,EAAE,IAAI,EAAE,MAAM,EAAE;CACnD,CAAC;AAEF,MAAM,cAAc,GAAG,IAAI,GAAG,EAAmC,CAAC;AAElE,SAAS,YAAY,CAAC,MAAc;IAClC,IAAI,SAAS,GAAG,cAAc,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAC3C,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,SAAS,GAAG,IAAI,IAAI,CAAC,kBAAkB,CAAC,MAAM,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC;QACrE,cAAc,CAAC,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IACxC,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,sEAAsE;AACtE,MAAM,CAAC,OAAO,UAAU,cAAc,CACpC,GAAW,EACX,GAAW,EACX,MAAc;IAEd,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAClC,IAAI,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,IAAI,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC;QACjD,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,IAAI,QAAQ,GAAG,CAAC,SAAS,GAAG,GAAG,CAAC,GAAG,IAAI,CAAC;IACxC,uEAAuE;IACvE,uEAAuE;IACvE,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE,CAAC;QACjC,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QACrC,IAAI,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC;YACxC,OAAO,YAAY,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,OAAO,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC;QAC7D,CAAC;QACD,QAAQ,IAAI,QAAQ,CAAC,MAAM,CAAC;IAC9B,CAAC;IACD,OAAO,EAAE,CAAC;AACZ,CAAC"}
@@ -0,0 +1,4 @@
1
+ export { default as buildFilterOptions } from "./buildFilterOptions.js";
2
+ export { default as formatRelative } from "./formatRelative.js";
3
+ export { default as resolveMarkerSizes } from "./resolveMarkerSizes.js";
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/lib/pattern/Timeline/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AACxE,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,yBAAyB,CAAC"}
@@ -0,0 +1,67 @@
1
+ function firstIndexesOfRuns(values) {
2
+ const firsts = new Set();
3
+ let previous;
4
+ values.forEach((value, index) => {
5
+ if (value === undefined) {
6
+ previous = undefined;
7
+ }
8
+ else if (value !== previous) {
9
+ firsts.add(index);
10
+ previous = value;
11
+ }
12
+ });
13
+ return firsts;
14
+ }
15
+ /** Marker sizes from the combination rules alone, before per-item overrides. */
16
+ function deriveMarkerSizes(items, combination) {
17
+ if (combination === "large" ||
18
+ combination === "medium" ||
19
+ combination === "small") {
20
+ return items.map(() => combination);
21
+ }
22
+ const actorRunStarts = firstIndexesOfRuns(items.map((item) => item.actorId));
23
+ if (combination === "large-medium" || combination === "large-small") {
24
+ const rest = combination === "large-medium" ? "medium" : "small";
25
+ return items.map((_, index) => actorRunStarts.has(index) ? "large" : rest);
26
+ }
27
+ if (combination === "medium-small") {
28
+ return items.map((_, index) => actorRunStarts.has(index) ? "medium" : "small");
29
+ }
30
+ // All sizes: large for the first event of each actor run, then type runs
31
+ // counted afresh within each run's remaining events — medium for the first
32
+ // event of each type sequence there, small for the rest.
33
+ let currentActor;
34
+ let inActorRun = false;
35
+ let currentType;
36
+ return items.map((item) => {
37
+ if (item.actorId !== undefined &&
38
+ (!inActorRun || item.actorId !== currentActor)) {
39
+ inActorRun = true;
40
+ currentActor = item.actorId;
41
+ currentType = undefined;
42
+ return "large";
43
+ }
44
+ if (item.actorId === undefined) {
45
+ inActorRun = false;
46
+ currentActor = undefined;
47
+ }
48
+ if (item.eventType === undefined) {
49
+ currentType = undefined;
50
+ return "small";
51
+ }
52
+ if (item.eventType !== currentType) {
53
+ currentType = item.eventType;
54
+ return "medium";
55
+ }
56
+ return "small";
57
+ });
58
+ }
59
+ /**
60
+ * Resolve each item's marker size from the combination rules. An explicit
61
+ * `marker.size` on the item wins over the derived size.
62
+ */
63
+ export default function resolveMarkerSizes(items, combination) {
64
+ const derived = deriveMarkerSizes(items, combination);
65
+ return items.map((item, index) => item.marker?.size ?? derived[index]);
66
+ }
67
+ //# sourceMappingURL=resolveMarkerSizes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolveMarkerSizes.js","sourceRoot":"","sources":["../../../../../../src/lib/pattern/Timeline/utils/resolveMarkerSizes.ts"],"names":[],"mappings":"AAMA,SAAS,kBAAkB,CACzB,MAAuC;IAEvC,MAAM,MAAM,GAAG,IAAI,GAAG,EAAU,CAAC;IACjC,IAAI,QAA4B,CAAC;IACjC,MAAM,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE;QAC9B,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACxB,QAAQ,GAAG,SAAS,CAAC;QACvB,CAAC;aAAM,IAAI,KAAK,KAAK,QAAQ,EAAE,CAAC;YAC9B,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;YAClB,QAAQ,GAAG,KAAK,CAAC;QACnB,CAAC;IACH,CAAC,CAAC,CAAC;IACH,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,gFAAgF;AAChF,SAAS,iBAAiB,CACxB,KAA8B,EAC9B,WAAsC;IAEtC,IACE,WAAW,KAAK,OAAO;QACvB,WAAW,KAAK,QAAQ;QACxB,WAAW,KAAK,OAAO,EACvB,CAAC;QACD,OAAO,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,WAAW,CAAC,CAAC;IACtC,CAAC;IAED,MAAM,cAAc,GAAG,kBAAkB,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;IAE7E,IAAI,WAAW,KAAK,cAAc,IAAI,WAAW,KAAK,aAAa,EAAE,CAAC;QACpE,MAAM,IAAI,GAAG,WAAW,KAAK,cAAc,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC;QACjE,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,CAC5B,cAAc,CAA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AACH,MAAM,CAAC,OAAO,UAAU,kBAAkB,CACxC,KAA8B,EAC9B,WAAsC;IAEtC,MAAM,OAAO,GAAG,iBAAiB,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC;IACtD,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,IAAI,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;AACzE,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"Header.d.ts","sourceRoot":"","sources":["../../../../../../../src/lib/pattern/Modal/common/Header/Header.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,cAAc,CAAC;wBAmBN,EACd,QAAQ,EACR,OAAO,EACP,aAAqB,EACrB,YAAsB,EACtB,SAAS,EACT,SAAS,EACT,GAAG,KAAK,EACT,EAAE,WAAW,GAAG,KAAK,CAAC,YAAY;;;;eA0BpB,MAAM"}
1
+ {"version":3,"file":"Header.d.ts","sourceRoot":"","sources":["../../../../../../../src/lib/pattern/Modal/common/Header/Header.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,cAAc,CAAC;wBAmBN,EACd,QAAQ,EACR,OAAO,EACP,aAAqB,EACrB,YAAsB,EACtB,SAAS,EACT,SAAS,EACT,GAAG,KAAK,EACT,EAAE,WAAW,GAAG,KAAK,CAAC,YAAY;;;;eA2BpB,MAAM"}
@@ -1,6 +1,82 @@
1
- import type { ComponentProps, ReactElement } from "react";
1
+ import type { ModifierFamily } from "@canonical/ds-types";
2
+ import type { ComponentProps, ReactElement, ReactNode } from "react";
2
3
  import type { ContentProps } from "./common/Content/types.js";
3
4
  import type { EventProps } from "./common/Event/types.js";
5
+ export type TimelineSortOrder = "newest" | "oldest";
6
+ export type TimelineDateTimePosition = "leading" | "trailing";
7
+ export type TimelineMarkerCombination = "all-sizes" | "large-medium" | "large-small" | "medium-small" | "large" | "medium" | "small";
8
+ export type TimelineCollapsingMethod = "none" | "bottom" | "middle";
9
+ export type TimelineMarkerSize = "large" | "medium" | "small";
10
+ /** Marker graphic; first of customGraphic, imageUrl, icon, initials wins. */
11
+ export type TimelineMarker = {
12
+ customGraphic?: ReactNode;
13
+ imageUrl?: string;
14
+ alt?: string;
15
+ icon?: ReactNode;
16
+ initials?: string;
17
+ size?: TimelineMarkerSize;
18
+ };
19
+ /** One data-driven timeline event. */
20
+ export type TimelineItem = {
21
+ /** Stable identity: React key and expansion restore. */
22
+ id: string;
23
+ /**
24
+ * ISO 8601 timestamp; drives sort and `<time datetime>`.
25
+ *
26
+ * @note Sort reads this via `Date.parse` today — engine-dependent on
27
+ * out-of-range dates and timezone-dependent on offsetless date-times; see
28
+ * the debt note on `sortItems` in `useTimelineFilters.ts`. Prefer
29
+ * offset-bearing forms.
30
+ */
31
+ dateTime: string;
32
+ /** Filter key; also drives consecutive-run marker sizing. */
33
+ actorId?: string;
34
+ actorName?: string;
35
+ /** Profile URL; marker and name become links. */
36
+ actorLink?: string;
37
+ /** Event-filter key. */
38
+ eventType?: string;
39
+ eventLabel?: string;
40
+ description?: string;
41
+ customContent?: ReactNode;
42
+ marker?: TimelineMarker;
43
+ /** Only the marker and `customContent` render. */
44
+ fullyCustom?: boolean;
45
+ showName?: boolean;
46
+ showDescription?: boolean;
47
+ showDateTime?: boolean;
48
+ criticality?: ModifierFamily<"criticality">;
49
+ };
50
+ export type TimelineFilterOption = {
51
+ value: string;
52
+ label: string;
53
+ };
54
+ export type TimelineFilterState = {
55
+ actorId?: string;
56
+ eventType?: string;
57
+ };
58
+ export type TimelineExpansion = {
59
+ method?: TimelineCollapsingMethod;
60
+ /** Default 8. */
61
+ initialVisible?: number;
62
+ /** Events revealed per "Show more". Default 4. */
63
+ step?: number;
64
+ };
65
+ export type TimelineDateTimeFormatProps = {
66
+ formatAbsolute?: (iso: string, locale: string) => string;
67
+ formatRelative?: (iso: string, now: number, locale: string) => string;
68
+ /** Click toggles absolute/relative for all events. Default true. */
69
+ toggleable?: boolean;
70
+ /** Hover tooltip shows the alternate format. Default true. */
71
+ tooltip?: boolean;
72
+ };
73
+ export type TimelineRenderContext = {
74
+ order: TimelineSortOrder;
75
+ isVisible: boolean;
76
+ isFiltered: boolean;
77
+ markerSize: TimelineMarkerSize;
78
+ index: number;
79
+ };
4
80
  type OwnProps = {
5
81
  /**
6
82
  * Timeline.Content element (required)
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/lib/pattern/Timeline/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAC1D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAE1D,KAAK,QAAQ,GAAG;IACd;;;OAGG;IACH,QAAQ,EAAE,YAAY,CAAC,YAAY,CAAC,CAAC;CACtC,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,MAAM,MAAM,aAAa,GAAG,QAAQ,GAClC,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE,MAAM,QAAQ,CAAC,CAAC;AAE9C;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,EAAE,aAAa,KAAK,YAAY,CAAC,GAAG;IACzE,OAAO,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,YAAY,CAAC;IAC/C,KAAK,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,YAAY,CAAC;CAC5C,CAAC"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/lib/pattern/Timeline/types.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OAAO,CAAC;IACnB,UAAU,EAAE,OAAO,CAAC;IACpB,UAAU,EAAE,kBAAkB,CAAC;IAC/B,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,KAAK,QAAQ,GAAG;IACd;;;OAGG;IACH,QAAQ,EAAE,YAAY,CAAC,YAAY,CAAC,CAAC;CACtC,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,MAAM,MAAM,aAAa,GAAG,QAAQ,GAClC,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE,MAAM,QAAQ,CAAC,CAAC;AAE9C;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,EAAE,aAAa,KAAK,YAAY,CAAC,GAAG;IACzE,OAAO,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,YAAY,CAAC;IAC/C,KAAK,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,YAAY,CAAC;CAC5C,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { TimelineFilterOption, TimelineItem } from "../types.js";
2
+ /** Unique filter options in first-seen order; label from the first carrier. */
3
+ export default function buildFilterOptions(items: readonly TimelineItem[], getValue: (item: TimelineItem) => string | undefined, getLabel: (item: TimelineItem) => string | undefined): TimelineFilterOption[];
4
+ //# sourceMappingURL=buildFilterOptions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buildFilterOptions.d.ts","sourceRoot":"","sources":["../../../../../../src/lib/pattern/Timeline/utils/buildFilterOptions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEtE,+EAA+E;AAC/E,MAAM,CAAC,OAAO,UAAU,kBAAkB,CACxC,KAAK,EAAE,SAAS,YAAY,EAAE,EAC9B,QAAQ,EAAE,CAAC,IAAI,EAAE,YAAY,KAAK,MAAM,GAAG,SAAS,EACpD,QAAQ,EAAE,CAAC,IAAI,EAAE,YAAY,KAAK,MAAM,GAAG,SAAS,GACnD,oBAAoB,EAAE,CAUxB"}
@@ -0,0 +1,3 @@
1
+ /** Format an ISO timestamp relative to `now` (e.g. "2 hours ago"). */
2
+ export default function formatRelative(iso: string, now: number, locale: string): string;
3
+ //# sourceMappingURL=formatRelative.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formatRelative.d.ts","sourceRoot":"","sources":["../../../../../../src/lib/pattern/Timeline/utils/formatRelative.ts"],"names":[],"mappings":"AAuBA,sEAAsE;AACtE,MAAM,CAAC,OAAO,UAAU,cAAc,CACpC,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,MAAM,GACb,MAAM,CAgBR"}
@@ -0,0 +1,4 @@
1
+ export { default as buildFilterOptions } from "./buildFilterOptions.js";
2
+ export { default as formatRelative } from "./formatRelative.js";
3
+ export { default as resolveMarkerSizes } from "./resolveMarkerSizes.js";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/lib/pattern/Timeline/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AACxE,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,yBAAyB,CAAC"}
@@ -0,0 +1,7 @@
1
+ import type { TimelineItem, TimelineMarkerCombination, TimelineMarkerSize } from "../types.js";
2
+ /**
3
+ * Resolve each item's marker size from the combination rules. An explicit
4
+ * `marker.size` on the item wins over the derived size.
5
+ */
6
+ export default function resolveMarkerSizes(items: readonly TimelineItem[], combination: TimelineMarkerCombination): TimelineMarkerSize[];
7
+ //# sourceMappingURL=resolveMarkerSizes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolveMarkerSizes.d.ts","sourceRoot":"","sources":["../../../../../../src/lib/pattern/Timeline/utils/resolveMarkerSizes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,yBAAyB,EACzB,kBAAkB,EACnB,MAAM,aAAa,CAAC;AA8ErB;;;GAGG;AACH,MAAM,CAAC,OAAO,UAAU,kBAAkB,CACxC,KAAK,EAAE,SAAS,YAAY,EAAE,EAC9B,WAAW,EAAE,yBAAyB,GACrC,kBAAkB,EAAE,CAGtB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@canonical/react-ds-global",
3
- "version": "0.42.0",
3
+ "version": "0.44.0",
4
4
  "type": "module",
5
5
  "main": "dist/esm/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -24,13 +24,13 @@
24
24
  },
25
25
  "repository": {
26
26
  "type": "git",
27
- "url": "https://github.com/canonical/pragma"
27
+ "url": "https://github.com/canonical/pragma-web"
28
28
  },
29
29
  "license": "LGPL-3.0",
30
30
  "bugs": {
31
- "url": "https://github.com/canonical/pragma/issues"
31
+ "url": "https://github.com/canonical/pragma-web/issues"
32
32
  },
33
- "homepage": "https://github.com/canonical/pragma#readme",
33
+ "homepage": "https://github.com/canonical/pragma-web#readme",
34
34
  "publishConfig": {
35
35
  "access": "public"
36
36
  },
@@ -53,26 +53,26 @@
53
53
  "test:vitest:watch": "vitest"
54
54
  },
55
55
  "dependencies": {
56
- "@canonical/design-tokens": "0.10.0",
57
- "@canonical/ds-assets": "^0.42.0",
58
- "@canonical/ds-utils": "^0.42.0",
59
- "@canonical/react-hooks": "^0.42.0",
60
- "@canonical/storybook-config": "^0.42.0",
61
- "@canonical/styles": "^0.42.0",
56
+ "@canonical/design-tokens": "0.43.0",
57
+ "@canonical/ds-assets": "^0.44.0",
58
+ "@canonical/ds-utils": "^0.44.0",
59
+ "@canonical/react-hooks": "^0.44.0",
60
+ "@canonical/storybook-config": "^0.44.0",
61
+ "@canonical/styles": "^0.44.0",
62
62
  "react": "^19.2.4",
63
63
  "react-dom": "^19.2.4"
64
64
  },
65
65
  "devDependencies": {
66
66
  "@biomejs/biome": "2.5.14",
67
- "@canonical/biome-config": "^0.42.0",
68
- "@canonical/ds-types": "^0.42.0",
69
- "@canonical/router-core": "^0.42.0",
70
- "@canonical/router-react": "^0.42.0",
71
- "@canonical/storybook-addon-utils": "^0.42.0",
72
- "@canonical/storybook-helpers": "^0.42.0",
73
- "@canonical/typescript-config-react": "^0.42.0",
74
- "@canonical/vitest-config-react": "^0.42.0",
75
- "@canonical/webarchitect": "^0.42.0",
67
+ "@canonical/biome-config": "0.43.0",
68
+ "@canonical/ds-types": "^0.44.0",
69
+ "@canonical/router-core": "^0.44.0",
70
+ "@canonical/router-react": "^0.44.0",
71
+ "@canonical/storybook-addon-utils": "^0.44.0",
72
+ "@canonical/storybook-helpers": "^0.44.0",
73
+ "@canonical/typescript-config-react": "^0.44.0",
74
+ "@canonical/vitest-config-react": "^0.44.0",
75
+ "@canonical/webarchitect": "0.43.0",
76
76
  "@chromatic-com/storybook": "^5.0.1",
77
77
  "@storybook/addon-docs": "^10.6.0",
78
78
  "@storybook/react-vite": "^10.6.0",
@@ -88,7 +88,7 @@
88
88
  "storybook": "^10.6.0",
89
89
  "typescript": "^7.0.2",
90
90
  "vite": "^8.0.1",
91
- "vitest": "^4.0.18"
91
+ "vitest": "^5.0.0"
92
92
  },
93
- "gitHead": "75c2b17029ba899be3fa645be28290ac6fcb83a9"
93
+ "gitHead": "c1f2abc7f04aa29a88f0e6036645469e82a5dd33"
94
94
  }