@rosettadash/react 0.1.1 → 0.1.3
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/package.json +87 -2
- package/src/domain/i18n/app-language-select/AppLanguageSelect.d.ts +17 -0
- package/src/domain/i18n/app-language-select/AppLanguageSelect.js +24 -0
- package/src/domain/i18n/app-language-select/AppLanguageSelect.js.map +1 -0
- package/src/domain/i18n/app-language-select/index.d.ts +2 -0
- package/src/domain/i18n/app-language-select/index.js +2 -0
- package/src/domain/i18n/app-language-select/index.js.map +1 -0
- package/src/domain/role-gate/RoleGate.d.ts +3 -0
- package/src/domain/role-gate/RoleGate.js +22 -4
- package/src/domain/role-gate/RoleGate.js.map +1 -1
- package/src/index.d.ts +15 -0
- package/src/index.js +15 -0
- package/src/index.js.map +1 -1
- package/src/infra/env/EnvConfig.d.ts +5 -0
- package/src/infra/env/EnvConfig.js +17 -2
- package/src/infra/env/EnvConfig.js.map +1 -1
- package/src/infra/env/index.d.ts +1 -1
- package/src/layout/collapsible/Collapsible.d.ts +1 -0
- package/src/layout/collapsible/Collapsible.js +16 -5
- package/src/layout/collapsible/Collapsible.js.map +1 -1
- package/src/layout/filter-grid/FilterGrid.d.ts +26 -0
- package/src/layout/filter-grid/FilterGrid.js +21 -0
- package/src/layout/filter-grid/FilterGrid.js.map +1 -0
- package/src/layout/filter-grid/index.d.ts +2 -0
- package/src/layout/filter-grid/index.js +2 -0
- package/src/layout/filter-grid/index.js.map +1 -0
- package/src/layout/flex/FlexLayout.d.ts +3 -0
- package/src/layout/flex/FlexLayout.js +24 -4
- package/src/layout/flex/FlexLayout.js.map +1 -1
- package/src/layout/form-section/FormSectionGrid.d.ts +21 -0
- package/src/layout/form-section/FormSectionGrid.js +16 -0
- package/src/layout/form-section/FormSectionGrid.js.map +1 -0
- package/src/layout/form-section/index.d.ts +2 -0
- package/src/layout/form-section/index.js +2 -0
- package/src/layout/form-section/index.js.map +1 -0
- package/src/layout/geo-explorer/GeoExplorerLayout.d.ts +18 -0
- package/src/layout/geo-explorer/GeoExplorerLayout.js +14 -0
- package/src/layout/geo-explorer/GeoExplorerLayout.js.map +1 -0
- package/src/layout/geo-explorer/index.d.ts +2 -0
- package/src/layout/geo-explorer/index.js +2 -0
- package/src/layout/geo-explorer/index.js.map +1 -0
- package/src/layout/scroll-region/ScrollRegion.d.ts +13 -0
- package/src/layout/scroll-region/ScrollRegion.js +15 -0
- package/src/layout/scroll-region/ScrollRegion.js.map +1 -0
- package/src/layout/scroll-region/index.d.ts +2 -0
- package/src/layout/scroll-region/index.js +2 -0
- package/src/layout/scroll-region/index.js.map +1 -0
- package/src/layout/tabs/TabsLayout.d.ts +1 -0
- package/src/layout/tabs/TabsLayout.js +7 -2
- package/src/layout/tabs/TabsLayout.js.map +1 -1
- package/src/lib/custom-element-host.js +2 -2
- package/src/lib/custom-element-host.js.map +1 -1
- package/src/visual/chart/bar/BarChart.d.ts +7 -0
- package/src/visual/chart/bar/BarChart.js +32 -2
- package/src/visual/chart/bar/BarChart.js.map +1 -1
- package/src/visual/chart/bar/index.d.ts +1 -1
- package/src/visual/chart/line/LineChart.d.ts +8 -0
- package/src/visual/chart/line/LineChart.js +58 -2
- package/src/visual/chart/line/LineChart.js.map +1 -1
- package/src/visual/chart/line/index.d.ts +1 -1
- package/src/visual/chart/sankey/JourneySankeyChart.d.ts +20 -0
- package/src/visual/chart/sankey/JourneySankeyChart.js +105 -0
- package/src/visual/chart/sankey/JourneySankeyChart.js.map +1 -0
- package/src/visual/chart/sankey/index.d.ts +2 -0
- package/src/visual/chart/sankey/index.js +2 -0
- package/src/visual/chart/sankey/index.js.map +1 -0
- package/src/visual/chart/venn/VennOverlapChart.d.ts +22 -0
- package/src/visual/chart/venn/VennOverlapChart.js +24 -0
- package/src/visual/chart/venn/VennOverlapChart.js.map +1 -0
- package/src/visual/chart/venn/index.d.ts +2 -0
- package/src/visual/chart/venn/index.js +2 -0
- package/src/visual/chart/venn/index.js.map +1 -0
- package/src/visual/destination/destination-select-list/DestinationSelectList.d.ts +16 -0
- package/src/visual/destination/destination-select-list/DestinationSelectList.js +39 -0
- package/src/visual/destination/destination-select-list/DestinationSelectList.js.map +1 -0
- package/src/visual/destination/destination-select-list/index.d.ts +2 -0
- package/src/visual/destination/destination-select-list/index.js +2 -0
- package/src/visual/destination/destination-select-list/index.js.map +1 -0
- package/src/visual/detail/DetailHistoricList.d.ts +14 -0
- package/src/visual/detail/DetailHistoricList.js +10 -0
- package/src/visual/detail/DetailHistoricList.js.map +1 -0
- package/src/visual/detail/DetailPanel.js +1 -1
- package/src/visual/detail/DetailPanel.js.map +1 -1
- package/src/visual/detail/DetailStats.d.ts +13 -0
- package/src/visual/detail/DetailStats.js +10 -0
- package/src/visual/detail/DetailStats.js.map +1 -0
- package/src/visual/detail/index.d.ts +4 -0
- package/src/visual/detail/index.js +2 -0
- package/src/visual/detail/index.js.map +1 -1
- package/src/visual/display/3d-geo-globe/ThreeGeoGlobe.d.ts +12 -2
- package/src/visual/display/3d-geo-globe/ThreeGeoGlobe.js +241 -7
- package/src/visual/display/3d-geo-globe/ThreeGeoGlobe.js.map +1 -1
- package/src/visual/display/3d-scatter/ThreeScatterPlot.d.ts +15 -2
- package/src/visual/display/3d-scatter/ThreeScatterPlot.js +152 -7
- package/src/visual/display/3d-scatter/ThreeScatterPlot.js.map +1 -1
- package/src/visual/display/3d-scatter/index.d.ts +1 -1
- package/src/visual/display/equirect-globe/EquirectGlobe.d.ts +21 -0
- package/src/visual/display/equirect-globe/EquirectGlobe.js +28 -0
- package/src/visual/display/equirect-globe/EquirectGlobe.js.map +1 -0
- package/src/visual/display/equirect-globe/index.d.ts +2 -0
- package/src/visual/display/equirect-globe/index.js +2 -0
- package/src/visual/display/equirect-globe/index.js.map +1 -0
- package/src/visual/display/geo-map/GeoMap.d.ts +22 -0
- package/src/visual/display/geo-map/GeoMap.js +29 -0
- package/src/visual/display/geo-map/GeoMap.js.map +1 -0
- package/src/visual/display/geo-map/index.d.ts +2 -0
- package/src/visual/display/geo-map/index.js +2 -0
- package/src/visual/display/geo-map/index.js.map +1 -0
- package/src/visual/filter/filter-summary/FilterSummary.d.ts +16 -0
- package/src/visual/filter/filter-summary/FilterSummary.js +9 -0
- package/src/visual/filter/filter-summary/FilterSummary.js.map +1 -0
- package/src/visual/filter/filter-summary/index.d.ts +2 -0
- package/src/visual/filter/filter-summary/index.js +2 -0
- package/src/visual/filter/filter-summary/index.js.map +1 -0
- package/src/visual/input/date-range/DateRangeFilter.d.ts +4 -0
- package/src/visual/input/date-range/DateRangeFilter.js +3 -1
- package/src/visual/input/date-range/DateRangeFilter.js.map +1 -1
- package/src/visual/input/number/NumberInput.d.ts +1 -0
- package/src/visual/input/number/NumberInput.js +1 -1
- package/src/visual/input/number/NumberInput.js.map +1 -1
- package/src/visual/input/text/TextInput.d.ts +1 -0
- package/src/visual/input/text/TextInput.js +2 -1
- package/src/visual/input/text/TextInput.js.map +1 -1
- package/src/visual/link-list/LinkList.d.ts +3 -0
- package/src/visual/link-list/LinkList.js +3 -2
- package/src/visual/link-list/LinkList.js.map +1 -1
- package/src/visual/media/carousel/SlideCarousel.d.ts +19 -0
- package/src/visual/media/carousel/SlideCarousel.js +39 -0
- package/src/visual/media/carousel/SlideCarousel.js.map +1 -0
- package/src/visual/media/carousel/index.d.ts +2 -0
- package/src/visual/media/carousel/index.js +2 -0
- package/src/visual/media/carousel/index.js.map +1 -0
- package/src/visual/media/equirect-sphere-viewport/EquirectSphereViewport.d.ts +45 -0
- package/src/visual/media/equirect-sphere-viewport/EquirectSphereViewport.js +527 -0
- package/src/visual/media/equirect-sphere-viewport/EquirectSphereViewport.js.map +1 -0
- package/src/visual/media/equirect-sphere-viewport/index.d.ts +2 -0
- package/src/visual/media/equirect-sphere-viewport/index.js +2 -0
- package/src/visual/media/equirect-sphere-viewport/index.js.map +1 -0
- package/src/visual/media/equirect-sphere-viewport/planet-shader.d.ts +6 -0
- package/src/visual/media/equirect-sphere-viewport/planet-shader.js +69 -0
- package/src/visual/media/equirect-sphere-viewport/planet-shader.js.map +1 -0
- package/src/visual/media/flat-video-viewport/FlatVideoViewport.d.ts +32 -0
- package/src/visual/media/flat-video-viewport/FlatVideoViewport.js +317 -0
- package/src/visual/media/flat-video-viewport/FlatVideoViewport.js.map +1 -0
- package/src/visual/media/flat-video-viewport/index.d.ts +2 -0
- package/src/visual/media/flat-video-viewport/index.js +2 -0
- package/src/visual/media/flat-video-viewport/index.js.map +1 -0
- package/src/visual/media/video-metadata/VideoMetadataPanel.d.ts +13 -0
- package/src/visual/media/video-metadata/VideoMetadataPanel.js +8 -0
- package/src/visual/media/video-metadata/VideoMetadataPanel.js.map +1 -0
- package/src/visual/media/video-metadata/index.d.ts +2 -0
- package/src/visual/media/video-metadata/index.js +2 -0
- package/src/visual/media/video-metadata/index.js.map +1 -0
- package/src/visual/media/video-source/VideoSource.d.ts +2 -0
- package/src/visual/media/video-source/VideoSource.js +6 -2
- package/src/visual/media/video-source/VideoSource.js.map +1 -1
- package/src/visual/media/youtube-embed/YoutubeEmbed.d.ts +14 -0
- package/src/visual/media/youtube-embed/YoutubeEmbed.js +21 -0
- package/src/visual/media/youtube-embed/YoutubeEmbed.js.map +1 -0
- package/src/visual/media/youtube-embed/index.d.ts +2 -0
- package/src/visual/media/youtube-embed/index.js +2 -0
- package/src/visual/media/youtube-embed/index.js.map +1 -0
- package/src/visual/news/article-detail/NewsArticleDetail.js +2 -2
- package/src/visual/news/article-detail/NewsArticleDetail.js.map +1 -1
- package/src/visual/news/results-table/NewsResultsTable.d.ts +14 -0
- package/src/visual/news/results-table/NewsResultsTable.js +30 -3
- package/src/visual/news/results-table/NewsResultsTable.js.map +1 -1
- package/src/visual/news/results-table/index.d.ts +1 -1
- package/src/visual/plugin/metric-chip/MetricChip.js +1 -1
- package/src/visual/plugin/metric-chip/MetricChip.js.map +1 -1
- package/src/visual/table/DataTable.d.ts +11 -1
- package/src/visual/table/DataTable.js +31 -2
- package/src/visual/table/DataTable.js.map +1 -1
- package/src/visual/table/index.d.ts +1 -1
- package/src/visual/wasm/media/WasmMedia.d.ts +6 -0
- package/src/visual/wasm/media/WasmMedia.js +9 -3
- package/src/visual/wasm/media/WasmMedia.js.map +1 -1
|
@@ -1,10 +1,30 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef } from 'react';
|
|
2
|
+
import { Children, cloneElement, forwardRef, isValidElement } from 'react';
|
|
3
3
|
/** @rosettadash/react/layout/flex — layout.flex */
|
|
4
4
|
export const FlexLayout = forwardRef(function FlexLayout(props, ref) {
|
|
5
5
|
var _a, _b;
|
|
6
|
-
const { className, style, children } = props;
|
|
7
|
-
const rootClass = ['rd-flex',
|
|
8
|
-
|
|
6
|
+
const { className, style, children, itemFlex, stretchItems } = props;
|
|
7
|
+
const rootClass = ['rd-flex', stretchItems ? 'rd-flex--stretch-items' : '', className]
|
|
8
|
+
.filter(Boolean)
|
|
9
|
+
.join(' ');
|
|
10
|
+
const childArray = Children.toArray(children);
|
|
11
|
+
const wrappedChildren = childArray.map((child, index) => {
|
|
12
|
+
var _a;
|
|
13
|
+
if (!isValidElement(child)) {
|
|
14
|
+
return child;
|
|
15
|
+
}
|
|
16
|
+
const grow = itemFlex === null || itemFlex === void 0 ? void 0 : itemFlex[index];
|
|
17
|
+
const itemStyle = grow !== undefined
|
|
18
|
+
? { '--rd-flex-grow': String(grow) }
|
|
19
|
+
: undefined;
|
|
20
|
+
const itemClass = grow !== undefined ? 'rd-flex__item rd-flex__item--grow' : 'rd-flex__item';
|
|
21
|
+
return cloneElement(child, {
|
|
22
|
+
className: [itemClass, child.props.className]
|
|
23
|
+
.filter(Boolean)
|
|
24
|
+
.join(' '),
|
|
25
|
+
style: Object.assign(Object.assign({}, ((_a = child.props.style) !== null && _a !== void 0 ? _a : {})), itemStyle),
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
return (_jsxs("section", { ref: ref, className: rootClass, style: style, "data-testid": "rd-flex", children: [props.title ? _jsx("span", { className: "rd-flex__title", children: props.title }) : null, _jsx("div", { className: "rd-flex__flex", style: { flexDirection: (_a = props.direction) !== null && _a !== void 0 ? _a : 'row', gap: (_b = props.gap) !== null && _b !== void 0 ? _b : 12 }, children: wrappedChildren })] }));
|
|
9
29
|
});
|
|
10
30
|
//# sourceMappingURL=FlexLayout.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FlexLayout.js","sourceRoot":"","sources":["../../../../../../packages/react/src/layout/flex/FlexLayout.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,
|
|
1
|
+
{"version":3,"file":"FlexLayout.js","sourceRoot":"","sources":["../../../../../../packages/react/src/layout/flex/FlexLayout.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,UAAU,EAAE,cAAc,EAAyD,MAAM,OAAO,CAAC;AAclI,mDAAmD;AACnD,MAAM,CAAC,MAAM,UAAU,GAAG,UAAU,CAA+B,SAAS,UAAU,CACpF,KAAK,EACL,GAAG;;IAEH,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,YAAY,EAAE,GAAG,KAAK,CAAC;IACrE,MAAM,SAAS,GAAG,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC,CAAC,wBAAwB,CAAC,CAAC,CAAC,EAAE,EAAE,SAAS,CAAC;SACnF,MAAM,CAAC,OAAO,CAAC;SACf,IAAI,CAAC,GAAG,CAAC,CAAC;IAEb,MAAM,UAAU,GAAG,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC9C,MAAM,eAAe,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE;;QACtD,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE,CAAC;YAC3B,OAAO,KAAK,CAAC;QACf,CAAC;QACD,MAAM,IAAI,GAAG,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAG,KAAK,CAAC,CAAC;QAC/B,MAAM,SAAS,GACb,IAAI,KAAK,SAAS;YAChB,CAAC,CAAE,EAAE,gBAAgB,EAAE,MAAM,CAAC,IAAI,CAAC,EAAoB;YACvD,CAAC,CAAC,SAAS,CAAC;QAChB,MAAM,SAAS,GAAG,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,mCAAmC,CAAC,CAAC,CAAC,eAAe,CAAC;QAC7F,OAAO,YAAY,CAAC,KAAoE,EAAE;YACxF,SAAS,EAAE,CAAC,SAAS,EAAG,KAA8C,CAAC,KAAK,CAAC,SAAS,CAAC;iBACpF,MAAM,CAAC,OAAO,CAAC;iBACf,IAAI,CAAC,GAAG,CAAC;YACZ,KAAK,kCAAO,CAAC,MAAC,KAAiD,CAAC,KAAK,CAAC,KAAK,mCAAI,EAAE,CAAC,GAAK,SAAS,CAAE;SACnG,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,OAAO,CACL,mBAAS,GAAG,EAAE,GAAmC,EAAE,SAAS,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,iBAAc,SAAS,aACzG,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,eAAM,SAAS,EAAC,gBAAgB,YAAE,KAAK,CAAC,KAAK,GAAQ,CAAC,CAAC,CAAC,IAAI,EAC3E,cAAK,SAAS,EAAC,eAAe,EAAC,KAAK,EAAE,EAAE,aAAa,EAAE,MAAA,KAAK,CAAC,SAAS,mCAAI,KAAK,EAAE,GAAG,EAAE,MAAA,KAAK,CAAC,GAAG,mCAAI,EAAE,EAAE,YACpG,eAAe,GACZ,IACE,CACX,CAAC;AACJ,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type CSSProperties, type ReactNode } from 'react';
|
|
2
|
+
export interface FormSectionGridProps {
|
|
3
|
+
className?: string;
|
|
4
|
+
style?: CSSProperties;
|
|
5
|
+
children?: ReactNode;
|
|
6
|
+
}
|
|
7
|
+
export interface FormSectionProps {
|
|
8
|
+
title: string;
|
|
9
|
+
fullWidth?: boolean;
|
|
10
|
+
columns?: 1 | 2;
|
|
11
|
+
className?: string;
|
|
12
|
+
style?: CSSProperties;
|
|
13
|
+
children?: ReactNode;
|
|
14
|
+
}
|
|
15
|
+
declare function FormSectionGridRoot({ className, style, children }: FormSectionGridProps): import("react").JSX.Element;
|
|
16
|
+
declare function FormSection({ title, fullWidth, columns, className, style, children }: FormSectionProps): import("react").JSX.Element;
|
|
17
|
+
/** @rosettadash/react/layout/form-section — layout.form-section */
|
|
18
|
+
export declare const FormSectionGrid: typeof FormSectionGridRoot & {
|
|
19
|
+
Section: typeof FormSection;
|
|
20
|
+
};
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
function FormSectionGridRoot({ className, style, children }) {
|
|
3
|
+
return (_jsx("div", { className: ['rd-form-section-grid', className].filter(Boolean).join(' '), style: style, "data-testid": "rd-form-section-grid", children: children }));
|
|
4
|
+
}
|
|
5
|
+
function FormSection({ title, fullWidth, columns = 1, className, style, children }) {
|
|
6
|
+
const sectionClass = ['rd-form-section', fullWidth ? 'rd-form-section--full' : '', className]
|
|
7
|
+
.filter(Boolean)
|
|
8
|
+
.join(' ');
|
|
9
|
+
const bodyClass = ['rd-form-section__body', columns === 2 ? 'rd-form-section__body--2col' : '']
|
|
10
|
+
.filter(Boolean)
|
|
11
|
+
.join(' ');
|
|
12
|
+
return (_jsxs("section", { className: sectionClass, style: style, "data-testid": "rd-form-section", children: [_jsx("h3", { className: "rd-form-section__title", children: title }), _jsx("div", { className: bodyClass, children: children })] }));
|
|
13
|
+
}
|
|
14
|
+
/** @rosettadash/react/layout/form-section — layout.form-section */
|
|
15
|
+
export const FormSectionGrid = Object.assign(FormSectionGridRoot, { Section: FormSection });
|
|
16
|
+
//# sourceMappingURL=FormSectionGrid.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FormSectionGrid.js","sourceRoot":"","sources":["../../../../../../packages/react/src/layout/form-section/FormSectionGrid.tsx"],"names":[],"mappings":";AAiBA,SAAS,mBAAmB,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAwB;IAC/E,OAAO,CACL,cAAK,SAAS,EAAE,CAAC,sBAAsB,EAAE,SAAS,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,KAAK,iBAAc,sBAAsB,YAC5H,QAAQ,GACL,CACP,CAAC;AACJ,CAAC;AAED,SAAS,WAAW,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,GAAG,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAoB;IAClG,MAAM,YAAY,GAAG,CAAC,iBAAiB,EAAE,SAAS,CAAC,CAAC,CAAC,uBAAuB,CAAC,CAAC,CAAC,EAAE,EAAE,SAAS,CAAC;SAC1F,MAAM,CAAC,OAAO,CAAC;SACf,IAAI,CAAC,GAAG,CAAC,CAAC;IACb,MAAM,SAAS,GAAG,CAAC,uBAAuB,EAAE,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,6BAA6B,CAAC,CAAC,CAAC,EAAE,CAAC;SAC5F,MAAM,CAAC,OAAO,CAAC;SACf,IAAI,CAAC,GAAG,CAAC,CAAC;IAEb,OAAO,CACL,mBAAS,SAAS,EAAE,YAAY,EAAE,KAAK,EAAE,KAAK,iBAAc,iBAAiB,aAC3E,aAAI,SAAS,EAAC,wBAAwB,YAAE,KAAK,GAAM,EACnD,cAAK,SAAS,EAAE,SAAS,YAAG,QAAQ,GAAO,IACnC,CACX,CAAC;AACJ,CAAC;AAED,mEAAmE;AACnE,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,CAAC,mBAAmB,EAAE,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/react/src/layout/form-section/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type CSSProperties, type ReactNode } from 'react';
|
|
2
|
+
import { type DestinationSelectItem } from '../../visual/destination/destination-select-list/DestinationSelectList.js';
|
|
3
|
+
export type GeoExplorerListPlacement = 'left' | 'right';
|
|
4
|
+
export interface GeoExplorerLayoutProps {
|
|
5
|
+
title?: string;
|
|
6
|
+
listTitle?: string;
|
|
7
|
+
listPlacement?: GeoExplorerListPlacement;
|
|
8
|
+
listWidth?: string;
|
|
9
|
+
viewportMinHeight?: string;
|
|
10
|
+
items: DestinationSelectItem[];
|
|
11
|
+
selectedId?: string;
|
|
12
|
+
onSelect?: (id: string) => void;
|
|
13
|
+
className?: string;
|
|
14
|
+
style?: CSSProperties;
|
|
15
|
+
children?: ReactNode;
|
|
16
|
+
}
|
|
17
|
+
/** @rosettadash/react/layout/geo-explorer — map/globe viewport + destination sidebar list */
|
|
18
|
+
export declare const GeoExplorerLayout: import("react").ForwardRefExoticComponent<GeoExplorerLayoutProps & import("react").RefAttributes<HTMLElement>>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from 'react';
|
|
3
|
+
import { DestinationSelectList, } from '../../visual/destination/destination-select-list/DestinationSelectList.js';
|
|
4
|
+
/** @rosettadash/react/layout/geo-explorer — map/globe viewport + destination sidebar list */
|
|
5
|
+
export const GeoExplorerLayout = forwardRef(function GeoExplorerLayout({ title, listTitle, listPlacement = 'right', listWidth = '14rem', viewportMinHeight = '28rem', items, selectedId, onSelect, className, style, children, }, ref) {
|
|
6
|
+
const rootClass = ['rd-geo-explorer', className].filter(Boolean).join(' ');
|
|
7
|
+
const bodyClass = [
|
|
8
|
+
'rd-geo-explorer__body',
|
|
9
|
+
listPlacement === 'left' ? 'rd-geo-explorer__body--list-left' : 'rd-geo-explorer__body--list-right',
|
|
10
|
+
].join(' ');
|
|
11
|
+
const layoutStyle = Object.assign(Object.assign({}, style), { '--rd-geo-explorer-list-width': listWidth, '--rd-geo-explorer-min-height': viewportMinHeight });
|
|
12
|
+
return (_jsxs("section", { ref: ref, className: rootClass, style: layoutStyle, "data-testid": "rd-geo-explorer", children: [title ? _jsx("span", { className: "rd-geo-explorer__title", children: title }) : null, _jsxs("div", { className: bodyClass, children: [_jsx("div", { className: "rd-geo-explorer__viewport", children: children }), _jsx(DestinationSelectList, { className: "rd-geo-explorer__list", title: listTitle, items: items, selectedId: selectedId, onSelect: onSelect })] })] }));
|
|
13
|
+
});
|
|
14
|
+
//# sourceMappingURL=GeoExplorerLayout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GeoExplorerLayout.js","sourceRoot":"","sources":["../../../../../../packages/react/src/layout/geo-explorer/GeoExplorerLayout.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAsC,MAAM,OAAO,CAAC;AACvE,OAAO,EACL,qBAAqB,GAEtB,MAAM,2EAA2E,CAAC;AAkBnF,6FAA6F;AAC7F,MAAM,CAAC,MAAM,iBAAiB,GAAG,UAAU,CAAsC,SAAS,iBAAiB,CACzG,EACE,KAAK,EACL,SAAS,EACT,aAAa,GAAG,OAAO,EACvB,SAAS,GAAG,OAAO,EACnB,iBAAiB,GAAG,OAAO,EAC3B,KAAK,EACL,UAAU,EACV,QAAQ,EACR,SAAS,EACT,KAAK,EACL,QAAQ,GACT,EACD,GAAG;IAEH,MAAM,SAAS,GAAG,CAAC,iBAAiB,EAAE,SAAS,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC3E,MAAM,SAAS,GAAG;QAChB,uBAAuB;QACvB,aAAa,KAAK,MAAM,CAAC,CAAC,CAAC,kCAAkC,CAAC,CAAC,CAAC,mCAAmC;KACpG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAEZ,MAAM,WAAW,GAAG,gCACf,KAAK,KACR,8BAA8B,EAAE,SAAS,EACzC,8BAA8B,EAAE,iBAAiB,GACjC,CAAC;IAEnB,OAAO,CACL,mBAAS,GAAG,EAAE,GAAmC,EAAE,SAAS,EAAE,SAAS,EAAE,KAAK,EAAE,WAAW,iBAAc,iBAAiB,aACvH,KAAK,CAAC,CAAC,CAAC,eAAM,SAAS,EAAC,wBAAwB,YAAE,KAAK,GAAQ,CAAC,CAAC,CAAC,IAAI,EACvE,eAAK,SAAS,EAAE,SAAS,aACvB,cAAK,SAAS,EAAC,2BAA2B,YAAE,QAAQ,GAAO,EAC3D,KAAC,qBAAqB,IACpB,SAAS,EAAC,uBAAuB,EACjC,KAAK,EAAE,SAAS,EAChB,KAAK,EAAE,KAAK,EACZ,UAAU,EAAE,UAAU,EACtB,QAAQ,EAAE,QAAQ,GAClB,IACE,IACE,CACX,CAAC;AACJ,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/react/src/layout/geo-explorer/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type CSSProperties, type ReactNode } from 'react';
|
|
2
|
+
export interface ScrollRegionProps {
|
|
3
|
+
title?: string;
|
|
4
|
+
/** When set, constrains height and enables vertical scroll when content overflows. */
|
|
5
|
+
maxHeight?: string;
|
|
6
|
+
/** Show scrollbar only while scrolling / when overflow exists (default true). */
|
|
7
|
+
overlayScrollbar?: boolean;
|
|
8
|
+
className?: string;
|
|
9
|
+
style?: CSSProperties;
|
|
10
|
+
children?: ReactNode;
|
|
11
|
+
}
|
|
12
|
+
/** @rosettadash/react/layout/scroll-region — designated scroll container for long-form content */
|
|
13
|
+
export declare const ScrollRegion: import("react").ForwardRefExoticComponent<ScrollRegionProps & import("react").RefAttributes<HTMLElement>>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from 'react';
|
|
3
|
+
/** @rosettadash/react/layout/scroll-region — designated scroll container for long-form content */
|
|
4
|
+
export const ScrollRegion = forwardRef(function ScrollRegion({ title, maxHeight, overlayScrollbar = true, className, style, children }, ref) {
|
|
5
|
+
const rootClass = [
|
|
6
|
+
'rd-scroll-region',
|
|
7
|
+
overlayScrollbar ? 'rd-scroll-region--overlay-scrollbar' : '',
|
|
8
|
+
className,
|
|
9
|
+
]
|
|
10
|
+
.filter(Boolean)
|
|
11
|
+
.join(' ');
|
|
12
|
+
const regionStyle = Object.assign(Object.assign({}, style), (maxHeight ? { maxHeight } : {}));
|
|
13
|
+
return (_jsxs("section", { ref: ref, className: rootClass, style: regionStyle, "data-testid": "rd-scroll-region", "aria-label": title !== null && title !== void 0 ? title : 'Scrollable content', children: [title ? _jsx("header", { className: "rd-scroll-region__header", children: title }) : null, _jsx("div", { className: "rd-scroll-region__body", children: children })] }));
|
|
14
|
+
});
|
|
15
|
+
//# sourceMappingURL=ScrollRegion.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ScrollRegion.js","sourceRoot":"","sources":["../../../../../../packages/react/src/layout/scroll-region/ScrollRegion.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAsC,MAAM,OAAO,CAAC;AAavE,kGAAkG;AAClG,MAAM,CAAC,MAAM,YAAY,GAAG,UAAU,CAAiC,SAAS,YAAY,CAC1F,EAAE,KAAK,EAAE,SAAS,EAAE,gBAAgB,GAAG,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,EACzE,GAAG;IAEH,MAAM,SAAS,GAAG;QAChB,kBAAkB;QAClB,gBAAgB,CAAC,CAAC,CAAC,qCAAqC,CAAC,CAAC,CAAC,EAAE;QAC7D,SAAS;KACV;SACE,MAAM,CAAC,OAAO,CAAC;SACf,IAAI,CAAC,GAAG,CAAC,CAAC;IAEb,MAAM,WAAW,mCACZ,KAAK,GACL,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CACpC,CAAC;IAEF,OAAO,CACL,mBACE,GAAG,EAAE,GAAmC,EACxC,SAAS,EAAE,SAAS,EACpB,KAAK,EAAE,WAAW,iBACN,kBAAkB,gBAClB,KAAK,aAAL,KAAK,cAAL,KAAK,GAAI,oBAAoB,aAExC,KAAK,CAAC,CAAC,CAAC,iBAAQ,SAAS,EAAC,0BAA0B,YAAE,KAAK,GAAU,CAAC,CAAC,CAAC,IAAI,EAC7E,cAAK,SAAS,EAAC,wBAAwB,YAAE,QAAQ,GAAO,IAChD,CACX,CAAC;AACJ,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/react/src/layout/scroll-region/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC"}
|
|
@@ -3,8 +3,13 @@ import { forwardRef } from 'react';
|
|
|
3
3
|
/** @rosettadash/react/layout/tabs — layout.tabs */
|
|
4
4
|
export const TabsLayout = forwardRef(function TabsLayout(props, ref) {
|
|
5
5
|
var _a;
|
|
6
|
-
const { className, style, children } = props;
|
|
6
|
+
const { className, style, children, panelMinHeight } = props;
|
|
7
7
|
const rootClass = ['rd-tabs', className].filter(Boolean).join(' ');
|
|
8
|
-
|
|
8
|
+
const panelStyle = panelMinHeight
|
|
9
|
+
? { '--rd-tabs-panel-min-height': panelMinHeight }
|
|
10
|
+
: undefined;
|
|
11
|
+
return (_jsxs("section", { ref: ref, className: rootClass, style: style, "data-testid": "rd-tabs", children: [props.title ? _jsx("span", { className: "rd-tabs__title", children: props.title }) : null, _jsx("div", { className: "rd-tabs__tabs", role: "tablist", children: ((_a = props.tabs) !== null && _a !== void 0 ? _a : []).map((tab) => (_jsx("button", { type: "button", role: "tab", className: ['rd-tabs__tab', props.activeTabId === tab.id ? 'rd-tabs__tab--active' : '']
|
|
12
|
+
.filter(Boolean)
|
|
13
|
+
.join(' '), onClick: () => { var _a; return (_a = props.onTabChange) === null || _a === void 0 ? void 0 : _a.call(props, tab.id); }, children: tab.label }, tab.id))) }), _jsx("div", { className: "rd-tabs__panel", style: panelStyle, children: children })] }));
|
|
9
14
|
});
|
|
10
15
|
//# sourceMappingURL=TabsLayout.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TabsLayout.js","sourceRoot":"","sources":["../../../../../../packages/react/src/layout/tabs/TabsLayout.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAsC,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"TabsLayout.js","sourceRoot":"","sources":["../../../../../../packages/react/src/layout/tabs/TabsLayout.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAsC,MAAM,OAAO,CAAC;AAkBvE,mDAAmD;AACnD,MAAM,CAAC,MAAM,UAAU,GAAG,UAAU,CAA+B,SAAS,UAAU,CACpF,KAAK,EACL,GAAG;;IAEH,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,GAAG,KAAK,CAAC;IAC7D,MAAM,SAAS,GAAG,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACnE,MAAM,UAAU,GAAG,cAAc;QAC/B,CAAC,CAAE,EAAE,4BAA4B,EAAE,cAAc,EAAoB;QACrE,CAAC,CAAC,SAAS,CAAC;IAEd,OAAO,CACL,mBAAS,GAAG,EAAE,GAAmC,EAAE,SAAS,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,iBAAc,SAAS,aACzG,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,eAAM,SAAS,EAAC,gBAAgB,YAAE,KAAK,CAAC,KAAK,GAAQ,CAAC,CAAC,CAAC,IAAI,EAC3E,cAAK,SAAS,EAAC,eAAe,EAAC,IAAI,EAAC,SAAS,YAC1C,CAAC,MAAA,KAAK,CAAC,IAAI,mCAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAC/B,iBAEE,IAAI,EAAC,QAAQ,EACb,IAAI,EAAC,KAAK,EACV,SAAS,EAAE,CAAC,cAAc,EAAE,KAAK,CAAC,WAAW,KAAK,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,sBAAsB,CAAC,CAAC,CAAC,EAAE,CAAC;yBACpF,MAAM,CAAC,OAAO,CAAC;yBACf,IAAI,CAAC,GAAG,CAAC,EACZ,OAAO,EAAE,GAAG,EAAE,WAAC,OAAA,MAAA,KAAK,CAAC,WAAW,sDAAG,GAAG,CAAC,EAAE,CAAC,CAAA,EAAA,YAEzC,GAAG,CAAC,KAAK,IARL,GAAG,CAAC,EAAE,CASJ,CACV,CAAC,GACE,EACN,cAAK,SAAS,EAAC,gBAAgB,EAAC,KAAK,EAAE,UAAU,YAC9C,QAAQ,GACL,IACE,CACX,CAAC;AACJ,CAAC,CAAC,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useCallback, useEffect, useRef, } from 'react';
|
|
1
|
+
import { useCallback, useEffect, useLayoutEffect, useRef, } from 'react';
|
|
2
2
|
import { mergeRef } from './merge-ref.js';
|
|
3
3
|
function toKebab(name) {
|
|
4
4
|
return name.replace(/[A-Z]/g, (ch) => `-${ch.toLowerCase()}`);
|
|
@@ -43,7 +43,7 @@ export function useCustomElementHost(options, values, handlers = {}, forwardedRe
|
|
|
43
43
|
registerRef.current();
|
|
44
44
|
}, []);
|
|
45
45
|
const propertyKeys = (_c = options.properties) !== null && _c !== void 0 ? _c : [];
|
|
46
|
-
|
|
46
|
+
useLayoutEffect(() => {
|
|
47
47
|
const el = host.current;
|
|
48
48
|
if (!el) {
|
|
49
49
|
return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"custom-element-host.js","sourceRoot":"","sources":["../../../../../packages/react/src/lib/custom-element-host.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,SAAS,EACT,MAAM,GAGP,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAY1C,SAAS,OAAO,CAAC,IAAY;IAC3B,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;AAChE,CAAC;AAED,SAAS,cAAc,CACrB,EAAe,EACf,MAAiC,EACjC,OAA+B;;IAE/B,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QAClD,MAAM,IAAI,GAAG,MAAA,OAAO,CAAC,GAAG,CAAC,mCAAI,OAAO,CAAC,GAAG,CAAC,CAAC;QAC1C,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,KAAK,EAAE,CAAC;YAC7D,EAAE,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;QAC3B,CAAC;aAAM,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;YAC1B,EAAE,CAAC,YAAY,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QAC5B,CAAC;aAAM,CAAC;YACN,EAAE,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;QACvC,CAAC;IACH,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,SAAS,cAAc,CACrB,EAAe,EACf,cAAuC,EACvC,YAAsB;IAEtB,MAAM,WAAW,GAAI,EAA+D;SACjF,WAAW,CAAC;IACf,IAAI,OAAO,WAAW,KAAK,UAAU,EAAE,CAAC;QACtC,OAAO;IACT,CAAC;IACD,KAAK,MAAM,GAAG,IAAI,YAAY,EAAE,CAAC;QAC/B,WAAW,CAAC,IAAI,CAAC,EAAE,EAAE,GAAG,EAAE,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC;IACjD,CAAC;AACH,CAAC;AAED,MAAM,UAAU,oBAAoB,CAClC,OAAiC,EACjC,MAAiC,EACjC,WAAoE,EAAE,EACtE,YAAsC,EACtC,iBAA0C,EAAE;;IAE5C,MAAM,IAAI,GAAG,MAAM,CAAqB,IAAI,CAAC,CAAC;IAC9C,MAAM,OAAO,GAAG,MAAA,OAAO,CAAC,KAAK,mCAAI,EAAE,CAAC;IACpC,MAAM,QAAQ,GAAG,MAAA,OAAO,CAAC,MAAM,mCAAI,EAAE,CAAC;IACtC,MAAM,WAAW,GAAG,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC7C,WAAW,CAAC,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC;IAEvC,SAAS,CAAC,GAAG,EAAE;QACb,WAAW,CAAC,OAAO,EAAE,CAAC;IACxB,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,MAAM,YAAY,GAAG,MAAA,OAAO,CAAC,UAAU,mCAAI,EAAE,CAAC;IAE9C,
|
|
1
|
+
{"version":3,"file":"custom-element-host.js","sourceRoot":"","sources":["../../../../../packages/react/src/lib/custom-element-host.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,SAAS,EACT,eAAe,EACf,MAAM,GAGP,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAY1C,SAAS,OAAO,CAAC,IAAY;IAC3B,OAAO,IAAI,CAAC,OAAO,C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;YACzC,CAAC,CAAC;YACF,EAAE,CAAC,gBAAgB,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;YACxC,SAAS,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC;QACvC,CAAC;QACD,OAAO,GAAG,EAAE;YACV,KAAK,MAAM,CAAC,QAAQ,EAAE,QAAQ,CAAC,IAAI,SAAS,EAAE,CAAC;gBAC7C,EAAE,CAAC,mBAAmB,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;YAC7C,CAAC;QACH,CAAC,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,OAAO,WAAW,CAAC,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAC,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC;AACnE,CAAC"}
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import { type CSSProperties, type ReactNode } from 'react';
|
|
2
|
+
export interface BarChartBar {
|
|
3
|
+
label: string;
|
|
4
|
+
value: number;
|
|
5
|
+
}
|
|
2
6
|
export interface BarChartProps {
|
|
3
7
|
title?: string;
|
|
8
|
+
bars?: BarChartBar[];
|
|
9
|
+
yAxisLabel?: string;
|
|
10
|
+
valueFormat?: (value: number) => string;
|
|
4
11
|
className?: string;
|
|
5
12
|
style?: CSSProperties;
|
|
6
13
|
children?: ReactNode;
|
|
@@ -1,10 +1,40 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef } from 'react';
|
|
3
|
+
const FALLBACK_BARS = [
|
|
4
|
+
{ label: 'A', value: 40 },
|
|
5
|
+
{ label: 'B', value: 65 },
|
|
6
|
+
{ label: 'C', value: 55 },
|
|
7
|
+
{ label: 'D', value: 80 },
|
|
8
|
+
{ label: 'E', value: 48 },
|
|
9
|
+
];
|
|
10
|
+
function defaultFormat(value) {
|
|
11
|
+
if (value >= 1000000) {
|
|
12
|
+
return `${(value / 1000000).toFixed(1)}M`;
|
|
13
|
+
}
|
|
14
|
+
if (value >= 1000) {
|
|
15
|
+
return `${(value / 1000).toFixed(0)}K`;
|
|
16
|
+
}
|
|
17
|
+
return String(Math.round(value));
|
|
18
|
+
}
|
|
19
|
+
function buildTicks(max, count = 4) {
|
|
20
|
+
if (max <= 0) {
|
|
21
|
+
return [0];
|
|
22
|
+
}
|
|
23
|
+
const step = max / (count - 1);
|
|
24
|
+
return Array.from({ length: count }, (_, index) => step * index);
|
|
25
|
+
}
|
|
3
26
|
/** @rosettadash/react/visual/chart/bar — visual.chart.bar */
|
|
4
27
|
export const BarChart = forwardRef(function BarChart(props, ref) {
|
|
5
|
-
var _a;
|
|
28
|
+
var _a, _b, _c, _d;
|
|
6
29
|
const { className, style, children } = props;
|
|
7
30
|
const rootClass = ['rd-chart-bar', className].filter(Boolean).join(' ');
|
|
8
|
-
|
|
31
|
+
const bars = ((_a = props.bars) === null || _a === void 0 ? void 0 : _a.length) ? props.bars : FALLBACK_BARS;
|
|
32
|
+
const format = (_b = props.valueFormat) !== null && _b !== void 0 ? _b : defaultFormat;
|
|
33
|
+
const maxValue = Math.max(...bars.map((bar) => bar.value), 1);
|
|
34
|
+
const ticks = buildTicks(maxValue);
|
|
35
|
+
return (_jsxs("section", { ref: ref, className: rootClass, style: style, "data-testid": "rd-chart-bar", role: "img", "aria-label": (_c = props.title) !== null && _c !== void 0 ? _c : 'Bar chart', children: [_jsx("header", { className: "rd-chart-bar__header", children: _jsx("span", { children: (_d = props.title) !== null && _d !== void 0 ? _d : 'Bar chart' }) }), _jsxs("div", { className: "rd-chart-bar__body", children: [_jsxs("div", { className: "rd-chart-bar__y-axis", "aria-hidden": "true", children: [_jsx("div", { className: "rd-chart-bar__y-ticks", children: [...ticks].reverse().map((tick) => (_jsx("span", { className: "rd-chart-bar__y-tick", children: format(tick) }, tick))) }), props.yAxisLabel ? (_jsx("span", { className: "rd-chart-bar__y-label", children: props.yAxisLabel })) : null] }), _jsxs("div", { className: "rd-chart-bar__plot", children: [_jsx("div", { className: "rd-chart-bar__grid-lines", "aria-hidden": "true", children: ticks.map((tick) => (_jsx("span", { className: "rd-chart-bar__grid-line", style: { bottom: `${(tick / maxValue) * 100}%` } }, tick))) }), _jsx("div", { className: "rd-chart-bar__bars", children: bars.map((bar) => {
|
|
36
|
+
const heightPct = (bar.value / maxValue) * 100;
|
|
37
|
+
return (_jsxs("div", { className: "rd-chart-bar__bar-group", children: [_jsx("div", { className: "rd-chart-bar__bar-wrap", children: _jsx("div", { className: "rd-chart-bar__bar", style: { height: `${heightPct}%` }, title: `${bar.label}: ${format(bar.value)}` }) }), _jsx("span", { className: "rd-chart-bar__x-label", children: bar.label }), _jsx("span", { className: "rd-chart-bar__value", children: format(bar.value) })] }, bar.label));
|
|
38
|
+
}) })] })] }), children] }));
|
|
9
39
|
});
|
|
10
40
|
//# sourceMappingURL=BarChart.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BarChart.js","sourceRoot":"","sources":["../../../../../../../packages/react/src/visual/chart/bar/BarChart.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAsC,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"BarChart.js","sourceRoot":"","sources":["../../../../../../../packages/react/src/visual/chart/bar/BarChart.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAsC,MAAM,OAAO,CAAC;AAiBvE,MAAM,aAAa,GAAkB;IACnC,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE,EAAE;IACzB,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE,EAAE;IACzB,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE,EAAE;IACzB,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE,EAAE;IACzB,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE,EAAE;CAC1B,CAAC;AAEF,SAAS,aAAa,CAA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GT,CACH,CAAC,GACE,EACN,cAAK,SAAS,EAAC,oBAAoB,YAChC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE;oCAChB,MAAM,SAAS,GAAG,CAAC,GAAG,CAAC,KAAK,GAAG,QAAQ,CAAC,GAAG,GAAG,CAAC;oCAC/C,OAAO,CACL,eAAqB,SAAS,EAAC,yBAAyB,aACtD,cAAK,SAAS,EAAC,wBAAwB,YACrC,cACE,SAAS,EAAC,mBAAmB,EAC7B,KAAK,EAAE,EAAE,MAAM,EAAE,GAAG,SAAS,GAAG,EAAE,EAClC,KAAK,EAAE,GAAG,GAAG,CAAC,KAAK,KAAK,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,GAC3C,GACE,EACN,eAAM,SAAS,EAAC,uBAAuB,YAAE,GAAG,CAAC,KAAK,GAAQ,EAC1D,eAAM,SAAS,EAAC,qBAAqB,YAAE,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,GAAQ,KATxD,GAAG,CAAC,KAAK,CAUb,CACP,CAAC;gCACJ,CAAC,CAAC,GACE,IACF,IACF,EACL,QAAQ,IACD,CACX,CAAC;AACJ,CAAC,CAAC,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export type { BarChartProps } from './BarChart.js';
|
|
1
|
+
export type { BarChartProps, BarChartBar } from './BarChart.js';
|
|
2
2
|
export { BarChart } from './BarChart.js';
|
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import { type CSSProperties, type ReactNode } from 'react';
|
|
2
|
+
export interface LineChartPoint {
|
|
3
|
+
x: string | number;
|
|
4
|
+
y: number;
|
|
5
|
+
}
|
|
2
6
|
export interface LineChartProps {
|
|
3
7
|
title?: string;
|
|
8
|
+
points?: LineChartPoint[];
|
|
9
|
+
xAxisLabel?: string;
|
|
10
|
+
yAxisLabel?: string;
|
|
11
|
+
valueFormat?: (value: number) => string;
|
|
4
12
|
className?: string;
|
|
5
13
|
style?: CSSProperties;
|
|
6
14
|
children?: ReactNode;
|
|
@@ -1,10 +1,66 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef } from 'react';
|
|
3
|
+
const FALLBACK_POINTS = [
|
|
4
|
+
{ x: '2019', y: 42 },
|
|
5
|
+
{ x: '2020', y: 18 },
|
|
6
|
+
{ x: '2021', y: 12 },
|
|
7
|
+
{ x: '2022', y: 19 },
|
|
8
|
+
{ x: '2023', y: 31 },
|
|
9
|
+
{ x: '2024', y: 36 },
|
|
10
|
+
];
|
|
11
|
+
const CHART_WIDTH = 320;
|
|
12
|
+
const CHART_HEIGHT = 200;
|
|
13
|
+
const PAD_LEFT = 58;
|
|
14
|
+
const PAD_RIGHT = 12;
|
|
15
|
+
const PAD_TOP = 16;
|
|
16
|
+
const PAD_BOTTOM = 36;
|
|
17
|
+
const Y_TICK_X = PAD_LEFT - 6;
|
|
18
|
+
function defaultFormat(value) {
|
|
19
|
+
if (value >= 1000000) {
|
|
20
|
+
return `${(value / 1000000).toFixed(1)}M`;
|
|
21
|
+
}
|
|
22
|
+
if (value >= 1000) {
|
|
23
|
+
return `${(value / 1000).toFixed(0)}K`;
|
|
24
|
+
}
|
|
25
|
+
return String(Math.round(value));
|
|
26
|
+
}
|
|
27
|
+
function buildTicks(min, max, count = 4) {
|
|
28
|
+
if (min === max) {
|
|
29
|
+
return [min];
|
|
30
|
+
}
|
|
31
|
+
const step = (max - min) / (count - 1);
|
|
32
|
+
return Array.from({ length: count }, (_, index) => min + step * index);
|
|
33
|
+
}
|
|
34
|
+
function chartCoords(points, minY, rangeY) {
|
|
35
|
+
const plotW = CHART_WIDTH - PAD_LEFT - PAD_RIGHT;
|
|
36
|
+
const plotH = CHART_HEIGHT - PAD_TOP - PAD_BOTTOM;
|
|
37
|
+
const lastIndex = Math.max(points.length - 1, 1);
|
|
38
|
+
return points.map((point, index) => {
|
|
39
|
+
const x = PAD_LEFT + (index / lastIndex) * plotW;
|
|
40
|
+
const y = PAD_TOP + plotH - ((point.y - minY) / rangeY) * plotH;
|
|
41
|
+
return { x, y, label: String(point.x) };
|
|
42
|
+
});
|
|
43
|
+
}
|
|
3
44
|
/** @rosettadash/react/visual/chart/line — visual.chart.line */
|
|
4
45
|
export const LineChart = forwardRef(function LineChart(props, ref) {
|
|
5
|
-
var _a;
|
|
46
|
+
var _a, _b, _c, _d;
|
|
6
47
|
const { className, style, children } = props;
|
|
7
48
|
const rootClass = ['rd-chart-line', className].filter(Boolean).join(' ');
|
|
8
|
-
|
|
49
|
+
const points = ((_a = props.points) === null || _a === void 0 ? void 0 : _a.length) ? props.points : FALLBACK_POINTS;
|
|
50
|
+
const format = (_b = props.valueFormat) !== null && _b !== void 0 ? _b : defaultFormat;
|
|
51
|
+
const values = points.map((point) => point.y);
|
|
52
|
+
const dataMin = Math.min(...values);
|
|
53
|
+
const dataMax = Math.max(...values);
|
|
54
|
+
const minY = dataMin >= 0 ? 0 : dataMin;
|
|
55
|
+
const maxY = dataMax;
|
|
56
|
+
const rangeY = maxY - minY || 1;
|
|
57
|
+
const ticks = buildTicks(minY, maxY);
|
|
58
|
+
const coords = chartCoords(points, minY, rangeY);
|
|
59
|
+
const polyline = coords.map(({ x, y }) => `${x},${y}`).join(' ');
|
|
60
|
+
const plotH = CHART_HEIGHT - PAD_TOP - PAD_BOTTOM;
|
|
61
|
+
return (_jsxs("section", { ref: ref, className: rootClass, style: style, "data-testid": "rd-chart-line", role: "img", "aria-label": (_c = props.title) !== null && _c !== void 0 ? _c : 'Line chart', children: [_jsx("header", { className: "rd-chart-line__header", children: _jsx("span", { children: (_d = props.title) !== null && _d !== void 0 ? _d : 'Line chart' }) }), _jsx("div", { className: "rd-chart-line__body", children: _jsxs("svg", { viewBox: `0 0 ${CHART_WIDTH} ${CHART_HEIGHT}`, className: "rd-chart-line__svg", "aria-hidden": "true", children: [ticks.map((tick) => {
|
|
62
|
+
const y = PAD_TOP + plotH - ((tick - minY) / rangeY) * plotH;
|
|
63
|
+
return (_jsxs("g", { className: "rd-chart-line__tick", children: [_jsx("line", { x1: PAD_LEFT, y1: y, x2: CHART_WIDTH - PAD_RIGHT, y2: y, className: "rd-chart-line__grid" }), _jsx("text", { x: Y_TICK_X, y: y + 4, className: "rd-chart-line__tick-label", children: format(tick) })] }, tick));
|
|
64
|
+
}), _jsx("polyline", { className: "rd-chart-line__line", points: polyline }), coords.map(({ x, y, label }) => (_jsxs("g", { className: "rd-chart-line__point", children: [_jsx("circle", { cx: x, cy: y, r: 3.5, className: "rd-chart-line__dot" }), _jsx("text", { x: x, y: CHART_HEIGHT - 10, className: "rd-chart-line__x-label", children: label })] }, label))), props.yAxisLabel ? (_jsx("text", { x: 12, y: PAD_TOP + plotH / 2, className: "rd-chart-line__axis-label rd-chart-line__axis-label--y", children: props.yAxisLabel })) : null, props.xAxisLabel ? (_jsx("text", { x: PAD_LEFT + (CHART_WIDTH - PAD_LEFT - PAD_RIGHT) / 2, y: CHART_HEIGHT - 2, className: "rd-chart-line__axis-label rd-chart-line__axis-label--x", children: props.xAxisLabel })) : null] }) }), children] }));
|
|
9
65
|
});
|
|
10
66
|
//# sourceMappingURL=LineChart.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LineChart.js","sourceRoot":"","sources":["../../../../../../../packages/react/src/visual/chart/line/LineChart.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAsC,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"LineChart.js","sourceRoot":"","sources":["../../../../../../../packages/react/src/visual/chart/line/LineChart.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAsC,MAAM,OAAO,CAAC;AAkBvE,MAAM,eAAe,GAAqB;IACxC,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,EAAE,EAAE;IACpB,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,EAAE,EAAE;IACpB,EAAE,CAAC,EAAE,MAAM,EAA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,IAAI,EACP,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,CAClB,eACE,CAAC,EAAE,QAAQ,GAAG,CAAC,WAAW,GAAG,QAAQ,GAAG,SAAS,CAAC,GAAG,CAAC,EACtD,CAAC,EAAE,YAAY,GAAG,CAAC,EACnB,SAAS,EAAC,wDAAwD,YAEjE,KAAK,CAAC,UAAU,GACZ,CACR,CAAC,CAAC,CAAC,IAAI,IACJ,GACF,EACL,QAAQ,IACD,CACX,CAAC;AACJ,CAAC,CAAC,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export type { LineChartProps } from './LineChart.js';
|
|
1
|
+
export type { LineChartProps, LineChartPoint } from './LineChart.js';
|
|
2
2
|
export { LineChart } from './LineChart.js';
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type CSSProperties, type ReactNode } from 'react';
|
|
2
|
+
export interface SankeyNode {
|
|
3
|
+
id: string;
|
|
4
|
+
label: string;
|
|
5
|
+
}
|
|
6
|
+
export interface SankeyLink {
|
|
7
|
+
source: string;
|
|
8
|
+
target: string;
|
|
9
|
+
value: number;
|
|
10
|
+
}
|
|
11
|
+
export interface JourneySankeyChartProps {
|
|
12
|
+
title?: string;
|
|
13
|
+
nodes?: SankeyNode[];
|
|
14
|
+
links?: SankeyLink[];
|
|
15
|
+
className?: string;
|
|
16
|
+
style?: CSSProperties;
|
|
17
|
+
children?: ReactNode;
|
|
18
|
+
}
|
|
19
|
+
/** @rosettadash/react/visual/chart/sankey — SVG journey / flow sankey chart */
|
|
20
|
+
export declare const JourneySankeyChart: import("react").ForwardRefExoticComponent<JourneySankeyChartProps & import("react").RefAttributes<HTMLElement>>;
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef, useMemo } from 'react';
|
|
3
|
+
const FALLBACK_NODES = [
|
|
4
|
+
{ id: 'a', label: 'Start' },
|
|
5
|
+
{ id: 'b', label: 'Middle' },
|
|
6
|
+
{ id: 'c', label: 'End' },
|
|
7
|
+
];
|
|
8
|
+
const FALLBACK_LINKS = [
|
|
9
|
+
{ source: 'a', target: 'b', value: 40 },
|
|
10
|
+
{ source: 'b', target: 'c', value: 40 },
|
|
11
|
+
];
|
|
12
|
+
const WIDTH = 640;
|
|
13
|
+
const HEIGHT = 280;
|
|
14
|
+
const PADDING = 16;
|
|
15
|
+
const NODE_WIDTH = 12;
|
|
16
|
+
function buildLayout(nodes, links) {
|
|
17
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
18
|
+
const columns = new Map();
|
|
19
|
+
const incoming = new Set(links.map((link) => link.target));
|
|
20
|
+
const roots = nodes.filter((node) => !incoming.has(node.id));
|
|
21
|
+
const queue = roots.length ? roots.map((node) => node.id) : [(_a = nodes[0]) === null || _a === void 0 ? void 0 : _a.id].filter(Boolean);
|
|
22
|
+
for (const id of queue) {
|
|
23
|
+
columns.set(id, 0);
|
|
24
|
+
}
|
|
25
|
+
let guard = 0;
|
|
26
|
+
while (guard < nodes.length * 2) {
|
|
27
|
+
guard += 1;
|
|
28
|
+
let progressed = false;
|
|
29
|
+
for (const link of links) {
|
|
30
|
+
const sourceCol = columns.get(link.source);
|
|
31
|
+
if (sourceCol === undefined) {
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
const nextCol = sourceCol + 1;
|
|
35
|
+
const existing = columns.get(link.target);
|
|
36
|
+
if (existing === undefined || nextCol > existing) {
|
|
37
|
+
columns.set(link.target, nextCol);
|
|
38
|
+
progressed = true;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
if (!progressed) {
|
|
42
|
+
break;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
for (const node of nodes) {
|
|
46
|
+
if (!columns.has(node.id)) {
|
|
47
|
+
columns.set(node.id, 0);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
const maxColumn = Math.max(...columns.values(), 0);
|
|
51
|
+
const byColumn = new Map();
|
|
52
|
+
for (const node of nodes) {
|
|
53
|
+
const column = (_b = columns.get(node.id)) !== null && _b !== void 0 ? _b : 0;
|
|
54
|
+
const list = (_c = byColumn.get(column)) !== null && _c !== void 0 ? _c : [];
|
|
55
|
+
list.push(node);
|
|
56
|
+
byColumn.set(column, list);
|
|
57
|
+
}
|
|
58
|
+
const outTotals = new Map();
|
|
59
|
+
const inTotals = new Map();
|
|
60
|
+
for (const link of links) {
|
|
61
|
+
outTotals.set(link.source, ((_d = outTotals.get(link.source)) !== null && _d !== void 0 ? _d : 0) + link.value);
|
|
62
|
+
inTotals.set(link.target, ((_e = inTotals.get(link.target)) !== null && _e !== void 0 ? _e : 0) + link.value);
|
|
63
|
+
}
|
|
64
|
+
const layoutNodes = [];
|
|
65
|
+
for (const [column, columnNodes] of byColumn.entries()) {
|
|
66
|
+
const totalValue = columnNodes.reduce((sum, node) => { var _a, _b; return sum + Math.max((_a = outTotals.get(node.id)) !== null && _a !== void 0 ? _a : 0, (_b = inTotals.get(node.id)) !== null && _b !== void 0 ? _b : 0, 1); }, 0);
|
|
67
|
+
let yCursor = PADDING;
|
|
68
|
+
for (const node of columnNodes) {
|
|
69
|
+
const nodeValue = Math.max((_f = outTotals.get(node.id)) !== null && _f !== void 0 ? _f : 0, (_g = inTotals.get(node.id)) !== null && _g !== void 0 ? _g : 0, 1);
|
|
70
|
+
const height = Math.max(((HEIGHT - PADDING * 2) * nodeValue) / totalValue, 18);
|
|
71
|
+
layoutNodes.push(Object.assign(Object.assign({}, node), { column, y: yCursor, height }));
|
|
72
|
+
yCursor += height + 10;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
const nodeMap = new Map(layoutNodes.map((node) => [node.id, node]));
|
|
76
|
+
const xForColumn = (column) => PADDING + (column / Math.max(maxColumn, 1)) * (WIDTH - PADDING * 2 - NODE_WIDTH);
|
|
77
|
+
const paths = [];
|
|
78
|
+
for (const link of links) {
|
|
79
|
+
const source = nodeMap.get(link.source);
|
|
80
|
+
const target = nodeMap.get(link.target);
|
|
81
|
+
if (!source || !target) {
|
|
82
|
+
continue;
|
|
83
|
+
}
|
|
84
|
+
const sourceTotal = (_h = outTotals.get(link.source)) !== null && _h !== void 0 ? _h : link.value;
|
|
85
|
+
const linkHeight = Math.max((source.height * link.value) / sourceTotal, 4);
|
|
86
|
+
const x1 = xForColumn(source.column) + NODE_WIDTH;
|
|
87
|
+
const x2 = xForColumn(target.column);
|
|
88
|
+
const y1 = source.y + source.height / 2 - linkHeight / 2;
|
|
89
|
+
const y2 = target.y + target.height / 2 - linkHeight / 2;
|
|
90
|
+
const midX = (x1 + x2) / 2;
|
|
91
|
+
paths.push(`M ${x1} ${y1} C ${midX} ${y1}, ${midX} ${y2}, ${x2} ${y2} L ${x2} ${y2 + linkHeight} C ${midX} ${y2 + linkHeight}, ${midX} ${y1 + linkHeight}, ${x1} ${y1 + linkHeight} Z`);
|
|
92
|
+
}
|
|
93
|
+
return { layoutNodes, paths };
|
|
94
|
+
}
|
|
95
|
+
/** @rosettadash/react/visual/chart/sankey — SVG journey / flow sankey chart */
|
|
96
|
+
export const JourneySankeyChart = forwardRef(function JourneySankeyChart({ title, nodes, links, className, style, children }, ref) {
|
|
97
|
+
const rootClass = ['rd-chart-sankey', className].filter(Boolean).join(' ');
|
|
98
|
+
const chartNodes = (nodes === null || nodes === void 0 ? void 0 : nodes.length) ? nodes : FALLBACK_NODES;
|
|
99
|
+
const chartLinks = (links === null || links === void 0 ? void 0 : links.length) ? links : FALLBACK_LINKS;
|
|
100
|
+
const { layoutNodes, paths } = useMemo(() => buildLayout(chartNodes, chartLinks), [chartNodes, chartLinks]);
|
|
101
|
+
const maxColumn = Math.max(...layoutNodes.map((node) => node.column), 0);
|
|
102
|
+
const xForColumn = (column) => PADDING + (column / Math.max(maxColumn, 1)) * (WIDTH - PADDING * 2 - NODE_WIDTH);
|
|
103
|
+
return (_jsxs("section", { ref: ref, className: rootClass, style: style, "data-testid": "rd-chart-sankey", role: "img", "aria-label": title !== null && title !== void 0 ? title : 'Journey sankey chart', children: [_jsx("header", { className: "rd-chart-sankey__header", children: _jsx("span", { children: title !== null && title !== void 0 ? title : 'Journey flow' }) }), _jsx("div", { className: "rd-chart-sankey__body", children: _jsxs("svg", { viewBox: `0 0 ${WIDTH} ${HEIGHT}`, className: "rd-chart-sankey__svg", "aria-hidden": "true", children: [paths.map((path, index) => (_jsx("path", { d: path, className: "rd-chart-sankey__link" }, index))), layoutNodes.map((node) => (_jsxs("g", { children: [_jsx("rect", { x: xForColumn(node.column), y: node.y, width: NODE_WIDTH, height: node.height, className: "rd-chart-sankey__node", rx: 2 }), _jsx("text", { x: xForColumn(node.column) + (node.column === maxColumn ? NODE_WIDTH + 6 : -6), y: node.y + node.height / 2, className: "rd-chart-sankey__label", textAnchor: node.column === maxColumn ? 'start' : 'end', dominantBaseline: "middle", children: node.label })] }, node.id)))] }) }), children] }));
|
|
104
|
+
});
|
|
105
|
+
//# sourceMappingURL=JourneySankeyChart.js.map
|