@esic-lab/data-core-ui 0.0.20 → 0.0.22
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 +66 -2
- package/dist/index.d.mts +31 -8
- package/dist/index.d.ts +31 -8
- package/dist/index.js +492 -16
- package/dist/index.mjs +497 -16
- package/package.json +3 -2
- package/dist/STO-logo-KFQUNTJ3.svg +0 -92
package/dist/index.js
CHANGED
|
@@ -475,6 +475,7 @@ __export(index_exports, {
|
|
|
475
475
|
GhostButton: () => GhostButton,
|
|
476
476
|
HeadingPage: () => HeadingPage,
|
|
477
477
|
InputField: () => InputField,
|
|
478
|
+
KpiSection: () => KpiSection,
|
|
478
479
|
Loader: () => Loader,
|
|
479
480
|
MenuNavBar: () => MenuNavBar,
|
|
480
481
|
PrimaryButton: () => PrimaryButton,
|
|
@@ -1170,7 +1171,8 @@ function InputField({
|
|
|
1170
1171
|
addonBefore,
|
|
1171
1172
|
addonAfter,
|
|
1172
1173
|
defaultValue,
|
|
1173
|
-
className
|
|
1174
|
+
className,
|
|
1175
|
+
onClear
|
|
1174
1176
|
}) {
|
|
1175
1177
|
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
1176
1178
|
import_antd2.ConfigProvider,
|
|
@@ -1197,7 +1199,8 @@ function InputField({
|
|
|
1197
1199
|
allowClear: true,
|
|
1198
1200
|
addonBefore,
|
|
1199
1201
|
addonAfter,
|
|
1200
|
-
defaultValue
|
|
1202
|
+
defaultValue,
|
|
1203
|
+
onClear
|
|
1201
1204
|
}
|
|
1202
1205
|
),
|
|
1203
1206
|
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { children: [
|
|
@@ -2284,7 +2287,8 @@ function ColorPalettePickerBasic({
|
|
|
2284
2287
|
allowClear,
|
|
2285
2288
|
defaultFormat,
|
|
2286
2289
|
className,
|
|
2287
|
-
placeholder = "\u0E01\u0E23\u0E38\u0E13\u0E32\u0E40\u0E25\u0E37\u0E2D\u0E01\u0E2A\u0E35"
|
|
2290
|
+
placeholder = "\u0E01\u0E23\u0E38\u0E13\u0E32\u0E40\u0E25\u0E37\u0E2D\u0E01\u0E2A\u0E35",
|
|
2291
|
+
onClear
|
|
2288
2292
|
}) {
|
|
2289
2293
|
const { token } = import_antd9.theme.useToken();
|
|
2290
2294
|
const presets = genPresets({
|
|
@@ -2328,7 +2332,8 @@ function ColorPalettePickerBasic({
|
|
|
2328
2332
|
")"
|
|
2329
2333
|
] });
|
|
2330
2334
|
},
|
|
2331
|
-
disabled
|
|
2335
|
+
disabled,
|
|
2336
|
+
onClear
|
|
2332
2337
|
}
|
|
2333
2338
|
),
|
|
2334
2339
|
/* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { children: [
|
|
@@ -2360,7 +2365,8 @@ function SelectField({
|
|
|
2360
2365
|
prefix,
|
|
2361
2366
|
prefixSize = 20,
|
|
2362
2367
|
handleSearch,
|
|
2363
|
-
className
|
|
2368
|
+
className,
|
|
2369
|
+
onClear
|
|
2364
2370
|
}) {
|
|
2365
2371
|
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
2366
2372
|
import_antd10.ConfigProvider,
|
|
@@ -2393,7 +2399,8 @@ function SelectField({
|
|
|
2393
2399
|
mode,
|
|
2394
2400
|
onSearch: handleSearch,
|
|
2395
2401
|
prefix: prefix ? /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { style: { width: prefixSize, height: prefixSize, display: "flex", alignItems: "center", justifyContent: "center" }, children: prefix }) : void 0,
|
|
2396
|
-
allowClear: true
|
|
2402
|
+
allowClear: true,
|
|
2403
|
+
onClear
|
|
2397
2404
|
}
|
|
2398
2405
|
),
|
|
2399
2406
|
/* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { children: [
|
|
@@ -2544,7 +2551,8 @@ function SelectFieldStatus({
|
|
|
2544
2551
|
placeholder,
|
|
2545
2552
|
optionFilterProp: "label",
|
|
2546
2553
|
filterOption: (input, option) => (option?.label ?? "").toString().toLowerCase().includes(input.toLowerCase()),
|
|
2547
|
-
options
|
|
2554
|
+
options,
|
|
2555
|
+
showSearch: true
|
|
2548
2556
|
}
|
|
2549
2557
|
),
|
|
2550
2558
|
/* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { children: [
|
|
@@ -2579,7 +2587,8 @@ function SelectFieldStatusReport({
|
|
|
2579
2587
|
disabled,
|
|
2580
2588
|
showError,
|
|
2581
2589
|
errorMessage,
|
|
2582
|
-
className
|
|
2590
|
+
className,
|
|
2591
|
+
options
|
|
2583
2592
|
}) {
|
|
2584
2593
|
const selectedItem = status2.find((s) => s.value === value);
|
|
2585
2594
|
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
@@ -2614,12 +2623,9 @@ function SelectFieldStatusReport({
|
|
|
2614
2623
|
className: `body-3 custom-select flex justify-center w-full ${className ?? ""}`,
|
|
2615
2624
|
placeholder,
|
|
2616
2625
|
optionFilterProp: "label",
|
|
2617
|
-
|
|
2618
|
-
options
|
|
2619
|
-
|
|
2620
|
-
label: s.label,
|
|
2621
|
-
color: s.color
|
|
2622
|
-
}))
|
|
2626
|
+
filterOption: (input, option) => (option?.label ?? "").toString().toLowerCase().includes(input.toLowerCase()),
|
|
2627
|
+
options,
|
|
2628
|
+
showSearch: true
|
|
2623
2629
|
}
|
|
2624
2630
|
),
|
|
2625
2631
|
/* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { children: [
|
|
@@ -2646,7 +2652,8 @@ function SelectFieldTag({
|
|
|
2646
2652
|
errorMessage,
|
|
2647
2653
|
value: controlledValue,
|
|
2648
2654
|
className,
|
|
2649
|
-
onChange
|
|
2655
|
+
onChange,
|
|
2656
|
+
onClear
|
|
2650
2657
|
}) {
|
|
2651
2658
|
const [internalValue, setInternalValue] = (0, import_react8.useState)([]);
|
|
2652
2659
|
const isControlled = controlledValue !== void 0;
|
|
@@ -2698,7 +2705,8 @@ function SelectFieldTag({
|
|
|
2698
2705
|
},
|
|
2699
2706
|
searchValue: searchWord,
|
|
2700
2707
|
options,
|
|
2701
|
-
allowClear: true
|
|
2708
|
+
allowClear: true,
|
|
2709
|
+
onClear
|
|
2702
2710
|
}
|
|
2703
2711
|
),
|
|
2704
2712
|
/* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("div", { children: [
|
|
@@ -3141,6 +3149,473 @@ function ProgressBar({
|
|
|
3141
3149
|
}
|
|
3142
3150
|
);
|
|
3143
3151
|
}
|
|
3152
|
+
|
|
3153
|
+
// src/KpiSection/KpiSection.tsx
|
|
3154
|
+
var import_antd20 = require("antd");
|
|
3155
|
+
var import_react13 = require("react");
|
|
3156
|
+
|
|
3157
|
+
// src/KpiSection/hooks/useGetKpiSection.ts
|
|
3158
|
+
var import_react12 = require("react");
|
|
3159
|
+
var import_cuid = __toESM(require("cuid"));
|
|
3160
|
+
function useGetKpiSection() {
|
|
3161
|
+
const [nameKpi, setNameKpi] = (0, import_react12.useState)("");
|
|
3162
|
+
const [kpiValue, setKpiValue] = (0, import_react12.useState)("");
|
|
3163
|
+
const [unitValue, setUnitValue] = (0, import_react12.useState)("");
|
|
3164
|
+
const [kpiList, setKpiList] = (0, import_react12.useState)([]);
|
|
3165
|
+
const [editingBackup, setEditingBackup] = (0, import_react12.useState)({});
|
|
3166
|
+
const [selected, setSelected] = (0, import_react12.useState)("2");
|
|
3167
|
+
const [errors, setErrors] = (0, import_react12.useState)({
|
|
3168
|
+
nameKpi: "",
|
|
3169
|
+
kpiValue: "",
|
|
3170
|
+
unitValue: ""
|
|
3171
|
+
});
|
|
3172
|
+
const [itemErrors, setItemErrors] = (0, import_react12.useState)({});
|
|
3173
|
+
const options = [
|
|
3174
|
+
{ value: "1", label: "\u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21" },
|
|
3175
|
+
{ value: "2", label: "\u0E15\u0E31\u0E27\u0E40\u0E25\u0E02" }
|
|
3176
|
+
];
|
|
3177
|
+
const handleAddKpi = (type) => {
|
|
3178
|
+
let newErrors = { nameKpi: "", kpiValue: "", unitValue: "" };
|
|
3179
|
+
let hasError = false;
|
|
3180
|
+
if (!nameKpi) {
|
|
3181
|
+
newErrors.nameKpi = "\u0E42\u0E1B\u0E23\u0E14\u0E23\u0E30\u0E1A\u0E38";
|
|
3182
|
+
hasError = true;
|
|
3183
|
+
}
|
|
3184
|
+
if (type === "number") {
|
|
3185
|
+
if (!kpiValue) {
|
|
3186
|
+
newErrors.kpiValue = "\u0E42\u0E1B\u0E23\u0E14\u0E23\u0E30\u0E1A\u0E38";
|
|
3187
|
+
hasError = true;
|
|
3188
|
+
}
|
|
3189
|
+
if (!unitValue) {
|
|
3190
|
+
newErrors.unitValue = "\u0E42\u0E1B\u0E23\u0E14\u0E23\u0E30\u0E1A\u0E38";
|
|
3191
|
+
hasError = true;
|
|
3192
|
+
}
|
|
3193
|
+
}
|
|
3194
|
+
setErrors(newErrors);
|
|
3195
|
+
if (hasError) return;
|
|
3196
|
+
const newKpi = {
|
|
3197
|
+
id: (0, import_cuid.default)(),
|
|
3198
|
+
name: nameKpi,
|
|
3199
|
+
value: kpiValue,
|
|
3200
|
+
unit: unitValue,
|
|
3201
|
+
isEditing: false
|
|
3202
|
+
};
|
|
3203
|
+
setKpiList([...kpiList, newKpi]);
|
|
3204
|
+
setNameKpi("");
|
|
3205
|
+
setKpiValue("");
|
|
3206
|
+
setUnitValue("");
|
|
3207
|
+
setErrors({ nameKpi: "", kpiValue: "", unitValue: "" });
|
|
3208
|
+
};
|
|
3209
|
+
const handleEdit = (id) => {
|
|
3210
|
+
const current = kpiList.find((kpi) => kpi.id === id);
|
|
3211
|
+
if (current) {
|
|
3212
|
+
setEditingBackup((prev) => ({ ...prev, [id]: { ...current } }));
|
|
3213
|
+
}
|
|
3214
|
+
setKpiList(
|
|
3215
|
+
(prev) => prev.map((item) => item.id === id ? { ...item, isEditing: true } : item)
|
|
3216
|
+
);
|
|
3217
|
+
};
|
|
3218
|
+
const handleSave = (id, type) => {
|
|
3219
|
+
setKpiList((prev) => {
|
|
3220
|
+
return prev.map((item) => {
|
|
3221
|
+
if (item.id === id) {
|
|
3222
|
+
let hasError = false;
|
|
3223
|
+
const errorsForItem = {};
|
|
3224
|
+
if (!item.name) {
|
|
3225
|
+
errorsForItem.name = "\u0E42\u0E1B\u0E23\u0E14\u0E23\u0E30\u0E1A\u0E38";
|
|
3226
|
+
hasError = true;
|
|
3227
|
+
}
|
|
3228
|
+
if (type === "number") {
|
|
3229
|
+
if (!item.value) {
|
|
3230
|
+
errorsForItem.value = "\u0E42\u0E1B\u0E23\u0E14\u0E23\u0E30\u0E1A\u0E38";
|
|
3231
|
+
hasError = true;
|
|
3232
|
+
}
|
|
3233
|
+
if (!item.unit) {
|
|
3234
|
+
errorsForItem.unit = "\u0E42\u0E1B\u0E23\u0E14\u0E23\u0E30\u0E1A\u0E38";
|
|
3235
|
+
hasError = true;
|
|
3236
|
+
}
|
|
3237
|
+
}
|
|
3238
|
+
if (hasError) {
|
|
3239
|
+
setItemErrors((prev2) => ({ ...prev2, [id]: errorsForItem }));
|
|
3240
|
+
return item;
|
|
3241
|
+
}
|
|
3242
|
+
setItemErrors((prev2) => {
|
|
3243
|
+
const copy = { ...prev2 };
|
|
3244
|
+
delete copy[id];
|
|
3245
|
+
return copy;
|
|
3246
|
+
});
|
|
3247
|
+
return { ...item, isEditing: false };
|
|
3248
|
+
}
|
|
3249
|
+
return item;
|
|
3250
|
+
});
|
|
3251
|
+
});
|
|
3252
|
+
};
|
|
3253
|
+
const handleCancel = (id) => {
|
|
3254
|
+
const backup = editingBackup[id];
|
|
3255
|
+
if (backup) {
|
|
3256
|
+
setKpiList(
|
|
3257
|
+
(prev) => prev.map(
|
|
3258
|
+
(item) => item.id === id ? { ...backup, isEditing: false } : item
|
|
3259
|
+
)
|
|
3260
|
+
);
|
|
3261
|
+
setEditingBackup((prev) => {
|
|
3262
|
+
const copy = { ...prev };
|
|
3263
|
+
delete copy[id];
|
|
3264
|
+
return copy;
|
|
3265
|
+
});
|
|
3266
|
+
} else {
|
|
3267
|
+
setKpiList(
|
|
3268
|
+
(prev) => prev.map(
|
|
3269
|
+
(item) => item.id === id ? { ...item, isEditing: false } : item
|
|
3270
|
+
)
|
|
3271
|
+
);
|
|
3272
|
+
}
|
|
3273
|
+
};
|
|
3274
|
+
const handleDelete = (id) => {
|
|
3275
|
+
setKpiList((prev) => prev.filter((item) => item.id !== id));
|
|
3276
|
+
};
|
|
3277
|
+
return {
|
|
3278
|
+
handleAddKpi,
|
|
3279
|
+
handleEdit,
|
|
3280
|
+
handleSave,
|
|
3281
|
+
handleCancel,
|
|
3282
|
+
handleDelete,
|
|
3283
|
+
nameKpi,
|
|
3284
|
+
setNameKpi,
|
|
3285
|
+
kpiValue,
|
|
3286
|
+
setKpiValue,
|
|
3287
|
+
unitValue,
|
|
3288
|
+
setUnitValue,
|
|
3289
|
+
kpiList,
|
|
3290
|
+
setKpiList,
|
|
3291
|
+
editingBackup,
|
|
3292
|
+
setEditingBackup,
|
|
3293
|
+
options,
|
|
3294
|
+
selected,
|
|
3295
|
+
setSelected,
|
|
3296
|
+
errors,
|
|
3297
|
+
setErrors,
|
|
3298
|
+
itemErrors,
|
|
3299
|
+
setItemErrors
|
|
3300
|
+
};
|
|
3301
|
+
}
|
|
3302
|
+
|
|
3303
|
+
// src/KpiSection/KpiSection.tsx
|
|
3304
|
+
var import_icons_react10 = require("@tabler/icons-react");
|
|
3305
|
+
var import_jsx_runtime36 = require("react/jsx-runtime");
|
|
3306
|
+
function KpiSection({ type, onChangeKpiList }) {
|
|
3307
|
+
const {
|
|
3308
|
+
handleAddKpi,
|
|
3309
|
+
handleEdit,
|
|
3310
|
+
handleSave,
|
|
3311
|
+
handleCancel,
|
|
3312
|
+
handleDelete,
|
|
3313
|
+
nameKpi,
|
|
3314
|
+
setNameKpi,
|
|
3315
|
+
kpiValue,
|
|
3316
|
+
setKpiValue,
|
|
3317
|
+
unitValue,
|
|
3318
|
+
setUnitValue,
|
|
3319
|
+
kpiList,
|
|
3320
|
+
setKpiList,
|
|
3321
|
+
errors,
|
|
3322
|
+
itemErrors,
|
|
3323
|
+
setItemErrors
|
|
3324
|
+
} = useGetKpiSection();
|
|
3325
|
+
const [messageApi2, messageContainer] = import_antd20.message.useMessage();
|
|
3326
|
+
const [hasShownError, setHasShownError] = (0, import_react13.useState)(false);
|
|
3327
|
+
(0, import_react13.useEffect)(() => {
|
|
3328
|
+
setMessageApi(messageApi2);
|
|
3329
|
+
}, [messageApi2]);
|
|
3330
|
+
(0, import_react13.useEffect)(() => {
|
|
3331
|
+
if (onChangeKpiList) {
|
|
3332
|
+
onChangeKpiList(kpiList);
|
|
3333
|
+
}
|
|
3334
|
+
}, [kpiList]);
|
|
3335
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
3336
|
+
import_antd20.ConfigProvider,
|
|
3337
|
+
{
|
|
3338
|
+
theme: {
|
|
3339
|
+
token: {
|
|
3340
|
+
fontFamily: "Kanit",
|
|
3341
|
+
fontSize: 16
|
|
3342
|
+
}
|
|
3343
|
+
},
|
|
3344
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: "container-input", children: [
|
|
3345
|
+
messageContainer,
|
|
3346
|
+
type === "number" && /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: "space-y-4", children: [
|
|
3347
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: "grid grid-cols-[1fr_200px_200px_50px] w-full gap-[24px] items-start", children: [
|
|
3348
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
3349
|
+
InputField,
|
|
3350
|
+
{
|
|
3351
|
+
value: nameKpi,
|
|
3352
|
+
title: "\u0E0A\u0E37\u0E48\u0E2D\u0E1C\u0E25\u0E25\u0E31\u0E1E\u0E18\u0E4C\u0E17\u0E35\u0E48\u0E04\u0E32\u0E14\u0E2B\u0E27\u0E31\u0E07 (KPI)",
|
|
3353
|
+
placeholder: "\u0E42\u0E1B\u0E23\u0E14\u0E23\u0E30\u0E1A\u0E38",
|
|
3354
|
+
require: true,
|
|
3355
|
+
onChange: (value) => setNameKpi(value ?? ""),
|
|
3356
|
+
className: "h-[32px]",
|
|
3357
|
+
showError: !!errors.nameKpi,
|
|
3358
|
+
errorMessage: errors.nameKpi
|
|
3359
|
+
}
|
|
3360
|
+
),
|
|
3361
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
3362
|
+
InputField,
|
|
3363
|
+
{
|
|
3364
|
+
value: kpiValue,
|
|
3365
|
+
title: "\u0E1C\u0E25\u0E25\u0E31\u0E1E\u0E18\u0E4C\u0E17\u0E35\u0E48\u0E04\u0E32\u0E14\u0E2B\u0E27\u0E31\u0E07 (KPI)",
|
|
3366
|
+
placeholder: "\u0E42\u0E1B\u0E23\u0E14\u0E23\u0E30\u0E1A\u0E38",
|
|
3367
|
+
require: true,
|
|
3368
|
+
onChange: (value) => {
|
|
3369
|
+
if (value === void 0 || value === "") {
|
|
3370
|
+
setKpiValue("");
|
|
3371
|
+
setHasShownError(false);
|
|
3372
|
+
} else if (/^\d*\.?\d*$/.test(value)) {
|
|
3373
|
+
setKpiValue(value);
|
|
3374
|
+
setHasShownError(false);
|
|
3375
|
+
} else {
|
|
3376
|
+
if (!hasShownError) {
|
|
3377
|
+
messageError("\u0E01\u0E23\u0E38\u0E13\u0E32\u0E01\u0E23\u0E2D\u0E01\u0E15\u0E31\u0E27\u0E40\u0E25\u0E02\u0E40\u0E17\u0E48\u0E32\u0E19\u0E31\u0E49\u0E19");
|
|
3378
|
+
setHasShownError(true);
|
|
3379
|
+
}
|
|
3380
|
+
}
|
|
3381
|
+
},
|
|
3382
|
+
showError: !!errors.kpiValue,
|
|
3383
|
+
errorMessage: errors.kpiValue
|
|
3384
|
+
}
|
|
3385
|
+
),
|
|
3386
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
3387
|
+
InputField,
|
|
3388
|
+
{
|
|
3389
|
+
value: unitValue,
|
|
3390
|
+
title: "\u0E2B\u0E19\u0E48\u0E27\u0E22",
|
|
3391
|
+
placeholder: "\u0E42\u0E1B\u0E23\u0E14\u0E23\u0E30\u0E1A\u0E38",
|
|
3392
|
+
require: true,
|
|
3393
|
+
onChange: (value) => setUnitValue(value ?? ""),
|
|
3394
|
+
className: "h-[32px]",
|
|
3395
|
+
showError: !!errors.unitValue,
|
|
3396
|
+
errorMessage: errors.unitValue
|
|
3397
|
+
}
|
|
3398
|
+
),
|
|
3399
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: "absolute top-21 right-5", children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
3400
|
+
import_icons_react10.IconCirclePlus,
|
|
3401
|
+
{
|
|
3402
|
+
className: "w-[40px] h-[40px] cursor-pointer hover:scale-110 transition",
|
|
3403
|
+
stroke: 1,
|
|
3404
|
+
onClick: () => handleAddKpi(type)
|
|
3405
|
+
}
|
|
3406
|
+
) })
|
|
3407
|
+
] }),
|
|
3408
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { children: kpiList.map((kpi, index) => /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
|
|
3409
|
+
"div",
|
|
3410
|
+
{
|
|
3411
|
+
className: "grid grid-cols-[30px_1fr_100px_120px_80px] items-start py-2 body-1 gap-[8px]",
|
|
3412
|
+
children: [
|
|
3413
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("p", { className: `body-1 ${kpi.isEditing ? "mt-[12px]" : ""}`, children: [
|
|
3414
|
+
index + 1,
|
|
3415
|
+
"."
|
|
3416
|
+
] }),
|
|
3417
|
+
kpi.isEditing ? /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(import_jsx_runtime36.Fragment, { children: [
|
|
3418
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
3419
|
+
InputField,
|
|
3420
|
+
{
|
|
3421
|
+
value: kpi.name,
|
|
3422
|
+
onChange: (value) => setKpiList(
|
|
3423
|
+
(prev) => prev.map(
|
|
3424
|
+
(item) => item.id === kpi.id ? { ...item, name: value ?? "" } : item
|
|
3425
|
+
)
|
|
3426
|
+
),
|
|
3427
|
+
showError: !!itemErrors[kpi.id]?.name,
|
|
3428
|
+
errorMessage: itemErrors[kpi.id]?.name
|
|
3429
|
+
}
|
|
3430
|
+
),
|
|
3431
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
3432
|
+
InputField,
|
|
3433
|
+
{
|
|
3434
|
+
value: kpi.value?.toString(),
|
|
3435
|
+
onChange: (value) => {
|
|
3436
|
+
if (value === void 0 || value === "") {
|
|
3437
|
+
setKpiList(
|
|
3438
|
+
(prev) => prev.map(
|
|
3439
|
+
(item) => item.id === kpi.id ? { ...item, value: "" } : item
|
|
3440
|
+
)
|
|
3441
|
+
);
|
|
3442
|
+
setHasShownError(false);
|
|
3443
|
+
} else if (/^\d*\.?\d*$/.test(value)) {
|
|
3444
|
+
setKpiList(
|
|
3445
|
+
(prev) => prev.map(
|
|
3446
|
+
(item) => item.id === kpi.id ? { ...item, value } : item
|
|
3447
|
+
)
|
|
3448
|
+
);
|
|
3449
|
+
setHasShownError(false);
|
|
3450
|
+
} else {
|
|
3451
|
+
if (!hasShownError) {
|
|
3452
|
+
messageError("\u0E01\u0E23\u0E38\u0E13\u0E32\u0E01\u0E23\u0E2D\u0E01\u0E15\u0E31\u0E27\u0E40\u0E25\u0E02\u0E40\u0E17\u0E48\u0E32\u0E19\u0E31\u0E49\u0E19");
|
|
3453
|
+
setHasShownError(true);
|
|
3454
|
+
}
|
|
3455
|
+
}
|
|
3456
|
+
},
|
|
3457
|
+
showError: !!itemErrors[kpi.id]?.value,
|
|
3458
|
+
errorMessage: itemErrors[kpi.id]?.value
|
|
3459
|
+
}
|
|
3460
|
+
),
|
|
3461
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
3462
|
+
InputField,
|
|
3463
|
+
{
|
|
3464
|
+
value: kpi.unit,
|
|
3465
|
+
onChange: (value) => setKpiList(
|
|
3466
|
+
(prev) => prev.map(
|
|
3467
|
+
(item) => item.id === kpi.id ? { ...item, unit: value ?? "" } : item
|
|
3468
|
+
)
|
|
3469
|
+
),
|
|
3470
|
+
showError: !!itemErrors[kpi.id]?.unit,
|
|
3471
|
+
errorMessage: itemErrors[kpi.id]?.unit
|
|
3472
|
+
}
|
|
3473
|
+
),
|
|
3474
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
|
|
3475
|
+
"div",
|
|
3476
|
+
{
|
|
3477
|
+
className: `flex gap-2 justify-end self-center ${!!itemErrors[kpi.id]?.value || !!itemErrors[kpi.id]?.unit || !!itemErrors[kpi.id]?.name ? "mt-[-12px]" : ""}`,
|
|
3478
|
+
children: [
|
|
3479
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
3480
|
+
import_icons_react10.IconCheck,
|
|
3481
|
+
{
|
|
3482
|
+
className: "w-[30px] h-[30px] cursor-pointer",
|
|
3483
|
+
onClick: () => handleSave(kpi.id, type)
|
|
3484
|
+
}
|
|
3485
|
+
),
|
|
3486
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
3487
|
+
import_icons_react10.IconX,
|
|
3488
|
+
{
|
|
3489
|
+
className: "w-[30px] h-[30px] cursor-pointer",
|
|
3490
|
+
onClick: () => handleCancel(kpi.id)
|
|
3491
|
+
}
|
|
3492
|
+
)
|
|
3493
|
+
]
|
|
3494
|
+
}
|
|
3495
|
+
)
|
|
3496
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(import_jsx_runtime36.Fragment, { children: [
|
|
3497
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("p", { className: "body-1", children: kpi.name }),
|
|
3498
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("p", { className: "body-1", children: kpi.value }),
|
|
3499
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("p", { className: "body-1", children: kpi.unit }),
|
|
3500
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: "flex gap-3 justify-end", children: [
|
|
3501
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
3502
|
+
import_icons_react10.IconPencil,
|
|
3503
|
+
{
|
|
3504
|
+
className: "w-[30px] h-[30px] cursor-pointer",
|
|
3505
|
+
onClick: () => handleEdit(kpi.id)
|
|
3506
|
+
}
|
|
3507
|
+
),
|
|
3508
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
3509
|
+
import_icons_react10.IconTrash,
|
|
3510
|
+
{
|
|
3511
|
+
className: "w-[30px] h-[30px] cursor-pointer",
|
|
3512
|
+
onClick: () => handleDelete(kpi.id)
|
|
3513
|
+
}
|
|
3514
|
+
)
|
|
3515
|
+
] })
|
|
3516
|
+
] })
|
|
3517
|
+
]
|
|
3518
|
+
},
|
|
3519
|
+
kpi.id
|
|
3520
|
+
)) })
|
|
3521
|
+
] }),
|
|
3522
|
+
type === "text" && /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: "space-y-4", children: [
|
|
3523
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: "grid grid-cols-[1fr_50px] w-full gap-[24px] items-start", children: [
|
|
3524
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
3525
|
+
InputField,
|
|
3526
|
+
{
|
|
3527
|
+
value: nameKpi,
|
|
3528
|
+
title: "\u0E0A\u0E37\u0E48\u0E2D\u0E1C\u0E25\u0E25\u0E31\u0E1E\u0E18\u0E4C\u0E17\u0E35\u0E48\u0E04\u0E32\u0E14\u0E2B\u0E27\u0E31\u0E07 (KPI)",
|
|
3529
|
+
placeholder: "\u0E42\u0E1B\u0E23\u0E14\u0E23\u0E30\u0E1A\u0E38",
|
|
3530
|
+
require: true,
|
|
3531
|
+
onChange: (value) => setNameKpi(value ?? ""),
|
|
3532
|
+
className: "h-[32px]",
|
|
3533
|
+
showError: !!errors.nameKpi,
|
|
3534
|
+
errorMessage: errors.nameKpi
|
|
3535
|
+
}
|
|
3536
|
+
),
|
|
3537
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: "absolute top-21 right-5", children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
3538
|
+
import_icons_react10.IconCirclePlus,
|
|
3539
|
+
{
|
|
3540
|
+
className: "w-[40px] h-[40px] cursor-pointer hover:scale-110 transition",
|
|
3541
|
+
stroke: 1,
|
|
3542
|
+
onClick: () => handleAddKpi(type)
|
|
3543
|
+
}
|
|
3544
|
+
) })
|
|
3545
|
+
] }),
|
|
3546
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { children: kpiList.map((kpi, index) => /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
|
|
3547
|
+
"div",
|
|
3548
|
+
{
|
|
3549
|
+
className: "grid grid-cols-[30px_1fr_80px] items-start py-2 body-1 gap-[8px]",
|
|
3550
|
+
children: [
|
|
3551
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("p", { className: `body-1 ${kpi.isEditing ? "mt-[12px]" : ""}`, children: [
|
|
3552
|
+
index + 1,
|
|
3553
|
+
"."
|
|
3554
|
+
] }),
|
|
3555
|
+
kpi.isEditing ? /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(import_jsx_runtime36.Fragment, { children: [
|
|
3556
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
3557
|
+
InputField,
|
|
3558
|
+
{
|
|
3559
|
+
value: kpi.name,
|
|
3560
|
+
onChange: (value) => setKpiList(
|
|
3561
|
+
(prev) => prev.map(
|
|
3562
|
+
(item) => item.id === kpi.id ? { ...item, name: value ?? "" } : item
|
|
3563
|
+
)
|
|
3564
|
+
),
|
|
3565
|
+
showError: !!itemErrors[kpi.id]?.name,
|
|
3566
|
+
errorMessage: itemErrors[kpi.id]?.name
|
|
3567
|
+
}
|
|
3568
|
+
),
|
|
3569
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
|
|
3570
|
+
"div",
|
|
3571
|
+
{
|
|
3572
|
+
className: `flex gap-2 justify-end self-center ${!!itemErrors[kpi.id]?.name ? "mt-[-12px]" : ""}`,
|
|
3573
|
+
children: [
|
|
3574
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
3575
|
+
import_icons_react10.IconCheck,
|
|
3576
|
+
{
|
|
3577
|
+
className: "w-[30px] h-[30px] cursor-pointer",
|
|
3578
|
+
onClick: () => handleSave(kpi.id, type)
|
|
3579
|
+
}
|
|
3580
|
+
),
|
|
3581
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
3582
|
+
import_icons_react10.IconX,
|
|
3583
|
+
{
|
|
3584
|
+
className: "w-[30px] h-[30px] cursor-pointer",
|
|
3585
|
+
onClick: () => handleCancel(kpi.id)
|
|
3586
|
+
}
|
|
3587
|
+
)
|
|
3588
|
+
]
|
|
3589
|
+
}
|
|
3590
|
+
)
|
|
3591
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(import_jsx_runtime36.Fragment, { children: [
|
|
3592
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("p", { className: "body-1", children: kpi.name }),
|
|
3593
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: "flex gap-3 justify-end", children: [
|
|
3594
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
3595
|
+
import_icons_react10.IconPencil,
|
|
3596
|
+
{
|
|
3597
|
+
className: "w-[30px] h-[30px] cursor-pointer",
|
|
3598
|
+
onClick: () => handleEdit(kpi.id)
|
|
3599
|
+
}
|
|
3600
|
+
),
|
|
3601
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
3602
|
+
import_icons_react10.IconTrash,
|
|
3603
|
+
{
|
|
3604
|
+
className: "w-[30px] h-[30px] cursor-pointer",
|
|
3605
|
+
onClick: () => handleDelete(kpi.id)
|
|
3606
|
+
}
|
|
3607
|
+
)
|
|
3608
|
+
] })
|
|
3609
|
+
] })
|
|
3610
|
+
]
|
|
3611
|
+
},
|
|
3612
|
+
kpi.id
|
|
3613
|
+
)) })
|
|
3614
|
+
] })
|
|
3615
|
+
] })
|
|
3616
|
+
}
|
|
3617
|
+
);
|
|
3618
|
+
}
|
|
3144
3619
|
// Annotate the CommonJS export names for ESM import in node:
|
|
3145
3620
|
0 && (module.exports = {
|
|
3146
3621
|
AntDataTable,
|
|
@@ -3157,6 +3632,7 @@ function ProgressBar({
|
|
|
3157
3632
|
GhostButton,
|
|
3158
3633
|
HeadingPage,
|
|
3159
3634
|
InputField,
|
|
3635
|
+
KpiSection,
|
|
3160
3636
|
Loader,
|
|
3161
3637
|
MenuNavBar,
|
|
3162
3638
|
PrimaryButton,
|