@esic-lab/data-core-ui 0.0.21 → 0.0.23
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.css +63 -2
- package/dist/index.d.mts +32 -9
- package/dist/index.d.ts +32 -9
- package/dist/index.js +504 -16
- package/dist/index.mjs +509 -16
- package/package.json +3 -2
- package/dist/STO-logo-KFQUNTJ3.svg +0 -92
package/dist/index.mjs
CHANGED
|
@@ -1118,7 +1118,8 @@ function InputField({
|
|
|
1118
1118
|
addonBefore,
|
|
1119
1119
|
addonAfter,
|
|
1120
1120
|
defaultValue,
|
|
1121
|
-
className
|
|
1121
|
+
className,
|
|
1122
|
+
onClear
|
|
1122
1123
|
}) {
|
|
1123
1124
|
return /* @__PURE__ */ jsx18(
|
|
1124
1125
|
ConfigProvider2,
|
|
@@ -1145,7 +1146,8 @@ function InputField({
|
|
|
1145
1146
|
allowClear: true,
|
|
1146
1147
|
addonBefore,
|
|
1147
1148
|
addonAfter,
|
|
1148
|
-
defaultValue
|
|
1149
|
+
defaultValue,
|
|
1150
|
+
onClear
|
|
1149
1151
|
}
|
|
1150
1152
|
),
|
|
1151
1153
|
/* @__PURE__ */ jsxs14("div", { children: [
|
|
@@ -2232,7 +2234,8 @@ function ColorPalettePickerBasic({
|
|
|
2232
2234
|
allowClear,
|
|
2233
2235
|
defaultFormat,
|
|
2234
2236
|
className,
|
|
2235
|
-
placeholder = "\u0E01\u0E23\u0E38\u0E13\u0E32\u0E40\u0E25\u0E37\u0E2D\u0E01\u0E2A\u0E35"
|
|
2237
|
+
placeholder = "\u0E01\u0E23\u0E38\u0E13\u0E32\u0E40\u0E25\u0E37\u0E2D\u0E01\u0E2A\u0E35",
|
|
2238
|
+
onClear
|
|
2236
2239
|
}) {
|
|
2237
2240
|
const { token } = theme.useToken();
|
|
2238
2241
|
const presets = genPresets({
|
|
@@ -2276,7 +2279,8 @@ function ColorPalettePickerBasic({
|
|
|
2276
2279
|
")"
|
|
2277
2280
|
] });
|
|
2278
2281
|
},
|
|
2279
|
-
disabled
|
|
2282
|
+
disabled,
|
|
2283
|
+
onClear
|
|
2280
2284
|
}
|
|
2281
2285
|
),
|
|
2282
2286
|
/* @__PURE__ */ jsxs21("div", { children: [
|
|
@@ -2308,7 +2312,8 @@ function SelectField({
|
|
|
2308
2312
|
prefix,
|
|
2309
2313
|
prefixSize = 20,
|
|
2310
2314
|
handleSearch,
|
|
2311
|
-
className
|
|
2315
|
+
className,
|
|
2316
|
+
onClear
|
|
2312
2317
|
}) {
|
|
2313
2318
|
return /* @__PURE__ */ jsx26(
|
|
2314
2319
|
ConfigProvider10,
|
|
@@ -2341,7 +2346,8 @@ function SelectField({
|
|
|
2341
2346
|
mode,
|
|
2342
2347
|
onSearch: handleSearch,
|
|
2343
2348
|
prefix: prefix ? /* @__PURE__ */ jsx26("span", { style: { width: prefixSize, height: prefixSize, display: "flex", alignItems: "center", justifyContent: "center" }, children: prefix }) : void 0,
|
|
2344
|
-
allowClear: true
|
|
2349
|
+
allowClear: true,
|
|
2350
|
+
onClear
|
|
2345
2351
|
}
|
|
2346
2352
|
),
|
|
2347
2353
|
/* @__PURE__ */ jsxs22("div", { children: [
|
|
@@ -2492,7 +2498,8 @@ function SelectFieldStatus({
|
|
|
2492
2498
|
placeholder,
|
|
2493
2499
|
optionFilterProp: "label",
|
|
2494
2500
|
filterOption: (input, option) => (option?.label ?? "").toString().toLowerCase().includes(input.toLowerCase()),
|
|
2495
|
-
options
|
|
2501
|
+
options,
|
|
2502
|
+
showSearch: true
|
|
2496
2503
|
}
|
|
2497
2504
|
),
|
|
2498
2505
|
/* @__PURE__ */ jsxs24("div", { children: [
|
|
@@ -2527,7 +2534,8 @@ function SelectFieldStatusReport({
|
|
|
2527
2534
|
disabled,
|
|
2528
2535
|
showError,
|
|
2529
2536
|
errorMessage,
|
|
2530
|
-
className
|
|
2537
|
+
className,
|
|
2538
|
+
options
|
|
2531
2539
|
}) {
|
|
2532
2540
|
const selectedItem = status2.find((s) => s.value === value);
|
|
2533
2541
|
return /* @__PURE__ */ jsx29(
|
|
@@ -2562,12 +2570,9 @@ function SelectFieldStatusReport({
|
|
|
2562
2570
|
className: `body-3 custom-select flex justify-center w-full ${className ?? ""}`,
|
|
2563
2571
|
placeholder,
|
|
2564
2572
|
optionFilterProp: "label",
|
|
2565
|
-
|
|
2566
|
-
options
|
|
2567
|
-
|
|
2568
|
-
label: s.label,
|
|
2569
|
-
color: s.color
|
|
2570
|
-
}))
|
|
2573
|
+
filterOption: (input, option) => (option?.label ?? "").toString().toLowerCase().includes(input.toLowerCase()),
|
|
2574
|
+
options,
|
|
2575
|
+
showSearch: true
|
|
2571
2576
|
}
|
|
2572
2577
|
),
|
|
2573
2578
|
/* @__PURE__ */ jsxs25("div", { children: [
|
|
@@ -2594,7 +2599,8 @@ function SelectFieldTag({
|
|
|
2594
2599
|
errorMessage,
|
|
2595
2600
|
value: controlledValue,
|
|
2596
2601
|
className,
|
|
2597
|
-
onChange
|
|
2602
|
+
onChange,
|
|
2603
|
+
onClear
|
|
2598
2604
|
}) {
|
|
2599
2605
|
const [internalValue, setInternalValue] = useState6([]);
|
|
2600
2606
|
const isControlled = controlledValue !== void 0;
|
|
@@ -2646,7 +2652,8 @@ function SelectFieldTag({
|
|
|
2646
2652
|
},
|
|
2647
2653
|
searchValue: searchWord,
|
|
2648
2654
|
options,
|
|
2649
|
-
allowClear: true
|
|
2655
|
+
allowClear: true,
|
|
2656
|
+
onClear
|
|
2650
2657
|
}
|
|
2651
2658
|
),
|
|
2652
2659
|
/* @__PURE__ */ jsxs26("div", { children: [
|
|
@@ -3089,6 +3096,491 @@ function ProgressBar({
|
|
|
3089
3096
|
}
|
|
3090
3097
|
);
|
|
3091
3098
|
}
|
|
3099
|
+
|
|
3100
|
+
// src/KpiSection/KpiSection.tsx
|
|
3101
|
+
import { ConfigProvider as ConfigProvider19, message } from "antd";
|
|
3102
|
+
import { useEffect as useEffect3, useState as useState11 } from "react";
|
|
3103
|
+
|
|
3104
|
+
// src/KpiSection/hooks/useGetKpiSection.ts
|
|
3105
|
+
import { useState as useState10 } from "react";
|
|
3106
|
+
import cuid from "cuid";
|
|
3107
|
+
function useGetKpiSection() {
|
|
3108
|
+
const [nameKpi, setNameKpi] = useState10("");
|
|
3109
|
+
const [kpiValue, setKpiValue] = useState10("");
|
|
3110
|
+
const [unitValue, setUnitValue] = useState10("");
|
|
3111
|
+
const [kpiList, setKpiList] = useState10([]);
|
|
3112
|
+
const [editingBackup, setEditingBackup] = useState10({});
|
|
3113
|
+
const [selected, setSelected] = useState10("2");
|
|
3114
|
+
const [errors, setErrors] = useState10({
|
|
3115
|
+
nameKpi: "",
|
|
3116
|
+
kpiValue: "",
|
|
3117
|
+
unitValue: ""
|
|
3118
|
+
});
|
|
3119
|
+
const [itemErrors, setItemErrors] = useState10({});
|
|
3120
|
+
const options = [
|
|
3121
|
+
{ value: "1", label: "\u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21" },
|
|
3122
|
+
{ value: "2", label: "\u0E15\u0E31\u0E27\u0E40\u0E25\u0E02" }
|
|
3123
|
+
];
|
|
3124
|
+
const handleAddKpi = (type) => {
|
|
3125
|
+
let newErrors = { nameKpi: "", kpiValue: "", unitValue: "" };
|
|
3126
|
+
let hasError = false;
|
|
3127
|
+
if (!nameKpi) {
|
|
3128
|
+
newErrors.nameKpi = "\u0E42\u0E1B\u0E23\u0E14\u0E23\u0E30\u0E1A\u0E38";
|
|
3129
|
+
hasError = true;
|
|
3130
|
+
}
|
|
3131
|
+
if (type === "number") {
|
|
3132
|
+
if (!kpiValue) {
|
|
3133
|
+
newErrors.kpiValue = "\u0E42\u0E1B\u0E23\u0E14\u0E23\u0E30\u0E1A\u0E38";
|
|
3134
|
+
hasError = true;
|
|
3135
|
+
}
|
|
3136
|
+
if (!unitValue) {
|
|
3137
|
+
newErrors.unitValue = "\u0E42\u0E1B\u0E23\u0E14\u0E23\u0E30\u0E1A\u0E38";
|
|
3138
|
+
hasError = true;
|
|
3139
|
+
}
|
|
3140
|
+
}
|
|
3141
|
+
setErrors(newErrors);
|
|
3142
|
+
if (hasError) return;
|
|
3143
|
+
const newKpi = {
|
|
3144
|
+
id: cuid(),
|
|
3145
|
+
name: nameKpi,
|
|
3146
|
+
value: kpiValue,
|
|
3147
|
+
unit: unitValue,
|
|
3148
|
+
isEditing: false
|
|
3149
|
+
};
|
|
3150
|
+
setKpiList([...kpiList, newKpi]);
|
|
3151
|
+
setNameKpi("");
|
|
3152
|
+
setKpiValue("");
|
|
3153
|
+
setUnitValue("");
|
|
3154
|
+
setErrors({ nameKpi: "", kpiValue: "", unitValue: "" });
|
|
3155
|
+
};
|
|
3156
|
+
const handleEdit = (id) => {
|
|
3157
|
+
const current = kpiList.find((kpi) => kpi.id === id);
|
|
3158
|
+
if (current) {
|
|
3159
|
+
setEditingBackup((prev) => ({ ...prev, [id]: { ...current } }));
|
|
3160
|
+
}
|
|
3161
|
+
setKpiList(
|
|
3162
|
+
(prev) => prev.map((item) => item.id === id ? { ...item, isEditing: true } : item)
|
|
3163
|
+
);
|
|
3164
|
+
};
|
|
3165
|
+
const handleSave = (id, type) => {
|
|
3166
|
+
setKpiList((prev) => {
|
|
3167
|
+
return prev.map((item) => {
|
|
3168
|
+
if (item.id === id) {
|
|
3169
|
+
let hasError = false;
|
|
3170
|
+
const errorsForItem = {};
|
|
3171
|
+
if (!item.name) {
|
|
3172
|
+
errorsForItem.name = "\u0E42\u0E1B\u0E23\u0E14\u0E23\u0E30\u0E1A\u0E38";
|
|
3173
|
+
hasError = true;
|
|
3174
|
+
}
|
|
3175
|
+
if (type === "number") {
|
|
3176
|
+
if (!item.value) {
|
|
3177
|
+
errorsForItem.value = "\u0E42\u0E1B\u0E23\u0E14\u0E23\u0E30\u0E1A\u0E38";
|
|
3178
|
+
hasError = true;
|
|
3179
|
+
}
|
|
3180
|
+
if (!item.unit) {
|
|
3181
|
+
errorsForItem.unit = "\u0E42\u0E1B\u0E23\u0E14\u0E23\u0E30\u0E1A\u0E38";
|
|
3182
|
+
hasError = true;
|
|
3183
|
+
}
|
|
3184
|
+
}
|
|
3185
|
+
if (hasError) {
|
|
3186
|
+
setItemErrors((prev2) => ({ ...prev2, [id]: errorsForItem }));
|
|
3187
|
+
return item;
|
|
3188
|
+
}
|
|
3189
|
+
setItemErrors((prev2) => {
|
|
3190
|
+
const copy = { ...prev2 };
|
|
3191
|
+
delete copy[id];
|
|
3192
|
+
return copy;
|
|
3193
|
+
});
|
|
3194
|
+
return { ...item, isEditing: false };
|
|
3195
|
+
}
|
|
3196
|
+
return item;
|
|
3197
|
+
});
|
|
3198
|
+
});
|
|
3199
|
+
};
|
|
3200
|
+
const handleCancel = (id) => {
|
|
3201
|
+
const backup = editingBackup[id];
|
|
3202
|
+
if (backup) {
|
|
3203
|
+
setKpiList(
|
|
3204
|
+
(prev) => prev.map(
|
|
3205
|
+
(item) => item.id === id ? { ...backup, isEditing: false } : item
|
|
3206
|
+
)
|
|
3207
|
+
);
|
|
3208
|
+
setEditingBackup((prev) => {
|
|
3209
|
+
const copy = { ...prev };
|
|
3210
|
+
delete copy[id];
|
|
3211
|
+
return copy;
|
|
3212
|
+
});
|
|
3213
|
+
} else {
|
|
3214
|
+
setKpiList(
|
|
3215
|
+
(prev) => prev.map(
|
|
3216
|
+
(item) => item.id === id ? { ...item, isEditing: false } : item
|
|
3217
|
+
)
|
|
3218
|
+
);
|
|
3219
|
+
}
|
|
3220
|
+
};
|
|
3221
|
+
const handleDelete = (id) => {
|
|
3222
|
+
setKpiList((prev) => prev.filter((item) => item.id !== id));
|
|
3223
|
+
};
|
|
3224
|
+
return {
|
|
3225
|
+
handleAddKpi,
|
|
3226
|
+
handleEdit,
|
|
3227
|
+
handleSave,
|
|
3228
|
+
handleCancel,
|
|
3229
|
+
handleDelete,
|
|
3230
|
+
nameKpi,
|
|
3231
|
+
setNameKpi,
|
|
3232
|
+
kpiValue,
|
|
3233
|
+
setKpiValue,
|
|
3234
|
+
unitValue,
|
|
3235
|
+
setUnitValue,
|
|
3236
|
+
kpiList,
|
|
3237
|
+
setKpiList,
|
|
3238
|
+
editingBackup,
|
|
3239
|
+
setEditingBackup,
|
|
3240
|
+
options,
|
|
3241
|
+
selected,
|
|
3242
|
+
setSelected,
|
|
3243
|
+
errors,
|
|
3244
|
+
setErrors,
|
|
3245
|
+
itemErrors,
|
|
3246
|
+
setItemErrors
|
|
3247
|
+
};
|
|
3248
|
+
}
|
|
3249
|
+
|
|
3250
|
+
// src/KpiSection/KpiSection.tsx
|
|
3251
|
+
import {
|
|
3252
|
+
IconCheck as IconCheck2,
|
|
3253
|
+
IconCirclePlus,
|
|
3254
|
+
IconPencil,
|
|
3255
|
+
IconTrash as IconTrash2,
|
|
3256
|
+
IconX as IconX2
|
|
3257
|
+
} from "@tabler/icons-react";
|
|
3258
|
+
import { Fragment as Fragment6, jsx as jsx36, jsxs as jsxs31 } from "react/jsx-runtime";
|
|
3259
|
+
function KpiSection({ type, onChangeKpiList }) {
|
|
3260
|
+
const {
|
|
3261
|
+
handleAddKpi,
|
|
3262
|
+
handleEdit,
|
|
3263
|
+
handleSave,
|
|
3264
|
+
handleCancel,
|
|
3265
|
+
handleDelete,
|
|
3266
|
+
nameKpi,
|
|
3267
|
+
setNameKpi,
|
|
3268
|
+
kpiValue,
|
|
3269
|
+
setKpiValue,
|
|
3270
|
+
unitValue,
|
|
3271
|
+
setUnitValue,
|
|
3272
|
+
kpiList,
|
|
3273
|
+
setKpiList,
|
|
3274
|
+
errors,
|
|
3275
|
+
itemErrors,
|
|
3276
|
+
setItemErrors
|
|
3277
|
+
} = useGetKpiSection();
|
|
3278
|
+
const [messageApi2, messageContainer] = message.useMessage();
|
|
3279
|
+
const [hasShownError, setHasShownError] = useState11(false);
|
|
3280
|
+
useEffect3(() => {
|
|
3281
|
+
setMessageApi(messageApi2);
|
|
3282
|
+
}, [messageApi2]);
|
|
3283
|
+
useEffect3(() => {
|
|
3284
|
+
if (onChangeKpiList) {
|
|
3285
|
+
onChangeKpiList(kpiList);
|
|
3286
|
+
}
|
|
3287
|
+
}, [kpiList]);
|
|
3288
|
+
return /* @__PURE__ */ jsx36(
|
|
3289
|
+
ConfigProvider19,
|
|
3290
|
+
{
|
|
3291
|
+
theme: {
|
|
3292
|
+
token: {
|
|
3293
|
+
fontFamily: "Kanit",
|
|
3294
|
+
fontSize: 16
|
|
3295
|
+
}
|
|
3296
|
+
},
|
|
3297
|
+
children: /* @__PURE__ */ jsxs31("div", { className: "container-input", children: [
|
|
3298
|
+
messageContainer,
|
|
3299
|
+
type === "number" && /* @__PURE__ */ jsxs31("div", { className: "space-y-4", children: [
|
|
3300
|
+
/* @__PURE__ */ jsxs31("div", { className: "grid grid-cols-[1fr_200px_200px_50px] w-full gap-[24px] items-start", children: [
|
|
3301
|
+
/* @__PURE__ */ jsx36(
|
|
3302
|
+
InputField,
|
|
3303
|
+
{
|
|
3304
|
+
value: nameKpi,
|
|
3305
|
+
title: "\u0E0A\u0E37\u0E48\u0E2D\u0E1C\u0E25\u0E25\u0E31\u0E1E\u0E18\u0E4C\u0E17\u0E35\u0E48\u0E04\u0E32\u0E14\u0E2B\u0E27\u0E31\u0E07 (KPI)",
|
|
3306
|
+
placeholder: "\u0E42\u0E1B\u0E23\u0E14\u0E23\u0E30\u0E1A\u0E38",
|
|
3307
|
+
require: true,
|
|
3308
|
+
onChange: (value) => setNameKpi(value ?? ""),
|
|
3309
|
+
className: "h-[32px]",
|
|
3310
|
+
showError: !!errors.nameKpi,
|
|
3311
|
+
errorMessage: errors.nameKpi
|
|
3312
|
+
}
|
|
3313
|
+
),
|
|
3314
|
+
/* @__PURE__ */ jsx36(
|
|
3315
|
+
InputField,
|
|
3316
|
+
{
|
|
3317
|
+
value: kpiValue,
|
|
3318
|
+
title: "\u0E1C\u0E25\u0E25\u0E31\u0E1E\u0E18\u0E4C\u0E17\u0E35\u0E48\u0E04\u0E32\u0E14\u0E2B\u0E27\u0E31\u0E07 (KPI)",
|
|
3319
|
+
placeholder: "\u0E42\u0E1B\u0E23\u0E14\u0E23\u0E30\u0E1A\u0E38",
|
|
3320
|
+
require: true,
|
|
3321
|
+
onChange: (value) => {
|
|
3322
|
+
if (value === void 0 || value === "") {
|
|
3323
|
+
setKpiValue("");
|
|
3324
|
+
setHasShownError(false);
|
|
3325
|
+
} else if (/^\d*\.?\d*$/.test(value)) {
|
|
3326
|
+
setKpiValue(value);
|
|
3327
|
+
setHasShownError(false);
|
|
3328
|
+
} else {
|
|
3329
|
+
if (!hasShownError) {
|
|
3330
|
+
messageError("\u0E01\u0E23\u0E38\u0E13\u0E32\u0E01\u0E23\u0E2D\u0E01\u0E15\u0E31\u0E27\u0E40\u0E25\u0E02\u0E40\u0E17\u0E48\u0E32\u0E19\u0E31\u0E49\u0E19");
|
|
3331
|
+
setHasShownError(true);
|
|
3332
|
+
}
|
|
3333
|
+
}
|
|
3334
|
+
},
|
|
3335
|
+
showError: !!errors.kpiValue,
|
|
3336
|
+
errorMessage: errors.kpiValue
|
|
3337
|
+
}
|
|
3338
|
+
),
|
|
3339
|
+
/* @__PURE__ */ jsx36(
|
|
3340
|
+
InputField,
|
|
3341
|
+
{
|
|
3342
|
+
value: unitValue,
|
|
3343
|
+
title: "\u0E2B\u0E19\u0E48\u0E27\u0E22",
|
|
3344
|
+
placeholder: "\u0E42\u0E1B\u0E23\u0E14\u0E23\u0E30\u0E1A\u0E38",
|
|
3345
|
+
require: true,
|
|
3346
|
+
onChange: (value) => setUnitValue(value ?? ""),
|
|
3347
|
+
className: "h-[32px]",
|
|
3348
|
+
showError: !!errors.unitValue,
|
|
3349
|
+
errorMessage: errors.unitValue
|
|
3350
|
+
}
|
|
3351
|
+
),
|
|
3352
|
+
/* @__PURE__ */ jsx36(
|
|
3353
|
+
"div",
|
|
3354
|
+
{
|
|
3355
|
+
className: `flex justify-end mt-[28px]`,
|
|
3356
|
+
children: /* @__PURE__ */ jsx36(
|
|
3357
|
+
IconCirclePlus,
|
|
3358
|
+
{
|
|
3359
|
+
className: "w-[40px] h-[40px] cursor-pointer hover:scale-110 transition",
|
|
3360
|
+
stroke: 1,
|
|
3361
|
+
onClick: () => handleAddKpi(type)
|
|
3362
|
+
}
|
|
3363
|
+
)
|
|
3364
|
+
}
|
|
3365
|
+
)
|
|
3366
|
+
] }),
|
|
3367
|
+
/* @__PURE__ */ jsx36("div", { children: kpiList.map((kpi, index) => /* @__PURE__ */ jsxs31(
|
|
3368
|
+
"div",
|
|
3369
|
+
{
|
|
3370
|
+
className: "grid grid-cols-[30px_1fr_100px_120px_80px] items-start py-2 body-1 gap-[8px]",
|
|
3371
|
+
children: [
|
|
3372
|
+
/* @__PURE__ */ jsxs31("p", { className: `body-1 ${kpi.isEditing ? "mt-[12px]" : ""}`, children: [
|
|
3373
|
+
index + 1,
|
|
3374
|
+
"."
|
|
3375
|
+
] }),
|
|
3376
|
+
kpi.isEditing ? /* @__PURE__ */ jsxs31(Fragment6, { children: [
|
|
3377
|
+
/* @__PURE__ */ jsx36(
|
|
3378
|
+
InputField,
|
|
3379
|
+
{
|
|
3380
|
+
value: kpi.name,
|
|
3381
|
+
onChange: (value) => setKpiList(
|
|
3382
|
+
(prev) => prev.map(
|
|
3383
|
+
(item) => item.id === kpi.id ? { ...item, name: value ?? "" } : item
|
|
3384
|
+
)
|
|
3385
|
+
),
|
|
3386
|
+
showError: !!itemErrors[kpi.id]?.name,
|
|
3387
|
+
errorMessage: itemErrors[kpi.id]?.name
|
|
3388
|
+
}
|
|
3389
|
+
),
|
|
3390
|
+
/* @__PURE__ */ jsx36(
|
|
3391
|
+
InputField,
|
|
3392
|
+
{
|
|
3393
|
+
value: kpi.value?.toString(),
|
|
3394
|
+
onChange: (value) => {
|
|
3395
|
+
if (value === void 0 || value === "") {
|
|
3396
|
+
setKpiList(
|
|
3397
|
+
(prev) => prev.map(
|
|
3398
|
+
(item) => item.id === kpi.id ? { ...item, value: "" } : item
|
|
3399
|
+
)
|
|
3400
|
+
);
|
|
3401
|
+
setHasShownError(false);
|
|
3402
|
+
} else if (/^\d*\.?\d*$/.test(value)) {
|
|
3403
|
+
setKpiList(
|
|
3404
|
+
(prev) => prev.map(
|
|
3405
|
+
(item) => item.id === kpi.id ? { ...item, value } : item
|
|
3406
|
+
)
|
|
3407
|
+
);
|
|
3408
|
+
setHasShownError(false);
|
|
3409
|
+
} else {
|
|
3410
|
+
if (!hasShownError) {
|
|
3411
|
+
messageError("\u0E01\u0E23\u0E38\u0E13\u0E32\u0E01\u0E23\u0E2D\u0E01\u0E15\u0E31\u0E27\u0E40\u0E25\u0E02\u0E40\u0E17\u0E48\u0E32\u0E19\u0E31\u0E49\u0E19");
|
|
3412
|
+
setHasShownError(true);
|
|
3413
|
+
}
|
|
3414
|
+
}
|
|
3415
|
+
},
|
|
3416
|
+
showError: !!itemErrors[kpi.id]?.value,
|
|
3417
|
+
errorMessage: itemErrors[kpi.id]?.value
|
|
3418
|
+
}
|
|
3419
|
+
),
|
|
3420
|
+
/* @__PURE__ */ jsx36(
|
|
3421
|
+
InputField,
|
|
3422
|
+
{
|
|
3423
|
+
value: kpi.unit,
|
|
3424
|
+
onChange: (value) => setKpiList(
|
|
3425
|
+
(prev) => prev.map(
|
|
3426
|
+
(item) => item.id === kpi.id ? { ...item, unit: value ?? "" } : item
|
|
3427
|
+
)
|
|
3428
|
+
),
|
|
3429
|
+
showError: !!itemErrors[kpi.id]?.unit,
|
|
3430
|
+
errorMessage: itemErrors[kpi.id]?.unit
|
|
3431
|
+
}
|
|
3432
|
+
),
|
|
3433
|
+
/* @__PURE__ */ jsxs31(
|
|
3434
|
+
"div",
|
|
3435
|
+
{
|
|
3436
|
+
className: `flex gap-2 justify-end self-center ${!!itemErrors[kpi.id]?.value || !!itemErrors[kpi.id]?.unit || !!itemErrors[kpi.id]?.name ? "mt-[-12px]" : ""}`,
|
|
3437
|
+
children: [
|
|
3438
|
+
/* @__PURE__ */ jsx36(
|
|
3439
|
+
IconCheck2,
|
|
3440
|
+
{
|
|
3441
|
+
className: "w-[30px] h-[30px] cursor-pointer",
|
|
3442
|
+
onClick: () => handleSave(kpi.id, type)
|
|
3443
|
+
}
|
|
3444
|
+
),
|
|
3445
|
+
/* @__PURE__ */ jsx36(
|
|
3446
|
+
IconX2,
|
|
3447
|
+
{
|
|
3448
|
+
className: "w-[30px] h-[30px] cursor-pointer",
|
|
3449
|
+
onClick: () => handleCancel(kpi.id)
|
|
3450
|
+
}
|
|
3451
|
+
)
|
|
3452
|
+
]
|
|
3453
|
+
}
|
|
3454
|
+
)
|
|
3455
|
+
] }) : /* @__PURE__ */ jsxs31(Fragment6, { children: [
|
|
3456
|
+
/* @__PURE__ */ jsx36("p", { className: "body-1", children: kpi.name }),
|
|
3457
|
+
/* @__PURE__ */ jsx36("p", { className: "body-1", children: kpi.value }),
|
|
3458
|
+
/* @__PURE__ */ jsx36("p", { className: "body-1", children: kpi.unit }),
|
|
3459
|
+
/* @__PURE__ */ jsxs31("div", { className: "flex gap-3 justify-end", children: [
|
|
3460
|
+
/* @__PURE__ */ jsx36(
|
|
3461
|
+
IconPencil,
|
|
3462
|
+
{
|
|
3463
|
+
className: "w-[30px] h-[30px] cursor-pointer",
|
|
3464
|
+
onClick: () => handleEdit(kpi.id)
|
|
3465
|
+
}
|
|
3466
|
+
),
|
|
3467
|
+
/* @__PURE__ */ jsx36(
|
|
3468
|
+
IconTrash2,
|
|
3469
|
+
{
|
|
3470
|
+
className: "w-[30px] h-[30px] cursor-pointer",
|
|
3471
|
+
onClick: () => handleDelete(kpi.id)
|
|
3472
|
+
}
|
|
3473
|
+
)
|
|
3474
|
+
] })
|
|
3475
|
+
] })
|
|
3476
|
+
]
|
|
3477
|
+
},
|
|
3478
|
+
kpi.id
|
|
3479
|
+
)) })
|
|
3480
|
+
] }),
|
|
3481
|
+
type === "text" && /* @__PURE__ */ jsxs31("div", { className: "space-y-4", children: [
|
|
3482
|
+
/* @__PURE__ */ jsxs31("div", { className: "grid grid-cols-[1fr_50px] w-full gap-[24px] items-start", children: [
|
|
3483
|
+
/* @__PURE__ */ jsx36(
|
|
3484
|
+
InputField,
|
|
3485
|
+
{
|
|
3486
|
+
value: nameKpi,
|
|
3487
|
+
title: "\u0E0A\u0E37\u0E48\u0E2D\u0E1C\u0E25\u0E25\u0E31\u0E1E\u0E18\u0E4C\u0E17\u0E35\u0E48\u0E04\u0E32\u0E14\u0E2B\u0E27\u0E31\u0E07 (KPI)",
|
|
3488
|
+
placeholder: "\u0E42\u0E1B\u0E23\u0E14\u0E23\u0E30\u0E1A\u0E38",
|
|
3489
|
+
require: true,
|
|
3490
|
+
onChange: (value) => setNameKpi(value ?? ""),
|
|
3491
|
+
className: "h-[32px]",
|
|
3492
|
+
showError: !!errors.nameKpi,
|
|
3493
|
+
errorMessage: errors.nameKpi
|
|
3494
|
+
}
|
|
3495
|
+
),
|
|
3496
|
+
/* @__PURE__ */ jsx36(
|
|
3497
|
+
"div",
|
|
3498
|
+
{
|
|
3499
|
+
className: `flex justify-end mt-[28px]`,
|
|
3500
|
+
children: /* @__PURE__ */ jsx36(
|
|
3501
|
+
IconCirclePlus,
|
|
3502
|
+
{
|
|
3503
|
+
className: "w-[40px] h-[40px] cursor-pointer hover:scale-110 transition",
|
|
3504
|
+
stroke: 1,
|
|
3505
|
+
onClick: () => handleAddKpi(type)
|
|
3506
|
+
}
|
|
3507
|
+
)
|
|
3508
|
+
}
|
|
3509
|
+
)
|
|
3510
|
+
] }),
|
|
3511
|
+
/* @__PURE__ */ jsx36("div", { children: kpiList.map((kpi, index) => /* @__PURE__ */ jsxs31(
|
|
3512
|
+
"div",
|
|
3513
|
+
{
|
|
3514
|
+
className: "grid grid-cols-[30px_1fr_80px] items-start py-2 body-1 gap-[8px]",
|
|
3515
|
+
children: [
|
|
3516
|
+
/* @__PURE__ */ jsxs31("p", { className: `body-1 ${kpi.isEditing ? "mt-[12px]" : ""}`, children: [
|
|
3517
|
+
index + 1,
|
|
3518
|
+
"."
|
|
3519
|
+
] }),
|
|
3520
|
+
kpi.isEditing ? /* @__PURE__ */ jsxs31(Fragment6, { children: [
|
|
3521
|
+
/* @__PURE__ */ jsx36(
|
|
3522
|
+
InputField,
|
|
3523
|
+
{
|
|
3524
|
+
value: kpi.name,
|
|
3525
|
+
onChange: (value) => setKpiList(
|
|
3526
|
+
(prev) => prev.map(
|
|
3527
|
+
(item) => item.id === kpi.id ? { ...item, name: value ?? "" } : item
|
|
3528
|
+
)
|
|
3529
|
+
),
|
|
3530
|
+
showError: !!itemErrors[kpi.id]?.name,
|
|
3531
|
+
errorMessage: itemErrors[kpi.id]?.name
|
|
3532
|
+
}
|
|
3533
|
+
),
|
|
3534
|
+
/* @__PURE__ */ jsxs31(
|
|
3535
|
+
"div",
|
|
3536
|
+
{
|
|
3537
|
+
className: `flex gap-2 justify-end self-center ${!!itemErrors[kpi.id]?.name ? "mt-[-12px]" : ""}`,
|
|
3538
|
+
children: [
|
|
3539
|
+
/* @__PURE__ */ jsx36(
|
|
3540
|
+
IconCheck2,
|
|
3541
|
+
{
|
|
3542
|
+
className: "w-[30px] h-[30px] cursor-pointer",
|
|
3543
|
+
onClick: () => handleSave(kpi.id, type)
|
|
3544
|
+
}
|
|
3545
|
+
),
|
|
3546
|
+
/* @__PURE__ */ jsx36(
|
|
3547
|
+
IconX2,
|
|
3548
|
+
{
|
|
3549
|
+
className: "w-[30px] h-[30px] cursor-pointer",
|
|
3550
|
+
onClick: () => handleCancel(kpi.id)
|
|
3551
|
+
}
|
|
3552
|
+
)
|
|
3553
|
+
]
|
|
3554
|
+
}
|
|
3555
|
+
)
|
|
3556
|
+
] }) : /* @__PURE__ */ jsxs31(Fragment6, { children: [
|
|
3557
|
+
/* @__PURE__ */ jsx36("p", { className: "body-1", children: kpi.name }),
|
|
3558
|
+
/* @__PURE__ */ jsxs31("div", { className: "flex gap-3 justify-end", children: [
|
|
3559
|
+
/* @__PURE__ */ jsx36(
|
|
3560
|
+
IconPencil,
|
|
3561
|
+
{
|
|
3562
|
+
className: "w-[30px] h-[30px] cursor-pointer",
|
|
3563
|
+
onClick: () => handleEdit(kpi.id)
|
|
3564
|
+
}
|
|
3565
|
+
),
|
|
3566
|
+
/* @__PURE__ */ jsx36(
|
|
3567
|
+
IconTrash2,
|
|
3568
|
+
{
|
|
3569
|
+
className: "w-[30px] h-[30px] cursor-pointer",
|
|
3570
|
+
onClick: () => handleDelete(kpi.id)
|
|
3571
|
+
}
|
|
3572
|
+
)
|
|
3573
|
+
] })
|
|
3574
|
+
] })
|
|
3575
|
+
]
|
|
3576
|
+
},
|
|
3577
|
+
kpi.id
|
|
3578
|
+
)) })
|
|
3579
|
+
] })
|
|
3580
|
+
] })
|
|
3581
|
+
}
|
|
3582
|
+
);
|
|
3583
|
+
}
|
|
3092
3584
|
export {
|
|
3093
3585
|
AntDataTable,
|
|
3094
3586
|
Breadcrumbs,
|
|
@@ -3104,6 +3596,7 @@ export {
|
|
|
3104
3596
|
GhostButton,
|
|
3105
3597
|
HeadingPage,
|
|
3106
3598
|
InputField,
|
|
3599
|
+
KpiSection,
|
|
3107
3600
|
Loader,
|
|
3108
3601
|
MenuNavBar,
|
|
3109
3602
|
PrimaryButton,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@esic-lab/data-core-ui",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.23",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"module": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -64,8 +64,9 @@
|
|
|
64
64
|
"@tabler/icons-react": "^3.35.0",
|
|
65
65
|
"antd": "^5.27.3",
|
|
66
66
|
"classnames": "^2.5.1",
|
|
67
|
-
"
|
|
67
|
+
"cuid": "^3.0.0",
|
|
68
68
|
"d3": "^7.9.0",
|
|
69
|
+
"fullcalendar": "^6.1.19",
|
|
69
70
|
"qrcode": "^1.5.4"
|
|
70
71
|
},
|
|
71
72
|
"publishConfig": {
|