@ds-mo/ui 13.4.0 → 13.5.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.
- package/dist/.package-ready.json +1 -1
- package/dist/agent-patterns.json +1 -1
- package/dist/agent.json +19 -21
- package/dist/components/ds-card-overview.js +1 -1
- package/dist/components/ds-card-overview.js.map +1 -1
- package/dist/components/ds-input.js +1 -1
- package/dist/components/ds-input.js.map +1 -1
- package/dist/components/ds-select.js +1 -1
- package/dist/components/ds-select.js.map +1 -1
- package/dist/docs/components.json +10 -16
- package/dist/mcp-data/registry/agent-activity.json +1 -1
- package/dist/mcp-data/registry/agent-response.json +1 -1
- package/dist/mcp-data/registry/agent-source-list.json +1 -1
- package/dist/mcp-data/registry/agent-tool-call.json +1 -1
- package/dist/mcp-data/registry/attachment-list.json +1 -1
- package/dist/mcp-data/registry/avatar.json +1 -1
- package/dist/mcp-data/registry/badge.json +1 -1
- package/dist/mcp-data/registry/bar-nav.json +1 -1
- package/dist/mcp-data/registry/bar-title.json +1 -1
- package/dist/mcp-data/registry/bar-workflow.json +1 -1
- package/dist/mcp-data/registry/breadcrumb.json +1 -1
- package/dist/mcp-data/registry/button-filled.json +1 -1
- package/dist/mcp-data/registry/button-unfilled.json +1 -1
- package/dist/mcp-data/registry/card-data-viz.json +1 -1
- package/dist/mcp-data/registry/card-overview.json +33 -35
- package/dist/mcp-data/registry/card-setting.json +1 -1
- package/dist/mcp-data/registry/chart-bar.json +1 -1
- package/dist/mcp-data/registry/chart-donut.json +1 -1
- package/dist/mcp-data/registry/chart-legend.json +1 -1
- package/dist/mcp-data/registry/chart-line.json +1 -1
- package/dist/mcp-data/registry/checkbox.json +1 -1
- package/dist/mcp-data/registry/chip.json +1 -1
- package/dist/mcp-data/registry/code-block.json +1 -1
- package/dist/mcp-data/registry/conversation-list-item.json +1 -1
- package/dist/mcp-data/registry/conversation-list-section.json +1 -1
- package/dist/mcp-data/registry/conversation-list.json +1 -1
- package/dist/mcp-data/registry/divider.json +1 -1
- package/dist/mcp-data/registry/empty-state.json +1 -1
- package/dist/mcp-data/registry/field.json +1 -1
- package/dist/mcp-data/registry/icon.json +1 -1
- package/dist/mcp-data/registry/input.json +6 -6
- package/dist/mcp-data/registry/loader.json +1 -1
- package/dist/mcp-data/registry/markdown.json +1 -1
- package/dist/mcp-data/registry/menu.json +1 -1
- package/dist/mcp-data/registry/message-actions.json +1 -1
- package/dist/mcp-data/registry/message-bubble.json +1 -1
- package/dist/mcp-data/registry/message-composer.json +1 -1
- package/dist/mcp-data/registry/message-scroller.json +1 -1
- package/dist/mcp-data/registry/message.json +1 -1
- package/dist/mcp-data/registry/mobile-bar-nav.json +1 -1
- package/dist/mcp-data/registry/mobile-header.json +1 -1
- package/dist/mcp-data/registry/mobile-section-switcher.json +1 -1
- package/dist/mcp-data/registry/mobile-sheet-nav.json +1 -1
- package/dist/mcp-data/registry/modal.json +1 -1
- package/dist/mcp-data/registry/panel-nav.json +1 -1
- package/dist/mcp-data/registry/panel-sub-nav.json +1 -1
- package/dist/mcp-data/registry/panel-tool-header.json +1 -1
- package/dist/mcp-data/registry/panel-tool-search.json +1 -1
- package/dist/mcp-data/registry/panel-tools.json +1 -1
- package/dist/mcp-data/registry/radio.json +1 -1
- package/dist/mcp-data/registry/registry.json +19 -21
- package/dist/mcp-data/registry/scroll-overlay.json +1 -1
- package/dist/mcp-data/registry/select.json +5 -5
- package/dist/mcp-data/registry/shell-app.json +1 -1
- package/dist/mcp-data/registry/shell-page.json +1 -1
- package/dist/mcp-data/registry/shell-tools.json +1 -1
- package/dist/mcp-data/registry/skeleton.json +1 -1
- package/dist/mcp-data/registry/slider.json +1 -1
- package/dist/mcp-data/registry/swatch-picker.json +1 -1
- package/dist/mcp-data/registry/switch.json +1 -1
- package/dist/mcp-data/registry/tab-group.json +1 -1
- package/dist/mcp-data/registry/tag.json +1 -1
- package/dist/mcp-data/registry/text.json +1 -1
- package/dist/mcp-data/registry/toast.json +1 -1
- package/dist/mcp-data/registry/tooltip-data-viz.json +1 -1
- package/dist/mcp-data/registry/tooltip.json +1 -1
- package/dist/mcp-data/registry/typing-indicator.json +1 -1
- package/dist/types/components/CardOverview/CardOverview.d.ts +10 -9
- package/dist/types/components/CardOverview/card-overview-controller.d.ts +13 -1
- package/dist/types/components/CardOverview/card-overview-types.d.ts +8 -2
- package/dist/types/components/CardOverview/index.d.ts +1 -1
- package/dist/types/components/Input/Input.d.ts +1 -1
- package/dist/types/components/Select/Select.d.ts +1 -1
- package/dist/types/components.d.ts +16 -16
- package/package.json +3 -3
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
3
|
"name": "card-overview",
|
|
4
4
|
"title": "CardOverview",
|
|
5
|
-
"description": "Page-level summary
|
|
5
|
+
"description": "Page-level summary with a persistent 48px reporting bar above an equal-track grid of an optional safety score and comparable measures, plus an elevated page-controlled collapse surface.",
|
|
6
6
|
"type": "registry:ui",
|
|
7
7
|
"meta": {
|
|
8
8
|
"library": "@ds-mo/ui",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"intent": {
|
|
14
14
|
"audience": "general",
|
|
15
15
|
"status": "experimental",
|
|
16
|
-
"summary": "Page-level summary
|
|
16
|
+
"summary": "Page-level summary with a persistent 48px reporting bar above an equal-track grid of an optional safety score and comparable measures, plus an elevated page-controlled collapse surface.",
|
|
17
17
|
"useWhen": [
|
|
18
18
|
"A page opens with one headline figure that the surrounding measures explain.",
|
|
19
19
|
"Every measure is compared against the same period, so one caption describes the comparison for all of them.",
|
|
@@ -45,8 +45,7 @@
|
|
|
45
45
|
],
|
|
46
46
|
"accessibility": [
|
|
47
47
|
"The bar is a labelled region; set overviewLabel to name what is being summarised, such as Safety summary.",
|
|
48
|
-
"
|
|
49
|
-
"Colour never carries the trend meaning alone; the arrow direction and the value are both present.",
|
|
48
|
+
"Colour never carries trend meaning alone; the arrow direction and formatted change value are both included in the accessible text.",
|
|
50
49
|
"Measures become selectable only when they are not inactive. Selectable measures form one roving tab stop, so the grid is a single stop and arrow keys move between measures.",
|
|
51
50
|
"Set labelTooltip when a measure's label needs qualifying rather than shortening the label into something ambiguous.",
|
|
52
51
|
"While loading, the region exposes a busy state and renders skeletons whose type metrics match the resolved content."
|
|
@@ -55,20 +54,21 @@
|
|
|
55
54
|
"Score and measures are supplied as data; the component owns their type treatment so summary bars stay consistent across pages.",
|
|
56
55
|
"Trend is supplied already resolved as a direction, a formatted value, and a tone. Whether a rise reads well is a product decision, so the component never infers tone from the numbers. Derive it with resolveMetricTrend.",
|
|
57
56
|
"Omit a trend when there is nothing to report; resolveMetricTrend returns null in that case so no zero change is rendered.",
|
|
58
|
-
"Omit score to render
|
|
57
|
+
"Omit score to render a centered Score unavailable cell with a tertiary border and no score fill. Set scoreErrorMessage to replace that copy while the measures remain readable.",
|
|
59
58
|
"Loading replaces the score and the measures with skeletons and does not alter the slotted period control.",
|
|
60
|
-
"At most
|
|
61
|
-
"The period
|
|
62
|
-
"
|
|
63
|
-
"
|
|
59
|
+
"At most seven measures are shown. Keep larger collections outside the summary bar rather than turning it into a dense dashboard.",
|
|
60
|
+
"The period and filter controls are slotted rather than owned. Use the period slot when the current range is selectable; otherwise periodLabel supplies fixed current copy in the same md control-frame and label-inset anatomy. Use the filter slot for the application-owned comparison-window control. Slotted Selects use hasBorder false so the 48px bar owns their surrounding boundary.",
|
|
61
|
+
"A numeric safety score infers fair from 0–50, good from 51–80, and excellent from 81–100. The level can be supplied explicitly when the displayed value is not numeric. The deprecated band field is ignored.",
|
|
62
|
+
"The safety score is the first grid cell and uses the same track, 8px outer inset, 6px inner padding, dividers, and responsive behavior as metric cells. The display value removes 12px from both block edges of its line box so it does not increase the shared row height. Score remains nonselectable and excluded from metric roving focus.",
|
|
63
|
+
"During page-controlled scroll collapse, the component preserves its expanded flow height and stationary reporting bar while the metric grid moves and clips beneath it. Elevation remains fitted to the visible surface.",
|
|
64
|
+
"compact is exactly 48px high and renders only the reporting bar. It omits Score, measures, and footer."
|
|
64
65
|
],
|
|
65
66
|
"responsiveBehavior": [
|
|
66
|
-
"The measure grid reflows to fewer columns and finally stacks
|
|
67
|
+
"The measure grid reflows to fewer columns and finally stacks without horizontal scrolling. Even cell totals prefer complete rows; odd totals retain the densest fitting layout and may leave an orphan in the final row.",
|
|
67
68
|
"Every occupied grid track has the same width. When a final row is incomplete, its measures keep the same width as the row above and the unused tracks remain empty.",
|
|
68
69
|
"Set metricMinWidth to change the width a measure may shrink to before the grid drops a column.",
|
|
69
|
-
"The score
|
|
70
|
-
"
|
|
71
|
-
"In that stacked summary, the score and trend share one line at the start, while the score band is hidden to preserve space. The period control stays at the upper end, while the current period and comparison sit on separate right-aligned lines beside the score.",
|
|
70
|
+
"The safety score participates in the same equal-width tracks as measures rather than occupying a separate rail.",
|
|
71
|
+
"The reporting bar owns an exact 8px inset on every edge. Fixed current copy and slotted controls begin at that inset; their labels share md control-frame geometry and truncate before changing the 48px height.",
|
|
72
72
|
"Every measure occupies a full-width row in the stacked state.",
|
|
73
73
|
"Set layout to stacked when the owning page shell enters a responsive mode before the card's own container reaches its narrow threshold.",
|
|
74
74
|
"CardOverview does not observe scroll, choose sticky offsets, or switch its own presentation. The page owner supplies collapse progress, keeps the card sticky at the appropriate shell inset, and swaps to compact at the 48px endpoint.",
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
"frameworkCaveats": {
|
|
78
78
|
"customElements": [
|
|
79
79
|
"Assign score and metrics as JavaScript properties; both are objects and cannot be expressed as HTML attributes.",
|
|
80
|
-
"Place the period control in the filter slot; the component reserves
|
|
80
|
+
"Place an optional current-range control in the period slot and the comparison-window control in the filter slot; the component reserves their layout but never computes or renders controls.",
|
|
81
81
|
"When driving scroll collapse, update scrollCollapseProgress from page-owned geometry and swap to a separate compact presentation at the endpoint."
|
|
82
82
|
],
|
|
83
83
|
"react": [
|
|
@@ -88,7 +88,7 @@
|
|
|
88
88
|
"angular": [
|
|
89
89
|
"Bind [score] and [metrics] as properties and read the selected measure from $event.detail on (dsMetricSelect).",
|
|
90
90
|
"Derive each trend with resolveMetricTrend so tone stays an explicit product decision.",
|
|
91
|
-
"Keep sticky geometry and [scrollCollapseProgress] in the page owner; CardOverview only renders the visual collapse."
|
|
91
|
+
"Keep date math, sticky geometry, and [scrollCollapseProgress] in the page owner; CardOverview only renders the supplied composition and visual collapse."
|
|
92
92
|
]
|
|
93
93
|
},
|
|
94
94
|
"references": [
|
|
@@ -111,7 +111,7 @@
|
|
|
111
111
|
"default": "''",
|
|
112
112
|
"required": false,
|
|
113
113
|
"mutable": false,
|
|
114
|
-
"description": "
|
|
114
|
+
"description": "Copy between the current period and comparison control, usually `vs.`."
|
|
115
115
|
},
|
|
116
116
|
"isLoading": {
|
|
117
117
|
"type": "boolean",
|
|
@@ -138,7 +138,7 @@
|
|
|
138
138
|
"default": "'var(--dimension-menu-width-xs)'",
|
|
139
139
|
"required": false,
|
|
140
140
|
"mutable": false,
|
|
141
|
-
"description": "Width a metric cell may shrink to before the grid drops a column. The grid\
|
|
141
|
+
"description": "Width a metric cell may shrink to before the grid drops a column. The grid\nuses this threshold while choosing an evenly distributed column count."
|
|
142
142
|
},
|
|
143
143
|
"metrics": {
|
|
144
144
|
"type": "OverviewMetric[]",
|
|
@@ -146,7 +146,7 @@
|
|
|
146
146
|
"default": "[]",
|
|
147
147
|
"required": false,
|
|
148
148
|
"mutable": false,
|
|
149
|
-
"description": "Measures rendered in the responsive grid. Only the first
|
|
149
|
+
"description": "Measures rendered in the responsive grid. Only the first seven are shown."
|
|
150
150
|
},
|
|
151
151
|
"overviewLabel": {
|
|
152
152
|
"type": "string",
|
|
@@ -164,14 +164,14 @@
|
|
|
164
164
|
"default": "''",
|
|
165
165
|
"required": false,
|
|
166
166
|
"mutable": false,
|
|
167
|
-
"description": "
|
|
167
|
+
"description": "Fixed current date or range. Replaced by content in the `period` slot."
|
|
168
168
|
},
|
|
169
169
|
"score": {
|
|
170
170
|
"type": "OverviewScore | undefined",
|
|
171
171
|
"resolvedType": "OverviewScore | undefined",
|
|
172
172
|
"required": false,
|
|
173
173
|
"mutable": false,
|
|
174
|
-
"description": "
|
|
174
|
+
"description": "Optional nonselectable safety score rendered as the first grid cell."
|
|
175
175
|
},
|
|
176
176
|
"scoreErrorMessage": {
|
|
177
177
|
"type": "string | undefined",
|
|
@@ -188,7 +188,7 @@
|
|
|
188
188
|
"default": "0",
|
|
189
189
|
"required": false,
|
|
190
190
|
"mutable": false,
|
|
191
|
-
"description": "Page-controlled visual collapse from the full card (`0`) toward its 48px\ncompact handoff height (`1`). The component preserves its expanded flow\nheight, keeps
|
|
191
|
+
"description": "Page-controlled visual collapse from the full card (`0`) toward its 48px\ncompact handoff height (`1`). The component preserves its expanded flow\nheight, keeps the period bar stationary, and moves/clips the grid beneath\nit. The page still owns sticky positioning and the final compact handoff."
|
|
192
192
|
},
|
|
193
193
|
"variant": {
|
|
194
194
|
"type": "CardOverviewVariant",
|
|
@@ -221,7 +221,7 @@
|
|
|
221
221
|
"default": "''",
|
|
222
222
|
"required": false,
|
|
223
223
|
"mutable": false,
|
|
224
|
-
"description": "
|
|
224
|
+
"description": "Copy between the current period and comparison control, usually `vs.`."
|
|
225
225
|
},
|
|
226
226
|
"isLoading": {
|
|
227
227
|
"type": "boolean",
|
|
@@ -248,7 +248,7 @@
|
|
|
248
248
|
"default": "'var(--dimension-menu-width-xs)'",
|
|
249
249
|
"required": false,
|
|
250
250
|
"mutable": false,
|
|
251
|
-
"description": "Width a metric cell may shrink to before the grid drops a column. The grid\
|
|
251
|
+
"description": "Width a metric cell may shrink to before the grid drops a column. The grid\nuses this threshold while choosing an evenly distributed column count."
|
|
252
252
|
},
|
|
253
253
|
"metrics": {
|
|
254
254
|
"type": "OverviewMetric[]",
|
|
@@ -256,7 +256,7 @@
|
|
|
256
256
|
"default": "[]",
|
|
257
257
|
"required": false,
|
|
258
258
|
"mutable": false,
|
|
259
|
-
"description": "Measures rendered in the responsive grid. Only the first
|
|
259
|
+
"description": "Measures rendered in the responsive grid. Only the first seven are shown."
|
|
260
260
|
},
|
|
261
261
|
"overviewLabel": {
|
|
262
262
|
"type": "string",
|
|
@@ -274,14 +274,14 @@
|
|
|
274
274
|
"default": "''",
|
|
275
275
|
"required": false,
|
|
276
276
|
"mutable": false,
|
|
277
|
-
"description": "
|
|
277
|
+
"description": "Fixed current date or range. Replaced by content in the `period` slot."
|
|
278
278
|
},
|
|
279
279
|
"score": {
|
|
280
280
|
"type": "OverviewScore | undefined",
|
|
281
281
|
"resolvedType": "OverviewScore | undefined",
|
|
282
282
|
"required": false,
|
|
283
283
|
"mutable": false,
|
|
284
|
-
"description": "
|
|
284
|
+
"description": "Optional nonselectable safety score rendered as the first grid cell."
|
|
285
285
|
},
|
|
286
286
|
"scoreErrorMessage": {
|
|
287
287
|
"type": "string | undefined",
|
|
@@ -298,7 +298,7 @@
|
|
|
298
298
|
"default": "0",
|
|
299
299
|
"required": false,
|
|
300
300
|
"mutable": false,
|
|
301
|
-
"description": "Page-controlled visual collapse from the full card (`0`) toward its 48px\ncompact handoff height (`1`). The component preserves its expanded flow\nheight, keeps
|
|
301
|
+
"description": "Page-controlled visual collapse from the full card (`0`) toward its 48px\ncompact handoff height (`1`). The component preserves its expanded flow\nheight, keeps the period bar stationary, and moves/clips the grid beneath\nit. The page still owns sticky positioning and the final compact handoff."
|
|
302
302
|
},
|
|
303
303
|
"variant": {
|
|
304
304
|
"type": "CardOverviewVariant",
|
|
@@ -345,7 +345,7 @@
|
|
|
345
345
|
"complexPropertyNote": "Assign these non-primitive values as JavaScript properties: metrics, score.",
|
|
346
346
|
"peerDependencies": {
|
|
347
347
|
"required": [
|
|
348
|
-
"@ds-mo/tokens ^5.1.
|
|
348
|
+
"@ds-mo/tokens ^5.1.1",
|
|
349
349
|
"@ds-mo/icons ^6.4.0"
|
|
350
350
|
],
|
|
351
351
|
"frameworks": "Custom Elements; React 18/19 wrappers; Angular 19-22 standalone adapters."
|
|
@@ -354,11 +354,9 @@
|
|
|
354
354
|
},
|
|
355
355
|
"dependencies": [
|
|
356
356
|
"@ds-mo/ui",
|
|
357
|
-
"@ds-mo/tokens"
|
|
358
|
-
"@ds-mo/icons"
|
|
357
|
+
"@ds-mo/tokens"
|
|
359
358
|
],
|
|
360
359
|
"registryDependencies": [
|
|
361
|
-
"icon",
|
|
362
360
|
"skeleton",
|
|
363
361
|
"text",
|
|
364
362
|
"tooltip"
|
|
@@ -366,22 +364,22 @@
|
|
|
366
364
|
"files": [
|
|
367
365
|
{
|
|
368
366
|
"path": "src/wc/components/CardOverview/CardOverview.css",
|
|
369
|
-
"content": "@import '../../utils/interaction-fill.css';\n@import '../../utils/focus-ring.css';\n@import '../../utils/control-density.css';\n@import '../../utils/control-parts.css';\n@import '../../styles/control-elevation.css';\n\n/* The summary bar follows the always-dark sub-theme. */\n\n:host {\n display: block;\n box-sizing: border-box;\n /* Drives the narrow layout below from the card's own width, not the viewport's. */\n container-type: inline-size;\n /* A summary is read, not copied; stray selection while clicking cells is noise. */\n -webkit-user-select: none;\n user-select: none;\n /* Width a metric may shrink to before the grid drops a column. */\n --ds-card-overview-metric-min: calc(var(--dimension-size-400) * 5);\n --ds-card-overview-divider-width: var(--dimension-stroke-width-012);\n --ds-card-overview-divider-color: var(--color-always-dark-border-tertiary);\n --ds-card-overview-divider: var(--ds-card-overview-divider-width) solid\n var(--ds-card-overview-divider-color);\n color: var(--color-always-dark-foreground-primary);\n}\n\n.card-overview__surface {\n width: 100%;\n min-width: 0;\n box-sizing: border-box;\n border-radius: var(--dimension-radius-050);\n background: var(--color-always-dark-background);\n color: var(--color-always-dark-foreground-primary);\n overflow-anchor: none;\n}\n\n/*\n * The visual surface owns elevation outside this clipping viewport. Keeping\n * those layers separate lets a page shrink the surface while content moves and\n * clips inside it without cutting off the shadow or inset highlight.\n */\n.card-overview__clip {\n height: 100%;\n min-width: 0;\n border-radius: inherit;\n background: inherit;\n overflow: hidden;\n}\n\n:host(.card-overview--scroll-collapsing) {\n height: var(--ds-card-overview-expanded-height);\n pointer-events: none;\n}\n\n:host(.card-overview--scroll-collapsing) .card-overview__surface {\n height: var(--ds-card-overview-visible-height);\n pointer-events: auto;\n will-change: height;\n}\n\n:host(.card-overview--scroll-collapsing) .card-overview__layout {\n transform: translateY(calc(-1 * var(--ds-card-overview-content-offset)));\n will-change: transform;\n}\n\n.card-overview__layout {\n display: grid;\n grid-template-rows: auto minmax(0, 1fr);\n grid-template-columns: minmax(0, 1fr);\n align-items: stretch;\n min-width: 0;\n}\n\n.card-overview__layout--has-score {\n grid-template-columns: auto minmax(0, 1fr);\n}\n\n/*\n * Transparent at regular widths so the score and header participate in the\n * inner layout grid directly. At the narrow breakpoint it becomes the unified\n * summary block above the metrics.\n */\n.card-overview__summary {\n display: contents;\n}\n\n/* ── Score ────────────────────────────────────────────────────────────────── */\n\n/*\n * Hugs its content and never shrinks, so the headline figure keeps its size and\n * the metric grid absorbs the remaining width.\n */\n/*\n * Top aligned rather than centred, and padded to match the header, so the score\n * label sits in the same 32px box at the same offset as the period text beside\n * it. Both use the same type variant, so their baselines land together.\n */\n.card-overview__score {\n display: flex;\n grid-row: 1 / span 2;\n grid-column: 1;\n flex: 0 0 auto;\n flex-direction: column;\n gap: 0;\n min-width: 0;\n padding: var(--dimension-space-100) var(--dimension-space-200);\n border-inline-end: var(--ds-card-overview-divider);\n}\n\n.card-overview__score--resolved {\n min-inline-size: max-content;\n}\n\n/* The control-height box that aligns this label with the period text. */\n.card-overview__score-label-row {\n display: flex;\n align-items: center;\n min-height: var(--ds-control-height);\n}\n\n/*\n * The score is its own column, so its rows cannot baseline-align with the measure\n * rows through flex or grid — those only align items that share a line. These two\n * offsets pull the column onto the measure baselines instead.\n *\n * They are compensation for how much lower a display-scale figure sits in its line\n * box than the body text it aligns to, so they are coupled to the type pairing:\n * change the score or measure variants and both need re-measuring.\n */\n.card-overview__score-figure {\n display: flex;\n align-items: baseline;\n gap: var(--dimension-space-050);\n min-width: 0;\n margin-block-start: calc(-1 * (var(--dimension-space-150) + var(--dimension-space-012)));\n}\n\n.card-overview__score-value {\n flex: 0 0 auto;\n}\n\n/* Second half of the baseline compensation described above the score figure. */\n.card-overview__score-band {\n margin-block-start: calc(-1 * var(--dimension-space-025));\n}\n\n/*\n * A skeleton bar is a solid block, so in a baseline-aligned row it aligns on its\n * bottom edge while the text it stands in for aligns on its baseline. Next to a\n * display-scale figure that difference is the descent under the figure's\n * baseline, which drops the bar below where the resolved trend sits.\n *\n * The offset is applied with relative positioning rather than a margin: a margin\n * is not part of a synthesized baseline, so it grows the figure instead of moving\n * the bar, which then pushes the band below it out of place.\n *\n * Only needed beside the score figure; the measure rows pair body variants whose\n * bottom edge and baseline already agree.\n */\n.card-overview__skeleton-baseline {\n position: relative;\n inset-block-start: calc(-1 * var(--dimension-space-150));\n}\n\n.card-overview__score--error {\n flex-direction: row;\n align-items: center;\n gap: var(--dimension-space-050);\n color: var(--color-always-dark-foreground-negative);\n}\n\n/* ── Body ─────────────────────────────────────────────────────────────────── */\n\n/*\n * Takes the remaining inline space. The minimum is what makes the host wrap: once\n * the score and roughly two measure columns no longer fit side by side, the body\n * drops below the score instead of squeezing it. `min()` keeps that from becoming\n * an overflow floor on very narrow viewports.\n */\n.card-overview__body {\n display: flex;\n grid-row: 2;\n grid-column: 1;\n flex-direction: column;\n min-width: 0;\n}\n\n.card-overview__body--has-score {\n grid-column: 2;\n}\n\n/*\n * One control row: 8px of padding on every side around a 32px md control, so the\n * bar is 8 + 32 + 8. Both ends of the bar are control-shaped boxes — the period\n * text on the left and the slotted control on the right — so the row reads\n * balanced rather than text on one side and a control on the other.\n */\n.card-overview__header {\n display: flex;\n grid-row: 1;\n grid-column: 1;\n align-items: center;\n gap: var(--dimension-space-100);\n min-width: 0;\n padding: var(--dimension-space-100);\n border-block-end: var(--ds-card-overview-divider);\n box-sizing: border-box;\n}\n\n.card-overview__header--has-score {\n grid-column: 2;\n}\n\n/*\n * Matches the control's box on the opposite end, including its inline padding, so\n * the text lands at the same optical inset the slotted control does:\n * 8 from the bar + 6 from this box + 2 from the label inset = 16.\n *\n * Nowrap keeps the row at the control height; the period truncates rather than\n * growing the bar to two lines.\n */\n.card-overview__period {\n display: flex;\n flex: 1 1 auto;\n align-items: center;\n gap: var(--dimension-space-050);\n min-height: var(--ds-control-height);\n min-width: 0;\n padding-inline: var(--ds-control-padding-inline);\n overflow: hidden;\n white-space: nowrap;\n}\n\n/* The period control is slotted, so only reserve space for it. */\n.card-overview__filter {\n display: flex;\n flex: 0 0 auto;\n align-items: center;\n}\n\n/* ── Metrics ──────────────────────────────────────────────────────────────── */\n\n/*\n * `auto-fit` gives every occupied track an equal share while all metrics fit on\n * one row. Once wrapping creates another row, its cells stay on those same\n * tracks, so a partial final row leaves empty space instead of stretching one\n * measure wider than its peers.\n *\n * Dividers are painted outward from each cell and clipped by this grid. That\n * leaves only the lines between cells: anything emitted from the final column or\n * final row lands outside the grid and is clipped without needing to detect the\n * number of tracks.\n *\n * `flex: 1 1 auto` makes the grid absorb whatever height the body has\n * left, so cells reach the card bottom and their hover wash has no dead strip.\n */\n.card-overview__metrics {\n display: grid;\n flex: 1 1 auto;\n grid-template-columns: repeat(\n auto-fit,\n minmax(min(100%, var(--ds-card-overview-metric-min)), 1fr)\n );\n align-content: stretch;\n min-width: 0;\n overflow: clip;\n}\n\n/*\n * Square by design. Cells tile edge to edge against their dividers, so a radius\n * would break the seam; the card's own radius clips the outer corners instead.\n *\n * Padding is plain rather than control-derived: a cell is a block of content, not\n * a control box that has to optically match something on the far side.\n */\n.card-overview__metric {\n display: flex;\n position: relative;\n flex-direction: column;\n gap: var(--dimension-space-050);\n min-width: 0;\n padding: var(--dimension-space-175) var(--dimension-space-200);\n border-radius: 0;\n box-shadow:\n var(--ds-card-overview-divider-width) 0 0 0 var(--ds-card-overview-divider-color),\n 0 var(--ds-card-overview-divider-width) 0 0 var(--ds-card-overview-divider-color);\n}\n\n.card-overview__metric[role='button'] {\n cursor: default;\n -webkit-user-select: none;\n user-select: none;\n}\n\n.card-overview__metric-label {\n min-width: 0;\n}\n\n.card-overview__metric-figure {\n display: flex;\n align-items: baseline;\n gap: var(--dimension-space-100);\n min-width: 0;\n}\n\n/* ── Trend ────────────────────────────────────────────────────────────────── */\n\n/*\n * Tone arrives resolved from the caller: the arrow direction and the sentiment\n * are independent, so a falling metric can read positive or neutral. The arrow is\n * a glyph inside this text node, so it always matches the surrounding weight.\n */\n.card-overview__trend {\n flex: 0 0 auto;\n white-space: nowrap;\n}\n\n/* ── Narrow layout ────────────────────────────────────────────────────────── */\n\n/*\n * Below roughly two measure columns the card becomes a full stack. The summary\n * wrapper owns one block above the metrics: score label, figure, and trend stay\n * together at the start; the period control sits at the upper end; and the period\n * copy follows the score instead of becoming a separate divided row.\n */\n/*\n * Selectors are host-qualified purely for specificity: the compiled sheet places\n * these rules ahead of the base ones, so a plain class here would only ever add\n * properties and never override them.\n */\n@container (max-width: 480px) {\n :host .card-overview__layout {\n grid-template-rows: auto minmax(0, 1fr);\n grid-template-columns: minmax(0, 1fr);\n }\n\n :host .card-overview__summary {\n display: grid;\n grid-row: 1;\n grid-column: 1;\n grid-template-columns: minmax(0, 1fr) auto;\n grid-template-rows: auto;\n border-block-end: var(--ds-card-overview-divider);\n }\n\n :host .card-overview__score {\n display: grid;\n grid-row: 1;\n grid-column: 1;\n grid-template-rows: auto auto;\n grid-template-columns: auto auto;\n justify-content: start;\n column-gap: var(--dimension-space-100);\n width: auto;\n padding-block-end: var(--dimension-space-100);\n padding-inline-end: var(--dimension-space-100);\n border-inline-end: none;\n }\n\n :host .card-overview__score-label-row {\n grid-row: 1;\n grid-column: 1 / -1;\n min-height: var(--ds-control-height);\n }\n\n /*\n * The wide score uses optical offsets to meet the neighbouring metric\n * baselines. In the stacked summary those neighbours are gone, so natural\n * document flow keeps the label, figure, band, and period clearly ordered.\n */\n :host .card-overview__score-band,\n :host .card-overview__score-figure {\n grid-row: 2;\n margin-block-start: 0;\n }\n\n :host .card-overview__score-figure {\n grid-column: 1;\n align-self: baseline;\n gap: var(--dimension-space-100);\n }\n\n :host .card-overview__score-band {\n grid-column: 2;\n align-self: baseline;\n display: none;\n }\n\n :host .card-overview__header {\n display: grid;\n grid-row: 1;\n grid-column: 2;\n grid-template-rows: auto auto;\n align-content: start;\n gap: 0;\n padding: 0;\n border-block-end: none;\n }\n\n :host .card-overview__filter {\n grid-row: 1;\n grid-column: 1;\n align-self: start;\n justify-self: end;\n padding: var(--dimension-space-100) var(--dimension-space-100) 0 0;\n }\n\n :host .card-overview__period {\n grid-row: 2;\n grid-column: 1;\n flex-direction: column;\n align-items: flex-end;\n justify-self: stretch;\n gap: 0;\n min-height: 0;\n padding-block: var(--dimension-space-150) var(--dimension-space-100);\n padding-inline: var(--dimension-space-100) var(--dimension-space-200);\n overflow: visible;\n text-align: end;\n white-space: nowrap;\n }\n\n :host .card-overview__body {\n grid-row: 2;\n grid-column: 1;\n }\n}\n\n/*\n * Page shells may enter a responsive mode before this card itself becomes\n * narrow. The explicit stacked layout applies the same composition without\n * coupling CardOverview to a viewport breakpoint.\n */\n:host(.card-overview--stacked) .card-overview__layout {\n grid-template-rows: auto minmax(0, 1fr);\n grid-template-columns: minmax(0, 1fr);\n}\n\n:host(.card-overview--stacked) .card-overview__summary {\n display: grid;\n grid-row: 1;\n grid-column: 1;\n grid-template-columns: minmax(0, 1fr) auto;\n grid-template-rows: auto;\n border-block-end: var(--ds-card-overview-divider);\n}\n\n:host(.card-overview--stacked) .card-overview__score {\n display: grid;\n grid-row: 1;\n grid-column: 1;\n grid-template-rows: auto auto;\n grid-template-columns: auto auto;\n justify-content: start;\n column-gap: var(--dimension-space-100);\n width: auto;\n padding-block-end: var(--dimension-space-100);\n padding-inline-end: var(--dimension-space-100);\n border-inline-end: none;\n}\n\n:host(.card-overview--stacked) .card-overview__score-label-row {\n grid-row: 1;\n grid-column: 1 / -1;\n min-height: var(--ds-control-height);\n}\n\n:host(.card-overview--stacked) .card-overview__score-band,\n:host(.card-overview--stacked) .card-overview__score-figure {\n grid-row: 2;\n margin-block-start: 0;\n}\n\n:host(.card-overview--stacked) .card-overview__score-figure {\n grid-column: 1;\n align-self: baseline;\n gap: var(--dimension-space-100);\n}\n\n:host(.card-overview--stacked) .card-overview__score-band {\n grid-column: 2;\n align-self: baseline;\n display: none;\n}\n\n:host(.card-overview--stacked) .card-overview__header {\n display: grid;\n grid-row: 1;\n grid-column: 2;\n grid-template-rows: auto auto;\n align-content: start;\n gap: 0;\n padding: 0;\n border-block-end: none;\n}\n\n:host(.card-overview--stacked) .card-overview__filter {\n grid-row: 1;\n grid-column: 1;\n align-self: start;\n justify-self: end;\n padding: var(--dimension-space-100) var(--dimension-space-100) 0 0;\n}\n\n:host(.card-overview--stacked) .card-overview__period {\n grid-row: 2;\n grid-column: 1;\n flex-direction: column;\n align-items: flex-end;\n justify-self: stretch;\n gap: 0;\n min-height: 0;\n padding-block: var(--dimension-space-150) var(--dimension-space-100);\n padding-inline: var(--dimension-space-100) var(--dimension-space-200);\n overflow: visible;\n text-align: end;\n white-space: nowrap;\n}\n\n:host(.card-overview--stacked) .card-overview__body {\n grid-row: 2;\n grid-column: 1;\n}\n\n:host(.card-overview--stacked) .card-overview__metrics {\n grid-template-columns: minmax(0, 1fr);\n}\n\n/* ── Compact presentation ───────────────────────────────────────────────── */\n\n/*\n * Matches the shared 48px bar contract: one 32px control row with 8px above\n * and below. The score remains a distinct leading cell, while reporting copy\n * absorbs the available width and the application-owned control never shrinks.\n */\n:host(.card-overview--compact) {\n height: var(--dimension-size-600);\n min-height: var(--dimension-size-600);\n}\n\n:host(.card-overview--compact) .card-overview__surface {\n height: 100%;\n}\n\n:host(.card-overview--compact) .card-overview__layout,\n:host(.card-overview--compact) .card-overview__summary {\n display: flex;\n width: 100%;\n height: 100%;\n min-width: 0;\n}\n\n:host(.card-overview--compact) .card-overview__score {\n display: flex;\n flex: 0 0 auto;\n flex-direction: row;\n align-items: center;\n gap: var(--dimension-space-100);\n width: auto;\n height: 100%;\n min-width: 0;\n padding: var(--dimension-space-100) var(--dimension-space-200);\n border-inline-end: var(--ds-card-overview-divider);\n box-sizing: border-box;\n}\n\n:host(.card-overview--compact) .card-overview__score-label-row {\n display: contents;\n min-height: 0;\n}\n\n:host(.card-overview--compact) .card-overview__score-label,\n:host(.card-overview--compact) .card-overview__score-figure,\n:host(.card-overview--compact) .card-overview__trend {\n flex: 0 0 auto;\n}\n\n:host(.card-overview--compact) .card-overview__score-figure {\n display: flex;\n align-self: center;\n align-items: baseline;\n gap: var(--dimension-space-050);\n margin-block-start: 0;\n}\n\n:host(.card-overview--compact) .card-overview__score-band {\n display: none;\n}\n\n:host(.card-overview--compact) .card-overview__header {\n display: flex;\n flex: 1 1 auto;\n grid-row: auto;\n grid-column: auto;\n align-items: center;\n gap: var(--dimension-space-100);\n height: 100%;\n min-width: 0;\n padding: var(--dimension-space-100);\n border-block-end: none;\n box-sizing: border-box;\n}\n\n:host(.card-overview--compact) .card-overview__period {\n display: flex;\n flex: 1 1 auto;\n flex-direction: row;\n align-items: center;\n gap: var(--dimension-space-050);\n min-width: 0;\n min-height: var(--ds-control-height);\n padding-inline: var(--ds-control-padding-inline);\n overflow: hidden;\n text-align: start;\n white-space: nowrap;\n}\n\n:host(.card-overview--compact) .card-overview__period-current,\n:host(.card-overview--compact) .card-overview__period-comparison {\n min-width: 0;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n\n:host(.card-overview--compact) .card-overview__period-current {\n flex: 0 1 auto;\n}\n\n:host(.card-overview--compact) .card-overview__period-comparison {\n flex: 1 1 auto;\n}\n\n:host(.card-overview--compact) .card-overview__filter {\n display: flex;\n flex: 0 0 auto;\n align-items: center;\n padding: 0;\n}\n",
|
|
367
|
+
"content": "@import '../../utils/interaction-fill.css';\n@import '../../utils/focus-ring.css';\n@import '../../utils/control-density.css';\n@import '../../utils/control-parts.css';\n@import '../../styles/control-elevation.css';\n\n:host {\n display: block;\n box-sizing: border-box;\n container-type: inline-size;\n -webkit-user-select: none;\n user-select: none;\n --ds-card-overview-metric-min: calc(var(--dimension-size-400) * 5);\n --ds-card-overview-divider-width: var(--dimension-stroke-width-012);\n --ds-card-overview-divider-color: var(--color-always-dark-border-tertiary);\n color: var(--color-always-dark-foreground-primary);\n}\n\n.card-overview__surface {\n width: 100%;\n min-width: 0;\n box-sizing: border-box;\n border-radius: var(--dimension-radius-125);\n background: var(--color-always-dark-background);\n color: var(--color-always-dark-foreground-primary);\n overflow-anchor: none;\n}\n\n.card-overview__clip {\n height: 100%;\n min-width: 0;\n border-radius: inherit;\n background: inherit;\n overflow: hidden;\n}\n\n:host(.card-overview--scroll-collapsing) {\n height: var(--ds-card-overview-expanded-height);\n pointer-events: none;\n}\n\n:host(.card-overview--scroll-collapsing) .card-overview__surface {\n height: var(--ds-card-overview-visible-height);\n pointer-events: auto;\n will-change: height;\n}\n\n:host(.card-overview--scroll-collapsing) .card-overview__body {\n transform: translateY(calc(-1 * var(--ds-card-overview-content-offset)));\n will-change: transform;\n}\n\n.card-overview__layout {\n display: flex;\n flex-direction: column;\n min-width: 0;\n}\n\n.card-overview__summary {\n position: relative;\n z-index: 1;\n flex: 0 0 auto;\n min-width: 0;\n background: var(--color-always-dark-background);\n}\n\n.card-overview__header {\n display: flex;\n position: relative;\n align-items: center;\n gap: 0;\n width: 100%;\n height: var(--dimension-size-600);\n min-width: 0;\n padding: var(--dimension-space-100);\n box-sizing: border-box;\n}\n\n.card-overview__header::after {\n content: '';\n position: absolute;\n inset-inline: 0;\n inset-block-end: 0;\n height: var(--ds-card-overview-divider-width);\n background: var(--ds-card-overview-divider-color);\n pointer-events: none;\n}\n\n.card-overview__period {\n display: flex;\n flex: 0 1 auto;\n align-items: center;\n gap: 0;\n min-width: 0;\n min-height: var(--ds-control-height);\n overflow: hidden;\n white-space: nowrap;\n}\n\n.card-overview__period-current,\n.card-overview__period-comparison {\n min-width: 0;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n\n.card-overview__period-current {\n display: flex;\n flex: 0 1 auto;\n align-items: center;\n}\n\n.card-overview__period-fixed {\n flex: 0 1 auto;\n min-width: 0;\n}\n\n.card-overview__period-comparison {\n flex: 0 0 auto;\n}\n\n.card-overview__filter {\n display: flex;\n flex: 0 1 auto;\n align-items: center;\n min-width: 0;\n}\n\n.card-overview__body {\n display: flex;\n position: relative;\n z-index: 0;\n flex-direction: column;\n min-width: 0;\n transform: translateY(0);\n}\n\n.card-overview__metrics {\n display: grid;\n flex: 1 1 auto;\n grid-template-columns: repeat(\n var(--ds-card-overview-grid-columns, auto-fit),\n minmax(min(100%, var(--ds-card-overview-metric-min)), 1fr)\n );\n align-content: stretch;\n min-width: 0;\n overflow: clip;\n}\n\n.card-overview__score,\n.card-overview__metric {\n display: flex;\n min-width: 0;\n padding: var(--dimension-space-100);\n box-shadow:\n var(--ds-card-overview-divider-width) 0 0 0 var(--ds-card-overview-divider-color),\n 0 var(--ds-card-overview-divider-width) 0 0 var(--ds-card-overview-divider-color);\n box-sizing: border-box;\n}\n\n.card-overview__score-content,\n.card-overview__metric-action {\n display: flex;\n flex: 1 1 auto;\n min-width: 0;\n padding: var(--dimension-space-075);\n border-radius: var(--dimension-radius-025);\n box-sizing: border-box;\n}\n\n.card-overview__score-content {\n align-items: center;\n justify-content: space-between;\n gap: var(--dimension-space-100);\n background: var(--color-always-dark-interaction-active);\n color: var(--color-always-dark-foreground-primary);\n}\n\n.card-overview__score-content--fair {\n background: var(--color-safety-score-background-fair);\n color: var(--color-safety-score-foreground-on-fair);\n}\n\n.card-overview__score-content--good {\n background: var(--color-safety-score-background-good);\n color: var(--color-safety-score-foreground-on-good);\n}\n\n.card-overview__score-content--excellent {\n background: var(--color-safety-score-background-excellent);\n color: var(--color-safety-score-foreground-on-excellent);\n}\n\n.card-overview__score-copy {\n display: flex;\n flex: 1 1 auto;\n flex-direction: column;\n align-items: flex-start;\n gap: var(--dimension-space-025);\n min-width: 0;\n}\n\n.card-overview__score-value,\n.card-overview__score-figure {\n flex: 0 0 auto;\n margin-block: calc(-1 * var(--dimension-space-150));\n}\n\n.card-overview__score-content--error {\n align-items: center;\n justify-content: center;\n border: var(--ds-card-overview-divider-width) solid\n var(--color-always-dark-border-tertiary);\n background: transparent;\n color: var(--color-always-dark-foreground-negative);\n text-align: center;\n}\n\n.card-overview__metric-action {\n flex-direction: column;\n justify-content: center;\n gap: var(--dimension-space-050);\n}\n\n.card-overview__metric-action[role='button'] {\n cursor: default;\n}\n\n.card-overview__metric-content {\n display: flex;\n flex-direction: column;\n justify-content: center;\n gap: var(--dimension-space-050);\n min-width: 0;\n}\n\n.card-overview__metric-label {\n min-width: 0;\n}\n\n.card-overview__metric-figure {\n display: flex;\n align-items: baseline;\n gap: var(--dimension-space-100);\n min-width: 0;\n}\n\n.card-overview__trend {\n flex: 0 0 auto;\n white-space: nowrap;\n}\n\n:host(.card-overview--stacked) .card-overview__metrics {\n grid-template-columns: minmax(0, 1fr);\n}\n\n:host(.card-overview--compact) {\n height: var(--dimension-size-600);\n min-height: var(--dimension-size-600);\n}\n\n:host(.card-overview--compact) .card-overview__surface,\n:host(.card-overview--compact) .card-overview__clip,\n:host(.card-overview--compact) .card-overview__layout,\n:host(.card-overview--compact) .card-overview__summary {\n width: 100%;\n height: 100%;\n}\n\n:host(.card-overview--compact) .card-overview__header::after {\n display: none;\n}\n\n@media (forced-colors: active) {\n .card-overview__header::after {\n background: var(--ds-forced-color-content);\n }\n\n .card-overview__score-content {\n border: var(--dimension-stroke-width-012) solid var(--ds-forced-color-content);\n background: var(--ds-forced-color-surface);\n color: var(--ds-forced-color-content);\n }\n}\n",
|
|
370
368
|
"type": "registry:ui"
|
|
371
369
|
},
|
|
372
370
|
{
|
|
373
371
|
"path": "src/wc/components/CardOverview/CardOverview.tsx",
|
|
374
|
-
"content": "import { Component, Element, Event, EventEmitter, h, Host, Prop, State } from '@stencil/core';\nimport { resolveCssLengthPx, TOKEN_DEFAULTS } from '../../utils';\nimport type { TextColor, TextVariant } from '../Text/text-types';\nimport type { MetricTrend } from '../../utils/metric-change';\nimport type {\n CardOverviewLayout,\n CardOverviewVariant,\n OverviewMetric,\n OverviewScore,\n} from './card-overview-types';\nimport {\n findNextOverviewMetricIndex,\n resolveCardOverviewCollapseGeometry,\n resolveOverviewRovingIndex,\n} from './card-overview-controller';\n\n/** Metric cells below this width drop a grid column rather than compress further. */\nconst DEFAULT_METRIC_MIN_WIDTH = 'var(--dimension-menu-width-xs)';\n\n/** Skeleton cells rendered while loading with no metrics supplied yet. */\nconst LOADING_PLACEHOLDER_COUNT = 4;\n\n/** Maximum number of comparable measures the summary bar presents at once. */\nconst MAX_METRIC_COUNT = 6;\n\nconst TREND_COLORS: Record<MetricTrend['tone'], TextColor> = {\n positive: 'var(--color-always-dark-foreground-positive)',\n negative: 'var(--color-always-dark-foreground-negative)',\n neutral: 'var(--color-always-dark-foreground-secondary)',\n};\n\nconst ALWAYS_DARK_PRIMARY: TextColor = 'var(--color-always-dark-foreground-primary)';\nconst ALWAYS_DARK_SECONDARY: TextColor = 'var(--color-always-dark-foreground-secondary)';\n\n@Component({\n tag: 'ds-card-overview',\n styleUrl: 'CardOverview.css',\n scoped: true,\n})\nexport class CardOverview {\n @Element() el!: HTMLElement;\n\n /** Full summary card, or the condensed 48px summary bar. */\n @Prop() variant: CardOverviewVariant = 'default';\n\n /** Intrinsic responsive layout, or a page-owned single-column stack. */\n @Prop() layout: CardOverviewLayout = 'auto';\n\n /** Leading summary block. Omit to render the bar without a headline figure. */\n @Prop() score: OverviewScore | undefined;\n\n /** Current reporting period, for example `Jun 29, 2026 – Jul 26, 2026`. */\n @Prop() periodLabel: string = '';\n\n /** Comparison caption, for example `vs Previous period`. */\n @Prop() comparisonLabel: string = '';\n\n /** Measures rendered in the responsive grid. Only the first six are shown. */\n @Prop() metrics: OverviewMetric[] = [];\n\n /**\n * Width a metric cell may shrink to before the grid drops a column. The grid\n * reflows and then stacks from this alone, so no measurement is required.\n */\n @Prop() metricMinWidth: string = DEFAULT_METRIC_MIN_WIDTH;\n\n /** Replace the score and metrics with skeletons while data resolves. */\n @Prop() isLoading: boolean = false;\n\n /** Message shown in place of the score when its figure cannot be resolved. */\n @Prop() scoreErrorMessage: string | undefined;\n\n /** Accessible name for the region. */\n @Prop() overviewLabel: string = 'Overview';\n\n /**\n * Page-controlled visual collapse from the full card (`0`) toward its 48px\n * compact handoff height (`1`). The component preserves its expanded flow\n * height, keeps elevation on the shrinking surface, and clips translated\n * content internally. The page still owns sticky positioning and the final\n * swap to `variant=\"compact\"`.\n */\n @Prop() scrollCollapseProgress: number = 0;\n\n /** Emitted when a metric that is not inactive is activated. */\n @Event() dsMetricSelect!: EventEmitter<OverviewMetric>;\n\n /** Roving tab stop across selectable metrics. */\n @State() private focusedMetricIndex: number = 0;\n @State() private expandedHeight: number = 0;\n\n private layoutEl?: HTMLElement;\n private layoutResizeObserver: ResizeObserver | null = null;\n\n componentDidLoad() {\n this.observeLayout();\n }\n\n componentDidRender() {\n // Re-bind after HMR when DidLoad's observer was dropped.\n if (!this.layoutResizeObserver) this.observeLayout();\n }\n\n disconnectedCallback() {\n this.layoutResizeObserver?.disconnect();\n this.layoutResizeObserver = null;\n }\n\n private get hasScore(): boolean {\n return this.score !== undefined || this.scoreErrorMessage !== undefined || this.isLoading;\n }\n\n private get visibleMetrics(): OverviewMetric[] {\n return this.metrics.slice(0, MAX_METRIC_COUNT);\n }\n\n private get resolvedScrollCollapseProgress(): number {\n if (this.variant === 'compact' || !Number.isFinite(this.scrollCollapseProgress)) return 0;\n return Math.min(1, Math.max(0, this.scrollCollapseProgress));\n }\n\n private get scrollCollapseGeometry() {\n const compactHeight = resolveCssLengthPx(TOKEN_DEFAULTS.size600, 48);\n return resolveCardOverviewCollapseGeometry({\n variant: this.variant,\n progress: this.resolvedScrollCollapseProgress,\n expandedHeight: this.expandedHeight,\n compactHeight,\n });\n }\n\n private observeLayout() {\n const layout = this.layoutEl;\n if (!layout) return;\n\n const updateHeight = (height: number) => {\n if (height > 0 && Math.abs(height - this.expandedHeight) >= 0.5) {\n this.expandedHeight = height;\n }\n };\n\n updateHeight(layout.getBoundingClientRect().height);\n if (typeof ResizeObserver === 'undefined') return;\n\n this.layoutResizeObserver?.disconnect();\n this.layoutResizeObserver = new ResizeObserver(entries => {\n const height = entries[0]?.contentRect.height;\n if (height !== undefined) updateHeight(height);\n });\n this.layoutResizeObserver.observe(layout);\n }\n\n /** Index of the roving tab stop, skipping inactive metrics. */\n private get rovingIndex(): number {\n return resolveOverviewRovingIndex(this.visibleMetrics, this.focusedMetricIndex);\n }\n\n private selectMetric(metric: OverviewMetric, index: number) {\n if (metric.isInactive) return;\n this.focusedMetricIndex = index;\n this.dsMetricSelect.emit(metric);\n }\n\n /** Move the roving tab stop, wrapping and skipping inactive metrics. */\n private moveFocus(from: number, step: number) {\n const metrics = this.visibleMetrics;\n const next = findNextOverviewMetricIndex(metrics, from, step < 0 ? -1 : 1);\n if (next < 0) return;\n\n this.focusedMetricIndex = next;\n const cells = this.el.querySelectorAll<HTMLElement>('.card-overview__metric');\n cells[next]?.focus();\n }\n\n private handleMetricKeyDown = (event: KeyboardEvent, index: number) => {\n switch (event.key) {\n case 'ArrowRight':\n case 'ArrowDown':\n event.preventDefault();\n this.moveFocus(index, 1);\n break;\n case 'ArrowLeft':\n case 'ArrowUp':\n event.preventDefault();\n this.moveFocus(index, -1);\n break;\n default:\n break;\n }\n };\n\n /**\n * A skeleton bar matching the type metrics of the text it stands in for, so the\n * loading state holds the same shape and rhythm as the resolved content.\n *\n * `background` is always passed so the base and shimmer follow the card's\n * permanently dark surface in both themes.\n */\n private bar(textVariant: TextVariant, width: string, className?: string) {\n return (\n <ds-skeleton\n class={className}\n variant=\"text\"\n textVariant={textVariant}\n width={width}\n background=\"always-dark\"\n />\n );\n }\n\n /**\n * Arrow and change in one text node.\n *\n * The arrow is a typeface glyph rather than an icon so it inherits the exact\n * size, weight, and baseline of the value beside it; an icon would need its\n * own size scale and would drift whenever the type scale changed.\n *\n * Tone is supplied by the caller and never inferred here.\n */\n private renderTrend(trend: MetricTrend | undefined, variant: TextVariant, emphasis = false) {\n if (!trend) return null;\n return (\n <ds-text\n as=\"span\"\n class={{\n 'card-overview__trend': true,\n [`card-overview__trend--${trend.tone}`]: true,\n }}\n variant={variant}\n emphasis={emphasis}\n color={TREND_COLORS[trend.tone]}\n fontFeature=\"tabular-nums\"\n >\n {trend.direction === 'up' ? '↑' : '↓'} {trend.value}\n </ds-text>\n );\n }\n\n private renderScore(compact: boolean) {\n if (this.isLoading) {\n if (compact) {\n return (\n <div class=\"card-overview__score ds-control--md\" part=\"score\">\n {this.bar('text-body-medium', '40px', 'card-overview__score-label')}\n <div class=\"card-overview__score-figure\">\n {this.bar('text-body-medium', '24px')}\n {this.bar('text-body-medium', '32px')}\n </div>\n </div>\n );\n }\n\n return (\n <div class=\"card-overview__score ds-control--md\" part=\"score\">\n {/*\n * The label row is kept but left empty. It carries the control-height\n * box that aligns the score block with the period control, so dropping\n * it would shift the whole block up; a bar inside it would collide with\n * the figure, which sits under the label by design.\n */}\n <div class=\"card-overview__score-label-row\" />\n <div class=\"card-overview__score-figure\">\n {this.bar('text-display-medium', '56px')}\n {this.bar('text-body-small', '24px', 'card-overview__skeleton-baseline')}\n </div>\n {/*\n * Class goes on the skeleton itself, matching the resolved band. In a\n * wrapper the bar picks up inline leading and drops below the resolved\n * band position.\n */}\n {this.bar(\n 'text-caption',\n '80px',\n 'card-overview__score-band card-overview__score-band--loading'\n )}\n </div>\n );\n }\n\n if (this.scoreErrorMessage) {\n return (\n <div class=\"card-overview__score card-overview__score--error\" part=\"score\" role=\"alert\">\n <ds-icon name=\"CircleExclamation\" size=\"sm\" color=\"inherit\" aria-hidden=\"true\" />\n <ds-text as=\"span\" variant=\"text-body-medium\" color=\"inherit\">\n {this.scoreErrorMessage}\n </ds-text>\n </div>\n );\n }\n\n const score = this.score;\n if (!score) return null;\n\n return (\n <div class=\"card-overview__score card-overview__score--resolved ds-control--md\" part=\"score\">\n {/* The row owns cross-layout baseline geometry and becomes display: contents in compact mode. */}\n {/* eslint-disable-next-line local/prefer-direct-ds-text */}\n <div class=\"card-overview__score-label-row\">\n <ds-text\n as=\"span\"\n class=\"card-overview__score-label\"\n variant=\"text-body-medium\"\n emphasis={!compact}\n color={ALWAYS_DARK_SECONDARY}\n >\n {score.label}\n </ds-text>\n </div>\n <div class=\"card-overview__score-figure\">\n <ds-text\n as=\"span\"\n class=\"card-overview__score-value\"\n variant={compact ? 'text-body-medium' : 'text-display-medium'}\n emphasis\n color={ALWAYS_DARK_PRIMARY}\n fontFeature=\"tabular-nums\"\n >\n {score.value}\n </ds-text>\n {this.renderTrend(\n score.trend,\n compact ? 'text-body-medium' : 'text-body-small',\n !compact\n )}\n </div>\n {score.band && !compact && (\n <ds-text\n as=\"span\"\n class=\"card-overview__score-band\"\n variant=\"text-caption\"\n color={ALWAYS_DARK_SECONDARY}\n >\n {score.band}\n </ds-text>\n )}\n </div>\n );\n }\n\n private renderMetric(metric: OverviewMetric, index: number) {\n const selectable = !metric.isInactive;\n const label = (\n <ds-text\n as=\"span\"\n class=\"card-overview__metric-label\"\n variant=\"text-body-small\"\n color={ALWAYS_DARK_SECONDARY}\n >\n {metric.label}\n </ds-text>\n );\n\n return (\n <div\n class={{\n 'card-overview__metric': true,\n 'card-overview__metric--inactive': !selectable,\n // Selection targets get the shared wash; press scaling is not used here\n // so the grid keeps its columns aligned. See docs/control-press-policy.md.\n 'ds-interaction-fill': selectable,\n 'ds-interaction-fill--on-always-dark': selectable,\n 'ds-focus-ring-inset': selectable,\n }}\n part=\"metric\"\n role={selectable ? 'button' : undefined}\n tabIndex={selectable && index === this.rovingIndex ? 0 : -1}\n onClick={() => this.selectMetric(metric, index)}\n onKeyDown={event => this.handleMetricKeyDown(event, index)}\n onFocusin={() => {\n if (selectable) this.focusedMetricIndex = index;\n }}\n >\n {metric.labelTooltip ? (\n <ds-tooltip label={metric.labelTooltip} side=\"top\" size=\"sm\">\n {label}\n </ds-tooltip>\n ) : (\n label\n )}\n <div class=\"card-overview__metric-figure\">\n <ds-text\n as=\"span\"\n class=\"card-overview__metric-value\"\n variant=\"text-body-medium\"\n color={ALWAYS_DARK_PRIMARY}\n fontFeature=\"tabular-nums\"\n >\n {metric.value}\n </ds-text>\n {this.renderTrend(metric.trend, 'text-body-medium')}\n </div>\n </div>\n );\n }\n\n private renderMetrics() {\n if (this.isLoading && this.metrics.length === 0) {\n return Array.from({ length: LOADING_PLACEHOLDER_COUNT }, (_, index) => (\n <div class=\"card-overview__metric\" key={`loading-${index}`}>\n {this.bar('text-body-small', '70%', 'card-overview__metric-label')}\n <div class=\"card-overview__metric-figure\">\n {this.bar('text-body-medium', '36px')}\n {/* text-body-medium, matching renderTrend for a metric — a smaller\n * variant here leaves the trend bar short of the value beside it. */}\n {this.bar('text-body-medium', '40px')}\n </div>\n </div>\n ));\n }\n\n return this.visibleMetrics.map((metric, index) => this.renderMetric(metric, index));\n }\n\n render() {\n const hasHeader = Boolean(this.periodLabel || this.comparisonLabel);\n const compact = this.variant === 'compact';\n const collapse = this.scrollCollapseGeometry;\n\n return (\n <Host\n class={{\n 'card-overview': true,\n 'card-overview--has-score': this.hasScore,\n 'card-overview--compact': compact,\n 'card-overview--stacked': !compact && this.layout === 'stacked',\n 'card-overview--scroll-collapsing': collapse.active,\n }}\n role=\"region\"\n aria-label={this.overviewLabel}\n aria-busy={this.isLoading ? 'true' : undefined}\n style={{\n '--ds-card-overview-metric-min': this.metricMinWidth,\n '--ds-card-overview-expanded-height': collapse.active\n ? `${collapse.expandedHeight}px`\n : undefined,\n '--ds-card-overview-visible-height': collapse.active\n ? `${collapse.visibleHeight}px`\n : undefined,\n '--ds-card-overview-content-offset': collapse.active\n ? `${collapse.offset}px`\n : undefined,\n }}\n >\n <div\n class={{\n 'card-overview__surface': true,\n // Split shadow and inset highlight, so the opaque surface cannot cover\n // the highlight the way a combined elevation shadow would.\n 'ds-control-elevation': true,\n 'ds-control-elevation--sm': !compact,\n 'ds-control-elevation--floating': compact,\n }}\n >\n <div class=\"card-overview__clip\">\n <div\n ref={element => {\n this.layoutEl = (element as HTMLElement) ?? undefined;\n }}\n class={{\n 'card-overview__layout': true,\n 'card-overview__layout--has-score': this.hasScore,\n }}\n >\n <div class=\"card-overview__summary\">\n {this.hasScore && this.renderScore(compact)}\n\n {/* `ds-control--md` supplies the 32px height and the label inset below. */}\n <div\n class={{\n 'card-overview__header': true,\n 'card-overview__header--has-score': this.hasScore,\n 'ds-control--md': true,\n }}\n >\n {this.isLoading ? (\n <div class=\"card-overview__period ds-control-label-box\">\n {this.bar('text-body-medium', '184px')}\n {this.bar('text-body-medium', '248px')}\n </div>\n ) : (\n hasHeader && (\n <div class=\"card-overview__period ds-control-label-box\">\n {this.periodLabel && (\n <ds-text\n as=\"span\"\n class=\"card-overview__period-current ds-control-label-box\"\n variant=\"text-body-medium\"\n emphasis\n color={ALWAYS_DARK_PRIMARY}\n >\n {this.periodLabel}\n </ds-text>\n )}\n {this.comparisonLabel && (\n <ds-text\n as=\"span\"\n class=\"card-overview__period-comparison ds-control-label-box\"\n variant=\"text-body-medium\"\n color={ALWAYS_DARK_SECONDARY}\n >\n {this.comparisonLabel}\n </ds-text>\n )}\n </div>\n )\n )}\n <div class=\"card-overview__filter\">\n {/*\n Period control is application owned: it varies by product surface.\n While loading it is stood in for by a control-shaped skeleton so the\n header keeps its resolved proportions.\n */}\n {this.isLoading ? (\n <ds-skeleton\n variant=\"control\"\n controlSize=\"md\"\n width=\"128px\"\n background=\"always-dark\"\n />\n ) : (\n <slot name=\"filter\" />\n )}\n </div>\n </div>\n </div>\n\n {!compact && (\n <div\n class={{\n 'card-overview__body': true,\n 'card-overview__body--has-score': this.hasScore,\n }}\n >\n <div class=\"card-overview__metrics\" part=\"metrics\">\n {this.renderMetrics()}\n </div>\n\n <slot name=\"footer\" />\n </div>\n )}\n </div>\n </div>\n </div>\n </Host>\n );\n }\n}\n",
|
|
372
|
+
"content": "import { Component, Element, Event, EventEmitter, h, Host, Prop, State } from '@stencil/core';\nimport { resolveCssLengthPx, TOKEN_DEFAULTS } from '../../utils';\nimport type { TextColor, TextVariant } from '../Text/text-types';\nimport type { MetricTrend } from '../../utils/metric-change';\nimport type {\n CardOverviewLayout,\n CardOverviewVariant,\n OverviewMetric,\n OverviewScore,\n} from './card-overview-types';\nimport {\n findNextOverviewMetricIndex,\n resolveCardOverviewCollapseGeometry,\n resolveOverviewGridColumns,\n resolveOverviewRovingIndex,\n resolveSafetyScoreLevel,\n} from './card-overview-controller';\n\n/** Metric cells below this width drop a grid column rather than compress further. */\nconst DEFAULT_METRIC_MIN_WIDTH = 'var(--dimension-menu-width-xs)';\n\n/** Skeleton cells rendered while loading with no metrics supplied yet. */\nconst LOADING_PLACEHOLDER_COUNT = 4;\n\n/** Maximum number of comparable measures the summary bar presents at once. */\nconst MAX_METRIC_COUNT = 7;\n\nconst TREND_COLORS: Record<MetricTrend['tone'], TextColor> = {\n positive: 'var(--color-always-dark-foreground-positive)',\n negative: 'var(--color-always-dark-foreground-negative)',\n neutral: 'var(--color-always-dark-foreground-secondary)',\n};\n\nconst ALWAYS_DARK_PRIMARY: TextColor = 'var(--color-always-dark-foreground-primary)';\nconst ALWAYS_DARK_SECONDARY: TextColor = 'var(--color-always-dark-foreground-secondary)';\n\n@Component({\n tag: 'ds-card-overview',\n styleUrl: 'CardOverview.css',\n scoped: true,\n})\nexport class CardOverview {\n @Element() el!: HTMLElement;\n\n /** Full summary card, or the condensed 48px summary bar. */\n @Prop() variant: CardOverviewVariant = 'default';\n\n /** Intrinsic responsive layout, or a page-owned single-column stack. */\n @Prop() layout: CardOverviewLayout = 'auto';\n\n /** Optional nonselectable safety score rendered as the first grid cell. */\n @Prop() score: OverviewScore | undefined;\n\n /** Fixed current date or range. Replaced by content in the `period` slot. */\n @Prop() periodLabel: string = '';\n\n /** Copy between the current period and comparison control, usually `vs.`. */\n @Prop() comparisonLabel: string = '';\n\n /** Measures rendered in the responsive grid. Only the first seven are shown. */\n @Prop() metrics: OverviewMetric[] = [];\n\n /**\n * Width a metric cell may shrink to before the grid drops a column. The grid\n * uses this threshold while choosing an evenly distributed column count.\n */\n @Prop() metricMinWidth: string = DEFAULT_METRIC_MIN_WIDTH;\n\n /** Replace the score and metrics with skeletons while data resolves. */\n @Prop() isLoading: boolean = false;\n\n /** Message shown in place of the score when its figure cannot be resolved. */\n @Prop() scoreErrorMessage: string | undefined;\n\n /** Accessible name for the region. */\n @Prop() overviewLabel: string = 'Overview';\n\n /**\n * Page-controlled visual collapse from the full card (`0`) toward its 48px\n * compact handoff height (`1`). The component preserves its expanded flow\n * height, keeps the period bar stationary, and moves/clips the grid beneath\n * it. The page still owns sticky positioning and the final compact handoff.\n */\n @Prop() scrollCollapseProgress: number = 0;\n\n /** Emitted when a metric that is not inactive is activated. */\n @Event() dsMetricSelect!: EventEmitter<OverviewMetric>;\n\n /** Roving tab stop across selectable metrics. */\n @State() private focusedMetricIndex: number = 0;\n @State() private expandedHeight: number = 0;\n @State() private gridColumns: number | undefined;\n\n private layoutEl?: HTMLElement;\n private layoutResizeObserver: ResizeObserver | null = null;\n\n componentDidLoad() {\n this.observeLayout();\n }\n\n componentDidRender() {\n // Re-bind after HMR when DidLoad's observer was dropped.\n if (!this.layoutResizeObserver) this.observeLayout();\n else this.updateLayoutGeometry();\n }\n\n disconnectedCallback() {\n this.layoutResizeObserver?.disconnect();\n this.layoutResizeObserver = null;\n }\n\n private get visibleMetrics(): OverviewMetric[] {\n return this.metrics.slice(0, MAX_METRIC_COUNT);\n }\n\n private get visibleCellCount(): number {\n const metricCount =\n this.isLoading && this.metrics.length === 0\n ? LOADING_PLACEHOLDER_COUNT\n : this.visibleMetrics.length;\n return 1 + metricCount;\n }\n\n private get resolvedScrollCollapseProgress(): number {\n if (this.variant === 'compact' || !Number.isFinite(this.scrollCollapseProgress)) return 0;\n return Math.min(1, Math.max(0, this.scrollCollapseProgress));\n }\n\n private get scrollCollapseGeometry() {\n const compactHeight = resolveCssLengthPx(TOKEN_DEFAULTS.size600, 48);\n return resolveCardOverviewCollapseGeometry({\n variant: this.variant,\n progress: this.resolvedScrollCollapseProgress,\n expandedHeight: this.expandedHeight,\n compactHeight,\n });\n }\n\n private observeLayout() {\n const layout = this.layoutEl;\n if (!layout) return;\n\n const bounds = layout.getBoundingClientRect();\n this.updateLayoutGeometry(bounds.width, bounds.height);\n if (typeof ResizeObserver === 'undefined') return;\n\n this.layoutResizeObserver?.disconnect();\n this.layoutResizeObserver = new ResizeObserver(entries => {\n const rect = entries[0]?.contentRect;\n if (rect) this.updateLayoutGeometry(rect.width, rect.height);\n });\n this.layoutResizeObserver.observe(layout);\n }\n\n private updateLayoutGeometry(width?: number, height?: number) {\n const layout = this.layoutEl;\n if (!layout) return;\n\n const bounds = width === undefined || height === undefined ? layout.getBoundingClientRect() : null;\n const resolvedWidth = width ?? bounds?.width ?? 0;\n const resolvedHeight = height ?? bounds?.height ?? 0;\n\n if (resolvedHeight > 0 && Math.abs(resolvedHeight - this.expandedHeight) >= 0.5) {\n this.expandedHeight = resolvedHeight;\n }\n\n const columns = resolveOverviewGridColumns({\n cellCount: this.visibleCellCount,\n availableWidth: resolvedWidth,\n minCellWidth: resolveCssLengthPx(this.metricMinWidth, TOKEN_DEFAULTS.menuWidthXs),\n });\n if (columns !== this.gridColumns) this.gridColumns = columns;\n }\n\n /** Index of the roving tab stop, skipping inactive metrics. */\n private get rovingIndex(): number {\n return resolveOverviewRovingIndex(this.visibleMetrics, this.focusedMetricIndex);\n }\n\n private selectMetric(metric: OverviewMetric, index: number) {\n if (metric.isInactive) return;\n this.focusedMetricIndex = index;\n this.dsMetricSelect.emit(metric);\n }\n\n /** Move the roving tab stop, wrapping and skipping inactive metrics. */\n private moveFocus(from: number, step: number) {\n const metrics = this.visibleMetrics;\n const next = findNextOverviewMetricIndex(metrics, from, step < 0 ? -1 : 1);\n if (next < 0) return;\n\n this.focusedMetricIndex = next;\n const cells = this.el.querySelectorAll<HTMLElement>('.card-overview__metric-action');\n cells[next]?.focus();\n }\n\n private handleMetricKeyDown = (event: KeyboardEvent, index: number) => {\n switch (event.key) {\n case 'ArrowRight':\n case 'ArrowDown':\n event.preventDefault();\n this.moveFocus(index, 1);\n break;\n case 'ArrowLeft':\n case 'ArrowUp':\n event.preventDefault();\n this.moveFocus(index, -1);\n break;\n default:\n break;\n }\n };\n\n /**\n * A skeleton bar matching the type metrics of the text it stands in for, so the\n * loading state holds the same shape and rhythm as the resolved content.\n *\n * `background` is always passed so the base and shimmer follow the card's\n * permanently dark surface in both themes.\n */\n private bar(textVariant: TextVariant, width: string, className?: string) {\n return (\n <ds-skeleton\n class={className}\n variant=\"text\"\n textVariant={textVariant}\n width={width}\n background=\"always-dark\"\n />\n );\n }\n\n /**\n * Arrow and change in one text node.\n *\n * The arrow is a typeface glyph rather than an icon so it inherits the exact\n * size, weight, and baseline of the value beside it; an icon would need its\n * own size scale and would drift whenever the type scale changed.\n *\n * Tone is supplied by the caller and never inferred here.\n */\n private renderTrend(\n trend: MetricTrend | undefined,\n variant: TextVariant,\n emphasis = false,\n color?: TextColor\n ) {\n if (!trend) return null;\n return (\n <ds-text\n as=\"span\"\n class={{\n 'card-overview__trend': true,\n 'ds-control-label-box': true,\n [`card-overview__trend--${trend.tone}`]: true,\n }}\n variant={variant}\n emphasis={emphasis}\n color={color ?? TREND_COLORS[trend.tone]}\n fontFeature=\"tabular-nums\"\n >\n {trend.direction === 'up' ? '↑' : '↓'} {trend.value}\n </ds-text>\n );\n }\n\n private renderScore() {\n if (this.isLoading) {\n return (\n <div class=\"card-overview__score\" part=\"score\">\n <div class=\"card-overview__score-content\">\n <div class=\"card-overview__score-copy\">\n {this.bar('text-body-small', '64px', 'card-overview__score-label')}\n {this.bar('text-body-medium', '28px')}\n </div>\n <div class=\"card-overview__score-figure\">\n {this.bar('text-display-medium', '56px')}\n </div>\n </div>\n </div>\n );\n }\n\n const unavailableMessage =\n this.scoreErrorMessage || (!this.score ? 'Score unavailable' : undefined);\n if (unavailableMessage) {\n return (\n /* eslint-disable-next-line local/prefer-direct-ds-text -- The score track owns the grid divider and 8px outer inset. */\n <div class=\"card-overview__score\" part=\"score\">\n <ds-text\n as=\"span\"\n class=\"card-overview__score-content card-overview__score-content--error\"\n variant=\"text-body-medium\"\n color=\"inherit\"\n role=\"alert\"\n >\n {unavailableMessage}\n </ds-text>\n </div>\n );\n }\n\n const score = this.score;\n if (!score) return null;\n const level = score.level ?? resolveSafetyScoreLevel(score.value);\n\n return (\n <div class=\"card-overview__score\" part=\"score\">\n <div\n class={{\n 'card-overview__score-content': true,\n [`card-overview__score-content--${level}`]: Boolean(level),\n }}\n >\n <div class=\"card-overview__score-copy\">\n <ds-text\n as=\"span\"\n class=\"card-overview__score-label ds-control-label-box\"\n variant=\"text-body-small\"\n color=\"inherit\"\n >\n {score.label}\n </ds-text>\n {this.renderTrend(score.trend, 'text-body-medium', false, 'inherit')}\n </div>\n <ds-text\n as=\"span\"\n class=\"card-overview__score-value ds-control-label-box\"\n variant=\"text-display-medium\"\n emphasis\n color=\"inherit\"\n fontFeature=\"tabular-nums\"\n >\n {score.value}\n </ds-text>\n </div>\n </div>\n );\n }\n\n private renderMetric(metric: OverviewMetric, index: number) {\n const selectable = !metric.isInactive;\n const label = (\n <ds-text\n as=\"span\"\n class=\"card-overview__metric-label ds-control-label-box\"\n variant=\"text-body-small\"\n color={ALWAYS_DARK_SECONDARY}\n >\n {metric.label}\n </ds-text>\n );\n\n return (\n <div class=\"card-overview__metric\" part=\"metric\">\n <div\n class={{\n 'card-overview__metric-action': true,\n 'card-overview__metric-action--inactive': !selectable,\n // Selection targets get the shared wash; press scaling is not used here\n // so the grid keeps its columns aligned. See docs/control-press-policy.md.\n 'ds-interaction-fill': selectable,\n 'ds-interaction-fill--on-always-dark': selectable,\n 'ds-focus-ring-inset': selectable,\n }}\n role={selectable ? 'button' : undefined}\n tabIndex={selectable && index === this.rovingIndex ? 0 : -1}\n onClick={() => this.selectMetric(metric, index)}\n onKeyDown={event => this.handleMetricKeyDown(event, index)}\n onFocusin={() => {\n if (selectable) this.focusedMetricIndex = index;\n }}\n >\n <div class=\"ds-interaction-fill__content card-overview__metric-content\">\n {metric.labelTooltip ? (\n <ds-tooltip label={metric.labelTooltip} side=\"top\" size=\"sm\">\n {label}\n </ds-tooltip>\n ) : (\n label\n )}\n <div class=\"card-overview__metric-figure\">\n <ds-text\n as=\"span\"\n class=\"card-overview__metric-value ds-control-label-box\"\n variant=\"text-body-medium\"\n color={ALWAYS_DARK_PRIMARY}\n fontFeature=\"tabular-nums\"\n >\n {metric.value}\n </ds-text>\n {this.renderTrend(metric.trend, 'text-body-medium')}\n </div>\n </div>\n </div>\n </div>\n );\n }\n\n private renderMetrics() {\n if (this.isLoading && this.metrics.length === 0) {\n return [\n this.renderScore(),\n ...Array.from({ length: LOADING_PLACEHOLDER_COUNT }, (_, index) => (\n <div class=\"card-overview__metric\" key={`loading-${index}`}>\n <div class=\"card-overview__metric-action card-overview__metric-action--inactive\">\n {this.bar('text-body-small', '70%', 'card-overview__metric-label')}\n <div class=\"card-overview__metric-figure\">\n {this.bar('text-body-medium', '36px')}\n {/* text-body-medium, matching renderTrend for a metric — a smaller\n * variant here leaves the trend bar short of the value beside it. */}\n {this.bar('text-body-medium', '40px')}\n </div>\n </div>\n </div>\n )),\n ];\n }\n\n return [\n this.renderScore(),\n ...this.visibleMetrics.map((metric, index) => this.renderMetric(metric, index)),\n ];\n }\n\n render() {\n const compact = this.variant === 'compact';\n const collapse = this.scrollCollapseGeometry;\n\n return (\n <Host\n class={{\n 'card-overview': true,\n 'card-overview--compact': compact,\n 'card-overview--stacked': !compact && this.layout === 'stacked',\n 'card-overview--scroll-collapsing': collapse.active,\n }}\n role=\"region\"\n aria-label={this.overviewLabel}\n aria-busy={this.isLoading ? 'true' : undefined}\n style={{\n '--ds-card-overview-metric-min': this.metricMinWidth,\n '--ds-card-overview-grid-columns': this.gridColumns\n ? String(this.gridColumns)\n : undefined,\n '--ds-card-overview-expanded-height': collapse.active\n ? `${collapse.expandedHeight}px`\n : undefined,\n '--ds-card-overview-visible-height': collapse.active\n ? `${collapse.visibleHeight}px`\n : undefined,\n '--ds-card-overview-content-offset': collapse.active\n ? `${collapse.offset}px`\n : undefined,\n }}\n >\n <div\n class={{\n 'card-overview__surface': true,\n // Split shadow and inset highlight, so the opaque surface cannot cover\n // the highlight the way a combined elevation shadow would.\n 'ds-control-elevation': true,\n 'ds-control-elevation--sm': !compact,\n 'ds-control-elevation--floating': compact,\n }}\n >\n <div class=\"card-overview__clip\">\n <div\n ref={element => {\n this.layoutEl = (element as HTMLElement) ?? undefined;\n }}\n class={{\n 'card-overview__layout': true,\n }}\n >\n <div class=\"card-overview__summary\">\n <div class=\"card-overview__header ds-control--md\">\n {this.isLoading ? (\n <div class=\"card-overview__period\">\n {this.bar('text-body-medium', '184px')}\n {this.bar('text-body-medium', '248px')}\n </div>\n ) : (\n <div class=\"card-overview__period\">\n <div class=\"card-overview__period-current\">\n <slot name=\"period\">\n {this.periodLabel && (\n /* eslint-disable-next-line local/prefer-direct-ds-text -- Fixed copy uses the same structural frame and label inset as a slotted Select. */\n <div class=\"card-overview__period-fixed ds-control-frame\">\n <ds-text\n as=\"span\"\n class=\"ds-control-label-box\"\n variant=\"text-body-medium\"\n emphasis\n color={ALWAYS_DARK_PRIMARY}\n >\n {this.periodLabel}\n </ds-text>\n </div>\n )}\n </slot>\n </div>\n {this.comparisonLabel && (\n <ds-text\n as=\"span\"\n class=\"card-overview__period-comparison ds-control-label-box\"\n variant=\"text-body-medium\"\n color={ALWAYS_DARK_SECONDARY}\n >\n {this.comparisonLabel}\n </ds-text>\n )}\n </div>\n )}\n <div class=\"card-overview__filter\">\n {/*\n Period control is application owned: it varies by product surface.\n While loading it is stood in for by a control-shaped skeleton so the\n header keeps its resolved proportions.\n */}\n {this.isLoading ? (\n <ds-skeleton\n variant=\"control\"\n controlSize=\"md\"\n width=\"128px\"\n background=\"always-dark\"\n />\n ) : (\n <slot name=\"filter\" />\n )}\n </div>\n </div>\n </div>\n\n {!compact && (\n <div class=\"card-overview__body\">\n <div class=\"card-overview__metrics\" part=\"metrics\">\n {this.renderMetrics()}\n </div>\n\n <slot name=\"footer\" />\n </div>\n )}\n </div>\n </div>\n </div>\n </Host>\n );\n }\n}\n",
|
|
375
373
|
"type": "registry:ui"
|
|
376
374
|
},
|
|
377
375
|
{
|
|
378
376
|
"path": "src/wc/components/CardOverview/card-overview-controller.ts",
|
|
379
|
-
"content": "import type {
|
|
377
|
+
"content": "import type {\n CardOverviewVariant,\n OverviewMetric,\n SafetyScoreLevel,\n} from './card-overview-types';\n\nexport interface CardOverviewCollapseGeometry {\n active: boolean;\n expandedHeight: number;\n offset: number;\n visibleHeight: number;\n}\n\n/**\n * Choose the densest column count that fits without leaving an incomplete row\n * for even cell totals. Odd totals retain the densest fitting layout and may\n * therefore leave an orphan in the final row.\n */\nexport function resolveOverviewGridColumns(options: {\n cellCount: number;\n availableWidth: number;\n minCellWidth: number;\n maxColumns?: number;\n}): number {\n const cellCount = Math.max(1, Math.floor(options.cellCount));\n const minCellWidth = Math.max(1, options.minCellWidth);\n const maxColumns = Math.max(1, Math.floor(options.maxColumns ?? 4));\n const fittingColumns = Math.max(\n 1,\n Math.min(cellCount, maxColumns, Math.floor(Math.max(0, options.availableWidth) / minCellWidth))\n );\n\n if (cellCount % 2 !== 0) return fittingColumns;\n\n for (let columns = fittingColumns; columns >= 1; columns -= 1) {\n if (cellCount % columns === 0) return columns;\n }\n\n return 1;\n}\n\nexport function resolveCardOverviewCollapseGeometry(options: {\n variant: CardOverviewVariant;\n progress: number;\n expandedHeight: number;\n compactHeight: number;\n}): CardOverviewCollapseGeometry {\n const compactHeight = Math.max(0, options.compactHeight);\n const expandedHeight = Math.max(options.expandedHeight, compactHeight);\n const progress =\n options.variant === 'compact' || !Number.isFinite(options.progress)\n ? 0\n : Math.min(1, Math.max(0, options.progress));\n const distance = Math.max(0, expandedHeight - compactHeight);\n const offset = distance * progress;\n\n return {\n active: progress > 0 && distance > 0,\n expandedHeight,\n offset,\n visibleHeight: expandedHeight - offset,\n };\n}\n\nexport function resolveSafetyScoreLevel(value: string | number): SafetyScoreLevel | undefined {\n const numericValue = typeof value === 'number' ? value : Number(value);\n if (!Number.isFinite(numericValue) || numericValue < 0 || numericValue > 100) return undefined;\n if (numericValue <= 50) return 'fair';\n if (numericValue <= 80) return 'good';\n return 'excellent';\n}\n\nexport function resolveOverviewRovingIndex(\n metrics: readonly OverviewMetric[],\n focusedIndex: number\n): number {\n const first = metrics.findIndex(metric => !metric.isInactive);\n if (first < 0) return -1;\n return metrics[focusedIndex] && !metrics[focusedIndex].isInactive\n ? focusedIndex\n : first;\n}\n\nexport function findNextOverviewMetricIndex(\n metrics: readonly OverviewMetric[],\n from: number,\n step: -1 | 1\n): number {\n for (let offset = 1; offset <= metrics.length; offset += 1) {\n const next = (((from + step * offset) % metrics.length) + metrics.length) % metrics.length;\n if (!metrics[next]?.isInactive) return next;\n }\n return -1;\n}\n",
|
|
380
378
|
"type": "registry:ui"
|
|
381
379
|
},
|
|
382
380
|
{
|
|
383
381
|
"path": "src/wc/components/CardOverview/card-overview-types.ts",
|
|
384
|
-
"content": "import type { MetricTrend } from '../../utils/metric-change';\n\nexport type CardOverviewVariant = 'default' | 'compact';\nexport type CardOverviewLayout = 'auto' | 'stacked';\n\n/**\n * Leading summary block — the headline figure the rest of the bar contextualises.\n *\n * Derive `trend` with `resolveMetricTrend` so whether a rise reads well stays a\n * product decision rather than a design-system one.\n */\nexport interface OverviewScore {\n /** Category
|
|
382
|
+
"content": "import type { MetricTrend } from '../../utils/metric-change';\n\nexport type CardOverviewVariant = 'default' | 'compact';\nexport type CardOverviewLayout = 'auto' | 'stacked';\nexport type SafetyScoreLevel = 'fair' | 'good' | 'excellent';\n\n/**\n * Leading summary block — the headline figure the rest of the bar contextualises.\n *\n * Derive `trend` with `resolveMetricTrend` so whether a rise reads well stays a\n * product decision rather than a design-system one.\n */\nexport interface OverviewScore {\n /** Category before the trend and figure, for example `Safety score`. */\n label: string;\n /** Display-ready headline figure. */\n value: string | number;\n /** Change against the comparison period. Omit when there is nothing to report. */\n trend?: MetricTrend;\n /**\n * Safety score color level. Numeric values from 0–100 infer fair (0–50),\n * good (51–80), or excellent (81–100) when this is omitted.\n */\n level?: SafetyScoreLevel;\n /** @deprecated Ignored. The redesigned score cell no longer renders a band. */\n band?: string;\n}\n\n/** One measure in the overview grid. */\nexport interface OverviewMetric {\n /** Stable identity for keyed rendering and selection events. */\n id: string;\n label: string;\n /** Display-ready value; format compactly before passing it in. */\n value: string | number;\n /** Change against the comparison period. Omit when there is nothing to report. */\n trend?: MetricTrend;\n /** Present the measure without making it selectable. */\n isInactive?: boolean;\n /** Supplementary explanation for the label. */\n labelTooltip?: string;\n}\n",
|
|
385
383
|
"type": "registry:ui"
|
|
386
384
|
}
|
|
387
385
|
]
|
|
@@ -218,7 +218,7 @@
|
|
|
218
218
|
"complexPropertyNote": "Assign these non-primitive values as JavaScript properties: categories, data, series.",
|
|
219
219
|
"peerDependencies": {
|
|
220
220
|
"required": [
|
|
221
|
-
"@ds-mo/tokens ^5.1.
|
|
221
|
+
"@ds-mo/tokens ^5.1.1",
|
|
222
222
|
"@ds-mo/icons ^6.4.0"
|
|
223
223
|
],
|
|
224
224
|
"frameworks": "Custom Elements; React 18/19 wrappers; Angular 19-22 standalone adapters."
|
|
@@ -315,7 +315,7 @@
|
|
|
315
315
|
"complexPropertyNote": "Assign these non-primitive values as JavaScript properties: data.",
|
|
316
316
|
"peerDependencies": {
|
|
317
317
|
"required": [
|
|
318
|
-
"@ds-mo/tokens ^5.1.
|
|
318
|
+
"@ds-mo/tokens ^5.1.1",
|
|
319
319
|
"@ds-mo/icons ^6.4.0"
|
|
320
320
|
],
|
|
321
321
|
"frameworks": "Custom Elements; React 18/19 wrappers; Angular 19-22 standalone adapters."
|
|
@@ -274,7 +274,7 @@
|
|
|
274
274
|
"complexPropertyNote": "Assign these non-primitive values as JavaScript properties: items.",
|
|
275
275
|
"peerDependencies": {
|
|
276
276
|
"required": [
|
|
277
|
-
"@ds-mo/tokens ^5.1.
|
|
277
|
+
"@ds-mo/tokens ^5.1.1",
|
|
278
278
|
"@ds-mo/icons ^6.4.0"
|
|
279
279
|
],
|
|
280
280
|
"frameworks": "Custom Elements; React 18/19 wrappers; Angular 19-22 standalone adapters."
|
|
@@ -196,7 +196,7 @@
|
|
|
196
196
|
"complexPropertyNote": "Assign these non-primitive values as JavaScript properties: categories, series.",
|
|
197
197
|
"peerDependencies": {
|
|
198
198
|
"required": [
|
|
199
|
-
"@ds-mo/tokens ^5.1.
|
|
199
|
+
"@ds-mo/tokens ^5.1.1",
|
|
200
200
|
"@ds-mo/icons ^6.4.0"
|
|
201
201
|
],
|
|
202
202
|
"frameworks": "Custom Elements; React 18/19 wrappers; Angular 19-22 standalone adapters."
|