@undp/carbon-library 1.0.151 → 1.0.152

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.
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ import React from "react";
2
2
  interface Item {
3
3
  key: string;
4
4
  name: string;
package/dist/esm/index.js CHANGED
@@ -24472,7 +24472,7 @@ var EditableCell = function (_a) {
24472
24472
  return [3 /*break*/, 3];
24473
24473
  case 2:
24474
24474
  errInfo_1 = _a.sent();
24475
- console.log('Save failed:', errInfo_1);
24475
+ console.log("Save failed:", errInfo_1);
24476
24476
  return [3 /*break*/, 3];
24477
24477
  case 3: return [2 /*return*/];
24478
24478
  }
@@ -24486,7 +24486,7 @@ var EditableCell = function (_a) {
24486
24486
  message: "".concat(title, " is required."),
24487
24487
  },
24488
24488
  ] },
24489
- React.createElement(Input, { ref: inputRef, onPressEnter: save, onBlur: save }))) : (React.createElement("div", { className: "editable-cell-value-wrap", style: { paddingRight: 24 }, onClick: toggleEdit }, children));
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
24490
  }
24491
24491
  return React.createElement("td", __assign({}, restProps), childNode);
24492
24492
  };
@@ -24494,6 +24494,11 @@ var EditableCell = function (_a) {
24494
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";
24495
24495
  styleInject(css_248z$4);
24496
24496
 
24497
+ var NdcActionType;
24498
+ (function (NdcActionType) {
24499
+ NdcActionType[NdcActionType["main"] = 0] = "main";
24500
+ NdcActionType[NdcActionType["sub"] = 1] = "sub";
24501
+ })(NdcActionType || (NdcActionType = {}));
24497
24502
  var NdcDetailsComponent = function (props) {
24498
24503
  var t = props.t; props.useConnection; var useUserContext = props.useUserContext;
24499
24504
  var RangePicker = DatePicker.RangePicker;
@@ -24516,19 +24521,39 @@ var NdcDetailsComponent = function (props) {
24516
24521
  return ((userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyRole) === CompanyRole.GOVERNMENT &&
24517
24522
  (userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.userRole) !== Role.ViewOnly);
24518
24523
  };
24519
- var isAddSubNdcActionVisible = function () {
24520
- return ((userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.companyRole) === CompanyRole.MINISTRY &&
24521
- (userInfoState === null || userInfoState === void 0 ? void 0 : userInfoState.userRole) !== Role.ViewOnly);
24522
- };
24523
24524
  var inRange = function (num, min, max) {
24524
24525
  return num >= min && num <= max;
24525
24526
  };
24526
24527
  var handleSave = function (row) {
24527
- var newData = __spreadArray([], ndcDetailsData, true);
24528
- var index = newData.findIndex(function (item) { return row.key === item.key; });
24529
- var item = newData[index];
24530
- newData.splice(index, 1, __assign(__assign({}, item), row));
24531
- setNdcDetailsData(newData);
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);
24544
+ }
24545
+ else {
24546
+ parentItem.subNdcDetails.splice(itemIndex, 1, __assign({}, row));
24547
+ }
24548
+ }
24549
+ else {
24550
+ parentItem.subNdcDetails = [row];
24551
+ }
24552
+ }
24553
+ newData.splice(parentIndex, 1, __assign({}, parentItem));
24554
+ setNdcDetailsData(newData);
24555
+ setTableKey(function (key) { return key + 1; });
24556
+ }
24532
24557
  };
24533
24558
  var getNdcDetailsForPeriod = function () {
24534
24559
  var range = selectedTab.split("-");
@@ -24558,6 +24583,7 @@ var NdcDetailsComponent = function (props) {
24558
24583
  key: "nationalPlanObj",
24559
24584
  align: "left",
24560
24585
  editable: true,
24586
+ width: 800,
24561
24587
  },
24562
24588
  {
24563
24589
  title: t("ndc:ndcColumnsKpi"),
@@ -24565,6 +24591,7 @@ var NdcDetailsComponent = function (props) {
24565
24591
  key: "kpi",
24566
24592
  align: "left",
24567
24593
  editable: true,
24594
+ width: 100,
24568
24595
  },
24569
24596
  {
24570
24597
  title: "Ministry",
@@ -24588,40 +24615,30 @@ var NdcDetailsComponent = function (props) {
24588
24615
  });
24589
24616
  function onAddNewNdcDetail() {
24590
24617
  var range = selectedTab.split("-");
24591
- addedNdcDetailId.current = addedNdcDetailId.current + 1;
24618
+ var ndcActionId = ++addedNdcDetailId.current;
24592
24619
  var newData = {
24593
- key: addedNdcDetailId.current,
24620
+ key: ndcActionId,
24621
+ type: NdcActionType.main,
24594
24622
  startDate: new Date("".concat(Number(range[0]), "-01-24 23:12:00")),
24595
24623
  endDate: new Date("".concat(Number(range[0]), "-12-24 23:12:00")),
24596
24624
  nationalPlanObj: t("ndc:enterNewPlanTxt"),
24597
24625
  kpi: 0,
24598
24626
  ministry: "Please add the Ministry name",
24627
+ subNdcDetails: [
24628
+ {
24629
+ key: ++addedNdcDetailId.current,
24630
+ ndcActionId: ndcActionId,
24631
+ type: NdcActionType.sub,
24632
+ startDate: new Date("2019-03-25"),
24633
+ endDate: new Date("2020-03-25"),
24634
+ nationalPlanObj: "",
24635
+ kpi: "",
24636
+ ministry: "",
24637
+ },
24638
+ ],
24599
24639
  };
24600
24640
  setNdcDetailsData(__spreadArray(__spreadArray([], ndcDetailsData, true), [newData], false));
24601
24641
  }
24602
- function onAddNewSubNdcDetail() {
24603
- var range = selectedTab.split("-");
24604
- var ndcDetail = ndcDetailsData.find(function (item) { return item.key === selectedNdcDetail.current.key; });
24605
- var ndcDetailItemIndex = ndcDetailsData.findIndex(function (item) { return item.key === selectedNdcDetail.current.key; });
24606
- if (ndcDetail) {
24607
- addedNdcDetailId.current = addedNdcDetailId.current + 1;
24608
- var newData = {
24609
- key: addedNdcDetailId.current,
24610
- startDate: new Date("".concat(Number(range[0]), "-01-24 23:12:00")),
24611
- endDate: new Date("".concat(Number(range[0]), "-12-24 23:12:00")),
24612
- nationalPlanObj: t("ndc:enterNewPlanTxt"),
24613
- kpi: 0,
24614
- ministry: "Please add the Ministry name",
24615
- };
24616
- if (!ndcDetail.subNdcDetails) {
24617
- ndcDetail.subNdcDetails = [];
24618
- }
24619
- ndcDetail.subNdcDetails.push(newData);
24620
- }
24621
- ndcDetailsData[ndcDetailItemIndex] = ndcDetail;
24622
- setNdcDetailsData(ndcDetailsData);
24623
- setTableKey(function (key) { return key + 1; });
24624
- }
24625
24642
  var components = {
24626
24643
  body: {
24627
24644
  row: EditableRow,
@@ -24702,13 +24719,7 @@ var NdcDetailsComponent = function (props) {
24702
24719
  }
24703
24720
  function getSubNdcActionContent(record) {
24704
24721
  selectedNdcDetail.current = record;
24705
- return (React.createElement(Table, { components: components, rowClassName: function () { return "editable-row"; }, bordered: true, dataSource: getSubNdcDetails(record.key), columns: columns, showHeader: false, pagination: false, footer: function () {
24706
- return isAddSubNdcActionVisible() && (React.createElement(Row, { justify: "center" },
24707
- React.createElement(Button, { onClick: onAddNewSubNdcDetail, type: "default", style: {
24708
- marginBottom: 16,
24709
- width: "100%",
24710
- } }, t("ndc:addSubNdcAction"))));
24711
- } }));
24722
+ return (React.createElement(Table, { components: components, rowClassName: function () { return "editable-row"; }, bordered: true, dataSource: getSubNdcDetails(record.key), columns: columns, showHeader: false, pagination: false }));
24712
24723
  }
24713
24724
  var onTabChange = function (key) {
24714
24725
  setSelectedTab(key);
@@ -24717,53 +24728,160 @@ var NdcDetailsComponent = function (props) {
24717
24728
  var defaultNdcDetails = [
24718
24729
  {
24719
24730
  key: 1,
24731
+ type: NdcActionType.main,
24720
24732
  startDate: new Date("2019-03-25"),
24721
24733
  endDate: new Date("2020-03-25"),
24722
24734
  nationalPlanObj: "Enhance value addition in key growth opportunities",
24723
24735
  kpi: 25,
24724
- ministry: "Ministry of Agriculture, Water and Forestry (MAWF)",
24736
+ ministry: "Ministry of Environment",
24725
24737
  subNdcDetails: [
24726
24738
  {
24727
24739
  key: 6,
24740
+ ndcActionId: 1,
24741
+ type: NdcActionType.sub,
24728
24742
  startDate: new Date("2019-03-25"),
24729
24743
  endDate: new Date("2020-03-25"),
24730
24744
  nationalPlanObj: "Enhance value addition in key growth opportunities sub details",
24731
24745
  kpi: 25,
24732
24746
  ministry: "Ministry of Agriculture, Water and Forestry (MAWF)",
24733
24747
  },
24748
+ {
24749
+ key: 7,
24750
+ ndcActionId: 1,
24751
+ type: NdcActionType.sub,
24752
+ startDate: new Date("2019-03-25"),
24753
+ endDate: new Date("2020-03-25"),
24754
+ nationalPlanObj: "",
24755
+ kpi: "",
24756
+ ministry: "",
24757
+ },
24734
24758
  ],
24735
24759
  },
24736
24760
  {
24737
24761
  key: 2,
24762
+ type: NdcActionType.main,
24738
24763
  startDate: new Date("2019-03-25"),
24739
24764
  endDate: new Date("2019-08-25"),
24740
24765
  nationalPlanObj: "Strengthen the private sector to create 10,000 jobs",
24741
24766
  kpi: 10500,
24742
- ministry: "Ministry of Tourism (MoT)",
24767
+ ministry: "Ministry of Environment",
24768
+ subNdcDetails: [
24769
+ {
24770
+ key: 8,
24771
+ ndcActionId: 2,
24772
+ type: NdcActionType.sub,
24773
+ startDate: new Date("2019-03-25"),
24774
+ endDate: new Date("2020-03-25"),
24775
+ nationalPlanObj: "",
24776
+ kpi: "",
24777
+ ministry: "",
24778
+ },
24779
+ ],
24780
+ },
24781
+ {
24782
+ key: 12,
24783
+ type: NdcActionType.main,
24784
+ startDate: new Date("2019-03-25"),
24785
+ endDate: new Date("2019-08-25"),
24786
+ nationalPlanObj: "Other",
24787
+ kpi: 10500,
24788
+ ministry: "Ministry of Environment",
24789
+ subNdcDetails: [
24790
+ {
24791
+ key: 8,
24792
+ ndcActionId: 12,
24793
+ type: NdcActionType.sub,
24794
+ startDate: new Date("2019-03-25"),
24795
+ endDate: new Date("2020-03-25"),
24796
+ nationalPlanObj: "",
24797
+ kpi: "",
24798
+ ministry: "",
24799
+ },
24800
+ ],
24743
24801
  },
24744
24802
  {
24745
24803
  key: 3,
24804
+ type: NdcActionType.main,
24746
24805
  startDate: new Date("2021-03-25"),
24747
24806
  endDate: new Date("2022-03-25"),
24748
24807
  nationalPlanObj: "Consolidate and increase the stock and quality of productive infrastructure by 50%",
24749
24808
  kpi: 48,
24750
- ministry: "Ministry of Education, Arts and Culture (MoE)",
24809
+ ministry: "Ministry of Environment",
24810
+ subNdcDetails: [
24811
+ {
24812
+ key: 9,
24813
+ ndcActionId: 3,
24814
+ type: NdcActionType.sub,
24815
+ startDate: new Date("2019-03-25"),
24816
+ endDate: new Date("2020-03-25"),
24817
+ nationalPlanObj: "",
24818
+ kpi: "",
24819
+ ministry: "",
24820
+ },
24821
+ ],
24751
24822
  },
24752
24823
  {
24753
24824
  key: 4,
24825
+ type: NdcActionType.main,
24754
24826
  startDate: new Date("2022-03-25"),
24755
24827
  endDate: new Date("2022-05-25"),
24756
24828
  nationalPlanObj: "Enhance the productivity and social wellbeing of the population",
24757
24829
  kpi: 20,
24758
- ministry: "Ministry of Environment, Forestry and Tourism (MEFT)",
24830
+ ministry: "Ministry of Environment",
24831
+ subNdcDetails: [
24832
+ {
24833
+ key: 10,
24834
+ ndcActionId: 4,
24835
+ type: NdcActionType.sub,
24836
+ startDate: new Date("2019-03-25"),
24837
+ endDate: new Date("2020-03-25"),
24838
+ nationalPlanObj: "",
24839
+ kpi: "",
24840
+ ministry: "",
24841
+ },
24842
+ ],
24759
24843
  },
24760
24844
  {
24761
24845
  key: 5,
24846
+ type: NdcActionType.main,
24762
24847
  startDate: new Date("2022-03-25"),
24763
24848
  endDate: new Date("2023-03-25"),
24764
24849
  nationalPlanObj: "Strengthen the role of the state in guiding and facilitating development",
24765
24850
  kpi: 10,
24766
- ministry: "Ministry of Tourism (MoT)",
24851
+ ministry: "Ministry of Environment",
24852
+ subNdcDetails: [
24853
+ {
24854
+ key: 11,
24855
+ ndcActionId: 5,
24856
+ type: NdcActionType.sub,
24857
+ startDate: new Date("2019-03-25"),
24858
+ endDate: new Date("2020-03-25"),
24859
+ nationalPlanObj: "",
24860
+ kpi: "",
24861
+ ministry: "",
24862
+ },
24863
+ ],
24864
+ },
24865
+ {
24866
+ key: 13,
24867
+ type: NdcActionType.main,
24868
+ startDate: new Date("2022-03-25"),
24869
+ endDate: new Date("2023-03-25"),
24870
+ nationalPlanObj: "Other",
24871
+ kpi: 10,
24872
+ ministry: "Ministry of Environment",
24873
+ subNdcDetails: [
24874
+ {
24875
+ key: 11,
24876
+ ndcActionId: 13,
24877
+ type: NdcActionType.sub,
24878
+ startDate: new Date("2019-03-25"),
24879
+ endDate: new Date("2020-03-25"),
24880
+ nationalPlanObj: "",
24881
+ kpi: "",
24882
+ ministry: "",
24883
+ },
24884
+ ],
24767
24885
  },
24768
24886
  ];
24769
24887
  var initialPeriods = [