@undp/carbon-library 1.0.135-CARBON-343.4 → 1.0.135-CARBON-343.6

Sign up to get free protection for your applications and to get access to all the features.
package/dist/esm/index.js CHANGED
@@ -23690,14 +23690,22 @@ var NdcDetailsComponent = function (props) {
23690
23690
  );
23691
23691
  }
23692
23692
  var onCancelPeriod = function () { };
23693
+ var inRange = function (num, min, max) {
23694
+ return num >= min && num <= max;
23695
+ };
23693
23696
  var onAddNewPeriod = function () {
23694
23697
  if (selectedPeriod && selectedPeriod.current) {
23695
23698
  var newPeriodItem_1 = {
23696
23699
  key: "".concat(selectedPeriod.current.start, "-").concat(selectedPeriod.current.end),
23697
23700
  label: "".concat(selectedPeriod.current.start, "-").concat(selectedPeriod.current.end),
23701
+ start: selectedPeriod.current.start,
23702
+ end: selectedPeriod.current.end,
23698
23703
  children: ndcDetailsTableContent(),
23699
23704
  };
23700
- var existingIndex = periodItemsRef.current.findIndex(function (item) { return item.key === newPeriodItem_1.key; });
23705
+ var existingIndex = periodItemsRef.current.findIndex(function (item) {
23706
+ return inRange(newPeriodItem_1.start, item.start, item.end) ||
23707
+ inRange(newPeriodItem_1.end, item.start, item.end);
23708
+ });
23701
23709
  if (existingIndex === -1) {
23702
23710
  setPeriodItems(function (items) { return __spreadArray(__spreadArray([], items, true), [newPeriodItem_1], false); });
23703
23711
  periodItemsRef.current = __spreadArray(__spreadArray([], periodItemsRef.current, true), [newPeriodItem_1], false);