@x-plat/design-system 0.5.2 → 0.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/dist/components/Accordion/index.cjs +38 -31
  2. package/dist/components/Accordion/index.css +1 -0
  3. package/dist/components/Accordion/index.js +38 -31
  4. package/dist/components/Alert/index.css +1 -0
  5. package/dist/components/Breadcrumb/index.css +3 -0
  6. package/dist/components/Button/index.css +1 -0
  7. package/dist/components/Calendar/index.cjs +103 -62
  8. package/dist/components/Calendar/index.css +1 -0
  9. package/dist/components/Calendar/index.js +103 -62
  10. package/dist/components/Card/index.css +2 -0
  11. package/dist/components/CardTab/index.css +1 -0
  12. package/dist/components/Chart/index.cjs +106 -83
  13. package/dist/components/Chart/index.css +1 -0
  14. package/dist/components/Chart/index.js +106 -83
  15. package/dist/components/DatePicker/index.cjs +36 -15
  16. package/dist/components/DatePicker/index.css +2 -0
  17. package/dist/components/DatePicker/index.js +36 -15
  18. package/dist/components/EmptyState/index.css +1 -0
  19. package/dist/components/FileUpload/index.css +2 -0
  20. package/dist/components/HtmlTypeWriter/index.css +1 -0
  21. package/dist/components/Pagination/index.css +8 -8
  22. package/dist/components/Spinner/index.css +7 -2
  23. package/dist/components/Steps/index.cjs +1 -4
  24. package/dist/components/Steps/index.css +15 -36
  25. package/dist/components/Steps/index.js +1 -4
  26. package/dist/components/Swiper/index.cjs +16 -12
  27. package/dist/components/Swiper/index.css +1 -0
  28. package/dist/components/Swiper/index.js +16 -12
  29. package/dist/components/Switch/index.css +20 -19
  30. package/dist/components/Tab/index.css +16 -2
  31. package/dist/components/Table/index.cjs +4 -4
  32. package/dist/components/Table/index.css +1 -0
  33. package/dist/components/Table/index.d.cts +2 -5
  34. package/dist/components/Table/index.d.ts +2 -5
  35. package/dist/components/Table/index.js +4 -4
  36. package/dist/components/Video/index.cjs +32 -43
  37. package/dist/components/Video/index.css +4 -4
  38. package/dist/components/Video/index.d.cts +1 -5
  39. package/dist/components/Video/index.d.ts +1 -5
  40. package/dist/components/Video/index.js +32 -43
  41. package/dist/components/index.cjs +339 -257
  42. package/dist/components/index.css +88 -71
  43. package/dist/components/index.js +339 -257
  44. package/dist/index.cjs +339 -257
  45. package/dist/index.css +88 -71
  46. package/dist/index.js +339 -257
  47. package/guidelines/Guidelines.md +11 -4
  48. 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 allValues = entries.flatMap(([, v]) => v);
96
- const maxVal = Math.max(...allValues) * 1.2 || 1;
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) * (300 - PADDING.top - PADDING.bottom);
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) * (600 - PADDING.left - PADDING.right);
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, values], di) => {
125
+ entries.map(([key], di) => {
112
126
  const palette = getPalette(LINE_BAR_PALETTES, di);
113
127
  const color = palette[4];
114
- const points = values.map((v, i) => {
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
- var BarChart = ({ data, labels, onHover, onMove, onLeave }) => {
148
- const entries = Object.entries(data);
149
- const allValues = entries.flatMap(([, v]) => v);
150
- const maxVal = Math.max(...allValues) * 1.2 || 1;
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, values], di) => {
191
+ entries.map(([key], di) => {
168
192
  const palette = getPalette(LINE_BAR_PALETTES, di);
169
193
  const color = palette[4];
170
- return values.map((v, i) => {
171
- const h = v / maxVal * chartH;
172
- const x = PADDING.left + groupW * i + (groupW - barW * groupCount) / 2 + barW * di;
173
- const y = PADDING.top + chartH - h;
174
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
175
- "rect",
176
- {
177
- x,
178
- y,
179
- width: barW,
180
- height: h,
181
- rx: "2",
182
- fill: color,
183
- className: "chart-bar",
184
- onMouseEnter: (e) => onHover(e, `${key}: ${labels[i]} \u2014 ${v}`),
185
- onMouseMove: onMove,
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
- var PieDonutChart = ({ data, labels, isDoughnut, onHover, onMove, onLeave }) => {
195
- const entries = Object.entries(data);
196
- const values = entries.flatMap(([, v]) => v);
197
- const total = values.reduce((a, b) => a + b, 0) || 1;
198
- const cx = 150;
199
- const cy = 150;
200
- const r = 120;
201
- const innerR = isDoughnut ? 60 : 0;
202
- const palette = getPalette(PIE_PALETTES, 0);
203
- let startAngle = -Math.PI / 2;
204
- const slices = values.map((v, i) => {
205
- const angle = v / total * Math.PI * 2;
206
- const endAngle = startAngle + angle;
207
- const largeArc = angle > Math.PI ? 1 : 0;
208
- const x1 = cx + r * Math.cos(startAngle);
209
- const y1 = cy + r * Math.sin(startAngle);
210
- const x2 = cx + r * Math.cos(endAngle);
211
- const y2 = cy + r * Math.sin(endAngle);
212
- let d;
213
- if (innerR > 0) {
214
- const ix1 = cx + innerR * Math.cos(startAngle);
215
- const iy1 = cy + innerR * Math.sin(startAngle);
216
- const ix2 = cx + innerR * Math.cos(endAngle);
217
- const iy2 = cy + innerR * Math.sin(endAngle);
218
- 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`;
219
- } else {
220
- d = `M ${cx} ${cy} L ${x1} ${y1} A ${r} ${r} 0 ${largeArc} 1 ${x2} ${y2} Z`;
221
- }
222
- const midAngle = startAngle + angle / 2;
223
- const labelR = innerR > 0 ? (r + innerR) / 2 : r * 0.6;
224
- const lx = cx + labelR * Math.cos(midAngle);
225
- const ly = cy + labelR * Math.sin(midAngle);
226
- const pct = Math.round(v / total * 100);
227
- const label = labels[i] || `${i + 1}`;
228
- startAngle = endAngle;
229
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("g", { children: [
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
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("svg", { viewBox: "0 0 300 300", className: "chart-svg chart-pie", children: slices });
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);
@@ -1,5 +1,6 @@
1
1
  /* src/components/Chart/chart.scss */
2
2
  .lib-xplat-chart {
3
+ contain: content;
3
4
  width: 100%;
4
5
  position: relative;
5
6
  }
@@ -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 allValues = entries.flatMap(([, v]) => v);
60
- const maxVal = Math.max(...allValues) * 1.2 || 1;
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) * (300 - PADDING.top - PADDING.bottom);
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) * (600 - PADDING.left - PADDING.right);
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, values], di) => {
89
+ entries.map(([key], di) => {
76
90
  const palette = getPalette(LINE_BAR_PALETTES, di);
77
91
  const color = palette[4];
78
- const points = values.map((v, i) => {
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
- var BarChart = ({ data, labels, onHover, onMove, onLeave }) => {
112
- const entries = Object.entries(data);
113
- const allValues = entries.flatMap(([, v]) => v);
114
- const maxVal = Math.max(...allValues) * 1.2 || 1;
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, values], di) => {
155
+ entries.map(([key], di) => {
132
156
  const palette = getPalette(LINE_BAR_PALETTES, di);
133
157
  const color = palette[4];
134
- return values.map((v, i) => {
135
- const h = v / maxVal * chartH;
136
- const x = PADDING.left + groupW * i + (groupW - barW * groupCount) / 2 + barW * di;
137
- const y = PADDING.top + chartH - h;
138
- return /* @__PURE__ */ jsx(
139
- "rect",
140
- {
141
- x,
142
- y,
143
- width: barW,
144
- height: h,
145
- rx: "2",
146
- fill: color,
147
- className: "chart-bar",
148
- onMouseEnter: (e) => onHover(e, `${key}: ${labels[i]} \u2014 ${v}`),
149
- onMouseMove: onMove,
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
- var PieDonutChart = ({ data, labels, isDoughnut, onHover, onMove, onLeave }) => {
159
- const entries = Object.entries(data);
160
- const values = entries.flatMap(([, v]) => v);
161
- const total = values.reduce((a, b) => a + b, 0) || 1;
162
- const cx = 150;
163
- const cy = 150;
164
- const r = 120;
165
- const innerR = isDoughnut ? 60 : 0;
166
- const palette = getPalette(PIE_PALETTES, 0);
167
- let startAngle = -Math.PI / 2;
168
- const slices = values.map((v, i) => {
169
- const angle = v / total * Math.PI * 2;
170
- const endAngle = startAngle + angle;
171
- const largeArc = angle > Math.PI ? 1 : 0;
172
- const x1 = cx + r * Math.cos(startAngle);
173
- const y1 = cy + r * Math.sin(startAngle);
174
- const x2 = cx + r * Math.cos(endAngle);
175
- const y2 = cy + r * Math.sin(endAngle);
176
- let d;
177
- if (innerR > 0) {
178
- const ix1 = cx + innerR * Math.cos(startAngle);
179
- const iy1 = cy + innerR * Math.sin(startAngle);
180
- const ix2 = cx + innerR * Math.cos(endAngle);
181
- const iy2 = cy + innerR * Math.sin(endAngle);
182
- 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`;
183
- } else {
184
- d = `M ${cx} ${cy} L ${x1} ${y1} A ${r} ${r} 0 ${largeArc} 1 ${x2} ${y2} Z`;
185
- }
186
- const midAngle = startAngle + angle / 2;
187
- const labelR = innerR > 0 ? (r + innerR) / 2 : r * 0.6;
188
- const lx = cx + labelR * Math.cos(midAngle);
189
- const ly = cy + labelR * Math.sin(midAngle);
190
- const pct = Math.round(v / total * 100);
191
- const label = labels[i] || `${i + 1}`;
192
- startAngle = endAngle;
193
- return /* @__PURE__ */ jsxs("g", { children: [
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
- return /* @__PURE__ */ jsx("svg", { viewBox: "0 0 300 300", className: "chart-svg chart-pie", children: slices });
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
- "button",
1848
+ RangeDayCell,
1820
1849
  {
1821
- type: "button",
1822
- className: clsx_default(
1823
- "datepicker-day",
1824
- !day.isCurrentMonth && "outside",
1825
- disabled && "disabled",
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;