@lattice-php/lattice 0.17.0 → 0.17.2
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/chat/index.d.ts +1 -1
- package/dist/chat/index.js +3 -3
- package/dist/chat/index.js.map +1 -1
- package/dist/core/components/chart-view.d.ts +3 -0
- package/dist/core/components/chart-view.js +225 -0
- package/dist/core/components/chart-view.js.map +1 -0
- package/dist/core/components/chart.js +10 -220
- package/dist/core/components/chart.js.map +1 -1
- package/dist/core/components/index.js +3 -2
- package/dist/core/components/index.js.map +1 -1
- package/dist/core/renderer.js +42 -2
- package/dist/core/renderer.js.map +1 -1
- package/dist/create-app.js +3 -3
- package/dist/create-app.js.map +1 -1
- package/dist/form/components/fields/date-input.js +2 -2
- package/dist/form/components/fields/date-input.js.map +1 -1
- package/dist/form/components/fields/{date-picker-control.d.ts → date-picker-field.d.ts} +2 -2
- package/dist/form/components/fields/{date-picker-control.js → date-picker-field.js} +4 -4
- package/dist/form/components/fields/date-picker-field.js.map +1 -0
- package/dist/form/components/fields/date-picker.d.ts +2 -0
- package/dist/form/components/fields/date-picker.js +17 -0
- package/dist/form/components/fields/date-picker.js.map +1 -0
- package/dist/form/components/fields/date-time-input.js +2 -2
- package/dist/form/components/fields/date-time-input.js.map +1 -1
- package/dist/form/components/fields/rich-editor-field.d.ts +3 -0
- package/dist/form/components/fields/rich-editor-field.js +340 -0
- package/dist/form/components/fields/rich-editor-field.js.map +1 -0
- package/dist/form/components/fields/rich-editor.js +10 -335
- package/dist/form/components/fields/rich-editor.js.map +1 -1
- package/dist/form/components/fields/table-rows.js +2 -2
- package/dist/form/index.js +37 -29
- package/dist/form/index.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +4 -4
- package/dist/notifications/index.d.ts +1 -1
- package/dist/notifications/index.js +2 -2
- package/dist/notifications/index.js.map +1 -1
- package/dist/provider.js +4 -4
- package/dist/provider.js.map +1 -1
- package/dist/registry.d.ts +1 -1
- package/dist/registry.js +15 -2
- package/dist/registry.js.map +1 -0
- package/dist/table/components/cells/money-cell.js +1 -1
- package/dist/table/components/cells/number-cell.js +1 -1
- package/dist/table/components/table.js +1 -1
- package/dist/table/index.js +3 -2
- package/dist/table/index.js.map +1 -1
- package/package.json +8 -11
- package/dist/core/components/eager.d.ts +0 -1
- package/dist/core/components/eager.js +0 -50
- package/dist/core/components/eager.js.map +0 -1
- package/dist/form/components/fields/date-picker-control.js.map +0 -1
- package/dist/form/components/fields/lazy-date-picker-control.d.ts +0 -2
- package/dist/form/components/fields/lazy-date-picker-control.js +0 -17
- package/dist/form/components/fields/lazy-date-picker-control.js.map +0 -1
- package/dist/form/eager.d.ts +0 -1
- package/dist/form/eager.js +0 -47
- package/dist/form/eager.js.map +0 -1
- package/dist/form/skeleton.d.ts +0 -2
- package/dist/form/skeleton.js +0 -22
- package/dist/form/skeleton.js.map +0 -1
- package/dist/registry/eager.d.ts +0 -1
- package/dist/registry/eager.js +0 -15
- package/dist/registry/eager.js.map +0 -1
- package/dist/registry/lazy.d.ts +0 -1
- package/dist/registry/lazy.js +0 -15
- package/dist/registry/lazy.js.map +0 -1
- package/dist/table/eager.d.ts +0 -1
- package/dist/table/eager.js +0 -11
- package/dist/table/eager.js.map +0 -1
package/dist/chat/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const
|
|
1
|
+
export declare const chatComponents: import('../core/registry').Plugin;
|
package/dist/chat/index.js
CHANGED
|
@@ -3,8 +3,8 @@ import { ChatBox } from "./components/chat-box.js";
|
|
|
3
3
|
import { TextPart } from "./parts/text.js";
|
|
4
4
|
import { ToolCallPart } from "./parts/tool-call.js";
|
|
5
5
|
//#region resources/js/chat/index.ts
|
|
6
|
-
var
|
|
7
|
-
name: "chat",
|
|
6
|
+
var chatComponents = createPlugin({
|
|
7
|
+
name: "lattice/chat",
|
|
8
8
|
components: {
|
|
9
9
|
"chat.box": eagerComponent(ChatBox),
|
|
10
10
|
"chat.part.text": eagerComponent(TextPart),
|
|
@@ -12,6 +12,6 @@ var chatPlugin = createPlugin({
|
|
|
12
12
|
}
|
|
13
13
|
});
|
|
14
14
|
//#endregion
|
|
15
|
-
export {
|
|
15
|
+
export { chatComponents };
|
|
16
16
|
|
|
17
17
|
//# sourceMappingURL=index.js.map
|
package/dist/chat/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../resources/js/chat/index.ts"],"sourcesContent":["import { createPlugin, eagerComponent } from \"@lattice-php/lattice/core/registry\";\nimport ChatBoxComponent from \"./components/chat-box\";\nimport { TextPart } from \"./parts/text\";\nimport { ToolCallPart } from \"./parts/tool-call\";\n\nexport const
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../resources/js/chat/index.ts"],"sourcesContent":["import { createPlugin, eagerComponent } from \"@lattice-php/lattice/core/registry\";\nimport ChatBoxComponent from \"./components/chat-box\";\nimport { TextPart } from \"./parts/text\";\nimport { ToolCallPart } from \"./parts/tool-call\";\n\nexport const chatComponents = createPlugin({\n name: \"lattice/chat\",\n components: {\n \"chat.box\": eagerComponent(ChatBoxComponent),\n \"chat.part.text\": eagerComponent(TextPart),\n \"chat.part.tool-call\": eagerComponent(ToolCallPart),\n },\n});\n"],"mappings":";;;;;AAKA,IAAa,iBAAiB,aAAa;CACzC,MAAM;CACN,YAAY;EACV,YAAY,eAAe,OAAgB;EAC3C,kBAAkB,eAAe,QAAQ;EACzC,uBAAuB,eAAe,YAAY;CACpD;AACF,CAAC"}
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
import { useLocale } from "../../i18n/locale.js";
|
|
2
|
+
import { useTimezone } from "../../i18n/timezone.js";
|
|
3
|
+
import { nodeIdentity } from "../test-id.js";
|
|
4
|
+
import { formatValue } from "../../format/value.js";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
import { Area, AreaChart, Bar, BarChart, CartesianGrid, Cell, ComposedChart, Legend, Line, LineChart, Pie, PieChart, ResponsiveContainer, Tooltip, XAxis, YAxis } from "recharts";
|
|
7
|
+
//#region resources/js/core/components/chart-view.tsx
|
|
8
|
+
var chartMargin = {
|
|
9
|
+
bottom: 0,
|
|
10
|
+
left: 0,
|
|
11
|
+
right: 16,
|
|
12
|
+
top: 8
|
|
13
|
+
};
|
|
14
|
+
var compactLegendProps = {
|
|
15
|
+
align: "center",
|
|
16
|
+
height: 24,
|
|
17
|
+
iconSize: 7,
|
|
18
|
+
verticalAlign: "top",
|
|
19
|
+
wrapperStyle: {
|
|
20
|
+
fontSize: 11,
|
|
21
|
+
lineHeight: "14px",
|
|
22
|
+
paddingBottom: 6
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
var axisTick = { fontSize: 10 };
|
|
26
|
+
var tooltipProps = {
|
|
27
|
+
contentStyle: {
|
|
28
|
+
background: "var(--lt-surface)",
|
|
29
|
+
border: "1px solid var(--lt-border)",
|
|
30
|
+
borderRadius: "var(--lt-radius-sm)",
|
|
31
|
+
boxShadow: "var(--lt-shadow-sm)",
|
|
32
|
+
color: "var(--lt-surface-fg)",
|
|
33
|
+
fontSize: 12
|
|
34
|
+
},
|
|
35
|
+
itemStyle: { color: "var(--lt-surface-fg)" },
|
|
36
|
+
labelStyle: { color: "var(--lt-muted-fg)" }
|
|
37
|
+
};
|
|
38
|
+
var palette = [
|
|
39
|
+
"var(--lt-primary)",
|
|
40
|
+
"var(--lt-success)",
|
|
41
|
+
"var(--lt-info)",
|
|
42
|
+
"var(--lt-warning)",
|
|
43
|
+
"var(--lt-danger)",
|
|
44
|
+
"var(--lt-muted-fg)"
|
|
45
|
+
];
|
|
46
|
+
function colorAt(index) {
|
|
47
|
+
return palette[index % palette.length] ?? "var(--lt-primary)";
|
|
48
|
+
}
|
|
49
|
+
function isRecord(value) {
|
|
50
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
51
|
+
}
|
|
52
|
+
function datumColor(datum, series, index) {
|
|
53
|
+
if (isRecord(datum) && typeof datum.color === "string") return datum.color;
|
|
54
|
+
return series.color ?? colorAt(index);
|
|
55
|
+
}
|
|
56
|
+
function isCartesianSeries(series) {
|
|
57
|
+
return series.type === "area" || series.type === "bar" || series.type === "line";
|
|
58
|
+
}
|
|
59
|
+
function cartesianChartFor(series) {
|
|
60
|
+
const types = new Set(series.map((item) => item.type));
|
|
61
|
+
const firstSeries = series[0];
|
|
62
|
+
if (firstSeries === void 0 || types.size !== 1) return ComposedChart;
|
|
63
|
+
switch (firstSeries.type) {
|
|
64
|
+
case "area": return AreaChart;
|
|
65
|
+
case "bar": return BarChart;
|
|
66
|
+
case "line": return LineChart;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
function ChartFrame({ children, description, id, title }) {
|
|
70
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
71
|
+
className: "flex flex-col gap-3 rounded-lt border border-lt-border bg-lt-surface p-4 text-lt-surface-fg shadow-lt-sm",
|
|
72
|
+
"data-lattice-component": id,
|
|
73
|
+
children: [(title !== null || description !== null) && /* @__PURE__ */ jsxs("div", {
|
|
74
|
+
className: "flex min-w-0 flex-col gap-1.5",
|
|
75
|
+
children: [title !== null && /* @__PURE__ */ jsx("div", {
|
|
76
|
+
className: "text-sm font-semibold leading-tight",
|
|
77
|
+
children: title
|
|
78
|
+
}), description !== null && /* @__PURE__ */ jsx("div", {
|
|
79
|
+
className: "text-xs leading-5 text-lt-muted-fg",
|
|
80
|
+
children: description
|
|
81
|
+
})]
|
|
82
|
+
}), children]
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
function CartesianChart({ props }) {
|
|
86
|
+
const series = props.series.filter(isCartesianSeries);
|
|
87
|
+
const RechartsChart = cartesianChartFor(series);
|
|
88
|
+
const { locale } = useLocale();
|
|
89
|
+
const { timezone } = useTimezone();
|
|
90
|
+
const ctx = {
|
|
91
|
+
locale,
|
|
92
|
+
timezone
|
|
93
|
+
};
|
|
94
|
+
const formatCategory = (value) => formatValue(value, props.categoryFormat, ctx);
|
|
95
|
+
const formatValueTick = (value) => formatValue(value, props.valueFormat, ctx);
|
|
96
|
+
const tooltipCursor = series.some((item) => item.type === "bar") ? {
|
|
97
|
+
fill: "var(--lt-muted-fg)",
|
|
98
|
+
fillOpacity: .15
|
|
99
|
+
} : {
|
|
100
|
+
stroke: "var(--lt-muted-fg)",
|
|
101
|
+
strokeOpacity: .4
|
|
102
|
+
};
|
|
103
|
+
return /* @__PURE__ */ jsx(ResponsiveContainer, {
|
|
104
|
+
width: "100%",
|
|
105
|
+
height: props.height,
|
|
106
|
+
debounce: 100,
|
|
107
|
+
children: /* @__PURE__ */ jsxs(RechartsChart, {
|
|
108
|
+
data: props.data,
|
|
109
|
+
margin: chartMargin,
|
|
110
|
+
children: [
|
|
111
|
+
props.grid && /* @__PURE__ */ jsx(CartesianGrid, {
|
|
112
|
+
strokeDasharray: "3 3",
|
|
113
|
+
stroke: "var(--lt-border)"
|
|
114
|
+
}),
|
|
115
|
+
props.xAxis && props.categoryKey !== null && /* @__PURE__ */ jsx(XAxis, {
|
|
116
|
+
dataKey: props.categoryKey,
|
|
117
|
+
stroke: "var(--lt-muted-fg)",
|
|
118
|
+
tick: axisTick,
|
|
119
|
+
tickFormatter: formatCategory,
|
|
120
|
+
tickLine: false
|
|
121
|
+
}),
|
|
122
|
+
props.yAxis && /* @__PURE__ */ jsx(YAxis, {
|
|
123
|
+
stroke: "var(--lt-muted-fg)",
|
|
124
|
+
tick: axisTick,
|
|
125
|
+
tickFormatter: formatValueTick,
|
|
126
|
+
tickLine: false,
|
|
127
|
+
width: 42
|
|
128
|
+
}),
|
|
129
|
+
props.tooltip && /* @__PURE__ */ jsx(Tooltip, {
|
|
130
|
+
...tooltipProps,
|
|
131
|
+
cursor: tooltipCursor,
|
|
132
|
+
formatter: formatValueTick,
|
|
133
|
+
labelFormatter: formatCategory
|
|
134
|
+
}),
|
|
135
|
+
props.legend && /* @__PURE__ */ jsx(Legend, { ...compactLegendProps }),
|
|
136
|
+
series.map((item, index) => {
|
|
137
|
+
const color = item.color ?? colorAt(index);
|
|
138
|
+
const key = `${item.type}:${item.dataKey}`;
|
|
139
|
+
if (item.type === "area") return /* @__PURE__ */ jsx(Area, {
|
|
140
|
+
dataKey: item.dataKey,
|
|
141
|
+
fill: color,
|
|
142
|
+
fillOpacity: .16,
|
|
143
|
+
name: item.name ?? void 0,
|
|
144
|
+
stackId: item.stackId ?? void 0,
|
|
145
|
+
stroke: color,
|
|
146
|
+
type: "monotone"
|
|
147
|
+
}, key);
|
|
148
|
+
if (item.type === "bar") return /* @__PURE__ */ jsx(Bar, {
|
|
149
|
+
dataKey: item.dataKey,
|
|
150
|
+
fill: color,
|
|
151
|
+
name: item.name ?? void 0,
|
|
152
|
+
radius: [
|
|
153
|
+
4,
|
|
154
|
+
4,
|
|
155
|
+
0,
|
|
156
|
+
0
|
|
157
|
+
],
|
|
158
|
+
stackId: item.stackId ?? void 0
|
|
159
|
+
}, key);
|
|
160
|
+
return /* @__PURE__ */ jsx(Line, {
|
|
161
|
+
dataKey: item.dataKey,
|
|
162
|
+
dot: false,
|
|
163
|
+
name: item.name ?? void 0,
|
|
164
|
+
stroke: color,
|
|
165
|
+
strokeWidth: 2,
|
|
166
|
+
type: "monotone"
|
|
167
|
+
}, key);
|
|
168
|
+
})
|
|
169
|
+
]
|
|
170
|
+
})
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
function PieChartView({ props, series }) {
|
|
174
|
+
const { locale } = useLocale();
|
|
175
|
+
const { timezone } = useTimezone();
|
|
176
|
+
const ctx = {
|
|
177
|
+
locale,
|
|
178
|
+
timezone
|
|
179
|
+
};
|
|
180
|
+
return /* @__PURE__ */ jsx(ResponsiveContainer, {
|
|
181
|
+
width: "100%",
|
|
182
|
+
height: props.height,
|
|
183
|
+
debounce: 100,
|
|
184
|
+
children: /* @__PURE__ */ jsxs(PieChart, {
|
|
185
|
+
margin: chartMargin,
|
|
186
|
+
children: [
|
|
187
|
+
props.tooltip && /* @__PURE__ */ jsx(Tooltip, {
|
|
188
|
+
...tooltipProps,
|
|
189
|
+
formatter: (value) => formatValue(value, props.valueFormat, ctx),
|
|
190
|
+
labelFormatter: (value) => formatValue(value, props.categoryFormat, ctx)
|
|
191
|
+
}),
|
|
192
|
+
props.legend && /* @__PURE__ */ jsx(Legend, { ...compactLegendProps }),
|
|
193
|
+
/* @__PURE__ */ jsx(Pie, {
|
|
194
|
+
data: props.data,
|
|
195
|
+
dataKey: series.dataKey,
|
|
196
|
+
name: series.name ?? void 0,
|
|
197
|
+
nameKey: series.nameKey ?? void 0,
|
|
198
|
+
outerRadius: "68%",
|
|
199
|
+
children: props.data.map((datum, index) => /* @__PURE__ */ jsx(Cell, { fill: datumColor(datum, series, index) }, index))
|
|
200
|
+
})
|
|
201
|
+
]
|
|
202
|
+
})
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
var ChartView = ({ node }) => {
|
|
206
|
+
const props = node.props;
|
|
207
|
+
const pieSeries = props.series.find((series) => series.type === "pie");
|
|
208
|
+
const hasCartesianSeries = props.series.some(isCartesianSeries);
|
|
209
|
+
return /* @__PURE__ */ jsx(ChartFrame, {
|
|
210
|
+
description: props.description,
|
|
211
|
+
id: nodeIdentity(node),
|
|
212
|
+
title: props.title,
|
|
213
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
214
|
+
className: "min-h-0 w-full",
|
|
215
|
+
children: pieSeries && !hasCartesianSeries ? /* @__PURE__ */ jsx(PieChartView, {
|
|
216
|
+
props,
|
|
217
|
+
series: pieSeries
|
|
218
|
+
}) : /* @__PURE__ */ jsx(CartesianChart, { props })
|
|
219
|
+
})
|
|
220
|
+
});
|
|
221
|
+
};
|
|
222
|
+
//#endregion
|
|
223
|
+
export { ChartView as default };
|
|
224
|
+
|
|
225
|
+
//# sourceMappingURL=chart-view.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chart-view.js","names":[],"sources":["../../../resources/js/core/components/chart-view.tsx"],"sourcesContent":["import {\n Area,\n AreaChart,\n Bar,\n BarChart,\n CartesianGrid,\n Cell,\n ComposedChart,\n Legend,\n Line,\n LineChart,\n Pie,\n PieChart,\n ResponsiveContainer,\n Tooltip,\n XAxis,\n YAxis,\n} from \"recharts\";\nimport type { ComponentType, ReactNode } from \"react\";\nimport { nodeIdentity } from \"@lattice-php/lattice/core/test-id\";\nimport type { PropsOf, RendererComponent } from \"@lattice-php/lattice/core/types\";\nimport { useLocale, useTimezone } from \"@lattice-php/lattice/i18n\";\nimport { formatValue } from \"../../format/value\";\n\ntype ChartProps = PropsOf<\"chart\">;\ntype ChartSeries = ChartProps[\"series\"][number];\ntype ChartDatum = ChartProps[\"data\"][number];\ntype CartesianSeries = ChartSeries & { type: \"area\" | \"bar\" | \"line\" };\ntype ChartMargin = { bottom: number; left: number; right: number; top: number };\ntype CartesianChartComponent = ComponentType<{\n children: ReactNode;\n data: ChartProps[\"data\"];\n margin?: ChartMargin;\n}>;\n\nconst chartMargin: ChartMargin = { bottom: 0, left: 0, right: 16, top: 8 };\nconst compactLegendProps = {\n align: \"center\" as const,\n height: 24,\n iconSize: 7,\n verticalAlign: \"top\" as const,\n wrapperStyle: { fontSize: 11, lineHeight: \"14px\", paddingBottom: 6 },\n};\nconst axisTick = { fontSize: 10 };\nconst tooltipProps = {\n contentStyle: {\n background: \"var(--lt-surface)\",\n border: \"1px solid var(--lt-border)\",\n borderRadius: \"var(--lt-radius-sm)\",\n boxShadow: \"var(--lt-shadow-sm)\",\n color: \"var(--lt-surface-fg)\",\n fontSize: 12,\n },\n itemStyle: { color: \"var(--lt-surface-fg)\" },\n labelStyle: { color: \"var(--lt-muted-fg)\" },\n} as const;\n\nconst palette = [\n \"var(--lt-primary)\",\n \"var(--lt-success)\",\n \"var(--lt-info)\",\n \"var(--lt-warning)\",\n \"var(--lt-danger)\",\n \"var(--lt-muted-fg)\",\n];\n\nfunction colorAt(index: number): string {\n return palette[index % palette.length] ?? \"var(--lt-primary)\";\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction datumColor(datum: ChartDatum, series: ChartSeries, index: number): string {\n if (isRecord(datum) && typeof datum.color === \"string\") {\n return datum.color;\n }\n\n return series.color ?? colorAt(index);\n}\n\nfunction isCartesianSeries(series: ChartSeries): series is CartesianSeries {\n return series.type === \"area\" || series.type === \"bar\" || series.type === \"line\";\n}\n\nfunction cartesianChartFor(series: CartesianSeries[]): CartesianChartComponent {\n const types = new Set(series.map((item) => item.type));\n const firstSeries = series[0];\n\n if (firstSeries === undefined || types.size !== 1) {\n return ComposedChart;\n }\n\n switch (firstSeries.type) {\n case \"area\":\n return AreaChart;\n case \"bar\":\n return BarChart;\n case \"line\":\n return LineChart;\n }\n}\n\nfunction ChartFrame({\n children,\n description,\n id,\n title,\n}: {\n children: ReactNode;\n description: string | null;\n id?: string;\n title: string | null;\n}) {\n const hasHeader = title !== null || description !== null;\n\n return (\n <div\n className=\"flex flex-col gap-3 rounded-lt border border-lt-border bg-lt-surface p-4 text-lt-surface-fg shadow-lt-sm\"\n data-lattice-component={id}\n >\n {hasHeader && (\n <div className=\"flex min-w-0 flex-col gap-1.5\">\n {title !== null && <div className=\"text-sm font-semibold leading-tight\">{title}</div>}\n {description !== null && (\n <div className=\"text-xs leading-5 text-lt-muted-fg\">{description}</div>\n )}\n </div>\n )}\n {children}\n </div>\n );\n}\n\nfunction CartesianChart({ props }: { props: ChartProps }) {\n const series = props.series.filter(isCartesianSeries);\n const RechartsChart = cartesianChartFor(series);\n const { locale } = useLocale();\n const { timezone } = useTimezone();\n const ctx = { locale, timezone };\n const formatCategory = (value: unknown) => formatValue(value, props.categoryFormat, ctx);\n const formatValueTick = (value: unknown) => formatValue(value, props.valueFormat, ctx);\n const hasBarSeries = series.some((item) => item.type === \"bar\");\n const tooltipCursor = hasBarSeries\n ? { fill: \"var(--lt-muted-fg)\", fillOpacity: 0.15 }\n : { stroke: \"var(--lt-muted-fg)\", strokeOpacity: 0.4 };\n\n return (\n <ResponsiveContainer width=\"100%\" height={props.height} debounce={100}>\n <RechartsChart data={props.data} margin={chartMargin}>\n {props.grid && <CartesianGrid strokeDasharray=\"3 3\" stroke=\"var(--lt-border)\" />}\n {props.xAxis && props.categoryKey !== null && (\n <XAxis\n dataKey={props.categoryKey}\n stroke=\"var(--lt-muted-fg)\"\n tick={axisTick}\n tickFormatter={formatCategory}\n tickLine={false}\n />\n )}\n {props.yAxis && (\n <YAxis\n stroke=\"var(--lt-muted-fg)\"\n tick={axisTick}\n tickFormatter={formatValueTick}\n tickLine={false}\n width={42}\n />\n )}\n {props.tooltip && (\n <Tooltip\n {...tooltipProps}\n cursor={tooltipCursor}\n formatter={formatValueTick}\n labelFormatter={formatCategory}\n />\n )}\n {props.legend && <Legend {...compactLegendProps} />}\n {series.map((item, index) => {\n const color = item.color ?? colorAt(index);\n const key = `${item.type}:${item.dataKey}`;\n\n if (item.type === \"area\") {\n return (\n <Area\n key={key}\n dataKey={item.dataKey}\n fill={color}\n fillOpacity={0.16}\n name={item.name ?? undefined}\n stackId={item.stackId ?? undefined}\n stroke={color}\n type=\"monotone\"\n />\n );\n }\n\n if (item.type === \"bar\") {\n return (\n <Bar\n key={key}\n dataKey={item.dataKey}\n fill={color}\n name={item.name ?? undefined}\n radius={[4, 4, 0, 0]}\n stackId={item.stackId ?? undefined}\n />\n );\n }\n\n return (\n <Line\n key={key}\n dataKey={item.dataKey}\n dot={false}\n name={item.name ?? undefined}\n stroke={color}\n strokeWidth={2}\n type=\"monotone\"\n />\n );\n })}\n </RechartsChart>\n </ResponsiveContainer>\n );\n}\n\nfunction PieChartView({ props, series }: { props: ChartProps; series: ChartSeries }) {\n const { locale } = useLocale();\n const { timezone } = useTimezone();\n const ctx = { locale, timezone };\n\n return (\n <ResponsiveContainer width=\"100%\" height={props.height} debounce={100}>\n <PieChart margin={chartMargin}>\n {props.tooltip && (\n <Tooltip\n {...tooltipProps}\n formatter={(value) => formatValue(value, props.valueFormat, ctx)}\n labelFormatter={(value) => formatValue(value, props.categoryFormat, ctx)}\n />\n )}\n {props.legend && <Legend {...compactLegendProps} />}\n <Pie\n data={props.data}\n dataKey={series.dataKey}\n name={series.name ?? undefined}\n nameKey={series.nameKey ?? undefined}\n outerRadius=\"68%\"\n >\n {props.data.map((datum, index) => (\n <Cell key={index} fill={datumColor(datum, series, index)} />\n ))}\n </Pie>\n </PieChart>\n </ResponsiveContainer>\n );\n}\n\nconst ChartView: RendererComponent<\"chart\"> = ({ node }) => {\n const props = node.props;\n const pieSeries = props.series.find((series) => series.type === \"pie\");\n const hasCartesianSeries = props.series.some(isCartesianSeries);\n\n return (\n <ChartFrame description={props.description} id={nodeIdentity(node)} title={props.title}>\n <div className=\"min-h-0 w-full\">\n {pieSeries && !hasCartesianSeries ? (\n <PieChartView props={props} series={pieSeries} />\n ) : (\n <CartesianChart props={props} />\n )}\n </div>\n </ChartFrame>\n );\n};\n\nexport default ChartView;\n"],"mappings":";;;;;;;AAmCA,IAAM,cAA2B;CAAE,QAAQ;CAAG,MAAM;CAAG,OAAO;CAAI,KAAK;AAAE;AACzE,IAAM,qBAAqB;CACzB,OAAO;CACP,QAAQ;CACR,UAAU;CACV,eAAe;CACf,cAAc;EAAE,UAAU;EAAI,YAAY;EAAQ,eAAe;CAAE;AACrE;AACA,IAAM,WAAW,EAAE,UAAU,GAAG;AAChC,IAAM,eAAe;CACnB,cAAc;EACZ,YAAY;EACZ,QAAQ;EACR,cAAc;EACd,WAAW;EACX,OAAO;EACP,UAAU;CACZ;CACA,WAAW,EAAE,OAAO,uBAAuB;CAC3C,YAAY,EAAE,OAAO,qBAAqB;AAC5C;AAEA,IAAM,UAAU;CACd;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,SAAS,QAAQ,OAAuB;CACtC,OAAO,QAAQ,QAAQ,QAAQ,WAAW;AAC5C;AAEA,SAAS,SAAS,OAAkD;CAClE,OAAO,OAAO,UAAU,YAAY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hD,oBAAC,gBAAD,EAAuB,MAAQ,CAAA;EAE9B,CAAA;CACK,CAAA;AAEhB"}
|
|
@@ -1,224 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { nodeIdentity } from "../test-id.js";
|
|
4
|
-
import { formatValue } from "../../format/value.js";
|
|
5
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
-
import { Area, AreaChart, Bar, BarChart, CartesianGrid, Cell, ComposedChart, Legend, Line, LineChart, Pie, PieChart, ResponsiveContainer, Tooltip, XAxis, YAxis } from "recharts";
|
|
1
|
+
import { Suspense, lazy } from "react";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
7
3
|
//#region resources/js/core/components/chart.tsx
|
|
8
|
-
var
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
height: 24,
|
|
17
|
-
iconSize: 7,
|
|
18
|
-
verticalAlign: "top",
|
|
19
|
-
wrapperStyle: {
|
|
20
|
-
fontSize: 11,
|
|
21
|
-
lineHeight: "14px",
|
|
22
|
-
paddingBottom: 6
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
var axisTick = { fontSize: 10 };
|
|
26
|
-
var tooltipProps = {
|
|
27
|
-
contentStyle: {
|
|
28
|
-
background: "var(--lt-surface)",
|
|
29
|
-
border: "1px solid var(--lt-border)",
|
|
30
|
-
borderRadius: "var(--lt-radius-sm)",
|
|
31
|
-
boxShadow: "var(--lt-shadow-sm)",
|
|
32
|
-
color: "var(--lt-surface-fg)",
|
|
33
|
-
fontSize: 12
|
|
34
|
-
},
|
|
35
|
-
itemStyle: { color: "var(--lt-surface-fg)" },
|
|
36
|
-
labelStyle: { color: "var(--lt-muted-fg)" }
|
|
37
|
-
};
|
|
38
|
-
var palette = [
|
|
39
|
-
"var(--lt-primary)",
|
|
40
|
-
"var(--lt-success)",
|
|
41
|
-
"var(--lt-info)",
|
|
42
|
-
"var(--lt-warning)",
|
|
43
|
-
"var(--lt-danger)",
|
|
44
|
-
"var(--lt-muted-fg)"
|
|
45
|
-
];
|
|
46
|
-
function colorAt(index) {
|
|
47
|
-
return palette[index % palette.length] ?? "var(--lt-primary)";
|
|
48
|
-
}
|
|
49
|
-
function isRecord(value) {
|
|
50
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
51
|
-
}
|
|
52
|
-
function datumColor(datum, series, index) {
|
|
53
|
-
if (isRecord(datum) && typeof datum.color === "string") return datum.color;
|
|
54
|
-
return series.color ?? colorAt(index);
|
|
55
|
-
}
|
|
56
|
-
function isCartesianSeries(series) {
|
|
57
|
-
return series.type === "area" || series.type === "bar" || series.type === "line";
|
|
58
|
-
}
|
|
59
|
-
function cartesianChartFor(series) {
|
|
60
|
-
const types = new Set(series.map((item) => item.type));
|
|
61
|
-
const firstSeries = series[0];
|
|
62
|
-
if (firstSeries === void 0 || types.size !== 1) return ComposedChart;
|
|
63
|
-
switch (firstSeries.type) {
|
|
64
|
-
case "area": return AreaChart;
|
|
65
|
-
case "bar": return BarChart;
|
|
66
|
-
case "line": return LineChart;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
function ChartFrame({ children, description, id, title }) {
|
|
70
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
71
|
-
className: "flex flex-col gap-3 rounded-lt border border-lt-border bg-lt-surface p-4 text-lt-surface-fg shadow-lt-sm",
|
|
72
|
-
"data-lattice-component": id,
|
|
73
|
-
children: [(title !== null || description !== null) && /* @__PURE__ */ jsxs("div", {
|
|
74
|
-
className: "flex min-w-0 flex-col gap-1.5",
|
|
75
|
-
children: [title !== null && /* @__PURE__ */ jsx("div", {
|
|
76
|
-
className: "text-sm font-semibold leading-tight",
|
|
77
|
-
children: title
|
|
78
|
-
}), description !== null && /* @__PURE__ */ jsx("div", {
|
|
79
|
-
className: "text-xs leading-5 text-lt-muted-fg",
|
|
80
|
-
children: description
|
|
81
|
-
})]
|
|
82
|
-
}), children]
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
function CartesianChart({ props }) {
|
|
86
|
-
const series = props.series.filter(isCartesianSeries);
|
|
87
|
-
const RechartsChart = cartesianChartFor(series);
|
|
88
|
-
const { locale } = useLocale();
|
|
89
|
-
const { timezone } = useTimezone();
|
|
90
|
-
const ctx = {
|
|
91
|
-
locale,
|
|
92
|
-
timezone
|
|
93
|
-
};
|
|
94
|
-
const formatCategory = (value) => formatValue(value, props.categoryFormat, ctx);
|
|
95
|
-
const formatValueTick = (value) => formatValue(value, props.valueFormat, ctx);
|
|
96
|
-
const tooltipCursor = series.some((item) => item.type === "bar") ? {
|
|
97
|
-
fill: "var(--lt-muted-fg)",
|
|
98
|
-
fillOpacity: .15
|
|
99
|
-
} : {
|
|
100
|
-
stroke: "var(--lt-muted-fg)",
|
|
101
|
-
strokeOpacity: .4
|
|
102
|
-
};
|
|
103
|
-
return /* @__PURE__ */ jsx(ResponsiveContainer, {
|
|
104
|
-
width: "100%",
|
|
105
|
-
height: props.height,
|
|
106
|
-
debounce: 100,
|
|
107
|
-
children: /* @__PURE__ */ jsxs(RechartsChart, {
|
|
108
|
-
data: props.data,
|
|
109
|
-
margin: chartMargin,
|
|
110
|
-
children: [
|
|
111
|
-
props.grid && /* @__PURE__ */ jsx(CartesianGrid, {
|
|
112
|
-
strokeDasharray: "3 3",
|
|
113
|
-
stroke: "var(--lt-border)"
|
|
114
|
-
}),
|
|
115
|
-
props.xAxis && props.categoryKey !== null && /* @__PURE__ */ jsx(XAxis, {
|
|
116
|
-
dataKey: props.categoryKey,
|
|
117
|
-
stroke: "var(--lt-muted-fg)",
|
|
118
|
-
tick: axisTick,
|
|
119
|
-
tickFormatter: formatCategory,
|
|
120
|
-
tickLine: false
|
|
121
|
-
}),
|
|
122
|
-
props.yAxis && /* @__PURE__ */ jsx(YAxis, {
|
|
123
|
-
stroke: "var(--lt-muted-fg)",
|
|
124
|
-
tick: axisTick,
|
|
125
|
-
tickFormatter: formatValueTick,
|
|
126
|
-
tickLine: false,
|
|
127
|
-
width: 42
|
|
128
|
-
}),
|
|
129
|
-
props.tooltip && /* @__PURE__ */ jsx(Tooltip, {
|
|
130
|
-
...tooltipProps,
|
|
131
|
-
cursor: tooltipCursor,
|
|
132
|
-
formatter: formatValueTick,
|
|
133
|
-
labelFormatter: formatCategory
|
|
134
|
-
}),
|
|
135
|
-
props.legend && /* @__PURE__ */ jsx(Legend, { ...compactLegendProps }),
|
|
136
|
-
series.map((item, index) => {
|
|
137
|
-
const color = item.color ?? colorAt(index);
|
|
138
|
-
const key = `${item.type}:${item.dataKey}`;
|
|
139
|
-
if (item.type === "area") return /* @__PURE__ */ jsx(Area, {
|
|
140
|
-
dataKey: item.dataKey,
|
|
141
|
-
fill: color,
|
|
142
|
-
fillOpacity: .16,
|
|
143
|
-
name: item.name ?? void 0,
|
|
144
|
-
stackId: item.stackId ?? void 0,
|
|
145
|
-
stroke: color,
|
|
146
|
-
type: "monotone"
|
|
147
|
-
}, key);
|
|
148
|
-
if (item.type === "bar") return /* @__PURE__ */ jsx(Bar, {
|
|
149
|
-
dataKey: item.dataKey,
|
|
150
|
-
fill: color,
|
|
151
|
-
name: item.name ?? void 0,
|
|
152
|
-
radius: [
|
|
153
|
-
4,
|
|
154
|
-
4,
|
|
155
|
-
0,
|
|
156
|
-
0
|
|
157
|
-
],
|
|
158
|
-
stackId: item.stackId ?? void 0
|
|
159
|
-
}, key);
|
|
160
|
-
return /* @__PURE__ */ jsx(Line, {
|
|
161
|
-
dataKey: item.dataKey,
|
|
162
|
-
dot: false,
|
|
163
|
-
name: item.name ?? void 0,
|
|
164
|
-
stroke: color,
|
|
165
|
-
strokeWidth: 2,
|
|
166
|
-
type: "monotone"
|
|
167
|
-
}, key);
|
|
168
|
-
})
|
|
169
|
-
]
|
|
170
|
-
})
|
|
171
|
-
});
|
|
172
|
-
}
|
|
173
|
-
function PieChartView({ props, series }) {
|
|
174
|
-
const { locale } = useLocale();
|
|
175
|
-
const { timezone } = useTimezone();
|
|
176
|
-
const ctx = {
|
|
177
|
-
locale,
|
|
178
|
-
timezone
|
|
179
|
-
};
|
|
180
|
-
return /* @__PURE__ */ jsx(ResponsiveContainer, {
|
|
181
|
-
width: "100%",
|
|
182
|
-
height: props.height,
|
|
183
|
-
debounce: 100,
|
|
184
|
-
children: /* @__PURE__ */ jsxs(PieChart, {
|
|
185
|
-
margin: chartMargin,
|
|
186
|
-
children: [
|
|
187
|
-
props.tooltip && /* @__PURE__ */ jsx(Tooltip, {
|
|
188
|
-
...tooltipProps,
|
|
189
|
-
formatter: (value) => formatValue(value, props.valueFormat, ctx),
|
|
190
|
-
labelFormatter: (value) => formatValue(value, props.categoryFormat, ctx)
|
|
191
|
-
}),
|
|
192
|
-
props.legend && /* @__PURE__ */ jsx(Legend, { ...compactLegendProps }),
|
|
193
|
-
/* @__PURE__ */ jsx(Pie, {
|
|
194
|
-
data: props.data,
|
|
195
|
-
dataKey: series.dataKey,
|
|
196
|
-
name: series.name ?? void 0,
|
|
197
|
-
nameKey: series.nameKey ?? void 0,
|
|
198
|
-
outerRadius: "68%",
|
|
199
|
-
children: props.data.map((datum, index) => /* @__PURE__ */ jsx(Cell, { fill: datumColor(datum, series, index) }, index))
|
|
200
|
-
})
|
|
201
|
-
]
|
|
202
|
-
})
|
|
203
|
-
});
|
|
204
|
-
}
|
|
205
|
-
var ChartComponent = ({ node }) => {
|
|
206
|
-
const props = node.props;
|
|
207
|
-
const pieSeries = props.series.find((series) => series.type === "pie");
|
|
208
|
-
const hasCartesianSeries = props.series.some(isCartesianSeries);
|
|
209
|
-
return /* @__PURE__ */ jsx(ChartFrame, {
|
|
210
|
-
description: props.description,
|
|
211
|
-
id: nodeIdentity(node),
|
|
212
|
-
title: props.title,
|
|
213
|
-
children: /* @__PURE__ */ jsx("div", {
|
|
214
|
-
className: "min-h-0 w-full",
|
|
215
|
-
children: pieSeries && !hasCartesianSeries ? /* @__PURE__ */ jsx(PieChartView, {
|
|
216
|
-
props,
|
|
217
|
-
series: pieSeries
|
|
218
|
-
}) : /* @__PURE__ */ jsx(CartesianChart, { props })
|
|
219
|
-
})
|
|
220
|
-
});
|
|
221
|
-
};
|
|
4
|
+
var ChartView = lazy(() => import("./chart-view.js"));
|
|
5
|
+
var ChartComponent = ({ children, node }) => /* @__PURE__ */ jsx(Suspense, {
|
|
6
|
+
fallback: null,
|
|
7
|
+
children: /* @__PURE__ */ jsx(ChartView, {
|
|
8
|
+
node,
|
|
9
|
+
children
|
|
10
|
+
})
|
|
11
|
+
});
|
|
222
12
|
//#endregion
|
|
223
13
|
export { ChartComponent as default };
|
|
224
14
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chart.js","names":[],"sources":["../../../resources/js/core/components/chart.tsx"],"sourcesContent":["import {\n Area,\n AreaChart,\n Bar,\n BarChart,\n CartesianGrid,\n Cell,\n ComposedChart,\n Legend,\n Line,\n LineChart,\n Pie,\n PieChart,\n ResponsiveContainer,\n Tooltip,\n XAxis,\n YAxis,\n} from \"recharts\";\nimport type { ComponentType, ReactNode } from \"react\";\nimport { nodeIdentity } from \"@lattice-php/lattice/core/test-id\";\nimport type { PropsOf, RendererComponent } from \"@lattice-php/lattice/core/types\";\nimport { useLocale, useTimezone } from \"@lattice-php/lattice/i18n\";\nimport { formatValue } from \"../../format/value\";\n\ntype ChartProps = PropsOf<\"chart\">;\ntype ChartSeries = ChartProps[\"series\"][number];\ntype ChartDatum = ChartProps[\"data\"][number];\ntype CartesianSeries = ChartSeries & { type: \"area\" | \"bar\" | \"line\" };\ntype ChartMargin = { bottom: number; left: number; right: number; top: number };\ntype CartesianChartComponent = ComponentType<{\n children: ReactNode;\n data: ChartProps[\"data\"];\n margin?: ChartMargin;\n}>;\n\nconst chartMargin: ChartMargin = { bottom: 0, left: 0, right: 16, top: 8 };\nconst compactLegendProps = {\n align: \"center\" as const,\n height: 24,\n iconSize: 7,\n verticalAlign: \"top\" as const,\n wrapperStyle: { fontSize: 11, lineHeight: \"14px\", paddingBottom: 6 },\n};\nconst axisTick = { fontSize: 10 };\nconst tooltipProps = {\n contentStyle: {\n background: \"var(--lt-surface)\",\n border: \"1px solid var(--lt-border)\",\n borderRadius: \"var(--lt-radius-sm)\",\n boxShadow: \"var(--lt-shadow-sm)\",\n color: \"var(--lt-surface-fg)\",\n fontSize: 12,\n },\n itemStyle: { color: \"var(--lt-surface-fg)\" },\n labelStyle: { color: \"var(--lt-muted-fg)\" },\n} as const;\n\nconst palette = [\n \"var(--lt-primary)\",\n \"var(--lt-success)\",\n \"var(--lt-info)\",\n \"var(--lt-warning)\",\n \"var(--lt-danger)\",\n \"var(--lt-muted-fg)\",\n];\n\nfunction colorAt(index: number): string {\n return palette[index % palette.length] ?? \"var(--lt-primary)\";\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction datumColor(datum: ChartDatum, series: ChartSeries, index: number): string {\n if (isRecord(datum) && typeof datum.color === \"string\") {\n return datum.color;\n }\n\n return series.color ?? colorAt(index);\n}\n\nfunction isCartesianSeries(series: ChartSeries): series is CartesianSeries {\n return series.type === \"area\" || series.type === \"bar\" || series.type === \"line\";\n}\n\nfunction cartesianChartFor(series: CartesianSeries[]): CartesianChartComponent {\n const types = new Set(series.map((item) => item.type));\n const firstSeries = series[0];\n\n if (firstSeries === undefined || types.size !== 1) {\n return ComposedChart;\n }\n\n switch (firstSeries.type) {\n case \"area\":\n return AreaChart;\n case \"bar\":\n return BarChart;\n case \"line\":\n return LineChart;\n }\n}\n\nfunction ChartFrame({\n children,\n description,\n id,\n title,\n}: {\n children: ReactNode;\n description: string | null;\n id?: string;\n title: string | null;\n}) {\n const hasHeader = title !== null || description !== null;\n\n return (\n <div\n className=\"flex flex-col gap-3 rounded-lt border border-lt-border bg-lt-surface p-4 text-lt-surface-fg shadow-lt-sm\"\n data-lattice-component={id}\n >\n {hasHeader && (\n <div className=\"flex min-w-0 flex-col gap-1.5\">\n {title !== null && <div className=\"text-sm font-semibold leading-tight\">{title}</div>}\n {description !== null && (\n <div className=\"text-xs leading-5 text-lt-muted-fg\">{description}</div>\n )}\n </div>\n )}\n {children}\n </div>\n );\n}\n\nfunction CartesianChart({ props }: { props: ChartProps }) {\n const series = props.series.filter(isCartesianSeries);\n const RechartsChart = cartesianChartFor(series);\n const { locale } = useLocale();\n const { timezone } = useTimezone();\n const ctx = { locale, timezone };\n const formatCategory = (value: unknown) => formatValue(value, props.categoryFormat, ctx);\n const formatValueTick = (value: unknown) => formatValue(value, props.valueFormat, ctx);\n const hasBarSeries = series.some((item) => item.type === \"bar\");\n const tooltipCursor = hasBarSeries\n ? { fill: \"var(--lt-muted-fg)\", fillOpacity: 0.15 }\n : { stroke: \"var(--lt-muted-fg)\", strokeOpacity: 0.4 };\n\n return (\n <ResponsiveContainer width=\"100%\" height={props.height} debounce={100}>\n <RechartsChart data={props.data} margin={chartMargin}>\n {props.grid && <CartesianGrid strokeDasharray=\"3 3\" stroke=\"var(--lt-border)\" />}\n {props.xAxis && props.categoryKey !== null && (\n <XAxis\n dataKey={props.categoryKey}\n stroke=\"var(--lt-muted-fg)\"\n tick={axisTick}\n tickFormatter={formatCategory}\n tickLine={false}\n />\n )}\n {props.yAxis && (\n <YAxis\n stroke=\"var(--lt-muted-fg)\"\n tick={axisTick}\n tickFormatter={formatValueTick}\n tickLine={false}\n width={42}\n />\n )}\n {props.tooltip && (\n <Tooltip\n {...tooltipProps}\n cursor={tooltipCursor}\n formatter={formatValueTick}\n labelFormatter={formatCategory}\n />\n )}\n {props.legend && <Legend {...compactLegendProps} />}\n {series.map((item, index) => {\n const color = item.color ?? colorAt(index);\n const key = `${item.type}:${item.dataKey}`;\n\n if (item.type === \"area\") {\n return (\n <Area\n key={key}\n dataKey={item.dataKey}\n fill={color}\n fillOpacity={0.16}\n name={item.name ?? undefined}\n stackId={item.stackId ?? undefined}\n stroke={color}\n type=\"monotone\"\n />\n );\n }\n\n if (item.type === \"bar\") {\n return (\n <Bar\n key={key}\n dataKey={item.dataKey}\n fill={color}\n name={item.name ?? undefined}\n radius={[4, 4, 0, 0]}\n stackId={item.stackId ?? undefined}\n />\n );\n }\n\n return (\n <Line\n key={key}\n dataKey={item.dataKey}\n dot={false}\n name={item.name ?? undefined}\n stroke={color}\n strokeWidth={2}\n type=\"monotone\"\n />\n );\n })}\n </RechartsChart>\n </ResponsiveContainer>\n );\n}\n\nfunction PieChartView({ props, series }: { props: ChartProps; series: ChartSeries }) {\n const { locale } = useLocale();\n const { timezone } = useTimezone();\n const ctx = { locale, timezone };\n\n return (\n <ResponsiveContainer width=\"100%\" height={props.height} debounce={100}>\n <PieChart margin={chartMargin}>\n {props.tooltip && (\n <Tooltip\n {...tooltipProps}\n formatter={(value) => formatValue(value, props.valueFormat, ctx)}\n labelFormatter={(value) => formatValue(value, props.categoryFormat, ctx)}\n />\n )}\n {props.legend && <Legend {...compactLegendProps} />}\n <Pie\n data={props.data}\n dataKey={series.dataKey}\n name={series.name ?? undefined}\n nameKey={series.nameKey ?? undefined}\n outerRadius=\"68%\"\n >\n {props.data.map((datum, index) => (\n <Cell key={index} fill={datumColor(datum, series, index)} />\n ))}\n </Pie>\n </PieChart>\n </ResponsiveContainer>\n );\n}\n\nconst ChartComponent: RendererComponent<\"chart\"> = ({ node }) => {\n const props = node.props;\n const pieSeries = props.series.find((series) => series.type === \"pie\");\n const hasCartesianSeries = props.series.some(isCartesianSeries);\n\n return (\n <ChartFrame description={props.description} id={nodeIdentity(node)} title={props.title}>\n <div className=\"min-h-0 w-full\">\n {pieSeries && !hasCartesianSeries ? (\n <PieChartView props={props} series={pieSeries} />\n ) : (\n <CartesianChart props={props} />\n )}\n </div>\n </ChartFrame>\n );\n};\n\nexport default ChartComponent;\n"],"mappings":";;;;;;;AAmCA,IAAM,cAA2B;CAAE,QAAQ;CAAG,MAAM;CAAG,OAAO;CAAI,KAAK;AAAE;AACzE,IAAM,qBAAqB;CACzB,OAAO;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K,OAAO,UACtB,oBAAC,MAAD,EAAkB,MAAM,WAAW,OAAO,QAAQ,KAAK,EAAI,GAAhD,KAAgD,CAC5D;IACE,CAAA;GACG;;CACS,CAAA;AAEzB;AAEA,IAAM,kBAA8C,EAAE,WAAW;CAC/D,MAAM,QAAQ,KAAK;CACnB,MAAM,YAAY,MAAM,OAAO,MAAM,WAAW,OAAO,SAAS,KAAK;CACrE,MAAM,qBAAqB,MAAM,OAAO,KAAK,iBAAiB;CAE9D,OACE,oBAAC,YAAD;EAAY,aAAa,MAAM;EAAa,IAAI,aAAa,IAAI;EAAG,OAAO,MAAM;YAC/E,oBAAC,OAAD;GAAK,WAAU;aACZ,aAAa,CAAC,qBACb,oBAAC,cAAD;IAAqB;IAAO,QAAQ;GAAY,CAAA,IAEhD,oBAAC,gBAAD,EAAuB,MAAQ,CAAA;EAE9B,CAAA;CACK,CAAA;AAEhB"}
|
|
1
|
+
{"version":3,"file":"chart.js","names":[],"sources":["../../../resources/js/core/components/chart.tsx"],"sourcesContent":["import { lazy, Suspense } from \"react\";\nimport type { RendererComponent, RendererComponentModule } from \"@lattice-php/lattice/core/types\";\n\nconst ChartView = lazy(() => import(\"./chart-view\") as unknown as Promise<RendererComponentModule>);\n\nconst ChartComponent: RendererComponent<\"chart\"> = ({ children, node }) => (\n <Suspense fallback={null}>\n <ChartView node={node}>{children}</ChartView>\n </Suspense>\n);\n\nexport default ChartComponent;\n"],"mappings":";;;AAGA,IAAM,YAAY,WAAW,OAAO,kBAA8D;AAElG,IAAM,kBAA8C,EAAE,UAAU,WAC9D,oBAAC,UAAD;CAAU,UAAU;WAClB,oBAAC,WAAD;EAAiB;EAAO;CAAoB,CAAA;AACpC,CAAA"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { createPlugin, eagerComponent
|
|
1
|
+
import { createPlugin, eagerComponent } from "../registry.js";
|
|
2
2
|
import ButtonComponent from "./button.js";
|
|
3
3
|
import BadgeComponent from "./badge.js";
|
|
4
4
|
import CardComponent from "./card.js";
|
|
5
|
+
import ChartComponent from "./chart.js";
|
|
5
6
|
import CollapsibleComponent from "./collapsible.js";
|
|
6
7
|
import FloatingPanelComponent from "./floating-panel.js";
|
|
7
8
|
import FragmentComponent from "./fragment.js";
|
|
@@ -23,7 +24,7 @@ var coreComponents = createPlugin({
|
|
|
23
24
|
badge: eagerComponent(BadgeComponent),
|
|
24
25
|
button: eagerComponent(ButtonComponent),
|
|
25
26
|
card: eagerComponent(CardComponent),
|
|
26
|
-
chart:
|
|
27
|
+
chart: eagerComponent(ChartComponent),
|
|
27
28
|
collapsible: eagerComponent(CollapsibleComponent),
|
|
28
29
|
"floating-panel": eagerComponent(FloatingPanelComponent),
|
|
29
30
|
fragment: eagerComponent(FragmentComponent),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../resources/js/core/components/index.ts"],"sourcesContent":["import { createPlugin, eagerComponent
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../resources/js/core/components/index.ts"],"sourcesContent":["import { createPlugin, eagerComponent } from \"@lattice-php/lattice/core/registry\";\nimport BadgeComponent from \"./badge\";\nimport ButtonComponent from \"./button\";\nimport CardComponent from \"./card\";\nimport ChartComponent from \"./chart\";\nimport CollapsibleComponent from \"./collapsible\";\nimport FloatingPanelComponent from \"./floating-panel\";\nimport FragmentComponent from \"./fragment\";\nimport GridComponent from \"./grid\";\nimport HeadingComponent from \"./heading\";\nimport IconComponent from \"./icon\";\nimport LinkComponent from \"./link\";\nimport ModalComponent from \"./modal\";\nimport RawBlockComponent from \"./raw-block\";\nimport SectionComponent from \"./section\";\nimport SegmentedControlComponent from \"./segmented-control\";\nimport StackComponent from \"./stack\";\nimport TabComponent, { TabsComponent } from \"./tabs\";\nimport TextComponent from \"./text\";\nimport TooltipComponent from \"./tooltip\";\n\nexport const coreComponents = createPlugin({\n components: {\n badge: eagerComponent(BadgeComponent),\n button: eagerComponent(ButtonComponent),\n card: eagerComponent(CardComponent),\n chart: eagerComponent(ChartComponent),\n collapsible: eagerComponent(CollapsibleComponent),\n \"floating-panel\": eagerComponent(FloatingPanelComponent),\n fragment: eagerComponent(FragmentComponent),\n grid: eagerComponent(GridComponent),\n heading: eagerComponent(HeadingComponent),\n icon: eagerComponent(IconComponent),\n link: eagerComponent(LinkComponent),\n modal: eagerComponent(ModalComponent),\n \"raw-block\": eagerComponent(RawBlockComponent),\n section: eagerComponent(SectionComponent),\n \"segmented-control\": eagerComponent(SegmentedControlComponent),\n stack: eagerComponent(StackComponent),\n tab: eagerComponent(TabComponent),\n tabs: eagerComponent(TabsComponent),\n text: eagerComponent(TextComponent),\n tooltip: eagerComponent(TooltipComponent),\n },\n name: \"lattice/core\",\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAqBA,IAAa,iBAAiB,aAAa;CACzC,YAAY;EACV,OAAO,eAAe,cAAc;EACpC,QAAQ,eAAe,eAAe;EACtC,MAAM,eAAe,aAAa;EAClC,OAAO,eAAe,cAAc;EACpC,aAAa,eAAe,oBAAoB;EAChD,kBAAkB,eAAe,sBAAsB;EACvD,UAAU,eAAe,iBAAiB;EAC1C,MAAM,eAAe,aAAa;EAClC,SAAS,eAAe,gBAAgB;EACxC,MAAM,eAAe,aAAa;EAClC,MAAM,eAAe,aAAa;EAClC,OAAO,eAAe,cAAc;EACpC,aAAa,eAAe,iBAAiB;EAC7C,SAAS,eAAe,gBAAgB;EACxC,qBAAqB,eAAe,yBAAyB;EAC7D,OAAO,eAAe,cAAc;EACpC,KAAK,eAAe,YAAY;EAChC,MAAM,eAAe,aAAa;EAClC,MAAM,eAAe,aAAa;EAClC,SAAS,eAAe,gBAAgB;CAC1C;CACA,MAAM;AACR,CAAC"}
|
package/dist/core/renderer.js
CHANGED
|
@@ -1,10 +1,50 @@
|
|
|
1
1
|
import { useComponentRegistry } from "./registry-context.js";
|
|
2
2
|
import { useCollapsed } from "./collapsed-context.js";
|
|
3
3
|
import { Suspense } from "react";
|
|
4
|
-
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
5
|
//#region resources/js/core/renderer.tsx
|
|
6
|
+
function MissingComponentIcon() {
|
|
7
|
+
return /* @__PURE__ */ jsxs("svg", {
|
|
8
|
+
"aria-hidden": "true",
|
|
9
|
+
className: "size-lt-icon-md shrink-0",
|
|
10
|
+
fill: "none",
|
|
11
|
+
stroke: "currentColor",
|
|
12
|
+
strokeLinecap: "round",
|
|
13
|
+
strokeLinejoin: "round",
|
|
14
|
+
strokeWidth: "2",
|
|
15
|
+
viewBox: "0 0 24 24",
|
|
16
|
+
children: [
|
|
17
|
+
/* @__PURE__ */ jsx("rect", {
|
|
18
|
+
height: "18",
|
|
19
|
+
rx: "2",
|
|
20
|
+
strokeDasharray: "4 3",
|
|
21
|
+
width: "18",
|
|
22
|
+
x: "3",
|
|
23
|
+
y: "3"
|
|
24
|
+
}),
|
|
25
|
+
/* @__PURE__ */ jsx("path", { d: "M12 8v4" }),
|
|
26
|
+
/* @__PURE__ */ jsx("path", { d: "M12 16h.01" })
|
|
27
|
+
]
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Fallback for a node whose type has no registered renderer. Always renders a
|
|
32
|
+
* visible, muted marker — icon-only survives tight spots like table cells — so
|
|
33
|
+
* the gap is never invisible. Shows the type inline in development; keeps it
|
|
34
|
+
* screen-reader-only (plus a hover tooltip) in production.
|
|
35
|
+
*/
|
|
6
36
|
function MissingComponent({ node }) {
|
|
7
|
-
|
|
37
|
+
node.type;
|
|
38
|
+
const label = `Missing component: ${node.type}`;
|
|
39
|
+
return /* @__PURE__ */ jsxs("span", {
|
|
40
|
+
className: "inline-flex items-center gap-1.5 align-middle text-lt-muted-fg",
|
|
41
|
+
"data-lattice-missing-component": node.type,
|
|
42
|
+
title: label,
|
|
43
|
+
children: [/* @__PURE__ */ jsx(MissingComponentIcon, {}), /* @__PURE__ */ jsx("span", {
|
|
44
|
+
className: "sr-only",
|
|
45
|
+
children: label
|
|
46
|
+
})]
|
|
47
|
+
});
|
|
8
48
|
}
|
|
9
49
|
function nodeKey(node, index) {
|
|
10
50
|
return node.key ?? node.id ?? `${node.type}-${index}`;
|