@undp/carbon-library 1.0.158-CARBON-343.0 → 1.0.158-CARBON-343.2
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/cjs/index.js +123 -111
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/Components/Common/AntComponents/antTableComponents.d.ts +14 -13
- package/dist/esm/index.js +125 -113
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/Components/Common/AntComponents/antTableComponents.d.ts +14 -13
- package/package.json +1 -1
@@ -1,20 +1,21 @@
|
|
1
1
|
import React from "react";
|
2
|
-
|
2
|
+
interface Item {
|
3
3
|
key: string;
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
};
|
10
|
-
interface EditableCellProps extends React.HTMLAttributes<HTMLElement> {
|
11
|
-
editing: boolean;
|
12
|
-
dataIndex: string;
|
13
|
-
title: any;
|
14
|
-
inputType: "number" | "text";
|
15
|
-
record: NdcDetail;
|
4
|
+
name: string;
|
5
|
+
age: string;
|
6
|
+
address: string;
|
7
|
+
}
|
8
|
+
interface EditableRowProps {
|
16
9
|
index: number;
|
10
|
+
}
|
11
|
+
export declare const EditableRow: React.FC<EditableRowProps>;
|
12
|
+
interface EditableCellProps {
|
13
|
+
title: React.ReactNode;
|
14
|
+
editable: boolean;
|
17
15
|
children: React.ReactNode;
|
16
|
+
dataIndex: keyof Item;
|
17
|
+
record: Item;
|
18
|
+
handleSave: (record: Item) => void;
|
18
19
|
}
|
19
20
|
export declare const EditableCell: React.FC<EditableCellProps>;
|
20
21
|
export {};
|
package/dist/esm/index.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
import { PlusOutlined, FilterOutlined, BankOutlined, SafetyOutlined, AuditOutlined, ExperimentOutlined, UploadOutlined, UserOutlined, MinusCircleOutlined, StarOutlined, ToolOutlined, EyeOutlined, SearchOutlined, EllipsisOutlined, EditOutlined, DeleteOutlined, FileAddOutlined, CheckCircleOutlined, ExclamationCircleOutlined, BookOutlined, CaretDownOutlined,
|
1
|
+
import { PlusOutlined, FilterOutlined, BankOutlined, SafetyOutlined, AuditOutlined, ExperimentOutlined, UploadOutlined, UserOutlined, MinusCircleOutlined, StarOutlined, ToolOutlined, EyeOutlined, SearchOutlined, EllipsisOutlined, EditOutlined, DeleteOutlined, FileAddOutlined, CheckCircleOutlined, ExclamationCircleOutlined, BookOutlined, CaretDownOutlined, EyeInvisibleOutlined, GlobalOutlined, FlagOutlined, LineChartOutlined, LikeOutlined, DislikeOutlined } from '@ant-design/icons';
|
2
2
|
import { Input, Radio, Space, Row, Col, Button, Dropdown, Table, Empty, message, Form, Steps, Upload, Tooltip, Select, Modal, Alert, Skeleton, Card, Tag, Checkbox, DatePicker, InputNumber, Popover, List, Typography, Spin, Tabs, Progress } from 'antd';
|
3
|
-
import React, { useState, useEffect, useRef } from 'react';
|
3
|
+
import React, { useState, useEffect, useRef, useContext } from 'react';
|
4
4
|
import { DateTime } from 'luxon';
|
5
5
|
import { Buffer } from 'buffer';
|
6
6
|
import PhoneInput, { formatPhoneNumberIntl, formatPhoneNumber } from 'react-phone-number-input';
|
@@ -24435,16 +24435,60 @@ var RegistryDashboardComponent = function (props) {
|
|
24435
24435
|
lastUpdateTransferLocations))))))))) : ("")));
|
24436
24436
|
};
|
24437
24437
|
|
24438
|
-
React.createContext(null);
|
24438
|
+
var EditableContext = React.createContext(null);
|
24439
|
+
var EditableRow = function (_a) {
|
24440
|
+
_a.index; var props = __rest(_a, ["index"]);
|
24441
|
+
var form = Form.useForm()[0];
|
24442
|
+
return (React.createElement(Form, { form: form, component: false },
|
24443
|
+
React.createElement(EditableContext.Provider, { value: form },
|
24444
|
+
React.createElement("tr", __assign({}, props)))));
|
24445
|
+
};
|
24439
24446
|
var EditableCell = function (_a) {
|
24440
|
-
var
|
24441
|
-
var
|
24442
|
-
|
24443
|
-
|
24444
|
-
|
24445
|
-
|
24446
|
-
|
24447
|
-
|
24447
|
+
var title = _a.title, editable = _a.editable, children = _a.children, dataIndex = _a.dataIndex, record = _a.record, handleSave = _a.handleSave, restProps = __rest(_a, ["title", "editable", "children", "dataIndex", "record", "handleSave"]);
|
24448
|
+
var _b = useState(false), editing = _b[0], setEditing = _b[1];
|
24449
|
+
var inputRef = useRef(null);
|
24450
|
+
var form = useContext(EditableContext);
|
24451
|
+
useEffect(function () {
|
24452
|
+
if (editing) {
|
24453
|
+
inputRef.current.focus();
|
24454
|
+
}
|
24455
|
+
}, [editing]);
|
24456
|
+
var toggleEdit = function () {
|
24457
|
+
var _a;
|
24458
|
+
setEditing(!editing);
|
24459
|
+
form.setFieldsValue((_a = {}, _a[dataIndex] = record[dataIndex], _a));
|
24460
|
+
};
|
24461
|
+
var save = function () { return __awaiter(void 0, void 0, void 0, function () {
|
24462
|
+
var values, errInfo_1;
|
24463
|
+
return __generator(this, function (_a) {
|
24464
|
+
switch (_a.label) {
|
24465
|
+
case 0:
|
24466
|
+
_a.trys.push([0, 2, , 3]);
|
24467
|
+
return [4 /*yield*/, form.validateFields()];
|
24468
|
+
case 1:
|
24469
|
+
values = _a.sent();
|
24470
|
+
toggleEdit();
|
24471
|
+
handleSave(__assign(__assign({}, record), values));
|
24472
|
+
return [3 /*break*/, 3];
|
24473
|
+
case 2:
|
24474
|
+
errInfo_1 = _a.sent();
|
24475
|
+
console.log("Save failed:", errInfo_1);
|
24476
|
+
return [3 /*break*/, 3];
|
24477
|
+
case 3: return [2 /*return*/];
|
24478
|
+
}
|
24479
|
+
});
|
24480
|
+
}); };
|
24481
|
+
var childNode = children;
|
24482
|
+
if (editable) {
|
24483
|
+
childNode = editing ? (React.createElement(Form.Item, { style: { margin: 0 }, name: dataIndex, rules: [
|
24484
|
+
{
|
24485
|
+
required: true,
|
24486
|
+
message: "".concat(title, " is required."),
|
24487
|
+
},
|
24488
|
+
] },
|
24489
|
+
React.createElement(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));
|
24490
|
+
}
|
24491
|
+
return React.createElement("td", __assign({}, restProps), childNode);
|
24448
24492
|
};
|
24449
24493
|
|
24450
24494
|
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";
|
@@ -24467,17 +24511,7 @@ var NdcDetailsComponent = function (props) {
|
|
24467
24511
|
var addedNdcDetailId = useRef(0);
|
24468
24512
|
var selectedNdcDetail = useRef({});
|
24469
24513
|
var _e = useState(0), tableKey = _e[0], setTableKey = _e[1];
|
24470
|
-
var form = Form.useForm()[0];
|
24471
|
-
var _f = useState(""), editingKey = _f[0], setEditingKey = _f[1];
|
24472
24514
|
var userInfoState = useUserContext().userInfoState;
|
24473
|
-
var isEditing = function (record) { return record.key === editingKey; };
|
24474
|
-
var onEditRow = function (record) {
|
24475
|
-
form.setFieldsValue(__assign({ nationalPlanObj: "", kpi: "", ministry: "" }, record));
|
24476
|
-
setEditingKey(record.key);
|
24477
|
-
};
|
24478
|
-
var onEditCancel = function () {
|
24479
|
-
setEditingKey("");
|
24480
|
-
};
|
24481
24515
|
var isAddRangeVisible = function () {
|
24482
24516
|
return (((userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyRole) === CompanyRole.MINISTRY ||
|
24483
24517
|
(userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyRole) === CompanyRole.GOVERNMENT) &&
|
@@ -24490,63 +24524,37 @@ var NdcDetailsComponent = function (props) {
|
|
24490
24524
|
var inRange = function (num, min, max) {
|
24491
24525
|
return num >= min && num <= max;
|
24492
24526
|
};
|
24493
|
-
var
|
24494
|
-
|
24495
|
-
|
24496
|
-
|
24497
|
-
|
24498
|
-
|
24499
|
-
|
24500
|
-
|
24501
|
-
|
24502
|
-
|
24503
|
-
|
24504
|
-
|
24505
|
-
|
24506
|
-
|
24507
|
-
|
24508
|
-
|
24509
|
-
|
24510
|
-
parentIndex = updatedNdcDetails.findIndex(function (item) { return record.ndcActionId === item.key; });
|
24511
|
-
parentItem = updatedNdcDetails[parentIndex];
|
24512
|
-
if (parentItem) {
|
24513
|
-
if (parentItem.subNdcDetails) {
|
24514
|
-
itemIndex = parentItem.subNdcDetails.findIndex(function (item) { return record.key === item.key; });
|
24515
|
-
if (itemIndex !== -1) {
|
24516
|
-
parentItem.subNdcDetails.splice(itemIndex, 1, __assign(__assign({}, record), editedData));
|
24517
|
-
}
|
24518
|
-
if (itemIndex + 1 === parentItem.subNdcDetails.length) {
|
24519
|
-
parentItem.subNdcDetails.push({
|
24520
|
-
key: ++addedNdcDetailId.current,
|
24521
|
-
ndcActionId: parentItem.key,
|
24522
|
-
type: NdcActionType.sub,
|
24523
|
-
startDate: new Date("2019-03-25"),
|
24524
|
-
endDate: new Date("2020-03-25"),
|
24525
|
-
nationalPlanObj: "",
|
24526
|
-
kpi: "",
|
24527
|
-
ministry: "",
|
24528
|
-
});
|
24529
|
-
}
|
24530
|
-
}
|
24531
|
-
updatedNdcDetails.splice(parentIndex, 1, __assign({}, parentItem));
|
24532
|
-
setNdcDetailsData(updatedNdcDetails);
|
24533
|
-
}
|
24534
|
-
}
|
24535
|
-
setEditingKey("");
|
24536
|
-
setTableKey(function (key) { return key + 1; });
|
24527
|
+
var handleSave = function (row) {
|
24528
|
+
if (row.type === NdcActionType.main) {
|
24529
|
+
var newData = __spreadArray([], ndcDetailsData, true);
|
24530
|
+
var index = newData.findIndex(function (item) { return row.key === item.key; });
|
24531
|
+
var item = newData[index];
|
24532
|
+
newData.splice(index, 1, __assign(__assign({}, item), row));
|
24533
|
+
setNdcDetailsData(newData);
|
24534
|
+
}
|
24535
|
+
else {
|
24536
|
+
var newData = __spreadArray([], ndcDetailsData, true);
|
24537
|
+
var parentIndex = newData.findIndex(function (item) { return row.ndcActionId === item.key; });
|
24538
|
+
var parentItem = newData[parentIndex];
|
24539
|
+
if (parentItem) {
|
24540
|
+
if (parentItem.subNdcDetails) {
|
24541
|
+
var itemIndex = parentItem.subNdcDetails.findIndex(function (item) { return row.key === item.key; });
|
24542
|
+
if (itemIndex === -1) {
|
24543
|
+
parentItem.subNdcDetails.push(row);
|
24537
24544
|
}
|
24538
24545
|
else {
|
24539
|
-
|
24546
|
+
parentItem.subNdcDetails.splice(itemIndex, 1, __assign({}, row));
|
24540
24547
|
}
|
24541
|
-
|
24542
|
-
|
24543
|
-
|
24544
|
-
|
24545
|
-
return [3 /*break*/, 3];
|
24546
|
-
case 3: return [2 /*return*/];
|
24548
|
+
}
|
24549
|
+
else {
|
24550
|
+
parentItem.subNdcDetails = [row];
|
24551
|
+
}
|
24547
24552
|
}
|
24548
|
-
|
24549
|
-
|
24553
|
+
newData.splice(parentIndex, 1, __assign({}, parentItem));
|
24554
|
+
setNdcDetailsData(newData);
|
24555
|
+
setTableKey(function (key) { return key + 1; });
|
24556
|
+
}
|
24557
|
+
};
|
24550
24558
|
var getNdcDetailsForPeriod = function () {
|
24551
24559
|
var range = selectedTab.split("-");
|
24552
24560
|
if (range.length > 1) {
|
@@ -24575,9 +24583,9 @@ var NdcDetailsComponent = function (props) {
|
|
24575
24583
|
key: "nationalPlanObj",
|
24576
24584
|
align: "left",
|
24577
24585
|
editable: true,
|
24578
|
-
width:
|
24586
|
+
width: "50%",
|
24579
24587
|
render: function (_, record) { return (React.createElement(React.Fragment, null, record.nationalPlanObj ? (React.createElement(Space, { size: "middle" },
|
24580
|
-
React.createElement("span", null, record.nationalPlanObj))) : (React.createElement("input", { className: "ant-input", disabled: true, type: "text" })))); },
|
24588
|
+
React.createElement("span", null, record.nationalPlanObj))) : (React.createElement("input", { placeholder: "Please add the National Plan Objective", className: "ant-input", disabled: true, type: "text" })))); },
|
24581
24589
|
},
|
24582
24590
|
{
|
24583
24591
|
title: t("ndc:ndcColumnsKpi"),
|
@@ -24585,9 +24593,9 @@ var NdcDetailsComponent = function (props) {
|
|
24585
24593
|
key: "kpi",
|
24586
24594
|
align: "left",
|
24587
24595
|
editable: true,
|
24588
|
-
width:
|
24596
|
+
width: "10%",
|
24589
24597
|
render: function (_, record) { return (React.createElement(React.Fragment, null, record.nationalPlanObj ? (React.createElement(Space, { size: "middle" },
|
24590
|
-
React.createElement("span", null, record.kpi))) : (React.createElement("input", { className: "ant-input", disabled: true, type: "text" })))); },
|
24598
|
+
React.createElement("span", null, record.kpi))) : (React.createElement("input", { placeholder: "Enter Kpi", className: "ant-input", disabled: true, type: "text" })))); },
|
24591
24599
|
},
|
24592
24600
|
{
|
24593
24601
|
title: "Ministry",
|
@@ -24595,24 +24603,9 @@ var NdcDetailsComponent = function (props) {
|
|
24595
24603
|
key: "ministry",
|
24596
24604
|
align: "left",
|
24597
24605
|
editable: true,
|
24606
|
+
width: "40%",
|
24598
24607
|
render: function (_, record) { return (React.createElement(React.Fragment, null, record.nationalPlanObj ? (React.createElement(Space, { size: "middle" },
|
24599
|
-
React.createElement("span", null, record.ministry))) : (React.createElement("input", { className: "ant-input", disabled: true, type: "text" })))); },
|
24600
|
-
},
|
24601
|
-
{
|
24602
|
-
title: "Action",
|
24603
|
-
dataIndex: "operation",
|
24604
|
-
render: function (_, record) {
|
24605
|
-
var editable = isEditing(record);
|
24606
|
-
return editable ? (React.createElement("span", null,
|
24607
|
-
React.createElement(Tooltip, { title: "Save" },
|
24608
|
-
React.createElement(Typography.Link, { onClick: function () { return onHandleSave(record); }, style: { marginRight: 20 } },
|
24609
|
-
React.createElement(SaveOutlined, null))),
|
24610
|
-
React.createElement(Tooltip, { title: "Cancel" },
|
24611
|
-
React.createElement(Typography.Link, { onClick: onEditCancel, style: { marginRight: 8 } },
|
24612
|
-
React.createElement(ExclamationCircleOutlined, null))))) : (React.createElement(Tooltip, { title: "Edit" },
|
24613
|
-
React.createElement(Typography.Link, { disabled: editingKey !== "", onClick: function () { return onEditRow(record); } },
|
24614
|
-
React.createElement(EditOutlined, null))));
|
24615
|
-
},
|
24608
|
+
React.createElement("span", null, record.ministry))) : (React.createElement("input", { placeholder: "Please add the Ministry name", className: "ant-input", disabled: true, type: "text" })))); },
|
24616
24609
|
},
|
24617
24610
|
];
|
24618
24611
|
var columns = defaultColumns.map(function (col) {
|
@@ -24624,7 +24617,7 @@ var NdcDetailsComponent = function (props) {
|
|
24624
24617
|
editable: col.editable,
|
24625
24618
|
dataIndex: col.dataIndex,
|
24626
24619
|
title: col.title,
|
24627
|
-
|
24620
|
+
handleSave: handleSave,
|
24628
24621
|
}); } });
|
24629
24622
|
});
|
24630
24623
|
function onAddNewNdcDetail() {
|
@@ -24635,9 +24628,9 @@ var NdcDetailsComponent = function (props) {
|
|
24635
24628
|
type: NdcActionType.main,
|
24636
24629
|
startDate: new Date("".concat(Number(range[0]), "-01-24 23:12:00")),
|
24637
24630
|
endDate: new Date("".concat(Number(range[0]), "-12-24 23:12:00")),
|
24638
|
-
nationalPlanObj:
|
24639
|
-
kpi:
|
24640
|
-
ministry: "
|
24631
|
+
nationalPlanObj: "",
|
24632
|
+
kpi: "",
|
24633
|
+
ministry: "",
|
24641
24634
|
subNdcDetails: [
|
24642
24635
|
{
|
24643
24636
|
key: ++addedNdcDetailId.current,
|
@@ -24655,11 +24648,32 @@ var NdcDetailsComponent = function (props) {
|
|
24655
24648
|
}
|
24656
24649
|
var components = {
|
24657
24650
|
body: {
|
24651
|
+
row: EditableRow,
|
24658
24652
|
cell: EditableCell,
|
24659
24653
|
},
|
24660
24654
|
};
|
24655
|
+
//commented because rendering issue
|
24661
24656
|
function ndcDetailsTableContent() {
|
24662
|
-
return React.createElement("div", null)
|
24657
|
+
return (React.createElement("div", null)
|
24658
|
+
// <div>
|
24659
|
+
// <Button
|
24660
|
+
// onClick={onAddNewNdcDetail}
|
24661
|
+
// type="primary"
|
24662
|
+
// style={{
|
24663
|
+
// marginBottom: 16,
|
24664
|
+
// }}
|
24665
|
+
// >
|
24666
|
+
// Add a row
|
24667
|
+
// </Button>
|
24668
|
+
// <Table
|
24669
|
+
// components={components}
|
24670
|
+
// rowClassName={() => 'editable-row'}
|
24671
|
+
// bordered
|
24672
|
+
// dataSource={ndcDetailsData}
|
24673
|
+
// columns={columns}
|
24674
|
+
// />
|
24675
|
+
// </div>
|
24676
|
+
);
|
24663
24677
|
}
|
24664
24678
|
var onCancelPeriod = function () { };
|
24665
24679
|
var onAddNewPeriod = function () {
|
@@ -24716,7 +24730,6 @@ var NdcDetailsComponent = function (props) {
|
|
24716
24730
|
}
|
24717
24731
|
var onTabChange = function (key) {
|
24718
24732
|
setSelectedTab(key);
|
24719
|
-
setEditingKey("");
|
24720
24733
|
};
|
24721
24734
|
useEffect(function () {
|
24722
24735
|
var defaultNdcDetails = [
|
@@ -24918,18 +24931,17 @@ var NdcDetailsComponent = function (props) {
|
|
24918
24931
|
React.createElement(Tabs, { centered: false, defaultActiveKey: "1", items: periodItems, activeKey: selectedTab, onChange: onTabChange })),
|
24919
24932
|
selectedTab !== "add_new" && (React.createElement("div", null,
|
24920
24933
|
React.createElement("div", null,
|
24921
|
-
React.createElement(
|
24922
|
-
|
24923
|
-
|
24924
|
-
|
24925
|
-
|
24926
|
-
|
24927
|
-
|
24928
|
-
|
24929
|
-
|
24930
|
-
|
24931
|
-
|
24932
|
-
} })))))));
|
24934
|
+
React.createElement(Table, { key: tableKey, components: components, rowClassName: function () { return "editable-row"; }, bordered: true, dataSource: getNdcDetailsForPeriod(), columns: columns, expandable: {
|
24935
|
+
expandedRowRender: function (record) { return getSubNdcActionContent(record); },
|
24936
|
+
indentSize: 0,
|
24937
|
+
defaultExpandedRowKeys: [selectedNdcDetail.current.key],
|
24938
|
+
}, footer: function () {
|
24939
|
+
return isAddNdcActionVisible() && (React.createElement(Row, { justify: "center" },
|
24940
|
+
React.createElement(Button, { onClick: onAddNewNdcDetail, type: "default", style: {
|
24941
|
+
marginBottom: 16,
|
24942
|
+
width: "100%",
|
24943
|
+
} }, t("ndc:addNdcAction"))));
|
24944
|
+
} }))))));
|
24933
24945
|
};
|
24934
24946
|
|
24935
24947
|
var ImgWithFallback = function (_a) {
|