@x-plat/design-system 0.5.2 → 0.5.4
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/components/Accordion/index.cjs +38 -31
- package/dist/components/Accordion/index.css +2 -0
- package/dist/components/Accordion/index.js +38 -31
- package/dist/components/Alert/index.css +1 -0
- package/dist/components/Breadcrumb/index.css +3 -0
- package/dist/components/Button/index.css +1 -0
- package/dist/components/Calendar/index.cjs +103 -62
- package/dist/components/Calendar/index.css +2 -0
- package/dist/components/Calendar/index.js +103 -62
- package/dist/components/Card/index.css +3 -1
- package/dist/components/CardTab/index.css +1 -0
- package/dist/components/Chart/index.cjs +106 -83
- package/dist/components/Chart/index.css +2 -0
- package/dist/components/Chart/index.js +106 -83
- package/dist/components/DatePicker/index.cjs +36 -15
- package/dist/components/DatePicker/index.css +2 -0
- package/dist/components/DatePicker/index.js +36 -15
- package/dist/components/Dropdown/index.css +1 -0
- package/dist/components/EmptyState/index.css +2 -0
- package/dist/components/FileUpload/index.css +3 -0
- package/dist/components/HtmlTypeWriter/index.css +1 -0
- package/dist/components/Pagination/index.css +8 -8
- package/dist/components/Select/index.css +1 -0
- package/dist/components/Spinner/index.css +7 -2
- package/dist/components/Steps/index.cjs +1 -4
- package/dist/components/Steps/index.css +15 -36
- package/dist/components/Steps/index.js +1 -4
- package/dist/components/Swiper/index.cjs +16 -12
- package/dist/components/Swiper/index.css +2 -0
- package/dist/components/Swiper/index.js +16 -12
- package/dist/components/Switch/index.css +20 -19
- package/dist/components/Tab/index.css +16 -2
- package/dist/components/Table/index.cjs +4 -4
- package/dist/components/Table/index.css +2 -0
- package/dist/components/Table/index.d.cts +2 -5
- package/dist/components/Table/index.d.ts +2 -5
- package/dist/components/Table/index.js +4 -4
- package/dist/components/Video/index.cjs +32 -43
- package/dist/components/Video/index.css +5 -4
- package/dist/components/Video/index.d.cts +1 -5
- package/dist/components/Video/index.d.ts +1 -5
- package/dist/components/Video/index.js +32 -43
- package/dist/components/index.cjs +339 -257
- package/dist/components/index.css +99 -72
- package/dist/components/index.js +339 -257
- package/dist/index.cjs +339 -257
- package/dist/index.css +99 -72
- package/dist/index.js +339 -257
- package/guidelines/Guidelines.md +11 -4
- package/package.json +1 -2
|
@@ -90,14 +90,28 @@ var useChartTooltip = (enabled) => {
|
|
|
90
90
|
}, []);
|
|
91
91
|
return { tooltip, show, hide, move, containerRef };
|
|
92
92
|
};
|
|
93
|
-
var LineChart = ({ data, labels, onHover, onMove, onLeave }) => {
|
|
94
|
-
const entries = Object.entries(data);
|
|
95
|
-
const
|
|
96
|
-
|
|
93
|
+
var LineChart = import_react.default.memo(({ data, labels, onHover, onMove, onLeave }) => {
|
|
94
|
+
const entries = import_react.default.useMemo(() => Object.entries(data), [data]);
|
|
95
|
+
const maxVal = import_react.default.useMemo(() => {
|
|
96
|
+
const allValues = entries.flatMap(([, v]) => v);
|
|
97
|
+
return Math.max(...allValues) * 1.2 || 1;
|
|
98
|
+
}, [entries]);
|
|
97
99
|
const count = labels.length;
|
|
100
|
+
const chartW = 600 - PADDING.left - PADDING.right;
|
|
101
|
+
const chartH = 300 - PADDING.top - PADDING.bottom;
|
|
102
|
+
const seriesPoints = import_react.default.useMemo(
|
|
103
|
+
() => entries.map(
|
|
104
|
+
([, values]) => values.map((v, i) => ({
|
|
105
|
+
x: PADDING.left + i / (count - 1 || 1) * chartW,
|
|
106
|
+
y: PADDING.top + (1 - v / maxVal) * chartH,
|
|
107
|
+
v
|
|
108
|
+
}))
|
|
109
|
+
),
|
|
110
|
+
[entries, count, chartW, chartH, maxVal]
|
|
111
|
+
);
|
|
98
112
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("svg", { viewBox: "0 0 600 300", className: "chart-svg", children: [
|
|
99
113
|
[0, 0.25, 0.5, 0.75, 1].map((ratio) => {
|
|
100
|
-
const y = PADDING.top + (1 - ratio) *
|
|
114
|
+
const y = PADDING.top + (1 - ratio) * chartH;
|
|
101
115
|
const val = Math.round(maxVal * ratio);
|
|
102
116
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("g", { children: [
|
|
103
117
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("line", { x1: PADDING.left, y1: y, x2: 600 - PADDING.right, y2: y, className: "chart-grid" }),
|
|
@@ -105,17 +119,13 @@ var LineChart = ({ data, labels, onHover, onMove, onLeave }) => {
|
|
|
105
119
|
] }, ratio);
|
|
106
120
|
}),
|
|
107
121
|
labels.map((label, i) => {
|
|
108
|
-
const x = PADDING.left + i / (count - 1 || 1) *
|
|
122
|
+
const x = PADDING.left + i / (count - 1 || 1) * chartW;
|
|
109
123
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("text", { x, y: 300 - 8, className: "chart-axis-label", textAnchor: "middle", children: label }, i);
|
|
110
124
|
}),
|
|
111
|
-
entries.map(([key
|
|
125
|
+
entries.map(([key], di) => {
|
|
112
126
|
const palette = getPalette(LINE_BAR_PALETTES, di);
|
|
113
127
|
const color = palette[4];
|
|
114
|
-
const points =
|
|
115
|
-
const x = PADDING.left + i / (count - 1 || 1) * (600 - PADDING.left - PADDING.right);
|
|
116
|
-
const y = PADDING.top + (1 - v / maxVal) * (300 - PADDING.top - PADDING.bottom);
|
|
117
|
-
return { x, y, v };
|
|
118
|
-
});
|
|
128
|
+
const points = seriesPoints[di];
|
|
119
129
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("g", { children: [
|
|
120
130
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
121
131
|
"polyline",
|
|
@@ -143,17 +153,31 @@ var LineChart = ({ data, labels, onHover, onMove, onLeave }) => {
|
|
|
143
153
|
] }, di);
|
|
144
154
|
})
|
|
145
155
|
] });
|
|
146
|
-
};
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
const
|
|
150
|
-
const maxVal =
|
|
156
|
+
});
|
|
157
|
+
LineChart.displayName = "LineChart";
|
|
158
|
+
var BarChart = import_react.default.memo(({ data, labels, onHover, onMove, onLeave }) => {
|
|
159
|
+
const entries = import_react.default.useMemo(() => Object.entries(data), [data]);
|
|
160
|
+
const maxVal = import_react.default.useMemo(() => {
|
|
161
|
+
const allValues = entries.flatMap(([, v]) => v);
|
|
162
|
+
return Math.max(...allValues) * 1.2 || 1;
|
|
163
|
+
}, [entries]);
|
|
151
164
|
const count = labels.length;
|
|
152
165
|
const groupCount = entries.length;
|
|
153
166
|
const chartW = 600 - PADDING.left - PADDING.right;
|
|
154
167
|
const chartH = 300 - PADDING.top - PADDING.bottom;
|
|
155
168
|
const groupW = chartW / count;
|
|
156
169
|
const barW = Math.min(32, groupW * 0.7 / groupCount);
|
|
170
|
+
const bars = import_react.default.useMemo(
|
|
171
|
+
() => entries.map(
|
|
172
|
+
([, values], di) => values.map((v, i) => {
|
|
173
|
+
const h = v / maxVal * chartH;
|
|
174
|
+
const x = PADDING.left + groupW * i + (groupW - barW * groupCount) / 2 + barW * di;
|
|
175
|
+
const y = PADDING.top + chartH - h;
|
|
176
|
+
return { x, y, w: barW, h, v };
|
|
177
|
+
})
|
|
178
|
+
),
|
|
179
|
+
[entries, maxVal, chartH, groupW, barW, groupCount]
|
|
180
|
+
);
|
|
157
181
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("svg", { viewBox: "0 0 600 300", className: "chart-svg", children: [
|
|
158
182
|
[0, 0.25, 0.5, 0.75, 1].map((ratio) => {
|
|
159
183
|
const y = PADDING.top + (1 - ratio) * chartH;
|
|
@@ -164,85 +188,84 @@ var BarChart = ({ data, labels, onHover, onMove, onLeave }) => {
|
|
|
164
188
|
] }, ratio);
|
|
165
189
|
}),
|
|
166
190
|
labels.map((label, i) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("text", { x: PADDING.left + groupW * i + groupW / 2, y: 300 - 8, className: "chart-axis-label", textAnchor: "middle", children: label }, i)),
|
|
167
|
-
entries.map(([key
|
|
191
|
+
entries.map(([key], di) => {
|
|
168
192
|
const palette = getPalette(LINE_BAR_PALETTES, di);
|
|
169
193
|
const color = palette[4];
|
|
170
|
-
return
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
onMouseLeave: onLeave
|
|
187
|
-
},
|
|
188
|
-
`${di}-${i}`
|
|
189
|
-
);
|
|
190
|
-
});
|
|
194
|
+
return bars[di].map((b, i) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
195
|
+
"rect",
|
|
196
|
+
{
|
|
197
|
+
x: b.x,
|
|
198
|
+
y: b.y,
|
|
199
|
+
width: b.w,
|
|
200
|
+
height: b.h,
|
|
201
|
+
rx: "2",
|
|
202
|
+
fill: color,
|
|
203
|
+
className: "chart-bar",
|
|
204
|
+
onMouseEnter: (e) => onHover(e, `${key}: ${labels[i]} \u2014 ${b.v}`),
|
|
205
|
+
onMouseMove: onMove,
|
|
206
|
+
onMouseLeave: onLeave
|
|
207
|
+
},
|
|
208
|
+
`${di}-${i}`
|
|
209
|
+
));
|
|
191
210
|
})
|
|
192
211
|
] });
|
|
193
|
-
};
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
212
|
+
});
|
|
213
|
+
BarChart.displayName = "BarChart";
|
|
214
|
+
var PieDonutChart = import_react.default.memo(
|
|
215
|
+
({ data, labels, isDoughnut, onHover, onMove, onLeave }) => {
|
|
216
|
+
const values = import_react.default.useMemo(() => Object.entries(data).flatMap(([, v]) => v), [data]);
|
|
217
|
+
const total = import_react.default.useMemo(() => values.reduce((a, b) => a + b, 0) || 1, [values]);
|
|
218
|
+
const cx = 150;
|
|
219
|
+
const cy = 150;
|
|
220
|
+
const r = 120;
|
|
221
|
+
const innerR = isDoughnut ? 60 : 0;
|
|
222
|
+
const palette = getPalette(PIE_PALETTES, 0);
|
|
223
|
+
const sliceData = import_react.default.useMemo(() => {
|
|
224
|
+
let angle0 = -Math.PI / 2;
|
|
225
|
+
return values.map((v, i) => {
|
|
226
|
+
const angle = v / total * Math.PI * 2;
|
|
227
|
+
const endAngle = angle0 + angle;
|
|
228
|
+
const largeArc = angle > Math.PI ? 1 : 0;
|
|
229
|
+
const x1 = cx + r * Math.cos(angle0);
|
|
230
|
+
const y1 = cy + r * Math.sin(angle0);
|
|
231
|
+
const x2 = cx + r * Math.cos(endAngle);
|
|
232
|
+
const y2 = cy + r * Math.sin(endAngle);
|
|
233
|
+
let d;
|
|
234
|
+
if (innerR > 0) {
|
|
235
|
+
const ix1 = cx + innerR * Math.cos(angle0);
|
|
236
|
+
const iy1 = cy + innerR * Math.sin(angle0);
|
|
237
|
+
const ix2 = cx + innerR * Math.cos(endAngle);
|
|
238
|
+
const iy2 = cy + innerR * Math.sin(endAngle);
|
|
239
|
+
d = `M ${ix1} ${iy1} L ${x1} ${y1} A ${r} ${r} 0 ${largeArc} 1 ${x2} ${y2} L ${ix2} ${iy2} A ${innerR} ${innerR} 0 ${largeArc} 0 ${ix1} ${iy1} Z`;
|
|
240
|
+
} else {
|
|
241
|
+
d = `M ${cx} ${cy} L ${x1} ${y1} A ${r} ${r} 0 ${largeArc} 1 ${x2} ${y2} Z`;
|
|
242
|
+
}
|
|
243
|
+
const midAngle = angle0 + angle / 2;
|
|
244
|
+
const labelR = innerR > 0 ? (r + innerR) / 2 : r * 0.6;
|
|
245
|
+
const lx = cx + labelR * Math.cos(midAngle);
|
|
246
|
+
const ly = cy + labelR * Math.sin(midAngle);
|
|
247
|
+
const pct = Math.round(v / total * 100);
|
|
248
|
+
angle0 = endAngle;
|
|
249
|
+
return { d, lx, ly, v, pct, angle, label: labels[i] || `${i + 1}` };
|
|
250
|
+
});
|
|
251
|
+
}, [values, total, innerR, labels]);
|
|
252
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("svg", { viewBox: "0 0 300 300", className: "chart-svg chart-pie", children: sliceData.map((s, i) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("g", { children: [
|
|
230
253
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
231
254
|
"path",
|
|
232
255
|
{
|
|
233
|
-
d,
|
|
256
|
+
d: s.d,
|
|
234
257
|
fill: palette[i % palette.length],
|
|
235
258
|
className: "chart-slice",
|
|
236
|
-
onMouseEnter: (e) => onHover(e, `${label}: ${v} (${pct}%)`),
|
|
259
|
+
onMouseEnter: (e) => onHover(e, `${s.label}: ${s.v} (${s.pct}%)`),
|
|
237
260
|
onMouseMove: onMove,
|
|
238
261
|
onMouseLeave: onLeave
|
|
239
262
|
}
|
|
240
263
|
),
|
|
241
|
-
angle > 0.2 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("text", { x: lx, y: ly, className: "chart-pie-label", textAnchor: "middle", dominantBaseline: "central", children: v })
|
|
242
|
-
] }, i);
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
|
|
264
|
+
s.angle > 0.2 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("text", { x: s.lx, y: s.ly, className: "chart-pie-label", textAnchor: "middle", dominantBaseline: "central", children: s.v })
|
|
265
|
+
] }, i)) });
|
|
266
|
+
}
|
|
267
|
+
);
|
|
268
|
+
PieDonutChart.displayName = "PieDonutChart";
|
|
246
269
|
var Chart = (props) => {
|
|
247
270
|
const { type, data, labels, tooltip: showTooltip = true } = props;
|
|
248
271
|
const { tooltip, show, hide, move, containerRef } = useChartTooltip(showTooltip);
|
|
@@ -54,14 +54,28 @@ var useChartTooltip = (enabled) => {
|
|
|
54
54
|
}, []);
|
|
55
55
|
return { tooltip, show, hide, move, containerRef };
|
|
56
56
|
};
|
|
57
|
-
var LineChart = ({ data, labels, onHover, onMove, onLeave }) => {
|
|
58
|
-
const entries = Object.entries(data);
|
|
59
|
-
const
|
|
60
|
-
|
|
57
|
+
var LineChart = React.memo(({ data, labels, onHover, onMove, onLeave }) => {
|
|
58
|
+
const entries = React.useMemo(() => Object.entries(data), [data]);
|
|
59
|
+
const maxVal = React.useMemo(() => {
|
|
60
|
+
const allValues = entries.flatMap(([, v]) => v);
|
|
61
|
+
return Math.max(...allValues) * 1.2 || 1;
|
|
62
|
+
}, [entries]);
|
|
61
63
|
const count = labels.length;
|
|
64
|
+
const chartW = 600 - PADDING.left - PADDING.right;
|
|
65
|
+
const chartH = 300 - PADDING.top - PADDING.bottom;
|
|
66
|
+
const seriesPoints = React.useMemo(
|
|
67
|
+
() => entries.map(
|
|
68
|
+
([, values]) => values.map((v, i) => ({
|
|
69
|
+
x: PADDING.left + i / (count - 1 || 1) * chartW,
|
|
70
|
+
y: PADDING.top + (1 - v / maxVal) * chartH,
|
|
71
|
+
v
|
|
72
|
+
}))
|
|
73
|
+
),
|
|
74
|
+
[entries, count, chartW, chartH, maxVal]
|
|
75
|
+
);
|
|
62
76
|
return /* @__PURE__ */ jsxs("svg", { viewBox: "0 0 600 300", className: "chart-svg", children: [
|
|
63
77
|
[0, 0.25, 0.5, 0.75, 1].map((ratio) => {
|
|
64
|
-
const y = PADDING.top + (1 - ratio) *
|
|
78
|
+
const y = PADDING.top + (1 - ratio) * chartH;
|
|
65
79
|
const val = Math.round(maxVal * ratio);
|
|
66
80
|
return /* @__PURE__ */ jsxs("g", { children: [
|
|
67
81
|
/* @__PURE__ */ jsx("line", { x1: PADDING.left, y1: y, x2: 600 - PADDING.right, y2: y, className: "chart-grid" }),
|
|
@@ -69,17 +83,13 @@ var LineChart = ({ data, labels, onHover, onMove, onLeave }) => {
|
|
|
69
83
|
] }, ratio);
|
|
70
84
|
}),
|
|
71
85
|
labels.map((label, i) => {
|
|
72
|
-
const x = PADDING.left + i / (count - 1 || 1) *
|
|
86
|
+
const x = PADDING.left + i / (count - 1 || 1) * chartW;
|
|
73
87
|
return /* @__PURE__ */ jsx("text", { x, y: 300 - 8, className: "chart-axis-label", textAnchor: "middle", children: label }, i);
|
|
74
88
|
}),
|
|
75
|
-
entries.map(([key
|
|
89
|
+
entries.map(([key], di) => {
|
|
76
90
|
const palette = getPalette(LINE_BAR_PALETTES, di);
|
|
77
91
|
const color = palette[4];
|
|
78
|
-
const points =
|
|
79
|
-
const x = PADDING.left + i / (count - 1 || 1) * (600 - PADDING.left - PADDING.right);
|
|
80
|
-
const y = PADDING.top + (1 - v / maxVal) * (300 - PADDING.top - PADDING.bottom);
|
|
81
|
-
return { x, y, v };
|
|
82
|
-
});
|
|
92
|
+
const points = seriesPoints[di];
|
|
83
93
|
return /* @__PURE__ */ jsxs("g", { children: [
|
|
84
94
|
/* @__PURE__ */ jsx(
|
|
85
95
|
"polyline",
|
|
@@ -107,17 +117,31 @@ var LineChart = ({ data, labels, onHover, onMove, onLeave }) => {
|
|
|
107
117
|
] }, di);
|
|
108
118
|
})
|
|
109
119
|
] });
|
|
110
|
-
};
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
const
|
|
114
|
-
const maxVal =
|
|
120
|
+
});
|
|
121
|
+
LineChart.displayName = "LineChart";
|
|
122
|
+
var BarChart = React.memo(({ data, labels, onHover, onMove, onLeave }) => {
|
|
123
|
+
const entries = React.useMemo(() => Object.entries(data), [data]);
|
|
124
|
+
const maxVal = React.useMemo(() => {
|
|
125
|
+
const allValues = entries.flatMap(([, v]) => v);
|
|
126
|
+
return Math.max(...allValues) * 1.2 || 1;
|
|
127
|
+
}, [entries]);
|
|
115
128
|
const count = labels.length;
|
|
116
129
|
const groupCount = entries.length;
|
|
117
130
|
const chartW = 600 - PADDING.left - PADDING.right;
|
|
118
131
|
const chartH = 300 - PADDING.top - PADDING.bottom;
|
|
119
132
|
const groupW = chartW / count;
|
|
120
133
|
const barW = Math.min(32, groupW * 0.7 / groupCount);
|
|
134
|
+
const bars = React.useMemo(
|
|
135
|
+
() => entries.map(
|
|
136
|
+
([, values], di) => values.map((v, i) => {
|
|
137
|
+
const h = v / maxVal * chartH;
|
|
138
|
+
const x = PADDING.left + groupW * i + (groupW - barW * groupCount) / 2 + barW * di;
|
|
139
|
+
const y = PADDING.top + chartH - h;
|
|
140
|
+
return { x, y, w: barW, h, v };
|
|
141
|
+
})
|
|
142
|
+
),
|
|
143
|
+
[entries, maxVal, chartH, groupW, barW, groupCount]
|
|
144
|
+
);
|
|
121
145
|
return /* @__PURE__ */ jsxs("svg", { viewBox: "0 0 600 300", className: "chart-svg", children: [
|
|
122
146
|
[0, 0.25, 0.5, 0.75, 1].map((ratio) => {
|
|
123
147
|
const y = PADDING.top + (1 - ratio) * chartH;
|
|
@@ -128,85 +152,84 @@ var BarChart = ({ data, labels, onHover, onMove, onLeave }) => {
|
|
|
128
152
|
] }, ratio);
|
|
129
153
|
}),
|
|
130
154
|
labels.map((label, i) => /* @__PURE__ */ jsx("text", { x: PADDING.left + groupW * i + groupW / 2, y: 300 - 8, className: "chart-axis-label", textAnchor: "middle", children: label }, i)),
|
|
131
|
-
entries.map(([key
|
|
155
|
+
entries.map(([key], di) => {
|
|
132
156
|
const palette = getPalette(LINE_BAR_PALETTES, di);
|
|
133
157
|
const color = palette[4];
|
|
134
|
-
return
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
onMouseLeave: onLeave
|
|
151
|
-
},
|
|
152
|
-
`${di}-${i}`
|
|
153
|
-
);
|
|
154
|
-
});
|
|
158
|
+
return bars[di].map((b, i) => /* @__PURE__ */ jsx(
|
|
159
|
+
"rect",
|
|
160
|
+
{
|
|
161
|
+
x: b.x,
|
|
162
|
+
y: b.y,
|
|
163
|
+
width: b.w,
|
|
164
|
+
height: b.h,
|
|
165
|
+
rx: "2",
|
|
166
|
+
fill: color,
|
|
167
|
+
className: "chart-bar",
|
|
168
|
+
onMouseEnter: (e) => onHover(e, `${key}: ${labels[i]} \u2014 ${b.v}`),
|
|
169
|
+
onMouseMove: onMove,
|
|
170
|
+
onMouseLeave: onLeave
|
|
171
|
+
},
|
|
172
|
+
`${di}-${i}`
|
|
173
|
+
));
|
|
155
174
|
})
|
|
156
175
|
] });
|
|
157
|
-
};
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
176
|
+
});
|
|
177
|
+
BarChart.displayName = "BarChart";
|
|
178
|
+
var PieDonutChart = React.memo(
|
|
179
|
+
({ data, labels, isDoughnut, onHover, onMove, onLeave }) => {
|
|
180
|
+
const values = React.useMemo(() => Object.entries(data).flatMap(([, v]) => v), [data]);
|
|
181
|
+
const total = React.useMemo(() => values.reduce((a, b) => a + b, 0) || 1, [values]);
|
|
182
|
+
const cx = 150;
|
|
183
|
+
const cy = 150;
|
|
184
|
+
const r = 120;
|
|
185
|
+
const innerR = isDoughnut ? 60 : 0;
|
|
186
|
+
const palette = getPalette(PIE_PALETTES, 0);
|
|
187
|
+
const sliceData = React.useMemo(() => {
|
|
188
|
+
let angle0 = -Math.PI / 2;
|
|
189
|
+
return values.map((v, i) => {
|
|
190
|
+
const angle = v / total * Math.PI * 2;
|
|
191
|
+
const endAngle = angle0 + angle;
|
|
192
|
+
const largeArc = angle > Math.PI ? 1 : 0;
|
|
193
|
+
const x1 = cx + r * Math.cos(angle0);
|
|
194
|
+
const y1 = cy + r * Math.sin(angle0);
|
|
195
|
+
const x2 = cx + r * Math.cos(endAngle);
|
|
196
|
+
const y2 = cy + r * Math.sin(endAngle);
|
|
197
|
+
let d;
|
|
198
|
+
if (innerR > 0) {
|
|
199
|
+
const ix1 = cx + innerR * Math.cos(angle0);
|
|
200
|
+
const iy1 = cy + innerR * Math.sin(angle0);
|
|
201
|
+
const ix2 = cx + innerR * Math.cos(endAngle);
|
|
202
|
+
const iy2 = cy + innerR * Math.sin(endAngle);
|
|
203
|
+
d = `M ${ix1} ${iy1} L ${x1} ${y1} A ${r} ${r} 0 ${largeArc} 1 ${x2} ${y2} L ${ix2} ${iy2} A ${innerR} ${innerR} 0 ${largeArc} 0 ${ix1} ${iy1} Z`;
|
|
204
|
+
} else {
|
|
205
|
+
d = `M ${cx} ${cy} L ${x1} ${y1} A ${r} ${r} 0 ${largeArc} 1 ${x2} ${y2} Z`;
|
|
206
|
+
}
|
|
207
|
+
const midAngle = angle0 + angle / 2;
|
|
208
|
+
const labelR = innerR > 0 ? (r + innerR) / 2 : r * 0.6;
|
|
209
|
+
const lx = cx + labelR * Math.cos(midAngle);
|
|
210
|
+
const ly = cy + labelR * Math.sin(midAngle);
|
|
211
|
+
const pct = Math.round(v / total * 100);
|
|
212
|
+
angle0 = endAngle;
|
|
213
|
+
return { d, lx, ly, v, pct, angle, label: labels[i] || `${i + 1}` };
|
|
214
|
+
});
|
|
215
|
+
}, [values, total, innerR, labels]);
|
|
216
|
+
return /* @__PURE__ */ jsx("svg", { viewBox: "0 0 300 300", className: "chart-svg chart-pie", children: sliceData.map((s, i) => /* @__PURE__ */ jsxs("g", { children: [
|
|
194
217
|
/* @__PURE__ */ jsx(
|
|
195
218
|
"path",
|
|
196
219
|
{
|
|
197
|
-
d,
|
|
220
|
+
d: s.d,
|
|
198
221
|
fill: palette[i % palette.length],
|
|
199
222
|
className: "chart-slice",
|
|
200
|
-
onMouseEnter: (e) => onHover(e, `${label}: ${v} (${pct}%)`),
|
|
223
|
+
onMouseEnter: (e) => onHover(e, `${s.label}: ${s.v} (${s.pct}%)`),
|
|
201
224
|
onMouseMove: onMove,
|
|
202
225
|
onMouseLeave: onLeave
|
|
203
226
|
}
|
|
204
227
|
),
|
|
205
|
-
angle > 0.2 && /* @__PURE__ */ jsx("text", { x: lx, y: ly, className: "chart-pie-label", textAnchor: "middle", dominantBaseline: "central", children: v })
|
|
206
|
-
] }, i);
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
|
|
228
|
+
s.angle > 0.2 && /* @__PURE__ */ jsx("text", { x: s.lx, y: s.ly, className: "chart-pie-label", textAnchor: "middle", dominantBaseline: "central", children: s.v })
|
|
229
|
+
] }, i)) });
|
|
230
|
+
}
|
|
231
|
+
);
|
|
232
|
+
PieDonutChart.displayName = "PieDonutChart";
|
|
210
233
|
var Chart = (props) => {
|
|
211
234
|
const { type, data, labels, tooltip: showTooltip = true } = props;
|
|
212
235
|
const { tooltip, show, hide, move, containerRef } = useChartTooltip(showTooltip);
|
|
@@ -1740,6 +1740,35 @@ var Modal_default = Modal;
|
|
|
1740
1740
|
// src/components/DatePicker/RangePicker/index.tsx
|
|
1741
1741
|
var import_react9 = __toESM(require("react"), 1);
|
|
1742
1742
|
var import_jsx_runtime302 = require("react/jsx-runtime");
|
|
1743
|
+
var RangeDayCell = import_react9.default.memo(
|
|
1744
|
+
({
|
|
1745
|
+
day,
|
|
1746
|
+
disabled,
|
|
1747
|
+
isStart,
|
|
1748
|
+
isEnd,
|
|
1749
|
+
inRange,
|
|
1750
|
+
onClick
|
|
1751
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime302.jsx)(
|
|
1752
|
+
"button",
|
|
1753
|
+
{
|
|
1754
|
+
type: "button",
|
|
1755
|
+
className: clsx_default(
|
|
1756
|
+
"datepicker-day",
|
|
1757
|
+
!day.isCurrentMonth && "outside",
|
|
1758
|
+
disabled && "disabled",
|
|
1759
|
+
(isStart || isEnd) && "selected",
|
|
1760
|
+
inRange && !isStart && !isEnd && "in-range",
|
|
1761
|
+
day.isToday && "today",
|
|
1762
|
+
day.isSunday && "sunday",
|
|
1763
|
+
day.isSaturday && "saturday"
|
|
1764
|
+
),
|
|
1765
|
+
disabled: disabled || !day.isCurrentMonth,
|
|
1766
|
+
onClick,
|
|
1767
|
+
children: day.day
|
|
1768
|
+
}
|
|
1769
|
+
)
|
|
1770
|
+
);
|
|
1771
|
+
RangeDayCell.displayName = "RangeDayCell";
|
|
1743
1772
|
var RangePicker = (props) => {
|
|
1744
1773
|
const {
|
|
1745
1774
|
startDate,
|
|
@@ -1816,20 +1845,13 @@ var RangePicker = (props) => {
|
|
|
1816
1845
|
const isEnd = isSameDay(day.date, endDate);
|
|
1817
1846
|
const inRange = isInRange(day.date, startDate, endDate);
|
|
1818
1847
|
return /* @__PURE__ */ (0, import_jsx_runtime302.jsx)(
|
|
1819
|
-
|
|
1848
|
+
RangeDayCell,
|
|
1820
1849
|
{
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
(isStart || isEnd) && "selected",
|
|
1827
|
-
inRange && !isStart && !isEnd && "in-range",
|
|
1828
|
-
day.isToday && "today",
|
|
1829
|
-
day.isSunday && "sunday",
|
|
1830
|
-
day.isSaturday && "saturday"
|
|
1831
|
-
),
|
|
1832
|
-
disabled: disabled || !day.isCurrentMonth,
|
|
1850
|
+
day,
|
|
1851
|
+
disabled,
|
|
1852
|
+
isStart,
|
|
1853
|
+
isEnd,
|
|
1854
|
+
inRange,
|
|
1833
1855
|
onClick: () => {
|
|
1834
1856
|
if (!disabled && day.isCurrentMonth) {
|
|
1835
1857
|
if (type === "start") {
|
|
@@ -1840,8 +1862,7 @@ var RangePicker = (props) => {
|
|
|
1840
1862
|
onChange?.({ startDate, endDate: newEnd });
|
|
1841
1863
|
}
|
|
1842
1864
|
}
|
|
1843
|
-
}
|
|
1844
|
-
children: day.day
|
|
1865
|
+
}
|
|
1845
1866
|
},
|
|
1846
1867
|
idx
|
|
1847
1868
|
);
|
|
@@ -97,6 +97,7 @@
|
|
|
97
97
|
|
|
98
98
|
/* src/components/DatePicker/datepicker.scss */
|
|
99
99
|
.lib-xplat-datepicker {
|
|
100
|
+
contain: content;
|
|
100
101
|
user-select: none;
|
|
101
102
|
min-width: 200px;
|
|
102
103
|
width: 100%;
|
|
@@ -346,6 +347,7 @@
|
|
|
346
347
|
|
|
347
348
|
/* src/components/Button/button.scss */
|
|
348
349
|
.lib-xplat-button {
|
|
350
|
+
width: 100%;
|
|
349
351
|
border-radius: var(--spacing-radius-md);
|
|
350
352
|
font-weight: 500;
|
|
351
353
|
cursor: pointer;
|