@ds-mo/ui 11.0.0 → 12.0.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/README.md +1 -1
- package/dist/.build-stamp +1 -1
- package/dist/agent-patterns.json +150 -9
- package/dist/agent.json +940 -220
- package/dist/angular/ds-bar-title.d.ts +28 -0
- package/dist/angular/ds-bar-title.js +48 -0
- package/dist/angular/ds-button-filled.d.ts +1 -1
- package/dist/angular/ds-button-filled.js +3 -3
- package/dist/angular/ds-chart-donut.d.ts +1 -1
- package/dist/angular/ds-chart-donut.js +3 -3
- package/dist/angular/ds-panel-nav.d.ts +1 -1
- package/dist/angular/{ds-app-shell.d.ts → ds-shell-app.d.ts} +5 -5
- package/dist/angular/{ds-app-shell.js → ds-shell-app.js} +10 -10
- package/dist/angular/ds-shell-page.d.ts +12 -0
- package/dist/angular/ds-shell-page.js +38 -0
- package/dist/angular/index.d.ts +1 -1
- package/dist/angular/index.js +3 -1
- package/dist/angular/proxies.d.ts +3 -1
- package/dist/angular/proxies.js +3 -1
- package/dist/components/ds-agent-activity.js +1 -1
- package/dist/components/ds-agent-response.js +1 -1
- package/dist/components/ds-agent-response.js.map +1 -1
- package/dist/components/ds-agent-source-list.js +1 -1
- package/dist/components/ds-agent-tool-call.js +1 -1
- package/dist/components/ds-attachment-list.js +1 -1
- package/dist/components/ds-avatar.js +1 -1
- package/dist/components/ds-avatar.js.map +1 -1
- package/dist/components/ds-badge.js +1 -1
- package/dist/components/ds-bar-nav.js +1 -1
- package/dist/components/ds-bar-nav.js.map +1 -1
- package/dist/components/{ds-app-shell.d.ts → ds-bar-title.d.ts} +4 -4
- package/dist/components/ds-bar-title.js +2 -0
- package/dist/components/ds-bar-title.js.map +1 -0
- package/dist/components/ds-button-filled.js +1 -1
- package/dist/components/ds-button-unfilled.js +1 -1
- package/dist/components/ds-card-data-viz-donut.js +1 -1
- package/dist/components/ds-card-data-viz-donut.js.map +1 -1
- package/dist/components/ds-card-setting.js +1 -1
- package/dist/components/ds-card-shell-data-viz.js +1 -1
- package/dist/components/ds-chart-bar.js +1 -1
- package/dist/components/ds-chart-donut.js +1 -1
- package/dist/components/ds-chart-donut.js.map +1 -1
- package/dist/components/ds-chart-legend.js +1 -1
- package/dist/components/ds-chart-line.js +1 -1
- package/dist/components/ds-checkbox.js +1 -1
- package/dist/components/ds-chip.js +1 -1
- package/dist/components/ds-code-block.js +1 -1
- package/dist/components/ds-conversation-list-item.js +1 -1
- package/dist/components/ds-conversation-list-item.js.map +1 -1
- package/dist/components/ds-conversation-list-section.js +1 -1
- package/dist/components/ds-conversation-list.js +1 -1
- package/dist/components/ds-empty-state.js +1 -1
- package/dist/components/ds-field.js +1 -1
- package/dist/components/ds-input.js +1 -1
- package/dist/components/ds-markdown.js +1 -1
- package/dist/components/ds-menu.js +1 -1
- package/dist/components/ds-message-composer.js +1 -1
- package/dist/components/ds-message-composer.js.map +1 -1
- package/dist/components/ds-message-scroller.js +1 -1
- package/dist/components/ds-message-scroller.js.map +1 -1
- package/dist/components/ds-message.js +1 -1
- package/dist/components/ds-modal.js +1 -1
- package/dist/components/ds-modal.js.map +1 -1
- package/dist/components/ds-panel-nav.js +1 -1
- package/dist/components/ds-panel-nav.js.map +1 -1
- package/dist/components/ds-panel-sub-nav.js +1 -1
- package/dist/components/ds-panel-sub-nav.js.map +1 -1
- package/dist/components/ds-panel-tool-header.js +1 -1
- package/dist/components/ds-panel-tool-search.js +1 -1
- package/dist/components/ds-panel-tool-search.js.map +1 -1
- package/dist/components/ds-panel-tools.js +1 -1
- package/dist/components/ds-panel-tools.js.map +1 -1
- package/dist/components/ds-radio.js +1 -1
- package/dist/components/ds-select-multi.js +1 -1
- package/dist/components/ds-select-multi.js.map +1 -1
- package/dist/components/ds-select.js +1 -1
- package/dist/components/ds-select.js.map +1 -1
- package/dist/components/ds-shell-app.d.ts +11 -0
- package/dist/components/ds-shell-app.js +2 -0
- package/dist/components/ds-shell-app.js.map +1 -0
- package/dist/components/ds-shell-gradient-picker.js +1 -1
- package/dist/components/ds-shell-gradient-swatch.js +1 -1
- package/dist/components/ds-shell-page.d.ts +11 -0
- package/dist/components/ds-shell-page.js +2 -0
- package/dist/components/ds-shell-page.js.map +1 -0
- package/dist/components/ds-skeleton.js +1 -1
- package/dist/components/ds-slider.js +1 -1
- package/dist/components/ds-slider.js.map +1 -1
- package/dist/components/ds-swatch-picker.js +1 -1
- package/dist/components/ds-switch.js +1 -1
- package/dist/components/ds-tab-group.js +1 -1
- package/dist/components/ds-tag.js +1 -1
- package/dist/components/ds-text.js +1 -1
- package/dist/components/ds-toast.js +1 -1
- package/dist/components/ds-toast.js.map +1 -1
- package/dist/components/ds-tooltip-data-viz.js +1 -1
- package/dist/components/ds-tooltip-data-viz.js.map +1 -1
- package/dist/components/ds-tooltip.js +1 -1
- package/dist/components/ds-typing-indicator.js +1 -1
- package/dist/components/{p-DJ78wdNv.js → p-6vj4kh70.js} +2 -2
- package/dist/components/p-B3YvoGjS.js +2 -0
- package/dist/components/p-B3YvoGjS.js.map +1 -0
- package/dist/components/{p-BEWtqFX7.js → p-BH3es4p7.js} +2 -2
- package/dist/components/p-BUmDHPr3.js +2 -0
- package/dist/components/p-BUmDHPr3.js.map +1 -0
- package/dist/components/p-BYHKdFzV.js +2 -0
- package/dist/components/p-BYHKdFzV.js.map +1 -0
- package/dist/components/p-BZZwQfmN.js +2 -0
- package/dist/components/{p-CbckeueL.js.map → p-BZZwQfmN.js.map} +1 -1
- package/dist/components/{p-Dh4q5TSS.js → p-BhKhX1er.js} +2 -2
- package/dist/components/{p-CZZYGqKz.js → p-Bs6SS34m.js} +2 -2
- package/dist/components/p-CUik7PCi.js +2 -0
- package/dist/components/p-CUik7PCi.js.map +1 -0
- package/dist/components/{p-M5pt9I13.js → p-Cf-i-6aE.js} +2 -2
- package/dist/components/{p-C8e2A66f.js → p-Cf2J9MEo.js} +2 -2
- package/dist/components/{p-bDx_rlLm.js → p-CwTVEAl2.js} +2 -2
- package/dist/components/p-Cy04lXlc.js +2 -0
- package/dist/components/p-Cy04lXlc.js.map +1 -0
- package/dist/components/{p-BKhG2xrW.js → p-D2x17ei-.js} +1 -1
- package/dist/components/{p-BKhG2xrW.js.map → p-D2x17ei-.js.map} +1 -1
- package/dist/components/{p-CjP8sYlo.js → p-DABj3qTX.js} +2 -2
- package/dist/components/{p-DTqCBjUj.js → p-DUHcJWTQ.js} +2 -2
- package/dist/components/{p-CPPAndX2.js → p-DVk0wxxX.js} +2 -2
- package/dist/components/p-DfIch2Dk.js +2 -0
- package/dist/components/{p-BMwnjAIq.js.map → p-DfIch2Dk.js.map} +1 -1
- package/dist/components/p-Dg3xLna0.js +2 -0
- package/dist/components/{p-C_0Q8Cnp.js.map → p-Dg3xLna0.js.map} +1 -1
- package/dist/components/{p-DrDHC7V6.js → p-DxeHimqk.js} +2 -2
- package/dist/components/{p-DrDHC7V6.js.map → p-DxeHimqk.js.map} +1 -1
- package/dist/components/{p-CLn7QnE0.js → p-Dy_sZ-dI.js} +2 -2
- package/dist/components/{p-0kEg-Z4f.js → p-liMPkhUP.js} +2 -2
- package/dist/components/p-xFbUt9Tc.js +2 -0
- package/dist/components/p-xFbUt9Tc.js.map +1 -0
- package/dist/docs/components.json +1139 -255
- package/dist/lib/shell/chrome-transition.d.ts +1 -1
- package/dist/lib/shell/index.js +1 -1
- package/dist/lib/shell/index.js.map +1 -1
- package/dist/lib/shell/shell-gradient.d.ts +2 -2
- package/dist/mcp/cli.js +8 -12
- package/dist/mcp-data/registry/avatar.json +1 -1
- package/dist/mcp-data/registry/badge.json +4 -4
- package/dist/mcp-data/registry/bar-nav.json +8 -8
- package/dist/mcp-data/registry/bar-title.json +431 -0
- package/dist/mcp-data/registry/button-filled.json +38 -2
- package/dist/mcp-data/registry/card-data-viz-donut.json +73 -4
- package/dist/mcp-data/registry/chart-bar.json +67 -3
- package/dist/mcp-data/registry/chart-donut.json +94 -8
- package/dist/mcp-data/registry/chart-legend.json +73 -3
- package/dist/mcp-data/registry/chart-line.json +67 -3
- package/dist/mcp-data/registry/code-block.json +4 -3
- package/dist/mcp-data/registry/menu.json +1 -1
- package/dist/mcp-data/registry/message-composer.json +7 -5
- package/dist/mcp-data/registry/message-scroller.json +4 -3
- package/dist/mcp-data/registry/modal.json +5 -4
- package/dist/mcp-data/registry/panel-nav.json +8 -8
- package/dist/mcp-data/registry/panel-sub-nav.json +1 -1
- package/dist/mcp-data/registry/panel-tool-header.json +4 -3
- package/dist/mcp-data/registry/panel-tool-search.json +6 -5
- package/dist/mcp-data/registry/panel-tools.json +13 -13
- package/dist/mcp-data/registry/registry.json +921 -195
- package/dist/mcp-data/registry/select-multi.json +2 -1
- package/dist/mcp-data/registry/select.json +2 -1
- package/dist/mcp-data/registry/shell-app.json +213 -0
- package/dist/mcp-data/registry/shell-gradient-picker.json +8 -8
- package/dist/mcp-data/registry/shell-gradient-swatch.json +2 -2
- package/dist/mcp-data/registry/shell-page.json +199 -0
- package/dist/mcp-data/registry/swatch-picker.json +1 -1
- package/dist/mcp-data/registry/tooltip-data-viz.json +68 -4
- package/dist/react/components.d.ts +3 -1
- package/dist/react/components.js +3 -1
- package/dist/react/ds-bar-title.d.ts +14 -0
- package/dist/react/ds-bar-title.js +16 -0
- package/dist/react/{ds-app-shell.d.ts → ds-shell-app.d.ts} +3 -3
- package/dist/react/ds-shell-app.js +12 -0
- package/dist/react/ds-shell-page.d.ts +9 -0
- package/dist/react/ds-shell-page.js +12 -0
- package/dist/types/components/Badge/Badge.d.ts +1 -1
- package/dist/types/components/BarTitle/BarTitle.d.ts +71 -0
- package/dist/types/components/BarTitle/bar-title-types.d.ts +29 -0
- package/dist/types/components/BarTitle/index.d.ts +2 -0
- package/dist/types/components/ButtonFilled/ButtonFilled.d.ts +9 -0
- package/dist/types/components/ButtonFilled/index.d.ts +1 -1
- package/dist/types/components/CardDataVizDonut/CardDataVizDonut.d.ts +1 -0
- package/dist/types/components/ChartDonut/ChartDonut.d.ts +12 -2
- package/dist/types/components/Menu/Menu.d.ts +5 -0
- package/dist/types/components/PanelNav/PanelNav.d.ts +1 -1
- package/dist/types/components/{AppShell/AppShell.d.ts → ShellApp/ShellApp.d.ts} +3 -3
- package/dist/types/components/ShellPage/ShellPage.d.ts +37 -0
- package/dist/types/components/ShellPage/index.d.ts +3 -0
- package/dist/types/components/ShellPage/shell-page-responsive.d.ts +12 -0
- package/dist/types/components/ShellPage/shell-page-types.d.ts +5 -0
- package/dist/types/components/TooltipDataViz/TooltipDataViz.d.ts +3 -2
- package/dist/types/components.d.ts +314 -67
- package/dist/types/shell/chrome-transition.d.ts +1 -1
- package/dist/types/shell/shell-gradient.d.ts +2 -2
- package/dist/types/shell/shell-shortcuts.d.ts +1 -1
- package/package.json +1 -1
- package/dist/components/ds-app-shell.js +0 -2
- package/dist/components/ds-app-shell.js.map +0 -1
- package/dist/components/p-BHtg1fh3.js +0 -2
- package/dist/components/p-BHtg1fh3.js.map +0 -1
- package/dist/components/p-BMwnjAIq.js +0 -2
- package/dist/components/p-C3nDIMX5.js +0 -2
- package/dist/components/p-C3nDIMX5.js.map +0 -1
- package/dist/components/p-CKaJx0IX.js +0 -2
- package/dist/components/p-CKaJx0IX.js.map +0 -1
- package/dist/components/p-CTFBf97-.js +0 -2
- package/dist/components/p-CTFBf97-.js.map +0 -1
- package/dist/components/p-C_0Q8Cnp.js +0 -2
- package/dist/components/p-CbckeueL.js +0 -2
- package/dist/components/p-DirD-b2y.js +0 -2
- package/dist/components/p-DirD-b2y.js.map +0 -1
- package/dist/components/p-Hw-HMjCk.js +0 -2
- package/dist/components/p-Hw-HMjCk.js.map +0 -1
- package/dist/mcp-data/registry/app-shell.json +0 -210
- package/dist/react/ds-app-shell.js +0 -12
- /package/dist/components/{p-DJ78wdNv.js.map → p-6vj4kh70.js.map} +0 -0
- /package/dist/components/{p-BEWtqFX7.js.map → p-BH3es4p7.js.map} +0 -0
- /package/dist/components/{p-Dh4q5TSS.js.map → p-BhKhX1er.js.map} +0 -0
- /package/dist/components/{p-CZZYGqKz.js.map → p-Bs6SS34m.js.map} +0 -0
- /package/dist/components/{p-M5pt9I13.js.map → p-Cf-i-6aE.js.map} +0 -0
- /package/dist/components/{p-C8e2A66f.js.map → p-Cf2J9MEo.js.map} +0 -0
- /package/dist/components/{p-bDx_rlLm.js.map → p-CwTVEAl2.js.map} +0 -0
- /package/dist/components/{p-CjP8sYlo.js.map → p-DABj3qTX.js.map} +0 -0
- /package/dist/components/{p-DTqCBjUj.js.map → p-DUHcJWTQ.js.map} +0 -0
- /package/dist/components/{p-CPPAndX2.js.map → p-DVk0wxxX.js.map} +0 -0
- /package/dist/components/{p-CLn7QnE0.js.map → p-Dy_sZ-dI.js.map} +0 -0
- /package/dist/components/{p-0kEg-Z4f.js.map → p-liMPkhUP.js.map} +0 -0
|
@@ -2,15 +2,84 @@
|
|
|
2
2
|
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
3
|
"name": "card-data-viz-donut",
|
|
4
4
|
"title": "CardDataVizDonut",
|
|
5
|
-
"description": "
|
|
5
|
+
"description": "Canonical donut-plus-legend dashboard card with shared data-viz chrome, a filter action, fill chart region, content-sized legend, and built-in hover synchronization.",
|
|
6
6
|
"type": "registry:ui",
|
|
7
7
|
"meta": {
|
|
8
8
|
"library": "@ds-mo/ui",
|
|
9
9
|
"distribution": "npm",
|
|
10
10
|
"storybook": "https://zainadeel.github.io/compomo/?path=/story/card-data-viz-donut",
|
|
11
11
|
"source": "src/wc/components/CardDataVizDonut/CardDataVizDonut.tsx",
|
|
12
|
-
"intentStatus": "
|
|
13
|
-
"intent":
|
|
12
|
+
"intentStatus": "complete",
|
|
13
|
+
"intent": {
|
|
14
|
+
"audience": "specialized",
|
|
15
|
+
"status": "experimental",
|
|
16
|
+
"summary": "Canonical donut-plus-legend dashboard card with shared data-viz chrome, a filter action, fill chart region, content-sized legend, and built-in hover synchronization.",
|
|
17
|
+
"useWhen": [
|
|
18
|
+
"A dashboard widget needs the standard donut and visible legend composition in one data-viz card.",
|
|
19
|
+
"Chart slices and legend rows should cross-highlight without application hover wiring.",
|
|
20
|
+
"The card needs the shared header filter action while the application owns filter state and menu content."
|
|
21
|
+
],
|
|
22
|
+
"avoidWhen": [
|
|
23
|
+
"The visualization is a bar, line, metric, or custom chart; compose CardShellDataViz directly.",
|
|
24
|
+
"The product needs a custom legend treatment such as chips, external stat callouts, or selectable filters.",
|
|
25
|
+
"The surface is a settings section or generic content card."
|
|
26
|
+
],
|
|
27
|
+
"alternatives": [
|
|
28
|
+
{
|
|
29
|
+
"when": "The visualization needs shared data-viz chrome without the canonical donut layout.",
|
|
30
|
+
"component": "component:ds-card-shell-data-viz",
|
|
31
|
+
"reason": "CardShellDataViz owns only the header, actions, width, and body boundary."
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"when": "A donut and legend need a custom layout without card chrome.",
|
|
35
|
+
"component": "component:ds-chart-donut",
|
|
36
|
+
"reason": "Compose the chart and ChartLegend directly and own their layout and hover synchronization."
|
|
37
|
+
}
|
|
38
|
+
],
|
|
39
|
+
"commonlyComposedWith": [
|
|
40
|
+
"component:ds-card-shell-data-viz",
|
|
41
|
+
"component:ds-chart-donut",
|
|
42
|
+
"component:ds-chart-legend",
|
|
43
|
+
"component:ds-empty-state",
|
|
44
|
+
"component:ds-skeleton"
|
|
45
|
+
],
|
|
46
|
+
"accessibility": [
|
|
47
|
+
"Provide a concise card heading and a localized filter label for the icon-only header action.",
|
|
48
|
+
"Keep essential values available through the chart and visible legend rather than encoding meaning through slice color alone.",
|
|
49
|
+
"The application owns meaningful loading, empty, and error status copy when either content region is temporarily replaced or absent."
|
|
50
|
+
],
|
|
51
|
+
"states": [
|
|
52
|
+
"The chart region fills remaining card height while the legend remains content-sized.",
|
|
53
|
+
"Chart and legend regions render only when their corresponding slots contain content, allowing the owner to substitute loading, empty, or error presentations without dangling region padding.",
|
|
54
|
+
"Hover synchronization changes highlight only; it never represents selection, filtering, or navigation.",
|
|
55
|
+
"The filter action emits intent while the parent owns popup content, applied constraints, and data updates."
|
|
56
|
+
],
|
|
57
|
+
"responsiveBehavior": [
|
|
58
|
+
"Select the token-based card width appropriate to the parent grid; the matching minimum height preserves the chart region.",
|
|
59
|
+
"The parent dashboard owns wrapping and column changes while the internal chart-over-legend arrangement remains stable."
|
|
60
|
+
],
|
|
61
|
+
"frameworkCaveats": {
|
|
62
|
+
"customElements": [
|
|
63
|
+
"Assign chart data and legend items as JavaScript properties and place the components in the chart and legend slots."
|
|
64
|
+
],
|
|
65
|
+
"react": [
|
|
66
|
+
"Keep filter and dataset state in the owner; the card handles hover synchronization for the canonical slotted pair."
|
|
67
|
+
],
|
|
68
|
+
"angular": [
|
|
69
|
+
"Keep filter and dataset state in the owner; the card handles hover synchronization for the canonical slotted pair."
|
|
70
|
+
]
|
|
71
|
+
},
|
|
72
|
+
"references": [
|
|
73
|
+
{
|
|
74
|
+
"label": "Storybook examples",
|
|
75
|
+
"path": "src/wc/components/CardDataVizDonut/CardDataVizDonut.stories.ts"
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
"label": "Dashboard review examples",
|
|
79
|
+
"path": "src/wc/stories/DataViz/OverviewReview.stories.ts"
|
|
80
|
+
}
|
|
81
|
+
]
|
|
82
|
+
},
|
|
14
83
|
"api": {
|
|
15
84
|
"props": {
|
|
16
85
|
"cardWidth": {
|
|
@@ -136,7 +205,7 @@
|
|
|
136
205
|
},
|
|
137
206
|
{
|
|
138
207
|
"path": "src/wc/components/CardDataVizDonut/CardDataVizDonut.tsx",
|
|
139
|
-
"content": "import { Component, Element, Event, EventEmitter, State, h, Host, Prop } from '@stencil/core';\nimport type { CardShellDataVizWidth } from '../CardShellDataViz/CardShellDataViz';\n\nexport type CardDataVizDonutWidth = CardShellDataVizWidth;\n\n/** Matches the `dsSliceHover`/`dsItemHover` detail shape emitted by `ds-chart-*` and `ds-chart-legend`. */\ntype HoveredDatum = { label: string } | null;\n\n/** A slotted chart/legend that opts into
|
|
208
|
+
"content": "import { Component, Element, Event, EventEmitter, State, h, Host, Prop } from '@stencil/core';\nimport type { CardShellDataVizWidth } from '../CardShellDataViz/CardShellDataViz';\n\nexport type CardDataVizDonutWidth = CardShellDataVizWidth;\n\n/** Matches the `dsSliceHover`/`dsItemHover` detail shape emitted by `ds-chart-*` and `ds-chart-legend`. */\ntype HoveredDatum = { label: string } | null;\n\n/** A slotted chart/legend that opts into composition behavior through public props. */\ntype SyncableSlot = HTMLElement & {\n activeLabel?: string | null;\n showTooltip?: boolean;\n};\n\n/**\n * Donut data-viz card — dedicated `ds-card-shell-data-viz` chrome with a fill chart region and\n * content-sized legend. Hover sync between chart and legend stays here.\n */\n@Component({\n tag: 'ds-card-data-viz-donut',\n styleUrl: 'CardDataVizDonut.css',\n scoped: true,\n})\nexport class CardDataVizDonut {\n @Element() el!: HTMLElement;\n\n /** Widget heading shown in the card header. */\n @Prop() heading!: string;\n\n /** Card width token — also sets matching min-height. */\n @Prop() cardWidth: CardDataVizDonutWidth = 'md';\n @Prop() filterLabel: string = 'Filter';\n\n /** Emits when the header filter control is activated. */\n @Event() dsFilterClick!: EventEmitter<void>;\n\n // Scoped (light-DOM) components have no native slot projection to detect emptiness from CSS —\n // check the actual children so an unused region (e.g. no legend) doesn't render a dangling\n // padded box plus a body gap next to nothing.\n @State() private hasChartSlot = false;\n @State() private hasLegendSlot = false;\n\n componentWillRender() {\n // Not `:scope >` — Stencil's scoped slot polyfill relocates slotted children into\n // region wrappers (and here into nested `ds-card-shell-data-viz`), so they may not stay direct\n // host children across renders.\n this.hasChartSlot = !!this.el.querySelector('[slot=\"chart\"]');\n this.hasLegendSlot = !!this.el.querySelector('[slot=\"legend\"]');\n }\n\n componentDidLoad() {\n // Sync the chart's and legend's `activeLabel` from each other's hover events, so any\n // ds-chart-donut + ds-chart-legend pair cross-highlights without every consumer having to\n // wire it up by hand. Delegated on the host (rather than bound to the specific slotted\n // elements) since Stencil events bubble and the slot content can be swapped at runtime.\n this.el.addEventListener('dsSliceHover', this.handleChartHover);\n this.el.addEventListener('dsItemHover', this.handleLegendHover);\n }\n\n componentDidRender() {\n const chart = this.el.querySelector('[slot=\"chart\"]') as SyncableSlot | null;\n if (!chart || !('showTooltip' in chart)) return;\n chart.showTooltip = !this.hasLegendSlot;\n }\n\n disconnectedCallback() {\n this.el.removeEventListener('dsSliceHover', this.handleChartHover);\n this.el.removeEventListener('dsItemHover', this.handleLegendHover);\n }\n\n private handleChartHover = (e: Event) => {\n // Not `:scope >` — Stencil's slot polyfill for scoped (non-shadow) components relocates\n // slotted children into an inner region wrapper on render, so they're no longer direct\n // children of the host by the time this fires.\n const legend = this.el.querySelector('[slot=\"legend\"]') as SyncableSlot | null;\n if (!legend || !('activeLabel' in legend)) return;\n legend.activeLabel = (e as CustomEvent<HoveredDatum>).detail?.label ?? null;\n };\n\n private handleLegendHover = (e: Event) => {\n const chart = this.el.querySelector('[slot=\"chart\"]') as SyncableSlot | null;\n if (!chart || !('activeLabel' in chart)) return;\n chart.activeLabel = (e as CustomEvent<HoveredDatum>).detail?.label ?? null;\n };\n\n private handleFilterClick = () => {\n this.dsFilterClick.emit();\n };\n\n render() {\n return (\n <Host class=\"card-data-viz-donut\">\n <ds-card-shell-data-viz heading={this.heading} cardWidth={this.cardWidth}>\n <ds-button-unfilled\n slot=\"actions\"\n variant=\"icon\"\n type=\"button\"\n icon=\"Filters\"\n aria-label={this.filterLabel}\n onDsClick={this.handleFilterClick}\n />\n <div class=\"card-data-viz-donut__layout\">\n {this.hasChartSlot && (\n <div class=\"card-data-viz-donut__chart-region\">\n <slot name=\"chart\" />\n </div>\n )}\n {this.hasLegendSlot && (\n <div class=\"card-data-viz-donut__legend-region\">\n <slot name=\"legend\" />\n </div>\n )}\n </div>\n </ds-card-shell-data-viz>\n </Host>\n );\n }\n}\n",
|
|
140
209
|
"type": "registry:ui"
|
|
141
210
|
}
|
|
142
211
|
]
|
|
@@ -2,15 +2,79 @@
|
|
|
2
2
|
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
3
|
"name": "chart-bar",
|
|
4
4
|
"title": "ChartBar",
|
|
5
|
-
"description": "
|
|
5
|
+
"description": "Single-series bar chart for comparing discrete categories or evenly spaced time buckets on a band-scaled axis.",
|
|
6
6
|
"type": "registry:ui",
|
|
7
7
|
"meta": {
|
|
8
8
|
"library": "@ds-mo/ui",
|
|
9
9
|
"distribution": "npm",
|
|
10
10
|
"storybook": "https://zainadeel.github.io/compomo/?path=/story/chart-bar",
|
|
11
11
|
"source": "src/wc/components/ChartBar/ChartBar.tsx",
|
|
12
|
-
"intentStatus": "
|
|
13
|
-
"intent":
|
|
12
|
+
"intentStatus": "complete",
|
|
13
|
+
"intent": {
|
|
14
|
+
"audience": "specialized",
|
|
15
|
+
"status": "experimental",
|
|
16
|
+
"summary": "Single-series bar chart for comparing discrete categories or evenly spaced time buckets on a band-scaled axis.",
|
|
17
|
+
"useWhen": [
|
|
18
|
+
"Users need to compare one numeric measure across a small set of categories.",
|
|
19
|
+
"Values are grouped into ordered time buckets such as hours, days, weeks, or months and equal visual spacing is appropriate.",
|
|
20
|
+
"A data-viz card needs a compact magnitude comparison rather than a continuous trend."
|
|
21
|
+
],
|
|
22
|
+
"avoidWhen": [
|
|
23
|
+
"Timestamp positions must reflect irregular elapsed time; pre-bucket the data or use a future continuous time-scale chart.",
|
|
24
|
+
"The visualization needs stacked, grouped, or multi-series bars.",
|
|
25
|
+
"The interaction requires selection, drill-down, brushing, or zoom.",
|
|
26
|
+
"The data communicates a part-to-whole relationship."
|
|
27
|
+
],
|
|
28
|
+
"alternatives": [
|
|
29
|
+
{
|
|
30
|
+
"when": "Users need to follow one or more trends across ordered categories.",
|
|
31
|
+
"component": "component:ds-chart-line",
|
|
32
|
+
"reason": "ChartLine connects ordered observations and supports multiple named series."
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"when": "The data communicates parts of a total.",
|
|
36
|
+
"component": "component:ds-chart-donut",
|
|
37
|
+
"reason": "ChartDonut provides the part-to-whole composition and center aggregate."
|
|
38
|
+
}
|
|
39
|
+
],
|
|
40
|
+
"commonlyComposedWith": [
|
|
41
|
+
"component:ds-card-shell-data-viz",
|
|
42
|
+
"component:ds-tooltip-data-viz"
|
|
43
|
+
],
|
|
44
|
+
"accessibility": [
|
|
45
|
+
"Keep category labels concise and provide an adjacent textual summary when exact values are critical to completing a task.",
|
|
46
|
+
"Do not rely on bar color alone to communicate category meaning.",
|
|
47
|
+
"A future interactive tooltip must supplement rather than replace the chart's accessible value representation."
|
|
48
|
+
],
|
|
49
|
+
"states": [
|
|
50
|
+
"The chart is currently a static single-series rendering without hover, selection, loading, or empty-state policy.",
|
|
51
|
+
"An empty dataset renders no bars; the owning card or product supplies meaningful empty-state messaging.",
|
|
52
|
+
"Use one consistent bar color across time buckets when every bar is the same measure at a different interval; categorical color changes are for genuinely distinct categories.",
|
|
53
|
+
"Authored datum colors override the shared categorical palette."
|
|
54
|
+
],
|
|
55
|
+
"responsiveBehavior": [
|
|
56
|
+
"The owner supplies dimensions and updates them with its layout; the chart does not measure its container.",
|
|
57
|
+
"Limit or pre-format long category labels so they remain legible at the chosen width.",
|
|
58
|
+
"Time labels remain ordered, pre-formatted buckets with equal spacing rather than raw continuous timestamps."
|
|
59
|
+
],
|
|
60
|
+
"frameworkCaveats": {
|
|
61
|
+
"customElements": [
|
|
62
|
+
"Assign data as a JavaScript property; arrays are not supported as HTML attributes."
|
|
63
|
+
],
|
|
64
|
+
"react": [
|
|
65
|
+
"Pass a stable data array and dimensions derived from the containing layout."
|
|
66
|
+
],
|
|
67
|
+
"angular": [
|
|
68
|
+
"Bind data as a property and update dimensions from the containing layout."
|
|
69
|
+
]
|
|
70
|
+
},
|
|
71
|
+
"references": [
|
|
72
|
+
{
|
|
73
|
+
"label": "Storybook examples",
|
|
74
|
+
"path": "src/wc/components/ChartBar/ChartBar.stories.ts"
|
|
75
|
+
}
|
|
76
|
+
]
|
|
77
|
+
},
|
|
14
78
|
"api": {
|
|
15
79
|
"props": {
|
|
16
80
|
"data": {
|
|
@@ -2,15 +2,81 @@
|
|
|
2
2
|
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
3
|
"name": "chart-donut",
|
|
4
4
|
"title": "ChartDonut",
|
|
5
|
-
"description": "
|
|
5
|
+
"description": "Part-to-whole donut chart with a center aggregate, responsive fill sizing, local slice tooltip feedback, and externally controlled legend highlighting.",
|
|
6
6
|
"type": "registry:ui",
|
|
7
7
|
"meta": {
|
|
8
8
|
"library": "@ds-mo/ui",
|
|
9
9
|
"distribution": "npm",
|
|
10
10
|
"storybook": "https://zainadeel.github.io/compomo/?path=/story/chart-donut",
|
|
11
11
|
"source": "src/wc/components/ChartDonut/ChartDonut.tsx",
|
|
12
|
-
"intentStatus": "
|
|
13
|
-
"intent":
|
|
12
|
+
"intentStatus": "complete",
|
|
13
|
+
"intent": {
|
|
14
|
+
"audience": "specialized",
|
|
15
|
+
"status": "experimental",
|
|
16
|
+
"summary": "Part-to-whole donut chart with a center aggregate, responsive fill sizing, local slice tooltip feedback, and externally controlled legend highlighting.",
|
|
17
|
+
"useWhen": [
|
|
18
|
+
"Users need to understand a small part-to-whole breakdown with a prominent total or status in the center.",
|
|
19
|
+
"A standalone donut needs pointer and keyboard-focus value feedback through a chart-owned data-viz tooltip.",
|
|
20
|
+
"A donut and visible ChartLegend should cross-highlight by matching stable labels."
|
|
21
|
+
],
|
|
22
|
+
"avoidWhen": [
|
|
23
|
+
"The data is a trend, time sequence, or independent magnitude comparison.",
|
|
24
|
+
"The category count creates slices too small to understand reliably.",
|
|
25
|
+
"Hover is intended to select, filter, or navigate rather than temporarily highlight data."
|
|
26
|
+
],
|
|
27
|
+
"alternatives": [
|
|
28
|
+
{
|
|
29
|
+
"when": "The product needs the canonical card, filter action, visible legend, and built-in hover synchronization.",
|
|
30
|
+
"component": "component:ds-card-data-viz-donut",
|
|
31
|
+
"reason": "The dedicated card owns that complete composition and suppresses redundant slice tooltips."
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"when": "Users need to compare independent category magnitudes.",
|
|
35
|
+
"component": "component:ds-chart-bar",
|
|
36
|
+
"reason": "Bars make category magnitude differences easier to compare."
|
|
37
|
+
}
|
|
38
|
+
],
|
|
39
|
+
"commonlyComposedWith": [
|
|
40
|
+
"component:ds-chart-legend",
|
|
41
|
+
"component:ds-tooltip-data-viz",
|
|
42
|
+
"component:ds-card-data-viz-donut"
|
|
43
|
+
],
|
|
44
|
+
"accessibility": [
|
|
45
|
+
"Every non-empty slice remains keyboard focusable and exposes its label and value without depending on the visual tooltip.",
|
|
46
|
+
"Use a visible legend when the full set of labels, values, or percentages must remain continuously available.",
|
|
47
|
+
"Provide localized no-data text for the neutral empty ring.",
|
|
48
|
+
"Center text is a visual summary and must not be the only source of essential category detail."
|
|
49
|
+
],
|
|
50
|
+
"states": [
|
|
51
|
+
"Genuine local pointer or keyboard focus may show a chart-owned tooltip; externally synchronized highlight never opens it.",
|
|
52
|
+
"When a visible legend already owns label and value detail, suppress the redundant donut tooltip. CardDataVizDonut does this automatically.",
|
|
53
|
+
"Local hover and external highlight remain separate while both may dim non-matching slices.",
|
|
54
|
+
"Zero or negative totals render a neutral empty ring without interactive slices.",
|
|
55
|
+
"Center value and caption truncate when they exceed the safe inner-circle measure."
|
|
56
|
+
],
|
|
57
|
+
"responsiveBehavior": [
|
|
58
|
+
"Prefer container-fill sizing inside data-viz cards and explicit sizing only in layouts that own a stable diameter.",
|
|
59
|
+
"Fill sizing remains centered and constrained to the shared donut size band.",
|
|
60
|
+
"The owner adapts category count and legend placement for available space."
|
|
61
|
+
],
|
|
62
|
+
"frameworkCaveats": {
|
|
63
|
+
"customElements": [
|
|
64
|
+
"Assign data as a JavaScript property and wire slice-hover detail to a sibling legend only when not using CardDataVizDonut."
|
|
65
|
+
],
|
|
66
|
+
"react": [
|
|
67
|
+
"Keep synchronized highlight controlled by the composition and disable slice tooltips when a sibling legend continuously shows the same details."
|
|
68
|
+
],
|
|
69
|
+
"angular": [
|
|
70
|
+
"Keep synchronized highlight controlled by the composition and disable slice tooltips when a sibling legend continuously shows the same details."
|
|
71
|
+
]
|
|
72
|
+
},
|
|
73
|
+
"references": [
|
|
74
|
+
{
|
|
75
|
+
"label": "Storybook examples",
|
|
76
|
+
"path": "src/wc/components/ChartDonut/ChartDonut.stories.ts"
|
|
77
|
+
}
|
|
78
|
+
]
|
|
79
|
+
},
|
|
14
80
|
"api": {
|
|
15
81
|
"props": {
|
|
16
82
|
"activeLabel": {
|
|
@@ -20,7 +86,7 @@
|
|
|
20
86
|
"default": "null",
|
|
21
87
|
"required": false,
|
|
22
88
|
"mutable": false,
|
|
23
|
-
"description": "Externally controlled highlight, matched by `label` — e.g. drive this from a sibling\n`ds-chart-legend`'s `dsItemHover` event to keep chart and legend hover in sync.\nFalls back to this component's own pointer/focus hover when unset.\nSlice hover dims peer slices and emits `dsSliceHover` for legend sync
|
|
89
|
+
"description": "Externally controlled highlight, matched by `label` — e.g. drive this from a sibling\n`ds-chart-legend`'s `dsItemHover` event to keep chart and legend hover in sync.\nFalls back to this component's own pointer/focus hover when unset.\nSlice hover dims peer slices and emits `dsSliceHover` for legend sync. External\nhighlight never opens the local tooltip."
|
|
24
90
|
},
|
|
25
91
|
"centerCaption": {
|
|
26
92
|
"type": "string | undefined",
|
|
@@ -79,6 +145,15 @@
|
|
|
79
145
|
"required": false,
|
|
80
146
|
"mutable": false
|
|
81
147
|
},
|
|
148
|
+
"showTooltip": {
|
|
149
|
+
"type": "boolean",
|
|
150
|
+
"resolvedType": "boolean",
|
|
151
|
+
"attribute": "show-tooltip",
|
|
152
|
+
"default": "true",
|
|
153
|
+
"required": false,
|
|
154
|
+
"mutable": false,
|
|
155
|
+
"description": "Show a chart-owned value callout for genuine pointer or keyboard focus.\nDisable when a visible legend already owns persistent label and value detail."
|
|
156
|
+
},
|
|
82
157
|
"size": {
|
|
83
158
|
"type": "number | undefined",
|
|
84
159
|
"resolvedType": "number | undefined",
|
|
@@ -118,7 +193,7 @@
|
|
|
118
193
|
"default": "null",
|
|
119
194
|
"required": false,
|
|
120
195
|
"mutable": false,
|
|
121
|
-
"description": "Externally controlled highlight, matched by `label` — e.g. drive this from a sibling\n`ds-chart-legend`'s `dsItemHover` event to keep chart and legend hover in sync.\nFalls back to this component's own pointer/focus hover when unset.\nSlice hover dims peer slices and emits `dsSliceHover` for legend sync
|
|
196
|
+
"description": "Externally controlled highlight, matched by `label` — e.g. drive this from a sibling\n`ds-chart-legend`'s `dsItemHover` event to keep chart and legend hover in sync.\nFalls back to this component's own pointer/focus hover when unset.\nSlice hover dims peer slices and emits `dsSliceHover` for legend sync. External\nhighlight never opens the local tooltip."
|
|
122
197
|
},
|
|
123
198
|
"centerCaption": {
|
|
124
199
|
"type": "string | undefined",
|
|
@@ -177,6 +252,15 @@
|
|
|
177
252
|
"required": false,
|
|
178
253
|
"mutable": false
|
|
179
254
|
},
|
|
255
|
+
"showTooltip": {
|
|
256
|
+
"type": "boolean",
|
|
257
|
+
"resolvedType": "boolean",
|
|
258
|
+
"attribute": "show-tooltip",
|
|
259
|
+
"default": "true",
|
|
260
|
+
"required": false,
|
|
261
|
+
"mutable": false,
|
|
262
|
+
"description": "Show a chart-owned value callout for genuine pointer or keyboard focus.\nDisable when a visible legend already owns persistent label and value detail."
|
|
263
|
+
},
|
|
180
264
|
"size": {
|
|
181
265
|
"type": "number | undefined",
|
|
182
266
|
"resolvedType": "number | undefined",
|
|
@@ -241,16 +325,18 @@
|
|
|
241
325
|
"@ds-mo/ui",
|
|
242
326
|
"@ds-mo/tokens"
|
|
243
327
|
],
|
|
244
|
-
"registryDependencies": [
|
|
328
|
+
"registryDependencies": [
|
|
329
|
+
"tooltip-data-viz"
|
|
330
|
+
],
|
|
245
331
|
"files": [
|
|
246
332
|
{
|
|
247
333
|
"path": "src/wc/components/ChartDonut/ChartDonut.css",
|
|
248
|
-
"content": ":host {\n display: inline-block;\n font-family: var(--typography-font-family);\n user-select: none;\n}\n\n:host(.chart-donut--fill) {\n display: block;\n width: 100%;\n height: 100%;\n min-width: 0;\n min-height: 0;\n}\n\n.chart-donut__wrapper {\n position: relative;\n}\n\n:host(.chart-donut--fill) .chart-donut__wrapper {\n width: 100%;\n height: 100%;\n display: flex;\n align-items: center;\n justify-content: center;\n}\n\n.chart-donut__svg path {\n cursor: default;\n transition: opacity var(--effect-motion-short-2);\n}\n\n@media (prefers-reduced-motion: reduce) {\n .chart-donut__svg path {\n transition: none;\n }\n}\n\n.chart-donut__svg path:focus-visible {\n outline: none;\n stroke: var(--color-interaction-focus);\n stroke-width: 2;\n}\n\n/* Matches ds-text text-title-large + emphasis (SVG cannot host ds-text). */\n.chart-donut__center-value {\n fill: var(--color-foreground-primary);\n font-family: var(--typography-font-family);\n font-size: var(--typography-fontsize-xl);\n line-height: var(--typography-lineheight-xl);\n font-weight: var(--typography-weight-semibold);\n letter-spacing: var(--typography-letterspacing-negative-double);\n cursor: default;\n}\n\n/* Matches ds-text text-body-medium regular. */\n.chart-donut__center-caption {\n fill: var(--color-foreground-secondary);\n font-family: var(--typography-font-family);\n font-size: var(--typography-fontsize-md);\n line-height: var(--typography-lineheight-md);\n font-weight: var(--typography-weight-regular);\n letter-spacing: var(--typography-letterspacing-negative-half);\n cursor: default;\n}\n",
|
|
334
|
+
"content": ":host {\n display: inline-block;\n font-family: var(--typography-font-family);\n user-select: none;\n}\n\n:host(.chart-donut--fill) {\n display: block;\n width: 100%;\n height: 100%;\n min-width: 0;\n min-height: 0;\n}\n\n.chart-donut__wrapper {\n position: relative;\n overflow: visible;\n}\n\n:host(.chart-donut--fill) .chart-donut__wrapper {\n width: 100%;\n height: 100%;\n display: flex;\n align-items: center;\n justify-content: center;\n}\n\n.chart-donut__svg path {\n cursor: default;\n transition: opacity var(--effect-motion-short-2);\n}\n\n@media (prefers-reduced-motion: reduce) {\n .chart-donut__svg path {\n transition: none;\n }\n}\n\n.chart-donut__svg path:focus-visible {\n outline: none;\n stroke: var(--color-interaction-focus);\n stroke-width: 2;\n}\n\n/* Matches ds-text text-title-large + emphasis (SVG cannot host ds-text). */\n.chart-donut__center-value {\n fill: var(--color-foreground-primary);\n font-family: var(--typography-font-family);\n font-size: var(--typography-fontsize-xl);\n line-height: var(--typography-lineheight-xl);\n font-weight: var(--typography-weight-semibold);\n letter-spacing: var(--typography-letterspacing-negative-double);\n cursor: default;\n pointer-events: none;\n}\n\n/* Matches ds-text text-body-medium regular. */\n.chart-donut__center-caption {\n fill: var(--color-foreground-secondary);\n font-family: var(--typography-font-family);\n font-size: var(--typography-fontsize-md);\n line-height: var(--typography-lineheight-md);\n font-weight: var(--typography-weight-regular);\n letter-spacing: var(--typography-letterspacing-negative-half);\n cursor: default;\n pointer-events: none;\n}\n",
|
|
249
335
|
"type": "registry:ui"
|
|
250
336
|
},
|
|
251
337
|
{
|
|
252
338
|
"path": "src/wc/components/ChartDonut/ChartDonut.tsx",
|
|
253
|
-
"content": "import { Component, Prop, State, Event, EventEmitter, Element, Watch, h, Host } from '@stencil/core';\nimport { arc, pie } from 'd3-shape';\nimport { categoryColor } from '../../utils/chart-colors';\nimport { formatCompactNumber, resolveCssLengthPx, truncateSvgTextToWidth, TOKEN_DEFAULTS } from '../../utils';\nimport type { ChartDatum } from '../../utils/chart-types';\n\nconst DIMMED_OPACITY = 0.25;\n/** Gap between the center value and caption line boxes. */\nconst CENTER_GAP_PX = 0;\n/** Fraction of the inner-circle diameter center text is allowed to use before truncating. */\nconst CENTER_TEXT_SAFE_WIDTH_RATIO = 0.82;\n/** Fallback when filling before the first ResizeObserver measurement (matches fill min). */\nconst FILL_FALLBACK_PX = 128;\n\n@Component({\n tag: 'ds-chart-donut',\n styleUrl: 'ChartDonut.css',\n scoped: true,\n})\nexport class ChartDonut {\n @Prop() locale: string | undefined;\n @Prop() noDataLabel: string = 'No data';\n @Element() el!: HTMLElement;\n\n /** Slices to render. Set as a JS property (not an HTML attribute). */\n @Prop() data: ChartDatum[] = [];\n /**\n * Explicit diameter in px. When unset, the donut sizes to its container\n * (ResizeObserver) clamped between `--dimension-size-base * 16` (128px) and\n * `* 24` (192px), and stays centered in the leftover space. Prefer unset\n * inside card layouts.\n */\n @Prop() size: number | undefined;\n /** Ring thickness — number (px) or TokoMo length. Defaults to `--dimension-size-200` (16px). */\n @Prop() thickness: number | string = TOKEN_DEFAULTS.size200;\n /** Corner radius on each slice — number (px) or TokoMo length. Defaults to `--dimension-radius-025` (2px). */\n @Prop() cornerRadius: number | string = TOKEN_DEFAULTS.radius025;\n /** Gap between slices, in degrees. */\n @Prop() gap: number = 1;\n /** Primary center value; defaults to the sum of `data` values (e.g. \"187\", \"40.9%\"). */\n @Prop() centerValue: string | undefined;\n /** Secondary caption below the center value (e.g. \"Total\", \"Normal\"). Rendered uppercase. */\n @Prop() centerCaption: string | undefined;\n /**\n * Externally controlled highlight, matched by `label` — e.g. drive this from a sibling\n * `ds-chart-legend`'s `dsItemHover` event to keep chart and legend hover in sync.\n * Falls back to this component's own pointer/focus hover when unset.\n * Slice hover dims peer slices and emits `dsSliceHover` for legend sync — no data-viz\n * tooltip (the legend already surfaces label/value).\n */\n @Prop() activeLabel: string | null = null;\n\n @State() private hoveredLabel: string | null = null;\n /** Center text, truncated with an ellipsis if it doesn't fit inside the inner circle. */\n @State() private displayedValueText: string = '';\n @State() private displayedCaptionText: string = '';\n /** Measured fill diameter when `size` is unset. */\n @State() private measuredSize: number = FILL_FALLBACK_PX;\n\n /** Fires with the hovered/focused slice's datum, or `null` on leave/blur. */\n @Event() dsSliceHover!: EventEmitter<ChartDatum | null>;\n\n private valueTextEl?: SVGTextElement;\n private captionTextEl?: SVGTextElement;\n private resizeObserver: ResizeObserver | null = null;\n\n private get isFillMode(): boolean {\n return this.size == null || !Number.isFinite(this.size) || this.size <= 0;\n }\n\n private get fillMinPx(): number {\n return resolveCssLengthPx(TOKEN_DEFAULTS.donutFillMin, FILL_FALLBACK_PX);\n }\n\n private get fillMaxPx(): number {\n return resolveCssLengthPx(TOKEN_DEFAULTS.donutFillMax, 192);\n }\n\n /** Clamp available square side into the fill min/max band. */\n private clampFillSize(availablePx: number): number {\n const minPx = this.fillMinPx;\n const maxPx = this.fillMaxPx;\n if (!(availablePx > 0)) return minPx;\n return Math.round(Math.min(maxPx, Math.max(minPx, availablePx)));\n }\n\n private get resolvedSize(): number {\n if (!this.isFillMode) return this.size as number;\n return this.clampFillSize(this.measuredSize);\n }\n\n componentDidLoad() {\n this.syncResizeObserver();\n }\n\n @Watch('size')\n onSizePropChange() {\n this.syncResizeObserver();\n }\n\n disconnectedCallback() {\n this.teardownResizeObserver();\n }\n\n private syncResizeObserver() {\n this.teardownResizeObserver();\n if (!this.isFillMode) return;\n // Observe the host (which fills its parent), not the wrapper — the wrapper\n // only wraps the SVG and would collapse to the clamped size, locking fill at min.\n const target = this.el;\n if (!target || typeof ResizeObserver === 'undefined') return;\n\n this.resizeObserver = new ResizeObserver(entries => {\n const entry = entries[0];\n if (!entry) return;\n this.applyAvailableSize(entry.contentRect.width, entry.contentRect.height);\n });\n this.resizeObserver.observe(target);\n this.measureHost();\n }\n\n private measureHost() {\n const rect = this.el.getBoundingClientRect();\n this.applyAvailableSize(rect.width, rect.height);\n }\n\n private applyAvailableSize(width: number, height: number) {\n const available = Math.floor(Math.min(width, height));\n if (available > 0 && available !== this.measuredSize) {\n this.measuredSize = available;\n }\n }\n\n private teardownResizeObserver() {\n this.resizeObserver?.disconnect();\n this.resizeObserver = null;\n }\n\n private handleHover(datum: ChartDatum | null) {\n this.hoveredLabel = datum?.label ?? null;\n this.dsSliceHover.emit(datum);\n }\n\n componentDidRender() {\n // Re-bind after HMR when DidLoad's observer was dropped.\n if (this.isFillMode && !this.resizeObserver) {\n this.syncResizeObserver();\n }\n\n const size = this.resolvedSize;\n const radius = size / 2;\n const thicknessPx = resolveCssLengthPx(this.thickness, TOKEN_DEFAULTS.size200);\n const innerRadius = radius - thicknessPx;\n const maxWidth = innerRadius * 2 * CENTER_TEXT_SAFE_WIDTH_RATIO;\n const total = this.data.reduce((sum, d) => sum + d.value, 0);\n\n const fullValueText = this.centerValue ?? formatCompactNumber(total, this.locale);\n if (this.valueTextEl) {\n const truncated = truncateSvgTextToWidth(this.valueTextEl, fullValueText, maxWidth);\n if (truncated !== this.displayedValueText) this.displayedValueText = truncated;\n else this.valueTextEl.textContent = truncated;\n }\n\n const fullCaptionText = this.centerCaption ?? '';\n if (this.captionTextEl && fullCaptionText) {\n const truncated = truncateSvgTextToWidth(this.captionTextEl, fullCaptionText, maxWidth);\n if (truncated !== this.displayedCaptionText) this.displayedCaptionText = truncated;\n else this.captionTextEl.textContent = truncated;\n }\n }\n\n render() {\n const size = this.resolvedSize;\n const radius = size / 2;\n const thicknessPx = resolveCssLengthPx(this.thickness, TOKEN_DEFAULTS.size200);\n const cornerRadiusPx = resolveCssLengthPx(this.cornerRadius, TOKEN_DEFAULTS.radius025);\n const innerRadius = radius - thicknessPx;\n const total = this.data.reduce((sum, d) => sum + d.value, 0);\n // d3's pie() divides each value by the total to get an angle — with an all-zero total\n // that's 0/0, producing NaN angles and broken paths. Render a flat neutral ring instead.\n const isEmpty = total <= 0;\n // Highlight/dim from either this component's own hover or an externally-synced label\n // (e.g. a sibling ds-chart-legend row).\n const highlightLabel = this.activeLabel ?? this.hoveredLabel;\n\n const arcGenerator = arc<{ startAngle: number; endAngle: number }>()\n .innerRadius(innerRadius)\n .outerRadius(radius)\n .cornerRadius(cornerRadiusPx)\n .padAngle((this.gap * Math.PI) / 180);\n\n const slices = isEmpty\n ? []\n : pie<ChartDatum>()\n .value(d => d.value)\n .sort(null)(this.data);\n\n const emptyRingPath = isEmpty\n ? arc<{ startAngle: number; endAngle: number }>()\n .innerRadius(innerRadius)\n .outerRadius(radius)({ startAngle: 0, endAngle: Math.PI * 2 })\n : null;\n\n // Precise vertical centering for the two-line center text, using the real line-height of\n // text-title-large (value) and text-body-medium (caption) rather than eyeballed em offsets.\n const valueLineHeight = resolveCssLengthPx(TOKEN_DEFAULTS.lineheightXl, 32);\n const captionLineHeight = resolveCssLengthPx(TOKEN_DEFAULTS.lineheightMd, 20);\n const centerValueY = this.centerCaption ? radius - (CENTER_GAP_PX + captionLineHeight) / 2 : radius;\n const centerCaptionY = radius + (valueLineHeight + CENTER_GAP_PX) / 2;\n\n // Show the full text before the post-render truncation pass has measured it (avoids a blank first paint).\n const fullValueText = this.centerValue ?? formatCompactNumber(total, this.locale);\n const fullCaptionText = this.centerCaption ?? '';\n const fill = this.isFillMode;\n\n return (\n <Host\n class={{\n 'chart-donut': true,\n 'chart-donut--fill': fill,\n 'chart-donut--fixed': !fill,\n }}\n style={!fill ? { width: `${size}px`, height: `${size}px` } : undefined}\n >\n <div\n class=\"chart-donut__wrapper\"\n style={!fill ? { width: `${size}px`, height: `${size}px` } : undefined}\n >\n <svg\n class=\"chart-donut__svg\"\n viewBox={`0 0 ${size} ${size}`}\n width={size}\n height={size}\n role={isEmpty ? 'img' : undefined}\n aria-label={isEmpty ? this.noDataLabel : undefined}\n >\n <g transform={`translate(${radius}, ${radius})`}>\n {isEmpty ? (\n <path d={emptyRingPath ?? undefined} fill=\"var(--color-background-faint-neutral)\" aria-hidden=\"true\" />\n ) : (\n slices.map((slice, i) => {\n const datum = this.data[i];\n const isDimmed = highlightLabel != null && datum.label !== highlightLabel;\n return (\n <path\n key={datum.label}\n d={arcGenerator(slice) ?? undefined}\n fill={datum.color ?? categoryColor(i)}\n opacity={isDimmed ? DIMMED_OPACITY : 1}\n tabindex={0}\n role=\"img\"\n aria-label={`${datum.label}: ${datum.value}`}\n onMouseEnter={() => this.handleHover(datum)}\n onMouseLeave={() => this.handleHover(null)}\n onFocus={() => this.handleHover(datum)}\n onBlur={() => this.handleHover(null)}\n />\n );\n })\n )}\n </g>\n <text\n class=\"chart-donut__center-value\"\n x={radius}\n y={centerValueY}\n text-anchor=\"middle\"\n dominant-baseline=\"central\"\n ref={el => {\n this.valueTextEl = (el as SVGTextElement) ?? undefined;\n }}\n >\n {this.displayedValueText || fullValueText}\n </text>\n {fullCaptionText && (\n <text\n class=\"chart-donut__center-caption\"\n x={radius}\n y={centerCaptionY}\n text-anchor=\"middle\"\n dominant-baseline=\"central\"\n ref={el => {\n this.captionTextEl = (el as SVGTextElement) ?? undefined;\n }}\n >\n {this.displayedCaptionText || fullCaptionText}\n </text>\n )}\n </svg>\n </div>\n </Host>\n );\n }\n}\n",
|
|
339
|
+
"content": "import { Component, Prop, State, Event, EventEmitter, Element, Watch, h, Host } from '@stencil/core';\nimport { arc, pie } from 'd3-shape';\nimport { categoryColor } from '../../utils/chart-colors';\nimport { formatCompactNumber, resolveCssLengthPx, truncateSvgTextToWidth, TOKEN_DEFAULTS } from '../../utils';\nimport type { ChartDatum } from '../../utils/chart-types';\n\nconst DIMMED_OPACITY = 0.25;\n/** Gap between the center value and caption line boxes. */\nconst CENTER_GAP_PX = 0;\n/** Fraction of the inner-circle diameter center text is allowed to use before truncating. */\nconst CENTER_TEXT_SAFE_WIDTH_RATIO = 0.82;\n/** Fallback when filling before the first ResizeObserver measurement (matches fill min). */\nconst FILL_FALLBACK_PX = 128;\n\n@Component({\n tag: 'ds-chart-donut',\n styleUrl: 'ChartDonut.css',\n scoped: true,\n})\nexport class ChartDonut {\n @Prop() locale: string | undefined;\n @Prop() noDataLabel: string = 'No data';\n @Element() el!: HTMLElement;\n\n /** Slices to render. Set as a JS property (not an HTML attribute). */\n @Prop() data: ChartDatum[] = [];\n /**\n * Explicit diameter in px. When unset, the donut sizes to its container\n * (ResizeObserver) clamped between `--dimension-size-base * 16` (128px) and\n * `* 24` (192px), and stays centered in the leftover space. Prefer unset\n * inside card layouts.\n */\n @Prop() size: number | undefined;\n /** Ring thickness — number (px) or TokoMo length. Defaults to `--dimension-size-200` (16px). */\n @Prop() thickness: number | string = TOKEN_DEFAULTS.size200;\n /** Corner radius on each slice — number (px) or TokoMo length. Defaults to `--dimension-radius-025` (2px). */\n @Prop() cornerRadius: number | string = TOKEN_DEFAULTS.radius025;\n /** Gap between slices, in degrees. */\n @Prop() gap: number = 1;\n /**\n * Show a chart-owned value callout for genuine pointer or keyboard focus.\n * Disable when a visible legend already owns persistent label and value detail.\n */\n @Prop() showTooltip: boolean = true;\n /** Primary center value; defaults to the sum of `data` values (e.g. \"187\", \"40.9%\"). */\n @Prop() centerValue: string | undefined;\n /** Secondary caption below the center value (e.g. \"Total\", \"Normal\"). Rendered uppercase. */\n @Prop() centerCaption: string | undefined;\n /**\n * Externally controlled highlight, matched by `label` — e.g. drive this from a sibling\n * `ds-chart-legend`'s `dsItemHover` event to keep chart and legend hover in sync.\n * Falls back to this component's own pointer/focus hover when unset.\n * Slice hover dims peer slices and emits `dsSliceHover` for legend sync. External\n * highlight never opens the local tooltip.\n */\n @Prop() activeLabel: string | null = null;\n\n @State() private hoveredLabel: string | null = null;\n /** Center text, truncated with an ellipsis if it doesn't fit inside the inner circle. */\n @State() private displayedValueText: string = '';\n @State() private displayedCaptionText: string = '';\n /** Measured fill diameter when `size` is unset. */\n @State() private measuredSize: number = FILL_FALLBACK_PX;\n @State() private tooltipX: number = 0;\n @State() private tooltipY: number = 0;\n\n /** Fires with the hovered/focused slice's datum, or `null` on leave/blur. */\n @Event() dsSliceHover!: EventEmitter<ChartDatum | null>;\n\n private valueTextEl?: SVGTextElement;\n private captionTextEl?: SVGTextElement;\n private resizeObserver: ResizeObserver | null = null;\n\n private get isFillMode(): boolean {\n return this.size == null || !Number.isFinite(this.size) || this.size <= 0;\n }\n\n private get fillMinPx(): number {\n return resolveCssLengthPx(TOKEN_DEFAULTS.donutFillMin, FILL_FALLBACK_PX);\n }\n\n private get fillMaxPx(): number {\n return resolveCssLengthPx(TOKEN_DEFAULTS.donutFillMax, 192);\n }\n\n /** Clamp available square side into the fill min/max band. */\n private clampFillSize(availablePx: number): number {\n const minPx = this.fillMinPx;\n const maxPx = this.fillMaxPx;\n if (!(availablePx > 0)) return minPx;\n return Math.round(Math.min(maxPx, Math.max(minPx, availablePx)));\n }\n\n private get resolvedSize(): number {\n if (!this.isFillMode) return this.size as number;\n return this.clampFillSize(this.measuredSize);\n }\n\n componentDidLoad() {\n this.syncResizeObserver();\n }\n\n @Watch('size')\n onSizePropChange() {\n this.syncResizeObserver();\n }\n\n disconnectedCallback() {\n this.teardownResizeObserver();\n }\n\n private syncResizeObserver() {\n this.teardownResizeObserver();\n if (!this.isFillMode) return;\n // Observe the host (which fills its parent), not the wrapper — the wrapper\n // only wraps the SVG and would collapse to the clamped size, locking fill at min.\n const target = this.el;\n if (!target || typeof ResizeObserver === 'undefined') return;\n\n this.resizeObserver = new ResizeObserver(entries => {\n const entry = entries[0];\n if (!entry) return;\n this.applyAvailableSize(entry.contentRect.width, entry.contentRect.height);\n });\n this.resizeObserver.observe(target);\n this.measureHost();\n }\n\n private measureHost() {\n const rect = this.el.getBoundingClientRect();\n this.applyAvailableSize(rect.width, rect.height);\n }\n\n private applyAvailableSize(width: number, height: number) {\n const available = Math.floor(Math.min(width, height));\n if (available > 0 && available !== this.measuredSize) {\n this.measuredSize = available;\n }\n }\n\n private teardownResizeObserver() {\n this.resizeObserver?.disconnect();\n this.resizeObserver = null;\n }\n\n private handleHover(datum: ChartDatum | null) {\n this.hoveredLabel = datum?.label ?? null;\n this.dsSliceHover.emit(datum);\n }\n\n private get tooltipDatum(): ChartDatum | null {\n if (!this.showTooltip || this.hoveredLabel == null) return null;\n return this.data.find(datum => datum.label === this.hoveredLabel) ?? null;\n }\n\n private updateTooltipFromPointer(event: MouseEvent) {\n if (!this.showTooltip) return;\n const wrapper = this.el.querySelector<HTMLElement>('.chart-donut__wrapper');\n if (!wrapper) return;\n const rect = wrapper.getBoundingClientRect();\n this.tooltipX = event.clientX - rect.left;\n this.tooltipY = event.clientY - rect.top;\n }\n\n private updateTooltipFromSvgPoint(\n path: SVGPathElement,\n svgX: number,\n svgY: number,\n viewBoxSize: number,\n ) {\n if (!this.showTooltip) return;\n const wrapper = this.el.querySelector<HTMLElement>('.chart-donut__wrapper');\n const svg = path.ownerSVGElement;\n if (!wrapper || !svg) return;\n const wrapperRect = wrapper.getBoundingClientRect();\n const svgRect = svg.getBoundingClientRect();\n this.tooltipX = svgRect.left - wrapperRect.left + svgX * (svgRect.width / viewBoxSize);\n this.tooltipY = svgRect.top - wrapperRect.top + svgY * (svgRect.height / viewBoxSize);\n }\n\n componentDidRender() {\n // Re-bind after HMR when DidLoad's observer was dropped.\n if (this.isFillMode && !this.resizeObserver) {\n this.syncResizeObserver();\n }\n\n const size = this.resolvedSize;\n const radius = size / 2;\n const thicknessPx = resolveCssLengthPx(this.thickness, TOKEN_DEFAULTS.size200);\n const innerRadius = radius - thicknessPx;\n const maxWidth = innerRadius * 2 * CENTER_TEXT_SAFE_WIDTH_RATIO;\n const total = this.data.reduce((sum, d) => sum + d.value, 0);\n\n const fullValueText = this.centerValue ?? formatCompactNumber(total, this.locale);\n if (this.valueTextEl) {\n const truncated = truncateSvgTextToWidth(this.valueTextEl, fullValueText, maxWidth);\n if (truncated !== this.displayedValueText) this.displayedValueText = truncated;\n else this.valueTextEl.textContent = truncated;\n }\n\n const fullCaptionText = this.centerCaption ?? '';\n if (this.captionTextEl && fullCaptionText) {\n const truncated = truncateSvgTextToWidth(this.captionTextEl, fullCaptionText, maxWidth);\n if (truncated !== this.displayedCaptionText) this.displayedCaptionText = truncated;\n else this.captionTextEl.textContent = truncated;\n }\n }\n\n render() {\n const size = this.resolvedSize;\n const radius = size / 2;\n const thicknessPx = resolveCssLengthPx(this.thickness, TOKEN_DEFAULTS.size200);\n const cornerRadiusPx = resolveCssLengthPx(this.cornerRadius, TOKEN_DEFAULTS.radius025);\n const innerRadius = radius - thicknessPx;\n const total = this.data.reduce((sum, d) => sum + d.value, 0);\n // d3's pie() divides each value by the total to get an angle — with an all-zero total\n // that's 0/0, producing NaN angles and broken paths. Render a flat neutral ring instead.\n const isEmpty = total <= 0;\n // Highlight/dim from either this component's own hover or an externally-synced label\n // (e.g. a sibling ds-chart-legend row).\n const highlightLabel = this.activeLabel ?? this.hoveredLabel;\n\n const arcGenerator = arc<{ startAngle: number; endAngle: number }>()\n .innerRadius(innerRadius)\n .outerRadius(radius)\n .cornerRadius(cornerRadiusPx)\n .padAngle((this.gap * Math.PI) / 180);\n\n const slices = isEmpty\n ? []\n : pie<ChartDatum>()\n .value(d => d.value)\n .sort(null)(this.data);\n\n const emptyRingPath = isEmpty\n ? arc<{ startAngle: number; endAngle: number }>()\n .innerRadius(innerRadius)\n .outerRadius(radius)({ startAngle: 0, endAngle: Math.PI * 2 })\n : null;\n\n // Precise vertical centering for the two-line center text, using the real line-height of\n // text-title-large (value) and text-body-medium (caption) rather than eyeballed em offsets.\n const valueLineHeight = resolveCssLengthPx(TOKEN_DEFAULTS.lineheightXl, 32);\n const captionLineHeight = resolveCssLengthPx(TOKEN_DEFAULTS.lineheightMd, 20);\n const centerValueY = this.centerCaption ? radius - (CENTER_GAP_PX + captionLineHeight) / 2 : radius;\n const centerCaptionY = radius + (valueLineHeight + CENTER_GAP_PX) / 2;\n\n // Show the full text before the post-render truncation pass has measured it (avoids a blank first paint).\n const fullValueText = this.centerValue ?? formatCompactNumber(total, this.locale);\n const fullCaptionText = this.centerCaption ?? '';\n const fill = this.isFillMode;\n\n return (\n <Host\n class={{\n 'chart-donut': true,\n 'chart-donut--fill': fill,\n 'chart-donut--fixed': !fill,\n }}\n style={!fill ? { width: `${size}px`, height: `${size}px` } : undefined}\n >\n <div\n class=\"chart-donut__wrapper\"\n style={!fill ? { width: `${size}px`, height: `${size}px` } : undefined}\n >\n <svg\n class=\"chart-donut__svg\"\n viewBox={`0 0 ${size} ${size}`}\n width={size}\n height={size}\n role={isEmpty ? 'img' : undefined}\n aria-label={isEmpty ? this.noDataLabel : undefined}\n >\n <g transform={`translate(${radius}, ${radius})`}>\n {isEmpty ? (\n <path d={emptyRingPath ?? undefined} fill=\"var(--color-background-faint-neutral)\" aria-hidden=\"true\" />\n ) : (\n slices.map((slice, i) => {\n const datum = this.data[i];\n const isDimmed = highlightLabel != null && datum.label !== highlightLabel;\n const [centroidX, centroidY] = arcGenerator.centroid(slice);\n return (\n <path\n key={datum.label}\n d={arcGenerator(slice) ?? undefined}\n fill={datum.color ?? categoryColor(i)}\n opacity={isDimmed ? DIMMED_OPACITY : 1}\n tabindex={0}\n role=\"img\"\n aria-label={`${datum.label}: ${datum.value}`}\n onMouseEnter={(event: MouseEvent) => {\n this.updateTooltipFromPointer(event);\n this.handleHover(datum);\n }}\n onMouseMove={(event: MouseEvent) => this.updateTooltipFromPointer(event)}\n onMouseLeave={() => this.handleHover(null)}\n onFocus={(event: FocusEvent) => {\n this.updateTooltipFromSvgPoint(\n event.currentTarget as SVGPathElement,\n radius + centroidX,\n radius + centroidY,\n size,\n );\n this.handleHover(datum);\n }}\n onBlur={() => this.handleHover(null)}\n />\n );\n })\n )}\n </g>\n <text\n class=\"chart-donut__center-value\"\n x={radius}\n y={centerValueY}\n text-anchor=\"middle\"\n dominant-baseline=\"central\"\n ref={el => {\n this.valueTextEl = (el as SVGTextElement) ?? undefined;\n }}\n >\n {this.displayedValueText || fullValueText}\n </text>\n {fullCaptionText && (\n <text\n class=\"chart-donut__center-caption\"\n x={radius}\n y={centerCaptionY}\n text-anchor=\"middle\"\n dominant-baseline=\"central\"\n ref={el => {\n this.captionTextEl = (el as SVGTextElement) ?? undefined;\n }}\n >\n {this.displayedCaptionText || fullCaptionText}\n </text>\n )}\n </svg>\n {this.tooltipDatum && (\n <ds-tooltip-data-viz\n label={this.tooltipDatum.label}\n value={formatCompactNumber(this.tooltipDatum.value, this.locale)}\n x={this.tooltipX}\n y={this.tooltipY}\n />\n )}\n </div>\n </Host>\n );\n }\n}\n",
|
|
254
340
|
"type": "registry:ui"
|
|
255
341
|
}
|
|
256
342
|
]
|
|
@@ -2,15 +2,85 @@
|
|
|
2
2
|
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
3
|
"name": "chart-legend",
|
|
4
4
|
"title": "ChartLegend",
|
|
5
|
-
"description": "
|
|
5
|
+
"description": "Display-first chart legend with swatches, labels, optional values and percentages, explicit deep links, and highlight-only chart synchronization.",
|
|
6
6
|
"type": "registry:ui",
|
|
7
7
|
"meta": {
|
|
8
8
|
"library": "@ds-mo/ui",
|
|
9
9
|
"distribution": "npm",
|
|
10
10
|
"storybook": "https://zainadeel.github.io/compomo/?path=/story/chart-legend",
|
|
11
11
|
"source": "src/wc/components/ChartLegend/ChartLegend.tsx",
|
|
12
|
-
"intentStatus": "
|
|
13
|
-
"intent":
|
|
12
|
+
"intentStatus": "complete",
|
|
13
|
+
"intent": {
|
|
14
|
+
"audience": "specialized",
|
|
15
|
+
"status": "experimental",
|
|
16
|
+
"summary": "Display-first chart legend with swatches, labels, optional values and percentages, explicit deep links, and highlight-only chart synchronization.",
|
|
17
|
+
"useWhen": [
|
|
18
|
+
"A chart needs the standard swatch, label, and optional numeric-detail legend.",
|
|
19
|
+
"Donut slices or line series need a continuously visible key beside or below the visualization.",
|
|
20
|
+
"A category has an explicit deep-link destination and should render as an accessible link."
|
|
21
|
+
],
|
|
22
|
+
"avoidWhen": [
|
|
23
|
+
"The design calls for chips, bare swatches, external stat callouts, or another custom legend treatment.",
|
|
24
|
+
"Rows need to toggle visibility, filter data, or represent selection.",
|
|
25
|
+
"The content is a command menu or navigation list unrelated to chart data."
|
|
26
|
+
],
|
|
27
|
+
"alternatives": [
|
|
28
|
+
{
|
|
29
|
+
"when": "The product needs a nonstandard legend treatment.",
|
|
30
|
+
"component": "component:ds-text",
|
|
31
|
+
"reason": "Compose product-owned semantic markup from the same chart data rather than forcing it into this row recipe."
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"when": "The donut belongs in the canonical dashboard card.",
|
|
35
|
+
"component": "component:ds-card-data-viz-donut",
|
|
36
|
+
"reason": "The dedicated card places the legend and handles bidirectional highlight synchronization."
|
|
37
|
+
}
|
|
38
|
+
],
|
|
39
|
+
"commonlyComposedWith": [
|
|
40
|
+
"component:ds-chart-donut",
|
|
41
|
+
"component:ds-chart-line",
|
|
42
|
+
"component:ds-card-data-viz-donut",
|
|
43
|
+
"component:ds-card-shell-data-viz"
|
|
44
|
+
],
|
|
45
|
+
"accessibility": [
|
|
46
|
+
"Rows remain non-interactive unless the item supplies an actual link destination.",
|
|
47
|
+
"Synced highlight changes opacity only and never moves focus or announces selection.",
|
|
48
|
+
"Keep full labels available when visible text truncates, and retain stable tabular numeric columns.",
|
|
49
|
+
"Do not rely on swatch color alone; every entry requires a meaningful visible label."
|
|
50
|
+
],
|
|
51
|
+
"states": [
|
|
52
|
+
"Local pointer or focus interaction and external chart highlight remain separate; both may dim peers, but only a real link row receives interactive affordances.",
|
|
53
|
+
"Hover synchronization is temporary emphasis, never filtering, toggling, or selected state.",
|
|
54
|
+
"Percentage values use one consistent precision across the complete legend.",
|
|
55
|
+
"The list owns pointer leave so moving across row gaps does not clear and reapply highlight."
|
|
56
|
+
],
|
|
57
|
+
"responsiveBehavior": [
|
|
58
|
+
"Vertical legends let the label yield width and truncate before right-aligned value and percentage columns.",
|
|
59
|
+
"Horizontal legends wrap complete entries and suit compact series keys below a chart.",
|
|
60
|
+
"The parent constrains width and decides when a custom condensed treatment is necessary."
|
|
61
|
+
],
|
|
62
|
+
"frameworkCaveats": {
|
|
63
|
+
"customElements": [
|
|
64
|
+
"Assign items as a JavaScript property and set href only for genuine navigation."
|
|
65
|
+
],
|
|
66
|
+
"react": [
|
|
67
|
+
"Intercept the item-click event only when application routing must replace native link navigation."
|
|
68
|
+
],
|
|
69
|
+
"angular": [
|
|
70
|
+
"Intercept the item-click event only when application routing must replace native link navigation."
|
|
71
|
+
]
|
|
72
|
+
},
|
|
73
|
+
"references": [
|
|
74
|
+
{
|
|
75
|
+
"label": "Storybook examples",
|
|
76
|
+
"path": "src/wc/components/ChartLegend/ChartLegend.stories.ts"
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
"label": "Rendered interaction tests",
|
|
80
|
+
"path": "tests/e2e/chart-legend.spec.ts"
|
|
81
|
+
}
|
|
82
|
+
]
|
|
83
|
+
},
|
|
14
84
|
"api": {
|
|
15
85
|
"props": {
|
|
16
86
|
"activeLabel": {
|
|
@@ -2,15 +2,79 @@
|
|
|
2
2
|
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
3
|
"name": "chart-line",
|
|
4
4
|
"title": "ChartLine",
|
|
5
|
-
"description": "
|
|
5
|
+
"description": "Static single- or multi-series line chart for trends across ordered, evenly spaced categories, including preformatted time-period labels.",
|
|
6
6
|
"type": "registry:ui",
|
|
7
7
|
"meta": {
|
|
8
8
|
"library": "@ds-mo/ui",
|
|
9
9
|
"distribution": "npm",
|
|
10
10
|
"storybook": "https://zainadeel.github.io/compomo/?path=/story/chart-line",
|
|
11
11
|
"source": "src/wc/components/ChartLine/ChartLine.tsx",
|
|
12
|
-
"intentStatus": "
|
|
13
|
-
"intent":
|
|
12
|
+
"intentStatus": "complete",
|
|
13
|
+
"intent": {
|
|
14
|
+
"audience": "specialized",
|
|
15
|
+
"status": "experimental",
|
|
16
|
+
"summary": "Static single- or multi-series line chart for trends across ordered, evenly spaced categories, including preformatted time-period labels.",
|
|
17
|
+
"useWhen": [
|
|
18
|
+
"Users need to follow one or more numeric trends across a shared ordered x-axis.",
|
|
19
|
+
"Time periods are already grouped into equally spaced labels such as months, weeks, or days.",
|
|
20
|
+
"A horizontal ChartLegend should identify multiple series."
|
|
21
|
+
],
|
|
22
|
+
"avoidWhen": [
|
|
23
|
+
"Pixel position must reflect irregular elapsed time or continuous timestamps.",
|
|
24
|
+
"The primary task is comparing unrelated category magnitudes rather than following a trend.",
|
|
25
|
+
"The chart needs built-in zoom, brushing, selection, or drill-down.",
|
|
26
|
+
"Series lengths do not align with the shared category list."
|
|
27
|
+
],
|
|
28
|
+
"alternatives": [
|
|
29
|
+
{
|
|
30
|
+
"when": "Users need to compare one measure across discrete categories or time buckets.",
|
|
31
|
+
"component": "component:ds-chart-bar",
|
|
32
|
+
"reason": "Bars emphasize independent bucket magnitudes."
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"when": "The data communicates parts of a total.",
|
|
36
|
+
"component": "component:ds-chart-donut",
|
|
37
|
+
"reason": "Donut provides the part-to-whole and center-summary treatment."
|
|
38
|
+
}
|
|
39
|
+
],
|
|
40
|
+
"commonlyComposedWith": [
|
|
41
|
+
"component:ds-chart-legend",
|
|
42
|
+
"component:ds-card-shell-data-viz",
|
|
43
|
+
"component:ds-tooltip-data-viz"
|
|
44
|
+
],
|
|
45
|
+
"accessibility": [
|
|
46
|
+
"Provide a visible legend or adjacent textual summary when exact series values are important; the chart image name alone is not a complete data table.",
|
|
47
|
+
"Do not rely on series color alone to communicate meaning.",
|
|
48
|
+
"A future point tooltip must supplement rather than replace accessible series and value context."
|
|
49
|
+
],
|
|
50
|
+
"states": [
|
|
51
|
+
"The chart is currently static and does not own hover, selection, loading, or empty-state policy.",
|
|
52
|
+
"Point markers may be shown or hidden without changing the underlying series meaning.",
|
|
53
|
+
"Authored series colors override the shared categorical palette."
|
|
54
|
+
],
|
|
55
|
+
"responsiveBehavior": [
|
|
56
|
+
"The owner supplies dimensions and updates them when its layout changes.",
|
|
57
|
+
"Category positions are always equally spaced, even when labels represent time.",
|
|
58
|
+
"Reduce or pre-format dense labels before passing them; the chart renders authored labels without a continuous time scale."
|
|
59
|
+
],
|
|
60
|
+
"frameworkCaveats": {
|
|
61
|
+
"customElements": [
|
|
62
|
+
"Assign series and categories as JavaScript properties and keep every series aligned to the category count."
|
|
63
|
+
],
|
|
64
|
+
"react": [
|
|
65
|
+
"Pass stable series and category arrays with dimensions derived from the containing layout."
|
|
66
|
+
],
|
|
67
|
+
"angular": [
|
|
68
|
+
"Bind series and categories as properties with dimensions derived from the containing layout."
|
|
69
|
+
]
|
|
70
|
+
},
|
|
71
|
+
"references": [
|
|
72
|
+
{
|
|
73
|
+
"label": "Storybook examples",
|
|
74
|
+
"path": "src/wc/components/ChartLine/ChartLine.stories.ts"
|
|
75
|
+
}
|
|
76
|
+
]
|
|
77
|
+
},
|
|
14
78
|
"api": {
|
|
15
79
|
"props": {
|
|
16
80
|
"categories": {
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"component:ds-button-unfilled"
|
|
26
26
|
],
|
|
27
27
|
"accessibility": [
|
|
28
|
-
"The copy action has
|
|
28
|
+
"The copy action has matching accessible-name and visible-tooltip status wording, and the code remains selectable text.",
|
|
29
29
|
"Language and filename labels supplement rather than replace the code content."
|
|
30
30
|
],
|
|
31
31
|
"responsiveBehavior": [
|
|
@@ -133,7 +133,8 @@
|
|
|
133
133
|
],
|
|
134
134
|
"registryDependencies": [
|
|
135
135
|
"button-unfilled",
|
|
136
|
-
"text"
|
|
136
|
+
"text",
|
|
137
|
+
"tooltip"
|
|
137
138
|
],
|
|
138
139
|
"files": [
|
|
139
140
|
{
|
|
@@ -143,7 +144,7 @@
|
|
|
143
144
|
},
|
|
144
145
|
{
|
|
145
146
|
"path": "src/wc/components/CodeBlock/CodeBlock.tsx",
|
|
146
|
-
"content": "import { Component, h, Host, Prop, State } from '@stencil/core';\n\n@Component({\n tag: 'ds-code-block',\n styleUrl: 'CodeBlock.css',\n scoped: true,\n})\nexport class CodeBlock {\n @Prop() code: string = '';\n @Prop() language: string = '';\n @Prop() filename: string = '';\n\n @State() private copied: boolean = false;\n private copiedTimer?: ReturnType<typeof setTimeout>;\n\n disconnectedCallback() {\n if (this.copiedTimer) clearTimeout(this.copiedTimer);\n }\n\n private copy = async () => {\n if (!navigator.clipboard || !this.code) return;\n await navigator.clipboard.writeText(this.code);\n this.copied = true;\n if (this.copiedTimer) clearTimeout(this.copiedTimer);\n this.copiedTimer = setTimeout(() => {\n this.copied = false;\n }, 2000);\n };\n\n render() {\n const label = this.filename || this.language || 'Code';\n return (\n <Host>\n <figure class=\"code-block\">\n <figcaption class=\"code-block__header\">\n <ds-text as=\"span\" variant=\"text-caption\" emphasis color=\"on-strong\">\n {label}\n </ds-text>\n <ds-button-unfilled\n
|
|
147
|
+
"content": "import { Component, h, Host, Prop, State } from '@stencil/core';\n\n@Component({\n tag: 'ds-code-block',\n styleUrl: 'CodeBlock.css',\n scoped: true,\n})\nexport class CodeBlock {\n @Prop() code: string = '';\n @Prop() language: string = '';\n @Prop() filename: string = '';\n\n @State() private copied: boolean = false;\n private copiedTimer?: ReturnType<typeof setTimeout>;\n\n disconnectedCallback() {\n if (this.copiedTimer) clearTimeout(this.copiedTimer);\n }\n\n private copy = async () => {\n if (!navigator.clipboard || !this.code) return;\n await navigator.clipboard.writeText(this.code);\n this.copied = true;\n if (this.copiedTimer) clearTimeout(this.copiedTimer);\n this.copiedTimer = setTimeout(() => {\n this.copied = false;\n }, 2000);\n };\n\n render() {\n const label = this.filename || this.language || 'Code';\n return (\n <Host>\n <figure class=\"code-block\">\n <figcaption class=\"code-block__header\">\n <ds-text as=\"span\" variant=\"text-caption\" emphasis color=\"on-strong\">\n {label}\n </ds-text>\n <ds-tooltip label={this.copied ? 'Copied' : 'Copy code'} side=\"bottom\" size=\"sm\">\n <ds-button-unfilled\n variant=\"icon\"\n icon={this.copied ? 'Check' : 'Copy'}\n size=\"xs\"\n aria-label={this.copied ? 'Copied' : 'Copy code'}\n hasBorder={false}\n onDsClick={this.copy}\n />\n </ds-tooltip>\n </figcaption>\n <pre>\n <code>{this.code}</code>\n </pre>\n </figure>\n </Host>\n );\n }\n}\n",
|
|
147
148
|
"type": "registry:ui"
|
|
148
149
|
}
|
|
149
150
|
]
|