@undp/carbon-library 1.0.152 → 1.0.156-CARBON-343.0
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/cjs/index.js +109 -114
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/Components/Common/AntComponents/antTableComponents.d.ts +13 -14
- package/dist/esm/index.js +111 -116
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/Components/Common/AntComponents/antTableComponents.d.ts +13 -14
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
@@ -24455,60 +24455,16 @@ var RegistryDashboardComponent = function (props) {
|
|
24455
24455
|
lastUpdateTransferLocations))))))))) : ("")));
|
24456
24456
|
};
|
24457
24457
|
|
24458
|
-
|
24459
|
-
var EditableRow = function (_a) {
|
24460
|
-
_a.index; var props = __rest(_a, ["index"]);
|
24461
|
-
var form = antd.Form.useForm()[0];
|
24462
|
-
return (React.createElement(antd.Form, { form: form, component: false },
|
24463
|
-
React.createElement(EditableContext.Provider, { value: form },
|
24464
|
-
React.createElement("tr", __assign({}, props)))));
|
24465
|
-
};
|
24458
|
+
React.createContext(null);
|
24466
24459
|
var EditableCell = function (_a) {
|
24467
|
-
var
|
24468
|
-
var
|
24469
|
-
|
24470
|
-
|
24471
|
-
|
24472
|
-
|
24473
|
-
|
24474
|
-
}
|
24475
|
-
}, [editing]);
|
24476
|
-
var toggleEdit = function () {
|
24477
|
-
var _a;
|
24478
|
-
setEditing(!editing);
|
24479
|
-
form.setFieldsValue((_a = {}, _a[dataIndex] = record[dataIndex], _a));
|
24480
|
-
};
|
24481
|
-
var save = function () { return __awaiter(void 0, void 0, void 0, function () {
|
24482
|
-
var values, errInfo_1;
|
24483
|
-
return __generator(this, function (_a) {
|
24484
|
-
switch (_a.label) {
|
24485
|
-
case 0:
|
24486
|
-
_a.trys.push([0, 2, , 3]);
|
24487
|
-
return [4 /*yield*/, form.validateFields()];
|
24488
|
-
case 1:
|
24489
|
-
values = _a.sent();
|
24490
|
-
toggleEdit();
|
24491
|
-
handleSave(__assign(__assign({}, record), values));
|
24492
|
-
return [3 /*break*/, 3];
|
24493
|
-
case 2:
|
24494
|
-
errInfo_1 = _a.sent();
|
24495
|
-
console.log("Save failed:", errInfo_1);
|
24496
|
-
return [3 /*break*/, 3];
|
24497
|
-
case 3: return [2 /*return*/];
|
24498
|
-
}
|
24499
|
-
});
|
24500
|
-
}); };
|
24501
|
-
var childNode = children;
|
24502
|
-
if (editable) {
|
24503
|
-
childNode = editing ? (React.createElement(antd.Form.Item, { style: { margin: 0 }, name: dataIndex, rules: [
|
24504
|
-
{
|
24505
|
-
required: true,
|
24506
|
-
message: "".concat(title, " is required."),
|
24507
|
-
},
|
24508
|
-
] },
|
24509
|
-
React.createElement(antd.Input, { ref: inputRef, onPressEnter: save, onBlur: save }))) : (React.createElement("div", { className: "editable-cell-value-wrap", style: { paddingRight: 24, minWidth: "100px", minHeight: "20px" }, onClick: toggleEdit }, children));
|
24510
|
-
}
|
24511
|
-
return React.createElement("td", __assign({}, restProps), childNode);
|
24460
|
+
var editing = _a.editing, dataIndex = _a.dataIndex, title = _a.title, inputType = _a.inputType; _a.record; _a.index; var children = _a.children, restProps = __rest(_a, ["editing", "dataIndex", "title", "inputType", "record", "index", "children"]);
|
24461
|
+
var inputNode = inputType === "number" ? React.createElement(antd.InputNumber, null) : React.createElement(antd.Input, null);
|
24462
|
+
return (React.createElement("td", __assign({}, restProps), editing ? (React.createElement(antd.Form.Item, { name: dataIndex, style: { margin: 0 }, rules: [
|
24463
|
+
{
|
24464
|
+
required: true,
|
24465
|
+
message: "Please Input ".concat(title, "!"),
|
24466
|
+
},
|
24467
|
+
] }, inputNode)) : (children)));
|
24512
24468
|
};
|
24513
24469
|
|
24514
24470
|
var css_248z$4 = ".ndc-steps-actions {\n display: flex;\n flex-direction: row-reverse;\n margin-right: 1rem;\n justify-content: center; }\n .ndc-steps-actions .action-btn {\n border: 1px solid #16b1ff;\n color: #16b1ff;\n margin-right: 1rem; }\n .ndc-steps-actions .back-btn {\n border: 1px solid rgba(140, 140, 140, 0.7);\n color: rgba(140, 140, 140, 0.7);\n margin-right: 1rem; }\n .ndc-steps-actions .mg-left-1 {\n margin-left: 1rem; }\n";
|
@@ -24531,7 +24487,17 @@ var NdcDetailsComponent = function (props) {
|
|
24531
24487
|
var addedNdcDetailId = React.useRef(0);
|
24532
24488
|
var selectedNdcDetail = React.useRef({});
|
24533
24489
|
var _e = React.useState(0), tableKey = _e[0], setTableKey = _e[1];
|
24490
|
+
var form = antd.Form.useForm()[0];
|
24491
|
+
var _f = React.useState(""), editingKey = _f[0], setEditingKey = _f[1];
|
24534
24492
|
var userInfoState = useUserContext().userInfoState;
|
24493
|
+
var isEditing = function (record) { return record.key === editingKey; };
|
24494
|
+
var onEditRow = function (record) {
|
24495
|
+
form.setFieldsValue(__assign({ nationalPlanObj: "", kpi: "", ministry: "" }, record));
|
24496
|
+
setEditingKey(record.key);
|
24497
|
+
};
|
24498
|
+
var onEditCancel = function () {
|
24499
|
+
setEditingKey("");
|
24500
|
+
};
|
24535
24501
|
var isAddRangeVisible = function () {
|
24536
24502
|
return (((userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyRole) === exports.CompanyRole.MINISTRY ||
|
24537
24503
|
(userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyRole) === exports.CompanyRole.GOVERNMENT) &&
|
@@ -24544,37 +24510,63 @@ var NdcDetailsComponent = function (props) {
|
|
24544
24510
|
var inRange = function (num, min, max) {
|
24545
24511
|
return num >= min && num <= max;
|
24546
24512
|
};
|
24547
|
-
var
|
24548
|
-
|
24549
|
-
|
24550
|
-
|
24551
|
-
|
24552
|
-
|
24553
|
-
|
24554
|
-
|
24555
|
-
|
24556
|
-
|
24557
|
-
|
24558
|
-
|
24559
|
-
|
24560
|
-
|
24561
|
-
|
24562
|
-
|
24563
|
-
|
24513
|
+
var onHandleSave = function (record) { return __awaiter(void 0, void 0, void 0, function () {
|
24514
|
+
var updatedNdcDetails, editedData, index, parentIndex, parentItem, itemIndex, errInfo_1;
|
24515
|
+
return __generator(this, function (_a) {
|
24516
|
+
switch (_a.label) {
|
24517
|
+
case 0:
|
24518
|
+
_a.trys.push([0, 2, , 3]);
|
24519
|
+
updatedNdcDetails = __spreadArray([], ndcDetailsData, true);
|
24520
|
+
return [4 /*yield*/, form.validateFields()];
|
24521
|
+
case 1:
|
24522
|
+
editedData = (_a.sent());
|
24523
|
+
if (record) {
|
24524
|
+
if (record.type === NdcActionType.main) {
|
24525
|
+
index = updatedNdcDetails.findIndex(function (item) { return record.key === item.key; });
|
24526
|
+
updatedNdcDetails.splice(index, 1, __assign(__assign({}, record), editedData));
|
24527
|
+
setNdcDetailsData(updatedNdcDetails);
|
24528
|
+
}
|
24529
|
+
else {
|
24530
|
+
parentIndex = updatedNdcDetails.findIndex(function (item) { return record.ndcActionId === item.key; });
|
24531
|
+
parentItem = updatedNdcDetails[parentIndex];
|
24532
|
+
if (parentItem) {
|
24533
|
+
if (parentItem.subNdcDetails) {
|
24534
|
+
itemIndex = parentItem.subNdcDetails.findIndex(function (item) { return record.key === item.key; });
|
24535
|
+
if (itemIndex !== -1) {
|
24536
|
+
parentItem.subNdcDetails.splice(itemIndex, 1, __assign(__assign({}, record), editedData));
|
24537
|
+
}
|
24538
|
+
if (itemIndex + 1 === parentItem.subNdcDetails.length) {
|
24539
|
+
parentItem.subNdcDetails.push({
|
24540
|
+
key: ++addedNdcDetailId.current,
|
24541
|
+
ndcActionId: parentItem.key,
|
24542
|
+
type: NdcActionType.sub,
|
24543
|
+
startDate: new Date("2019-03-25"),
|
24544
|
+
endDate: new Date("2020-03-25"),
|
24545
|
+
nationalPlanObj: "",
|
24546
|
+
kpi: "",
|
24547
|
+
ministry: "",
|
24548
|
+
});
|
24549
|
+
}
|
24550
|
+
}
|
24551
|
+
updatedNdcDetails.splice(parentIndex, 1, __assign({}, parentItem));
|
24552
|
+
setNdcDetailsData(updatedNdcDetails);
|
24553
|
+
}
|
24554
|
+
}
|
24555
|
+
setEditingKey("");
|
24556
|
+
setTableKey(function (key) { return key + 1; });
|
24564
24557
|
}
|
24565
24558
|
else {
|
24566
|
-
|
24559
|
+
throw new Error("Save failed");
|
24567
24560
|
}
|
24568
|
-
|
24569
|
-
|
24570
|
-
|
24571
|
-
|
24561
|
+
return [3 /*break*/, 3];
|
24562
|
+
case 2:
|
24563
|
+
errInfo_1 = _a.sent();
|
24564
|
+
console.log("Validate Failed:", errInfo_1);
|
24565
|
+
return [3 /*break*/, 3];
|
24566
|
+
case 3: return [2 /*return*/];
|
24572
24567
|
}
|
24573
|
-
|
24574
|
-
|
24575
|
-
setTableKey(function (key) { return key + 1; });
|
24576
|
-
}
|
24577
|
-
};
|
24568
|
+
});
|
24569
|
+
}); };
|
24578
24570
|
var getNdcDetailsForPeriod = function () {
|
24579
24571
|
var range = selectedTab.split("-");
|
24580
24572
|
if (range.length > 1) {
|
@@ -24604,6 +24596,8 @@ var NdcDetailsComponent = function (props) {
|
|
24604
24596
|
align: "left",
|
24605
24597
|
editable: true,
|
24606
24598
|
width: 800,
|
24599
|
+
render: function (_, record) { return (React.createElement(React.Fragment, null, record.nationalPlanObj ? (React.createElement(antd.Space, { size: "middle" },
|
24600
|
+
React.createElement("span", null, record.nationalPlanObj))) : (React.createElement("input", { className: "ant-input", disabled: true, type: "text" })))); },
|
24607
24601
|
},
|
24608
24602
|
{
|
24609
24603
|
title: t("ndc:ndcColumnsKpi"),
|
@@ -24612,6 +24606,8 @@ var NdcDetailsComponent = function (props) {
|
|
24612
24606
|
align: "left",
|
24613
24607
|
editable: true,
|
24614
24608
|
width: 100,
|
24609
|
+
render: function (_, record) { return (React.createElement(React.Fragment, null, record.nationalPlanObj ? (React.createElement(antd.Space, { size: "middle" },
|
24610
|
+
React.createElement("span", null, record.kpi))) : (React.createElement("input", { className: "ant-input", disabled: true, type: "text" })))); },
|
24615
24611
|
},
|
24616
24612
|
{
|
24617
24613
|
title: "Ministry",
|
@@ -24619,6 +24615,24 @@ var NdcDetailsComponent = function (props) {
|
|
24619
24615
|
key: "ministry",
|
24620
24616
|
align: "left",
|
24621
24617
|
editable: true,
|
24618
|
+
render: function (_, record) { return (React.createElement(React.Fragment, null, record.nationalPlanObj ? (React.createElement(antd.Space, { size: "middle" },
|
24619
|
+
React.createElement("span", null, record.ministry))) : (React.createElement("input", { className: "ant-input", disabled: true, type: "text" })))); },
|
24620
|
+
},
|
24621
|
+
{
|
24622
|
+
title: "Action",
|
24623
|
+
dataIndex: "operation",
|
24624
|
+
render: function (_, record) {
|
24625
|
+
var editable = isEditing(record);
|
24626
|
+
return editable ? (React.createElement("span", null,
|
24627
|
+
React.createElement(antd.Tooltip, { title: "Save" },
|
24628
|
+
React.createElement(antd.Typography.Link, { onClick: function () { return onHandleSave(record); }, style: { marginRight: 20 } },
|
24629
|
+
React.createElement(icons.SaveOutlined, null))),
|
24630
|
+
React.createElement(antd.Tooltip, { title: "Cancel" },
|
24631
|
+
React.createElement(antd.Typography.Link, { onClick: onEditCancel, style: { marginRight: 8 } },
|
24632
|
+
React.createElement(icons.ExclamationCircleOutlined, null))))) : (React.createElement(antd.Tooltip, { title: "Edit" },
|
24633
|
+
React.createElement(antd.Typography.Link, { disabled: editingKey !== "", onClick: function () { return onEditRow(record); } },
|
24634
|
+
React.createElement(icons.EditOutlined, null))));
|
24635
|
+
},
|
24622
24636
|
},
|
24623
24637
|
];
|
24624
24638
|
var columns = defaultColumns.map(function (col) {
|
@@ -24630,7 +24644,7 @@ var NdcDetailsComponent = function (props) {
|
|
24630
24644
|
editable: col.editable,
|
24631
24645
|
dataIndex: col.dataIndex,
|
24632
24646
|
title: col.title,
|
24633
|
-
|
24647
|
+
editing: isEditing(record),
|
24634
24648
|
}); } });
|
24635
24649
|
});
|
24636
24650
|
function onAddNewNdcDetail() {
|
@@ -24661,32 +24675,11 @@ var NdcDetailsComponent = function (props) {
|
|
24661
24675
|
}
|
24662
24676
|
var components = {
|
24663
24677
|
body: {
|
24664
|
-
row: EditableRow,
|
24665
24678
|
cell: EditableCell,
|
24666
24679
|
},
|
24667
24680
|
};
|
24668
|
-
//commented because rendering issue
|
24669
24681
|
function ndcDetailsTableContent() {
|
24670
|
-
return
|
24671
|
-
// <div>
|
24672
|
-
// <Button
|
24673
|
-
// onClick={onAddNewNdcDetail}
|
24674
|
-
// type="primary"
|
24675
|
-
// style={{
|
24676
|
-
// marginBottom: 16,
|
24677
|
-
// }}
|
24678
|
-
// >
|
24679
|
-
// Add a row
|
24680
|
-
// </Button>
|
24681
|
-
// <Table
|
24682
|
-
// components={components}
|
24683
|
-
// rowClassName={() => 'editable-row'}
|
24684
|
-
// bordered
|
24685
|
-
// dataSource={ndcDetailsData}
|
24686
|
-
// columns={columns}
|
24687
|
-
// />
|
24688
|
-
// </div>
|
24689
|
-
);
|
24682
|
+
return React.createElement("div", null);
|
24690
24683
|
}
|
24691
24684
|
var onCancelPeriod = function () { };
|
24692
24685
|
var onAddNewPeriod = function () {
|
@@ -24743,6 +24736,7 @@ var NdcDetailsComponent = function (props) {
|
|
24743
24736
|
}
|
24744
24737
|
var onTabChange = function (key) {
|
24745
24738
|
setSelectedTab(key);
|
24739
|
+
setEditingKey("");
|
24746
24740
|
};
|
24747
24741
|
React.useEffect(function () {
|
24748
24742
|
var defaultNdcDetails = [
|
@@ -24944,17 +24938,18 @@ var NdcDetailsComponent = function (props) {
|
|
24944
24938
|
React.createElement(antd.Tabs, { centered: false, defaultActiveKey: "1", items: periodItems, activeKey: selectedTab, onChange: onTabChange })),
|
24945
24939
|
selectedTab !== "add_new" && (React.createElement("div", null,
|
24946
24940
|
React.createElement("div", null,
|
24947
|
-
React.createElement(antd.
|
24948
|
-
|
24949
|
-
|
24950
|
-
|
24951
|
-
|
24952
|
-
|
24953
|
-
React.createElement(antd.
|
24954
|
-
|
24955
|
-
|
24956
|
-
|
24957
|
-
|
24941
|
+
React.createElement(antd.Form, { form: form, component: false },
|
24942
|
+
React.createElement(antd.Table, { key: tableKey, components: components, rowClassName: function () { return "editable-row"; }, bordered: true, dataSource: getNdcDetailsForPeriod(), columns: columns, expandable: {
|
24943
|
+
expandedRowRender: function (record) { return getSubNdcActionContent(record); },
|
24944
|
+
indentSize: 0,
|
24945
|
+
defaultExpandedRowKeys: [selectedNdcDetail.current.key],
|
24946
|
+
}, footer: function () {
|
24947
|
+
return isAddNdcActionVisible() && (React.createElement(antd.Row, { justify: "center" },
|
24948
|
+
React.createElement(antd.Button, { onClick: onAddNewNdcDetail, type: "default", style: {
|
24949
|
+
marginBottom: 16,
|
24950
|
+
width: "100%",
|
24951
|
+
} }, t("ndc:addNdcAction"))));
|
24952
|
+
} })))))));
|
24958
24953
|
};
|
24959
24954
|
|
24960
24955
|
var ImgWithFallback = function (_a) {
|