@signalflare-ai/ui 0.5.0 → 1.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/CHANGELOG.md +117 -1
- package/ai/USAGE.md +64 -0
- package/ai/component-registry.json +492 -618
- package/ai/component-registry.md +167 -85
- package/ai/schemas.ts +545 -102
- package/bin/sf.js +2 -3
- package/dist/.build-complete +1 -1
- package/dist/ai/schemas.d.ts +1659 -5532
- package/dist/ai/schemas.d.ts.map +1 -1
- package/dist/{ai-actions-DG1dhDMP.js → ai-actions-DSVeQn4e.js} +1 -1
- package/dist/{ai-actions-DG1dhDMP.js.map → ai-actions-DSVeQn4e.js.map} +1 -1
- package/dist/{ai-agent-card-BbtL4NII.js → ai-agent-card-BXHwhWAU.js} +1 -1
- package/dist/{ai-agent-card-BbtL4NII.js.map → ai-agent-card-BXHwhWAU.js.map} +1 -1
- package/dist/{ai-approval-Mb7-BY6i.js → ai-approval-aa0qvjFN.js} +1 -1
- package/dist/{ai-approval-Mb7-BY6i.js.map → ai-approval-aa0qvjFN.js.map} +1 -1
- package/dist/{ai-code-block-BI_z0UVR.js → ai-code-block-BgtIxtZZ.js} +1 -1
- package/dist/{ai-code-block-BI_z0UVR.js.map → ai-code-block-BgtIxtZZ.js.map} +1 -1
- package/dist/{ai-conversation-DYtExcrw.js → ai-conversation-CArP7C8K.js} +1 -1
- package/dist/{ai-conversation-DYtExcrw.js.map → ai-conversation-CArP7C8K.js.map} +1 -1
- package/dist/{ai-info-banner-BpzauUAY.js → ai-info-banner-uFxHHwBA.js} +1 -1
- package/dist/{ai-info-banner-BpzauUAY.js.map → ai-info-banner-uFxHHwBA.js.map} +1 -1
- package/dist/{ai-message-CV8SBoHM.js → ai-message-BjnFznXy.js} +1 -1
- package/dist/{ai-message-CV8SBoHM.js.map → ai-message-BjnFznXy.js.map} +1 -1
- package/dist/{ai-mission-header-ByYkJ6YP.js → ai-mission-header-08__gULL.js} +1 -1
- package/dist/{ai-mission-header-ByYkJ6YP.js.map → ai-mission-header-08__gULL.js.map} +1 -1
- package/dist/ai-part-group-DBtgTgAn.js +277 -0
- package/dist/ai-part-group-DBtgTgAn.js.map +1 -0
- package/dist/ai-prompt-input-Dy1LfxPk.js +1541 -0
- package/dist/ai-prompt-input-Dy1LfxPk.js.map +1 -0
- package/dist/{ai-question-Dp1g9k2o.js → ai-question-CHHoDJMg.js} +1 -1
- package/dist/{ai-question-Dp1g9k2o.js.map → ai-question-CHHoDJMg.js.map} +1 -1
- package/dist/{ai-reasoning-UAmNx_LD.js → ai-reasoning-CnL6ZSr5.js} +84 -5
- package/dist/ai-reasoning-CnL6ZSr5.js.map +1 -0
- package/dist/{ai-response-BWoVsNQG.js → ai-response-BEUg3xvd.js} +13 -16
- package/dist/ai-response-BEUg3xvd.js.map +1 -0
- package/dist/{ai-shimmer-BpOmfonu.js → ai-shimmer-By5_L05p.js} +1 -1
- package/dist/{ai-shimmer-BpOmfonu.js.map → ai-shimmer-By5_L05p.js.map} +1 -1
- package/dist/{ai-status-badge-WhbKVeqn.js → ai-status-badge-BGYGWYF6.js} +1 -1
- package/dist/{ai-status-badge-WhbKVeqn.js.map → ai-status-badge-BGYGWYF6.js.map} +1 -1
- package/dist/{ai-streaming-text-ClL7FwvD.js → ai-streaming-text-CMfoThV0.js} +1 -1
- package/dist/{ai-streaming-text-ClL7FwvD.js.map → ai-streaming-text-CMfoThV0.js.map} +1 -1
- package/dist/{ai-subagent-BruGN1UE.js → ai-subagent-DcPRqkAA.js} +1 -1
- package/dist/{ai-subagent-BruGN1UE.js.map → ai-subagent-DcPRqkAA.js.map} +1 -1
- package/dist/{ai-suggestion-CNsCZj5P.js → ai-suggestion-MgeCg5Ar.js} +1 -1
- package/dist/{ai-suggestion-CNsCZj5P.js.map → ai-suggestion-MgeCg5Ar.js.map} +1 -1
- package/dist/{ai-task-list-B9CpMDYN.js → ai-task-list-Da9zIm00.js} +9 -12
- package/dist/ai-task-list-Da9zIm00.js.map +1 -0
- package/dist/{ai-timeline-Bb5ntsr3.js → ai-timeline-Cwu045IR.js} +1 -1
- package/dist/ai-timeline-Cwu045IR.js.map +1 -0
- package/dist/{ai-tool-BGH8nQ_D.js → ai-tool-Cn1O4xjP.js} +168 -11
- package/dist/ai-tool-Cn1O4xjP.js.map +1 -0
- package/dist/{ai-usage-bar-BI-p-JBk.js → ai-usage-bar-DjS12DMp.js} +1 -1
- package/dist/{ai-usage-bar-BI-p-JBk.js.map → ai-usage-bar-DjS12DMp.js.map} +1 -1
- package/dist/catalog.js +3 -3
- package/dist/catalog.js.map +1 -1
- package/dist/{chart-Bes4MN3C.js → chart-BK3sVPnD.js} +442 -248
- package/dist/chart-BK3sVPnD.js.map +1 -0
- package/dist/{checkbox-CPX7lBaU.js → checkbox-DYhUmZNw.js} +4 -4
- package/dist/checkbox-DYhUmZNw.js.map +1 -0
- package/dist/{clipboard-text-92YeCybc.js → clipboard-text-ssybngLw.js} +2 -2
- package/dist/{clipboard-text-92YeCybc.js.map → clipboard-text-ssybngLw.js.map} +1 -1
- package/dist/{code-DE1Yy1Cu.js → code-Cx-QSoOT.js} +2 -2
- package/dist/{code-DE1Yy1Cu.js.map → code-Cx-QSoOT.js.map} +1 -1
- package/dist/{combobox-B0bLdsX8.js → combobox-C0iW6a0r.js} +2 -2
- package/dist/{combobox-B0bLdsX8.js.map → combobox-C0iW6a0r.js.map} +1 -1
- package/dist/command-line/cli.js +22 -27
- package/dist/{command-palette-CBTY8EiF.js → command-palette-DGzioeki.js} +2 -2
- package/dist/command-palette-DGzioeki.js.map +1 -0
- package/dist/components/ai-actions.js +1 -1
- package/dist/components/ai-agent-card.js +1 -1
- package/dist/components/ai-approval.js +1 -1
- package/dist/components/ai-code-block.js +1 -1
- package/dist/components/ai-conversation.js +1 -1
- package/dist/components/ai-info-banner.js +1 -1
- package/dist/components/ai-message.js +1 -1
- package/dist/components/ai-mission-header.js +1 -1
- package/dist/components/ai-part-group.js +3 -0
- package/dist/components/ai-prompt-input.js +2 -2
- package/dist/components/ai-question.js +1 -1
- package/dist/components/ai-reasoning.js +1 -1
- package/dist/components/ai-response.js +1 -1
- package/dist/components/ai-shimmer.js +1 -1
- package/dist/components/ai-status-badge.js +1 -1
- package/dist/components/ai-streaming-text.js +1 -1
- package/dist/components/ai-subagent.js +1 -1
- package/dist/components/ai-suggestion.js +1 -1
- package/dist/components/ai-task-list.js +1 -1
- package/dist/components/ai-timeline.js +1 -1
- package/dist/components/ai-tool.js +1 -1
- package/dist/components/ai-usage-bar.js +1 -1
- package/dist/components/chart.js +3 -2
- package/dist/components/checkbox.js +1 -1
- package/dist/components/clipboard-text.js +1 -1
- package/dist/components/code.js +1 -1
- package/dist/components/combobox.js +1 -1
- package/dist/components/command-palette.js +1 -1
- package/dist/components/data-grid.js +1 -1
- package/dist/components/date-picker.js +1 -1
- package/dist/components/dropdown.js +1 -1
- package/dist/components/filters.js +1 -1
- package/dist/components/input.js +2 -2
- package/dist/components/link.js +2 -2
- package/dist/components/link.js.map +1 -1
- package/dist/components/pagination.js +1 -1
- package/dist/components/radio.js +1 -1
- package/dist/components/select.js +1 -1
- package/dist/components/sensitive-input.js +1 -1
- package/dist/components/sidebar.js +1 -1
- package/dist/components/sparkline.js +3 -0
- package/dist/components/stat-card.js +3 -0
- package/dist/components/table.js +1 -1
- package/dist/components/text-roll.js +3 -0
- package/dist/components/theme-toggle.js +1 -1
- package/dist/components/use-agent-harness.js +1 -1
- package/dist/{data-grid-UJ9ja5cu.js → data-grid-CG76N_hK.js} +6 -6
- package/dist/data-grid-CG76N_hK.js.map +1 -0
- package/dist/{date-picker-ebekkC3R.js → date-picker-Dqg9L4xu.js} +2 -2
- package/dist/{date-picker-ebekkC3R.js.map → date-picker-Dqg9L4xu.js.map} +1 -1
- package/dist/{dist-BNlyONdD.js → dist-1-gcEL2L.js} +224 -135
- package/dist/dist-1-gcEL2L.js.map +1 -0
- package/dist/{dropdown-J5T4pHaR.js → dropdown-qnEYRFXZ.js} +2 -2
- package/dist/{dropdown-J5T4pHaR.js.map → dropdown-qnEYRFXZ.js.map} +1 -1
- package/dist/echart-DURZEyai.js +314 -0
- package/dist/echart-DURZEyai.js.map +1 -0
- package/dist/{filters-BdBogf7D.js → filters-Bw_U6ZTx.js} +5 -5
- package/dist/filters-Bw_U6ZTx.js.map +1 -0
- package/dist/flow-BRsYUCJa.js.map +1 -1
- package/dist/genui.js +2 -2
- package/dist/genui.js.map +1 -1
- package/dist/index.js +45 -42
- package/dist/index.js.map +1 -1
- package/dist/{input-BxQAnXki.js → input-DXYUjGgD.js} +2 -2
- package/dist/{input-BxQAnXki.js.map → input-DXYUjGgD.js.map} +1 -1
- package/dist/{input-Cn25I4o5.js → input-DddtBN-g.js} +2 -2
- package/dist/{input-Cn25I4o5.js.map → input-DddtBN-g.js.map} +1 -1
- package/dist/layer-card-BME0eljh.js.map +1 -1
- package/dist/{pagination-C_YqCy8l.js → pagination-BVqdlONY.js} +2 -2
- package/dist/{pagination-C_YqCy8l.js.map → pagination-BVqdlONY.js.map} +1 -1
- package/dist/primitives/otp-field.js +2 -0
- package/dist/primitives.js +1 -0
- package/dist/{radio-B7zg1wUI.js → radio-BNSwOt3B.js} +3 -3
- package/dist/radio-BNSwOt3B.js.map +1 -0
- package/dist/{select-9p721G00.js → select-1w2aebGQ.js} +2 -2
- package/dist/select-1w2aebGQ.js.map +1 -0
- package/dist/{sensitive-input-D5je2NLl.js → sensitive-input-82Cez3vj.js} +2 -2
- package/dist/{sensitive-input-D5je2NLl.js.map → sensitive-input-82Cez3vj.js.map} +1 -1
- package/dist/{sidebar-DOwBrq57.js → sidebar-CAsCmSpM.js} +3 -3
- package/dist/sidebar-CAsCmSpM.js.map +1 -0
- package/dist/sparkline-DdbeM4Ai.js +108 -0
- package/dist/sparkline-DdbeM4Ai.js.map +1 -0
- package/dist/src/blocks/agent-harness/agent-harness.d.ts +30 -9
- package/dist/src/blocks/agent-harness/agent-harness.d.ts.map +1 -1
- package/dist/src/blocks/agent-harness/agent-harness.stories.tsx +114 -0
- package/dist/src/blocks/agent-harness/agent-harness.tsx +144 -63
- package/dist/src/blocks/commander/commander.stories.tsx +31 -0
- package/dist/src/blocks/dashboard-grid/dashboard-grid.d.ts +48 -0
- package/dist/src/blocks/dashboard-grid/dashboard-grid.d.ts.map +1 -0
- package/dist/src/blocks/dashboard-grid/dashboard-grid.stories.tsx +19 -0
- package/dist/src/blocks/dashboard-grid/dashboard-grid.tsx +110 -0
- package/dist/src/blocks/dashboard-grid/index.d.ts +2 -0
- package/dist/src/blocks/dashboard-grid/index.d.ts.map +1 -0
- package/dist/src/blocks/delete-resource/delete-resource.stories.tsx +31 -0
- package/dist/src/blocks/map-block/map-block.stories.tsx +41 -0
- package/dist/src/blocks/metrics-overview/index.d.ts +2 -0
- package/dist/src/blocks/metrics-overview/index.d.ts.map +1 -0
- package/dist/src/blocks/metrics-overview/metrics-overview.d.ts +67 -0
- package/dist/src/blocks/metrics-overview/metrics-overview.d.ts.map +1 -0
- package/dist/src/blocks/metrics-overview/metrics-overview.stories.tsx +26 -0
- package/dist/src/blocks/metrics-overview/metrics-overview.tsx +139 -0
- package/dist/src/blocks/page-header/page-header.stories.tsx +56 -0
- package/dist/src/blocks/resource-list/resource-list.stories.tsx +31 -0
- package/dist/src/catalog/catalog.d.ts +1 -1
- package/dist/src/catalog/index.d.ts +1 -1
- package/dist/src/catalog/types.d.ts +1 -1
- package/dist/src/command-line/build-cli.d.ts +1 -1
- package/dist/src/command-line/cli.d.ts +1 -1
- package/dist/src/command-line/commands/add.d.ts +1 -1
- package/dist/src/command-line/commands/add.d.ts.map +1 -1
- package/dist/src/command-line/commands/ai.d.ts.map +1 -1
- package/dist/src/command-line/commands/blocks.d.ts +1 -1
- package/dist/src/command-line/commands/blocks.d.ts.map +1 -1
- package/dist/src/command-line/commands/doc.d.ts +1 -1
- package/dist/src/command-line/commands/doc.d.ts.map +1 -1
- package/dist/src/command-line/commands/ls.d.ts +1 -1
- package/dist/src/command-line/commands/ls.d.ts.map +1 -1
- package/dist/src/command-line/commands/migrate.d.ts +3 -3
- package/dist/src/command-line/commands/migrate.d.ts.map +1 -1
- package/dist/src/command-line/utils/config.d.ts +1 -1
- package/dist/src/command-line/utils/transformer.d.ts +1 -1
- package/dist/src/components/ai-part-group/ai-part-group.d.ts +134 -0
- package/dist/src/components/ai-part-group/ai-part-group.d.ts.map +1 -0
- package/dist/src/components/ai-part-group/index.d.ts +2 -0
- package/dist/src/components/ai-part-group/index.d.ts.map +1 -0
- package/dist/src/components/ai-prompt-input/ai-prompt-input.d.ts +196 -7
- package/dist/src/components/ai-prompt-input/ai-prompt-input.d.ts.map +1 -1
- package/dist/src/components/ai-prompt-input/controller.d.ts +41 -0
- package/dist/src/components/ai-prompt-input/controller.d.ts.map +1 -0
- package/dist/src/components/ai-prompt-input/index.d.ts +3 -1
- package/dist/src/components/ai-prompt-input/index.d.ts.map +1 -1
- package/dist/src/components/ai-prompt-input/types.d.ts +86 -0
- package/dist/src/components/ai-prompt-input/types.d.ts.map +1 -0
- package/dist/src/components/ai-reasoning/ai-reasoning.d.ts +17 -1
- package/dist/src/components/ai-reasoning/ai-reasoning.d.ts.map +1 -1
- package/dist/src/components/ai-response/ai-response.d.ts +1 -2
- package/dist/src/components/ai-response/ai-response.d.ts.map +1 -1
- package/dist/src/components/ai-task-list/ai-task-list.d.ts.map +1 -1
- package/dist/src/components/ai-tool/ai-tool.d.ts +17 -1
- package/dist/src/components/ai-tool/ai-tool.d.ts.map +1 -1
- package/dist/src/components/chart/area-chart.d.ts +69 -0
- package/dist/src/components/chart/area-chart.d.ts.map +1 -0
- package/dist/src/components/chart/bar-chart.d.ts +60 -0
- package/dist/src/components/chart/bar-chart.d.ts.map +1 -0
- package/dist/src/components/chart/color.d.ts +56 -0
- package/dist/src/components/chart/color.d.ts.map +1 -1
- package/dist/src/components/chart/echart.d.ts.map +1 -1
- package/dist/src/components/chart/index.d.ts +5 -0
- package/dist/src/components/chart/index.d.ts.map +1 -1
- package/dist/src/components/chart/pie-chart.d.ts +64 -0
- package/dist/src/components/chart/pie-chart.d.ts.map +1 -0
- package/dist/src/components/chart/scatter-chart.d.ts +57 -0
- package/dist/src/components/chart/scatter-chart.d.ts.map +1 -0
- package/dist/src/components/chart/stacked-bar-chart.d.ts +59 -0
- package/dist/src/components/chart/stacked-bar-chart.d.ts.map +1 -0
- package/dist/src/components/chart/timeseries-chart.d.ts.map +1 -1
- package/dist/src/components/code/code.d.ts +1 -1
- package/dist/src/components/command-palette/command-palette.d.ts +1 -1
- package/dist/src/components/data-grid/data-grid.d.ts.map +1 -1
- package/dist/src/components/data-grid/index.d.ts +1 -1
- package/dist/src/components/data-grid/index.d.ts.map +1 -1
- package/dist/src/components/data-grid/types.d.ts.map +1 -1
- package/dist/src/components/date-picker/date-picker.d.ts +2 -2
- package/dist/src/components/filters/filters.d.ts.map +1 -1
- package/dist/src/components/filters/helpers.d.ts.map +1 -1
- package/dist/src/components/filters/types.d.ts.map +1 -1
- package/dist/src/components/layer-card/layer-card.d.ts +1 -1
- package/dist/src/components/link/link.d.ts +2 -2
- package/dist/src/components/radio/radio.d.ts +1 -1
- package/dist/src/components/select/select.d.ts +1 -1
- package/dist/src/components/sidebar/sidebar.d.ts +2 -2
- package/dist/src/components/sparkline/index.d.ts +2 -0
- package/dist/src/components/sparkline/index.d.ts.map +1 -0
- package/dist/src/components/sparkline/sparkline.d.ts +52 -0
- package/dist/src/components/sparkline/sparkline.d.ts.map +1 -0
- package/dist/src/components/stat-card/index.d.ts +2 -0
- package/dist/src/components/{ai-loader → stat-card}/index.d.ts.map +1 -1
- package/dist/src/components/stat-card/stat-card.d.ts +80 -0
- package/dist/src/components/stat-card/stat-card.d.ts.map +1 -0
- package/dist/src/components/text-roll/index.d.ts +2 -0
- package/dist/src/components/text-roll/index.d.ts.map +1 -0
- package/dist/src/components/text-roll/text-roll.d.ts +49 -0
- package/dist/src/components/text-roll/text-roll.d.ts.map +1 -0
- package/dist/src/components/toast/toast.d.ts.map +1 -1
- package/dist/src/components/use-agent-harness/use-agent-harness.d.ts +2 -2
- package/dist/src/genui/genui.d.ts.map +1 -1
- package/dist/src/index.d.ts +5 -2
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/primitives/index.d.ts +1 -0
- package/dist/src/primitives/index.d.ts.map +1 -1
- package/dist/src/primitives/otp-field.d.ts +13 -0
- package/dist/src/primitives/otp-field.d.ts.map +1 -0
- package/dist/src/registry/index.d.ts +1 -1
- package/dist/src/registry/types.d.ts +1 -1
- package/dist/stat-card-CEZscNh8.js +103 -0
- package/dist/stat-card-CEZscNh8.js.map +1 -0
- package/dist/styles/sf-binding.css +20 -62
- package/dist/styles/sf-standalone.css +2 -2
- package/dist/styles/shadcn.css +120 -0
- package/dist/styles/theme-blue-tint.css +98 -0
- package/dist/styles/theme-fedramp.css +3 -12
- package/dist/styles/theme-minimal.css +26 -104
- package/dist/styles/theme-sf.css +96 -114
- package/dist/{table-CIMx0Oq0.js → table-Rv4JMy0B.js} +2 -2
- package/dist/{table-CIMx0Oq0.js.map → table-Rv4JMy0B.js.map} +1 -1
- package/dist/text-roll-BZ3I1umc.js +79 -0
- package/dist/text-roll-BZ3I1umc.js.map +1 -0
- package/dist/{theme-toggle-Dpgnoj_Q.js → theme-toggle-Bhu681D7.js} +1 -1
- package/dist/{theme-toggle-Dpgnoj_Q.js.map → theme-toggle-Bhu681D7.js.map} +1 -1
- package/dist/{use-agent-harness-DZzcn96L.js → use-agent-harness-BMyF8pTq.js} +5 -5
- package/dist/use-agent-harness-BMyF8pTq.js.map +1 -0
- package/package.json +48 -19
- package/scripts/component-registry/discovery.ts +2 -2
- package/scripts/component-registry/index.ts +1 -1
- package/scripts/component-registry/props-filter.ts +1 -1
- package/scripts/component-registry/utils.ts +5 -5
- package/scripts/component-registry/variant-parser.ts +124 -19
- package/scripts/convert-demos-to-stories.ts +253 -0
- package/scripts/css-build.ts +4 -3
- package/scripts/generate-primitives.ts +11 -3
- package/scripts/theme-generator/config.ts +339 -71
- package/scripts/theme-generator/generate-css.ts +17 -3
- package/scripts/theme-generator/index.ts +3 -3
- package/scripts/theme-generator/migrate.ts +1 -1
- package/dist/ai-loader-Cr3eQkNS.js +0 -134
- package/dist/ai-loader-Cr3eQkNS.js.map +0 -1
- package/dist/ai-prompt-input-Bo1YuJly.js +0 -769
- package/dist/ai-prompt-input-Bo1YuJly.js.map +0 -1
- package/dist/ai-reasoning-UAmNx_LD.js.map +0 -1
- package/dist/ai-response-BWoVsNQG.js.map +0 -1
- package/dist/ai-task-list-B9CpMDYN.js.map +0 -1
- package/dist/ai-timeline-Bb5ntsr3.js.map +0 -1
- package/dist/ai-tool-BGH8nQ_D.js.map +0 -1
- package/dist/chart-Bes4MN3C.js.map +0 -1
- package/dist/checkbox-CPX7lBaU.js.map +0 -1
- package/dist/command-palette-CBTY8EiF.js.map +0 -1
- package/dist/components/ai-loader.js +0 -3
- package/dist/data-grid-UJ9ja5cu.js.map +0 -1
- package/dist/dist-BNlyONdD.js.map +0 -1
- package/dist/filters-BdBogf7D.js.map +0 -1
- package/dist/radio-B7zg1wUI.js.map +0 -1
- package/dist/select-9p721G00.js.map +0 -1
- package/dist/sidebar-DOwBrq57.js.map +0 -1
- package/dist/src/components/ai-loader/ai-loader.d.ts +0 -44
- package/dist/src/components/ai-loader/ai-loader.d.ts.map +0 -1
- package/dist/src/components/ai-loader/index.d.ts +0 -2
- package/dist/styles/theme-navigator.css +0 -137
- package/dist/use-agent-harness-DZzcn96L.js.map +0 -1
|
@@ -1,249 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { t as cn } from "./cn-YROP2_ox.js";
|
|
3
|
-
import {
|
|
3
|
+
import { i as ChartPalette, n as CHART_DARK_COLORS, r as CHART_LIGHT_COLORS, t as Chart } from "./echart-DURZEyai.js";
|
|
4
|
+
import { useEffect, useMemo, useRef } from "react";
|
|
4
5
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
-
//#region src/components/chart/color.ts
|
|
6
|
-
/**
|
|
7
|
-
* Categorical colors for light mode — used when assigning colors to data series
|
|
8
|
-
* by index (e.g. the first series gets Blue, the second gets Violet, etc.).
|
|
9
|
-
*/
|
|
10
|
-
var ChartCategoricalLightColors = /* @__PURE__ */ function(ChartCategoricalLightColors) {
|
|
11
|
-
ChartCategoricalLightColors["Blue"] = "#086FFF";
|
|
12
|
-
ChartCategoricalLightColors["Violet"] = "#CF7EE9";
|
|
13
|
-
ChartCategoricalLightColors["Cyan"] = "#73CEE6";
|
|
14
|
-
ChartCategoricalLightColors["Indigo"] = "#5B5FEF";
|
|
15
|
-
ChartCategoricalLightColors["LightBlue"] = "#82B6FF";
|
|
16
|
-
ChartCategoricalLightColors["Pink"] = "#F5609F";
|
|
17
|
-
ChartCategoricalLightColors["Indigo3"] = "#C2BDF3";
|
|
18
|
-
ChartCategoricalLightColors["Violet2"] = "#8D1EB1";
|
|
19
|
-
ChartCategoricalLightColors["Violet3"] = "#EBCAF6";
|
|
20
|
-
ChartCategoricalLightColors["Indigo2"] = "#7366E4";
|
|
21
|
-
return ChartCategoricalLightColors;
|
|
22
|
-
}(ChartCategoricalLightColors || {});
|
|
23
|
-
/**
|
|
24
|
-
* Categorical colors for dark mode — same hues as the light palette but with
|
|
25
|
-
* `E6` alpha (90% opacity) appended to soften contrast on dark backgrounds.
|
|
26
|
-
*/
|
|
27
|
-
var ChartCategoricalDarkColors = /* @__PURE__ */ function(ChartCategoricalDarkColors) {
|
|
28
|
-
ChartCategoricalDarkColors["Blue"] = "#086FFFE6";
|
|
29
|
-
ChartCategoricalDarkColors["Violet"] = "#CF7EE9E6";
|
|
30
|
-
ChartCategoricalDarkColors["Cyan"] = "#73CEE6E6";
|
|
31
|
-
ChartCategoricalDarkColors["Indigo"] = "#5B5FEFE6";
|
|
32
|
-
ChartCategoricalDarkColors["LightBlue"] = "#82B6FFE6";
|
|
33
|
-
ChartCategoricalDarkColors["Pink"] = "#F5609FE6";
|
|
34
|
-
ChartCategoricalDarkColors["Indigo3"] = "#C2BDF3E6";
|
|
35
|
-
ChartCategoricalDarkColors["Violet2"] = "#8D1EB1E6";
|
|
36
|
-
ChartCategoricalDarkColors["Violet3"] = "#EBCAF6E6";
|
|
37
|
-
ChartCategoricalDarkColors["Indigo2"] = "#7366E4E6";
|
|
38
|
-
return ChartCategoricalDarkColors;
|
|
39
|
-
}(ChartCategoricalDarkColors || {});
|
|
40
|
-
/**
|
|
41
|
-
* Semantic colors for light mode — used to convey meaning (status, severity)
|
|
42
|
-
* rather than just distinguishing series. Use via `ChartPalette.semantic()`.
|
|
43
|
-
*/
|
|
44
|
-
var ChartSemanticLightColors = /* @__PURE__ */ function(ChartSemanticLightColors) {
|
|
45
|
-
ChartSemanticLightColors["Attention"] = "#FC574A";
|
|
46
|
-
ChartSemanticLightColors["Warning"] = "#F8A054";
|
|
47
|
-
ChartSemanticLightColors["Neutral"] = "#82B6FF";
|
|
48
|
-
ChartSemanticLightColors["NeutralLight"] = "#B9D6FF";
|
|
49
|
-
ChartSemanticLightColors["Disabled"] = "#B6B6B6";
|
|
50
|
-
ChartSemanticLightColors["DisabledLight"] = "#D9D9D9";
|
|
51
|
-
return ChartSemanticLightColors;
|
|
52
|
-
}(ChartSemanticLightColors || {});
|
|
53
|
-
/**
|
|
54
|
-
* Semantic colors for dark mode — same meanings as the light palette but with
|
|
55
|
-
* `E6` alpha (90% opacity) for dark backgrounds.
|
|
56
|
-
*/
|
|
57
|
-
var ChartSemanticDarkColors = /* @__PURE__ */ function(ChartSemanticDarkColors) {
|
|
58
|
-
ChartSemanticDarkColors["Attention"] = "#FC574AE6";
|
|
59
|
-
ChartSemanticDarkColors["Warning"] = "#F8A054E6";
|
|
60
|
-
ChartSemanticDarkColors["Neutral"] = "#82B6FFE6";
|
|
61
|
-
ChartSemanticDarkColors["NeutralLight"] = "#B9D6FFE6";
|
|
62
|
-
ChartSemanticDarkColors["Disabled"] = "#B6B6B6E6";
|
|
63
|
-
ChartSemanticDarkColors["DisabledLight"] = "#D9D9D9E6";
|
|
64
|
-
return ChartSemanticDarkColors;
|
|
65
|
-
}(ChartSemanticDarkColors || {});
|
|
66
|
-
/**
|
|
67
|
-
* Ordered list of categorical colors for light mode, indexed by series position.
|
|
68
|
-
* Used as the default ECharts color palette when `isDarkMode` is `false`.
|
|
69
|
-
*/
|
|
70
|
-
var CHART_LIGHT_COLORS = [
|
|
71
|
-
ChartCategoricalLightColors.Blue,
|
|
72
|
-
ChartCategoricalLightColors.Violet,
|
|
73
|
-
ChartCategoricalLightColors.Cyan,
|
|
74
|
-
ChartCategoricalLightColors.Indigo,
|
|
75
|
-
ChartCategoricalLightColors.LightBlue,
|
|
76
|
-
ChartCategoricalLightColors.Pink,
|
|
77
|
-
ChartCategoricalLightColors.Indigo3,
|
|
78
|
-
ChartCategoricalLightColors.Violet2,
|
|
79
|
-
ChartCategoricalLightColors.Violet3,
|
|
80
|
-
ChartCategoricalLightColors.Indigo2
|
|
81
|
-
];
|
|
82
|
-
/**
|
|
83
|
-
* Ordered list of categorical colors for dark mode, indexed by series position.
|
|
84
|
-
* Used as the default ECharts color palette when `isDarkMode` is `true`.
|
|
85
|
-
*/
|
|
86
|
-
var CHART_DARK_COLORS = [
|
|
87
|
-
ChartCategoricalDarkColors.Blue,
|
|
88
|
-
ChartCategoricalDarkColors.Violet,
|
|
89
|
-
ChartCategoricalDarkColors.Cyan,
|
|
90
|
-
ChartCategoricalDarkColors.Indigo,
|
|
91
|
-
ChartCategoricalDarkColors.LightBlue,
|
|
92
|
-
ChartCategoricalDarkColors.Pink,
|
|
93
|
-
ChartCategoricalDarkColors.Indigo3,
|
|
94
|
-
ChartCategoricalDarkColors.Violet2,
|
|
95
|
-
ChartCategoricalDarkColors.Violet3,
|
|
96
|
-
ChartCategoricalDarkColors.Indigo2
|
|
97
|
-
];
|
|
98
|
-
/**
|
|
99
|
-
* Returns the hex color for a named semantic value (status, severity, etc.).
|
|
100
|
-
*
|
|
101
|
-
* @example
|
|
102
|
-
* ```ts
|
|
103
|
-
* ChartPalette.semantic("Attention") // "#FC574A" (light)
|
|
104
|
-
* ChartPalette.semantic("Warning", true) // "#F8A054E6" (dark)
|
|
105
|
-
* ```
|
|
106
|
-
*/
|
|
107
|
-
function semantic(name, isDarkMode = false) {
|
|
108
|
-
return isDarkMode ? ChartSemanticDarkColors[name] : ChartSemanticLightColors[name];
|
|
109
|
-
}
|
|
110
|
-
/**
|
|
111
|
-
* Returns the categorical color for a given series index.
|
|
112
|
-
* Wraps around via modulo when `index` exceeds the palette length (10 colors).
|
|
113
|
-
*
|
|
114
|
-
* @example
|
|
115
|
-
* ```ts
|
|
116
|
-
* ChartPalette.color(0) // Blue (light)
|
|
117
|
-
* ChartPalette.color(0, true) // Blue with E6 alpha (dark)
|
|
118
|
-
* ChartPalette.color(10) // wraps back to Blue
|
|
119
|
-
* ```
|
|
120
|
-
*/
|
|
121
|
-
function color(index, isDarkMode = false) {
|
|
122
|
-
return isDarkMode ? CHART_DARK_COLORS[index % CHART_DARK_COLORS.length] : CHART_LIGHT_COLORS[index % CHART_LIGHT_COLORS.length];
|
|
123
|
-
}
|
|
124
|
-
/**
|
|
125
|
-
* Utilities for resolving SignalFlare chart colors by semantic name or series index.
|
|
126
|
-
* Both functions accept an `isDarkMode` flag and return the appropriate hex color.
|
|
127
|
-
*/
|
|
128
|
-
var ChartPalette = {
|
|
129
|
-
semantic,
|
|
130
|
-
color
|
|
131
|
-
};
|
|
132
|
-
//#endregion
|
|
133
|
-
//#region src/components/chart/echart.tsx
|
|
134
|
-
/**
|
|
135
|
-
* Chart — a low-level wrapper around [Apache ECharts](https://echarts.apache.org).
|
|
136
|
-
*
|
|
137
|
-
* Manages the ECharts instance lifecycle (init, option updates, event binding,
|
|
138
|
-
* resize observation, and disposal). Exposes the raw `echarts.ECharts` instance
|
|
139
|
-
* via `ref` for imperative access when needed.
|
|
140
|
-
*
|
|
141
|
-
* Prefer `TimeseriesChart` for time-series data; use this component when you
|
|
142
|
-
* need full control over the ECharts option object.
|
|
143
|
-
*
|
|
144
|
-
* @example
|
|
145
|
-
* ```tsx
|
|
146
|
-
* import * as echarts from "echarts/core";
|
|
147
|
-
* import { BarChart } from "echarts/charts";
|
|
148
|
-
* import { GridComponent } from "echarts/components";
|
|
149
|
-
* import { CanvasRenderer } from "echarts/renderers";
|
|
150
|
-
*
|
|
151
|
-
* echarts.use([BarChart, GridComponent, CanvasRenderer]);
|
|
152
|
-
*
|
|
153
|
-
* <Chart
|
|
154
|
-
* echarts={echarts}
|
|
155
|
-
* options={{ xAxis: { data: ["A", "B"] }, yAxis: {}, series: [{ type: "bar", data: [1, 2] }] }}
|
|
156
|
-
* />
|
|
157
|
-
* ```
|
|
158
|
-
*/
|
|
159
|
-
var Chart = forwardRef(function Chart({ echarts, options, optionUpdateBehavior, className, isDarkMode, height = 350, onEvents }, ref) {
|
|
160
|
-
const elRef = useRef(null);
|
|
161
|
-
const chartRef = useRef(null);
|
|
162
|
-
const handlersRef = useRef({});
|
|
163
|
-
const wrappersRef = useRef({});
|
|
164
|
-
const boundEventsRef = useRef(/* @__PURE__ */ new Set());
|
|
165
|
-
useEffect(() => {
|
|
166
|
-
if (!elRef.current) return;
|
|
167
|
-
const chart = echarts.init(elRef.current, isDarkMode ? "dark" : { color: isDarkMode ? CHART_DARK_COLORS : CHART_LIGHT_COLORS });
|
|
168
|
-
chartRef.current = chart;
|
|
169
|
-
if (typeof ref === "function") ref(chart);
|
|
170
|
-
else if (ref) ref.current = chart;
|
|
171
|
-
return () => {
|
|
172
|
-
for (const event of boundEventsRef.current) {
|
|
173
|
-
const wrapper = wrappersRef.current[event];
|
|
174
|
-
if (wrapper) chart.off(event, wrapper);
|
|
175
|
-
}
|
|
176
|
-
boundEventsRef.current.clear();
|
|
177
|
-
if (typeof ref === "function") ref(null);
|
|
178
|
-
else if (ref) ref.current = null;
|
|
179
|
-
chartRef.current = null;
|
|
180
|
-
chart.dispose();
|
|
181
|
-
};
|
|
182
|
-
}, [elRef, isDarkMode]);
|
|
183
|
-
useEffect(() => {
|
|
184
|
-
const chart = chartRef.current;
|
|
185
|
-
if (!chart) return;
|
|
186
|
-
chart.setOption(options, {
|
|
187
|
-
notMerge: false,
|
|
188
|
-
lazyUpdate: true,
|
|
189
|
-
...optionUpdateBehavior
|
|
190
|
-
});
|
|
191
|
-
}, [
|
|
192
|
-
isDarkMode,
|
|
193
|
-
optionUpdateBehavior,
|
|
194
|
-
options
|
|
195
|
-
]);
|
|
196
|
-
useEffect(() => {
|
|
197
|
-
handlersRef.current = onEvents ?? {};
|
|
198
|
-
}, [onEvents]);
|
|
199
|
-
useEffect(() => {
|
|
200
|
-
const chart = chartRef.current;
|
|
201
|
-
if (!chart) return;
|
|
202
|
-
const nextBound = /* @__PURE__ */ new Set();
|
|
203
|
-
for (const [event, handler] of Object.entries(onEvents ?? {})) {
|
|
204
|
-
if (typeof handler !== "function") continue;
|
|
205
|
-
nextBound.add(event);
|
|
206
|
-
if (!wrappersRef.current[event]) wrappersRef.current[event] = (params) => {
|
|
207
|
-
handlersRef.current[event]?.(params);
|
|
208
|
-
};
|
|
209
|
-
if (!boundEventsRef.current.has(event)) chart.on(event, wrappersRef.current[event]);
|
|
210
|
-
}
|
|
211
|
-
for (const event of boundEventsRef.current) {
|
|
212
|
-
if (nextBound.has(event)) continue;
|
|
213
|
-
const wrapper = wrappersRef.current[event];
|
|
214
|
-
if (wrapper) chart.off(event, wrapper);
|
|
215
|
-
}
|
|
216
|
-
boundEventsRef.current = nextBound;
|
|
217
|
-
}, [
|
|
218
|
-
echarts,
|
|
219
|
-
isDarkMode,
|
|
220
|
-
onEvents
|
|
221
|
-
]);
|
|
222
|
-
useEffect(() => {
|
|
223
|
-
const chart = chartRef.current;
|
|
224
|
-
const el = elRef.current;
|
|
225
|
-
if (!chart || !el) return;
|
|
226
|
-
let isInitial = true;
|
|
227
|
-
const ro = new ResizeObserver(() => {
|
|
228
|
-
if (isInitial) {
|
|
229
|
-
isInitial = false;
|
|
230
|
-
return;
|
|
231
|
-
}
|
|
232
|
-
chart.resize();
|
|
233
|
-
});
|
|
234
|
-
ro.observe(el);
|
|
235
|
-
return () => ro.disconnect();
|
|
236
|
-
}, []);
|
|
237
|
-
return /* @__PURE__ */ jsx("div", {
|
|
238
|
-
ref: elRef,
|
|
239
|
-
className: cn("w-full", className),
|
|
240
|
-
style: { height },
|
|
241
|
-
tabIndex: options.aria?.enabled ? 0 : void 0,
|
|
242
|
-
role: options.aria?.enabled ? "img" : void 0
|
|
243
|
-
});
|
|
244
|
-
});
|
|
245
|
-
Chart.displayName = "Chart";
|
|
246
|
-
//#endregion
|
|
247
6
|
//#region src/components/chart/timeseries-chart.tsx
|
|
248
7
|
/**
|
|
249
8
|
* TimeseriesChart — a time-series line or bar chart.
|
|
@@ -368,7 +127,14 @@ function TimeseriesChart({ echarts, type = "line", data, xAxisName, xAxisTickCou
|
|
|
368
127
|
nameLocation: "middle",
|
|
369
128
|
nameGap: 30,
|
|
370
129
|
type: "time",
|
|
371
|
-
splitLine: {
|
|
130
|
+
splitLine: {
|
|
131
|
+
show: true,
|
|
132
|
+
lineStyle: {
|
|
133
|
+
color: ChartPalette.axisLine(isDarkMode),
|
|
134
|
+
type: "dashed",
|
|
135
|
+
width: 1
|
|
136
|
+
}
|
|
137
|
+
},
|
|
372
138
|
axisLine: { show: false },
|
|
373
139
|
splitNumber: xAxisTickCount ?? 5,
|
|
374
140
|
...xAxisTickFormat && { axisLabel: { formatter: (value) => xAxisTickFormat(value) } }
|
|
@@ -378,7 +144,8 @@ function TimeseriesChart({ echarts, type = "line", data, xAxisName, xAxisTickCou
|
|
|
378
144
|
nameLocation: "middle",
|
|
379
145
|
nameGap: 40,
|
|
380
146
|
type: "value",
|
|
381
|
-
|
|
147
|
+
axisLine: { show: false },
|
|
148
|
+
axisTick: { show: false },
|
|
382
149
|
axisLabel: {
|
|
383
150
|
margin: 15,
|
|
384
151
|
...yAxisTickFormat && { formatter: (value) => yAxisTickFormat(value) }
|
|
@@ -386,6 +153,7 @@ function TimeseriesChart({ echarts, type = "line", data, xAxisName, xAxisTickCou
|
|
|
386
153
|
splitLine: {
|
|
387
154
|
show: true,
|
|
388
155
|
lineStyle: {
|
|
156
|
+
color: ChartPalette.axisLine(isDarkMode),
|
|
389
157
|
type: "dashed",
|
|
390
158
|
width: 1
|
|
391
159
|
}
|
|
@@ -523,7 +291,7 @@ function ChartWaveLoader({ height, isDarkMode }) {
|
|
|
523
291
|
*/
|
|
524
292
|
function colorWithOpacity(color, alpha) {
|
|
525
293
|
const a = Math.max(0, Math.min(1, alpha));
|
|
526
|
-
const rgbMatch =
|
|
294
|
+
const rgbMatch = /rgba?\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)/i.exec(color);
|
|
527
295
|
if (rgbMatch) return `rgba(${rgbMatch[1]}, ${rgbMatch[2]}, ${rgbMatch[3]}, ${a})`;
|
|
528
296
|
let hex = color.replace(/^#/, "");
|
|
529
297
|
if (hex.length === 3) hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2];
|
|
@@ -613,6 +381,432 @@ var ChartLegend = {
|
|
|
613
381
|
LargeItem
|
|
614
382
|
};
|
|
615
383
|
//#endregion
|
|
616
|
-
|
|
384
|
+
//#region src/components/chart/bar-chart.tsx
|
|
385
|
+
/**
|
|
386
|
+
* BarChart — categorical bar chart for comparing discrete values.
|
|
387
|
+
*
|
|
388
|
+
* Consumer must register `BarChart`, `GridComponent`, `TooltipComponent`, and a
|
|
389
|
+
* renderer (e.g. `CanvasRenderer`) on the passed-in `echarts` instance.
|
|
390
|
+
*
|
|
391
|
+
* @example
|
|
392
|
+
* ```tsx
|
|
393
|
+
* <BarChart
|
|
394
|
+
* echarts={echarts}
|
|
395
|
+
* data={[
|
|
396
|
+
* { name: "Mon", value: 120 },
|
|
397
|
+
* { name: "Tue", value: 200 },
|
|
398
|
+
* { name: "Wed", value: 150 },
|
|
399
|
+
* ]}
|
|
400
|
+
* />
|
|
401
|
+
* ```
|
|
402
|
+
*/
|
|
403
|
+
function BarChart({ echarts, data, orientation = "vertical", height = 320, yAxisTickFormat, tooltipValueFormat, isDarkMode, loading, onBarClick, className }) {
|
|
404
|
+
const options = useMemo(() => {
|
|
405
|
+
const palette = isDarkMode ? CHART_DARK_COLORS : CHART_LIGHT_COLORS;
|
|
406
|
+
const axis = ChartPalette.axisDefaults(isDarkMode);
|
|
407
|
+
const categoryAxis = {
|
|
408
|
+
...axis,
|
|
409
|
+
type: "category",
|
|
410
|
+
data: data.map((d) => d.name)
|
|
411
|
+
};
|
|
412
|
+
const valueAxis = {
|
|
413
|
+
...axis,
|
|
414
|
+
type: "value",
|
|
415
|
+
axisLabel: yAxisTickFormat ? { formatter: (v) => yAxisTickFormat(v) } : void 0
|
|
416
|
+
};
|
|
417
|
+
return {
|
|
418
|
+
grid: {
|
|
419
|
+
left: 40,
|
|
420
|
+
right: 16,
|
|
421
|
+
top: 24,
|
|
422
|
+
bottom: 32,
|
|
423
|
+
containLabel: true
|
|
424
|
+
},
|
|
425
|
+
tooltip: {
|
|
426
|
+
trigger: "axis",
|
|
427
|
+
axisPointer: { type: "shadow" },
|
|
428
|
+
valueFormatter: tooltipValueFormat ? (value) => typeof value === "number" ? tooltipValueFormat(value) : String(value) : void 0
|
|
429
|
+
},
|
|
430
|
+
xAxis: orientation === "vertical" ? categoryAxis : valueAxis,
|
|
431
|
+
yAxis: orientation === "vertical" ? valueAxis : categoryAxis,
|
|
432
|
+
series: [{
|
|
433
|
+
type: "bar",
|
|
434
|
+
data: data.map((d, i) => ({
|
|
435
|
+
value: d.value,
|
|
436
|
+
itemStyle: { color: d.color ?? palette[i % palette.length] }
|
|
437
|
+
}))
|
|
438
|
+
}]
|
|
439
|
+
};
|
|
440
|
+
}, [
|
|
441
|
+
data,
|
|
442
|
+
orientation,
|
|
443
|
+
yAxisTickFormat,
|
|
444
|
+
tooltipValueFormat,
|
|
445
|
+
isDarkMode
|
|
446
|
+
]);
|
|
447
|
+
const onEvents = useMemo(() => onBarClick ? { click: (params) => {
|
|
448
|
+
if (params.name) onBarClick(params.name);
|
|
449
|
+
} } : void 0, [onBarClick]);
|
|
450
|
+
if (loading) return /* @__PURE__ */ jsx("div", {
|
|
451
|
+
"aria-busy": "true",
|
|
452
|
+
className,
|
|
453
|
+
style: { height },
|
|
454
|
+
"data-sf-skeleton": "",
|
|
455
|
+
children: /* @__PURE__ */ jsx("div", { className: "h-full w-full animate-pulse rounded-md bg-sf-fill" })
|
|
456
|
+
});
|
|
457
|
+
return /* @__PURE__ */ jsx(Chart, {
|
|
458
|
+
echarts,
|
|
459
|
+
options,
|
|
460
|
+
height,
|
|
461
|
+
isDarkMode,
|
|
462
|
+
className,
|
|
463
|
+
onEvents
|
|
464
|
+
});
|
|
465
|
+
}
|
|
466
|
+
//#endregion
|
|
467
|
+
//#region src/components/chart/stacked-bar-chart.tsx
|
|
468
|
+
/**
|
|
469
|
+
* StackedBarChart — stacked categorical bar chart for part-to-whole comparisons.
|
|
470
|
+
*
|
|
471
|
+
* @example
|
|
472
|
+
* ```tsx
|
|
473
|
+
* <StackedBarChart
|
|
474
|
+
* echarts={echarts}
|
|
475
|
+
* categories={["Mon", "Tue", "Wed"]}
|
|
476
|
+
* series={[
|
|
477
|
+
* { name: "Desktop", data: [100, 120, 90] },
|
|
478
|
+
* { name: "Mobile", data: [60, 80, 110] },
|
|
479
|
+
* ]}
|
|
480
|
+
* />
|
|
481
|
+
* ```
|
|
482
|
+
*/
|
|
483
|
+
function StackedBarChart({ echarts, categories, series, orientation = "vertical", percent = false, height = 320, yAxisTickFormat, tooltipValueFormat, isDarkMode, loading, className }) {
|
|
484
|
+
const options = useMemo(() => {
|
|
485
|
+
const palette = isDarkMode ? CHART_DARK_COLORS : CHART_LIGHT_COLORS;
|
|
486
|
+
const resolvedSeries = percent ? series.map((s) => ({
|
|
487
|
+
...s,
|
|
488
|
+
data: s.data.map((v, i) => {
|
|
489
|
+
const total = series.reduce((acc, other) => acc + (other.data[i] ?? 0), 0);
|
|
490
|
+
return total === 0 ? 0 : v / total * 100;
|
|
491
|
+
})
|
|
492
|
+
})) : series;
|
|
493
|
+
const axis = ChartPalette.axisDefaults(isDarkMode);
|
|
494
|
+
const categoryAxis = {
|
|
495
|
+
...axis,
|
|
496
|
+
type: "category",
|
|
497
|
+
data: categories
|
|
498
|
+
};
|
|
499
|
+
const valueAxis = {
|
|
500
|
+
...axis,
|
|
501
|
+
type: "value",
|
|
502
|
+
max: percent ? 100 : void 0,
|
|
503
|
+
axisLabel: yAxisTickFormat ? { formatter: (v) => yAxisTickFormat(v) } : percent ? { formatter: "{value}%" } : void 0
|
|
504
|
+
};
|
|
505
|
+
return {
|
|
506
|
+
legend: { bottom: 0 },
|
|
507
|
+
grid: {
|
|
508
|
+
left: 40,
|
|
509
|
+
right: 16,
|
|
510
|
+
top: 24,
|
|
511
|
+
bottom: 48,
|
|
512
|
+
containLabel: true
|
|
513
|
+
},
|
|
514
|
+
tooltip: {
|
|
515
|
+
trigger: "axis",
|
|
516
|
+
axisPointer: { type: "shadow" },
|
|
517
|
+
valueFormatter: tooltipValueFormat ? (value) => typeof value === "number" ? tooltipValueFormat(value) : String(value) : void 0
|
|
518
|
+
},
|
|
519
|
+
xAxis: orientation === "vertical" ? categoryAxis : valueAxis,
|
|
520
|
+
yAxis: orientation === "vertical" ? valueAxis : categoryAxis,
|
|
521
|
+
series: resolvedSeries.map((s, i) => ({
|
|
522
|
+
name: s.name,
|
|
523
|
+
type: "bar",
|
|
524
|
+
stack: "total",
|
|
525
|
+
data: s.data,
|
|
526
|
+
itemStyle: { color: s.color ?? palette[i % palette.length] }
|
|
527
|
+
}))
|
|
528
|
+
};
|
|
529
|
+
}, [
|
|
530
|
+
categories,
|
|
531
|
+
series,
|
|
532
|
+
orientation,
|
|
533
|
+
percent,
|
|
534
|
+
yAxisTickFormat,
|
|
535
|
+
tooltipValueFormat,
|
|
536
|
+
isDarkMode
|
|
537
|
+
]);
|
|
538
|
+
if (loading) return /* @__PURE__ */ jsx("div", {
|
|
539
|
+
"aria-busy": "true",
|
|
540
|
+
className,
|
|
541
|
+
style: { height },
|
|
542
|
+
children: /* @__PURE__ */ jsx("div", { className: "h-full w-full animate-pulse rounded-md bg-sf-fill" })
|
|
543
|
+
});
|
|
544
|
+
return /* @__PURE__ */ jsx(Chart, {
|
|
545
|
+
echarts,
|
|
546
|
+
options,
|
|
547
|
+
height,
|
|
548
|
+
isDarkMode,
|
|
549
|
+
className
|
|
550
|
+
});
|
|
551
|
+
}
|
|
552
|
+
//#endregion
|
|
553
|
+
//#region src/components/chart/pie-chart.tsx
|
|
554
|
+
/**
|
|
555
|
+
* PieChart — single-series pie or donut chart for part-to-whole relationships.
|
|
556
|
+
*
|
|
557
|
+
* @example
|
|
558
|
+
* ```tsx
|
|
559
|
+
* <PieChart
|
|
560
|
+
* echarts={echarts}
|
|
561
|
+
* variant="donut"
|
|
562
|
+
* data={[
|
|
563
|
+
* { name: "Prod", value: 60 },
|
|
564
|
+
* { name: "Staging", value: 30 },
|
|
565
|
+
* { name: "Dev", value: 10 },
|
|
566
|
+
* ]}
|
|
567
|
+
* centerSlot={<span className="text-sf-strong">100</span>}
|
|
568
|
+
* />
|
|
569
|
+
* ```
|
|
570
|
+
*/
|
|
571
|
+
function PieChart({ echarts, data, variant = "pie", height = 320, showLegend, tooltipValueFormat, isDarkMode, loading, centerSlot, className }) {
|
|
572
|
+
const options = useMemo(() => {
|
|
573
|
+
const palette = isDarkMode ? CHART_DARK_COLORS : CHART_LIGHT_COLORS;
|
|
574
|
+
return {
|
|
575
|
+
legend: showLegend ? { bottom: 0 } : void 0,
|
|
576
|
+
tooltip: {
|
|
577
|
+
trigger: "item",
|
|
578
|
+
valueFormatter: tooltipValueFormat ? (value) => typeof value === "number" ? tooltipValueFormat(value) : String(value) : void 0
|
|
579
|
+
},
|
|
580
|
+
series: [{
|
|
581
|
+
type: "pie",
|
|
582
|
+
radius: variant === "donut" ? ["55%", "80%"] : "75%",
|
|
583
|
+
avoidLabelOverlap: true,
|
|
584
|
+
label: {
|
|
585
|
+
show: variant !== "donut",
|
|
586
|
+
color: isDarkMode ? "#e5e5e5" : "#1a1a1a",
|
|
587
|
+
textBorderWidth: 0,
|
|
588
|
+
textBorderColor: "transparent"
|
|
589
|
+
},
|
|
590
|
+
labelLine: {
|
|
591
|
+
show: variant !== "donut",
|
|
592
|
+
lineStyle: { color: isDarkMode ? "#e5e5e5" : "#1a1a1a" }
|
|
593
|
+
},
|
|
594
|
+
data: data.map((d, i) => ({
|
|
595
|
+
name: d.name,
|
|
596
|
+
value: d.value,
|
|
597
|
+
itemStyle: { color: d.color ?? palette[i % palette.length] }
|
|
598
|
+
}))
|
|
599
|
+
}]
|
|
600
|
+
};
|
|
601
|
+
}, [
|
|
602
|
+
data,
|
|
603
|
+
variant,
|
|
604
|
+
showLegend,
|
|
605
|
+
tooltipValueFormat,
|
|
606
|
+
isDarkMode
|
|
607
|
+
]);
|
|
608
|
+
if (loading) return /* @__PURE__ */ jsx("div", {
|
|
609
|
+
"aria-busy": "true",
|
|
610
|
+
className,
|
|
611
|
+
style: { height },
|
|
612
|
+
children: /* @__PURE__ */ jsx("div", { className: "h-full w-full animate-pulse rounded-full bg-sf-fill" })
|
|
613
|
+
});
|
|
614
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
615
|
+
className: cn("relative", className),
|
|
616
|
+
style: { height },
|
|
617
|
+
children: [/* @__PURE__ */ jsx(Chart, {
|
|
618
|
+
echarts,
|
|
619
|
+
options,
|
|
620
|
+
height,
|
|
621
|
+
isDarkMode
|
|
622
|
+
}), centerSlot !== void 0 && variant === "donut" ? /* @__PURE__ */ jsx("div", {
|
|
623
|
+
className: "pointer-events-none absolute inset-0 flex items-center justify-center",
|
|
624
|
+
children: centerSlot
|
|
625
|
+
}) : null]
|
|
626
|
+
});
|
|
627
|
+
}
|
|
628
|
+
//#endregion
|
|
629
|
+
//#region src/components/chart/area-chart.tsx
|
|
630
|
+
/**
|
|
631
|
+
* AreaChart — filled line chart with gradient fill, suitable for trend
|
|
632
|
+
* visualisations on either a time or category x-axis.
|
|
633
|
+
*
|
|
634
|
+
* Unlike `TimeseriesChart`, this component also accepts a category x-axis,
|
|
635
|
+
* making it useful for cohort or bucketed trend displays.
|
|
636
|
+
*
|
|
637
|
+
* @example
|
|
638
|
+
* ```tsx
|
|
639
|
+
* <AreaChart
|
|
640
|
+
* echarts={echarts}
|
|
641
|
+
* xAxisType="category"
|
|
642
|
+
* categories={["W1", "W2", "W3", "W4"]}
|
|
643
|
+
* series={[{ name: "Signups", data: [120, 180, 240, 200] }]}
|
|
644
|
+
* />
|
|
645
|
+
* ```
|
|
646
|
+
*/
|
|
647
|
+
function AreaChart({ echarts, series, xAxisType = "time", categories, height = 320, xAxisName, yAxisName, yAxisTickFormat, tooltipValueFormat, isDarkMode, stacked, loading, className }) {
|
|
648
|
+
const options = useMemo(() => {
|
|
649
|
+
const palette = isDarkMode ? CHART_DARK_COLORS : CHART_LIGHT_COLORS;
|
|
650
|
+
return {
|
|
651
|
+
grid: {
|
|
652
|
+
left: 40,
|
|
653
|
+
right: 16,
|
|
654
|
+
top: 24,
|
|
655
|
+
bottom: 32,
|
|
656
|
+
containLabel: true
|
|
657
|
+
},
|
|
658
|
+
legend: series.length > 1 ? { bottom: 0 } : void 0,
|
|
659
|
+
tooltip: {
|
|
660
|
+
trigger: "axis",
|
|
661
|
+
valueFormatter: tooltipValueFormat ? (value) => typeof value === "number" ? tooltipValueFormat(value) : String(value) : void 0
|
|
662
|
+
},
|
|
663
|
+
xAxis: xAxisType === "category" ? {
|
|
664
|
+
...ChartPalette.axisDefaults(isDarkMode),
|
|
665
|
+
type: "category",
|
|
666
|
+
name: xAxisName,
|
|
667
|
+
data: categories,
|
|
668
|
+
boundaryGap: false
|
|
669
|
+
} : {
|
|
670
|
+
...ChartPalette.axisDefaults(isDarkMode),
|
|
671
|
+
type: "time",
|
|
672
|
+
name: xAxisName
|
|
673
|
+
},
|
|
674
|
+
yAxis: {
|
|
675
|
+
...ChartPalette.axisDefaults(isDarkMode),
|
|
676
|
+
type: "value",
|
|
677
|
+
name: yAxisName,
|
|
678
|
+
axisLabel: yAxisTickFormat ? { formatter: (v) => yAxisTickFormat(v) } : void 0
|
|
679
|
+
},
|
|
680
|
+
series: series.map((s, i) => {
|
|
681
|
+
const color = s.color ?? palette[i % palette.length];
|
|
682
|
+
return {
|
|
683
|
+
name: s.name,
|
|
684
|
+
type: "line",
|
|
685
|
+
smooth: true,
|
|
686
|
+
showSymbol: false,
|
|
687
|
+
stack: stacked ? "total" : void 0,
|
|
688
|
+
data: s.data,
|
|
689
|
+
itemStyle: { color },
|
|
690
|
+
lineStyle: { color },
|
|
691
|
+
areaStyle: {
|
|
692
|
+
color: {
|
|
693
|
+
type: "linear",
|
|
694
|
+
x: 0,
|
|
695
|
+
y: 0,
|
|
696
|
+
x2: 0,
|
|
697
|
+
y2: 1,
|
|
698
|
+
colorStops: [{
|
|
699
|
+
offset: 0,
|
|
700
|
+
color
|
|
701
|
+
}, {
|
|
702
|
+
offset: 1,
|
|
703
|
+
color: "rgba(0,0,0,0)"
|
|
704
|
+
}]
|
|
705
|
+
},
|
|
706
|
+
opacity: .4
|
|
707
|
+
}
|
|
708
|
+
};
|
|
709
|
+
})
|
|
710
|
+
};
|
|
711
|
+
}, [
|
|
712
|
+
series,
|
|
713
|
+
xAxisType,
|
|
714
|
+
categories,
|
|
715
|
+
xAxisName,
|
|
716
|
+
yAxisName,
|
|
717
|
+
yAxisTickFormat,
|
|
718
|
+
tooltipValueFormat,
|
|
719
|
+
stacked,
|
|
720
|
+
isDarkMode
|
|
721
|
+
]);
|
|
722
|
+
if (loading) return /* @__PURE__ */ jsx("div", {
|
|
723
|
+
"aria-busy": "true",
|
|
724
|
+
className,
|
|
725
|
+
style: { height },
|
|
726
|
+
children: /* @__PURE__ */ jsx("div", { className: "h-full w-full animate-pulse rounded-md bg-sf-fill" })
|
|
727
|
+
});
|
|
728
|
+
return /* @__PURE__ */ jsx(Chart, {
|
|
729
|
+
echarts,
|
|
730
|
+
options,
|
|
731
|
+
height,
|
|
732
|
+
isDarkMode,
|
|
733
|
+
className
|
|
734
|
+
});
|
|
735
|
+
}
|
|
736
|
+
//#endregion
|
|
737
|
+
//#region src/components/chart/scatter-chart.tsx
|
|
738
|
+
/**
|
|
739
|
+
* ScatterChart — multi-series scatter/point cloud for correlation visualisations.
|
|
740
|
+
*
|
|
741
|
+
* @example
|
|
742
|
+
* ```tsx
|
|
743
|
+
* <ScatterChart
|
|
744
|
+
* echarts={echarts}
|
|
745
|
+
* series={[
|
|
746
|
+
* { name: "Group A", data: [[1, 2], [2, 3], [3, 4]] },
|
|
747
|
+
* { name: "Group B", data: [[1.5, 4], [2.5, 5]] },
|
|
748
|
+
* ]}
|
|
749
|
+
* xAxisName="Cost"
|
|
750
|
+
* yAxisName="Value"
|
|
751
|
+
* />
|
|
752
|
+
* ```
|
|
753
|
+
*/
|
|
754
|
+
function ScatterChart({ echarts, series, height = 320, xAxisName, yAxisName, xAxisTickFormat, yAxisTickFormat, isDarkMode, loading, className }) {
|
|
755
|
+
const options = useMemo(() => {
|
|
756
|
+
const palette = isDarkMode ? CHART_DARK_COLORS : CHART_LIGHT_COLORS;
|
|
757
|
+
return {
|
|
758
|
+
grid: {
|
|
759
|
+
left: 40,
|
|
760
|
+
right: 16,
|
|
761
|
+
top: 24,
|
|
762
|
+
bottom: 40,
|
|
763
|
+
containLabel: true
|
|
764
|
+
},
|
|
765
|
+
legend: series.length > 1 ? { bottom: 0 } : void 0,
|
|
766
|
+
tooltip: { trigger: "item" },
|
|
767
|
+
xAxis: {
|
|
768
|
+
...ChartPalette.axisDefaults(isDarkMode),
|
|
769
|
+
type: "value",
|
|
770
|
+
name: xAxisName,
|
|
771
|
+
axisLabel: xAxisTickFormat ? { formatter: (v) => xAxisTickFormat(v) } : void 0
|
|
772
|
+
},
|
|
773
|
+
yAxis: {
|
|
774
|
+
...ChartPalette.axisDefaults(isDarkMode),
|
|
775
|
+
type: "value",
|
|
776
|
+
name: yAxisName,
|
|
777
|
+
axisLabel: yAxisTickFormat ? { formatter: (v) => yAxisTickFormat(v) } : void 0
|
|
778
|
+
},
|
|
779
|
+
series: series.map((s, i) => ({
|
|
780
|
+
name: s.name,
|
|
781
|
+
type: "scatter",
|
|
782
|
+
data: s.data,
|
|
783
|
+
symbolSize: s.symbolSize ?? 8,
|
|
784
|
+
itemStyle: { color: s.color ?? palette[i % palette.length] }
|
|
785
|
+
}))
|
|
786
|
+
};
|
|
787
|
+
}, [
|
|
788
|
+
series,
|
|
789
|
+
xAxisName,
|
|
790
|
+
yAxisName,
|
|
791
|
+
xAxisTickFormat,
|
|
792
|
+
yAxisTickFormat,
|
|
793
|
+
isDarkMode
|
|
794
|
+
]);
|
|
795
|
+
if (loading) return /* @__PURE__ */ jsx("div", {
|
|
796
|
+
"aria-busy": "true",
|
|
797
|
+
className,
|
|
798
|
+
style: { height },
|
|
799
|
+
children: /* @__PURE__ */ jsx("div", { className: "h-full w-full animate-pulse rounded-md bg-sf-fill" })
|
|
800
|
+
});
|
|
801
|
+
return /* @__PURE__ */ jsx(Chart, {
|
|
802
|
+
echarts,
|
|
803
|
+
options,
|
|
804
|
+
height,
|
|
805
|
+
isDarkMode,
|
|
806
|
+
className
|
|
807
|
+
});
|
|
808
|
+
}
|
|
809
|
+
//#endregion
|
|
810
|
+
export { BarChart as a, StackedBarChart as i, AreaChart as n, ChartLegend as o, PieChart as r, TimeseriesChart as s, ScatterChart as t };
|
|
617
811
|
|
|
618
|
-
//# sourceMappingURL=chart-
|
|
812
|
+
//# sourceMappingURL=chart-BK3sVPnD.js.map
|