dp-widgets-framework 1.3.6 → 1.3.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.esm.js +2260 -84
- package/dist/index.js +2260 -84
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -17,8 +17,6 @@ var reactGridLayout = require('react-grid-layout');
|
|
|
17
17
|
var uuid = require('uuid');
|
|
18
18
|
var reactCore = require('@copilotkit/react-core');
|
|
19
19
|
var reactUi = require('@copilotkit/react-ui');
|
|
20
|
-
var ChartDataLabels = require('chartjs-plugin-datalabels');
|
|
21
|
-
var ChartPieChartOutlabels = require('@energiency/chartjs-plugin-piechart-outlabels');
|
|
22
20
|
var CheckboxPrimitive = require('@radix-ui/react-checkbox');
|
|
23
21
|
var DialogPrimitive = require('@radix-ui/react-dialog');
|
|
24
22
|
|
|
@@ -1514,11 +1512,11 @@ const Input = React__namespace.forwardRef((_a, ref) => {
|
|
|
1514
1512
|
Input.displayName = "Input";
|
|
1515
1513
|
|
|
1516
1514
|
const labelVariants = classVarianceAuthority.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70");
|
|
1517
|
-
const Label = React__namespace.forwardRef((_a, ref) => {
|
|
1515
|
+
const Label$1 = React__namespace.forwardRef((_a, ref) => {
|
|
1518
1516
|
var { className } = _a, props = __rest(_a, ["className"]);
|
|
1519
1517
|
return (jsxRuntimeExports.jsx(LabelPrimitive__namespace.Root, Object.assign({ ref: ref, className: cn(labelVariants(), className) }, props)));
|
|
1520
1518
|
});
|
|
1521
|
-
Label.displayName = LabelPrimitive__namespace.Root.displayName;
|
|
1519
|
+
Label$1.displayName = LabelPrimitive__namespace.Root.displayName;
|
|
1522
1520
|
|
|
1523
1521
|
const Switch = React__namespace.forwardRef((_a, ref) => {
|
|
1524
1522
|
var { className } = _a, props = __rest(_a, ["className"]);
|
|
@@ -1827,17 +1825,17 @@ function WidgetSettingsPanel({ pageId, widget, onClose, onWidgetUpdate, widgetBa
|
|
|
1827
1825
|
};
|
|
1828
1826
|
const renderCommonSettings = () => {
|
|
1829
1827
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
|
|
1830
|
-
return (jsxRuntimeExports.jsxs("div", { className: "space-y-4", children: [jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [jsxRuntimeExports.jsx(Label, { className: "text-xs", children: "Title" }), jsxRuntimeExports.jsx(Input, { value: localWidget.title, onChange: (e) => updateWidget({ title: e.target.value }), className: "h-8" })] }), jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between py-2", children: [jsxRuntimeExports.jsx(Label, { className: "text-xs", children: "Show Header" }), jsxRuntimeExports.jsx(Switch, { checked: ((_a = localWidget.config) === null || _a === void 0 ? void 0 : _a.showHeader) !== false, onCheckedChange: (checked) => updateConfig({ showHeader: checked }) })] }), jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between py-2", children: [jsxRuntimeExports.jsx(Label, { className: "text-xs", children: "Resizable" }), jsxRuntimeExports.jsx(Switch, { checked: localWidget.is_resizable, onCheckedChange: (checked) => updateWidget({ is_resizable: checked }) })] }), jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between py-2", children: [jsxRuntimeExports.jsx(Label, { className: "text-xs", children: "Draggable" }), jsxRuntimeExports.jsx(Switch, { checked: localWidget.is_draggable, onCheckedChange: (checked) => updateWidget({ is_draggable: checked }) })] }), jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [jsxRuntimeExports.jsx(Label, { className: "text-xs", children: "Background Color" }), jsxRuntimeExports.jsxs("div", { className: "flex gap-2", children: [jsxRuntimeExports.jsx(Input, { type: "color", value: ((_c = (_b = localWidget.config) === null || _b === void 0 ? void 0 : _b.styles) === null || _c === void 0 ? void 0 : _c.backgroundColor) || "#ffffff", onChange: (e) => updateStyle({ backgroundColor: e.target.value }), className: "w-12 h-8 p-1" }), jsxRuntimeExports.jsx(Input, { value: ((_e = (_d = localWidget.config) === null || _d === void 0 ? void 0 : _d.styles) === null || _e === void 0 ? void 0 : _e.backgroundColor) || "#ffffff", onChange: (e) => updateStyle({ backgroundColor: e.target.value }), className: "h-8" })] })] }), jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [jsxRuntimeExports.jsx(Label, { className: "text-xs", children: "Border Radius" }), jsxRuntimeExports.jsxs(Select, { value: ((_g = (_f = localWidget.config) === null || _f === void 0 ? void 0 : _f.styles) === null || _g === void 0 ? void 0 : _g.borderRadius) || "rounded", onValueChange: (value) => updateStyle({ borderRadius: value }), children: [jsxRuntimeExports.jsx(SelectTrigger, { className: "h-8", children: jsxRuntimeExports.jsx(SelectValue, { placeholder: "Select border radius" }) }), jsxRuntimeExports.jsxs(SelectContent, { children: [jsxRuntimeExports.jsx(SelectItem, { value: "none", children: "None" }), jsxRuntimeExports.jsx(SelectItem, { value: "rounded", children: "Rounded" }), jsxRuntimeExports.jsx(SelectItem, { value: "large", children: "Large" }), jsxRuntimeExports.jsx(SelectItem, { value: "extra-large", children: "Extra Large" })] })] })] }), jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [jsxRuntimeExports.jsx(Label, { className: "text-xs", children: "Padding" }), jsxRuntimeExports.jsxs(Select, { value: ((_j = (_h = localWidget.config) === null || _h === void 0 ? void 0 : _h.styles) === null || _j === void 0 ? void 0 : _j.padding) || "medium", onValueChange: (value) => updateStyle({ padding: value }), children: [jsxRuntimeExports.jsx(SelectTrigger, { className: "h-8", children: jsxRuntimeExports.jsx(SelectValue, { placeholder: "Select padding" }) }), jsxRuntimeExports.jsxs(SelectContent, { children: [jsxRuntimeExports.jsx(SelectItem, { value: "small", children: "Small" }), jsxRuntimeExports.jsx(SelectItem, { value: "medium", children: "Medium" }), jsxRuntimeExports.jsx(SelectItem, { value: "large", children: "Large" }), jsxRuntimeExports.jsx(SelectItem, { value: "extra-large", children: "Extra Large" })] })] })] }), jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [jsxRuntimeExports.jsx(Label, { className: "text-xs", children: "Text Color" }), jsxRuntimeExports.jsxs("div", { className: "flex gap-2", children: [jsxRuntimeExports.jsx(Input, { type: "color", value: ((_l = (_k = localWidget.config) === null || _k === void 0 ? void 0 : _k.styles) === null || _l === void 0 ? void 0 : _l.textColor) || "#000000", onChange: (e) => updateStyle({ textColor: e.target.value }), className: "w-12 h-8 p-1" }), jsxRuntimeExports.jsx(Input, { value: ((_o = (_m = localWidget.config) === null || _m === void 0 ? void 0 : _m.styles) === null || _o === void 0 ? void 0 : _o.textColor) || "#000000", onChange: (e) => updateStyle({ textColor: e.target.value }), className: "h-8" })] })] }), jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [jsxRuntimeExports.jsx(Label, { className: "text-xs", children: "Font Size" }), jsxRuntimeExports.jsx(Input, { value: ((_q = (_p = localWidget.config) === null || _p === void 0 ? void 0 : _p.styles) === null || _q === void 0 ? void 0 : _q.fontSize) || "14px", onChange: (e) => updateStyle({ fontSize: e.target.value }), className: "h-8", placeholder: "e.g., 14px, 1rem" })] }), jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [jsxRuntimeExports.jsx(Label, { className: "text-xs", children: "Alignment" }), jsxRuntimeExports.jsxs(Select, { value: ((_s = (_r = localWidget.config) === null || _r === void 0 ? void 0 : _r.styles) === null || _s === void 0 ? void 0 : _s.alignment) || "left", onValueChange: (value) => updateStyle({ alignment: value }), children: [jsxRuntimeExports.jsx(SelectTrigger, { className: "h-8", children: jsxRuntimeExports.jsx(SelectValue, { placeholder: "Select alignment" }) }), jsxRuntimeExports.jsxs(SelectContent, { children: [jsxRuntimeExports.jsx(SelectItem, { value: "left", children: "Left" }), jsxRuntimeExports.jsx(SelectItem, { value: "center", children: "Center" }), jsxRuntimeExports.jsx(SelectItem, { value: "right", children: "Right" })] })] })] })] }));
|
|
1828
|
+
return (jsxRuntimeExports.jsxs("div", { className: "space-y-4", children: [jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [jsxRuntimeExports.jsx(Label$1, { className: "text-xs", children: "Title" }), jsxRuntimeExports.jsx(Input, { value: localWidget.title, onChange: (e) => updateWidget({ title: e.target.value }), className: "h-8" })] }), jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between py-2", children: [jsxRuntimeExports.jsx(Label$1, { className: "text-xs", children: "Show Header" }), jsxRuntimeExports.jsx(Switch, { checked: ((_a = localWidget.config) === null || _a === void 0 ? void 0 : _a.showHeader) !== false, onCheckedChange: (checked) => updateConfig({ showHeader: checked }) })] }), jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between py-2", children: [jsxRuntimeExports.jsx(Label$1, { className: "text-xs", children: "Resizable" }), jsxRuntimeExports.jsx(Switch, { checked: localWidget.is_resizable, onCheckedChange: (checked) => updateWidget({ is_resizable: checked }) })] }), jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between py-2", children: [jsxRuntimeExports.jsx(Label$1, { className: "text-xs", children: "Draggable" }), jsxRuntimeExports.jsx(Switch, { checked: localWidget.is_draggable, onCheckedChange: (checked) => updateWidget({ is_draggable: checked }) })] }), jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [jsxRuntimeExports.jsx(Label$1, { className: "text-xs", children: "Background Color" }), jsxRuntimeExports.jsxs("div", { className: "flex gap-2", children: [jsxRuntimeExports.jsx(Input, { type: "color", value: ((_c = (_b = localWidget.config) === null || _b === void 0 ? void 0 : _b.styles) === null || _c === void 0 ? void 0 : _c.backgroundColor) || "#ffffff", onChange: (e) => updateStyle({ backgroundColor: e.target.value }), className: "w-12 h-8 p-1" }), jsxRuntimeExports.jsx(Input, { value: ((_e = (_d = localWidget.config) === null || _d === void 0 ? void 0 : _d.styles) === null || _e === void 0 ? void 0 : _e.backgroundColor) || "#ffffff", onChange: (e) => updateStyle({ backgroundColor: e.target.value }), className: "h-8" })] })] }), jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [jsxRuntimeExports.jsx(Label$1, { className: "text-xs", children: "Border Radius" }), jsxRuntimeExports.jsxs(Select, { value: ((_g = (_f = localWidget.config) === null || _f === void 0 ? void 0 : _f.styles) === null || _g === void 0 ? void 0 : _g.borderRadius) || "rounded", onValueChange: (value) => updateStyle({ borderRadius: value }), children: [jsxRuntimeExports.jsx(SelectTrigger, { className: "h-8", children: jsxRuntimeExports.jsx(SelectValue, { placeholder: "Select border radius" }) }), jsxRuntimeExports.jsxs(SelectContent, { children: [jsxRuntimeExports.jsx(SelectItem, { value: "none", children: "None" }), jsxRuntimeExports.jsx(SelectItem, { value: "rounded", children: "Rounded" }), jsxRuntimeExports.jsx(SelectItem, { value: "large", children: "Large" }), jsxRuntimeExports.jsx(SelectItem, { value: "extra-large", children: "Extra Large" })] })] })] }), jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [jsxRuntimeExports.jsx(Label$1, { className: "text-xs", children: "Padding" }), jsxRuntimeExports.jsxs(Select, { value: ((_j = (_h = localWidget.config) === null || _h === void 0 ? void 0 : _h.styles) === null || _j === void 0 ? void 0 : _j.padding) || "medium", onValueChange: (value) => updateStyle({ padding: value }), children: [jsxRuntimeExports.jsx(SelectTrigger, { className: "h-8", children: jsxRuntimeExports.jsx(SelectValue, { placeholder: "Select padding" }) }), jsxRuntimeExports.jsxs(SelectContent, { children: [jsxRuntimeExports.jsx(SelectItem, { value: "small", children: "Small" }), jsxRuntimeExports.jsx(SelectItem, { value: "medium", children: "Medium" }), jsxRuntimeExports.jsx(SelectItem, { value: "large", children: "Large" }), jsxRuntimeExports.jsx(SelectItem, { value: "extra-large", children: "Extra Large" })] })] })] }), jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [jsxRuntimeExports.jsx(Label$1, { className: "text-xs", children: "Text Color" }), jsxRuntimeExports.jsxs("div", { className: "flex gap-2", children: [jsxRuntimeExports.jsx(Input, { type: "color", value: ((_l = (_k = localWidget.config) === null || _k === void 0 ? void 0 : _k.styles) === null || _l === void 0 ? void 0 : _l.textColor) || "#000000", onChange: (e) => updateStyle({ textColor: e.target.value }), className: "w-12 h-8 p-1" }), jsxRuntimeExports.jsx(Input, { value: ((_o = (_m = localWidget.config) === null || _m === void 0 ? void 0 : _m.styles) === null || _o === void 0 ? void 0 : _o.textColor) || "#000000", onChange: (e) => updateStyle({ textColor: e.target.value }), className: "h-8" })] })] }), jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [jsxRuntimeExports.jsx(Label$1, { className: "text-xs", children: "Font Size" }), jsxRuntimeExports.jsx(Input, { value: ((_q = (_p = localWidget.config) === null || _p === void 0 ? void 0 : _p.styles) === null || _q === void 0 ? void 0 : _q.fontSize) || "14px", onChange: (e) => updateStyle({ fontSize: e.target.value }), className: "h-8", placeholder: "e.g., 14px, 1rem" })] }), jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [jsxRuntimeExports.jsx(Label$1, { className: "text-xs", children: "Alignment" }), jsxRuntimeExports.jsxs(Select, { value: ((_s = (_r = localWidget.config) === null || _r === void 0 ? void 0 : _r.styles) === null || _s === void 0 ? void 0 : _s.alignment) || "left", onValueChange: (value) => updateStyle({ alignment: value }), children: [jsxRuntimeExports.jsx(SelectTrigger, { className: "h-8", children: jsxRuntimeExports.jsx(SelectValue, { placeholder: "Select alignment" }) }), jsxRuntimeExports.jsxs(SelectContent, { children: [jsxRuntimeExports.jsx(SelectItem, { value: "left", children: "Left" }), jsxRuntimeExports.jsx(SelectItem, { value: "center", children: "Center" }), jsxRuntimeExports.jsx(SelectItem, { value: "right", children: "Right" })] })] })] })] }));
|
|
1831
1829
|
};
|
|
1832
1830
|
const renderSearchSettings = () => {
|
|
1833
1831
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
1834
|
-
return (jsxRuntimeExports.jsxs("div", { className: "space-y-4", children: [jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [jsxRuntimeExports.jsx(Label, { className: "text-xs", children: "Placeholder Text" }), jsxRuntimeExports.jsx(Input, { value: ((_a = localWidget.config) === null || _a === void 0 ? void 0 : _a.placeholder) || "", onChange: (e) => updateConfig({ placeholder: e.target.value }), className: "h-8" })] }), jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [jsxRuntimeExports.jsx(Label, { className: "text-xs", children: "Minimum Characters" }), jsxRuntimeExports.jsx(Input, { type: "number", min: 1, max: 10, value: ((_b = localWidget.config) === null || _b === void 0 ? void 0 : _b.minCharacters) || 3, onChange: (e) => updateConfig({
|
|
1832
|
+
return (jsxRuntimeExports.jsxs("div", { className: "space-y-4", children: [jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [jsxRuntimeExports.jsx(Label$1, { className: "text-xs", children: "Placeholder Text" }), jsxRuntimeExports.jsx(Input, { value: ((_a = localWidget.config) === null || _a === void 0 ? void 0 : _a.placeholder) || "", onChange: (e) => updateConfig({ placeholder: e.target.value }), className: "h-8" })] }), jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [jsxRuntimeExports.jsx(Label$1, { className: "text-xs", children: "Minimum Characters" }), jsxRuntimeExports.jsx(Input, { type: "number", min: 1, max: 10, value: ((_b = localWidget.config) === null || _b === void 0 ? void 0 : _b.minCharacters) || 3, onChange: (e) => updateConfig({
|
|
1835
1833
|
minCharacters: parseInt(e.target.value) || 3,
|
|
1836
|
-
}), className: "h-8" })] }), jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [jsxRuntimeExports.jsx(Label, { className: "text-xs", children: "Search Delay (ms)" }), jsxRuntimeExports.jsx(Input, { type: "number", min: 0, max: 1000, step: 50, value: ((_c = localWidget.config) === null || _c === void 0 ? void 0 : _c.searchDelay) || 300, onChange: (e) => updateConfig({
|
|
1834
|
+
}), className: "h-8" })] }), jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [jsxRuntimeExports.jsx(Label$1, { className: "text-xs", children: "Search Delay (ms)" }), jsxRuntimeExports.jsx(Input, { type: "number", min: 0, max: 1000, step: 50, value: ((_c = localWidget.config) === null || _c === void 0 ? void 0 : _c.searchDelay) || 300, onChange: (e) => updateConfig({
|
|
1837
1835
|
searchDelay: parseInt(e.target.value) || 300,
|
|
1838
|
-
}), className: "h-8" })] }), jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between py-2", children: [jsxRuntimeExports.jsx(Label, { className: "text-xs", children: "Auto Focus" }), jsxRuntimeExports.jsx(Switch, { checked: ((_d = localWidget.config) === null || _d === void 0 ? void 0 : _d.autoFocus) || false, onCheckedChange: (checked) => updateConfig({ autoFocus: checked }) })] }), jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between py-2", children: [jsxRuntimeExports.jsx(Label, { className: "text-xs", children: "Voice Search" }), jsxRuntimeExports.jsx(Switch, { checked: ((_e = localWidget.config) === null || _e === void 0 ? void 0 : _e.voiceSearch) || false, onCheckedChange: (checked) => updateConfig({ voiceSearch: checked }) })] }), jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between py-2", children: [jsxRuntimeExports.jsx(Label, { className: "text-xs", children: "Recent Searches" }), jsxRuntimeExports.jsx(Switch, { checked: ((_f = localWidget.config) === null || _f === void 0 ? void 0 : _f.recentSearches) || false, onCheckedChange: (checked) => updateConfig({ recentSearches: checked }) })] }), ((_g = localWidget.config) === null || _g === void 0 ? void 0 : _g.recentSearches) && (jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [jsxRuntimeExports.jsx(Label, { className: "text-xs", children: "Maximum Recent Searches" }), jsxRuntimeExports.jsx(Input, { type: "number", min: 1, value: ((_h = localWidget.config) === null || _h === void 0 ? void 0 : _h.maxRecentSearches) || 5, onChange: (e) => updateConfig({
|
|
1836
|
+
}), className: "h-8" })] }), jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between py-2", children: [jsxRuntimeExports.jsx(Label$1, { className: "text-xs", children: "Auto Focus" }), jsxRuntimeExports.jsx(Switch, { checked: ((_d = localWidget.config) === null || _d === void 0 ? void 0 : _d.autoFocus) || false, onCheckedChange: (checked) => updateConfig({ autoFocus: checked }) })] }), jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between py-2", children: [jsxRuntimeExports.jsx(Label$1, { className: "text-xs", children: "Voice Search" }), jsxRuntimeExports.jsx(Switch, { checked: ((_e = localWidget.config) === null || _e === void 0 ? void 0 : _e.voiceSearch) || false, onCheckedChange: (checked) => updateConfig({ voiceSearch: checked }) })] }), jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between py-2", children: [jsxRuntimeExports.jsx(Label$1, { className: "text-xs", children: "Recent Searches" }), jsxRuntimeExports.jsx(Switch, { checked: ((_f = localWidget.config) === null || _f === void 0 ? void 0 : _f.recentSearches) || false, onCheckedChange: (checked) => updateConfig({ recentSearches: checked }) })] }), ((_g = localWidget.config) === null || _g === void 0 ? void 0 : _g.recentSearches) && (jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [jsxRuntimeExports.jsx(Label$1, { className: "text-xs", children: "Maximum Recent Searches" }), jsxRuntimeExports.jsx(Input, { type: "number", min: 1, value: ((_h = localWidget.config) === null || _h === void 0 ? void 0 : _h.maxRecentSearches) || 5, onChange: (e) => updateConfig({
|
|
1839
1837
|
maxRecentSearches: parseInt(e.target.value) || 5,
|
|
1840
|
-
}), className: "h-8" })] })), jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between", children: [jsxRuntimeExports.jsx(Label, { children: "Enable Facets" }), jsxRuntimeExports.jsx(Switch, { checked: (_l = (_k = (_j = widget.config) === null || _j === void 0 ? void 0 : _j.facets) === null || _k === void 0 ? void 0 : _k.enabled) !== null && _l !== void 0 ? _l : false, onCheckedChange: (checked) => {
|
|
1838
|
+
}), className: "h-8" })] })), jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between", children: [jsxRuntimeExports.jsx(Label$1, { children: "Enable Facets" }), jsxRuntimeExports.jsx(Switch, { checked: (_l = (_k = (_j = widget.config) === null || _j === void 0 ? void 0 : _j.facets) === null || _k === void 0 ? void 0 : _k.enabled) !== null && _l !== void 0 ? _l : false, onCheckedChange: (checked) => {
|
|
1841
1839
|
var _a, _b, _c;
|
|
1842
1840
|
const newConfig = Object.assign(Object.assign({}, widget.config), { facets: Object.assign(Object.assign({}, (((_a = widget.config) === null || _a === void 0 ? void 0 : _a.facets) || {})), { enabled: checked, fields: ((_c = (_b = widget.config) === null || _b === void 0 ? void 0 : _b.facets) === null || _c === void 0 ? void 0 : _c.fields) || [] }) });
|
|
1843
1841
|
updateWidgetAPI(widget.id, { config: newConfig }).catch(console.error);
|
|
@@ -1848,29 +1846,29 @@ function WidgetSettingsPanel({ pageId, widget, onClose, onWidgetUpdate, widgetBa
|
|
|
1848
1846
|
};
|
|
1849
1847
|
const renderResultsSettings = () => {
|
|
1850
1848
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
1851
|
-
return (jsxRuntimeExports.jsxs("div", { className: "space-y-4", children: [jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [jsxRuntimeExports.jsx(Label, { className: "text-xs", children: "Layout Type" }), jsxRuntimeExports.jsxs(Select, { value: ((_b = (_a = localWidget.config) === null || _a === void 0 ? void 0 : _a.layout) === null || _b === void 0 ? void 0 : _b.type) || "list", onValueChange: (value) => {
|
|
1849
|
+
return (jsxRuntimeExports.jsxs("div", { className: "space-y-4", children: [jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [jsxRuntimeExports.jsx(Label$1, { className: "text-xs", children: "Layout Type" }), jsxRuntimeExports.jsxs(Select, { value: ((_b = (_a = localWidget.config) === null || _a === void 0 ? void 0 : _a.layout) === null || _b === void 0 ? void 0 : _b.type) || "list", onValueChange: (value) => {
|
|
1852
1850
|
var _a;
|
|
1853
1851
|
return updateConfig({
|
|
1854
1852
|
layout: Object.assign(Object.assign({}, (_a = localWidget.config) === null || _a === void 0 ? void 0 : _a.layout), { type: value }),
|
|
1855
1853
|
});
|
|
1856
|
-
}, children: [jsxRuntimeExports.jsx(SelectTrigger, { className: "h-8", children: jsxRuntimeExports.jsx(SelectValue, { placeholder: "Select layout type" }) }), jsxRuntimeExports.jsxs(SelectContent, { children: [jsxRuntimeExports.jsx(SelectItem, { value: "grid", children: "Grid" }), jsxRuntimeExports.jsx(SelectItem, { value: "list", children: "List" }), jsxRuntimeExports.jsx(SelectItem, { value: "table", children: "Table" })] })] })] }), jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [jsxRuntimeExports.jsx(Label, { className: "text-xs", children: "Items Per Page" }), jsxRuntimeExports.jsxs(Select, { value: String(((_d = (_c = localWidget.config) === null || _c === void 0 ? void 0 : _c.layout) === null || _d === void 0 ? void 0 : _d.itemsPerPage) || 10), onValueChange: (value) => {
|
|
1854
|
+
}, children: [jsxRuntimeExports.jsx(SelectTrigger, { className: "h-8", children: jsxRuntimeExports.jsx(SelectValue, { placeholder: "Select layout type" }) }), jsxRuntimeExports.jsxs(SelectContent, { children: [jsxRuntimeExports.jsx(SelectItem, { value: "grid", children: "Grid" }), jsxRuntimeExports.jsx(SelectItem, { value: "list", children: "List" }), jsxRuntimeExports.jsx(SelectItem, { value: "table", children: "Table" })] })] })] }), jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [jsxRuntimeExports.jsx(Label$1, { className: "text-xs", children: "Items Per Page" }), jsxRuntimeExports.jsxs(Select, { value: String(((_d = (_c = localWidget.config) === null || _c === void 0 ? void 0 : _c.layout) === null || _d === void 0 ? void 0 : _d.itemsPerPage) || 10), onValueChange: (value) => {
|
|
1857
1855
|
var _a;
|
|
1858
1856
|
return updateConfig({
|
|
1859
1857
|
layout: Object.assign(Object.assign({}, (_a = localWidget.config) === null || _a === void 0 ? void 0 : _a.layout), { itemsPerPage: parseInt(value) }),
|
|
1860
1858
|
});
|
|
1861
|
-
}, children: [jsxRuntimeExports.jsx(SelectTrigger, { className: "h-8", children: jsxRuntimeExports.jsx(SelectValue, { placeholder: "Select items per page" }) }), jsxRuntimeExports.jsx(SelectContent, { children: [5, 10, 20, 50, 100].map((value) => (jsxRuntimeExports.jsxs(SelectItem, { value: String(value), children: [value, " items"] }, value))) })] })] }), jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between py-2", children: [jsxRuntimeExports.jsx(Label, { className: "text-xs", children: "Infinite Scroll" }), jsxRuntimeExports.jsx(Switch, { checked: ((_f = (_e = localWidget.config) === null || _e === void 0 ? void 0 : _e.layout) === null || _f === void 0 ? void 0 : _f.infiniteScroll) || false, onCheckedChange: (checked) => {
|
|
1859
|
+
}, children: [jsxRuntimeExports.jsx(SelectTrigger, { className: "h-8", children: jsxRuntimeExports.jsx(SelectValue, { placeholder: "Select items per page" }) }), jsxRuntimeExports.jsx(SelectContent, { children: [5, 10, 20, 50, 100].map((value) => (jsxRuntimeExports.jsxs(SelectItem, { value: String(value), children: [value, " items"] }, value))) })] })] }), jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between py-2", children: [jsxRuntimeExports.jsx(Label$1, { className: "text-xs", children: "Infinite Scroll" }), jsxRuntimeExports.jsx(Switch, { checked: ((_f = (_e = localWidget.config) === null || _e === void 0 ? void 0 : _e.layout) === null || _f === void 0 ? void 0 : _f.infiniteScroll) || false, onCheckedChange: (checked) => {
|
|
1862
1860
|
var _a;
|
|
1863
1861
|
return updateConfig({
|
|
1864
1862
|
layout: Object.assign(Object.assign({}, (_a = localWidget.config) === null || _a === void 0 ? void 0 : _a.layout), { infiniteScroll: checked }),
|
|
1865
1863
|
});
|
|
1866
|
-
} })] }), jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between py-2", children: [jsxRuntimeExports.jsx(Label, { className: "text-xs", children: "Show Pagination" }), jsxRuntimeExports.jsx(Switch, { checked: ((_g = localWidget.config) === null || _g === void 0 ? void 0 : _g.showPagination) !== false, onCheckedChange: (checked) => updateConfig({ showPagination: checked }) })] }), jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between py-2", children: [jsxRuntimeExports.jsx(Label, { className: "text-xs", children: "Hide Relevance" }), jsxRuntimeExports.jsx(Switch, { checked: (_j = (_h = localWidget.config) === null || _h === void 0 ? void 0 : _h.hideRelevance) !== null && _j !== void 0 ? _j : false, onCheckedChange: (checked) => updateConfig({ hideRelevance: checked }) })] }), jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [jsxRuntimeExports.jsx(Label, { className: "text-xs", children: "Title" }), jsxRuntimeExports.jsxs(Select, { value: ((_k = localWidget.config) === null || _k === void 0 ? void 0 : _k.titleTemplate) || "filename", onValueChange: (value) => updateConfig({ titleTemplate: value }), children: [jsxRuntimeExports.jsx(SelectTrigger, { className: "h-8", children: jsxRuntimeExports.jsx(SelectValue, { placeholder: "Select title template" }) }), jsxRuntimeExports.jsx(SelectContent, { children: availableFacets.map((facet) => facet.type === "string" && (jsxRuntimeExports.jsx(SelectItem, { value: facet.value, children: facet.value }, facet.value))) })] })] }), jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [jsxRuntimeExports.jsx(Label, { className: "text-xs", children: "Metadata" }), jsxRuntimeExports.jsx(SearchWidgetFacetSettings, { placeHolder: "Select metadata field", value: ((_m = (_l = widget.config) === null || _l === void 0 ? void 0 : _l.metadata) === null || _m === void 0 ? void 0 : _m.fields) || [], onChange: (fields) => {
|
|
1864
|
+
} })] }), jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between py-2", children: [jsxRuntimeExports.jsx(Label$1, { className: "text-xs", children: "Show Pagination" }), jsxRuntimeExports.jsx(Switch, { checked: ((_g = localWidget.config) === null || _g === void 0 ? void 0 : _g.showPagination) !== false, onCheckedChange: (checked) => updateConfig({ showPagination: checked }) })] }), jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between py-2", children: [jsxRuntimeExports.jsx(Label$1, { className: "text-xs", children: "Hide Relevance" }), jsxRuntimeExports.jsx(Switch, { checked: (_j = (_h = localWidget.config) === null || _h === void 0 ? void 0 : _h.hideRelevance) !== null && _j !== void 0 ? _j : false, onCheckedChange: (checked) => updateConfig({ hideRelevance: checked }) })] }), jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [jsxRuntimeExports.jsx(Label$1, { className: "text-xs", children: "Title" }), jsxRuntimeExports.jsxs(Select, { value: ((_k = localWidget.config) === null || _k === void 0 ? void 0 : _k.titleTemplate) || "filename", onValueChange: (value) => updateConfig({ titleTemplate: value }), children: [jsxRuntimeExports.jsx(SelectTrigger, { className: "h-8", children: jsxRuntimeExports.jsx(SelectValue, { placeholder: "Select title template" }) }), jsxRuntimeExports.jsx(SelectContent, { children: availableFacets.map((facet) => facet.type === "string" && (jsxRuntimeExports.jsx(SelectItem, { value: facet.value, children: facet.value }, facet.value))) })] })] }), jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [jsxRuntimeExports.jsx(Label$1, { className: "text-xs", children: "Metadata" }), jsxRuntimeExports.jsx(SearchWidgetFacetSettings, { placeHolder: "Select metadata field", value: ((_m = (_l = widget.config) === null || _l === void 0 ? void 0 : _l.metadata) === null || _m === void 0 ? void 0 : _m.fields) || [], onChange: (fields) => {
|
|
1867
1865
|
const newConfig = Object.assign(Object.assign({}, widget.config), { metadata: Object.assign(Object.assign({}, widget.config.metadata), { fields }) });
|
|
1868
1866
|
updateWidgetAPI(widget.id, { config: newConfig }).catch(console.error);
|
|
1869
1867
|
}, maxFields: ((_p = (_o = widget.config) === null || _o === void 0 ? void 0 : _o.facets) === null || _p === void 0 ? void 0 : _p.maxFields) || 10 })] })] }));
|
|
1870
1868
|
};
|
|
1871
1869
|
const renderCodeSettings = () => {
|
|
1872
1870
|
var _a;
|
|
1873
|
-
return (jsxRuntimeExports.jsx("div", { className: "space-y-4", children: jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [jsxRuntimeExports.jsx(Label, { className: "text-xs", children: "Custom Widget Code" }), jsxRuntimeExports.jsx(CodeEditor, { value: ((_a = localWidget.config) === null || _a === void 0 ? void 0 : _a.customCode) ||
|
|
1871
|
+
return (jsxRuntimeExports.jsx("div", { className: "space-y-4", children: jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [jsxRuntimeExports.jsx(Label$1, { className: "text-xs", children: "Custom Widget Code" }), jsxRuntimeExports.jsx(CodeEditor, { value: ((_a = localWidget.config) === null || _a === void 0 ? void 0 : _a.customCode) ||
|
|
1874
1872
|
`// Custom search widget code
|
|
1875
1873
|
// You can modify the widget behavior here
|
|
1876
1874
|
function customSearch(query) {
|
|
@@ -1885,7 +1883,7 @@ function WidgetSettingsPanel({ pageId, widget, onClose, onWidgetUpdate, widgetBa
|
|
|
1885
1883
|
};
|
|
1886
1884
|
const renderFilterSettings = () => {
|
|
1887
1885
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
1888
|
-
return (jsxRuntimeExports.jsxs("div", { className: "space-y-4", children: [jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between py-2", children: [jsxRuntimeExports.jsx(Label, { className: "text-xs", children: "Show Clear Button" }), jsxRuntimeExports.jsx(Switch, { checked: ((_a = localWidget.config) === null || _a === void 0 ? void 0 : _a.showClearButton) !== false, onCheckedChange: (checked) => updateConfig({ showClearButton: checked }) })] }), jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between py-2", children: [jsxRuntimeExports.jsx(Label, { className: "text-xs", children: "Collapsible Sections" }), jsxRuntimeExports.jsx(Switch, { checked: ((_b = localWidget.config) === null || _b === void 0 ? void 0 : _b.collapsible) !== false, onCheckedChange: (checked) => updateConfig({ collapsible: checked }) })] }), jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between py-2", children: [jsxRuntimeExports.jsx(Label, { className: "text-xs", children: "Default Expanded" }), jsxRuntimeExports.jsx(Switch, { checked: ((_c = localWidget.config) === null || _c === void 0 ? void 0 : _c.defaultExpanded) !== false, onCheckedChange: (checked) => updateConfig({ defaultExpanded: checked }) })] }), jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between", children: [jsxRuntimeExports.jsx(Label, { children: "Enable Facets" }), jsxRuntimeExports.jsx(Switch, { checked: (_f = (_e = (_d = widget.config) === null || _d === void 0 ? void 0 : _d.facets) === null || _e === void 0 ? void 0 : _e.enabled) !== null && _f !== void 0 ? _f : false, onCheckedChange: (checked) => {
|
|
1886
|
+
return (jsxRuntimeExports.jsxs("div", { className: "space-y-4", children: [jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between py-2", children: [jsxRuntimeExports.jsx(Label$1, { className: "text-xs", children: "Show Clear Button" }), jsxRuntimeExports.jsx(Switch, { checked: ((_a = localWidget.config) === null || _a === void 0 ? void 0 : _a.showClearButton) !== false, onCheckedChange: (checked) => updateConfig({ showClearButton: checked }) })] }), jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between py-2", children: [jsxRuntimeExports.jsx(Label$1, { className: "text-xs", children: "Collapsible Sections" }), jsxRuntimeExports.jsx(Switch, { checked: ((_b = localWidget.config) === null || _b === void 0 ? void 0 : _b.collapsible) !== false, onCheckedChange: (checked) => updateConfig({ collapsible: checked }) })] }), jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between py-2", children: [jsxRuntimeExports.jsx(Label$1, { className: "text-xs", children: "Default Expanded" }), jsxRuntimeExports.jsx(Switch, { checked: ((_c = localWidget.config) === null || _c === void 0 ? void 0 : _c.defaultExpanded) !== false, onCheckedChange: (checked) => updateConfig({ defaultExpanded: checked }) })] }), jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between", children: [jsxRuntimeExports.jsx(Label$1, { children: "Enable Facets" }), jsxRuntimeExports.jsx(Switch, { checked: (_f = (_e = (_d = widget.config) === null || _d === void 0 ? void 0 : _d.facets) === null || _e === void 0 ? void 0 : _e.enabled) !== null && _f !== void 0 ? _f : false, onCheckedChange: (checked) => {
|
|
1889
1887
|
var _a, _b, _c;
|
|
1890
1888
|
const newConfig = Object.assign(Object.assign({}, widget.config), { facets: Object.assign(Object.assign({}, (((_a = widget.config) === null || _a === void 0 ? void 0 : _a.facets) || {})), { enabled: checked, fields: ((_c = (_b = widget.config) === null || _b === void 0 ? void 0 : _b.facets) === null || _c === void 0 ? void 0 : _c.fields) || [] }) });
|
|
1891
1889
|
console.log("newConfig", newConfig);
|
|
@@ -1897,14 +1895,14 @@ function WidgetSettingsPanel({ pageId, widget, onClose, onWidgetUpdate, widgetBa
|
|
|
1897
1895
|
};
|
|
1898
1896
|
const renderAgentSettings = () => {
|
|
1899
1897
|
var _a, _b, _c, _d, _e;
|
|
1900
|
-
return (jsxRuntimeExports.jsxs("div", { className: "space-y-4", children: [jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [jsxRuntimeExports.jsx(Label, { className: "text-xs", children: "Agent Type" }), jsxRuntimeExports.jsxs(Select, { value: ((_a = localWidget.config) === null || _a === void 0 ? void 0 : _a.agentType) || "Chatbot Agent", onValueChange: (value) => {
|
|
1898
|
+
return (jsxRuntimeExports.jsxs("div", { className: "space-y-4", children: [jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [jsxRuntimeExports.jsx(Label$1, { className: "text-xs", children: "Agent Type" }), jsxRuntimeExports.jsxs(Select, { value: ((_a = localWidget.config) === null || _a === void 0 ? void 0 : _a.agentType) || "Chatbot Agent", onValueChange: (value) => {
|
|
1901
1899
|
const updates = { agentType: value };
|
|
1902
1900
|
// Remove query property when Chatbot Agent is selected
|
|
1903
1901
|
if (value === "Chatbot Agent") {
|
|
1904
1902
|
updates.query = undefined;
|
|
1905
1903
|
}
|
|
1906
1904
|
updateConfig(updates);
|
|
1907
|
-
}, children: [jsxRuntimeExports.jsx(SelectTrigger, { className: "h-8", children: jsxRuntimeExports.jsx(SelectValue, { placeholder: "Select agent type" }) }), jsxRuntimeExports.jsxs(SelectContent, { children: [jsxRuntimeExports.jsx(SelectItem, { value: "Chatbot Agent", children: "Chatbot Agent" }), jsxRuntimeExports.jsx(SelectItem, { value: "Bar Chart Agent", children: "Bar Chart Agent" }), jsxRuntimeExports.jsx(SelectItem, { value: "Pie Chart Agent", children: "Pie Chart Agent" })] })] })] }), jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [jsxRuntimeExports.jsx(Label, { className: "text-xs", children: "Agent ID" }), agentIds && agentIds.length > 0 ? (jsxRuntimeExports.jsxs(Select, { value: ((_b = localWidget.config) === null || _b === void 0 ? void 0 : _b.agentName) || "", onValueChange: (value) => updateConfig({ agentName: value }), children: [jsxRuntimeExports.jsx(SelectTrigger, { className: "h-8", children: jsxRuntimeExports.jsx(SelectValue, { placeholder: "Select an agent ID" }) }), jsxRuntimeExports.jsx(SelectContent, { children: agentIds.map((agentId) => (jsxRuntimeExports.jsx(SelectItem, { value: agentId, children: agentId }, agentId))) })] })) : (jsxRuntimeExports.jsx(Input, { value: ((_c = localWidget.config) === null || _c === void 0 ? void 0 : _c.agentName) || "", onChange: (e) => updateConfig({ agentName: e.target.value }), className: "h-8", placeholder: "e.g., adk-construction-project-agent" }))] }), ((_d = localWidget.config) === null || _d === void 0 ? void 0 : _d.agentType) !== "Chatbot Agent" && (jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [jsxRuntimeExports.jsx(Label, { className: "text-xs", children: "Query" }), jsxRuntimeExports.jsx(Input, { value: ((_e = localWidget.config) === null || _e === void 0 ? void 0 : _e.query) || "", onChange: (e) => updateConfig({ query: e.target.value }), className: "h-8", placeholder: "Enter query for the agent..." })] }))] }));
|
|
1905
|
+
}, children: [jsxRuntimeExports.jsx(SelectTrigger, { className: "h-8", children: jsxRuntimeExports.jsx(SelectValue, { placeholder: "Select agent type" }) }), jsxRuntimeExports.jsxs(SelectContent, { children: [jsxRuntimeExports.jsx(SelectItem, { value: "Chatbot Agent", children: "Chatbot Agent" }), jsxRuntimeExports.jsx(SelectItem, { value: "Bar Chart Agent", children: "Bar Chart Agent" }), jsxRuntimeExports.jsx(SelectItem, { value: "Pie Chart Agent", children: "Pie Chart Agent" })] })] })] }), jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [jsxRuntimeExports.jsx(Label$1, { className: "text-xs", children: "Agent ID" }), agentIds && agentIds.length > 0 ? (jsxRuntimeExports.jsxs(Select, { value: ((_b = localWidget.config) === null || _b === void 0 ? void 0 : _b.agentName) || "", onValueChange: (value) => updateConfig({ agentName: value }), children: [jsxRuntimeExports.jsx(SelectTrigger, { className: "h-8", children: jsxRuntimeExports.jsx(SelectValue, { placeholder: "Select an agent ID" }) }), jsxRuntimeExports.jsx(SelectContent, { children: agentIds.map((agentId) => (jsxRuntimeExports.jsx(SelectItem, { value: agentId, children: agentId }, agentId))) })] })) : (jsxRuntimeExports.jsx(Input, { value: ((_c = localWidget.config) === null || _c === void 0 ? void 0 : _c.agentName) || "", onChange: (e) => updateConfig({ agentName: e.target.value }), className: "h-8", placeholder: "e.g., adk-construction-project-agent" }))] }), ((_d = localWidget.config) === null || _d === void 0 ? void 0 : _d.agentType) !== "Chatbot Agent" && (jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [jsxRuntimeExports.jsx(Label$1, { className: "text-xs", children: "Query" }), jsxRuntimeExports.jsx(Input, { value: ((_e = localWidget.config) === null || _e === void 0 ? void 0 : _e.query) || "", onChange: (e) => updateConfig({ query: e.target.value }), className: "h-8", placeholder: "Enter query for the agent..." })] }))] }));
|
|
1908
1906
|
};
|
|
1909
1907
|
return (jsxRuntimeExports.jsxs("div", { className: "h-full flex flex-col", children: [jsxRuntimeExports.jsx("div", { className: "p-3 border-b flex justify-between items-center", children: jsxRuntimeExports.jsx("h3", { className: "font-medium text-sm", children: "Widget Settings" }) }), error && (jsxRuntimeExports.jsxs(Alert, { variant: "destructive", className: "m-3", children: [jsxRuntimeExports.jsx(lucideReact.AlertCircle, { className: "h-4 w-4" }), jsxRuntimeExports.jsx(AlertDescription, { children: error })] })), jsxRuntimeExports.jsx(ScrollArea, { className: "flex-1", children: jsxRuntimeExports.jsx("div", { className: "p-3", children: jsxRuntimeExports.jsxs(Tabs, { defaultValue: "common", children: [jsxRuntimeExports.jsxs(TabsList, { className: "w-full", children: [jsxRuntimeExports.jsx(TabsTrigger, { value: "common", className: "flex-1", children: "Common" }), localWidget.type === "search" && (jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [jsxRuntimeExports.jsx(TabsTrigger, { value: "search", className: "flex-1", children: "Search" }), jsxRuntimeExports.jsx(TabsTrigger, { value: "code", className: "flex-1", children: "Code" })] })), localWidget.type === "results" && (jsxRuntimeExports.jsx(TabsTrigger, { value: "results", className: "flex-1", children: "Results" })), localWidget.type === "filter" && (jsxRuntimeExports.jsx(TabsTrigger, { value: "filter", className: "flex-1", children: "Filter" })), localWidget.type === "agent" && (jsxRuntimeExports.jsx(TabsTrigger, { value: "agent", className: "flex-1", children: "Agent" }))] }), jsxRuntimeExports.jsxs("div", { className: "mt-4", children: [jsxRuntimeExports.jsx(TabsContent, { value: "common", children: renderCommonSettings() }), jsxRuntimeExports.jsx(TabsContent, { value: "search", children: renderSearchSettings() }), jsxRuntimeExports.jsx(TabsContent, { value: "results", children: renderResultsSettings() }), jsxRuntimeExports.jsx(TabsContent, { value: "filter", children: renderFilterSettings() }), jsxRuntimeExports.jsx(TabsContent, { value: "agent", children: renderAgentSettings() }), jsxRuntimeExports.jsx(TabsContent, { value: "code", children: renderCodeSettings() })] })] }) }) }), jsxRuntimeExports.jsxs("div", { className: "p-3 border-t flex justify-between gap-2", children: [jsxRuntimeExports.jsx("div", { className: "text-sm text-muted-foreground", children: isAutosaving && "Autosaving..." }), jsxRuntimeExports.jsxs("div", { className: "flex gap-2", children: [jsxRuntimeExports.jsx(Button, { variant: "outline", onClick: handleCancel, disabled: isSaving || isAutosaving, children: "Cancel" }), jsxRuntimeExports.jsx(Button, { onClick: handleSave, disabled: isSaving || isAutosaving, children: isSaving ? "Saving..." : "Save Changes" })] })] })] }));
|
|
1910
1908
|
}
|
|
@@ -2216,7 +2214,7 @@ function FacetWidget({ widget, showHeader = true, onConfigUpdate, }) {
|
|
|
2216
2214
|
onConfigUpdate(Object.assign(Object.assign({}, widget.config), { fields: newFields }));
|
|
2217
2215
|
}
|
|
2218
2216
|
};
|
|
2219
|
-
return (jsxRuntimeExports.jsxs(Card, { className: "p-4 h-full", children: [showHeader && jsxRuntimeExports.jsx("h3", { className: "font-medium mb-4", children: "Facet Configuration" }), jsxRuntimeExports.jsx(ScrollArea, { className: "h-[calc(100%-2rem)]", children: jsxRuntimeExports.jsxs("div", { className: "space-y-4", children: [fields.map((field, index) => (jsxRuntimeExports.jsxs("div", { className: "flex items-start gap-2 bg-accent/10 p-2 rounded-md", children: [jsxRuntimeExports.jsxs("div", { className: "flex-1 space-y-2", children: [jsxRuntimeExports.jsxs("div", { className: "space-y-1", children: [jsxRuntimeExports.jsxs(Label, { children: ["Field ", index + 1] }), jsxRuntimeExports.jsxs(Select, { value: field.field, onValueChange: (value) => updateField(index, value, field.displayName), children: [jsxRuntimeExports.jsx(SelectTrigger, { children: jsxRuntimeExports.jsx(SelectValue, { placeholder: "Select field" }) }), jsxRuntimeExports.jsx(SelectContent, { children: availableFacets.map((facet) => (jsxRuntimeExports.jsx(SelectItem, { value: facet.value, children: facet.value }, facet.value))) })] })] }), jsxRuntimeExports.jsxs("div", { className: "space-y-1", children: [jsxRuntimeExports.jsx(Label, { children: "Display Name" }), jsxRuntimeExports.jsx(Input, { value: field.displayName, onChange: (e) => updateField(index, field.field, e.target.value), placeholder: "Enter display name" })] })] }), jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-1", children: [jsxRuntimeExports.jsx(Button, { variant: "ghost", size: "icon", onClick: () => moveField(index, "up"), disabled: index === 0, children: jsxRuntimeExports.jsx(lucideReact.ArrowUp, { className: "h-4 w-4" }) }), jsxRuntimeExports.jsx(Button, { variant: "ghost", size: "icon", onClick: () => moveField(index, "down"), disabled: index === fields.length - 1, children: jsxRuntimeExports.jsx(lucideReact.ArrowDown, { className: "h-4 w-4" }) }), jsxRuntimeExports.jsx(Button, { variant: "ghost", size: "icon", onClick: () => removeField(index), children: jsxRuntimeExports.jsx(lucideReact.Trash2, { className: "h-4 w-4" }) })] })] }, index))), fields.length < (((_b = widget.config) === null || _b === void 0 ? void 0 : _b.maxFields) || 10) && (jsxRuntimeExports.jsxs(Button, { variant: "outline", className: "w-full", onClick: addField, children: [jsxRuntimeExports.jsx(lucideReact.Plus, { className: "h-4 w-4 mr-2" }), "Add Facet"] })), error && jsxRuntimeExports.jsx("p", { className: "text-sm text-destructive mt-2", children: error })] }) })] }));
|
|
2217
|
+
return (jsxRuntimeExports.jsxs(Card, { className: "p-4 h-full", children: [showHeader && jsxRuntimeExports.jsx("h3", { className: "font-medium mb-4", children: "Facet Configuration" }), jsxRuntimeExports.jsx(ScrollArea, { className: "h-[calc(100%-2rem)]", children: jsxRuntimeExports.jsxs("div", { className: "space-y-4", children: [fields.map((field, index) => (jsxRuntimeExports.jsxs("div", { className: "flex items-start gap-2 bg-accent/10 p-2 rounded-md", children: [jsxRuntimeExports.jsxs("div", { className: "flex-1 space-y-2", children: [jsxRuntimeExports.jsxs("div", { className: "space-y-1", children: [jsxRuntimeExports.jsxs(Label$1, { children: ["Field ", index + 1] }), jsxRuntimeExports.jsxs(Select, { value: field.field, onValueChange: (value) => updateField(index, value, field.displayName), children: [jsxRuntimeExports.jsx(SelectTrigger, { children: jsxRuntimeExports.jsx(SelectValue, { placeholder: "Select field" }) }), jsxRuntimeExports.jsx(SelectContent, { children: availableFacets.map((facet) => (jsxRuntimeExports.jsx(SelectItem, { value: facet.value, children: facet.value }, facet.value))) })] })] }), jsxRuntimeExports.jsxs("div", { className: "space-y-1", children: [jsxRuntimeExports.jsx(Label$1, { children: "Display Name" }), jsxRuntimeExports.jsx(Input, { value: field.displayName, onChange: (e) => updateField(index, field.field, e.target.value), placeholder: "Enter display name" })] })] }), jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-1", children: [jsxRuntimeExports.jsx(Button, { variant: "ghost", size: "icon", onClick: () => moveField(index, "up"), disabled: index === 0, children: jsxRuntimeExports.jsx(lucideReact.ArrowUp, { className: "h-4 w-4" }) }), jsxRuntimeExports.jsx(Button, { variant: "ghost", size: "icon", onClick: () => moveField(index, "down"), disabled: index === fields.length - 1, children: jsxRuntimeExports.jsx(lucideReact.ArrowDown, { className: "h-4 w-4" }) }), jsxRuntimeExports.jsx(Button, { variant: "ghost", size: "icon", onClick: () => removeField(index), children: jsxRuntimeExports.jsx(lucideReact.Trash2, { className: "h-4 w-4" }) })] })] }, index))), fields.length < (((_b = widget.config) === null || _b === void 0 ? void 0 : _b.maxFields) || 10) && (jsxRuntimeExports.jsxs(Button, { variant: "outline", className: "w-full", onClick: addField, children: [jsxRuntimeExports.jsx(lucideReact.Plus, { className: "h-4 w-4 mr-2" }), "Add Facet"] })), error && jsxRuntimeExports.jsx("p", { className: "text-sm text-destructive mt-2", children: error })] }) })] }));
|
|
2220
2218
|
}
|
|
2221
2219
|
|
|
2222
2220
|
// src/graphql/@generated/graphql.ts
|
|
@@ -3919,7 +3917,7 @@ function set(root, scope, values) {
|
|
|
3919
3917
|
appliers.forEach((apply)=>apply(this));
|
|
3920
3918
|
}
|
|
3921
3919
|
}
|
|
3922
|
-
var defaults = /* #__PURE__ */ new Defaults({
|
|
3920
|
+
var defaults$1 = /* #__PURE__ */ new Defaults({
|
|
3923
3921
|
_scriptable: (name)=>!name.startsWith('on'),
|
|
3924
3922
|
_indexable: (name)=>name !== 'events',
|
|
3925
3923
|
hover: {
|
|
@@ -3940,7 +3938,7 @@ var defaults = /* #__PURE__ */ new Defaults({
|
|
|
3940
3938
|
* @param font - A font object.
|
|
3941
3939
|
* @return The CSS font string. See https://developer.mozilla.org/en-US/docs/Web/CSS/font
|
|
3942
3940
|
* @private
|
|
3943
|
-
*/ function toFontString(font) {
|
|
3941
|
+
*/ function toFontString$1(font) {
|
|
3944
3942
|
if (!font || isNullOrUndef(font.size) || isNullOrUndef(font.family)) {
|
|
3945
3943
|
return null;
|
|
3946
3944
|
}
|
|
@@ -4351,7 +4349,7 @@ function _readValueToProps(value, props) {
|
|
|
4351
4349
|
* @private
|
|
4352
4350
|
*/ function toFont(options, fallback) {
|
|
4353
4351
|
options = options || {};
|
|
4354
|
-
fallback = fallback || defaults.font;
|
|
4352
|
+
fallback = fallback || defaults$1.font;
|
|
4355
4353
|
let size = valueOrDefault(options.size, fallback.size);
|
|
4356
4354
|
if (typeof size === 'string') {
|
|
4357
4355
|
size = parseInt(size, 10);
|
|
@@ -4369,7 +4367,7 @@ function _readValueToProps(value, props) {
|
|
|
4369
4367
|
weight: valueOrDefault(options.weight, fallback.weight),
|
|
4370
4368
|
string: ''
|
|
4371
4369
|
};
|
|
4372
|
-
font.string = toFontString(font);
|
|
4370
|
+
font.string = toFontString$1(font);
|
|
4373
4371
|
return font;
|
|
4374
4372
|
}
|
|
4375
4373
|
/**
|
|
@@ -4389,6 +4387,12 @@ function _readValueToProps(value, props) {
|
|
|
4389
4387
|
if (value === undefined) {
|
|
4390
4388
|
continue;
|
|
4391
4389
|
}
|
|
4390
|
+
if (context !== undefined && typeof value === 'function') {
|
|
4391
|
+
value = value(context);
|
|
4392
|
+
}
|
|
4393
|
+
if (index !== undefined && isArray(value)) {
|
|
4394
|
+
value = value[index % value.length];
|
|
4395
|
+
}
|
|
4392
4396
|
if (value !== undefined) {
|
|
4393
4397
|
return value;
|
|
4394
4398
|
}
|
|
@@ -5796,7 +5800,7 @@ class Animations {
|
|
|
5796
5800
|
if (!isObject(config)) {
|
|
5797
5801
|
return;
|
|
5798
5802
|
}
|
|
5799
|
-
const animationOptions = Object.keys(defaults.animation);
|
|
5803
|
+
const animationOptions = Object.keys(defaults$1.animation);
|
|
5800
5804
|
const animatedProps = this._properties;
|
|
5801
5805
|
Object.getOwnPropertyNames(config).forEach((key)=>{
|
|
5802
5806
|
const cfg = config[key];
|
|
@@ -6494,7 +6498,7 @@ class DatasetController {
|
|
|
6494
6498
|
''
|
|
6495
6499
|
];
|
|
6496
6500
|
const scopes = config.getOptionScopes(this.getDataset(), scopeKeys);
|
|
6497
|
-
const names = Object.keys(defaults.elements[elementType]);
|
|
6501
|
+
const names = Object.keys(defaults$1.elements[elementType]);
|
|
6498
6502
|
const context = ()=>this.getContext(index, active, mode);
|
|
6499
6503
|
const values = config.resolveNamedOptions(scopes, names, context, prefixes);
|
|
6500
6504
|
if (values.$shared) {
|
|
@@ -8252,7 +8256,7 @@ class BasicPlatform extends BasePlatform {
|
|
|
8252
8256
|
}
|
|
8253
8257
|
}
|
|
8254
8258
|
|
|
8255
|
-
const EXPANDO_KEY = '$chartjs';
|
|
8259
|
+
const EXPANDO_KEY$1 = '$chartjs';
|
|
8256
8260
|
const EVENT_TYPES = {
|
|
8257
8261
|
touchstart: 'mousedown',
|
|
8258
8262
|
touchmove: 'mousemove',
|
|
@@ -8269,7 +8273,7 @@ const isNullOrEmpty = (value)=>value === null || value === '';
|
|
|
8269
8273
|
const style = canvas.style;
|
|
8270
8274
|
const renderHeight = canvas.getAttribute('height');
|
|
8271
8275
|
const renderWidth = canvas.getAttribute('width');
|
|
8272
|
-
canvas[EXPANDO_KEY] = {
|
|
8276
|
+
canvas[EXPANDO_KEY$1] = {
|
|
8273
8277
|
initial: {
|
|
8274
8278
|
height: renderHeight,
|
|
8275
8279
|
width: renderWidth,
|
|
@@ -8448,10 +8452,10 @@ function createProxyAndListen(chart, type, listener) {
|
|
|
8448
8452
|
}
|
|
8449
8453
|
releaseContext(context) {
|
|
8450
8454
|
const canvas = context.canvas;
|
|
8451
|
-
if (!canvas[EXPANDO_KEY]) {
|
|
8455
|
+
if (!canvas[EXPANDO_KEY$1]) {
|
|
8452
8456
|
return false;
|
|
8453
8457
|
}
|
|
8454
|
-
const initial = canvas[EXPANDO_KEY].initial;
|
|
8458
|
+
const initial = canvas[EXPANDO_KEY$1].initial;
|
|
8455
8459
|
[
|
|
8456
8460
|
'height',
|
|
8457
8461
|
'width'
|
|
@@ -8468,7 +8472,7 @@ function createProxyAndListen(chart, type, listener) {
|
|
|
8468
8472
|
canvas.style[key] = style[key];
|
|
8469
8473
|
});
|
|
8470
8474
|
canvas.width = canvas.width;
|
|
8471
|
-
delete canvas[EXPANDO_KEY];
|
|
8475
|
+
delete canvas[EXPANDO_KEY$1];
|
|
8472
8476
|
return true;
|
|
8473
8477
|
}
|
|
8474
8478
|
addEventListener(chart, type, listener) {
|
|
@@ -9960,7 +9964,7 @@ class TypedRegistry {
|
|
|
9960
9964
|
items[id] = item;
|
|
9961
9965
|
registerDefaults(item, scope, parentScope);
|
|
9962
9966
|
if (this.override) {
|
|
9963
|
-
defaults.override(item.id, item.overrides);
|
|
9967
|
+
defaults$1.override(item.id, item.overrides);
|
|
9964
9968
|
}
|
|
9965
9969
|
return scope;
|
|
9966
9970
|
}
|
|
@@ -9974,8 +9978,8 @@ class TypedRegistry {
|
|
|
9974
9978
|
if (id in items) {
|
|
9975
9979
|
delete items[id];
|
|
9976
9980
|
}
|
|
9977
|
-
if (scope && id in defaults[scope]) {
|
|
9978
|
-
delete defaults[scope][id];
|
|
9981
|
+
if (scope && id in defaults$1[scope]) {
|
|
9982
|
+
delete defaults$1[scope][id];
|
|
9979
9983
|
if (this.override) {
|
|
9980
9984
|
delete overrides[id];
|
|
9981
9985
|
}
|
|
@@ -9984,16 +9988,16 @@ class TypedRegistry {
|
|
|
9984
9988
|
}
|
|
9985
9989
|
function registerDefaults(item, scope, parentScope) {
|
|
9986
9990
|
const itemDefaults = merge$1(Object.create(null), [
|
|
9987
|
-
parentScope ? defaults.get(parentScope) : {},
|
|
9988
|
-
defaults.get(scope),
|
|
9991
|
+
parentScope ? defaults$1.get(parentScope) : {},
|
|
9992
|
+
defaults$1.get(scope),
|
|
9989
9993
|
item.defaults
|
|
9990
9994
|
]);
|
|
9991
|
-
defaults.set(scope, itemDefaults);
|
|
9995
|
+
defaults$1.set(scope, itemDefaults);
|
|
9992
9996
|
if (item.defaultRoutes) {
|
|
9993
9997
|
routeDefaults(scope, item.defaultRoutes);
|
|
9994
9998
|
}
|
|
9995
9999
|
if (item.descriptors) {
|
|
9996
|
-
defaults.describe(scope, item.descriptors);
|
|
10000
|
+
defaults$1.describe(scope, item.descriptors);
|
|
9997
10001
|
}
|
|
9998
10002
|
}
|
|
9999
10003
|
function routeDefaults(scope, routes) {
|
|
@@ -10006,7 +10010,7 @@ function routeDefaults(scope, routes) {
|
|
|
10006
10010
|
const parts = routes[property].split('.');
|
|
10007
10011
|
const targetName = parts.pop();
|
|
10008
10012
|
const targetScope = parts.join('.');
|
|
10009
|
-
defaults.route(sourceScope, sourceName, targetScope, targetName);
|
|
10013
|
+
defaults$1.route(sourceScope, sourceName, targetScope, targetName);
|
|
10010
10014
|
});
|
|
10011
10015
|
}
|
|
10012
10016
|
function isIChartComponent(proto) {
|
|
@@ -10232,7 +10236,7 @@ function pluginOpts(config, { plugin , local }, opts, context) {
|
|
|
10232
10236
|
}
|
|
10233
10237
|
|
|
10234
10238
|
function getIndexAxis(type, options) {
|
|
10235
|
-
const datasetDefaults = defaults.datasets[type] || {};
|
|
10239
|
+
const datasetDefaults = defaults$1.datasets[type] || {};
|
|
10236
10240
|
const datasetOptions = (options.datasets || {})[type] || {};
|
|
10237
10241
|
return datasetOptions.indexAxis || options.indexAxis || datasetDefaults.indexAxis || 'x';
|
|
10238
10242
|
}
|
|
@@ -10304,7 +10308,7 @@ function mergeScaleConfig(config, options) {
|
|
|
10304
10308
|
if (scaleConf._proxy) {
|
|
10305
10309
|
return console.warn(`Ignoring resolver passed as options for scale: ${id}`);
|
|
10306
10310
|
}
|
|
10307
|
-
const axis = determineAxis(id, scaleConf, retrieveAxisFromDatasets(id, config), defaults.scales[scaleConf.type]);
|
|
10311
|
+
const axis = determineAxis(id, scaleConf, retrieveAxisFromDatasets(id, config), defaults$1.scales[scaleConf.type]);
|
|
10308
10312
|
const defaultId = getDefaultScaleIDFromAxis(axis, chartIndexAxis);
|
|
10309
10313
|
const defaultScaleOptions = chartDefaults.scales || {};
|
|
10310
10314
|
scales[id] = mergeIf(Object.create(null), [
|
|
@@ -10337,8 +10341,8 @@ function mergeScaleConfig(config, options) {
|
|
|
10337
10341
|
Object.keys(scales).forEach((key)=>{
|
|
10338
10342
|
const scale = scales[key];
|
|
10339
10343
|
mergeIf(scale, [
|
|
10340
|
-
defaults.scales[scale.type],
|
|
10341
|
-
defaults.scale
|
|
10344
|
+
defaults$1.scales[scale.type],
|
|
10345
|
+
defaults$1.scale
|
|
10342
10346
|
]);
|
|
10343
10347
|
});
|
|
10344
10348
|
return scales;
|
|
@@ -10480,7 +10484,7 @@ class Config {
|
|
|
10480
10484
|
}
|
|
10481
10485
|
keys.forEach((key)=>addIfFound(scopes, options, key));
|
|
10482
10486
|
keys.forEach((key)=>addIfFound(scopes, overrides[type] || {}, key));
|
|
10483
|
-
keys.forEach((key)=>addIfFound(scopes, defaults, key));
|
|
10487
|
+
keys.forEach((key)=>addIfFound(scopes, defaults$1, key));
|
|
10484
10488
|
keys.forEach((key)=>addIfFound(scopes, descriptors, key));
|
|
10485
10489
|
});
|
|
10486
10490
|
const array = Array.from(scopes);
|
|
@@ -10497,11 +10501,11 @@ class Config {
|
|
|
10497
10501
|
return [
|
|
10498
10502
|
options,
|
|
10499
10503
|
overrides[type] || {},
|
|
10500
|
-
defaults.datasets[type] || {},
|
|
10504
|
+
defaults$1.datasets[type] || {},
|
|
10501
10505
|
{
|
|
10502
10506
|
type
|
|
10503
10507
|
},
|
|
10504
|
-
defaults,
|
|
10508
|
+
defaults$1,
|
|
10505
10509
|
descriptors
|
|
10506
10510
|
];
|
|
10507
10511
|
}
|
|
@@ -10634,7 +10638,7 @@ function moveNumericKeys(obj, start, move) {
|
|
|
10634
10638
|
return e;
|
|
10635
10639
|
}
|
|
10636
10640
|
let Chart$1 = class Chart {
|
|
10637
|
-
static defaults = defaults;
|
|
10641
|
+
static defaults = defaults$1;
|
|
10638
10642
|
static instances = instances;
|
|
10639
10643
|
static overrides = overrides;
|
|
10640
10644
|
static registry = registry;
|
|
@@ -10892,7 +10896,7 @@ let Chart$1 = class Chart {
|
|
|
10892
10896
|
meta.controller.linkScales();
|
|
10893
10897
|
} else {
|
|
10894
10898
|
const ControllerClass = registry.getController(type);
|
|
10895
|
-
const { datasetElementType , dataElementType } = defaults.datasets[type];
|
|
10899
|
+
const { datasetElementType , dataElementType } = defaults$1.datasets[type];
|
|
10896
10900
|
Object.assign(ControllerClass, {
|
|
10897
10901
|
dataElementType: registry.getElement(dataElementType),
|
|
10898
10902
|
datasetElementType: datasetElementType && registry.getElement(datasetElementType)
|
|
@@ -12225,7 +12229,7 @@ function parseBorderRadius(bar, maxW, maxH) {
|
|
|
12225
12229
|
bottomRight: skipOrLimit(!enableBorder || skip.bottom || skip.right, o.bottomRight, 0, maxR)
|
|
12226
12230
|
};
|
|
12227
12231
|
}
|
|
12228
|
-
function boundingRects(bar) {
|
|
12232
|
+
function boundingRects$1(bar) {
|
|
12229
12233
|
const bounds = getBarBounds(bar);
|
|
12230
12234
|
const width = bounds.right - bounds.left;
|
|
12231
12235
|
const height = bounds.bottom - bounds.top;
|
|
@@ -12306,7 +12310,7 @@ class BarElement extends Element {
|
|
|
12306
12310
|
}
|
|
12307
12311
|
draw(ctx) {
|
|
12308
12312
|
const { inflateAmount , options: { borderColor , backgroundColor } } = this;
|
|
12309
|
-
const { inner , outer } = boundingRects(this);
|
|
12313
|
+
const { inner , outer } = boundingRects$1(this);
|
|
12310
12314
|
const addRectPath = hasRadius(outer.radius) ? addRoundedRectPath : addNormalRectPath;
|
|
12311
12315
|
ctx.save();
|
|
12312
12316
|
if (outer.w !== inner.w || outer.h !== inner.h) {
|
|
@@ -12564,7 +12568,7 @@ class Legend extends Element {
|
|
|
12564
12568
|
_draw() {
|
|
12565
12569
|
const { options: opts , columnSizes , lineWidths , ctx } = this;
|
|
12566
12570
|
const { align , labels: labelOpts } = opts;
|
|
12567
|
-
const defaultColor = defaults.color;
|
|
12571
|
+
const defaultColor = defaults$1.color;
|
|
12568
12572
|
const rtlHelper = getRtlAdapter(opts.rtl, this.left, this.width);
|
|
12569
12573
|
const labelFont = toFont(labelOpts.font);
|
|
12570
12574
|
const { padding } = labelOpts;
|
|
@@ -13038,7 +13042,7 @@ var plugin_title = {
|
|
|
13038
13042
|
}
|
|
13039
13043
|
};
|
|
13040
13044
|
|
|
13041
|
-
const positioners = {
|
|
13045
|
+
const positioners$2 = {
|
|
13042
13046
|
average (items) {
|
|
13043
13047
|
if (!items.length) {
|
|
13044
13048
|
return false;
|
|
@@ -13353,7 +13357,7 @@ const defaultCallbacks = {
|
|
|
13353
13357
|
return result;
|
|
13354
13358
|
}
|
|
13355
13359
|
class Tooltip extends Element {
|
|
13356
|
-
static positioners = positioners;
|
|
13360
|
+
static positioners = positioners$2;
|
|
13357
13361
|
constructor(config){
|
|
13358
13362
|
super();
|
|
13359
13363
|
this.opacity = 0;
|
|
@@ -13492,7 +13496,7 @@ class Tooltip extends Element {
|
|
|
13492
13496
|
};
|
|
13493
13497
|
}
|
|
13494
13498
|
} else {
|
|
13495
|
-
const position = positioners[options.position].call(this, active, this._eventPosition);
|
|
13499
|
+
const position = positioners$2[options.position].call(this, active, this._eventPosition);
|
|
13496
13500
|
tooltipItems = this._createItems(options);
|
|
13497
13501
|
this.title = this.getTitle(tooltipItems, options);
|
|
13498
13502
|
this.beforeBody = this.getBeforeBody(tooltipItems, options);
|
|
@@ -13773,7 +13777,7 @@ class Tooltip extends Element {
|
|
|
13773
13777
|
const animX = anims && anims.x;
|
|
13774
13778
|
const animY = anims && anims.y;
|
|
13775
13779
|
if (animX || animY) {
|
|
13776
|
-
const position = positioners[options.position].call(this, this._active, this._eventPosition);
|
|
13780
|
+
const position = positioners$2[options.position].call(this, this._active, this._eventPosition);
|
|
13777
13781
|
if (!position) {
|
|
13778
13782
|
return;
|
|
13779
13783
|
}
|
|
@@ -13889,14 +13893,14 @@ class Tooltip extends Element {
|
|
|
13889
13893
|
}
|
|
13890
13894
|
_positionChanged(active, e) {
|
|
13891
13895
|
const { caretX , caretY , options } = this;
|
|
13892
|
-
const position = positioners[options.position].call(this, active, e);
|
|
13896
|
+
const position = positioners$2[options.position].call(this, active, e);
|
|
13893
13897
|
return position !== false && (caretX !== position.x || caretY !== position.y);
|
|
13894
13898
|
}
|
|
13895
13899
|
}
|
|
13896
13900
|
var plugin_tooltip = {
|
|
13897
13901
|
id: 'tooltip',
|
|
13898
13902
|
_element: Tooltip,
|
|
13899
|
-
positioners,
|
|
13903
|
+
positioners: positioners$2,
|
|
13900
13904
|
afterInit (chart, _args, options) {
|
|
13901
13905
|
if (options) {
|
|
13902
13906
|
chart.tooltip = new Tooltip({
|
|
@@ -15162,7 +15166,7 @@ function BarChart({ orientation, title, data, options, className, units, content
|
|
|
15162
15166
|
}
|
|
15163
15167
|
|
|
15164
15168
|
Chart$1.register(CategoryScale, LinearScale, BarElement, plugin_title, plugin_tooltip, plugin_legend);
|
|
15165
|
-
function SeriesChart({ orientation, title, data, options, className, units, content }) {
|
|
15169
|
+
function SeriesChart({ orientation, title, data, options, className, units, content, x_axis_title, y_axis_title }) {
|
|
15166
15170
|
var _a, _b;
|
|
15167
15171
|
const formatValue = (value) => {
|
|
15168
15172
|
const numValue = typeof value === 'string' ? parseFloat(value) : value;
|
|
@@ -15249,12 +15253,16 @@ function SeriesChart({ orientation, title, data, options, className, units, cont
|
|
|
15249
15253
|
},
|
|
15250
15254
|
scales: {
|
|
15251
15255
|
x: {
|
|
15256
|
+
title: {
|
|
15257
|
+
display: !!x_axis_title,
|
|
15258
|
+
text: x_axis_title,
|
|
15259
|
+
},
|
|
15252
15260
|
ticks: { autoSkip: false, maxRotation: 45, minRotation: 0 },
|
|
15253
15261
|
},
|
|
15254
15262
|
y: {
|
|
15255
15263
|
title: {
|
|
15256
15264
|
display: true,
|
|
15257
|
-
text: (data === null || data === void 0 ? void 0 : data.datasets) && ((_a = data === null || data === void 0 ? void 0 : data.datasets) === null || _a === void 0 ? void 0 : _a.length) === 1 ? (_b = data === null || data === void 0 ? void 0 : data.datasets) === null || _b === void 0 ? void 0 : _b[0].label : getAxisLabel(units !== null && units !== void 0 ? units : ""),
|
|
15265
|
+
text: y_axis_title || ((data === null || data === void 0 ? void 0 : data.datasets) && ((_a = data === null || data === void 0 ? void 0 : data.datasets) === null || _a === void 0 ? void 0 : _a.length) === 1 ? (_b = data === null || data === void 0 ? void 0 : data.datasets) === null || _b === void 0 ? void 0 : _b[0].label : getAxisLabel(units !== null && units !== void 0 ? units : "")),
|
|
15258
15266
|
},
|
|
15259
15267
|
beginAtZero: true,
|
|
15260
15268
|
ticks: {
|
|
@@ -15271,9 +15279,1358 @@ function SeriesChart({ orientation, title, data, options, className, units, cont
|
|
|
15271
15279
|
return (jsxRuntimeExports.jsx(Bar, { data: data, options: options !== null && options !== void 0 ? options : defaultOptions, plugins: [barValuePlugin] }));
|
|
15272
15280
|
}
|
|
15273
15281
|
|
|
15282
|
+
/*!
|
|
15283
|
+
* chartjs-plugin-datalabels v2.2.0
|
|
15284
|
+
* https://chartjs-plugin-datalabels.netlify.app
|
|
15285
|
+
* (c) 2017-2022 chartjs-plugin-datalabels contributors
|
|
15286
|
+
* Released under the MIT license
|
|
15287
|
+
*/
|
|
15288
|
+
|
|
15289
|
+
var devicePixelRatio = (function() {
|
|
15290
|
+
if (typeof window !== 'undefined') {
|
|
15291
|
+
if (window.devicePixelRatio) {
|
|
15292
|
+
return window.devicePixelRatio;
|
|
15293
|
+
}
|
|
15294
|
+
|
|
15295
|
+
// devicePixelRatio is undefined on IE10
|
|
15296
|
+
// https://stackoverflow.com/a/20204180/8837887
|
|
15297
|
+
// https://github.com/chartjs/chartjs-plugin-datalabels/issues/85
|
|
15298
|
+
var screen = window.screen;
|
|
15299
|
+
if (screen) {
|
|
15300
|
+
return (screen.deviceXDPI || 1) / (screen.logicalXDPI || 1);
|
|
15301
|
+
}
|
|
15302
|
+
}
|
|
15303
|
+
|
|
15304
|
+
return 1;
|
|
15305
|
+
}());
|
|
15306
|
+
|
|
15307
|
+
var utils = {
|
|
15308
|
+
// @todo move this in Chart.helpers.toTextLines
|
|
15309
|
+
toTextLines: function(inputs) {
|
|
15310
|
+
var lines = [];
|
|
15311
|
+
var input;
|
|
15312
|
+
|
|
15313
|
+
inputs = [].concat(inputs);
|
|
15314
|
+
while (inputs.length) {
|
|
15315
|
+
input = inputs.pop();
|
|
15316
|
+
if (typeof input === 'string') {
|
|
15317
|
+
lines.unshift.apply(lines, input.split('\n'));
|
|
15318
|
+
} else if (Array.isArray(input)) {
|
|
15319
|
+
inputs.push.apply(inputs, input);
|
|
15320
|
+
} else if (!isNullOrUndef(inputs)) {
|
|
15321
|
+
lines.unshift('' + input);
|
|
15322
|
+
}
|
|
15323
|
+
}
|
|
15324
|
+
|
|
15325
|
+
return lines;
|
|
15326
|
+
},
|
|
15327
|
+
|
|
15328
|
+
// @todo move this in Chart.helpers.canvas.textSize
|
|
15329
|
+
// @todo cache calls of measureText if font doesn't change?!
|
|
15330
|
+
textSize: function(ctx, lines, font) {
|
|
15331
|
+
var items = [].concat(lines);
|
|
15332
|
+
var ilen = items.length;
|
|
15333
|
+
var prev = ctx.font;
|
|
15334
|
+
var width = 0;
|
|
15335
|
+
var i;
|
|
15336
|
+
|
|
15337
|
+
ctx.font = font.string;
|
|
15338
|
+
|
|
15339
|
+
for (i = 0; i < ilen; ++i) {
|
|
15340
|
+
width = Math.max(ctx.measureText(items[i]).width, width);
|
|
15341
|
+
}
|
|
15342
|
+
|
|
15343
|
+
ctx.font = prev;
|
|
15344
|
+
|
|
15345
|
+
return {
|
|
15346
|
+
height: ilen * font.lineHeight,
|
|
15347
|
+
width: width
|
|
15348
|
+
};
|
|
15349
|
+
},
|
|
15350
|
+
|
|
15351
|
+
/**
|
|
15352
|
+
* Returns value bounded by min and max. This is equivalent to max(min, min(value, max)).
|
|
15353
|
+
* @todo move this method in Chart.helpers.bound
|
|
15354
|
+
* https://doc.qt.io/qt-5/qtglobal.html#qBound
|
|
15355
|
+
*/
|
|
15356
|
+
bound: function(min, value, max) {
|
|
15357
|
+
return Math.max(min, Math.min(value, max));
|
|
15358
|
+
},
|
|
15359
|
+
|
|
15360
|
+
/**
|
|
15361
|
+
* Returns an array of pair [value, state] where state is:
|
|
15362
|
+
* * -1: value is only in a0 (removed)
|
|
15363
|
+
* * 1: value is only in a1 (added)
|
|
15364
|
+
*/
|
|
15365
|
+
arrayDiff: function(a0, a1) {
|
|
15366
|
+
var prev = a0.slice();
|
|
15367
|
+
var updates = [];
|
|
15368
|
+
var i, j, ilen, v;
|
|
15369
|
+
|
|
15370
|
+
for (i = 0, ilen = a1.length; i < ilen; ++i) {
|
|
15371
|
+
v = a1[i];
|
|
15372
|
+
j = prev.indexOf(v);
|
|
15373
|
+
|
|
15374
|
+
if (j === -1) {
|
|
15375
|
+
updates.push([v, 1]);
|
|
15376
|
+
} else {
|
|
15377
|
+
prev.splice(j, 1);
|
|
15378
|
+
}
|
|
15379
|
+
}
|
|
15380
|
+
|
|
15381
|
+
for (i = 0, ilen = prev.length; i < ilen; ++i) {
|
|
15382
|
+
updates.push([prev[i], -1]);
|
|
15383
|
+
}
|
|
15384
|
+
|
|
15385
|
+
return updates;
|
|
15386
|
+
},
|
|
15387
|
+
|
|
15388
|
+
/**
|
|
15389
|
+
* https://github.com/chartjs/chartjs-plugin-datalabels/issues/70
|
|
15390
|
+
*/
|
|
15391
|
+
rasterize: function(v) {
|
|
15392
|
+
return Math.round(v * devicePixelRatio) / devicePixelRatio;
|
|
15393
|
+
}
|
|
15394
|
+
};
|
|
15395
|
+
|
|
15396
|
+
function orient(point, origin) {
|
|
15397
|
+
var x0 = origin.x;
|
|
15398
|
+
var y0 = origin.y;
|
|
15399
|
+
|
|
15400
|
+
if (x0 === null) {
|
|
15401
|
+
return {x: 0, y: -1};
|
|
15402
|
+
}
|
|
15403
|
+
if (y0 === null) {
|
|
15404
|
+
return {x: 1, y: 0};
|
|
15405
|
+
}
|
|
15406
|
+
|
|
15407
|
+
var dx = point.x - x0;
|
|
15408
|
+
var dy = point.y - y0;
|
|
15409
|
+
var ln = Math.sqrt(dx * dx + dy * dy);
|
|
15410
|
+
|
|
15411
|
+
return {
|
|
15412
|
+
x: ln ? dx / ln : 0,
|
|
15413
|
+
y: ln ? dy / ln : -1
|
|
15414
|
+
};
|
|
15415
|
+
}
|
|
15416
|
+
|
|
15417
|
+
function aligned(x, y, vx, vy, align) {
|
|
15418
|
+
switch (align) {
|
|
15419
|
+
case 'center':
|
|
15420
|
+
vx = vy = 0;
|
|
15421
|
+
break;
|
|
15422
|
+
case 'bottom':
|
|
15423
|
+
vx = 0;
|
|
15424
|
+
vy = 1;
|
|
15425
|
+
break;
|
|
15426
|
+
case 'right':
|
|
15427
|
+
vx = 1;
|
|
15428
|
+
vy = 0;
|
|
15429
|
+
break;
|
|
15430
|
+
case 'left':
|
|
15431
|
+
vx = -1;
|
|
15432
|
+
vy = 0;
|
|
15433
|
+
break;
|
|
15434
|
+
case 'top':
|
|
15435
|
+
vx = 0;
|
|
15436
|
+
vy = -1;
|
|
15437
|
+
break;
|
|
15438
|
+
case 'start':
|
|
15439
|
+
vx = -vx;
|
|
15440
|
+
vy = -vy;
|
|
15441
|
+
break;
|
|
15442
|
+
case 'end':
|
|
15443
|
+
// keep natural orientation
|
|
15444
|
+
break;
|
|
15445
|
+
default:
|
|
15446
|
+
// clockwise rotation (in degree)
|
|
15447
|
+
align *= (Math.PI / 180);
|
|
15448
|
+
vx = Math.cos(align);
|
|
15449
|
+
vy = Math.sin(align);
|
|
15450
|
+
break;
|
|
15451
|
+
}
|
|
15452
|
+
|
|
15453
|
+
return {
|
|
15454
|
+
x: x,
|
|
15455
|
+
y: y,
|
|
15456
|
+
vx: vx,
|
|
15457
|
+
vy: vy
|
|
15458
|
+
};
|
|
15459
|
+
}
|
|
15460
|
+
|
|
15461
|
+
// Line clipping (Cohen–Sutherland algorithm)
|
|
15462
|
+
// https://en.wikipedia.org/wiki/Cohen–Sutherland_algorithm
|
|
15463
|
+
|
|
15464
|
+
var R_INSIDE = 0;
|
|
15465
|
+
var R_LEFT = 1;
|
|
15466
|
+
var R_RIGHT = 2;
|
|
15467
|
+
var R_BOTTOM = 4;
|
|
15468
|
+
var R_TOP = 8;
|
|
15469
|
+
|
|
15470
|
+
function region(x, y, rect) {
|
|
15471
|
+
var res = R_INSIDE;
|
|
15472
|
+
|
|
15473
|
+
if (x < rect.left) {
|
|
15474
|
+
res |= R_LEFT;
|
|
15475
|
+
} else if (x > rect.right) {
|
|
15476
|
+
res |= R_RIGHT;
|
|
15477
|
+
}
|
|
15478
|
+
if (y < rect.top) {
|
|
15479
|
+
res |= R_TOP;
|
|
15480
|
+
} else if (y > rect.bottom) {
|
|
15481
|
+
res |= R_BOTTOM;
|
|
15482
|
+
}
|
|
15483
|
+
|
|
15484
|
+
return res;
|
|
15485
|
+
}
|
|
15486
|
+
|
|
15487
|
+
function clipped(segment, area) {
|
|
15488
|
+
var x0 = segment.x0;
|
|
15489
|
+
var y0 = segment.y0;
|
|
15490
|
+
var x1 = segment.x1;
|
|
15491
|
+
var y1 = segment.y1;
|
|
15492
|
+
var r0 = region(x0, y0, area);
|
|
15493
|
+
var r1 = region(x1, y1, area);
|
|
15494
|
+
var r, x, y;
|
|
15495
|
+
|
|
15496
|
+
// eslint-disable-next-line no-constant-condition
|
|
15497
|
+
while (true) {
|
|
15498
|
+
if (!(r0 | r1) || (r0 & r1)) {
|
|
15499
|
+
// both points inside or on the same side: no clipping
|
|
15500
|
+
break;
|
|
15501
|
+
}
|
|
15502
|
+
|
|
15503
|
+
// at least one point is outside
|
|
15504
|
+
r = r0 || r1;
|
|
15505
|
+
|
|
15506
|
+
if (r & R_TOP) {
|
|
15507
|
+
x = x0 + (x1 - x0) * (area.top - y0) / (y1 - y0);
|
|
15508
|
+
y = area.top;
|
|
15509
|
+
} else if (r & R_BOTTOM) {
|
|
15510
|
+
x = x0 + (x1 - x0) * (area.bottom - y0) / (y1 - y0);
|
|
15511
|
+
y = area.bottom;
|
|
15512
|
+
} else if (r & R_RIGHT) {
|
|
15513
|
+
y = y0 + (y1 - y0) * (area.right - x0) / (x1 - x0);
|
|
15514
|
+
x = area.right;
|
|
15515
|
+
} else if (r & R_LEFT) {
|
|
15516
|
+
y = y0 + (y1 - y0) * (area.left - x0) / (x1 - x0);
|
|
15517
|
+
x = area.left;
|
|
15518
|
+
}
|
|
15519
|
+
|
|
15520
|
+
if (r === r0) {
|
|
15521
|
+
x0 = x;
|
|
15522
|
+
y0 = y;
|
|
15523
|
+
r0 = region(x0, y0, area);
|
|
15524
|
+
} else {
|
|
15525
|
+
x1 = x;
|
|
15526
|
+
y1 = y;
|
|
15527
|
+
r1 = region(x1, y1, area);
|
|
15528
|
+
}
|
|
15529
|
+
}
|
|
15530
|
+
|
|
15531
|
+
return {
|
|
15532
|
+
x0: x0,
|
|
15533
|
+
x1: x1,
|
|
15534
|
+
y0: y0,
|
|
15535
|
+
y1: y1
|
|
15536
|
+
};
|
|
15537
|
+
}
|
|
15538
|
+
|
|
15539
|
+
function compute$1(range, config) {
|
|
15540
|
+
var anchor = config.anchor;
|
|
15541
|
+
var segment = range;
|
|
15542
|
+
var x, y;
|
|
15543
|
+
|
|
15544
|
+
if (config.clamp) {
|
|
15545
|
+
segment = clipped(segment, config.area);
|
|
15546
|
+
}
|
|
15547
|
+
|
|
15548
|
+
if (anchor === 'start') {
|
|
15549
|
+
x = segment.x0;
|
|
15550
|
+
y = segment.y0;
|
|
15551
|
+
} else if (anchor === 'end') {
|
|
15552
|
+
x = segment.x1;
|
|
15553
|
+
y = segment.y1;
|
|
15554
|
+
} else {
|
|
15555
|
+
x = (segment.x0 + segment.x1) / 2;
|
|
15556
|
+
y = (segment.y0 + segment.y1) / 2;
|
|
15557
|
+
}
|
|
15558
|
+
|
|
15559
|
+
return aligned(x, y, range.vx, range.vy, config.align);
|
|
15560
|
+
}
|
|
15561
|
+
|
|
15562
|
+
var positioners$1 = {
|
|
15563
|
+
arc: function(el, config) {
|
|
15564
|
+
var angle = (el.startAngle + el.endAngle) / 2;
|
|
15565
|
+
var vx = Math.cos(angle);
|
|
15566
|
+
var vy = Math.sin(angle);
|
|
15567
|
+
var r0 = el.innerRadius;
|
|
15568
|
+
var r1 = el.outerRadius;
|
|
15569
|
+
|
|
15570
|
+
return compute$1({
|
|
15571
|
+
x0: el.x + vx * r0,
|
|
15572
|
+
y0: el.y + vy * r0,
|
|
15573
|
+
x1: el.x + vx * r1,
|
|
15574
|
+
y1: el.y + vy * r1,
|
|
15575
|
+
vx: vx,
|
|
15576
|
+
vy: vy
|
|
15577
|
+
}, config);
|
|
15578
|
+
},
|
|
15579
|
+
|
|
15580
|
+
point: function(el, config) {
|
|
15581
|
+
var v = orient(el, config.origin);
|
|
15582
|
+
var rx = v.x * el.options.radius;
|
|
15583
|
+
var ry = v.y * el.options.radius;
|
|
15584
|
+
|
|
15585
|
+
return compute$1({
|
|
15586
|
+
x0: el.x - rx,
|
|
15587
|
+
y0: el.y - ry,
|
|
15588
|
+
x1: el.x + rx,
|
|
15589
|
+
y1: el.y + ry,
|
|
15590
|
+
vx: v.x,
|
|
15591
|
+
vy: v.y
|
|
15592
|
+
}, config);
|
|
15593
|
+
},
|
|
15594
|
+
|
|
15595
|
+
bar: function(el, config) {
|
|
15596
|
+
var v = orient(el, config.origin);
|
|
15597
|
+
var x = el.x;
|
|
15598
|
+
var y = el.y;
|
|
15599
|
+
var sx = 0;
|
|
15600
|
+
var sy = 0;
|
|
15601
|
+
|
|
15602
|
+
if (el.horizontal) {
|
|
15603
|
+
x = Math.min(el.x, el.base);
|
|
15604
|
+
sx = Math.abs(el.base - el.x);
|
|
15605
|
+
} else {
|
|
15606
|
+
y = Math.min(el.y, el.base);
|
|
15607
|
+
sy = Math.abs(el.base - el.y);
|
|
15608
|
+
}
|
|
15609
|
+
|
|
15610
|
+
return compute$1({
|
|
15611
|
+
x0: x,
|
|
15612
|
+
y0: y + sy,
|
|
15613
|
+
x1: x + sx,
|
|
15614
|
+
y1: y,
|
|
15615
|
+
vx: v.x,
|
|
15616
|
+
vy: v.y
|
|
15617
|
+
}, config);
|
|
15618
|
+
},
|
|
15619
|
+
|
|
15620
|
+
fallback: function(el, config) {
|
|
15621
|
+
var v = orient(el, config.origin);
|
|
15622
|
+
|
|
15623
|
+
return compute$1({
|
|
15624
|
+
x0: el.x,
|
|
15625
|
+
y0: el.y,
|
|
15626
|
+
x1: el.x + (el.width || 0),
|
|
15627
|
+
y1: el.y + (el.height || 0),
|
|
15628
|
+
vx: v.x,
|
|
15629
|
+
vy: v.y
|
|
15630
|
+
}, config);
|
|
15631
|
+
}
|
|
15632
|
+
};
|
|
15633
|
+
|
|
15634
|
+
var rasterize = utils.rasterize;
|
|
15635
|
+
|
|
15636
|
+
function boundingRects(model) {
|
|
15637
|
+
var borderWidth = model.borderWidth || 0;
|
|
15638
|
+
var padding = model.padding;
|
|
15639
|
+
var th = model.size.height;
|
|
15640
|
+
var tw = model.size.width;
|
|
15641
|
+
var tx = -tw / 2;
|
|
15642
|
+
var ty = -th / 2;
|
|
15643
|
+
|
|
15644
|
+
return {
|
|
15645
|
+
frame: {
|
|
15646
|
+
x: tx - padding.left - borderWidth,
|
|
15647
|
+
y: ty - padding.top - borderWidth,
|
|
15648
|
+
w: tw + padding.width + borderWidth * 2,
|
|
15649
|
+
h: th + padding.height + borderWidth * 2
|
|
15650
|
+
},
|
|
15651
|
+
text: {
|
|
15652
|
+
x: tx,
|
|
15653
|
+
y: ty,
|
|
15654
|
+
w: tw,
|
|
15655
|
+
h: th
|
|
15656
|
+
}
|
|
15657
|
+
};
|
|
15658
|
+
}
|
|
15659
|
+
|
|
15660
|
+
function getScaleOrigin(el, context) {
|
|
15661
|
+
var scale = context.chart.getDatasetMeta(context.datasetIndex).vScale;
|
|
15662
|
+
|
|
15663
|
+
if (!scale) {
|
|
15664
|
+
return null;
|
|
15665
|
+
}
|
|
15666
|
+
|
|
15667
|
+
if (scale.xCenter !== undefined && scale.yCenter !== undefined) {
|
|
15668
|
+
return {x: scale.xCenter, y: scale.yCenter};
|
|
15669
|
+
}
|
|
15670
|
+
|
|
15671
|
+
var pixel = scale.getBasePixel();
|
|
15672
|
+
return el.horizontal ?
|
|
15673
|
+
{x: pixel, y: null} :
|
|
15674
|
+
{x: null, y: pixel};
|
|
15675
|
+
}
|
|
15676
|
+
|
|
15677
|
+
function getPositioner(el) {
|
|
15678
|
+
if (el instanceof ArcElement) {
|
|
15679
|
+
return positioners$1.arc;
|
|
15680
|
+
}
|
|
15681
|
+
if (el instanceof PointElement) {
|
|
15682
|
+
return positioners$1.point;
|
|
15683
|
+
}
|
|
15684
|
+
if (el instanceof BarElement) {
|
|
15685
|
+
return positioners$1.bar;
|
|
15686
|
+
}
|
|
15687
|
+
return positioners$1.fallback;
|
|
15688
|
+
}
|
|
15689
|
+
|
|
15690
|
+
function drawRoundedRect(ctx, x, y, w, h, radius) {
|
|
15691
|
+
var HALF_PI = Math.PI / 2;
|
|
15692
|
+
|
|
15693
|
+
if (radius) {
|
|
15694
|
+
var r = Math.min(radius, h / 2, w / 2);
|
|
15695
|
+
var left = x + r;
|
|
15696
|
+
var top = y + r;
|
|
15697
|
+
var right = x + w - r;
|
|
15698
|
+
var bottom = y + h - r;
|
|
15699
|
+
|
|
15700
|
+
ctx.moveTo(x, top);
|
|
15701
|
+
if (left < right && top < bottom) {
|
|
15702
|
+
ctx.arc(left, top, r, -Math.PI, -HALF_PI);
|
|
15703
|
+
ctx.arc(right, top, r, -HALF_PI, 0);
|
|
15704
|
+
ctx.arc(right, bottom, r, 0, HALF_PI);
|
|
15705
|
+
ctx.arc(left, bottom, r, HALF_PI, Math.PI);
|
|
15706
|
+
} else if (left < right) {
|
|
15707
|
+
ctx.moveTo(left, y);
|
|
15708
|
+
ctx.arc(right, top, r, -HALF_PI, HALF_PI);
|
|
15709
|
+
ctx.arc(left, top, r, HALF_PI, Math.PI + HALF_PI);
|
|
15710
|
+
} else if (top < bottom) {
|
|
15711
|
+
ctx.arc(left, top, r, -Math.PI, 0);
|
|
15712
|
+
ctx.arc(left, bottom, r, 0, Math.PI);
|
|
15713
|
+
} else {
|
|
15714
|
+
ctx.arc(left, top, r, -Math.PI, Math.PI);
|
|
15715
|
+
}
|
|
15716
|
+
ctx.closePath();
|
|
15717
|
+
ctx.moveTo(x, y);
|
|
15718
|
+
} else {
|
|
15719
|
+
ctx.rect(x, y, w, h);
|
|
15720
|
+
}
|
|
15721
|
+
}
|
|
15722
|
+
|
|
15723
|
+
function drawFrame(ctx, rect, model) {
|
|
15724
|
+
var bgColor = model.backgroundColor;
|
|
15725
|
+
var borderColor = model.borderColor;
|
|
15726
|
+
var borderWidth = model.borderWidth;
|
|
15727
|
+
|
|
15728
|
+
if (!bgColor && (!borderColor || !borderWidth)) {
|
|
15729
|
+
return;
|
|
15730
|
+
}
|
|
15731
|
+
|
|
15732
|
+
ctx.beginPath();
|
|
15733
|
+
|
|
15734
|
+
drawRoundedRect(
|
|
15735
|
+
ctx,
|
|
15736
|
+
rasterize(rect.x) + borderWidth / 2,
|
|
15737
|
+
rasterize(rect.y) + borderWidth / 2,
|
|
15738
|
+
rasterize(rect.w) - borderWidth,
|
|
15739
|
+
rasterize(rect.h) - borderWidth,
|
|
15740
|
+
model.borderRadius);
|
|
15741
|
+
|
|
15742
|
+
ctx.closePath();
|
|
15743
|
+
|
|
15744
|
+
if (bgColor) {
|
|
15745
|
+
ctx.fillStyle = bgColor;
|
|
15746
|
+
ctx.fill();
|
|
15747
|
+
}
|
|
15748
|
+
|
|
15749
|
+
if (borderColor && borderWidth) {
|
|
15750
|
+
ctx.strokeStyle = borderColor;
|
|
15751
|
+
ctx.lineWidth = borderWidth;
|
|
15752
|
+
ctx.lineJoin = 'miter';
|
|
15753
|
+
ctx.stroke();
|
|
15754
|
+
}
|
|
15755
|
+
}
|
|
15756
|
+
|
|
15757
|
+
function textGeometry(rect, align, font) {
|
|
15758
|
+
var h = font.lineHeight;
|
|
15759
|
+
var w = rect.w;
|
|
15760
|
+
var x = rect.x;
|
|
15761
|
+
var y = rect.y + h / 2;
|
|
15762
|
+
|
|
15763
|
+
if (align === 'center') {
|
|
15764
|
+
x += w / 2;
|
|
15765
|
+
} else if (align === 'end' || align === 'right') {
|
|
15766
|
+
x += w;
|
|
15767
|
+
}
|
|
15768
|
+
|
|
15769
|
+
return {
|
|
15770
|
+
h: h,
|
|
15771
|
+
w: w,
|
|
15772
|
+
x: x,
|
|
15773
|
+
y: y
|
|
15774
|
+
};
|
|
15775
|
+
}
|
|
15776
|
+
|
|
15777
|
+
function drawTextLine(ctx, text, cfg) {
|
|
15778
|
+
var shadow = ctx.shadowBlur;
|
|
15779
|
+
var stroked = cfg.stroked;
|
|
15780
|
+
var x = rasterize(cfg.x);
|
|
15781
|
+
var y = rasterize(cfg.y);
|
|
15782
|
+
var w = rasterize(cfg.w);
|
|
15783
|
+
|
|
15784
|
+
if (stroked) {
|
|
15785
|
+
ctx.strokeText(text, x, y, w);
|
|
15786
|
+
}
|
|
15787
|
+
|
|
15788
|
+
if (cfg.filled) {
|
|
15789
|
+
if (shadow && stroked) {
|
|
15790
|
+
// Prevent drawing shadow on both the text stroke and fill, so
|
|
15791
|
+
// if the text is stroked, remove the shadow for the text fill.
|
|
15792
|
+
ctx.shadowBlur = 0;
|
|
15793
|
+
}
|
|
15794
|
+
|
|
15795
|
+
ctx.fillText(text, x, y, w);
|
|
15796
|
+
|
|
15797
|
+
if (shadow && stroked) {
|
|
15798
|
+
ctx.shadowBlur = shadow;
|
|
15799
|
+
}
|
|
15800
|
+
}
|
|
15801
|
+
}
|
|
15802
|
+
|
|
15803
|
+
function drawText(ctx, lines, rect, model) {
|
|
15804
|
+
var align = model.textAlign;
|
|
15805
|
+
var color = model.color;
|
|
15806
|
+
var filled = !!color;
|
|
15807
|
+
var font = model.font;
|
|
15808
|
+
var ilen = lines.length;
|
|
15809
|
+
var strokeColor = model.textStrokeColor;
|
|
15810
|
+
var strokeWidth = model.textStrokeWidth;
|
|
15811
|
+
var stroked = strokeColor && strokeWidth;
|
|
15812
|
+
var i;
|
|
15813
|
+
|
|
15814
|
+
if (!ilen || (!filled && !stroked)) {
|
|
15815
|
+
return;
|
|
15816
|
+
}
|
|
15817
|
+
|
|
15818
|
+
// Adjust coordinates based on text alignment and line height
|
|
15819
|
+
rect = textGeometry(rect, align, font);
|
|
15820
|
+
|
|
15821
|
+
ctx.font = font.string;
|
|
15822
|
+
ctx.textAlign = align;
|
|
15823
|
+
ctx.textBaseline = 'middle';
|
|
15824
|
+
ctx.shadowBlur = model.textShadowBlur;
|
|
15825
|
+
ctx.shadowColor = model.textShadowColor;
|
|
15826
|
+
|
|
15827
|
+
if (filled) {
|
|
15828
|
+
ctx.fillStyle = color;
|
|
15829
|
+
}
|
|
15830
|
+
if (stroked) {
|
|
15831
|
+
ctx.lineJoin = 'round';
|
|
15832
|
+
ctx.lineWidth = strokeWidth;
|
|
15833
|
+
ctx.strokeStyle = strokeColor;
|
|
15834
|
+
}
|
|
15835
|
+
|
|
15836
|
+
for (i = 0, ilen = lines.length; i < ilen; ++i) {
|
|
15837
|
+
drawTextLine(ctx, lines[i], {
|
|
15838
|
+
stroked: stroked,
|
|
15839
|
+
filled: filled,
|
|
15840
|
+
w: rect.w,
|
|
15841
|
+
x: rect.x,
|
|
15842
|
+
y: rect.y + rect.h * i
|
|
15843
|
+
});
|
|
15844
|
+
}
|
|
15845
|
+
}
|
|
15846
|
+
|
|
15847
|
+
var Label = function(config, ctx, el, index) {
|
|
15848
|
+
var me = this;
|
|
15849
|
+
|
|
15850
|
+
me._config = config;
|
|
15851
|
+
me._index = index;
|
|
15852
|
+
me._model = null;
|
|
15853
|
+
me._rects = null;
|
|
15854
|
+
me._ctx = ctx;
|
|
15855
|
+
me._el = el;
|
|
15856
|
+
};
|
|
15857
|
+
|
|
15858
|
+
merge$1(Label.prototype, {
|
|
15859
|
+
/**
|
|
15860
|
+
* @private
|
|
15861
|
+
*/
|
|
15862
|
+
_modelize: function(display, lines, config, context) {
|
|
15863
|
+
var me = this;
|
|
15864
|
+
var index = me._index;
|
|
15865
|
+
var font = toFont(resolve([config.font, {}], context, index));
|
|
15866
|
+
var color = resolve([config.color, defaults$1.color], context, index);
|
|
15867
|
+
|
|
15868
|
+
return {
|
|
15869
|
+
align: resolve([config.align, 'center'], context, index),
|
|
15870
|
+
anchor: resolve([config.anchor, 'center'], context, index),
|
|
15871
|
+
area: context.chart.chartArea,
|
|
15872
|
+
backgroundColor: resolve([config.backgroundColor, null], context, index),
|
|
15873
|
+
borderColor: resolve([config.borderColor, null], context, index),
|
|
15874
|
+
borderRadius: resolve([config.borderRadius, 0], context, index),
|
|
15875
|
+
borderWidth: resolve([config.borderWidth, 0], context, index),
|
|
15876
|
+
clamp: resolve([config.clamp, false], context, index),
|
|
15877
|
+
clip: resolve([config.clip, false], context, index),
|
|
15878
|
+
color: color,
|
|
15879
|
+
display: display,
|
|
15880
|
+
font: font,
|
|
15881
|
+
lines: lines,
|
|
15882
|
+
offset: resolve([config.offset, 4], context, index),
|
|
15883
|
+
opacity: resolve([config.opacity, 1], context, index),
|
|
15884
|
+
origin: getScaleOrigin(me._el, context),
|
|
15885
|
+
padding: toPadding(resolve([config.padding, 4], context, index)),
|
|
15886
|
+
positioner: getPositioner(me._el),
|
|
15887
|
+
rotation: resolve([config.rotation, 0], context, index) * (Math.PI / 180),
|
|
15888
|
+
size: utils.textSize(me._ctx, lines, font),
|
|
15889
|
+
textAlign: resolve([config.textAlign, 'start'], context, index),
|
|
15890
|
+
textShadowBlur: resolve([config.textShadowBlur, 0], context, index),
|
|
15891
|
+
textShadowColor: resolve([config.textShadowColor, color], context, index),
|
|
15892
|
+
textStrokeColor: resolve([config.textStrokeColor, color], context, index),
|
|
15893
|
+
textStrokeWidth: resolve([config.textStrokeWidth, 0], context, index)
|
|
15894
|
+
};
|
|
15895
|
+
},
|
|
15896
|
+
|
|
15897
|
+
update: function(context) {
|
|
15898
|
+
var me = this;
|
|
15899
|
+
var model = null;
|
|
15900
|
+
var rects = null;
|
|
15901
|
+
var index = me._index;
|
|
15902
|
+
var config = me._config;
|
|
15903
|
+
var value, label, lines;
|
|
15904
|
+
|
|
15905
|
+
// We first resolve the display option (separately) to avoid computing
|
|
15906
|
+
// other options in case the label is hidden (i.e. display: false).
|
|
15907
|
+
var display = resolve([config.display, true], context, index);
|
|
15908
|
+
|
|
15909
|
+
if (display) {
|
|
15910
|
+
value = context.dataset.data[index];
|
|
15911
|
+
label = valueOrDefault(callback(config.formatter, [value, context]), value);
|
|
15912
|
+
lines = isNullOrUndef(label) ? [] : utils.toTextLines(label);
|
|
15913
|
+
|
|
15914
|
+
if (lines.length) {
|
|
15915
|
+
model = me._modelize(display, lines, config, context);
|
|
15916
|
+
rects = boundingRects(model);
|
|
15917
|
+
}
|
|
15918
|
+
}
|
|
15919
|
+
|
|
15920
|
+
me._model = model;
|
|
15921
|
+
me._rects = rects;
|
|
15922
|
+
},
|
|
15923
|
+
|
|
15924
|
+
geometry: function() {
|
|
15925
|
+
return this._rects ? this._rects.frame : {};
|
|
15926
|
+
},
|
|
15927
|
+
|
|
15928
|
+
rotation: function() {
|
|
15929
|
+
return this._model ? this._model.rotation : 0;
|
|
15930
|
+
},
|
|
15931
|
+
|
|
15932
|
+
visible: function() {
|
|
15933
|
+
return this._model && this._model.opacity;
|
|
15934
|
+
},
|
|
15935
|
+
|
|
15936
|
+
model: function() {
|
|
15937
|
+
return this._model;
|
|
15938
|
+
},
|
|
15939
|
+
|
|
15940
|
+
draw: function(chart, center) {
|
|
15941
|
+
var me = this;
|
|
15942
|
+
var ctx = chart.ctx;
|
|
15943
|
+
var model = me._model;
|
|
15944
|
+
var rects = me._rects;
|
|
15945
|
+
var area;
|
|
15946
|
+
|
|
15947
|
+
if (!this.visible()) {
|
|
15948
|
+
return;
|
|
15949
|
+
}
|
|
15950
|
+
|
|
15951
|
+
ctx.save();
|
|
15952
|
+
|
|
15953
|
+
if (model.clip) {
|
|
15954
|
+
area = model.area;
|
|
15955
|
+
ctx.beginPath();
|
|
15956
|
+
ctx.rect(
|
|
15957
|
+
area.left,
|
|
15958
|
+
area.top,
|
|
15959
|
+
area.right - area.left,
|
|
15960
|
+
area.bottom - area.top);
|
|
15961
|
+
ctx.clip();
|
|
15962
|
+
}
|
|
15963
|
+
|
|
15964
|
+
ctx.globalAlpha = utils.bound(0, model.opacity, 1);
|
|
15965
|
+
ctx.translate(rasterize(center.x), rasterize(center.y));
|
|
15966
|
+
ctx.rotate(model.rotation);
|
|
15967
|
+
|
|
15968
|
+
drawFrame(ctx, rects.frame, model);
|
|
15969
|
+
drawText(ctx, model.lines, rects.text, model);
|
|
15970
|
+
|
|
15971
|
+
ctx.restore();
|
|
15972
|
+
}
|
|
15973
|
+
});
|
|
15974
|
+
|
|
15975
|
+
var MIN_INTEGER = Number.MIN_SAFE_INTEGER || -9007199254740991; // eslint-disable-line es/no-number-minsafeinteger
|
|
15976
|
+
var MAX_INTEGER = Number.MAX_SAFE_INTEGER || 9007199254740991; // eslint-disable-line es/no-number-maxsafeinteger
|
|
15977
|
+
|
|
15978
|
+
function rotated(point, center, angle) {
|
|
15979
|
+
var cos = Math.cos(angle);
|
|
15980
|
+
var sin = Math.sin(angle);
|
|
15981
|
+
var cx = center.x;
|
|
15982
|
+
var cy = center.y;
|
|
15983
|
+
|
|
15984
|
+
return {
|
|
15985
|
+
x: cx + cos * (point.x - cx) - sin * (point.y - cy),
|
|
15986
|
+
y: cy + sin * (point.x - cx) + cos * (point.y - cy)
|
|
15987
|
+
};
|
|
15988
|
+
}
|
|
15989
|
+
|
|
15990
|
+
function projected(points, axis) {
|
|
15991
|
+
var min = MAX_INTEGER;
|
|
15992
|
+
var max = MIN_INTEGER;
|
|
15993
|
+
var origin = axis.origin;
|
|
15994
|
+
var i, pt, vx, vy, dp;
|
|
15995
|
+
|
|
15996
|
+
for (i = 0; i < points.length; ++i) {
|
|
15997
|
+
pt = points[i];
|
|
15998
|
+
vx = pt.x - origin.x;
|
|
15999
|
+
vy = pt.y - origin.y;
|
|
16000
|
+
dp = axis.vx * vx + axis.vy * vy;
|
|
16001
|
+
min = Math.min(min, dp);
|
|
16002
|
+
max = Math.max(max, dp);
|
|
16003
|
+
}
|
|
16004
|
+
|
|
16005
|
+
return {
|
|
16006
|
+
min: min,
|
|
16007
|
+
max: max
|
|
16008
|
+
};
|
|
16009
|
+
}
|
|
16010
|
+
|
|
16011
|
+
function toAxis(p0, p1) {
|
|
16012
|
+
var vx = p1.x - p0.x;
|
|
16013
|
+
var vy = p1.y - p0.y;
|
|
16014
|
+
var ln = Math.sqrt(vx * vx + vy * vy);
|
|
16015
|
+
|
|
16016
|
+
return {
|
|
16017
|
+
vx: (p1.x - p0.x) / ln,
|
|
16018
|
+
vy: (p1.y - p0.y) / ln,
|
|
16019
|
+
origin: p0,
|
|
16020
|
+
ln: ln
|
|
16021
|
+
};
|
|
16022
|
+
}
|
|
16023
|
+
|
|
16024
|
+
var HitBox = function() {
|
|
16025
|
+
this._rotation = 0;
|
|
16026
|
+
this._rect = {
|
|
16027
|
+
x: 0,
|
|
16028
|
+
y: 0,
|
|
16029
|
+
w: 0,
|
|
16030
|
+
h: 0
|
|
16031
|
+
};
|
|
16032
|
+
};
|
|
16033
|
+
|
|
16034
|
+
merge$1(HitBox.prototype, {
|
|
16035
|
+
center: function() {
|
|
16036
|
+
var r = this._rect;
|
|
16037
|
+
return {
|
|
16038
|
+
x: r.x + r.w / 2,
|
|
16039
|
+
y: r.y + r.h / 2
|
|
16040
|
+
};
|
|
16041
|
+
},
|
|
16042
|
+
|
|
16043
|
+
update: function(center, rect, rotation) {
|
|
16044
|
+
this._rotation = rotation;
|
|
16045
|
+
this._rect = {
|
|
16046
|
+
x: rect.x + center.x,
|
|
16047
|
+
y: rect.y + center.y,
|
|
16048
|
+
w: rect.w,
|
|
16049
|
+
h: rect.h
|
|
16050
|
+
};
|
|
16051
|
+
},
|
|
16052
|
+
|
|
16053
|
+
contains: function(point) {
|
|
16054
|
+
var me = this;
|
|
16055
|
+
var margin = 1;
|
|
16056
|
+
var rect = me._rect;
|
|
16057
|
+
|
|
16058
|
+
point = rotated(point, me.center(), -me._rotation);
|
|
16059
|
+
|
|
16060
|
+
return !(point.x < rect.x - margin
|
|
16061
|
+
|| point.y < rect.y - margin
|
|
16062
|
+
|| point.x > rect.x + rect.w + margin * 2
|
|
16063
|
+
|| point.y > rect.y + rect.h + margin * 2);
|
|
16064
|
+
},
|
|
16065
|
+
|
|
16066
|
+
// Separating Axis Theorem
|
|
16067
|
+
// https://gamedevelopment.tutsplus.com/tutorials/collision-detection-using-the-separating-axis-theorem--gamedev-169
|
|
16068
|
+
intersects: function(other) {
|
|
16069
|
+
var r0 = this._points();
|
|
16070
|
+
var r1 = other._points();
|
|
16071
|
+
var axes = [
|
|
16072
|
+
toAxis(r0[0], r0[1]),
|
|
16073
|
+
toAxis(r0[0], r0[3])
|
|
16074
|
+
];
|
|
16075
|
+
var i, pr0, pr1;
|
|
16076
|
+
|
|
16077
|
+
if (this._rotation !== other._rotation) {
|
|
16078
|
+
// Only separate with r1 axis if the rotation is different,
|
|
16079
|
+
// else it's enough to separate r0 and r1 with r0 axis only!
|
|
16080
|
+
axes.push(
|
|
16081
|
+
toAxis(r1[0], r1[1]),
|
|
16082
|
+
toAxis(r1[0], r1[3])
|
|
16083
|
+
);
|
|
16084
|
+
}
|
|
16085
|
+
|
|
16086
|
+
for (i = 0; i < axes.length; ++i) {
|
|
16087
|
+
pr0 = projected(r0, axes[i]);
|
|
16088
|
+
pr1 = projected(r1, axes[i]);
|
|
16089
|
+
|
|
16090
|
+
if (pr0.max < pr1.min || pr1.max < pr0.min) {
|
|
16091
|
+
return false;
|
|
16092
|
+
}
|
|
16093
|
+
}
|
|
16094
|
+
|
|
16095
|
+
return true;
|
|
16096
|
+
},
|
|
16097
|
+
|
|
16098
|
+
/**
|
|
16099
|
+
* @private
|
|
16100
|
+
*/
|
|
16101
|
+
_points: function() {
|
|
16102
|
+
var me = this;
|
|
16103
|
+
var rect = me._rect;
|
|
16104
|
+
var angle = me._rotation;
|
|
16105
|
+
var center = me.center();
|
|
16106
|
+
|
|
16107
|
+
return [
|
|
16108
|
+
rotated({x: rect.x, y: rect.y}, center, angle),
|
|
16109
|
+
rotated({x: rect.x + rect.w, y: rect.y}, center, angle),
|
|
16110
|
+
rotated({x: rect.x + rect.w, y: rect.y + rect.h}, center, angle),
|
|
16111
|
+
rotated({x: rect.x, y: rect.y + rect.h}, center, angle)
|
|
16112
|
+
];
|
|
16113
|
+
}
|
|
16114
|
+
});
|
|
16115
|
+
|
|
16116
|
+
function coordinates(el, model, geometry) {
|
|
16117
|
+
var point = model.positioner(el, model);
|
|
16118
|
+
var vx = point.vx;
|
|
16119
|
+
var vy = point.vy;
|
|
16120
|
+
|
|
16121
|
+
if (!vx && !vy) {
|
|
16122
|
+
// if aligned center, we don't want to offset the center point
|
|
16123
|
+
return {x: point.x, y: point.y};
|
|
16124
|
+
}
|
|
16125
|
+
|
|
16126
|
+
var w = geometry.w;
|
|
16127
|
+
var h = geometry.h;
|
|
16128
|
+
|
|
16129
|
+
// take in account the label rotation
|
|
16130
|
+
var rotation = model.rotation;
|
|
16131
|
+
var dx = Math.abs(w / 2 * Math.cos(rotation)) + Math.abs(h / 2 * Math.sin(rotation));
|
|
16132
|
+
var dy = Math.abs(w / 2 * Math.sin(rotation)) + Math.abs(h / 2 * Math.cos(rotation));
|
|
16133
|
+
|
|
16134
|
+
// scale the unit vector (vx, vy) to get at least dx or dy equal to
|
|
16135
|
+
// w or h respectively (else we would calculate the distance to the
|
|
16136
|
+
// ellipse inscribed in the bounding rect)
|
|
16137
|
+
var vs = 1 / Math.max(Math.abs(vx), Math.abs(vy));
|
|
16138
|
+
dx *= vx * vs;
|
|
16139
|
+
dy *= vy * vs;
|
|
16140
|
+
|
|
16141
|
+
// finally, include the explicit offset
|
|
16142
|
+
dx += model.offset * vx;
|
|
16143
|
+
dy += model.offset * vy;
|
|
16144
|
+
|
|
16145
|
+
return {
|
|
16146
|
+
x: point.x + dx,
|
|
16147
|
+
y: point.y + dy
|
|
16148
|
+
};
|
|
16149
|
+
}
|
|
16150
|
+
|
|
16151
|
+
function collide(labels, collider) {
|
|
16152
|
+
var i, j, s0, s1;
|
|
16153
|
+
|
|
16154
|
+
// IMPORTANT Iterate in the reverse order since items at the end of the
|
|
16155
|
+
// list have an higher weight/priority and thus should be less impacted
|
|
16156
|
+
// by the overlapping strategy.
|
|
16157
|
+
|
|
16158
|
+
for (i = labels.length - 1; i >= 0; --i) {
|
|
16159
|
+
s0 = labels[i].$layout;
|
|
16160
|
+
|
|
16161
|
+
for (j = i - 1; j >= 0 && s0._visible; --j) {
|
|
16162
|
+
s1 = labels[j].$layout;
|
|
16163
|
+
|
|
16164
|
+
if (s1._visible && s0._box.intersects(s1._box)) {
|
|
16165
|
+
collider(s0, s1);
|
|
16166
|
+
}
|
|
16167
|
+
}
|
|
16168
|
+
}
|
|
16169
|
+
|
|
16170
|
+
return labels;
|
|
16171
|
+
}
|
|
16172
|
+
|
|
16173
|
+
function compute(labels) {
|
|
16174
|
+
var i, ilen, label, state, geometry, center, proxy;
|
|
16175
|
+
|
|
16176
|
+
// Initialize labels for overlap detection
|
|
16177
|
+
for (i = 0, ilen = labels.length; i < ilen; ++i) {
|
|
16178
|
+
label = labels[i];
|
|
16179
|
+
state = label.$layout;
|
|
16180
|
+
|
|
16181
|
+
if (state._visible) {
|
|
16182
|
+
// Chart.js 3 removed el._model in favor of getProps(), making harder to
|
|
16183
|
+
// abstract reading values in positioners. Also, using string arrays to
|
|
16184
|
+
// read values (i.e. var {a,b,c} = el.getProps(["a","b","c"])) would make
|
|
16185
|
+
// positioners inefficient in the normal case (i.e. not the final values)
|
|
16186
|
+
// and the code a bit ugly, so let's use a Proxy instead.
|
|
16187
|
+
proxy = new Proxy(label._el, {get: (el, p) => el.getProps([p], true)[p]});
|
|
16188
|
+
|
|
16189
|
+
geometry = label.geometry();
|
|
16190
|
+
center = coordinates(proxy, label.model(), geometry);
|
|
16191
|
+
state._box.update(center, geometry, label.rotation());
|
|
16192
|
+
}
|
|
16193
|
+
}
|
|
16194
|
+
|
|
16195
|
+
// Auto hide overlapping labels
|
|
16196
|
+
return collide(labels, function(s0, s1) {
|
|
16197
|
+
var h0 = s0._hidable;
|
|
16198
|
+
var h1 = s1._hidable;
|
|
16199
|
+
|
|
16200
|
+
if ((h0 && h1) || h1) {
|
|
16201
|
+
s1._visible = false;
|
|
16202
|
+
} else if (h0) {
|
|
16203
|
+
s0._visible = false;
|
|
16204
|
+
}
|
|
16205
|
+
});
|
|
16206
|
+
}
|
|
16207
|
+
|
|
16208
|
+
var layout = {
|
|
16209
|
+
prepare: function(datasets) {
|
|
16210
|
+
var labels = [];
|
|
16211
|
+
var i, j, ilen, jlen, label;
|
|
16212
|
+
|
|
16213
|
+
for (i = 0, ilen = datasets.length; i < ilen; ++i) {
|
|
16214
|
+
for (j = 0, jlen = datasets[i].length; j < jlen; ++j) {
|
|
16215
|
+
label = datasets[i][j];
|
|
16216
|
+
labels.push(label);
|
|
16217
|
+
label.$layout = {
|
|
16218
|
+
_box: new HitBox(),
|
|
16219
|
+
_hidable: false,
|
|
16220
|
+
_visible: true,
|
|
16221
|
+
_set: i,
|
|
16222
|
+
_idx: label._index
|
|
16223
|
+
};
|
|
16224
|
+
}
|
|
16225
|
+
}
|
|
16226
|
+
|
|
16227
|
+
// TODO New `z` option: labels with a higher z-index are drawn
|
|
16228
|
+
// of top of the ones with a lower index. Lowest z-index labels
|
|
16229
|
+
// are also discarded first when hiding overlapping labels.
|
|
16230
|
+
labels.sort(function(a, b) {
|
|
16231
|
+
var sa = a.$layout;
|
|
16232
|
+
var sb = b.$layout;
|
|
16233
|
+
|
|
16234
|
+
return sa._idx === sb._idx
|
|
16235
|
+
? sb._set - sa._set
|
|
16236
|
+
: sb._idx - sa._idx;
|
|
16237
|
+
});
|
|
16238
|
+
|
|
16239
|
+
this.update(labels);
|
|
16240
|
+
|
|
16241
|
+
return labels;
|
|
16242
|
+
},
|
|
16243
|
+
|
|
16244
|
+
update: function(labels) {
|
|
16245
|
+
var dirty = false;
|
|
16246
|
+
var i, ilen, label, model, state;
|
|
16247
|
+
|
|
16248
|
+
for (i = 0, ilen = labels.length; i < ilen; ++i) {
|
|
16249
|
+
label = labels[i];
|
|
16250
|
+
model = label.model();
|
|
16251
|
+
state = label.$layout;
|
|
16252
|
+
state._hidable = model && model.display === 'auto';
|
|
16253
|
+
state._visible = label.visible();
|
|
16254
|
+
dirty |= state._hidable;
|
|
16255
|
+
}
|
|
16256
|
+
|
|
16257
|
+
if (dirty) {
|
|
16258
|
+
compute(labels);
|
|
16259
|
+
}
|
|
16260
|
+
},
|
|
16261
|
+
|
|
16262
|
+
lookup: function(labels, point) {
|
|
16263
|
+
var i, state;
|
|
16264
|
+
|
|
16265
|
+
// IMPORTANT Iterate in the reverse order since items at the end of
|
|
16266
|
+
// the list have an higher z-index, thus should be picked first.
|
|
16267
|
+
|
|
16268
|
+
for (i = labels.length - 1; i >= 0; --i) {
|
|
16269
|
+
state = labels[i].$layout;
|
|
16270
|
+
|
|
16271
|
+
if (state && state._visible && state._box.contains(point)) {
|
|
16272
|
+
return labels[i];
|
|
16273
|
+
}
|
|
16274
|
+
}
|
|
16275
|
+
|
|
16276
|
+
return null;
|
|
16277
|
+
},
|
|
16278
|
+
|
|
16279
|
+
draw: function(chart, labels) {
|
|
16280
|
+
var i, ilen, label, state, geometry, center;
|
|
16281
|
+
|
|
16282
|
+
for (i = 0, ilen = labels.length; i < ilen; ++i) {
|
|
16283
|
+
label = labels[i];
|
|
16284
|
+
state = label.$layout;
|
|
16285
|
+
|
|
16286
|
+
if (state._visible) {
|
|
16287
|
+
geometry = label.geometry();
|
|
16288
|
+
center = coordinates(label._el, label.model(), geometry);
|
|
16289
|
+
state._box.update(center, geometry, label.rotation());
|
|
16290
|
+
label.draw(chart, center);
|
|
16291
|
+
}
|
|
16292
|
+
}
|
|
16293
|
+
}
|
|
16294
|
+
};
|
|
16295
|
+
|
|
16296
|
+
var formatter = function(value) {
|
|
16297
|
+
if (isNullOrUndef(value)) {
|
|
16298
|
+
return null;
|
|
16299
|
+
}
|
|
16300
|
+
|
|
16301
|
+
var label = value;
|
|
16302
|
+
var keys, klen, k;
|
|
16303
|
+
if (isObject(value)) {
|
|
16304
|
+
if (!isNullOrUndef(value.label)) {
|
|
16305
|
+
label = value.label;
|
|
16306
|
+
} else if (!isNullOrUndef(value.r)) {
|
|
16307
|
+
label = value.r;
|
|
16308
|
+
} else {
|
|
16309
|
+
label = '';
|
|
16310
|
+
keys = Object.keys(value);
|
|
16311
|
+
for (k = 0, klen = keys.length; k < klen; ++k) {
|
|
16312
|
+
label += (k !== 0 ? ', ' : '') + keys[k] + ': ' + value[keys[k]];
|
|
16313
|
+
}
|
|
16314
|
+
}
|
|
16315
|
+
}
|
|
16316
|
+
|
|
16317
|
+
return '' + label;
|
|
16318
|
+
};
|
|
16319
|
+
|
|
16320
|
+
/**
|
|
16321
|
+
* IMPORTANT: make sure to also update tests and TypeScript definition
|
|
16322
|
+
* files (`/test/specs/defaults.spec.js` and `/types/options.d.ts`)
|
|
16323
|
+
*/
|
|
16324
|
+
|
|
16325
|
+
var defaults = {
|
|
16326
|
+
align: 'center',
|
|
16327
|
+
anchor: 'center',
|
|
16328
|
+
backgroundColor: null,
|
|
16329
|
+
borderColor: null,
|
|
16330
|
+
borderRadius: 0,
|
|
16331
|
+
borderWidth: 0,
|
|
16332
|
+
clamp: false,
|
|
16333
|
+
clip: false,
|
|
16334
|
+
color: undefined,
|
|
16335
|
+
display: true,
|
|
16336
|
+
font: {
|
|
16337
|
+
family: undefined,
|
|
16338
|
+
lineHeight: 1.2,
|
|
16339
|
+
size: undefined,
|
|
16340
|
+
style: undefined,
|
|
16341
|
+
weight: null
|
|
16342
|
+
},
|
|
16343
|
+
formatter: formatter,
|
|
16344
|
+
labels: undefined,
|
|
16345
|
+
listeners: {},
|
|
16346
|
+
offset: 4,
|
|
16347
|
+
opacity: 1,
|
|
16348
|
+
padding: {
|
|
16349
|
+
top: 4,
|
|
16350
|
+
right: 4,
|
|
16351
|
+
bottom: 4,
|
|
16352
|
+
left: 4
|
|
16353
|
+
},
|
|
16354
|
+
rotation: 0,
|
|
16355
|
+
textAlign: 'start',
|
|
16356
|
+
textStrokeColor: undefined,
|
|
16357
|
+
textStrokeWidth: 0,
|
|
16358
|
+
textShadowBlur: 0,
|
|
16359
|
+
textShadowColor: undefined
|
|
16360
|
+
};
|
|
16361
|
+
|
|
16362
|
+
/**
|
|
16363
|
+
* @see https://github.com/chartjs/Chart.js/issues/4176
|
|
16364
|
+
*/
|
|
16365
|
+
|
|
16366
|
+
var EXPANDO_KEY = '$datalabels';
|
|
16367
|
+
var DEFAULT_KEY = '$default';
|
|
16368
|
+
|
|
16369
|
+
function configure$2(dataset, options) {
|
|
16370
|
+
var override = dataset.datalabels;
|
|
16371
|
+
var listeners = {};
|
|
16372
|
+
var configs = [];
|
|
16373
|
+
var labels, keys;
|
|
16374
|
+
|
|
16375
|
+
if (override === false) {
|
|
16376
|
+
return null;
|
|
16377
|
+
}
|
|
16378
|
+
if (override === true) {
|
|
16379
|
+
override = {};
|
|
16380
|
+
}
|
|
16381
|
+
|
|
16382
|
+
options = merge$1({}, [options, override]);
|
|
16383
|
+
labels = options.labels || {};
|
|
16384
|
+
keys = Object.keys(labels);
|
|
16385
|
+
delete options.labels;
|
|
16386
|
+
|
|
16387
|
+
if (keys.length) {
|
|
16388
|
+
keys.forEach(function(key) {
|
|
16389
|
+
if (labels[key]) {
|
|
16390
|
+
configs.push(merge$1({}, [
|
|
16391
|
+
options,
|
|
16392
|
+
labels[key],
|
|
16393
|
+
{_key: key}
|
|
16394
|
+
]));
|
|
16395
|
+
}
|
|
16396
|
+
});
|
|
16397
|
+
} else {
|
|
16398
|
+
// Default label if no "named" label defined.
|
|
16399
|
+
configs.push(options);
|
|
16400
|
+
}
|
|
16401
|
+
|
|
16402
|
+
// listeners: {<event-type>: {<label-key>: <fn>}}
|
|
16403
|
+
listeners = configs.reduce(function(target, config) {
|
|
16404
|
+
each(config.listeners || {}, function(fn, event) {
|
|
16405
|
+
target[event] = target[event] || {};
|
|
16406
|
+
target[event][config._key || DEFAULT_KEY] = fn;
|
|
16407
|
+
});
|
|
16408
|
+
|
|
16409
|
+
delete config.listeners;
|
|
16410
|
+
return target;
|
|
16411
|
+
}, {});
|
|
16412
|
+
|
|
16413
|
+
return {
|
|
16414
|
+
labels: configs,
|
|
16415
|
+
listeners: listeners
|
|
16416
|
+
};
|
|
16417
|
+
}
|
|
16418
|
+
|
|
16419
|
+
function dispatchEvent(chart, listeners, label, event) {
|
|
16420
|
+
if (!listeners) {
|
|
16421
|
+
return;
|
|
16422
|
+
}
|
|
16423
|
+
|
|
16424
|
+
var context = label.$context;
|
|
16425
|
+
var groups = label.$groups;
|
|
16426
|
+
var callback$1;
|
|
16427
|
+
|
|
16428
|
+
if (!listeners[groups._set]) {
|
|
16429
|
+
return;
|
|
16430
|
+
}
|
|
16431
|
+
|
|
16432
|
+
callback$1 = listeners[groups._set][groups._key];
|
|
16433
|
+
if (!callback$1) {
|
|
16434
|
+
return;
|
|
16435
|
+
}
|
|
16436
|
+
|
|
16437
|
+
if (callback(callback$1, [context, event]) === true) {
|
|
16438
|
+
// Users are allowed to tweak the given context by injecting values that can be
|
|
16439
|
+
// used in scriptable options to display labels differently based on the current
|
|
16440
|
+
// event (e.g. highlight an hovered label). That's why we update the label with
|
|
16441
|
+
// the output context and schedule a new chart render by setting it dirty.
|
|
16442
|
+
chart[EXPANDO_KEY]._dirty = true;
|
|
16443
|
+
label.update(context);
|
|
16444
|
+
}
|
|
16445
|
+
}
|
|
16446
|
+
|
|
16447
|
+
function dispatchMoveEvents(chart, listeners, previous, label, event) {
|
|
16448
|
+
var enter, leave;
|
|
16449
|
+
|
|
16450
|
+
if (!previous && !label) {
|
|
16451
|
+
return;
|
|
16452
|
+
}
|
|
16453
|
+
|
|
16454
|
+
if (!previous) {
|
|
16455
|
+
enter = true;
|
|
16456
|
+
} else if (!label) {
|
|
16457
|
+
leave = true;
|
|
16458
|
+
} else if (previous !== label) {
|
|
16459
|
+
leave = enter = true;
|
|
16460
|
+
}
|
|
16461
|
+
|
|
16462
|
+
if (leave) {
|
|
16463
|
+
dispatchEvent(chart, listeners.leave, previous, event);
|
|
16464
|
+
}
|
|
16465
|
+
if (enter) {
|
|
16466
|
+
dispatchEvent(chart, listeners.enter, label, event);
|
|
16467
|
+
}
|
|
16468
|
+
}
|
|
16469
|
+
|
|
16470
|
+
function handleMoveEvents(chart, event) {
|
|
16471
|
+
var expando = chart[EXPANDO_KEY];
|
|
16472
|
+
var listeners = expando._listeners;
|
|
16473
|
+
var previous, label;
|
|
16474
|
+
|
|
16475
|
+
if (!listeners.enter && !listeners.leave) {
|
|
16476
|
+
return;
|
|
16477
|
+
}
|
|
16478
|
+
|
|
16479
|
+
if (event.type === 'mousemove') {
|
|
16480
|
+
label = layout.lookup(expando._labels, event);
|
|
16481
|
+
} else if (event.type !== 'mouseout') {
|
|
16482
|
+
return;
|
|
16483
|
+
}
|
|
16484
|
+
|
|
16485
|
+
previous = expando._hovered;
|
|
16486
|
+
expando._hovered = label;
|
|
16487
|
+
dispatchMoveEvents(chart, listeners, previous, label, event);
|
|
16488
|
+
}
|
|
16489
|
+
|
|
16490
|
+
function handleClickEvents(chart, event) {
|
|
16491
|
+
var expando = chart[EXPANDO_KEY];
|
|
16492
|
+
var handlers = expando._listeners.click;
|
|
16493
|
+
var label = handlers && layout.lookup(expando._labels, event);
|
|
16494
|
+
if (label) {
|
|
16495
|
+
dispatchEvent(chart, handlers, label, event);
|
|
16496
|
+
}
|
|
16497
|
+
}
|
|
16498
|
+
|
|
16499
|
+
var plugin$1 = {
|
|
16500
|
+
id: 'datalabels',
|
|
16501
|
+
|
|
16502
|
+
defaults: defaults,
|
|
16503
|
+
|
|
16504
|
+
beforeInit: function(chart) {
|
|
16505
|
+
chart[EXPANDO_KEY] = {
|
|
16506
|
+
_actives: []
|
|
16507
|
+
};
|
|
16508
|
+
},
|
|
16509
|
+
|
|
16510
|
+
beforeUpdate: function(chart) {
|
|
16511
|
+
var expando = chart[EXPANDO_KEY];
|
|
16512
|
+
expando._listened = false;
|
|
16513
|
+
expando._listeners = {}; // {<event-type>: {<dataset-index>: {<label-key>: <fn>}}}
|
|
16514
|
+
expando._datasets = []; // per dataset labels: [Label[]]
|
|
16515
|
+
expando._labels = []; // layouted labels: Label[]
|
|
16516
|
+
},
|
|
16517
|
+
|
|
16518
|
+
afterDatasetUpdate: function(chart, args, options) {
|
|
16519
|
+
var datasetIndex = args.index;
|
|
16520
|
+
var expando = chart[EXPANDO_KEY];
|
|
16521
|
+
var labels = expando._datasets[datasetIndex] = [];
|
|
16522
|
+
var visible = chart.isDatasetVisible(datasetIndex);
|
|
16523
|
+
var dataset = chart.data.datasets[datasetIndex];
|
|
16524
|
+
var config = configure$2(dataset, options);
|
|
16525
|
+
var elements = args.meta.data || [];
|
|
16526
|
+
var ctx = chart.ctx;
|
|
16527
|
+
var i, j, ilen, jlen, cfg, key, el, label;
|
|
16528
|
+
|
|
16529
|
+
ctx.save();
|
|
16530
|
+
|
|
16531
|
+
for (i = 0, ilen = elements.length; i < ilen; ++i) {
|
|
16532
|
+
el = elements[i];
|
|
16533
|
+
el[EXPANDO_KEY] = [];
|
|
16534
|
+
|
|
16535
|
+
if (visible && el && chart.getDataVisibility(i) && !el.skip) {
|
|
16536
|
+
for (j = 0, jlen = config.labels.length; j < jlen; ++j) {
|
|
16537
|
+
cfg = config.labels[j];
|
|
16538
|
+
key = cfg._key;
|
|
16539
|
+
|
|
16540
|
+
label = new Label(cfg, ctx, el, i);
|
|
16541
|
+
label.$groups = {
|
|
16542
|
+
_set: datasetIndex,
|
|
16543
|
+
_key: key || DEFAULT_KEY
|
|
16544
|
+
};
|
|
16545
|
+
label.$context = {
|
|
16546
|
+
active: false,
|
|
16547
|
+
chart: chart,
|
|
16548
|
+
dataIndex: i,
|
|
16549
|
+
dataset: dataset,
|
|
16550
|
+
datasetIndex: datasetIndex
|
|
16551
|
+
};
|
|
16552
|
+
|
|
16553
|
+
label.update(label.$context);
|
|
16554
|
+
el[EXPANDO_KEY].push(label);
|
|
16555
|
+
labels.push(label);
|
|
16556
|
+
}
|
|
16557
|
+
}
|
|
16558
|
+
}
|
|
16559
|
+
|
|
16560
|
+
ctx.restore();
|
|
16561
|
+
|
|
16562
|
+
// Store listeners at the chart level and per event type to optimize
|
|
16563
|
+
// cases where no listeners are registered for a specific event.
|
|
16564
|
+
merge$1(expando._listeners, config.listeners, {
|
|
16565
|
+
merger: function(event, target, source) {
|
|
16566
|
+
target[event] = target[event] || {};
|
|
16567
|
+
target[event][args.index] = source[event];
|
|
16568
|
+
expando._listened = true;
|
|
16569
|
+
}
|
|
16570
|
+
});
|
|
16571
|
+
},
|
|
16572
|
+
|
|
16573
|
+
afterUpdate: function(chart) {
|
|
16574
|
+
chart[EXPANDO_KEY]._labels = layout.prepare(chart[EXPANDO_KEY]._datasets);
|
|
16575
|
+
},
|
|
16576
|
+
|
|
16577
|
+
// Draw labels on top of all dataset elements
|
|
16578
|
+
// https://github.com/chartjs/chartjs-plugin-datalabels/issues/29
|
|
16579
|
+
// https://github.com/chartjs/chartjs-plugin-datalabels/issues/32
|
|
16580
|
+
afterDatasetsDraw: function(chart) {
|
|
16581
|
+
layout.draw(chart, chart[EXPANDO_KEY]._labels);
|
|
16582
|
+
},
|
|
16583
|
+
|
|
16584
|
+
beforeEvent: function(chart, args) {
|
|
16585
|
+
// If there is no listener registered for this chart, `listened` will be false,
|
|
16586
|
+
// meaning we can immediately ignore the incoming event and avoid useless extra
|
|
16587
|
+
// computation for users who don't implement label interactions.
|
|
16588
|
+
if (chart[EXPANDO_KEY]._listened) {
|
|
16589
|
+
var event = args.event;
|
|
16590
|
+
switch (event.type) {
|
|
16591
|
+
case 'mousemove':
|
|
16592
|
+
case 'mouseout':
|
|
16593
|
+
handleMoveEvents(chart, event);
|
|
16594
|
+
break;
|
|
16595
|
+
case 'click':
|
|
16596
|
+
handleClickEvents(chart, event);
|
|
16597
|
+
break;
|
|
16598
|
+
}
|
|
16599
|
+
}
|
|
16600
|
+
},
|
|
16601
|
+
|
|
16602
|
+
afterEvent: function(chart) {
|
|
16603
|
+
var expando = chart[EXPANDO_KEY];
|
|
16604
|
+
var previous = expando._actives;
|
|
16605
|
+
var actives = expando._actives = chart.getActiveElements();
|
|
16606
|
+
var updates = utils.arrayDiff(previous, actives);
|
|
16607
|
+
var i, ilen, j, jlen, update, label, labels;
|
|
16608
|
+
|
|
16609
|
+
for (i = 0, ilen = updates.length; i < ilen; ++i) {
|
|
16610
|
+
update = updates[i];
|
|
16611
|
+
if (update[1]) {
|
|
16612
|
+
labels = update[0].element[EXPANDO_KEY] || [];
|
|
16613
|
+
for (j = 0, jlen = labels.length; j < jlen; ++j) {
|
|
16614
|
+
label = labels[j];
|
|
16615
|
+
label.$context.active = (update[1] === 1);
|
|
16616
|
+
label.update(label.$context);
|
|
16617
|
+
}
|
|
16618
|
+
}
|
|
16619
|
+
}
|
|
16620
|
+
|
|
16621
|
+
if (expando._dirty || updates.length) {
|
|
16622
|
+
layout.update(expando._labels);
|
|
16623
|
+
chart.render();
|
|
16624
|
+
}
|
|
16625
|
+
|
|
16626
|
+
delete expando._dirty;
|
|
16627
|
+
}
|
|
16628
|
+
};
|
|
16629
|
+
|
|
15274
16630
|
Chart$1.register(CategoryScale, LinearScale, PointElement, LineElement, plugin_title, plugin_tooltip, plugin_legend);
|
|
15275
|
-
function SeriesLineChart({ orientation, title, data, options, className, units, content }) {
|
|
16631
|
+
function SeriesLineChart({ orientation, title, data, options, className, units, content, x_axis_title, y_axis_title }) {
|
|
15276
16632
|
var _a, _b;
|
|
16633
|
+
console.log('x_axis_title==>', x_axis_title);
|
|
15277
16634
|
const formatValue = (value) => {
|
|
15278
16635
|
const numValue = typeof value === 'string' ? parseFloat(value) : value;
|
|
15279
16636
|
if (!isNaN(numValue)) {
|
|
@@ -15348,12 +16705,16 @@ function SeriesLineChart({ orientation, title, data, options, className, units,
|
|
|
15348
16705
|
},
|
|
15349
16706
|
scales: {
|
|
15350
16707
|
x: {
|
|
16708
|
+
title: {
|
|
16709
|
+
display: !!x_axis_title,
|
|
16710
|
+
text: x_axis_title,
|
|
16711
|
+
},
|
|
15351
16712
|
ticks: { autoSkip: true, maxTicksLimit: 8, maxRotation: 45, minRotation: 0 },
|
|
15352
16713
|
},
|
|
15353
16714
|
y: {
|
|
15354
16715
|
title: {
|
|
15355
16716
|
display: true,
|
|
15356
|
-
text: (data === null || data === void 0 ? void 0 : data.datasets) && ((_a = data === null || data === void 0 ? void 0 : data.datasets) === null || _a === void 0 ? void 0 : _a.length) === 1 ? (_b = data === null || data === void 0 ? void 0 : data.datasets) === null || _b === void 0 ? void 0 : _b[0].label : getAxisLabel(units !== null && units !== void 0 ? units : ""),
|
|
16717
|
+
text: y_axis_title || ((data === null || data === void 0 ? void 0 : data.datasets) && ((_a = data === null || data === void 0 ? void 0 : data.datasets) === null || _a === void 0 ? void 0 : _a.length) === 1 ? (_b = data === null || data === void 0 ? void 0 : data.datasets) === null || _b === void 0 ? void 0 : _b[0].label : getAxisLabel(units !== null && units !== void 0 ? units : "")),
|
|
15357
16718
|
},
|
|
15358
16719
|
beginAtZero: true,
|
|
15359
16720
|
ticks: {
|
|
@@ -15372,9 +16733,791 @@ function SeriesLineChart({ orientation, title, data, options, className, units,
|
|
|
15372
16733
|
},
|
|
15373
16734
|
},
|
|
15374
16735
|
};
|
|
15375
|
-
return (jsxRuntimeExports.jsx(Line, { data: data, options: options !== null && options !== void 0 ? options : defaultOptions, plugins: [
|
|
16736
|
+
return (jsxRuntimeExports.jsx(Line, { data: data, options: options !== null && options !== void 0 ? options : defaultOptions, plugins: [plugin$1] }));
|
|
15376
16737
|
}
|
|
15377
16738
|
|
|
16739
|
+
/*!
|
|
16740
|
+
* @energiency/chartjs-plugin-piechart-outlabels v1.3.4
|
|
16741
|
+
* http://www.chartjs.org
|
|
16742
|
+
* (c) 2017-2025 @energiency/chartjs-plugin-piechart-outlabels contributors
|
|
16743
|
+
* Released under the MIT license
|
|
16744
|
+
*/
|
|
16745
|
+
|
|
16746
|
+
/**
|
|
16747
|
+
* @module Options
|
|
16748
|
+
*/
|
|
16749
|
+
|
|
16750
|
+
var customDefaults = {
|
|
16751
|
+
PLUGIN_KEY: '$outlabels',
|
|
16752
|
+
|
|
16753
|
+
/**
|
|
16754
|
+
* The color used to draw the background of the label rect.
|
|
16755
|
+
* @member {String|Array|Function|null}
|
|
16756
|
+
* @default null (adaptive background)
|
|
16757
|
+
*/
|
|
16758
|
+
backgroundColor: function (context) {
|
|
16759
|
+
return context.dataset.backgroundColor;
|
|
16760
|
+
},
|
|
16761
|
+
|
|
16762
|
+
/**
|
|
16763
|
+
* The color used to draw the border of the label rect.
|
|
16764
|
+
* @member {String|Array|Function|null}
|
|
16765
|
+
* @default null (adaptive border color)
|
|
16766
|
+
*/
|
|
16767
|
+
borderColor: function (context) {
|
|
16768
|
+
return context.dataset.backgroundColor;
|
|
16769
|
+
},
|
|
16770
|
+
|
|
16771
|
+
/**
|
|
16772
|
+
* The color used to draw the line between label and arc of the chart.
|
|
16773
|
+
* @member {String|Array|Function|null}
|
|
16774
|
+
* @default null (adaptive line color)
|
|
16775
|
+
*/
|
|
16776
|
+
lineColor: function (context) {
|
|
16777
|
+
return context.dataset.backgroundColor;
|
|
16778
|
+
},
|
|
16779
|
+
|
|
16780
|
+
/**
|
|
16781
|
+
* The border radius used to add rounded corners to the label rect.
|
|
16782
|
+
* @member {Number|Array|Function}
|
|
16783
|
+
* @default 0 (not rounded)
|
|
16784
|
+
*/
|
|
16785
|
+
borderRadius: 0,
|
|
16786
|
+
|
|
16787
|
+
/**
|
|
16788
|
+
* The border width of the surrounding frame.
|
|
16789
|
+
* @member {Number|Array|Function}
|
|
16790
|
+
* @default 0 (no border)
|
|
16791
|
+
*/
|
|
16792
|
+
borderWidth: 0,
|
|
16793
|
+
|
|
16794
|
+
/**
|
|
16795
|
+
* The width (thickness) of the line between label and chart arc.
|
|
16796
|
+
* @member {Number|Array|Function}
|
|
16797
|
+
* @default 2
|
|
16798
|
+
*/
|
|
16799
|
+
lineWidth: 2,
|
|
16800
|
+
|
|
16801
|
+
/**
|
|
16802
|
+
* The color used to draw the label text.
|
|
16803
|
+
* @member {String|Array|Function}
|
|
16804
|
+
* @default white
|
|
16805
|
+
*/
|
|
16806
|
+
color: 'white',
|
|
16807
|
+
|
|
16808
|
+
/**
|
|
16809
|
+
* Whether to display labels global (boolean) or per data (function)
|
|
16810
|
+
* @member {Boolean|Array|Function}
|
|
16811
|
+
* @default true
|
|
16812
|
+
*/
|
|
16813
|
+
display: true,
|
|
16814
|
+
|
|
16815
|
+
/**
|
|
16816
|
+
* The font options used to draw the label text.
|
|
16817
|
+
* @member {Object|Array|Function}
|
|
16818
|
+
* @prop {Boolean} font.family - defaults to Chart.defaults.global.defaultFontFamily
|
|
16819
|
+
* @prop {Boolean} font.size - defaults to Chart.defaults.global.defaultFontSize
|
|
16820
|
+
* @prop {Boolean} font.style - defaults to Chart.defaults.global.defaultFontStyle
|
|
16821
|
+
* @prop {Boolean} font.weight - defaults to 'normal'
|
|
16822
|
+
* @prop {Boolean} font.maxSize - defaults to undefined (unlimited)
|
|
16823
|
+
* @prop {Boolean} font.minSize - defaults to undefined (unlimited)
|
|
16824
|
+
* @prop {Boolean} font.resizable - defaults to true
|
|
16825
|
+
* @default Chart.defaults.global.defaultFont.*
|
|
16826
|
+
*/
|
|
16827
|
+
font: {
|
|
16828
|
+
family: undefined,
|
|
16829
|
+
size: undefined,
|
|
16830
|
+
style: undefined,
|
|
16831
|
+
weight: null,
|
|
16832
|
+
maxSize: null,
|
|
16833
|
+
minSize: null,
|
|
16834
|
+
resizable: true,
|
|
16835
|
+
},
|
|
16836
|
+
|
|
16837
|
+
/**
|
|
16838
|
+
* The line height (in pixel) to use for multi-lines labels.
|
|
16839
|
+
* @member {Number|Array|Function|undefined}
|
|
16840
|
+
* @default 1.2
|
|
16841
|
+
*/
|
|
16842
|
+
lineHeight: 1.2,
|
|
16843
|
+
|
|
16844
|
+
/**
|
|
16845
|
+
* The padding (in pixels) to apply between the text and the surrounding frame.
|
|
16846
|
+
* @member {Number|Object|Array|Function}
|
|
16847
|
+
* @prop {Number} padding.top - Space above the text.
|
|
16848
|
+
* @prop {Number} padding.right - Space on the right of the text.
|
|
16849
|
+
* @prop {Number} padding.bottom - Space below the text.
|
|
16850
|
+
* @prop {Number} padding.left - Space on the left of the text.
|
|
16851
|
+
* @default 4 (all values)
|
|
16852
|
+
*/
|
|
16853
|
+
padding: {
|
|
16854
|
+
top: 2,
|
|
16855
|
+
right: 2,
|
|
16856
|
+
bottom: 2,
|
|
16857
|
+
left: 2,
|
|
16858
|
+
},
|
|
16859
|
+
|
|
16860
|
+
/**
|
|
16861
|
+
* Text alignment for multi-lines labels ('left'|'right'|'start'|'center'|'end').
|
|
16862
|
+
* @member {String|Array|Function}
|
|
16863
|
+
* @default 'center'
|
|
16864
|
+
*/
|
|
16865
|
+
textAlign: 'center',
|
|
16866
|
+
|
|
16867
|
+
/**
|
|
16868
|
+
* The radius of distance where the label will be drawn
|
|
16869
|
+
* @member {Number|Array|Function|undefined}
|
|
16870
|
+
* @default 30
|
|
16871
|
+
*/
|
|
16872
|
+
stretch: 12,
|
|
16873
|
+
|
|
16874
|
+
/**
|
|
16875
|
+
* The length of the horizontal part of line between label and chart arc.
|
|
16876
|
+
* @member {Number}
|
|
16877
|
+
* @default 30
|
|
16878
|
+
*/
|
|
16879
|
+
horizontalStrechPad: 12,
|
|
16880
|
+
|
|
16881
|
+
/**
|
|
16882
|
+
* The text of the label.
|
|
16883
|
+
* @member {String}
|
|
16884
|
+
* @default '%l %p' (label name and value percentage)
|
|
16885
|
+
*/
|
|
16886
|
+
text: '%l %p',
|
|
16887
|
+
|
|
16888
|
+
/**
|
|
16889
|
+
* The max level of zoom (out) for pie/doughnut chart in percent.
|
|
16890
|
+
* @member {Number}
|
|
16891
|
+
* @default 50 (%)
|
|
16892
|
+
*/
|
|
16893
|
+
maxZoomOutPercentage: 50,
|
|
16894
|
+
|
|
16895
|
+
/**
|
|
16896
|
+
* The count of numbers after the point separator for float values of percent property
|
|
16897
|
+
* @member {Number}
|
|
16898
|
+
* @default 1
|
|
16899
|
+
*/
|
|
16900
|
+
percentPrecision: 1,
|
|
16901
|
+
|
|
16902
|
+
/**
|
|
16903
|
+
* The count of numbers after the point separator for float values of value property
|
|
16904
|
+
* @member {Number}
|
|
16905
|
+
* @default 3
|
|
16906
|
+
*/
|
|
16907
|
+
valuePrecision: 3,
|
|
16908
|
+
};
|
|
16909
|
+
|
|
16910
|
+
const chartStates = new WeakMap();
|
|
16911
|
+
|
|
16912
|
+
function getState(chart) {
|
|
16913
|
+
let state = chartStates.get(chart);
|
|
16914
|
+
if (!state) {
|
|
16915
|
+
state = { sizeChanged: false, fitting: false };
|
|
16916
|
+
chartStates.set(chart, state);
|
|
16917
|
+
}
|
|
16918
|
+
return state;
|
|
16919
|
+
}
|
|
16920
|
+
|
|
16921
|
+
function removeState(chart) {
|
|
16922
|
+
chartStates.delete(chart);
|
|
16923
|
+
}
|
|
16924
|
+
|
|
16925
|
+
var positioners = {
|
|
16926
|
+
center: function (arc, stretch) {
|
|
16927
|
+
var angle = (arc.startAngle + arc.endAngle) / 2;
|
|
16928
|
+
var cosA = Math.cos(angle);
|
|
16929
|
+
var sinA = Math.sin(angle);
|
|
16930
|
+
var d = arc.outerRadius;
|
|
16931
|
+
|
|
16932
|
+
var stretchedD = d + stretch;
|
|
16933
|
+
return {
|
|
16934
|
+
x: arc.x + cosA * stretchedD,
|
|
16935
|
+
y: arc.y + sinA * stretchedD,
|
|
16936
|
+
d: stretchedD,
|
|
16937
|
+
arc: arc,
|
|
16938
|
+
anchor: { x: arc.x + cosA * d, y: arc.y + sinA * d },
|
|
16939
|
+
copy: { x: arc.x + cosA * stretchedD, y: arc.y + sinA * stretchedD },
|
|
16940
|
+
};
|
|
16941
|
+
},
|
|
16942
|
+
|
|
16943
|
+
moveFromAnchor: function (center, dist) {
|
|
16944
|
+
var arc = center.arc;
|
|
16945
|
+
var d = center.d;
|
|
16946
|
+
var angle = (arc.startAngle + arc.endAngle) / 2;
|
|
16947
|
+
var cosA = Math.cos(angle);
|
|
16948
|
+
var sinA = Math.sin(angle);
|
|
16949
|
+
|
|
16950
|
+
d += dist;
|
|
16951
|
+
|
|
16952
|
+
return {
|
|
16953
|
+
x: arc.x + cosA * d,
|
|
16954
|
+
y: arc.y + sinA * d,
|
|
16955
|
+
d: d,
|
|
16956
|
+
arc: arc,
|
|
16957
|
+
anchor: center.anchor,
|
|
16958
|
+
copy: {
|
|
16959
|
+
x: arc.x + cosA * d,
|
|
16960
|
+
y: arc.y + sinA * d,
|
|
16961
|
+
},
|
|
16962
|
+
};
|
|
16963
|
+
},
|
|
16964
|
+
};
|
|
16965
|
+
|
|
16966
|
+
function toFontString(font) {
|
|
16967
|
+
if (!font || isNullOrUndef(font.size) || isNullOrUndef(font.family)) {
|
|
16968
|
+
return null;
|
|
16969
|
+
}
|
|
16970
|
+
|
|
16971
|
+
return (
|
|
16972
|
+
(font.style ? font.style + ' ' : '') + (font.weight ? font.weight + ' ' : '') + font.size + 'px ' + font.family
|
|
16973
|
+
);
|
|
16974
|
+
}
|
|
16975
|
+
|
|
16976
|
+
function textSize(ctx, lines, font) {
|
|
16977
|
+
var items = [].concat(lines);
|
|
16978
|
+
var ilen = items.length;
|
|
16979
|
+
var prev = ctx.font;
|
|
16980
|
+
var width = 0;
|
|
16981
|
+
var i;
|
|
16982
|
+
|
|
16983
|
+
ctx.font = font.string;
|
|
16984
|
+
|
|
16985
|
+
for (i = 0; i < ilen; ++i) {
|
|
16986
|
+
width = Math.max(ctx.measureText(items[i]).width, width);
|
|
16987
|
+
}
|
|
16988
|
+
|
|
16989
|
+
ctx.font = prev;
|
|
16990
|
+
|
|
16991
|
+
return {
|
|
16992
|
+
height: ilen * font.lineHeight,
|
|
16993
|
+
width,
|
|
16994
|
+
};
|
|
16995
|
+
}
|
|
16996
|
+
|
|
16997
|
+
function adaptTextSizeToDimensions(width, height, minimum, maximum) {
|
|
16998
|
+
const diag = Math.sqrt(Math.pow(width || 100, 2) + Math.pow(height || 100, 2));
|
|
16999
|
+
const size = Math.round(diag * 0.02);
|
|
17000
|
+
|
|
17001
|
+
if (minimum && size < minimum) {
|
|
17002
|
+
return minimum;
|
|
17003
|
+
}
|
|
17004
|
+
if (maximum && size > maximum) {
|
|
17005
|
+
return maximum;
|
|
17006
|
+
}
|
|
17007
|
+
return size;
|
|
17008
|
+
}
|
|
17009
|
+
|
|
17010
|
+
function parseFont(value, width, height) {
|
|
17011
|
+
var size = valueOrDefault(value.size, Chart$1.defaults.defaultFontSize);
|
|
17012
|
+
|
|
17013
|
+
if (value.resizable) {
|
|
17014
|
+
size = adaptTextSizeToDimensions(width, height, value.minSize, value.maxSize);
|
|
17015
|
+
}
|
|
17016
|
+
|
|
17017
|
+
var font = {
|
|
17018
|
+
family: valueOrDefault(value.family, Chart$1.defaults.defaultFontFamily),
|
|
17019
|
+
lineHeight: toLineHeight(value.lineHeight, size),
|
|
17020
|
+
lineWidth: toLineHeight(value.lineWidth, size),
|
|
17021
|
+
size,
|
|
17022
|
+
style: valueOrDefault(value.style, Chart$1.defaults.defaultFontStyle),
|
|
17023
|
+
weight: valueOrDefault(value.weight, null),
|
|
17024
|
+
string: '',
|
|
17025
|
+
};
|
|
17026
|
+
|
|
17027
|
+
font.string = toFontString(font);
|
|
17028
|
+
return font;
|
|
17029
|
+
}
|
|
17030
|
+
|
|
17031
|
+
var PLUGIN_KEY$1 = customDefaults.PLUGIN_KEY;
|
|
17032
|
+
|
|
17033
|
+
function collides(rect, otherRect) {
|
|
17034
|
+
return (
|
|
17035
|
+
rect.x < otherRect.x + otherRect.width &&
|
|
17036
|
+
rect.x + rect.width > otherRect.x &&
|
|
17037
|
+
rect.y < otherRect.y + otherRect.height &&
|
|
17038
|
+
rect.y + rect.height > otherRect.y
|
|
17039
|
+
);
|
|
17040
|
+
}
|
|
17041
|
+
|
|
17042
|
+
var classes = {
|
|
17043
|
+
OutLabel: function (chart, index, ctx, config, context) {
|
|
17044
|
+
// Check whether the label should be displayed
|
|
17045
|
+
if (!resolve([config.display, true], context, index)) {
|
|
17046
|
+
throw new Error('Label display property is set to false.');
|
|
17047
|
+
}
|
|
17048
|
+
|
|
17049
|
+
// Init text
|
|
17050
|
+
var value = context.dataset.data[index];
|
|
17051
|
+
var label = context.labels[index];
|
|
17052
|
+
var text = resolve([config.text, customDefaults.text], context, index);
|
|
17053
|
+
/* Replace label marker */
|
|
17054
|
+
text = text.replace(/%l/gi, label);
|
|
17055
|
+
|
|
17056
|
+
/* Replace value marker with possible precision value */
|
|
17057
|
+
(text.match(/%v\.?(\d*)/gi) || [])
|
|
17058
|
+
.map(function (val) {
|
|
17059
|
+
var prec = val.replace(/%v\./gi, '');
|
|
17060
|
+
if (prec.length) {
|
|
17061
|
+
return +prec;
|
|
17062
|
+
}
|
|
17063
|
+
return config.valuePrecision || customDefaults.valuePrecision;
|
|
17064
|
+
})
|
|
17065
|
+
.forEach(function (val) {
|
|
17066
|
+
text = text.replace(/%v\.?(\d*)/i, value.toFixed(val));
|
|
17067
|
+
});
|
|
17068
|
+
|
|
17069
|
+
/* Replace percent marker with possible precision value */
|
|
17070
|
+
(text.match(/%p\.?(\d*)/gi) || [])
|
|
17071
|
+
.map(function (val) {
|
|
17072
|
+
var prec = val.replace(/%p\./gi, '');
|
|
17073
|
+
if (prec.length) {
|
|
17074
|
+
return +prec;
|
|
17075
|
+
}
|
|
17076
|
+
return config.percentPrecision || customDefaults.percentPrecision;
|
|
17077
|
+
})
|
|
17078
|
+
.forEach(function (val) {
|
|
17079
|
+
text = text.replace(/%p\.?(\d*)/i, (context.percent * 100).toFixed(val) + '%');
|
|
17080
|
+
});
|
|
17081
|
+
|
|
17082
|
+
// Count lines
|
|
17083
|
+
var lines = text.match(/[^\r\n]+/g) || [];
|
|
17084
|
+
|
|
17085
|
+
// Remove unnecessary spaces
|
|
17086
|
+
for (var i = 0; i < lines.length; ++i) {
|
|
17087
|
+
lines[i] = lines[i].trim();
|
|
17088
|
+
}
|
|
17089
|
+
|
|
17090
|
+
/* ===================== CONSTRUCTOR ==================== */
|
|
17091
|
+
this.init = function (text, lines) {
|
|
17092
|
+
// If everything ok -> begin initializing
|
|
17093
|
+
this.encodedText = config.text;
|
|
17094
|
+
this.text = text;
|
|
17095
|
+
this.lines = lines;
|
|
17096
|
+
this.label = label;
|
|
17097
|
+
this.value = value;
|
|
17098
|
+
|
|
17099
|
+
// Init style
|
|
17100
|
+
this.style = {
|
|
17101
|
+
backgroundColor: resolve(
|
|
17102
|
+
[config.backgroundColor, customDefaults.backgroundColor, 'black'],
|
|
17103
|
+
context,
|
|
17104
|
+
index,
|
|
17105
|
+
),
|
|
17106
|
+
borderColor: resolve([config.borderColor, customDefaults.borderColor, 'black'], context, index),
|
|
17107
|
+
borderRadius: resolve([config.borderRadius, 0], context, index),
|
|
17108
|
+
borderWidth: resolve([config.borderWidth, 0], context, index),
|
|
17109
|
+
lineWidth: resolve([config.lineWidth, 2], context, index),
|
|
17110
|
+
lineColor: resolve([config.lineColor, customDefaults.lineColor, 'black'], context, index),
|
|
17111
|
+
color: resolve([config.color, 'white'], context, index),
|
|
17112
|
+
font: parseFont(
|
|
17113
|
+
resolve([config.font, { resizable: true }]),
|
|
17114
|
+
ctx.canvas.style.width.slice(0, -2),
|
|
17115
|
+
ctx.canvas.style.height.slice(0, -2),
|
|
17116
|
+
),
|
|
17117
|
+
padding: toPadding(resolve([config.padding, 0], context, index)),
|
|
17118
|
+
textAlign: resolve([config.textAlign, 'left'], context, index),
|
|
17119
|
+
};
|
|
17120
|
+
|
|
17121
|
+
this.stretch = resolve([config.stretch, customDefaults.stretch], context, index);
|
|
17122
|
+
this.horizontalStrechPad = resolve(
|
|
17123
|
+
[config.horizontalStrechPad, customDefaults.horizontalStrechPad],
|
|
17124
|
+
context,
|
|
17125
|
+
index,
|
|
17126
|
+
);
|
|
17127
|
+
this.size = textSize(ctx, this.lines, this.style.font);
|
|
17128
|
+
|
|
17129
|
+
this.offsetStep = this.size.width / 20;
|
|
17130
|
+
this.offset = {
|
|
17131
|
+
x: 0,
|
|
17132
|
+
y: 0,
|
|
17133
|
+
};
|
|
17134
|
+
};
|
|
17135
|
+
|
|
17136
|
+
this.init(text, lines);
|
|
17137
|
+
|
|
17138
|
+
/* COMPUTING RECTS PART */
|
|
17139
|
+
this.computeLabelRect = function () {
|
|
17140
|
+
var width =
|
|
17141
|
+
this.textRect.width + 2 * this.style.borderWidth + this.style.padding.left + this.style.padding.right;
|
|
17142
|
+
var height =
|
|
17143
|
+
this.textRect.height + 2 * this.style.borderWidth + this.style.padding.top + this.style.padding.bottom;
|
|
17144
|
+
|
|
17145
|
+
var x = this.textRect.x - this.style.borderWidth;
|
|
17146
|
+
var y = this.textRect.y - this.style.borderWidth;
|
|
17147
|
+
|
|
17148
|
+
return {
|
|
17149
|
+
x: x,
|
|
17150
|
+
y: y,
|
|
17151
|
+
width: width,
|
|
17152
|
+
height: height,
|
|
17153
|
+
isLeft: this.textRect.isLeft,
|
|
17154
|
+
isTop: this.textRect.isTop,
|
|
17155
|
+
};
|
|
17156
|
+
};
|
|
17157
|
+
|
|
17158
|
+
this.computeTextRect = function () {
|
|
17159
|
+
const isLeft = this.center.x - this.center.anchor.x < 0;
|
|
17160
|
+
const isTop = this.center.y - this.center.anchor.y < 0;
|
|
17161
|
+
const shift = isLeft ? -(this.horizontalStrechPad + this.size.width) : this.horizontalStrechPad;
|
|
17162
|
+
return {
|
|
17163
|
+
x: this.center.x - this.style.padding.left + shift,
|
|
17164
|
+
y: this.center.y - this.size.height / 2,
|
|
17165
|
+
width: this.size.width,
|
|
17166
|
+
height: this.size.height,
|
|
17167
|
+
isLeft,
|
|
17168
|
+
isTop,
|
|
17169
|
+
};
|
|
17170
|
+
};
|
|
17171
|
+
|
|
17172
|
+
/* ======================= DRAWING ======================= */
|
|
17173
|
+
// Draw label text
|
|
17174
|
+
this.drawText = function (ctx) {
|
|
17175
|
+
var align = this.style.textAlign;
|
|
17176
|
+
var font = this.style.font;
|
|
17177
|
+
var lh = font.lineHeight;
|
|
17178
|
+
var color = this.style.color;
|
|
17179
|
+
var ilen = this.lines.length;
|
|
17180
|
+
var x, y, idx;
|
|
17181
|
+
|
|
17182
|
+
if (!ilen || !color) {
|
|
17183
|
+
return;
|
|
17184
|
+
}
|
|
17185
|
+
|
|
17186
|
+
x = this.textRect.x;
|
|
17187
|
+
y = this.textRect.y + lh / 2;
|
|
17188
|
+
|
|
17189
|
+
if (align === 'center') {
|
|
17190
|
+
x += this.textRect.width / 2;
|
|
17191
|
+
} else if (align === 'end' || align === 'right') {
|
|
17192
|
+
x += this.textRect.width;
|
|
17193
|
+
}
|
|
17194
|
+
|
|
17195
|
+
ctx.font = this.style.font.string;
|
|
17196
|
+
ctx.fillStyle = color;
|
|
17197
|
+
ctx.textAlign = align;
|
|
17198
|
+
ctx.textBaseline = 'middle';
|
|
17199
|
+
|
|
17200
|
+
for (idx = 0; idx < ilen; ++idx) {
|
|
17201
|
+
ctx.fillText(
|
|
17202
|
+
this.lines[idx],
|
|
17203
|
+
Math.round(x) + this.style.padding.left,
|
|
17204
|
+
Math.round(y),
|
|
17205
|
+
Math.round(this.textRect.width),
|
|
17206
|
+
);
|
|
17207
|
+
y += lh;
|
|
17208
|
+
}
|
|
17209
|
+
};
|
|
17210
|
+
|
|
17211
|
+
// Draw label box
|
|
17212
|
+
this.drawLabel = function (ctx) {
|
|
17213
|
+
ctx.beginPath();
|
|
17214
|
+
|
|
17215
|
+
ctx.roundRect(
|
|
17216
|
+
Math.round(this.labelRect.x),
|
|
17217
|
+
Math.round(this.labelRect.y),
|
|
17218
|
+
Math.round(this.labelRect.width),
|
|
17219
|
+
Math.round(this.labelRect.height),
|
|
17220
|
+
this.style.borderRadius,
|
|
17221
|
+
);
|
|
17222
|
+
ctx.closePath();
|
|
17223
|
+
|
|
17224
|
+
if (this.style.backgroundColor) {
|
|
17225
|
+
ctx.fillStyle = this.style.backgroundColor || 'transparent';
|
|
17226
|
+
ctx.fill();
|
|
17227
|
+
}
|
|
17228
|
+
|
|
17229
|
+
if (this.style.borderColor && this.style.borderWidth) {
|
|
17230
|
+
ctx.strokeStyle = this.style.borderColor;
|
|
17231
|
+
ctx.lineWidth = this.style.borderWidth;
|
|
17232
|
+
ctx.lineJoin = 'miter';
|
|
17233
|
+
ctx.stroke();
|
|
17234
|
+
}
|
|
17235
|
+
};
|
|
17236
|
+
|
|
17237
|
+
this.ccw = function (A, B, C) {
|
|
17238
|
+
return (C.y - A.y) * (B.x - A.x) > (B.y - A.y) * (C.x - A.x);
|
|
17239
|
+
};
|
|
17240
|
+
|
|
17241
|
+
this.intersects = function (A, B, C, D) {
|
|
17242
|
+
return this.ccw(A, C, D) !== this.ccw(B, C, D) && this.ccw(A, B, C) !== this.ccw(A, B, D);
|
|
17243
|
+
};
|
|
17244
|
+
|
|
17245
|
+
this.drawLine = function (ctx) {
|
|
17246
|
+
if (!this.lines.length) {
|
|
17247
|
+
return;
|
|
17248
|
+
}
|
|
17249
|
+
ctx.save();
|
|
17250
|
+
|
|
17251
|
+
ctx.strokeStyle = this.style.lineColor;
|
|
17252
|
+
ctx.lineWidth = this.style.lineWidth;
|
|
17253
|
+
ctx.lineJoin = 'miter';
|
|
17254
|
+
ctx.beginPath();
|
|
17255
|
+
ctx.moveTo(this.center.anchor.x, this.center.anchor.y);
|
|
17256
|
+
ctx.lineTo(this.center.copy.x, this.center.copy.y);
|
|
17257
|
+
ctx.stroke();
|
|
17258
|
+
|
|
17259
|
+
ctx.beginPath();
|
|
17260
|
+
ctx.moveTo(this.center.copy.x, this.center.copy.y);
|
|
17261
|
+
const xOffset = this.textRect.width + this.style.padding.width;
|
|
17262
|
+
const intersect = this.intersects(
|
|
17263
|
+
this.textRect,
|
|
17264
|
+
{
|
|
17265
|
+
x: this.textRect.x + this.textRect.width,
|
|
17266
|
+
y: this.textRect.y + this.textRect.height,
|
|
17267
|
+
},
|
|
17268
|
+
this.center.copy,
|
|
17269
|
+
{
|
|
17270
|
+
x: this.textRect.x,
|
|
17271
|
+
y: this.textRect.y + this.textRect.height / 2,
|
|
17272
|
+
},
|
|
17273
|
+
);
|
|
17274
|
+
ctx.lineTo(this.textRect.x + (intersect ? xOffset : 0), this.textRect.y + this.textRect.height / 2);
|
|
17275
|
+
ctx.stroke();
|
|
17276
|
+
ctx.restore();
|
|
17277
|
+
};
|
|
17278
|
+
|
|
17279
|
+
this.draw = function (ctx) {
|
|
17280
|
+
if (chart.getDataVisibility(index)) {
|
|
17281
|
+
this.drawLabel(ctx);
|
|
17282
|
+
this.drawText(ctx);
|
|
17283
|
+
this.drawLine(ctx);
|
|
17284
|
+
}
|
|
17285
|
+
};
|
|
17286
|
+
|
|
17287
|
+
// eslint-disable-next-line max-statements
|
|
17288
|
+
this.update = function (view, elements, max) {
|
|
17289
|
+
this.center = positioners.center(view, this.stretch);
|
|
17290
|
+
|
|
17291
|
+
let valid = false;
|
|
17292
|
+
let steps = 30;
|
|
17293
|
+
|
|
17294
|
+
while (!valid && steps > 0) {
|
|
17295
|
+
this.textRect = this.computeTextRect();
|
|
17296
|
+
this.labelRect = this.computeLabelRect();
|
|
17297
|
+
|
|
17298
|
+
valid = true;
|
|
17299
|
+
|
|
17300
|
+
for (var e = 0; e < max; ++e) {
|
|
17301
|
+
var element = elements[e][PLUGIN_KEY$1];
|
|
17302
|
+
if (!element || !chart.getDataVisibility(index)) {
|
|
17303
|
+
continue;
|
|
17304
|
+
}
|
|
17305
|
+
|
|
17306
|
+
if (collides(this.labelRect, element.labelRect)) {
|
|
17307
|
+
valid = false;
|
|
17308
|
+
break;
|
|
17309
|
+
}
|
|
17310
|
+
}
|
|
17311
|
+
|
|
17312
|
+
if (!valid) {
|
|
17313
|
+
this.center = positioners.moveFromAnchor(this.center, 5);
|
|
17314
|
+
}
|
|
17315
|
+
|
|
17316
|
+
steps--;
|
|
17317
|
+
}
|
|
17318
|
+
};
|
|
17319
|
+
},
|
|
17320
|
+
};
|
|
17321
|
+
|
|
17322
|
+
defaults$1.plugins.outlabels = customDefaults;
|
|
17323
|
+
|
|
17324
|
+
var PLUGIN_KEY = customDefaults.PLUGIN_KEY;
|
|
17325
|
+
|
|
17326
|
+
function configure$1(dataset, options) {
|
|
17327
|
+
var override = dataset.outlabels;
|
|
17328
|
+
var config = {};
|
|
17329
|
+
|
|
17330
|
+
if (override === false) {
|
|
17331
|
+
return null;
|
|
17332
|
+
}
|
|
17333
|
+
if (override === true) {
|
|
17334
|
+
override = {};
|
|
17335
|
+
}
|
|
17336
|
+
|
|
17337
|
+
return Object.assign({}, config, options, override);
|
|
17338
|
+
}
|
|
17339
|
+
|
|
17340
|
+
/**
|
|
17341
|
+
* Returns the bounding box of the given label elements.
|
|
17342
|
+
*
|
|
17343
|
+
* @param {*} elements List of chart elements
|
|
17344
|
+
* @returns Bounding box
|
|
17345
|
+
*/
|
|
17346
|
+
function getBoundingBox(elements) {
|
|
17347
|
+
const rect = { left: Infinity, right: -Infinity, top: Infinity, bottom: -Infinity };
|
|
17348
|
+
|
|
17349
|
+
for (let i = 0, l = elements.length; i < l; i++) {
|
|
17350
|
+
const outlabel = elements[i][PLUGIN_KEY];
|
|
17351
|
+
if (!outlabel || !outlabel.labelRect) {
|
|
17352
|
+
continue;
|
|
17353
|
+
}
|
|
17354
|
+
|
|
17355
|
+
const { labelRect } = outlabel;
|
|
17356
|
+
const { x, y, width, height } = labelRect;
|
|
17357
|
+
|
|
17358
|
+
rect.left = Math.min(rect.left, x);
|
|
17359
|
+
rect.right = Math.max(rect.right, x + width);
|
|
17360
|
+
rect.top = Math.min(rect.top, y);
|
|
17361
|
+
rect.bottom = Math.max(rect.bottom, y + height);
|
|
17362
|
+
}
|
|
17363
|
+
|
|
17364
|
+
return {
|
|
17365
|
+
...rect,
|
|
17366
|
+
width: rect.right - rect.left,
|
|
17367
|
+
height: rect.bottom - rect.top,
|
|
17368
|
+
};
|
|
17369
|
+
}
|
|
17370
|
+
|
|
17371
|
+
/**
|
|
17372
|
+
* Returns the zoom percentage required to fit the given bounding box within the given bounding box.
|
|
17373
|
+
*
|
|
17374
|
+
* @param {*} boundingBoxToResize
|
|
17375
|
+
* @param {*} boundingBoxToFitWithin
|
|
17376
|
+
* @returns Zoom percentage
|
|
17377
|
+
*/
|
|
17378
|
+
function getResizeZoomPercentage(boundingBoxToResize, boundingBoxToFitWithin) {
|
|
17379
|
+
const { width, height } = boundingBoxToFitWithin;
|
|
17380
|
+
const deltas = [
|
|
17381
|
+
((boundingBoxToFitWithin.left - boundingBoxToResize.left) / width) * 2,
|
|
17382
|
+
((boundingBoxToFitWithin.top - boundingBoxToResize.top) / height) * 2,
|
|
17383
|
+
((boundingBoxToResize.right - boundingBoxToFitWithin.right) / width) * 2,
|
|
17384
|
+
((boundingBoxToResize.bottom - boundingBoxToFitWithin.bottom) / height) * 2,
|
|
17385
|
+
];
|
|
17386
|
+
|
|
17387
|
+
const maxDelta = Math.max(0, ...deltas);
|
|
17388
|
+
return 1 - maxDelta;
|
|
17389
|
+
}
|
|
17390
|
+
|
|
17391
|
+
/**
|
|
17392
|
+
* Updates the labels of the given elements.
|
|
17393
|
+
* @param {*} elements
|
|
17394
|
+
*/
|
|
17395
|
+
function updateLabels(elements) {
|
|
17396
|
+
for (let i = 0, l = elements.length; i < l; i++) {
|
|
17397
|
+
const element = elements[i];
|
|
17398
|
+
const outlabel = element[PLUGIN_KEY];
|
|
17399
|
+
if (!outlabel) {
|
|
17400
|
+
continue;
|
|
17401
|
+
}
|
|
17402
|
+
|
|
17403
|
+
outlabel.update(element, elements, i);
|
|
17404
|
+
}
|
|
17405
|
+
}
|
|
17406
|
+
|
|
17407
|
+
function fitChartArea(chart) {
|
|
17408
|
+
const ctrl = chart._metasets[0].controller;
|
|
17409
|
+
const meta = ctrl.getMeta();
|
|
17410
|
+
const elements = meta.data || [];
|
|
17411
|
+
|
|
17412
|
+
const boundingBox = getBoundingBox(elements);
|
|
17413
|
+
const zoom = getResizeZoomPercentage(boundingBox, chart.chartArea);
|
|
17414
|
+
|
|
17415
|
+
if (zoom && zoom !== 1) {
|
|
17416
|
+
ctrl.outerRadius = ctrl.outerRadius * zoom;
|
|
17417
|
+
ctrl.innerRadius *= zoom;
|
|
17418
|
+
|
|
17419
|
+
ctrl.updateElements(meta.data, 0, meta.data.length, 'none');
|
|
17420
|
+
return true;
|
|
17421
|
+
}
|
|
17422
|
+
|
|
17423
|
+
return false;
|
|
17424
|
+
}
|
|
17425
|
+
|
|
17426
|
+
var plugin = {
|
|
17427
|
+
id: 'outlabels',
|
|
17428
|
+
resize: function (chart) {
|
|
17429
|
+
getState(chart).sizeChanged = true;
|
|
17430
|
+
},
|
|
17431
|
+
afterUpdate: (chart) => {
|
|
17432
|
+
const ctrl = chart._metasets[0].controller;
|
|
17433
|
+
const meta = ctrl.getMeta();
|
|
17434
|
+
const elements = meta.data || [];
|
|
17435
|
+
|
|
17436
|
+
let fit = false;
|
|
17437
|
+
// Limit the number of steps to prevent infinite loops
|
|
17438
|
+
// It seems that using the number of elements will ensure that the chart
|
|
17439
|
+
// fits by positioning all labels in successive resizes
|
|
17440
|
+
let maxSteps = elements.length;
|
|
17441
|
+
|
|
17442
|
+
// Avoid to draw labels while fitting the chart area
|
|
17443
|
+
getState(chart).fitting = true;
|
|
17444
|
+
|
|
17445
|
+
while (!fit && maxSteps-- > 0) {
|
|
17446
|
+
updateLabels(elements);
|
|
17447
|
+
fit = !fitChartArea(chart);
|
|
17448
|
+
}
|
|
17449
|
+
|
|
17450
|
+
getState(chart).fitting = false;
|
|
17451
|
+
},
|
|
17452
|
+
afterDatasetUpdate: function (chart, args, options) {
|
|
17453
|
+
var labels = chart.config.data.labels;
|
|
17454
|
+
var dataset = chart.data.datasets[args.index];
|
|
17455
|
+
var config = configure$1(dataset, options);
|
|
17456
|
+
var display = config && config.display;
|
|
17457
|
+
var elements = args.meta.data || [];
|
|
17458
|
+
var ctx = chart.ctx;
|
|
17459
|
+
var el, label, percent, newLabel, context, i;
|
|
17460
|
+
ctx.save();
|
|
17461
|
+
|
|
17462
|
+
for (i = 0; i < elements.length; ++i) {
|
|
17463
|
+
el = elements[i];
|
|
17464
|
+
label = el[PLUGIN_KEY];
|
|
17465
|
+
percent = dataset.data[i] / args.meta.total;
|
|
17466
|
+
newLabel = null;
|
|
17467
|
+
|
|
17468
|
+
if (display && el && !el.hidden) {
|
|
17469
|
+
try {
|
|
17470
|
+
context = {
|
|
17471
|
+
chart: chart,
|
|
17472
|
+
dataIndex: i,
|
|
17473
|
+
dataset: dataset,
|
|
17474
|
+
labels: labels,
|
|
17475
|
+
datasetIndex: args.index,
|
|
17476
|
+
percent: percent,
|
|
17477
|
+
};
|
|
17478
|
+
newLabel = new classes.OutLabel(chart, i, ctx, config, context);
|
|
17479
|
+
} catch (e) {
|
|
17480
|
+
newLabel = null;
|
|
17481
|
+
}
|
|
17482
|
+
}
|
|
17483
|
+
|
|
17484
|
+
if (
|
|
17485
|
+
label &&
|
|
17486
|
+
newLabel &&
|
|
17487
|
+
!getState(chart).sizeChanged &&
|
|
17488
|
+
label.label === newLabel.label &&
|
|
17489
|
+
label.encodedText === newLabel.encodedText
|
|
17490
|
+
) {
|
|
17491
|
+
newLabel.offset = label.offset;
|
|
17492
|
+
}
|
|
17493
|
+
el[PLUGIN_KEY] = newLabel;
|
|
17494
|
+
}
|
|
17495
|
+
|
|
17496
|
+
ctx.restore();
|
|
17497
|
+
getState(chart).sizeChanged = false;
|
|
17498
|
+
},
|
|
17499
|
+
afterDatasetDraw: function (chart, args) {
|
|
17500
|
+
var elements = args.meta.data || [];
|
|
17501
|
+
var ctx = chart.ctx;
|
|
17502
|
+
|
|
17503
|
+
if (getState(chart).fitting) {
|
|
17504
|
+
return;
|
|
17505
|
+
}
|
|
17506
|
+
|
|
17507
|
+
elements.forEach((el, index) => {
|
|
17508
|
+
const outlabelPlugin = el[PLUGIN_KEY];
|
|
17509
|
+
if (!outlabelPlugin) {
|
|
17510
|
+
return;
|
|
17511
|
+
}
|
|
17512
|
+
outlabelPlugin.update(el, elements, index);
|
|
17513
|
+
outlabelPlugin.draw(ctx);
|
|
17514
|
+
});
|
|
17515
|
+
},
|
|
17516
|
+
afterDestroy: function (chart) {
|
|
17517
|
+
removeState(chart);
|
|
17518
|
+
},
|
|
17519
|
+
};
|
|
17520
|
+
|
|
15378
17521
|
Chart$1.register(ArcElement, plugin_tooltip, plugin_legend);
|
|
15379
17522
|
const PieChart = (props) => {
|
|
15380
17523
|
const { data, title, options, units, content } = props;
|
|
@@ -15452,7 +17595,7 @@ const PieChart = (props) => {
|
|
|
15452
17595
|
},
|
|
15453
17596
|
},
|
|
15454
17597
|
};
|
|
15455
|
-
return jsxRuntimeExports.jsx(Pie, { data: data, options: options !== null && options !== void 0 ? options : defaultOptions, plugins: [
|
|
17598
|
+
return jsxRuntimeExports.jsx(Pie, { data: data, options: options !== null && options !== void 0 ? options : defaultOptions, plugins: [plugin] });
|
|
15456
17599
|
};
|
|
15457
17600
|
|
|
15458
17601
|
Chart$1.register(CategoryScale, LinearScale, PointElement, LineElement, plugin_title, plugin_tooltip, plugin_legend);
|
|
@@ -15529,13 +17672,14 @@ function LineChart({ title, data, options, className, units, content }) {
|
|
|
15529
17672
|
},
|
|
15530
17673
|
},
|
|
15531
17674
|
};
|
|
15532
|
-
return (jsxRuntimeExports.jsx(Line, { data: data, options: options !== null && options !== void 0 ? options : defaultOptions, plugins: [
|
|
17675
|
+
return (jsxRuntimeExports.jsx(Line, { data: data, options: options !== null && options !== void 0 ? options : defaultOptions, plugins: [plugin$1] }));
|
|
15533
17676
|
}
|
|
15534
17677
|
|
|
15535
17678
|
function DataGrid({ title, data, className }) {
|
|
15536
17679
|
var _a;
|
|
15537
|
-
const { columns, rows, grouped = false, grouping } = data;
|
|
17680
|
+
const { columns, rows, units, grouped = false, grouping } = data;
|
|
15538
17681
|
const [expandedGroups, setExpandedGroups] = React.useState(new Set(((_a = grouping === null || grouping === void 0 ? void 0 : grouping.sections) === null || _a === void 0 ? void 0 : _a.filter(s => s.expanded).map(s => s.group_value)) || []));
|
|
17682
|
+
console.log('units==>', units);
|
|
15539
17683
|
const toggleGroup = (groupValue) => {
|
|
15540
17684
|
const newExpanded = new Set(expandedGroups);
|
|
15541
17685
|
if (newExpanded.has(groupValue)) {
|
|
@@ -15546,6 +17690,30 @@ function DataGrid({ title, data, className }) {
|
|
|
15546
17690
|
}
|
|
15547
17691
|
setExpandedGroups(newExpanded);
|
|
15548
17692
|
};
|
|
17693
|
+
const formatValueWithUnit = (value, columnIndex) => {
|
|
17694
|
+
if (value === null || value === undefined)
|
|
17695
|
+
return "—";
|
|
17696
|
+
const unit = units === null || units === void 0 ? void 0 : units[columnIndex];
|
|
17697
|
+
// Format the value with commas if it's a number or numeric string
|
|
17698
|
+
let valueStr;
|
|
17699
|
+
if (typeof value === 'number') {
|
|
17700
|
+
valueStr = value.toLocaleString();
|
|
17701
|
+
}
|
|
17702
|
+
else {
|
|
17703
|
+
const numValue = parseFloat(String(value));
|
|
17704
|
+
valueStr = !isNaN(numValue) ? numValue.toLocaleString() : String(value);
|
|
17705
|
+
}
|
|
17706
|
+
// If no unit or unit length > 3, return value only
|
|
17707
|
+
if (!unit || unit.length > 3) {
|
|
17708
|
+
return valueStr;
|
|
17709
|
+
}
|
|
17710
|
+
// If unit is $, display unit before value
|
|
17711
|
+
if (unit === '$') {
|
|
17712
|
+
return `${unit}${valueStr}`;
|
|
17713
|
+
}
|
|
17714
|
+
// Otherwise display value then unit
|
|
17715
|
+
return `${valueStr}${unit}`;
|
|
17716
|
+
};
|
|
15549
17717
|
// Backward compatibility: if no data or not grouped, show original table
|
|
15550
17718
|
if (!columns || columns.length === 0 || (!grouped && (!rows || rows.length === 0))) {
|
|
15551
17719
|
return (jsxRuntimeExports.jsx("div", { className: "flex items-center justify-center h-full", children: jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-500", children: "No data available" }) }));
|
|
@@ -15557,7 +17725,7 @@ function DataGrid({ title, data, className }) {
|
|
|
15557
17725
|
const renderGroupedTable = () => {
|
|
15558
17726
|
if (!(grouping === null || grouping === void 0 ? void 0 : grouping.sections))
|
|
15559
17727
|
return null;
|
|
15560
|
-
return (jsxRuntimeExports.jsxs("table", { className: "w-full border-collapse", children: [jsxRuntimeExports.jsx("thead", { children: jsxRuntimeExports.jsxs("tr", { className: "border-b border-gray-200", children: [jsxRuntimeExports.jsx("th", { className: "px-4 py-3 text-left text-sm font-medium text-gray-900 bg-gray-50 w-8" }), columns.map((column, index) => (jsxRuntimeExports.
|
|
17728
|
+
return (jsxRuntimeExports.jsxs("table", { className: "w-full border-collapse", children: [jsxRuntimeExports.jsx("thead", { children: jsxRuntimeExports.jsxs("tr", { className: "border-b border-gray-200", children: [jsxRuntimeExports.jsx("th", { className: "px-4 py-3 text-left text-sm font-medium text-gray-900 bg-gray-50 w-8" }), columns.map((column, index) => (jsxRuntimeExports.jsxs("th", { className: "px-4 py-3 text-left text-sm font-medium text-gray-900 bg-gray-50", children: [column, (units === null || units === void 0 ? void 0 : units[index]) ? ` (${units[index]})` : ''] }, index)))] }) }), jsxRuntimeExports.jsx("tbody", { children: grouping.sections.map((section, sectionIndex) => {
|
|
15561
17729
|
const isExpanded = expandedGroups.has(section.group_value);
|
|
15562
17730
|
return (jsxRuntimeExports.jsxs(React.Fragment, { children: [jsxRuntimeExports.jsxs("tr", { className: "bg-blue-50 border-b border-gray-200", children: [jsxRuntimeExports.jsx("td", { className: "px-4 py-3", children: section.collapsible && (jsxRuntimeExports.jsx("button", { onClick: () => toggleGroup(section.group_value), className: "flex items-center justify-center w-6 h-6 hover:bg-blue-100 rounded transition-colors", "aria-label": isExpanded ? "Collapse group" : "Expand group", children: isExpanded ? (jsxRuntimeExports.jsx(lucideReact.ChevronDown, { className: "w-4 h-4 text-blue-600" })) : (jsxRuntimeExports.jsx(lucideReact.ChevronRight, { className: "w-4 h-4 text-blue-600" })) })) }), columns.map((column, columnIndex) => (jsxRuntimeExports.jsx("td", { className: "px-4 py-3 text-sm font-medium text-blue-700", children: columnIndex === 0 ? (jsxRuntimeExports.jsxs("span", { className: "font-semibold text-blue-900", children: [section.title, ": ", section.group_value] })) : (jsxRuntimeExports.jsx("div", { className: "text-left", children: (() => {
|
|
15563
17731
|
var _a;
|
|
@@ -15569,7 +17737,7 @@ function DataGrid({ title, data, className }) {
|
|
|
15569
17737
|
if (sectionStats[column] &&
|
|
15570
17738
|
typeof sectionStats[column].total === 'number' &&
|
|
15571
17739
|
!isNaN(sectionStats[column].total)) {
|
|
15572
|
-
return (jsxRuntimeExports.jsx("span", { className: "whitespace-nowrap text-xs font-medium text-blue-800", children: sectionStats[column].total
|
|
17740
|
+
return (jsxRuntimeExports.jsx("span", { className: "whitespace-nowrap text-xs font-medium text-blue-800", children: formatValueWithUnit(sectionStats[column].total, columnIndex) }));
|
|
15573
17741
|
}
|
|
15574
17742
|
// If exact match fails, try to find by partial match
|
|
15575
17743
|
const matchingKey = Object.keys(sectionStats).find(key => key.toLowerCase().includes(column.toLowerCase()) ||
|
|
@@ -15577,17 +17745,17 @@ function DataGrid({ title, data, className }) {
|
|
|
15577
17745
|
if (matchingKey && sectionStats[matchingKey] &&
|
|
15578
17746
|
typeof sectionStats[matchingKey].total === 'number' &&
|
|
15579
17747
|
!isNaN(sectionStats[matchingKey].total)) {
|
|
15580
|
-
return (jsxRuntimeExports.jsx("span", { className: "whitespace-nowrap text-xs font-medium text-blue-800", children: sectionStats[matchingKey].total
|
|
17748
|
+
return (jsxRuntimeExports.jsx("span", { className: "whitespace-nowrap text-xs font-medium text-blue-800", children: formatValueWithUnit(sectionStats[matchingKey].total, columnIndex) }));
|
|
15581
17749
|
}
|
|
15582
17750
|
return jsxRuntimeExports.jsx("span", { className: "text-gray-400", children: "\u2014" });
|
|
15583
17751
|
})() })) }, columnIndex)))] }), (!section.collapsible || isExpanded) && section.rows.map((row, rowIndex) => (jsxRuntimeExports.jsxs("tr", { className: `border-b border-gray-200 ${rowIndex % 2 === 0
|
|
15584
17752
|
? "bg-white"
|
|
15585
|
-
: "bg-gray-50"} hover:bg-gray-100 transition-colors`, children: [jsxRuntimeExports.jsx("td", { className: "px-4 py-3" }), row.map((cell, cellIndex) => (jsxRuntimeExports.jsx("td", { className: "px-4 py-3 text-sm text-gray-900", children: cell
|
|
17753
|
+
: "bg-gray-50"} hover:bg-gray-100 transition-colors`, children: [jsxRuntimeExports.jsx("td", { className: "px-4 py-3" }), row.map((cell, cellIndex) => (jsxRuntimeExports.jsx("td", { className: "px-4 py-3 text-sm text-gray-900", children: formatValueWithUnit(cell, cellIndex) }, cellIndex)))] }, `${sectionIndex}-${rowIndex}`)))] }, `section-${sectionIndex}`));
|
|
15586
17754
|
}) })] }));
|
|
15587
17755
|
};
|
|
15588
|
-
const renderRegularTable = () => (jsxRuntimeExports.jsxs("table", { className: "w-full border-collapse", children: [jsxRuntimeExports.jsx("thead", { children: jsxRuntimeExports.jsx("tr", { className: "border-b border-gray-200", children: columns.map((column, index) => (jsxRuntimeExports.
|
|
17756
|
+
const renderRegularTable = () => (jsxRuntimeExports.jsxs("table", { className: "w-full border-collapse", children: [jsxRuntimeExports.jsx("thead", { children: jsxRuntimeExports.jsx("tr", { className: "border-b border-gray-200", children: columns.map((column, index) => (jsxRuntimeExports.jsxs("th", { className: "px-4 py-3 text-left text-sm font-medium text-gray-900 bg-gray-50", children: [column, (units === null || units === void 0 ? void 0 : units[index]) ? ` (${units[index]})` : ''] }, index))) }) }), jsxRuntimeExports.jsx("tbody", { children: rows.map((row, rowIndex) => (jsxRuntimeExports.jsx("tr", { className: `border-b border-gray-200 ${rowIndex % 2 === 0
|
|
15589
17757
|
? "bg-white"
|
|
15590
|
-
: "bg-gray-50"} hover:bg-gray-100 transition-colors`, children: row.map((cell, cellIndex) => (jsxRuntimeExports.jsx("td", { className: "px-4 py-3 text-sm text-gray-900", children: cell
|
|
17758
|
+
: "bg-gray-50"} hover:bg-gray-100 transition-colors`, children: row.map((cell, cellIndex) => (jsxRuntimeExports.jsx("td", { className: "px-4 py-3 text-sm text-gray-900", children: formatValueWithUnit(cell, cellIndex) }, cellIndex))) }, rowIndex))) })] }));
|
|
15591
17759
|
return (jsxRuntimeExports.jsxs("div", { className: `h-full flex flex-col ${className || ""}`, children: [title && (jsxRuntimeExports.jsx("div", { className: "pb-4", children: jsxRuntimeExports.jsx("h3", { className: "text-lg font-bold", style: {
|
|
15592
17760
|
color: "#0F172A"
|
|
15593
17761
|
}, children: title }) })), jsxRuntimeExports.jsx("div", { className: "flex-1 overflow-auto", children: jsxRuntimeExports.jsx("div", { className: "min-w-full", children: grouped && grouping ? renderGroupedTable() : renderRegularTable() }) }), jsxRuntimeExports.jsx("div", { className: "pt-2 text-xs text-gray-500", children: grouped && grouping && grouping.section_statistics ? (jsxRuntimeExports.jsxs("div", { className: "flex gap-6", children: [jsxRuntimeExports.jsxs("span", { children: [grouping.total_groups, " group", grouping.total_groups !== 1 ? "s" : "", " \u00D7 ", columns.length, " column", columns.length !== 1 ? "s" : ""] }), jsxRuntimeExports.jsx("div", { className: "flex gap-4", children: (() => {
|
|
@@ -15599,7 +17767,10 @@ function DataGrid({ title, data, className }) {
|
|
|
15599
17767
|
}
|
|
15600
17768
|
});
|
|
15601
17769
|
});
|
|
15602
|
-
return Object.entries(totals).map(([column, total], index) =>
|
|
17770
|
+
return Object.entries(totals).map(([column, total], index) => {
|
|
17771
|
+
const columnIndex = columns.findIndex(col => col === column);
|
|
17772
|
+
return (jsxRuntimeExports.jsxs("span", { className: "font-medium", children: ["Total ", column, ": ", formatValueWithUnit(total, columnIndex)] }, index));
|
|
17773
|
+
});
|
|
15603
17774
|
})() })] })) : (jsxRuntimeExports.jsxs("span", { children: ["Showing ", rows.length, " row", rows.length !== 1 ? "s" : "", " \u00D7 ", columns.length, " column", columns.length !== 1 ? "s" : ""] })) })] }));
|
|
15604
17775
|
}
|
|
15605
17776
|
|
|
@@ -36490,12 +38661,14 @@ function BarChartComponent({ orientation, barChartState, styles, appendMessage,
|
|
|
36490
38661
|
return (jsxRuntimeExports.jsx(BarChart, { orientation: orientation, title: chartTitle, data: transformedData, units: units, content: content }));
|
|
36491
38662
|
}
|
|
36492
38663
|
function SeriesBarChartComponent({ orientation, seriesBarChartState, styles, appendMessage, query, isFirstLoad, widgetBackendUrl, widgetId, startLoadingTimeout, clearLoadingTimeout, content }) {
|
|
36493
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
38664
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
|
|
36494
38665
|
const hasCalledRef = React.useRef(false);
|
|
36495
38666
|
const labels = ((_b = (_a = seriesBarChartState === null || seriesBarChartState === void 0 ? void 0 : seriesBarChartState.series_bar_chart_data) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.labels) || ((_e = (_d = (_c = seriesBarChartState === null || seriesBarChartState === void 0 ? void 0 : seriesBarChartState.state) === null || _c === void 0 ? void 0 : _c.series_bar_chart_data) === null || _d === void 0 ? void 0 : _d.data) === null || _e === void 0 ? void 0 : _e.labels) || [];
|
|
36496
|
-
const
|
|
36497
|
-
const
|
|
36498
|
-
const
|
|
38667
|
+
const x_axis_title = ((_f = seriesBarChartState === null || seriesBarChartState === void 0 ? void 0 : seriesBarChartState.series_bar_chart_data) === null || _f === void 0 ? void 0 : _f.x_axis_title) || ((_h = (_g = seriesBarChartState === null || seriesBarChartState === void 0 ? void 0 : seriesBarChartState.state) === null || _g === void 0 ? void 0 : _g.series_bar_chart_data) === null || _h === void 0 ? void 0 : _h.x_axis_title) || "";
|
|
38668
|
+
const y_axis_title = ((_j = seriesBarChartState === null || seriesBarChartState === void 0 ? void 0 : seriesBarChartState.series_bar_chart_data) === null || _j === void 0 ? void 0 : _j.y_axis_title) || ((_l = (_k = seriesBarChartState === null || seriesBarChartState === void 0 ? void 0 : seriesBarChartState.state) === null || _k === void 0 ? void 0 : _k.series_bar_chart_data) === null || _l === void 0 ? void 0 : _l.y_axis_title) || "";
|
|
38669
|
+
const series = ((_o = (_m = seriesBarChartState === null || seriesBarChartState === void 0 ? void 0 : seriesBarChartState.series_bar_chart_data) === null || _m === void 0 ? void 0 : _m.data) === null || _o === void 0 ? void 0 : _o.series) || ((_r = (_q = (_p = seriesBarChartState === null || seriesBarChartState === void 0 ? void 0 : seriesBarChartState.state) === null || _p === void 0 ? void 0 : _p.series_bar_chart_data) === null || _q === void 0 ? void 0 : _q.data) === null || _r === void 0 ? void 0 : _r.series) || [];
|
|
38670
|
+
const chartTitle = ((_s = seriesBarChartState === null || seriesBarChartState === void 0 ? void 0 : seriesBarChartState.series_bar_chart_data) === null || _s === void 0 ? void 0 : _s.title) || ((_u = (_t = seriesBarChartState === null || seriesBarChartState === void 0 ? void 0 : seriesBarChartState.state) === null || _t === void 0 ? void 0 : _t.series_bar_chart_data) === null || _u === void 0 ? void 0 : _u.title) || "";
|
|
38671
|
+
const units = ((_v = seriesBarChartState === null || seriesBarChartState === void 0 ? void 0 : seriesBarChartState.series_bar_chart_data) === null || _v === void 0 ? void 0 : _v.units) || ((_x = (_w = seriesBarChartState === null || seriesBarChartState === void 0 ? void 0 : seriesBarChartState.state) === null || _w === void 0 ? void 0 : _w.series_bar_chart_data) === null || _x === void 0 ? void 0 : _x.units) || "";
|
|
36499
38672
|
const isEmpty = labels.length === 0 || series.length === 0;
|
|
36500
38673
|
const handleRefresh = async () => {
|
|
36501
38674
|
if (query) {
|
|
@@ -36538,15 +38711,17 @@ function SeriesBarChartComponent({ orientation, seriesBarChartState, styles, app
|
|
|
36538
38711
|
backgroundColor: (seriesItem === null || seriesItem === void 0 ? void 0 : seriesItem.colors) || (seriesItem === null || seriesItem === void 0 ? void 0 : seriesItem.color) || finalColors[index % finalColors.length],
|
|
36539
38712
|
})),
|
|
36540
38713
|
};
|
|
36541
|
-
return (jsxRuntimeExports.jsx(SeriesChart, { orientation: orientation, title: chartTitle, data: transformedData, units: units, content: content }));
|
|
38714
|
+
return (jsxRuntimeExports.jsx(SeriesChart, { orientation: orientation, title: chartTitle, data: transformedData, units: units, content: content, x_axis_title: x_axis_title, y_axis_title: y_axis_title }));
|
|
36542
38715
|
}
|
|
36543
38716
|
function SeriesLineChartComponent({ orientation, seriesLineChartState, styles, appendMessage, content, query, isFirstLoad, widgetBackendUrl, widgetId, startLoadingTimeout, clearLoadingTimeout }) {
|
|
36544
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
38717
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
|
|
36545
38718
|
const hasCalledRef = React.useRef(false);
|
|
36546
38719
|
const labels = ((_b = (_a = seriesLineChartState === null || seriesLineChartState === void 0 ? void 0 : seriesLineChartState.series_bar_chart_data) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.labels) || ((_e = (_d = (_c = seriesLineChartState === null || seriesLineChartState === void 0 ? void 0 : seriesLineChartState.state) === null || _c === void 0 ? void 0 : _c.series_bar_chart_data) === null || _d === void 0 ? void 0 : _d.data) === null || _e === void 0 ? void 0 : _e.labels) || [];
|
|
36547
38720
|
const series = ((_g = (_f = seriesLineChartState === null || seriesLineChartState === void 0 ? void 0 : seriesLineChartState.series_bar_chart_data) === null || _f === void 0 ? void 0 : _f.data) === null || _g === void 0 ? void 0 : _g.series) || ((_k = (_j = (_h = seriesLineChartState === null || seriesLineChartState === void 0 ? void 0 : seriesLineChartState.state) === null || _h === void 0 ? void 0 : _h.series_bar_chart_data) === null || _j === void 0 ? void 0 : _j.data) === null || _k === void 0 ? void 0 : _k.series) || [];
|
|
36548
|
-
const
|
|
36549
|
-
const
|
|
38721
|
+
const x_axis_title = ((_l = seriesLineChartState === null || seriesLineChartState === void 0 ? void 0 : seriesLineChartState.series_bar_chart_data) === null || _l === void 0 ? void 0 : _l.x_axis_title) || ((_o = (_m = seriesLineChartState === null || seriesLineChartState === void 0 ? void 0 : seriesLineChartState.state) === null || _m === void 0 ? void 0 : _m.series_bar_chart_data) === null || _o === void 0 ? void 0 : _o.x_axis_title) || "";
|
|
38722
|
+
const y_axis_title = ((_p = seriesLineChartState === null || seriesLineChartState === void 0 ? void 0 : seriesLineChartState.series_bar_chart_data) === null || _p === void 0 ? void 0 : _p.y_axis_title) || ((_r = (_q = seriesLineChartState === null || seriesLineChartState === void 0 ? void 0 : seriesLineChartState.state) === null || _q === void 0 ? void 0 : _q.series_bar_chart_data) === null || _r === void 0 ? void 0 : _r.y_axis_title) || "";
|
|
38723
|
+
const chartTitle = ((_s = seriesLineChartState === null || seriesLineChartState === void 0 ? void 0 : seriesLineChartState.series_bar_chart_data) === null || _s === void 0 ? void 0 : _s.title) || ((_u = (_t = seriesLineChartState === null || seriesLineChartState === void 0 ? void 0 : seriesLineChartState.state) === null || _t === void 0 ? void 0 : _t.series_bar_chart_data) === null || _u === void 0 ? void 0 : _u.title) || "";
|
|
38724
|
+
const units = ((_v = seriesLineChartState === null || seriesLineChartState === void 0 ? void 0 : seriesLineChartState.series_bar_chart_data) === null || _v === void 0 ? void 0 : _v.units) || ((_x = (_w = seriesLineChartState === null || seriesLineChartState === void 0 ? void 0 : seriesLineChartState.state) === null || _w === void 0 ? void 0 : _w.series_bar_chart_data) === null || _x === void 0 ? void 0 : _x.units) || "";
|
|
36550
38725
|
const isEmpty = labels.length === 0 || series.length === 0;
|
|
36551
38726
|
const handleRefresh = async () => {
|
|
36552
38727
|
if (query) {
|
|
@@ -36596,7 +38771,7 @@ function SeriesLineChartComponent({ orientation, seriesLineChartState, styles, a
|
|
|
36596
38771
|
tension: 0.1,
|
|
36597
38772
|
})),
|
|
36598
38773
|
};
|
|
36599
|
-
return (jsxRuntimeExports.jsx(SeriesLineChart, { orientation: orientation, title: chartTitle, data: transformedData, units: units, content: content }));
|
|
38774
|
+
return (jsxRuntimeExports.jsx(SeriesLineChart, { orientation: orientation, title: chartTitle, data: transformedData, units: units, content: content, x_axis_title: x_axis_title, y_axis_title: y_axis_title }));
|
|
36600
38775
|
}
|
|
36601
38776
|
function PieChartComponent({ pieChartState, styles, appendMessage, query, isFirstLoad, widgetBackendUrl, widgetId, startLoadingTimeout, clearLoadingTimeout, content }) {
|
|
36602
38777
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1;
|
|
@@ -36712,11 +38887,12 @@ function LineChartComponent({ lineChartState, styles, appendMessage, query, isFi
|
|
|
36712
38887
|
return (jsxRuntimeExports.jsx(LineChart, { title: chartTitle, data: transformedData, units: units, content: content }));
|
|
36713
38888
|
}
|
|
36714
38889
|
function DataGridComponent({ dataGridState, styles, appendMessage, query, isFirstLoad, widgetBackendUrl, widgetId, startLoadingTimeout, clearLoadingTimeout }) {
|
|
36715
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
|
|
38890
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z;
|
|
36716
38891
|
const hasCalledRef = React.useRef(false);
|
|
36717
38892
|
const columns = ((_b = (_a = dataGridState === null || dataGridState === void 0 ? void 0 : dataGridState.matrix_grid_data) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.headers) || ((_e = (_d = (_c = dataGridState === null || dataGridState === void 0 ? void 0 : dataGridState.state) === null || _c === void 0 ? void 0 : _c.matrix_grid_data) === null || _d === void 0 ? void 0 : _d.data) === null || _e === void 0 ? void 0 : _e.headers) || [];
|
|
36718
38893
|
const rows = ((_g = (_f = dataGridState === null || dataGridState === void 0 ? void 0 : dataGridState.matrix_grid_data) === null || _f === void 0 ? void 0 : _f.data) === null || _g === void 0 ? void 0 : _g.rows) || ((_k = (_j = (_h = dataGridState === null || dataGridState === void 0 ? void 0 : dataGridState.state) === null || _h === void 0 ? void 0 : _h.matrix_grid_data) === null || _j === void 0 ? void 0 : _j.data) === null || _k === void 0 ? void 0 : _k.rows) || [];
|
|
36719
38894
|
const gridTitle = ((_l = dataGridState === null || dataGridState === void 0 ? void 0 : dataGridState.matrix_grid_data) === null || _l === void 0 ? void 0 : _l.title) || ((_o = (_m = dataGridState === null || dataGridState === void 0 ? void 0 : dataGridState.state) === null || _m === void 0 ? void 0 : _m.matrix_grid_data) === null || _o === void 0 ? void 0 : _o.title) || "";
|
|
38895
|
+
const units = ((_q = (_p = dataGridState === null || dataGridState === void 0 ? void 0 : dataGridState.matrix_grid_data) === null || _p === void 0 ? void 0 : _p.data) === null || _q === void 0 ? void 0 : _q.units) || ((_t = (_s = (_r = dataGridState === null || dataGridState === void 0 ? void 0 : dataGridState.state) === null || _r === void 0 ? void 0 : _r.matrix_grid_data) === null || _s === void 0 ? void 0 : _s.data) === null || _t === void 0 ? void 0 : _t.units) || [];
|
|
36720
38896
|
const isEmpty = columns.length === 0 || rows.length === 0;
|
|
36721
38897
|
const handleRefresh = async () => {
|
|
36722
38898
|
if (query) {
|
|
@@ -36750,9 +38926,10 @@ function DataGridComponent({ dataGridState, styles, appendMessage, query, isFirs
|
|
|
36750
38926
|
}
|
|
36751
38927
|
const transformedData = {
|
|
36752
38928
|
columns: columns,
|
|
38929
|
+
units: units,
|
|
36753
38930
|
rows: rows,
|
|
36754
|
-
grouped: ((
|
|
36755
|
-
grouping: ((
|
|
38931
|
+
grouped: ((_u = dataGridState === null || dataGridState === void 0 ? void 0 : dataGridState.matrix_grid_data) === null || _u === void 0 ? void 0 : _u.grouped) || ((_w = (_v = dataGridState === null || dataGridState === void 0 ? void 0 : dataGridState.state) === null || _v === void 0 ? void 0 : _v.matrix_grid_data) === null || _w === void 0 ? void 0 : _w.grouped) || false,
|
|
38932
|
+
grouping: ((_x = dataGridState === null || dataGridState === void 0 ? void 0 : dataGridState.matrix_grid_data) === null || _x === void 0 ? void 0 : _x.grouping) || ((_z = (_y = dataGridState === null || dataGridState === void 0 ? void 0 : dataGridState.state) === null || _y === void 0 ? void 0 : _y.matrix_grid_data) === null || _z === void 0 ? void 0 : _z.grouping)
|
|
36756
38933
|
};
|
|
36757
38934
|
return (jsxRuntimeExports.jsx(DataGrid, { title: gridTitle, data: transformedData, className: "" }));
|
|
36758
38935
|
}
|
|
@@ -36902,7 +39079,6 @@ function CopilotKitAgent({ widget, showHeader, styles, onResetReady, widgetIds,
|
|
|
36902
39079
|
React.useEffect(() => {
|
|
36903
39080
|
const handleTriggerAgent = (event) => {
|
|
36904
39081
|
const { widgetId, query, agentType: eventAgentType, datasetId } = event.detail;
|
|
36905
|
-
console.log('event.detail==>', event.detail);
|
|
36906
39082
|
if (widgetId === widget.id) {
|
|
36907
39083
|
let messageContent = query;
|
|
36908
39084
|
// Customize message based on agent type
|
|
@@ -40782,7 +42958,7 @@ function SavedPages({ onEditPage, widgetBackendUrl }) {
|
|
|
40782
42958
|
if (isLoading) {
|
|
40783
42959
|
return (jsxRuntimeExports.jsx("div", { className: "flex items-center justify-center h-screen", children: jsxRuntimeExports.jsx("div", { className: "animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900" }) }));
|
|
40784
42960
|
}
|
|
40785
|
-
return (jsxRuntimeExports.jsxs("div", { className: "container mx-auto p-6 space-y-6", children: [jsxRuntimeExports.jsxs("div", { className: "flex justify-between items-center", children: [jsxRuntimeExports.jsx("h1", { className: "text-2xl font-bold", children: "Saved Pages" }), jsxRuntimeExports.jsxs(Button, { onClick: handleCreatePage, children: [jsxRuntimeExports.jsx(lucideReact.Plus, { className: "h-4 w-4 mr-2" }), "Create New Page"] })] }), error && (jsxRuntimeExports.jsx(Alert, { variant: "destructive", children: jsxRuntimeExports.jsx(AlertDescription, { children: error }) })), jsxRuntimeExports.jsxs("div", { className: "flex items-center space-x-2", children: [jsxRuntimeExports.jsx(lucideReact.Search, { className: "h-4 w-4 text-muted-foreground" }), jsxRuntimeExports.jsx(Input, { placeholder: "Search pages...", value: searchTerm, onChange: (e) => setSearchTerm(e.target.value), className: "max-w-sm" })] }), jsxRuntimeExports.jsx("div", { className: "grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6", children: filteredPages.map((page) => (jsxRuntimeExports.jsxs(Card, { className: "hover:shadow-lg transition-shadow", children: [jsxRuntimeExports.jsxs(CardHeader, { children: [jsxRuntimeExports.jsx(CardTitle, { children: page.title }), jsxRuntimeExports.jsxs(CardDescription, { children: ["Created: ", format(new Date(page.created_at), "PPP")] })] }), jsxRuntimeExports.jsx(CardContent, { children: jsxRuntimeExports.jsxs("div", { className: "flex justify-between items-center", children: [jsxRuntimeExports.jsxs("div", { className: "flex items-center space-x-2 text-sm text-muted-foreground", children: [jsxRuntimeExports.jsx(lucideReact.LayoutGrid, { className: "h-4 w-4" }), jsxRuntimeExports.jsxs("span", { children: ["Page #", page.id] })] }), jsxRuntimeExports.jsxs("div", { className: "flex space-x-2", children: [jsxRuntimeExports.jsx(Button, { variant: "outline", size: "sm", onClick: () => onEditPage(page.id), children: jsxRuntimeExports.jsx(lucideReact.Edit2, { className: "h-4 w-4" }) }), jsxRuntimeExports.jsx(Button, { variant: "outline", size: "sm", onClick: () => handleDeletePage(page.id), children: jsxRuntimeExports.jsx(lucideReact.Trash2, { className: "h-4 w-4" }) })] })] }) })] }, page.id))) }), filteredPages.length === 0 && (jsxRuntimeExports.jsx("div", { className: "text-center text-muted-foreground py-12", children: "No pages found. Create a new one to get started." })), jsxRuntimeExports.jsx(Dialog, { open: isCreateModalOpen, onOpenChange: setIsCreateModalOpen, children: jsxRuntimeExports.jsxs(DialogContent, { className: "sm:max-w-[425px]", children: [jsxRuntimeExports.jsxs(DialogHeader, { children: [jsxRuntimeExports.jsx(DialogTitle, { children: "Create New Page" }), jsxRuntimeExports.jsx(DialogDescription, { children: "Create a new page with widgets. You can customize it after creation." })] }), jsxRuntimeExports.jsxs("div", { className: "grid gap-4 py-4", children: [jsxRuntimeExports.jsxs("div", { className: "grid grid-cols-4 items-center gap-4", children: [jsxRuntimeExports.jsx(Label, { htmlFor: "title", className: "text-right", children: "Title" }), jsxRuntimeExports.jsx(Input, { id: "title", value: newPageTitle, onChange: (e) => setNewPageTitle(e.target.value), placeholder: "Enter page title...", className: "col-span-3" })] }), jsxRuntimeExports.jsxs("div", { className: "flex items-center space-x-2", children: [jsxRuntimeExports.jsx(Checkbox, { id: "public", checked: newPageIsPublic, onCheckedChange: (checked) => setNewPageIsPublic(checked === true) }), jsxRuntimeExports.jsx(Label, { htmlFor: "public", className: "text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70", children: "Make this page public" })] })] }), jsxRuntimeExports.jsxs(DialogFooter, { children: [jsxRuntimeExports.jsx(Button, { type: "button", variant: "outline", onClick: () => {
|
|
42961
|
+
return (jsxRuntimeExports.jsxs("div", { className: "container mx-auto p-6 space-y-6", children: [jsxRuntimeExports.jsxs("div", { className: "flex justify-between items-center", children: [jsxRuntimeExports.jsx("h1", { className: "text-2xl font-bold", children: "Saved Pages" }), jsxRuntimeExports.jsxs(Button, { onClick: handleCreatePage, children: [jsxRuntimeExports.jsx(lucideReact.Plus, { className: "h-4 w-4 mr-2" }), "Create New Page"] })] }), error && (jsxRuntimeExports.jsx(Alert, { variant: "destructive", children: jsxRuntimeExports.jsx(AlertDescription, { children: error }) })), jsxRuntimeExports.jsxs("div", { className: "flex items-center space-x-2", children: [jsxRuntimeExports.jsx(lucideReact.Search, { className: "h-4 w-4 text-muted-foreground" }), jsxRuntimeExports.jsx(Input, { placeholder: "Search pages...", value: searchTerm, onChange: (e) => setSearchTerm(e.target.value), className: "max-w-sm" })] }), jsxRuntimeExports.jsx("div", { className: "grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6", children: filteredPages.map((page) => (jsxRuntimeExports.jsxs(Card, { className: "hover:shadow-lg transition-shadow", children: [jsxRuntimeExports.jsxs(CardHeader, { children: [jsxRuntimeExports.jsx(CardTitle, { children: page.title }), jsxRuntimeExports.jsxs(CardDescription, { children: ["Created: ", format(new Date(page.created_at), "PPP")] })] }), jsxRuntimeExports.jsx(CardContent, { children: jsxRuntimeExports.jsxs("div", { className: "flex justify-between items-center", children: [jsxRuntimeExports.jsxs("div", { className: "flex items-center space-x-2 text-sm text-muted-foreground", children: [jsxRuntimeExports.jsx(lucideReact.LayoutGrid, { className: "h-4 w-4" }), jsxRuntimeExports.jsxs("span", { children: ["Page #", page.id] })] }), jsxRuntimeExports.jsxs("div", { className: "flex space-x-2", children: [jsxRuntimeExports.jsx(Button, { variant: "outline", size: "sm", onClick: () => onEditPage(page.id), children: jsxRuntimeExports.jsx(lucideReact.Edit2, { className: "h-4 w-4" }) }), jsxRuntimeExports.jsx(Button, { variant: "outline", size: "sm", onClick: () => handleDeletePage(page.id), children: jsxRuntimeExports.jsx(lucideReact.Trash2, { className: "h-4 w-4" }) })] })] }) })] }, page.id))) }), filteredPages.length === 0 && (jsxRuntimeExports.jsx("div", { className: "text-center text-muted-foreground py-12", children: "No pages found. Create a new one to get started." })), jsxRuntimeExports.jsx(Dialog, { open: isCreateModalOpen, onOpenChange: setIsCreateModalOpen, children: jsxRuntimeExports.jsxs(DialogContent, { className: "sm:max-w-[425px]", children: [jsxRuntimeExports.jsxs(DialogHeader, { children: [jsxRuntimeExports.jsx(DialogTitle, { children: "Create New Page" }), jsxRuntimeExports.jsx(DialogDescription, { children: "Create a new page with widgets. You can customize it after creation." })] }), jsxRuntimeExports.jsxs("div", { className: "grid gap-4 py-4", children: [jsxRuntimeExports.jsxs("div", { className: "grid grid-cols-4 items-center gap-4", children: [jsxRuntimeExports.jsx(Label$1, { htmlFor: "title", className: "text-right", children: "Title" }), jsxRuntimeExports.jsx(Input, { id: "title", value: newPageTitle, onChange: (e) => setNewPageTitle(e.target.value), placeholder: "Enter page title...", className: "col-span-3" })] }), jsxRuntimeExports.jsxs("div", { className: "flex items-center space-x-2", children: [jsxRuntimeExports.jsx(Checkbox, { id: "public", checked: newPageIsPublic, onCheckedChange: (checked) => setNewPageIsPublic(checked === true) }), jsxRuntimeExports.jsx(Label$1, { htmlFor: "public", className: "text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70", children: "Make this page public" })] })] }), jsxRuntimeExports.jsxs(DialogFooter, { children: [jsxRuntimeExports.jsx(Button, { type: "button", variant: "outline", onClick: () => {
|
|
40786
42962
|
setIsCreateModalOpen(false);
|
|
40787
42963
|
setNewPageTitle("");
|
|
40788
42964
|
setNewPageIsPublic(false);
|