@esic-lab/data-core-ui 0.0.53 → 0.0.55
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/assets/STO-logo.svg +92 -92
- package/dist/index.cjs +4084 -0
- package/dist/index.css +5 -1
- package/dist/index.d.cts +573 -0
- package/dist/index.d.mts +5 -50
- package/dist/index.d.ts +5 -50
- package/dist/index.js +174 -15
- package/dist/index.mjs +172 -15
- package/package.json +5 -3
package/dist/index.d.ts
CHANGED
|
@@ -7,7 +7,6 @@ import { InputNumberProps, SelectProps } from 'antd';
|
|
|
7
7
|
import { Color } from 'antd/es/color-picker';
|
|
8
8
|
import { MessageInstance } from 'antd/es/message/interface';
|
|
9
9
|
import { ItemType } from 'antd/es/breadcrumb/Breadcrumb';
|
|
10
|
-
import { ReactNode as ReactNode$1 } from '@tabler/icons-react';
|
|
11
10
|
|
|
12
11
|
type ColorScale = 50 | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900;
|
|
13
12
|
type BaseColor = "primary" | "gray" | "green" | "red" | "yellow" | "blue";
|
|
@@ -443,10 +442,9 @@ interface SortFilterProps {
|
|
|
443
442
|
declare function SortFilter({ showYear, showQuarter, showMonth, onSortClick, onFilterClick, }: SortFilterProps): react_jsx_runtime.JSX.Element;
|
|
444
443
|
|
|
445
444
|
interface FileUploaderProps {
|
|
446
|
-
onUpload: (file:
|
|
445
|
+
onUpload: (file: File) => Promise<void>;
|
|
447
446
|
onRemove?: (index: number) => Promise<void>;
|
|
448
447
|
onError?: (message: string) => void;
|
|
449
|
-
onClickFile?: (file: any) => void;
|
|
450
448
|
accept?: string[];
|
|
451
449
|
maxSize?: number;
|
|
452
450
|
disabled?: boolean;
|
|
@@ -454,11 +452,8 @@ interface FileUploaderProps {
|
|
|
454
452
|
description?: string;
|
|
455
453
|
label?: string;
|
|
456
454
|
value?: File[] | any[];
|
|
457
|
-
uploadText?: string;
|
|
458
|
-
uploaderWidth?: string;
|
|
459
|
-
attachWidth?: string;
|
|
460
455
|
}
|
|
461
|
-
declare function FileUploader({ onUpload, onError, onRemove,
|
|
456
|
+
declare function FileUploader({ onUpload, onError, onRemove, accept, maxSize, disabled, mode, description, label, value, }: FileUploaderProps): react_jsx_runtime.JSX.Element;
|
|
462
457
|
|
|
463
458
|
declare function setMessageApi(api: MessageInstance): void;
|
|
464
459
|
declare function messageSuccess(content: string): void;
|
|
@@ -527,22 +522,16 @@ interface IndicatorProps {
|
|
|
527
522
|
}[];
|
|
528
523
|
type: "OUTPUT" | "OUTCOME";
|
|
529
524
|
arrayData: IndicatorArray[];
|
|
530
|
-
canEdit?: boolean;
|
|
531
525
|
setArrayData: (data: IndicatorArray[]) => void;
|
|
532
|
-
onDeleteClick?: (payload: {
|
|
533
|
-
index: number;
|
|
534
|
-
item: IndicatorArray;
|
|
535
|
-
confirm: () => void;
|
|
536
|
-
}) => void;
|
|
537
526
|
}
|
|
538
527
|
interface IndicatorArray {
|
|
539
528
|
indicatorType: "OUTPUT" | "OUTCOME";
|
|
540
529
|
inputType: "TEXT" | "NUMBER";
|
|
541
530
|
textValue: string;
|
|
542
|
-
numberValue?:
|
|
531
|
+
numberValue?: string;
|
|
543
532
|
unit?: string;
|
|
544
533
|
}
|
|
545
|
-
declare function Indicator({ option, type, arrayData, setArrayData,
|
|
534
|
+
declare function Indicator({ option, type, arrayData, setArrayData, }: IndicatorProps): react_jsx_runtime.JSX.Element;
|
|
546
535
|
|
|
547
536
|
interface optionSelect {
|
|
548
537
|
value: string;
|
|
@@ -553,38 +542,4 @@ declare const FilterPopUp: (filter: {
|
|
|
553
542
|
handleSearch: (listFiler: string[]) => void;
|
|
554
543
|
}) => react_jsx_runtime.JSX.Element;
|
|
555
544
|
|
|
556
|
-
|
|
557
|
-
id: string;
|
|
558
|
-
name: string;
|
|
559
|
-
profile: string;
|
|
560
|
-
}
|
|
561
|
-
interface ProfileSelectProp {
|
|
562
|
-
allUser: UserData[];
|
|
563
|
-
assignUser: UserData[];
|
|
564
|
-
mode: "show" | "showAssign" | "icon";
|
|
565
|
-
className?: string;
|
|
566
|
-
onUpdateAssignUser: (user: UserData, action?: "add" | "remove") => void;
|
|
567
|
-
}
|
|
568
|
-
declare function ProfileSelect({ allUser, assignUser, mode, className, onUpdateAssignUser, }: ProfileSelectProp): react_jsx_runtime.JSX.Element;
|
|
569
|
-
|
|
570
|
-
interface QRCodeGeneratorProps {
|
|
571
|
-
url: string;
|
|
572
|
-
previewSize?: number;
|
|
573
|
-
defaultExportSize?: number;
|
|
574
|
-
fileBaseName?: string;
|
|
575
|
-
}
|
|
576
|
-
declare const QRCodeGenerator: react.FC<QRCodeGeneratorProps>;
|
|
577
|
-
|
|
578
|
-
interface TabProjectProp {
|
|
579
|
-
tabOption: {
|
|
580
|
-
key: string;
|
|
581
|
-
label: string;
|
|
582
|
-
icon: ReactNode$1;
|
|
583
|
-
}[];
|
|
584
|
-
projectId: string;
|
|
585
|
-
now: string;
|
|
586
|
-
onChange: (key: string) => void;
|
|
587
|
-
}
|
|
588
|
-
declare function TabProject({ tabOption, now, onChange }: TabProjectProp): react_jsx_runtime.JSX.Element;
|
|
589
|
-
|
|
590
|
-
export { AntDModal, AntDataTable, Breadcrumbs, Calendar, Checkbox, CheckboxGroup, ColorPalettePickerBasic, ColorPickerBasic, DataTable, DatePickerBasic, DatePickerRange, FileUploader, FilterPopUp, GhostButton, HeadingPage, Indicator, InputField, InputFieldNumber, KpiSection, Loader, MenuNavBar, type MenuNavBarProps, PrimaryButton, ProfileSelect, ProgressBar, QRCodeGenerator, Radio, RadioGroup, SecondaryButton, SelectCustom, SelectField, SelectFieldGroup, SelectFieldStatus, SelectFieldStatusReport, SelectFieldTag, Sidebar, SortFilter, Switch, SwitchSelect, TabProject, TabSelectionButton, TextAreaInput, TextInput, TopNavBar, messageError, messageInfo, messageLoading, messageSuccess, messageWarning, setMessageApi };
|
|
545
|
+
export { AntDModal, AntDataTable, Breadcrumbs, Calendar, Checkbox, CheckboxGroup, ColorPalettePickerBasic, ColorPickerBasic, DataTable, DatePickerBasic, DatePickerRange, FileUploader, FilterPopUp, GhostButton, HeadingPage, Indicator, InputField, InputFieldNumber, KpiSection, Loader, MenuNavBar, type MenuNavBarProps, PrimaryButton, ProgressBar, Radio, RadioGroup, SecondaryButton, SelectCustom, SelectField, SelectFieldGroup, SelectFieldStatus, SelectFieldStatusReport, SelectFieldTag, Sidebar, SortFilter, Switch, SwitchSelect, TabSelectionButton, TextAreaInput, TextInput, TopNavBar, messageError, messageInfo, messageLoading, messageSuccess, messageWarning, setMessageApi };
|
package/dist/index.js
CHANGED
|
@@ -357,6 +357,7 @@ var index_exports = {};
|
|
|
357
357
|
__export(index_exports, {
|
|
358
358
|
AntDModal: () => AntDModal,
|
|
359
359
|
AntDataTable: () => AntDataTable,
|
|
360
|
+
BarChart: () => BarChart,
|
|
360
361
|
Breadcrumbs: () => Breadcrumbs,
|
|
361
362
|
Calendar: () => Calendar,
|
|
362
363
|
Checkbox: () => Checkbox,
|
|
@@ -376,6 +377,7 @@ __export(index_exports, {
|
|
|
376
377
|
KpiSection: () => KpiSection,
|
|
377
378
|
Loader: () => Loader,
|
|
378
379
|
MenuNavBar: () => MenuNavBar,
|
|
380
|
+
PieChart: () => PieChart,
|
|
379
381
|
PrimaryButton: () => PrimaryButton,
|
|
380
382
|
ProfileSelect: () => ProfileSelect,
|
|
381
383
|
ProgressBar: () => ProgressBar,
|
|
@@ -1243,7 +1245,7 @@ function InputFieldNumber({
|
|
|
1243
1245
|
addonAfter,
|
|
1244
1246
|
defaultValue,
|
|
1245
1247
|
className,
|
|
1246
|
-
max,
|
|
1248
|
+
max: max2,
|
|
1247
1249
|
min,
|
|
1248
1250
|
controls,
|
|
1249
1251
|
size,
|
|
@@ -1276,7 +1278,7 @@ function InputFieldNumber({
|
|
|
1276
1278
|
addonBefore,
|
|
1277
1279
|
addonAfter,
|
|
1278
1280
|
defaultValue,
|
|
1279
|
-
max,
|
|
1281
|
+
max: max2,
|
|
1280
1282
|
min,
|
|
1281
1283
|
controls,
|
|
1282
1284
|
size,
|
|
@@ -1730,8 +1732,8 @@ function splitColorStr(str, parseNum) {
|
|
|
1730
1732
|
return numList;
|
|
1731
1733
|
}
|
|
1732
1734
|
var parseHSVorHSL = (num, _, index) => index === 0 ? num : num / 100;
|
|
1733
|
-
function limitRange(value,
|
|
1734
|
-
const mergedMax =
|
|
1735
|
+
function limitRange(value, max2) {
|
|
1736
|
+
const mergedMax = max2 || 255;
|
|
1735
1737
|
if (value > mergedMax) {
|
|
1736
1738
|
return mergedMax;
|
|
1737
1739
|
}
|
|
@@ -2025,9 +2027,9 @@ var FastColor = class _FastColor {
|
|
|
2025
2027
|
}
|
|
2026
2028
|
// ====================== Privates ======================
|
|
2027
2029
|
/** Return a new FastColor object with one channel changed */
|
|
2028
|
-
_sc(rgb, value,
|
|
2030
|
+
_sc(rgb, value, max2) {
|
|
2029
2031
|
const clone = this.clone();
|
|
2030
|
-
clone[rgb] = limitRange(value,
|
|
2032
|
+
clone[rgb] = limitRange(value, max2);
|
|
2031
2033
|
return clone;
|
|
2032
2034
|
}
|
|
2033
2035
|
_c(input) {
|
|
@@ -3017,7 +3019,8 @@ function FileUploader({
|
|
|
3017
3019
|
value,
|
|
3018
3020
|
uploadText = "\u0E41\u0E19\u0E1A\u0E44\u0E1F\u0E25\u0E4C",
|
|
3019
3021
|
uploaderWidth = "w-full",
|
|
3020
|
-
attachWidth = "w-full"
|
|
3022
|
+
attachWidth = "w-full",
|
|
3023
|
+
readOnly = false
|
|
3021
3024
|
}) {
|
|
3022
3025
|
const [internalFileList, setInternalFileList] = (0, import_react14.useState)([]);
|
|
3023
3026
|
const [uploading, setUploading] = (0, import_react14.useState)(false);
|
|
@@ -3089,7 +3092,7 @@ function FileUploader({
|
|
|
3089
3092
|
};
|
|
3090
3093
|
return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { className: "w-full", children: [
|
|
3091
3094
|
label && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("p", { className: "body-1", children: label }),
|
|
3092
|
-
/* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { className: uploaderWidth, children: [
|
|
3095
|
+
!readOnly && /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { className: uploaderWidth, children: [
|
|
3093
3096
|
mode === "upload" ? /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
3094
3097
|
"button",
|
|
3095
3098
|
{
|
|
@@ -3159,7 +3162,7 @@ function FileUploader({
|
|
|
3159
3162
|
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: "w-[24px] h-[24px] flex items-center justify-center", children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_icons_react10.IconFileDescription, { size: 20 }) }),
|
|
3160
3163
|
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)("span", { className: "truncate", children: file.name || file.fileName })
|
|
3161
3164
|
] }),
|
|
3162
|
-
!disabled && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
3165
|
+
!readOnly && !disabled && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
3163
3166
|
import_icons_react10.IconTrash,
|
|
3164
3167
|
{
|
|
3165
3168
|
size: 20,
|
|
@@ -4342,7 +4345,7 @@ var QRCodeGenerator = ({
|
|
|
4342
4345
|
fileBaseName = "qr-code"
|
|
4343
4346
|
}) => {
|
|
4344
4347
|
const canvasRef = (0, import_react21.useRef)(null);
|
|
4345
|
-
const [
|
|
4348
|
+
const [format4, setFormat] = (0, import_react21.useState)("png");
|
|
4346
4349
|
const [exportSize, setExportSize] = (0, import_react21.useState)(defaultExportSize);
|
|
4347
4350
|
const sizeOption = [
|
|
4348
4351
|
{
|
|
@@ -4396,7 +4399,7 @@ var QRCodeGenerator = ({
|
|
|
4396
4399
|
}, [url, previewSize]);
|
|
4397
4400
|
const download = async () => {
|
|
4398
4401
|
try {
|
|
4399
|
-
if (
|
|
4402
|
+
if (format4 === "svg") {
|
|
4400
4403
|
const svgString = await import_qrcode.default.toString(url, {
|
|
4401
4404
|
type: "svg",
|
|
4402
4405
|
width: exportSize,
|
|
@@ -4412,9 +4415,9 @@ var QRCodeGenerator = ({
|
|
|
4412
4415
|
width: exportSize,
|
|
4413
4416
|
margin: 1
|
|
4414
4417
|
});
|
|
4415
|
-
const mime =
|
|
4416
|
-
const dataURL =
|
|
4417
|
-
triggerDownload(dataURL, `${fileBaseName}.${
|
|
4418
|
+
const mime = format4 === "png" ? "image/png" : "image/jpeg";
|
|
4419
|
+
const dataURL = format4 === "jpeg" ? offscreen.toDataURL(mime, 0.92) : offscreen.toDataURL(mime);
|
|
4420
|
+
triggerDownload(dataURL, `${fileBaseName}.${format4}`);
|
|
4418
4421
|
}
|
|
4419
4422
|
} catch (err) {
|
|
4420
4423
|
console.error("Failed to generate QR export:", err);
|
|
@@ -4447,7 +4450,7 @@ var QRCodeGenerator = ({
|
|
|
4447
4450
|
SelectField,
|
|
4448
4451
|
{
|
|
4449
4452
|
label: "\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A",
|
|
4450
|
-
value:
|
|
4453
|
+
value: format4,
|
|
4451
4454
|
onChange: (e) => setFormat(e.target.value),
|
|
4452
4455
|
options: typeOption
|
|
4453
4456
|
}
|
|
@@ -4507,10 +4510,165 @@ function TabProject({ tabOption, now, onChange }) {
|
|
|
4507
4510
|
}
|
|
4508
4511
|
);
|
|
4509
4512
|
}
|
|
4513
|
+
|
|
4514
|
+
// src/Chart/BarChart/BarChart.tsx
|
|
4515
|
+
var import_react22 = require("react");
|
|
4516
|
+
var d3 = __toESM(require("d3"));
|
|
4517
|
+
var import_jsx_runtime45 = require("react/jsx-runtime");
|
|
4518
|
+
var defaultMargin = { top: 30, right: 200, bottom: 36, left: 50 };
|
|
4519
|
+
var defaultColorPalette = [
|
|
4520
|
+
"#4E79A7",
|
|
4521
|
+
"#F28E2B",
|
|
4522
|
+
"#E15759",
|
|
4523
|
+
"#76B7B2",
|
|
4524
|
+
"#59A14F",
|
|
4525
|
+
"#EDC949",
|
|
4526
|
+
"#AF7AA1",
|
|
4527
|
+
"#FF9DA7",
|
|
4528
|
+
"#9C755F",
|
|
4529
|
+
"#BAB0AC"
|
|
4530
|
+
];
|
|
4531
|
+
var BarChart = ({
|
|
4532
|
+
data,
|
|
4533
|
+
height = 300,
|
|
4534
|
+
margin = defaultMargin,
|
|
4535
|
+
yLabel,
|
|
4536
|
+
xLabel,
|
|
4537
|
+
colorPalette = defaultColorPalette
|
|
4538
|
+
}) => {
|
|
4539
|
+
const svgRef = (0, import_react22.useRef)(null);
|
|
4540
|
+
const gRef = (0, import_react22.useRef)(null);
|
|
4541
|
+
const xAxisRef = (0, import_react22.useRef)(null);
|
|
4542
|
+
const yAxisRef = (0, import_react22.useRef)(null);
|
|
4543
|
+
const containerRef = (0, import_react22.useRef)(null);
|
|
4544
|
+
const widthRef = (0, import_react22.useRef)(0);
|
|
4545
|
+
(0, import_react22.useEffect)(() => {
|
|
4546
|
+
if (!containerRef.current) return;
|
|
4547
|
+
const ro = new ResizeObserver((entries) => {
|
|
4548
|
+
const cr = entries[0].contentRect;
|
|
4549
|
+
widthRef.current = cr.width;
|
|
4550
|
+
render();
|
|
4551
|
+
});
|
|
4552
|
+
ro.observe(containerRef.current);
|
|
4553
|
+
return () => ro.disconnect();
|
|
4554
|
+
}, []);
|
|
4555
|
+
const xDomain = (0, import_react22.useMemo)(() => data.map((d) => d.x), [data]);
|
|
4556
|
+
const yDomain = (0, import_react22.useMemo)(() => {
|
|
4557
|
+
const maxY = d3.max(data, (d) => d.y);
|
|
4558
|
+
return [0, (maxY !== void 0 ? maxY : 0) + (maxY !== void 0 ? maxY : 0) * 0.1];
|
|
4559
|
+
}, [data]);
|
|
4560
|
+
const render = () => {
|
|
4561
|
+
const svg = d3.select(svgRef.current);
|
|
4562
|
+
const g = d3.select(gRef.current);
|
|
4563
|
+
const xAxisG = d3.select(xAxisRef.current);
|
|
4564
|
+
const yAxisG = d3.select(yAxisRef.current);
|
|
4565
|
+
const width = Math.max(200, widthRef.current || 600);
|
|
4566
|
+
const innerW = width - margin.left - margin.right;
|
|
4567
|
+
const innerH = height - margin.top - margin.bottom;
|
|
4568
|
+
svg.attr("width", width).attr("height", height);
|
|
4569
|
+
const x = d3.scaleBand().domain(xDomain).range([0, innerW]).padding(0.2);
|
|
4570
|
+
const y = d3.scaleLinear().domain(yDomain).nice().range([innerH, 0]);
|
|
4571
|
+
const xAxis = d3.axisBottom(x).tickSizeOuter(0).tickSize(0).tickFormat((d) => d);
|
|
4572
|
+
const yAxis = d3.axisLeft(y).ticks(5).tickFormat(d3.format("~s"));
|
|
4573
|
+
const grid = d3.axisLeft(y).ticks(5).tickSize(-innerW).scale(y);
|
|
4574
|
+
const gridG = svg.append("g").attr("class", "grid").attr("transform", `translate(${margin.left}, ${margin.top})`).call(grid).style("font-size", "14px");
|
|
4575
|
+
gridG.selectAll("path").remove();
|
|
4576
|
+
const barsG = svg.append("g").attr("class", "bars");
|
|
4577
|
+
svg.selectAll(".grid").data([0]).join("g").attr("class", "grid").attr("transform", `translate(${margin.left}, ${margin.top})`).call(grid).style("font-size", "14px").call((g2) => g2.selectAll("path").remove()).call(
|
|
4578
|
+
(g2) => g2.selectAll("line").style("stroke", "gray").style("stroke-opacity", 0.1)
|
|
4579
|
+
// keep faint
|
|
4580
|
+
);
|
|
4581
|
+
svg.select(".grid").lower();
|
|
4582
|
+
xAxisG.attr("transform", `translate(${margin.left},${height - margin.bottom})`).call(xAxis).selectAll("text").style("text-anchor", "middle").attr("dy", "1.5em").attr("fill", "currentColor").style("font-size", "14px").style("font-family", "Arial, sans-serif");
|
|
4583
|
+
yAxisG.selectAll(".y-axis-label").data(yLabel ? [yLabel] : []).join(
|
|
4584
|
+
(enter) => enter.append("text").attr("class", "y-axis-label").attr("fill", "currentColor").attr("x", -margin.left + 8).attr("y", -margin.top + 20).attr("text-anchor", "start").style("font-size", "14px").style("font-family", "Arial").text((d) => d),
|
|
4585
|
+
(update) => update.text((d) => d)
|
|
4586
|
+
);
|
|
4587
|
+
xAxisG.selectAll(".x-axis-label").data(xLabel ? [xLabel] : []).join(
|
|
4588
|
+
(enter) => enter.append("text").attr("class", "x-axis-label").attr("fill", "currentColor").attr("x", width).attr("y", height - margin.bottom).attr("text-anchor", "middle").style("font-size", "14px").style("font-family", "Arial").text((d) => d),
|
|
4589
|
+
(update) => update.text((d) => d).attr("x", width)
|
|
4590
|
+
);
|
|
4591
|
+
const t = svg.transition().duration(400);
|
|
4592
|
+
const bars = g.selectAll("rect.bar").data(data, (d) => d.x);
|
|
4593
|
+
bars.join(
|
|
4594
|
+
(enter) => enter.append("rect").attr("class", "bar").attr("x", (d) => margin.left).attr("width", x.bandwidth()).attr("y", () => margin.top + y(0)).attr("height", () => innerH - y(0)).attr("rx", 5).attr("ry", 5).style("fill", (d, i) => colorPalette[i % colorPalette.length]).append("title").text((d) => `${d.x}: ${d.y}`).merge(bars).attr("width", x.bandwidth()).attr("y", (d) => y(d.y)).attr("height", (d) => innerH - y(d.y)).call((enter2) => enter2.raise()),
|
|
4595
|
+
// Bring the new bars to the front
|
|
4596
|
+
(update) => update.call((update2) => update2.raise()).transition(t).attr("x", (d) => x(d.x) ?? 0).attr("width", x.bandwidth()).attr("y", (d) => y(d.y)).attr("height", (d) => innerH - y(d.y)).style("fill", (d, i) => colorPalette[i % colorPalette.length]),
|
|
4597
|
+
// Update color on update
|
|
4598
|
+
(exit) => exit.transition(t).attr("y", margin.top + y(0)).attr("height", innerH - y(0)).remove()
|
|
4599
|
+
);
|
|
4600
|
+
g.selectAll("text.bar-label").data(data).join(
|
|
4601
|
+
(enter) => enter.append("text").attr("class", "bar-label").attr("x", (d) => (x(d.x) ?? 0) + x.bandwidth() / 2).attr("y", (d) => y(d.y) - 6).attr("text-anchor", "middle").style("font-size", "50px").style("font-weight", "bold").style("font-family", "Arial, sans-serif").style("fill", (d, i) => colorPalette[i % colorPalette.length]).text((d) => d.y),
|
|
4602
|
+
(update) => update.transition(t).attr("x", (d) => (x(d.x) ?? 0) + x.bandwidth() / 2).attr("y", (d) => y(d.y) - 6).text((d) => d.y),
|
|
4603
|
+
(exit) => exit.remove()
|
|
4604
|
+
);
|
|
4605
|
+
};
|
|
4606
|
+
(0, import_react22.useEffect)(() => {
|
|
4607
|
+
render();
|
|
4608
|
+
}, [data, height, margin, xDomain.toString(), yDomain.toString()]);
|
|
4609
|
+
return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("div", { ref: containerRef, style: { width: "100%" }, children: /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("svg", { ref: svgRef, role: "img", "aria-label": "Bar chart", style: { display: "block", width: "100%", height }, children: [
|
|
4610
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)("title", { children: "Bar chart" }),
|
|
4611
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)("g", { ref: gRef, transform: `translate(${margin.left},${margin.top})` }),
|
|
4612
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)("g", { ref: xAxisRef }),
|
|
4613
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)("g", { ref: yAxisRef })
|
|
4614
|
+
] }) });
|
|
4615
|
+
};
|
|
4616
|
+
|
|
4617
|
+
// src/Chart/PieChart/PieChart.tsx
|
|
4618
|
+
var import_react23 = __toESM(require("react"));
|
|
4619
|
+
var d32 = __toESM(require("d3"));
|
|
4620
|
+
var import_jsx_runtime46 = require("react/jsx-runtime");
|
|
4621
|
+
var defaultColors = d32.schemeCategory10;
|
|
4622
|
+
var PieChart = ({
|
|
4623
|
+
title,
|
|
4624
|
+
description,
|
|
4625
|
+
data,
|
|
4626
|
+
width,
|
|
4627
|
+
height,
|
|
4628
|
+
colorPalette = defaultColors
|
|
4629
|
+
}) => {
|
|
4630
|
+
const svgRef = (0, import_react23.useRef)(null);
|
|
4631
|
+
const [dataSide, setDataSide] = import_react23.default.useState([]);
|
|
4632
|
+
(0, import_react23.useEffect)(() => {
|
|
4633
|
+
if (!svgRef.current) return;
|
|
4634
|
+
d32.select(svgRef.current).selectAll("*").remove();
|
|
4635
|
+
const radius = Math.min(width, height) / 2;
|
|
4636
|
+
const totalValue = d32.sum(data, (d) => d.value) ?? 0;
|
|
4637
|
+
const svg = d32.select(svgRef.current).attr("width", width).attr("height", height).append("g").attr("transform", `translate(${width / 2}, ${height / 2})`);
|
|
4638
|
+
const pie2 = d32.pie().value((d) => d.value);
|
|
4639
|
+
const arc2 = d32.arc().innerRadius(0).outerRadius(radius);
|
|
4640
|
+
const arcs = svg.selectAll(".arc").data(pie2(data)).enter().append("g").attr("class", "arc");
|
|
4641
|
+
arcs.append("path").attr("d", arc2).attr("fill", (d, i) => colorPalette[i]).attr("stroke", "white").attr("stroke-width", 2).attr("stroke-linejoin", "round");
|
|
4642
|
+
setDataSide(
|
|
4643
|
+
data.map((d, i) => ({
|
|
4644
|
+
color: colorPalette[i],
|
|
4645
|
+
label: d.label,
|
|
4646
|
+
value: d.value
|
|
4647
|
+
}))
|
|
4648
|
+
);
|
|
4649
|
+
arcs.append("text").attr("transform", (d) => `translate(${arc2.centroid(d)})`).attr("dy", ".35em").attr("text-anchor", "middle").style("fill", "white").style("font-family", "Kanit").style("font-size", "20px").style("font-style", "normal").style("font-weight", "500px").text((d) => {
|
|
4650
|
+
const percentage = (d.data.value / totalValue * 100).toFixed(1);
|
|
4651
|
+
return `${percentage}%`;
|
|
4652
|
+
});
|
|
4653
|
+
}, [data, width, height]);
|
|
4654
|
+
return /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)("div", { children: [
|
|
4655
|
+
title && /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("p", { className: "body-2", children: title }),
|
|
4656
|
+
description && /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("p", { className: "caption-1", children: description }),
|
|
4657
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsxs)("div", { className: "flex", children: [
|
|
4658
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)("svg", { ref: svgRef }),
|
|
4659
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)("div", { className: "flex flex-col gap-2 body-3 pl-[200px]", children: dataSide.map((d, i) => /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)("div", { className: "grid grid-cols-3 gap-2 items-center", children: [
|
|
4660
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)("div", { className: "w-[20px] h-[20px]", style: { backgroundColor: d.color } }),
|
|
4661
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)("div", { children: d.label }),
|
|
4662
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)("div", { children: d.value })
|
|
4663
|
+
] }, i)) })
|
|
4664
|
+
] })
|
|
4665
|
+
] });
|
|
4666
|
+
};
|
|
4510
4667
|
// Annotate the CommonJS export names for ESM import in node:
|
|
4511
4668
|
0 && (module.exports = {
|
|
4512
4669
|
AntDModal,
|
|
4513
4670
|
AntDataTable,
|
|
4671
|
+
BarChart,
|
|
4514
4672
|
Breadcrumbs,
|
|
4515
4673
|
Calendar,
|
|
4516
4674
|
Checkbox,
|
|
@@ -4530,6 +4688,7 @@ function TabProject({ tabOption, now, onChange }) {
|
|
|
4530
4688
|
KpiSection,
|
|
4531
4689
|
Loader,
|
|
4532
4690
|
MenuNavBar,
|
|
4691
|
+
PieChart,
|
|
4533
4692
|
PrimaryButton,
|
|
4534
4693
|
ProfileSelect,
|
|
4535
4694
|
ProgressBar,
|