@cratis/scene.primereact 4.4.0 → 4.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +25 -3
- package/chart/ChartGallery.stories.tsx +63 -0
- package/chart/ChartType.ts +14 -0
- package/chart/ChartTypeResolution.ts +14 -0
- package/chart/PrimeChart.tsx +62 -0
- package/chart/chartHasData.ts +22 -0
- package/chart/chartTypeChoices.ts +32 -0
- package/chart/index.ts +7 -0
- package/chart/resolveChartType.ts +61 -0
- package/chart/useChart.ts +61 -0
- package/dist/cjs/chart/ChartType.js +18 -0
- package/dist/cjs/chart/ChartType.js.map +1 -0
- package/dist/cjs/chart/PrimeChart.js +92 -0
- package/dist/cjs/chart/PrimeChart.js.map +1 -0
- package/dist/cjs/chart/chartHasData.js +24 -0
- package/dist/cjs/chart/chartHasData.js.map +1 -0
- package/dist/cjs/chart/chartTypeChoices.js +43 -0
- package/dist/cjs/chart/chartTypeChoices.js.map +1 -0
- package/dist/cjs/chart/resolveChartType.js +69 -0
- package/dist/cjs/chart/resolveChartType.js.map +1 -0
- package/dist/cjs/chart/useChart.js +62 -0
- package/dist/cjs/chart/useChart.js.map +1 -0
- package/dist/cjs/form/MultiStateGlyph.js +59 -0
- package/dist/cjs/form/MultiStateGlyph.js.map +1 -0
- package/dist/cjs/form/PrimeMultiStateCheckbox.js +123 -0
- package/dist/cjs/form/PrimeMultiStateCheckbox.js.map +1 -0
- package/dist/cjs/form/multiStateOptions.js +77 -0
- package/dist/cjs/form/multiStateOptions.js.map +1 -0
- package/dist/cjs/form/multiStateStates.js +32 -0
- package/dist/cjs/form/multiStateStates.js.map +1 -0
- package/dist/cjs/form/useMultiStateSelection.js +51 -0
- package/dist/cjs/form/useMultiStateSelection.js.map +1 -0
- package/dist/cjs/index.js +12 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/primeReactComponents.js +5 -0
- package/dist/cjs/primeReactComponents.js.map +1 -1
- package/dist/cjs/primeReactDescriptors.js +157 -0
- package/dist/cjs/primeReactDescriptors.js.map +1 -0
- package/dist/cjs/primeReactPackage.js +4 -0
- package/dist/cjs/primeReactPackage.js.map +1 -1
- package/dist/cjs/properties.js +11 -0
- package/dist/cjs/properties.js.map +1 -1
- package/dist/cjs/structurallyEqual.js +27 -0
- package/dist/cjs/structurallyEqual.js.map +1 -0
- package/dist/cjs/useStructuralValue.js +20 -0
- package/dist/cjs/useStructuralValue.js.map +1 -0
- package/dist/esm/chart/ChartGallery.stories.d.ts +14 -0
- package/dist/esm/chart/ChartGallery.stories.d.ts.map +1 -0
- package/dist/esm/chart/ChartGallery.stories.js +47 -0
- package/dist/esm/chart/ChartGallery.stories.js.map +1 -0
- package/dist/esm/chart/ChartType.d.ts +11 -0
- package/dist/esm/chart/ChartType.d.ts.map +1 -0
- package/dist/esm/chart/ChartType.js +16 -0
- package/dist/esm/chart/ChartType.js.map +1 -0
- package/dist/esm/chart/ChartTypeResolution.d.ts +10 -0
- package/dist/esm/chart/ChartTypeResolution.d.ts.map +1 -0
- package/dist/esm/chart/ChartTypeResolution.js +2 -0
- package/dist/esm/chart/ChartTypeResolution.js.map +1 -0
- package/dist/esm/chart/PrimeChart.d.ts +3 -0
- package/dist/esm/chart/PrimeChart.d.ts.map +1 -0
- package/dist/esm/chart/PrimeChart.js +90 -0
- package/dist/esm/chart/PrimeChart.js.map +1 -0
- package/dist/esm/chart/chartHasData.d.ts +2 -0
- package/dist/esm/chart/chartHasData.d.ts.map +1 -0
- package/dist/esm/chart/chartHasData.js +22 -0
- package/dist/esm/chart/chartHasData.js.map +1 -0
- package/dist/esm/chart/chartTypeChoices.d.ts +3 -0
- package/dist/esm/chart/chartTypeChoices.d.ts.map +1 -0
- package/dist/esm/chart/chartTypeChoices.js +41 -0
- package/dist/esm/chart/chartTypeChoices.js.map +1 -0
- package/dist/esm/chart/index.d.ts +5 -0
- package/dist/esm/chart/index.d.ts.map +1 -0
- package/dist/esm/chart/index.js +5 -0
- package/dist/esm/chart/index.js.map +1 -0
- package/dist/esm/chart/resolveChartType.d.ts +6 -0
- package/dist/esm/chart/resolveChartType.d.ts.map +1 -0
- package/dist/esm/chart/resolveChartType.js +66 -0
- package/dist/esm/chart/resolveChartType.js.map +1 -0
- package/dist/esm/chart/useChart.d.ts +4 -0
- package/dist/esm/chart/useChart.d.ts.map +1 -0
- package/dist/esm/chart/useChart.js +60 -0
- package/dist/esm/chart/useChart.js.map +1 -0
- package/dist/esm/form/FormGallery.stories.d.ts.map +1 -1
- package/dist/esm/form/FormGallery.stories.js +8 -0
- package/dist/esm/form/FormGallery.stories.js.map +1 -1
- package/dist/esm/form/MultiStateGlyph.d.ts +8 -0
- package/dist/esm/form/MultiStateGlyph.d.ts.map +1 -0
- package/dist/esm/form/MultiStateGlyph.js +57 -0
- package/dist/esm/form/MultiStateGlyph.js.map +1 -0
- package/dist/esm/form/MultiStateOption.d.ts +7 -0
- package/dist/esm/form/MultiStateOption.d.ts.map +1 -0
- package/dist/esm/form/MultiStateOption.js +2 -0
- package/dist/esm/form/MultiStateOption.js.map +1 -0
- package/dist/esm/form/PrimeMultiStateCheckbox.d.ts +3 -0
- package/dist/esm/form/PrimeMultiStateCheckbox.d.ts.map +1 -0
- package/dist/esm/form/PrimeMultiStateCheckbox.js +121 -0
- package/dist/esm/form/PrimeMultiStateCheckbox.js.map +1 -0
- package/dist/esm/form/index.d.ts +1 -0
- package/dist/esm/form/index.d.ts.map +1 -1
- package/dist/esm/form/index.js +1 -0
- package/dist/esm/form/index.js.map +1 -1
- package/dist/esm/form/multiStateOptions.d.ts +4 -0
- package/dist/esm/form/multiStateOptions.d.ts.map +1 -0
- package/dist/esm/form/multiStateOptions.js +75 -0
- package/dist/esm/form/multiStateOptions.js.map +1 -0
- package/dist/esm/form/multiStateStates.d.ts +4 -0
- package/dist/esm/form/multiStateStates.d.ts.map +1 -0
- package/dist/esm/form/multiStateStates.js +30 -0
- package/dist/esm/form/multiStateStates.js.map +1 -0
- package/dist/esm/form/useMultiStateSelection.d.ts +6 -0
- package/dist/esm/form/useMultiStateSelection.d.ts.map +1 -0
- package/dist/esm/form/useMultiStateSelection.js +49 -0
- package/dist/esm/form/useMultiStateSelection.js.map +1 -0
- package/dist/esm/index.d.ts +2 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +6 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/primeReactComponents.d.ts.map +1 -1
- package/dist/esm/primeReactComponents.js +5 -0
- package/dist/esm/primeReactComponents.js.map +1 -1
- package/dist/esm/primeReactDescriptors.d.ts +3 -0
- package/dist/esm/primeReactDescriptors.d.ts.map +1 -0
- package/dist/esm/primeReactDescriptors.js +155 -0
- package/dist/esm/primeReactDescriptors.js.map +1 -0
- package/dist/esm/primeReactPackage.d.ts.map +1 -1
- package/dist/esm/primeReactPackage.js +4 -0
- package/dist/esm/primeReactPackage.js.map +1 -1
- package/dist/esm/properties.d.ts +1 -0
- package/dist/esm/properties.d.ts.map +1 -1
- package/dist/esm/properties.js +11 -1
- package/dist/esm/properties.js.map +1 -1
- package/dist/esm/structurallyEqual.d.ts +2 -0
- package/dist/esm/structurallyEqual.d.ts.map +1 -0
- package/dist/esm/structurallyEqual.js +25 -0
- package/dist/esm/structurallyEqual.js.map +1 -0
- package/dist/esm/tsconfig.tsbuildinfo +1 -1
- package/dist/esm/useStructuralValue.d.ts +2 -0
- package/dist/esm/useStructuralValue.d.ts.map +1 -0
- package/dist/esm/useStructuralValue.js +18 -0
- package/dist/esm/useStructuralValue.js.map +1 -0
- package/form/FormGallery.stories.tsx +8 -0
- package/form/MultiStateGlyph.tsx +55 -0
- package/form/MultiStateOption.ts +17 -0
- package/form/PrimeMultiStateCheckbox.tsx +101 -0
- package/form/index.ts +1 -0
- package/form/multiStateOptions.ts +78 -0
- package/form/multiStateStates.ts +23 -0
- package/form/useMultiStateSelection.ts +48 -0
- package/index.ts +2 -0
- package/package.json +17 -7
- package/primeReactComponents.ts +4 -0
- package/primeReactDescriptors.ts +48 -0
- package/primeReactPackage.ts +4 -2
- package/properties.ts +14 -0
- package/structurallyEqual.ts +29 -0
- package/useStructuralValue.ts +17 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { SceneElementView } from '@cratis/scene.react';
|
|
2
|
+
import { primeReactComponents } from '../primeReactComponents';
|
|
3
|
+
import { sceneComponent } from '../storyElements';
|
|
4
|
+
const meta = {
|
|
5
|
+
title: 'PrimeReact/Chart',
|
|
6
|
+
component: SceneElementView,
|
|
7
|
+
tags: ['autodocs'],
|
|
8
|
+
};
|
|
9
|
+
export default meta;
|
|
10
|
+
const salesData = {
|
|
11
|
+
labels: ['January', 'February', 'March'],
|
|
12
|
+
datasets: [{ label: 'Sales', data: [12, 19, 8], backgroundColor: '#6366f1' }],
|
|
13
|
+
};
|
|
14
|
+
export const Bar = {
|
|
15
|
+
args: {
|
|
16
|
+
element: sceneComponent('sales', 'chart', {
|
|
17
|
+
type: 'bar', data: salesData, options: { maintainAspectRatio: false }, style: { height: 240 }, ariaLabel: 'Monthly sales',
|
|
18
|
+
}),
|
|
19
|
+
registry: primeReactComponents,
|
|
20
|
+
resolveBinding: () => undefined,
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
export const MigratedWithoutData = {
|
|
24
|
+
args: {
|
|
25
|
+
element: sceneComponent('legacy-empty', 'chart', { type: 0, style: { height: 72 }, ariaLabel: 'Migrated chart without data', legacyType: 'PrimeReact.Chart' }),
|
|
26
|
+
registry: primeReactComponents,
|
|
27
|
+
resolveBinding: () => undefined,
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
export const UnsupportedType = {
|
|
31
|
+
args: {
|
|
32
|
+
element: sceneComponent('unsupported', 'chart', { type: 8, data: salesData }),
|
|
33
|
+
registry: primeReactComponents,
|
|
34
|
+
resolveBinding: () => undefined,
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
export const MigratedLegacyBar = {
|
|
38
|
+
args: {
|
|
39
|
+
element: sceneComponent('legacy-sales', 'chart', {
|
|
40
|
+
type: 0, data: salesData, options: { maintainAspectRatio: false }, style: { height: 240 }, ariaLabel: 'Migrated monthly sales',
|
|
41
|
+
legacyType: 'PrimeReact.Chart', legacyExtras: { canvas: { x: 256, y: 184 } },
|
|
42
|
+
}),
|
|
43
|
+
registry: primeReactComponents,
|
|
44
|
+
resolveBinding: () => undefined,
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
//# sourceMappingURL=ChartGallery.stories.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChartGallery.stories.js","sourceRoot":"","sources":["../../../chart/ChartGallery.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,MAAM,IAAI,GAAG;IACT,KAAK,EAAE,kBAAkB;IACzB,SAAS,EAAE,gBAAgB;IAC3B,IAAI,EAAE,CAAC,UAAU,CAAC;CACmB,CAAC;AAE1C,eAAe,IAAI,CAAC;AAKpB,MAAM,SAAS,GAAG;IACd,MAAM,EAAE,CAAC,SAAS,EAAE,UAAU,EAAE,OAAO,CAAC;IACxC,QAAQ,EAAE,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,eAAe,EAAE,SAAS,EAAE,CAAC;CAChF,CAAC;AAEF,MAAM,CAAC,MAAM,GAAG,GAAU;IACtB,IAAI,EAAE;QACF,OAAO,EAAE,cAAc,CAAC,OAAO,EAAE,OAAO,EAAE;YACtC,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,EAAE,mBAAmB,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,EAAE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@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChartType.d.ts","sourceRoot":"","sources":["../../../chart/ChartType.ts"],"names":[],"mappings":"AAIA,oBAAY,SAAS;IACjB,GAAG,QAAQ;IACX,IAAI,SAAS;IACb,GAAG,QAAQ;IACX,QAAQ,aAAa;IACrB,SAAS,cAAc;IACvB,KAAK,UAAU;IACf,MAAM,WAAW;IACjB,OAAO,YAAY;CACtB"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
2
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
3
|
+
/** The canonical names of the Chart.js chart types Scene's `chart` component supports. */ var ChartType = /*#__PURE__*/ function(ChartType) {
|
|
4
|
+
ChartType["Bar"] = "bar";
|
|
5
|
+
ChartType["Line"] = "line";
|
|
6
|
+
ChartType["Pie"] = "pie";
|
|
7
|
+
ChartType["Doughnut"] = "doughnut";
|
|
8
|
+
ChartType["PolarArea"] = "polarArea";
|
|
9
|
+
ChartType["Radar"] = "radar";
|
|
10
|
+
ChartType["Bubble"] = "bubble";
|
|
11
|
+
ChartType["Scatter"] = "scatter";
|
|
12
|
+
return ChartType;
|
|
13
|
+
}({});
|
|
14
|
+
|
|
15
|
+
export { ChartType };
|
|
16
|
+
//# sourceMappingURL=ChartType.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChartType.js","sources":["../../../chart/ChartType.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\n/** The canonical names of the Chart.js chart types Scene's `chart` component supports. */\nexport enum ChartType {\n Bar = 'bar',\n Line = 'line',\n Pie = 'pie',\n Doughnut = 'doughnut',\n PolarArea = 'polarArea',\n Radar = 'radar',\n Bubble = 'bubble',\n Scatter = 'scatter',\n}\n"],"names":["ChartType"],"mappings":"AAAA;AACA;AAEA,2FACO,IAAKA,SAAAA,iBAAAA,SAAAA,SAAAA,EAAAA;;;;;;;;;AAAAA,IAAAA,OAAAA,SAAAA;AASX,CAAA,CAAA,EAAA;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChartTypeResolution.d.ts","sourceRoot":"","sources":["../../../chart/ChartTypeResolution.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAQxC,MAAM,MAAM,mBAAmB,GACzB;IAAE,OAAO,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,SAAS,CAAA;CAAE,GAClC;IAAE,OAAO,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChartTypeResolution.js","sourceRoot":"","sources":["../../../chart/ChartTypeResolution.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PrimeChart.d.ts","sourceRoot":"","sources":["../../../chart/PrimeChart.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAuB/D,wBAAgB,UAAU,CAAC,EAAE,OAAO,EAAE,YAAY,EAAE,EAAE,wBAAwB,+BAiC7E"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { useRef, useMemo } from 'react';
|
|
3
|
+
import { recordProperty, booleanProperty, stringProperty } from '../properties.js';
|
|
4
|
+
import { useStructuralValue } from '../useStructuralValue.js';
|
|
5
|
+
import { chartHasData } from './chartHasData.js';
|
|
6
|
+
import { resolveChartType } from './resolveChartType.js';
|
|
7
|
+
import { useChart } from './useChart.js';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* The `PrimeReact:chart` component, rendered by Chart.js because PrimeReact 11 no longer ships its
|
|
11
|
+
* former Chart.js wrapper.
|
|
12
|
+
*
|
|
13
|
+
* Three states are explicit rather than a blank canvas: an unsupported `type` is reported (the right chart
|
|
14
|
+
* cannot be guessed), a chart with no data points shows its `emptyLabel` (data is never invented), and a
|
|
15
|
+
* chart Chart.js could not draw says why. Only a chart with data and a supported type reaches Chart.js.
|
|
16
|
+
*
|
|
17
|
+
* Chart.js is an optional peer dependency of this package: a host that renders charts must install
|
|
18
|
+
* `chart.js` itself. The chart rebuilds only when its resolved type, data or options change in content -
|
|
19
|
+
* every edit to a Scene document clones the whole document, and a clone with equal content is not a change.
|
|
20
|
+
*
|
|
21
|
+
* The chart fills the authored size: `maintainAspectRatio` defaults to `false` here (Chart.js defaults to
|
|
22
|
+
* `true`, which shrinks the chart inside its box) and an authored `options.maintainAspectRatio` wins. The
|
|
23
|
+
* `responsive` property is authoritative over `options.responsive` when both are set.
|
|
24
|
+
*/ function PrimeChart({ element, interactions }) {
|
|
25
|
+
const canvas = useRef(null);
|
|
26
|
+
const resolution = resolveChartType(element);
|
|
27
|
+
const data = useStructuralValue(recordProperty(element, 'data'));
|
|
28
|
+
const options = useStructuralValue(recordProperty(element, 'options'));
|
|
29
|
+
const style = recordProperty(element, 'style');
|
|
30
|
+
const responsive = booleanProperty(element, 'responsive', options?.responsive ?? true);
|
|
31
|
+
const ariaLabel = stringProperty(element, 'ariaLabel', element.name || 'Chart');
|
|
32
|
+
const emptyLabel = stringProperty(element, 'emptyLabel', 'No chart data');
|
|
33
|
+
const hasData = chartHasData(data);
|
|
34
|
+
const type = resolution.isValid ? resolution.type : undefined;
|
|
35
|
+
const enabled = type !== undefined && hasData;
|
|
36
|
+
const configuration = useMemo(()=>({
|
|
37
|
+
type,
|
|
38
|
+
data: data ?? {
|
|
39
|
+
datasets: []
|
|
40
|
+
},
|
|
41
|
+
options: {
|
|
42
|
+
maintainAspectRatio: false,
|
|
43
|
+
...options,
|
|
44
|
+
responsive
|
|
45
|
+
}
|
|
46
|
+
}), [
|
|
47
|
+
type,
|
|
48
|
+
data,
|
|
49
|
+
options,
|
|
50
|
+
responsive
|
|
51
|
+
]);
|
|
52
|
+
const failure = useChart(canvas, configuration, enabled);
|
|
53
|
+
return /*#__PURE__*/ jsxs("div", {
|
|
54
|
+
"data-scene-id": element.id,
|
|
55
|
+
"data-scene-component": "chart",
|
|
56
|
+
style: {
|
|
57
|
+
position: 'relative',
|
|
58
|
+
width: element.size.width ?? '100%',
|
|
59
|
+
height: element.size.height ?? '100%',
|
|
60
|
+
...style
|
|
61
|
+
},
|
|
62
|
+
...interactions,
|
|
63
|
+
children: [
|
|
64
|
+
!resolution.isValid && /*#__PURE__*/ jsx("div", {
|
|
65
|
+
role: "alert",
|
|
66
|
+
"data-scene-state": "unsupported-type",
|
|
67
|
+
children: resolution.message
|
|
68
|
+
}),
|
|
69
|
+
resolution.isValid && !hasData && /*#__PURE__*/ jsx("div", {
|
|
70
|
+
role: "status",
|
|
71
|
+
"data-scene-state": "empty",
|
|
72
|
+
children: emptyLabel
|
|
73
|
+
}),
|
|
74
|
+
failure !== undefined && /*#__PURE__*/ jsx("div", {
|
|
75
|
+
role: "alert",
|
|
76
|
+
"data-scene-state": "unavailable",
|
|
77
|
+
children: `The chart could not be drawn: ${failure}`
|
|
78
|
+
}),
|
|
79
|
+
enabled && /*#__PURE__*/ jsx("canvas", {
|
|
80
|
+
ref: canvas,
|
|
81
|
+
role: "img",
|
|
82
|
+
"aria-label": ariaLabel,
|
|
83
|
+
hidden: failure !== undefined
|
|
84
|
+
})
|
|
85
|
+
]
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export { PrimeChart };
|
|
90
|
+
//# sourceMappingURL=PrimeChart.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PrimeChart.js","sources":["../../../chart/PrimeChart.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { CSSProperties, useMemo, useRef } from 'react';\nimport type { ChartConfiguration, ChartData, ChartOptions } from 'chart.js';\nimport { RegisteredComponentProps } from '@cratis/scene.react';\nimport { booleanProperty, recordProperty, stringProperty } from '../properties';\nimport { useStructuralValue } from '../useStructuralValue';\nimport { chartHasData } from './chartHasData';\nimport { resolveChartType } from './resolveChartType';\nimport { useChart } from './useChart';\n\n/**\n * The `PrimeReact:chart` component, rendered by Chart.js because PrimeReact 11 no longer ships its\n * former Chart.js wrapper.\n *\n * Three states are explicit rather than a blank canvas: an unsupported `type` is reported (the right chart\n * cannot be guessed), a chart with no data points shows its `emptyLabel` (data is never invented), and a\n * chart Chart.js could not draw says why. Only a chart with data and a supported type reaches Chart.js.\n *\n * Chart.js is an optional peer dependency of this package: a host that renders charts must install\n * `chart.js` itself. The chart rebuilds only when its resolved type, data or options change in content -\n * every edit to a Scene document clones the whole document, and a clone with equal content is not a change.\n *\n * The chart fills the authored size: `maintainAspectRatio` defaults to `false` here (Chart.js defaults to\n * `true`, which shrinks the chart inside its box) and an authored `options.maintainAspectRatio` wins. The\n * `responsive` property is authoritative over `options.responsive` when both are set.\n */\nexport function PrimeChart({ element, interactions }: RegisteredComponentProps) {\n const canvas = useRef<HTMLCanvasElement>(null);\n const resolution = resolveChartType(element);\n const data = useStructuralValue(recordProperty(element, 'data') as ChartData | undefined);\n const options = useStructuralValue(recordProperty(element, 'options') as ChartOptions | undefined);\n const style = recordProperty(element, 'style') as CSSProperties | undefined;\n const responsive = booleanProperty(element, 'responsive', options?.responsive ?? true);\n const ariaLabel = stringProperty(element, 'ariaLabel', element.name || 'Chart');\n const emptyLabel = stringProperty(element, 'emptyLabel', 'No chart data');\n const hasData = chartHasData(data);\n const type = resolution.isValid ? resolution.type : undefined;\n const enabled = type !== undefined && hasData;\n\n const configuration = useMemo(() => ({\n type,\n data: data ?? { datasets: [] },\n options: { maintainAspectRatio: false, ...options, responsive },\n }) as unknown as ChartConfiguration, [type, data, options, responsive]);\n\n const failure = useChart(canvas, configuration, enabled);\n\n return (\n <div\n data-scene-id={element.id}\n data-scene-component='chart'\n style={{ position: 'relative', width: element.size.width ?? '100%', height: element.size.height ?? '100%', ...style }}\n {...interactions}>\n {!resolution.isValid && <div role='alert' data-scene-state='unsupported-type'>{resolution.message}</div>}\n {resolution.isValid && !hasData && <div role='status' data-scene-state='empty'>{emptyLabel}</div>}\n {failure !== undefined && <div role='alert' data-scene-state='unavailable'>{`The chart could not be drawn: ${failure}`}</div>}\n {enabled && <canvas ref={canvas} role='img' aria-label={ariaLabel} hidden={failure !== undefined} />}\n </div>\n );\n}\n"],"names":["PrimeChart","element","interactions","canvas","useRef","resolution","resolveChartType","data","useStructuralValue","recordProperty","options","style","responsive","booleanProperty","ariaLabel","stringProperty","name","emptyLabel","hasData","chartHasData","type","isValid","undefined","enabled","configuration","useMemo","datasets","maintainAspectRatio","failure","useChart","_jsxs","div","data-scene-id","id","data-scene-component","position","width","size","height","_jsx","role","data-scene-state","message","ref","aria-label","hidden"],"mappings":";;;;;;;;AAYA;;;;;;;;;;;;;;;AAeC,IACM,SAASA,UAAAA,CAAW,EAAEC,OAAO,EAAEC,YAAY,EAA4B,EAAA;AAC1E,IAAA,MAAMC,SAASC,MAAAA,CAA0B,IAAA,CAAA;AACzC,IAAA,MAAMC,aAAaC,gBAAAA,CAAiBL,OAAAA,CAAAA;IACpC,MAAMM,IAAAA,GAAOC,kBAAAA,CAAmBC,cAAAA,CAAeR,OAAAA,EAAS,MAAA,CAAA,CAAA;IACxD,MAAMS,OAAAA,GAAUF,kBAAAA,CAAmBC,cAAAA,CAAeR,OAAAA,EAAS,SAAA,CAAA,CAAA;IAC3D,MAAMU,KAAAA,GAAQF,eAAeR,OAAAA,EAAS,OAAA,CAAA;AACtC,IAAA,MAAMW,UAAAA,GAAaC,eAAAA,CAAgBZ,OAAAA,EAAS,YAAA,EAAcS,SAASE,UAAAA,IAAc,IAAA,CAAA;AACjF,IAAA,MAAME,YAAYC,cAAAA,CAAed,OAAAA,EAAS,WAAA,EAAaA,OA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A,EAAAA;gBAAIS,IAAAA,EAAK,OAAA;gBAAQC,kBAAAA,EAAiB,kBAAA;AAAoBpC,gBAAAA,QAAAA,EAAAA,UAAAA,CAAWqC;;AACzFrC,YAAAA,UAAAA,CAAWgB,OAAO,IAAI,CAACH,OAAAA,kBAAWqB,GAAA,CAACR,KAAAA,EAAAA;gBAAIS,IAAAA,EAAK,QAAA;gBAASC,kBAAAA,EAAiB,OAAA;AAASxB,gBAAAA,QAAAA,EAAAA;;AAC/EW,YAAAA,OAAAA,KAAYN,2BAAaiB,GAAA,CAACR,KAAAA,EAAAA;gBAAIS,IAAAA,EAAK,OAAA;gBAAQC,kBAAAA,EAAiB,aAAA;0BAAe,CAAC,8BAA8B,EAAEb,OAAAA,CAAAA;;AAC5GL,YAAAA,OAAAA,kBAAWgB,GAAA,CAACpC,QAAAA,EAAAA;gBAAOwC,GAAAA,EAAKxC,MAAAA;gBAAQqC,IAAAA,EAAK,KAAA;gBAAMI,YAAAA,EAAY9B,SAAAA;AAAW+B,gBAAAA,MAAAA,EAAQjB,OAAAA,KAAYN;;;;AAGnG;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chartHasData.d.ts","sourceRoot":"","sources":["../../../chart/chartHasData.ts"],"names":[],"mappings":"AAUA,wBAAgB,YAAY,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAWnD"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
2
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
3
|
+
/**
|
|
4
|
+
* Whether chart data holds at least one data point to draw.
|
|
5
|
+
*
|
|
6
|
+
* Datasets whose `data` is empty (or absent) draw nothing but axes, so the chart reports it instead.
|
|
7
|
+
* A dataset may also give its points as keyed records (Chart.js `parsing` over an object), which counts
|
|
8
|
+
* when it has any keys.
|
|
9
|
+
*/ function chartHasData(data) {
|
|
10
|
+
if (data === null || typeof data !== 'object') return false;
|
|
11
|
+
const datasets = data.datasets;
|
|
12
|
+
if (!Array.isArray(datasets)) return false;
|
|
13
|
+
return datasets.some((dataset)=>{
|
|
14
|
+
if (dataset === null || typeof dataset !== 'object') return false;
|
|
15
|
+
const points = dataset.data;
|
|
16
|
+
if (Array.isArray(points)) return points.length > 0;
|
|
17
|
+
return points !== null && typeof points === 'object' && Object.keys(points).length > 0;
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export { chartHasData };
|
|
22
|
+
//# sourceMappingURL=chartHasData.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chartHasData.js","sources":["../../../chart/chartHasData.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\n/**\n * Whether chart data holds at least one data point to draw.\n *\n * Datasets whose `data` is empty (or absent) draw nothing but axes, so the chart reports it instead.\n * A dataset may also give its points as keyed records (Chart.js `parsing` over an object), which counts\n * when it has any keys.\n */\nexport function chartHasData(data: unknown): boolean {\n if (data === null || typeof data !== 'object') return false;\n const datasets = (data as Record<string, unknown>).datasets;\n if (!Array.isArray(datasets)) return false;\n\n return datasets.some(dataset => {\n if (dataset === null || typeof dataset !== 'object') return false;\n const points = (dataset as Record<string, unknown>).data;\n if (Array.isArray(points)) return points.length > 0;\n return points !== null && typeof points === 'object' && Object.keys(points).length > 0;\n });\n}\n"],"names":["chartHasData","data","datasets","Array","isArray","some","dataset","points","length","Object","keys"],"mappings":"AAAA;AACA;AAEA;;;;;;IAOO,SAASA,YAAAA,CAAaC,IAAa,EAAA;AACtC,IAAA,IAAIA,IAAAA,KAAS,IAAA,IAAQ,OAAOA,IAAAA,KAAS,UAAU,OAAO,KAAA;IACtD,MAAMC,QAAAA,GAAW,IAACD,CAAiCC,QAAQ;AAC3D,IAAA,IAAI,CAACC,KAAAA,CAAMC,OAAO,CAACF,WAAW,OAAO,KAAA;IAErC,OAAOA,QAAAA,CAASG,IAAI,CAACC,CAAAA,OAAAA,GAAAA;AACjB,QAAA,IAAIA,OAAAA,KAAY,IAAA,IAAQ,OAAOA,OAAAA,KAAY,UAAU,OAAO,KAAA;QAC5D,MAAMC,MAAAA,GAAS,OAACD,CAAoCL,IAAI;AACxD,QAAA,IAAIE,MAAMC,OAAO,CAACG,SAAS,OAAOA,MAAAA,CAAOC,MAAM,GAAG,CAAA;QAClD,OAAOD,MAAAA,KAAW,IAAA,IAAQ,OAAOA,MAAAA,KAAW,QAAA,IAAYE,OAAOC,IAAI,CAACH,MAAAA,CAAAA,CAAQC,MAAM,GAAG,CAAA;AACzF,IAAA,CAAA,CAAA;AACJ;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chartTypeChoices.d.ts","sourceRoot":"","sources":["../../../chart/chartTypeChoices.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAuBrD,eAAO,MAAM,gBAAgB,EAAE,cAAc,EAI5C,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { ChartType } from './ChartType.js';
|
|
2
|
+
import { legacyChartTypes } from './resolveChartType.js';
|
|
3
|
+
|
|
4
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
5
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
6
|
+
const chartTypeLabels = {
|
|
7
|
+
[ChartType.Bar]: 'Bar',
|
|
8
|
+
[ChartType.Line]: 'Line',
|
|
9
|
+
[ChartType.Pie]: 'Pie',
|
|
10
|
+
[ChartType.Doughnut]: 'Doughnut',
|
|
11
|
+
[ChartType.PolarArea]: 'Polar area',
|
|
12
|
+
[ChartType.Radar]: 'Radar',
|
|
13
|
+
[ChartType.Bubble]: 'Bubble',
|
|
14
|
+
[ChartType.Scatter]: 'Scatter'
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* The chart type choices: the stable names new documents use, then the ordinals migrated documents carry,
|
|
18
|
+
* then the Pascal case member names of the original .NET enum that a serialized enum produces.
|
|
19
|
+
* A migrated chart stores its original `type`; offering every form the renderer accepts keeps that stored
|
|
20
|
+
* value valid (and its type visible and re-selectable) without rewriting it to another form behind the
|
|
21
|
+
* author's back. The choices are the same set `resolveChartType` accepts, so what the renderer draws is
|
|
22
|
+
* exactly what the descriptor allows.
|
|
23
|
+
*/ const chartTypeChoices = [
|
|
24
|
+
...Object.values(ChartType).map((type)=>({
|
|
25
|
+
value: type,
|
|
26
|
+
label: chartTypeLabels[type]
|
|
27
|
+
})),
|
|
28
|
+
...legacyChartTypes.map((type, ordinal)=>({
|
|
29
|
+
value: ordinal,
|
|
30
|
+
label: `${chartTypeLabels[type]} (legacy ${ordinal})`,
|
|
31
|
+
description: `The ordinal ${ordinal} of the original chart type enum, as stored by migrated documents.`
|
|
32
|
+
})),
|
|
33
|
+
...Object.keys(ChartType).map((name)=>({
|
|
34
|
+
value: name,
|
|
35
|
+
label: `${chartTypeLabels[ChartType[name]]} (legacy name ${name})`,
|
|
36
|
+
description: `The member name ${name} of the original chart type enum, as a serialized enum stores it.`
|
|
37
|
+
}))
|
|
38
|
+
];
|
|
39
|
+
|
|
40
|
+
export { chartTypeChoices };
|
|
41
|
+
//# sourceMappingURL=chartTypeChoices.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chartTypeChoices.js","sources":["../../../chart/chartTypeChoices.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { PropertyChoice } from '@cratis/scene.model';\nimport { ChartType } from './ChartType';\nimport { legacyChartTypes } from './resolveChartType';\n\nconst chartTypeLabels: Record<ChartType, string> = {\n [ChartType.Bar]: 'Bar',\n [ChartType.Line]: 'Line',\n [ChartType.Pie]: 'Pie',\n [ChartType.Doughnut]: 'Doughnut',\n [ChartType.PolarArea]: 'Polar area',\n [ChartType.Radar]: 'Radar',\n [ChartType.Bubble]: 'Bubble',\n [ChartType.Scatter]: 'Scatter',\n};\n\n/**\n * The chart type choices: the stable names new documents use, then the ordinals migrated documents carry,\n * then the Pascal case member names of the original .NET enum that a serialized enum produces.\n * A migrated chart stores its original `type`; offering every form the renderer accepts keeps that stored\n * value valid (and its type visible and re-selectable) without rewriting it to another form behind the\n * author's back. The choices are the same set `resolveChartType` accepts, so what the renderer draws is\n * exactly what the descriptor allows.\n */\nexport const chartTypeChoices: PropertyChoice[] = [\n ...Object.values(ChartType).map(type => ({ value: type, label: chartTypeLabels[type] })),\n ...legacyChartTypes.map((type, ordinal) => ({ value: ordinal, label: `${chartTypeLabels[type]} (legacy ${ordinal})`, description: `The ordinal ${ordinal} of the original chart type enum, as stored by migrated documents.` })),\n ...(Object.keys(ChartType) as (keyof typeof ChartType)[]).map(name => ({ value: name, label: `${chartTypeLabels[ChartType[name]]} (legacy name ${name})`, description: `The member name ${name} of the original chart type enum, as a serialized enum stores it.` })),\n];\n\n"],"names":["chartTypeLabels","ChartType","Bar","Line","Pie","Doughnut","PolarArea","Radar","Bubble","Scatter","chartTypeChoices","Object","values","map","type","value","label","legacyChartTypes","ordinal","description","keys","name"],"mappings":";;;AAAA;AACA;AAMA,MAAMA,eAAAA,GAA6C;IAC/C,CAACC,SAAAA,CAAUC,GAAG,GAAG,KAAA;IACjB,CAACD,SAAAA,CAAUE,IAAI,GAAG,MAAA;IAClB,CAACF,SAAAA,CAAUG,GAAG,GAAG,KAAA;IACjB,CAACH,SAAAA,CAAUI,QAAQ,GAAG,UAAA;IACtB,CAACJ,SAAAA,CAAUK,SAAS,GAAG,YAAA;IACvB,CAACL,SAAAA,CAAUM,KAAK,GAAG,OAAA;IACnB,CAACN,SAAAA,CAAUO,MAAM,GAAG,QAAA;IACpB,CAACP,SAAAA,CAAUQ,OAAO,GAAG;AACzB,CAAA;AAEA;;;;;;;UAQaC,gBAAAA,GAAqC;AAC3CC,IAAAA,GAAAA,MAAAA,CAAOC,MAAM,CAACX,SAAAA,CAAAA,CAAWY,GAAG,CAACC,CAAAA,QAAS;YAAEC,KAAAA,EAAOD,IAAAA;YAAME,KAAAA,EAAOhB,eAAe,CAACc,IAAAA;SAAM,CAAA,CAAA;AAClFG,IAAAA,GAAAA,gBAAAA,CAAiBJ,GAAG,CAAC,CAACC,IAAAA,EAAMI,WAAa;YAAEH,KAAAA,EAAOG,OAAAA;YAASF,KAAAA,EAAO,CAAA,EAAGhB,eAAe,CAACc,IAAAA,CAAK,CAAC,SAAS,EAAEI,OAAAA,CAAQ,CAAC,CAAC;AAAEC,YAAAA,WAAAA,EAAa,CAAC,YAAY,EAAED,OAAAA,CAAQ,kEAAkE;SAAE,CAAA,CAAA;OAC1N,MAACP,CAAOS,IAAI,CAACnB,SAAAA,CAAAA,CAA0CY,GAAG,CAACQ,CAAAA,QAAS;YAAEN,KAAAA,EAAOM,IAAAA;AAAML,YAAAA,KAAAA,EAAO,CAAA,EAAGhB,eAAe,CAACC,SAAS,CAACoB,IAAAA,CAAK,CAAC,CAAC,cAAc,EAAEA,IAAAA,CAAK,CAAC,CAAC;AAAEF,YAAAA,WAAAA,EAAa,CAAC,gBAAgB,EAAEE,IAAAA,CAAK,iEAAiE;SAAE,CAAA;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../chart/index.ts"],"names":[],"mappings":"AAGA,cAAc,aAAa,CAAC;AAC5B,cAAc,uBAAuB,CAAC;AACtC,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../chart/index.ts"],"names":[],"mappings":"AAGA,cAAc,aAAa,CAAC;AAC5B,cAAc,uBAAuB,CAAC;AACtC,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { SceneElement } from '@cratis/scene.model';
|
|
2
|
+
import { ChartType } from './ChartType';
|
|
3
|
+
import { ChartTypeResolution } from './ChartTypeResolution';
|
|
4
|
+
export declare const legacyChartTypes: readonly ChartType[];
|
|
5
|
+
export declare function resolveChartType(element: SceneElement): ChartTypeResolution;
|
|
6
|
+
//# sourceMappingURL=resolveChartType.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolveChartType.d.ts","sourceRoot":"","sources":["../../../chart/resolveChartType.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAO5D,eAAO,MAAM,gBAAgB,EAAE,SAAS,SAAS,EAShD,CAAC;AAeF,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,YAAY,GAAG,mBAAmB,CAe3E"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { ChartType } from './ChartType.js';
|
|
2
|
+
|
|
3
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
4
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
5
|
+
/**
|
|
6
|
+
* The ordinals of the original .NET `PrimeReact.Charts.ChartType` enum, in declaration order
|
|
7
|
+
* (`Studio/Source/PrimeReact/Charts/Chart.cs`). Migrated documents keep the ordinal, so the position of
|
|
8
|
+
* each entry here is part of the stored-data contract and must never be reordered.
|
|
9
|
+
*/ const legacyChartTypes = [
|
|
10
|
+
ChartType.Bar,
|
|
11
|
+
ChartType.Line,
|
|
12
|
+
ChartType.Pie,
|
|
13
|
+
ChartType.Doughnut,
|
|
14
|
+
ChartType.PolarArea,
|
|
15
|
+
ChartType.Radar,
|
|
16
|
+
ChartType.Bubble,
|
|
17
|
+
ChartType.Scatter
|
|
18
|
+
];
|
|
19
|
+
/**
|
|
20
|
+
* Resolves an authored chart type to the Chart.js vocabulary.
|
|
21
|
+
*
|
|
22
|
+
* Three forms are accepted, and the stored value is never rewritten:
|
|
23
|
+
* - a canonical Chart.js name from {@link ChartType} (`'polarArea'`), which new documents use;
|
|
24
|
+
* - the ordinal of the original .NET enum (`4`), which migrated documents carry;
|
|
25
|
+
* - the .NET member name in its original Pascal case (`'PolarArea'`), which a JSON serialization of that
|
|
26
|
+
* enum produces.
|
|
27
|
+
*
|
|
28
|
+
* Anything else - an unknown or fractional ordinal, a numeric string, a differently cased name, `null` -
|
|
29
|
+
* resolves to a finding with a message, because the right chart cannot be known. An absent `type` is the
|
|
30
|
+
* one default: the original control defaulted to `Bar`.
|
|
31
|
+
*/ function resolveChartType(element) {
|
|
32
|
+
const value = element.properties.type;
|
|
33
|
+
if (value === undefined) return {
|
|
34
|
+
isValid: true,
|
|
35
|
+
type: ChartType.Bar
|
|
36
|
+
};
|
|
37
|
+
if (typeof value === 'number') {
|
|
38
|
+
const type = Number.isInteger(value) ? legacyChartTypes[value] : undefined;
|
|
39
|
+
return type === undefined ? unsupported(value) : {
|
|
40
|
+
isValid: true,
|
|
41
|
+
type
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
if (typeof value === 'string') {
|
|
45
|
+
if (Object.values(ChartType).includes(value)) return {
|
|
46
|
+
isValid: true,
|
|
47
|
+
type: value
|
|
48
|
+
};
|
|
49
|
+
if (Object.hasOwn(ChartType, value)) return {
|
|
50
|
+
isValid: true,
|
|
51
|
+
type: ChartType[value]
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
return unsupported(value);
|
|
55
|
+
}
|
|
56
|
+
function unsupported(value) {
|
|
57
|
+
const shown = typeof value === 'string' ? `'${value}'` : JSON.stringify(value) ?? String(value);
|
|
58
|
+
return {
|
|
59
|
+
isValid: false,
|
|
60
|
+
value,
|
|
61
|
+
message: `Unsupported chart type ${shown}. Use one of ${Object.values(ChartType).join(', ')}, or a legacy ordinal from 0 to ${legacyChartTypes.length - 1}.`
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export { legacyChartTypes, resolveChartType };
|
|
66
|
+
//# sourceMappingURL=resolveChartType.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolveChartType.js","sources":["../../../chart/resolveChartType.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { SceneElement } from '@cratis/scene.model';\nimport { ChartType } from './ChartType';\nimport { ChartTypeResolution } from './ChartTypeResolution';\n\n/**\n * The ordinals of the original .NET `PrimeReact.Charts.ChartType` enum, in declaration order\n * (`Studio/Source/PrimeReact/Charts/Chart.cs`). Migrated documents keep the ordinal, so the position of\n * each entry here is part of the stored-data contract and must never be reordered.\n */\nexport const legacyChartTypes: readonly ChartType[] = [\n ChartType.Bar,\n ChartType.Line,\n ChartType.Pie,\n ChartType.Doughnut,\n ChartType.PolarArea,\n ChartType.Radar,\n ChartType.Bubble,\n ChartType.Scatter,\n];\n\n/**\n * Resolves an authored chart type to the Chart.js vocabulary.\n *\n * Three forms are accepted, and the stored value is never rewritten:\n * - a canonical Chart.js name from {@link ChartType} (`'polarArea'`), which new documents use;\n * - the ordinal of the original .NET enum (`4`), which migrated documents carry;\n * - the .NET member name in its original Pascal case (`'PolarArea'`), which a JSON serialization of that\n * enum produces.\n *\n * Anything else - an unknown or fractional ordinal, a numeric string, a differently cased name, `null` -\n * resolves to a finding with a message, because the right chart cannot be known. An absent `type` is the\n * one default: the original control defaulted to `Bar`.\n */\nexport function resolveChartType(element: SceneElement): ChartTypeResolution {\n const value = element.properties.type;\n if (value === undefined) return { isValid: true, type: ChartType.Bar };\n\n if (typeof value === 'number') {\n const type = Number.isInteger(value) ? legacyChartTypes[value] : undefined;\n return type === undefined ? unsupported(value) : { isValid: true, type };\n }\n\n if (typeof value === 'string') {\n if (Object.values(ChartType).includes(value as ChartType)) return { isValid: true, type: value as ChartType };\n if (Object.hasOwn(ChartType, value)) return { isValid: true, type: ChartType[value as keyof typeof ChartType] };\n }\n\n return unsupported(value);\n}\n\nfunction unsupported(value: unknown): ChartTypeResolution {\n const shown = typeof value === 'string' ? `'${value}'` : JSON.stringify(value) ?? String(value);\n return {\n isValid: false,\n value,\n message: `Unsupported chart type ${shown}. Use one of ${Object.values(ChartType).join(', ')}, or a legacy ordinal from 0 to ${legacyChartTypes.length - 1}.`,\n };\n}\n"],"names":["legacyChartTypes","ChartType","Bar","Line","Pie","Doughnut","PolarArea","Radar","Bubble","Scatter","resolveChartType","element","value","properties","type","undefined","isValid","Number","isInteger","unsupported","Object","values","includes","hasOwn","shown","JSON","stringify","String","message","join","length"],"mappings":";;AAAA;AACA;AAMA;;;;UAKaA,gBAAAA,GAAyC;AAClDC,IAAAA,SAAAA,CAAUC,GAAG;AACbD,IAAAA,SAAAA,CAAUE,IAAI;AACdF,IAAAA,SAAAA,CAAUG,GAAG;AACbH,IAAAA,SAAAA,CAAUI,QAAQ;AAClBJ,IAAAA,SAAAA,CAAUK,SAAS;AACnBL,IAAAA,SAAAA,CAAUM,KAAK;AACfN,IAAAA,SAAAA,CAAUO,MAAM;AAChBP,IAAAA,SAAAA,CAAUQ;;AAGd;;;;;;;;;;;;IAaO,SAASC,gBAAAA,CAAiBC,OAAqB,EAAA;AAClD,IAAA,MAAMC,KAAAA,GAAQD,OAAAA,CAAQE,UAAU,CAACC,IAAI;IACrC,IAAIF,KAAAA,KAAUG,WAAW,OAAO;QAAEC,OAAAA,EAAS,IAAA;AAAMF,QAAAA,IAAAA,EAAMb,UAAUC;AAAI,KAAA;IAErE,IAAI,OAAOU,UAAU,QAAA,EAAU;QAC3B,MAAME,IAAAA,GAAOG,OAAOC,SAAS,CAACN,SAASZ,gBAAgB,CAACY,MAAM,GAAGG,SAAAA;QACjE,OAAOD,IAAAA,KAASC,SAAAA,GAAYI,WAAAA,CAAYP,KAAAA,CAAAA,GAAS;YAAEI,OAAAA,EAAS,IAAA;AAAMF,YAAAA;AAAK,SAAA;AAC3E,IAAA;IAEA,IAAI,OAAOF,UAAU,QAAA,EAAU;AAC3B,QAAA,IAAIQ,OAAOC,MAAM,CAACpB,WAAWqB,QAAQ,CAACV,QAAqB,OAAO;YAAEI,OAAAA,EAAS,IAAA;YAAMF,IAAAA,EAAMF;AAAmB,SAAA;AAC5G,QAAA,IAAIQ,MAAAA,CAAOG,MAAM,CAACtB,SAAAA,EAAWW,QAAQ,OAAO;YAAEI,OAAAA,EAAS,IAAA;YAAMF,IAAAA,EAAMb,SAAS,CAACW,KAAAA;AAAiC,SAAA;AAClH,IAAA;AAEA,IAAA,OAAOO,WAAAA,CAAYP,KAAAA,CAAAA;AACvB;AAEA,SAASO,YAAYP,KAAc,EAAA;AAC/B,IAAA,MAAMY,KAAAA,GAAQ,OAAOZ,KAAAA,KAAU,QAAA,GAAW,CAAC,CAAC,EAAEA,KAAAA,CAAM,CAAC,CAAC,GAAGa,IAAAA,CAAKC,SAAS,CAACd,UAAUe,MAAAA,CAAOf,KAAAA,CAAAA;IACzF,OAAO;QACHI,OAAAA,EAAS,KAAA;AACTJ,QAAAA,KAAAA;QACAgB,OAAAA,EAAS,CAAC,uBAAuB,EAAEJ,KAAAA,CAAM,aAAa,EAAEJ,MAAAA,CAAOC,MAAM,CAACpB,SAAAA,CAAAA,CAAW4B,IAAI,CAAC,IAAA,CAAA,CAAM,gCAAgC,EAAE7B,gBAAAA,CAAiB8B,MAAM,GAAG,CAAA,CAAE,CAAC;AAC/J,KAAA;AACJ;;"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { RefObject } from 'react';
|
|
2
|
+
import type { ChartConfiguration } from 'chart.js';
|
|
3
|
+
export declare function useChart(canvas: RefObject<HTMLCanvasElement | null>, configuration: ChartConfiguration, enabled: boolean): string | undefined;
|
|
4
|
+
//# sourceMappingURL=useChart.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useChart.d.ts","sourceRoot":"","sources":["../../../chart/useChart.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAuB,MAAM,OAAO,CAAC;AACvD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAoBnD,wBAAgB,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC,iBAAiB,GAAG,IAAI,CAAC,EAAE,aAAa,EAAE,kBAAkB,EAAE,OAAO,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAoC7I"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { useState, useEffect } from 'react';
|
|
2
|
+
|
|
3
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
4
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
5
|
+
/**
|
|
6
|
+
* Draws a Chart.js chart on a canvas and owns its lifetime.
|
|
7
|
+
*
|
|
8
|
+
* Chart.js loads only after the canvas has mounted, which keeps server rendering independent of browser
|
|
9
|
+
* globals. The chart is destroyed before it is rebuilt and when the component unmounts - Chart.js owns
|
|
10
|
+
* listeners and resize observers, so a retained instance would draw twice and leak them.
|
|
11
|
+
*
|
|
12
|
+
* A chart that cannot be drawn is reported rather than left as a blank canvas: `chart.js` not being
|
|
13
|
+
* installed (it is an optional peer dependency), a failed dynamic import and a rejected configuration all
|
|
14
|
+
* come back as the returned failure message. A rejected configuration is released from the canvas as well,
|
|
15
|
+
* so correcting it draws again on the same canvas.
|
|
16
|
+
*
|
|
17
|
+
* @param canvas The canvas to draw on. It must be rendered whenever `enabled` is true.
|
|
18
|
+
* @param configuration The Chart.js configuration. Pass a structurally stable value (see
|
|
19
|
+
* {@link useStructuralValue}); a new identity rebuilds the chart.
|
|
20
|
+
* @param enabled Whether there is something to draw.
|
|
21
|
+
* @returns The reason the chart could not be drawn, or `undefined`.
|
|
22
|
+
*/ function useChart(canvas, configuration, enabled) {
|
|
23
|
+
const [failure, setFailure] = useState(undefined);
|
|
24
|
+
useEffect(()=>{
|
|
25
|
+
setFailure(undefined);
|
|
26
|
+
const target = canvas.current;
|
|
27
|
+
if (!enabled || target === null) return undefined;
|
|
28
|
+
let disposed = false;
|
|
29
|
+
let instance;
|
|
30
|
+
const create = async ()=>{
|
|
31
|
+
let chartType;
|
|
32
|
+
try {
|
|
33
|
+
chartType = (await import('chart.js/auto')).default;
|
|
34
|
+
if (disposed) return;
|
|
35
|
+
instance = new chartType(target, structuredClone(configuration));
|
|
36
|
+
} catch (error) {
|
|
37
|
+
// Chart.js registers a chart on its canvas before the constructor finishes, so a constructor
|
|
38
|
+
// that throws still leaves a registered instance behind - one `instance` never points at. Left
|
|
39
|
+
// alone it makes every later attempt fail with "Canvas is already in use" and hides the real
|
|
40
|
+
// reason, so release whatever is bound to this canvas before reporting.
|
|
41
|
+
chartType?.getChart(target)?.destroy();
|
|
42
|
+
if (!disposed) setFailure(error instanceof Error ? error.message : String(error));
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
void create();
|
|
46
|
+
return ()=>{
|
|
47
|
+
disposed = true;
|
|
48
|
+
instance?.destroy();
|
|
49
|
+
instance = undefined;
|
|
50
|
+
};
|
|
51
|
+
}, [
|
|
52
|
+
canvas,
|
|
53
|
+
configuration,
|
|
54
|
+
enabled
|
|
55
|
+
]);
|
|
56
|
+
return failure;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export { useChart };
|
|
60
|
+
//# sourceMappingURL=useChart.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useChart.js","sources":["../../../chart/useChart.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { RefObject, useEffect, useState } from 'react';\nimport type { ChartConfiguration } from 'chart.js';\n\n/**\n * Draws a Chart.js chart on a canvas and owns its lifetime.\n *\n * Chart.js loads only after the canvas has mounted, which keeps server rendering independent of browser\n * globals. The chart is destroyed before it is rebuilt and when the component unmounts - Chart.js owns\n * listeners and resize observers, so a retained instance would draw twice and leak them.\n *\n * A chart that cannot be drawn is reported rather than left as a blank canvas: `chart.js` not being\n * installed (it is an optional peer dependency), a failed dynamic import and a rejected configuration all\n * come back as the returned failure message. A rejected configuration is released from the canvas as well,\n * so correcting it draws again on the same canvas.\n *\n * @param canvas The canvas to draw on. It must be rendered whenever `enabled` is true.\n * @param configuration The Chart.js configuration. Pass a structurally stable value (see\n * {@link useStructuralValue}); a new identity rebuilds the chart.\n * @param enabled Whether there is something to draw.\n * @returns The reason the chart could not be drawn, or `undefined`.\n */\nexport function useChart(canvas: RefObject<HTMLCanvasElement | null>, configuration: ChartConfiguration, enabled: boolean): string | undefined {\n const [failure, setFailure] = useState<string | undefined>(undefined);\n\n useEffect(() => {\n setFailure(undefined);\n const target = canvas.current;\n if (!enabled || target === null) return undefined;\n\n let disposed = false;\n let instance: { destroy(): void } | undefined;\n\n const create = async () => {\n let chartType: typeof import('chart.js/auto').default | undefined;\n try {\n chartType = (await import('chart.js/auto')).default;\n if (disposed) return;\n instance = new chartType(target, structuredClone(configuration));\n } catch (error) {\n // Chart.js registers a chart on its canvas before the constructor finishes, so a constructor\n // that throws still leaves a registered instance behind - one `instance` never points at. Left\n // alone it makes every later attempt fail with \"Canvas is already in use\" and hides the real\n // reason, so release whatever is bound to this canvas before reporting.\n chartType?.getChart(target)?.destroy();\n if (!disposed) setFailure(error instanceof Error ? error.message : String(error));\n }\n };\n\n void create();\n return () => {\n disposed = true;\n instance?.destroy();\n instance = undefined;\n };\n }, [canvas, configuration, enabled]);\n\n return failure;\n}\n"],"names":["useChart","canvas","configuration","enabled","failure","setFailure","useState","undefined","useEffect","target","current","disposed","instance","create","chartType","default","structuredClone","error","getChart","destroy","Error","message","String"],"mappings":";;AAAA;AACA;AAKA;;;;;;;;;;;;;;;;;AAiBC,IACM,SAASA,QAAAA,CAASC,MAA2C,EAAEC,aAAiC,EAAEC,OAAgB,EAAA;AACrH,IAAA,MAAM,CAACC,OAAAA,EAASC,UAAAA,CAAW,GAAGC,QAAAA,CAA6BC,SAAA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BAAkB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAIvD,QAAA,MAAM,IAAI;;;;;QAKF,MAAM;QACN,IAAI;YAAI,WAAW;gBAAI,SAAS;;;;CAEC,CAAC;eAE3B,IAAI;AAEnB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,IAAI,CAAC,CAAC;AAGnC,eAAO,MAAM,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"FormGallery.stories.d.ts","sourceRoot":"","sources":["../../../form/FormGallery.stories.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAQ,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAIvD,QAAA,MAAM,IAAI;;;;;QAKF,MAAM;QACN,IAAI;YAAI,WAAW;gBAAI,SAAS;;;;CAEC,CAAC;eAE3B,IAAI;AAEnB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,IAAI,CAAC,CAAC;AAGnC,eAAO,MAAM,OAAO,EAAE,KAsCrB,CAAC"}
|
|
@@ -25,6 +25,14 @@ export const Gallery = {
|
|
|
25
25
|
sceneComponent('listBox', 'listBox', { options: ['Daily', 'Weekly', 'Monthly'] }),
|
|
26
26
|
sceneComponent('selectButton', 'selectButton', { options: ['Day', 'Week', 'Month'], value: 'Week' }),
|
|
27
27
|
sceneComponent('checkbox', 'checkbox', { label: 'Notify me', checked: true }),
|
|
28
|
+
sceneComponent('multiStateCheckbox', 'multiStateCheckbox', {
|
|
29
|
+
value: null,
|
|
30
|
+
options: [
|
|
31
|
+
{ label: 'Approved', value: 'approved', icon: 'pi pi-check' },
|
|
32
|
+
{ label: 'Rejected', value: 'rejected', icon: 'pi pi-times' },
|
|
33
|
+
],
|
|
34
|
+
ariaLabel: 'Review state',
|
|
35
|
+
}),
|
|
28
36
|
sceneComponent('radioButton', 'radioButton', { options: ['Email', 'SMS'], value: 'Email' }),
|
|
29
37
|
sceneComponent('toggleSwitch', 'toggleSwitch', { label: 'Enabled', checked: true }),
|
|
30
38
|
sceneComponent('slider', 'slider', { value: 35 }),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormGallery.stories.js","sourceRoot":"","sources":["../../../form/FormGallery.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhE,MAAM,IAAI,GAAG;IACT,KAAK,EAAE,iBAAiB;IACxB,SAAS,EAAE,gBAAgB;IAC3B,IAAI,EAAE,CAAC,UAAU,CAAC;IAClB,UAAU,EAAE;QACR,MAAM,EAAE,QAAQ;QAChB,IAAI,EAAE,EAAE,WAAW,EAAE,EAAE,SAAS,EAAE,2PAA2P,EAAE,EAAE;KACpS;CACoC,CAAC;AAE1C,eAAe,IAAI,CAAC;AAKpB,MAAM,CAAC,MAAM,OAAO,GAAU;IAC1B,IAAI,EAAE;QACF,OAAO,EAAE,YAAY,CAAC,SAAS,EAAE;YAC7B,cAAc,CAAC,WAAW,EAAE,WAAW,EAAE,EAAE,WAAW,EAAE,MAAM,EAAE,CAAC;YACjE,cAAc,CAAC,eAAe,EAAE,eAAe,EAAE,EAAE,WAAW,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;YACnF,cAAc,CAAC,aAAa,EAAE,aAAa,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;YAC9E,cAAc,CAAC,UAAU,EAAE,UAAU,EAAE,EAAE,WAAW,EAAE,UAAU,EAAE,CAAC;YACnE,cAAc,CAAC,YAAY,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,cAAc,EAAE,CAAC;YACrE,cAAc,CAAC,WAAW,EAAE,WAAW,EAA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AAQ,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC;aAChE,CAAC;SACL,CAAC;QACF,QAAQ,EAAE,oBAAoB;QAC9B,cAAc,EAAE,GAAG,EAAE,CAAC,SAAS;KAClC;CACJ,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { MultiStateOption } from './MultiStateOption';
|
|
2
|
+
export interface MultiStateGlyphProps {
|
|
3
|
+
state: MultiStateOption | undefined;
|
|
4
|
+
isEmpty: boolean;
|
|
5
|
+
isInactive: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare function MultiStateGlyph({ state, isEmpty, isInactive }: MultiStateGlyphProps): import("react").JSX.Element;
|
|
8
|
+
//# sourceMappingURL=MultiStateGlyph.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MultiStateGlyph.d.ts","sourceRoot":"","sources":["../../../form/MultiStateGlyph.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD,MAAM,WAAW,oBAAoB;IAEjC,KAAK,EAAE,gBAAgB,GAAG,SAAS,CAAC;IAGpC,OAAO,EAAE,OAAO,CAAC;IAGjB,UAAU,EAAE,OAAO,CAAC;CACvB;AAQD,wBAAgB,eAAe,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,EAAE,oBAAoB,+BAkBnF"}
|