@nutui/nutui-react 2.0.0-alpha.15 → 2.0.0-alpha.16

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.
Files changed (40) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/esm/DatePicker.js +54 -58
  3. package/dist/esm/Dialog/style/index.js +1 -0
  4. package/dist/esm/Dialog/style/style.css +1 -1
  5. package/dist/esm/Menu/style/style.css +1 -1
  6. package/dist/esm/Menu.js +5 -3
  7. package/dist/esm/MenuItem/style/style.css +1 -1
  8. package/dist/esm/MenuItem.js +31 -44
  9. package/dist/esm/NoticeBar.js +2 -2
  10. package/dist/esm/Picker.js +1 -1
  11. package/dist/esm/Popover.js +3 -40
  12. package/dist/esm/Popup.js +1 -1
  13. package/dist/esm/Toast.js +16 -7
  14. package/dist/esm/Uploader.js +1 -1
  15. package/dist/esm/index.js +2 -2
  16. package/dist/esm/types/src/packages/datepicker/datepicker.d.ts +11 -17
  17. package/dist/esm/types/src/packages/datepicker/datepicker.taro.d.ts +11 -17
  18. package/dist/esm/types/src/packages/datepicker/index.d.ts +1 -0
  19. package/dist/esm/types/src/packages/datepicker/index.taro.d.ts +1 -0
  20. package/dist/esm/types/src/packages/nutui.react.taro.d.ts +2 -2
  21. package/dist/esm/types/src/packages/nutui.taro.react.build.d.ts +2 -2
  22. package/dist/esm/types/src/packages/toast/Notification.d.ts +4 -1
  23. package/dist/esm/use-click-away.js +43 -0
  24. package/dist/locales/base.js +1 -1
  25. package/dist/locales/en-US.js +1 -1
  26. package/dist/locales/id-ID.js +1 -1
  27. package/dist/locales/tr-TR.js +1 -1
  28. package/dist/locales/zh-CN.js +1 -1
  29. package/dist/locales/zh-TW.js +1 -1
  30. package/dist/locales/zh-UG.js +1 -1
  31. package/dist/nutui.react.es.js +210 -224
  32. package/dist/nutui.react.umd.js +210 -224
  33. package/dist/packages/menuitem/menuitem.scss +1 -1
  34. package/dist/packages/noticebar/noticebar.scss +0 -3
  35. package/dist/style.css +1 -1
  36. package/dist/style.mjs +1 -1
  37. package/dist/types/packages/datepicker/datepicker.d.ts +79 -25
  38. package/dist/types/packages/datepicker/index.d.ts +1 -0
  39. package/dist/types/packages/toast/Notification.d.ts +4 -1
  40. package/package.json +1 -1
@@ -9,7 +9,7 @@ var __publicField = (obj, key, value) => {
9
9
  return value;
10
10
  };
11
11
  /*!
12
- * @nutui/nutui-react v2.0.0-alpha.15 Wed Jun 07 2023 16:11:56 GMT+0800 (China Standard Time)
12
+ * @nutui/nutui-react v2.0.0-alpha.16 Fri Jun 09 2023 18:29:35 GMT+0800 (China Standard Time)
13
13
  * (c) 2023 @jdf2e.
14
14
  * Released under the MIT License.
15
15
  */
@@ -11221,7 +11221,7 @@ Please add \`${key}Action\` when creating your handler.`);
11221
11221
  {
11222
11222
  classNames: transitionName,
11223
11223
  unmountOnExit: true,
11224
- timeout: 500,
11224
+ timeout: 300,
11225
11225
  in: innerVisible,
11226
11226
  onEntered: onHandleOpened,
11227
11227
  onExited: onHandleClosed
@@ -14549,7 +14549,7 @@ Please add \`${key}Action\` when creating your handler.`);
14549
14549
  {
14550
14550
  visible,
14551
14551
  position: "bottom",
14552
- onClose: () => {
14552
+ afterClose: () => {
14553
14553
  closePicker();
14554
14554
  }
14555
14555
  },
@@ -14574,29 +14574,29 @@ Please add \`${key}Action\` when creating your handler.`);
14574
14574
  const Picker$1 = Picker;
14575
14575
  const currentYear = (/* @__PURE__ */ new Date()).getFullYear();
14576
14576
  const defaultProps$V = {
14577
- modelValue: null,
14577
+ ...ComponentDefaults,
14578
14578
  visible: false,
14579
14579
  title: "",
14580
14580
  type: "date",
14581
- isShowChinese: false,
14581
+ showChinese: false,
14582
14582
  threeDimensional: true,
14583
14583
  minuteStep: 1,
14584
- minDate: new Date(currentYear - 10, 0, 1),
14585
- maxDate: new Date(currentYear + 10, 11, 31)
14584
+ startDate: new Date(currentYear - 10, 0, 1),
14585
+ endDate: new Date(currentYear + 10, 11, 31)
14586
14586
  };
14587
14587
  const DatePicker = (props) => {
14588
14588
  const {
14589
- minDate,
14590
- maxDate,
14589
+ startDate,
14590
+ endDate,
14591
14591
  type: type2,
14592
- isShowChinese,
14592
+ showChinese,
14593
14593
  minuteStep,
14594
- modelValue,
14595
14594
  visible,
14596
14595
  title,
14596
+ defaultValue,
14597
14597
  formatter,
14598
- onCloseDatePicker,
14599
- onConfirmDatePicker,
14598
+ onClose,
14599
+ onConfirm,
14600
14600
  filter,
14601
14601
  onChange,
14602
14602
  threeDimensional,
@@ -14608,14 +14608,6 @@ Please add \`${key}Action\` when creating your handler.`);
14608
14608
  ...props
14609
14609
  };
14610
14610
  const { locale } = useConfig();
14611
- const [show2, setShow] = React.useState(false);
14612
- const [currentDate, setCurrentDate] = React.useState(modelValue);
14613
- const [defaultValue, setDefaultValue] = React.useState([]);
14614
- const [options2, setListData] = React.useState([]);
14615
- const pickerRef = React.useRef(null);
14616
- const isDate = (val) => {
14617
- return Object.prototype.toString.call(val) === "[object Date]" && !Number.isNaN(val.getTime());
14618
- };
14619
14611
  const datepickerLang = locale.datepicker;
14620
14612
  const zhCNType = {
14621
14613
  day: datepickerLang.day,
@@ -14625,20 +14617,32 @@ Please add \`${key}Action\` when creating your handler.`);
14625
14617
  minute: datepickerLang.min,
14626
14618
  seconds: datepickerLang.seconds
14627
14619
  };
14620
+ const [defaultValueOfPicker, setDefaultValueOfPicker] = React.useState([]);
14621
+ const [options2, setOptions] = React.useState([]);
14622
+ const isDate = (val) => {
14623
+ return Object.prototype.toString.call(val) === "[object Date]" && !Number.isNaN(val.getTime());
14624
+ };
14628
14625
  const formatValue = (value) => {
14629
14626
  let cvalue = value;
14630
14627
  if (!cvalue || cvalue && !isDate(cvalue)) {
14631
- cvalue = minDate;
14628
+ cvalue = startDate;
14632
14629
  }
14633
- let timestmp = Math.max(cvalue.getTime(), minDate.getTime());
14634
- timestmp = Math.min(timestmp, maxDate.getTime());
14630
+ let timestmp = Math.max(cvalue.getTime(), startDate.getTime());
14631
+ timestmp = Math.min(timestmp, endDate.getTime());
14635
14632
  return new Date(timestmp);
14636
14633
  };
14634
+ const [currentDate, setCurrentDate] = usePropsValue({
14635
+ value: props.value && formatValue(props.value),
14636
+ defaultValue: formatValue(props.defaultValue || null),
14637
+ finalValue: null,
14638
+ onChange: (val) => {
14639
+ }
14640
+ });
14637
14641
  function getMonthEndDay(year, month) {
14638
14642
  return new Date(year, month, 0).getDate();
14639
14643
  }
14640
14644
  const getBoundary = (type22, value) => {
14641
- const boundary = type22 === "min" ? minDate : maxDate;
14645
+ const boundary = type22 === "min" ? startDate : endDate;
14642
14646
  const year = boundary.getFullYear();
14643
14647
  let month = 1;
14644
14648
  let date2 = 1;
@@ -14672,12 +14676,12 @@ Please add \`${key}Action\` when creating your handler.`);
14672
14676
  [`${type22}Seconds`]: seconds
14673
14677
  };
14674
14678
  };
14675
- const ranges = (date2) => {
14676
- const curDate = date2 || currentDate;
14679
+ const ranges = () => {
14680
+ const curDate = currentDate;
14677
14681
  if (!curDate)
14678
14682
  return [];
14679
- const { maxYear, maxDate: maxDate2, maxMonth, maxHour, maxMinute, maxSeconds } = getBoundary("max", curDate);
14680
- const { minYear, minDate: minDate2, minMonth, minHour, minMinute, minSeconds } = getBoundary("min", curDate);
14683
+ const { maxYear, maxDate, maxMonth, maxHour, maxMinute, maxSeconds } = getBoundary("max", curDate);
14684
+ const { minYear, minDate, minMonth, minHour, minMinute, minSeconds } = getBoundary("min", curDate);
14681
14685
  let result = [
14682
14686
  {
14683
14687
  type: "year",
@@ -14689,7 +14693,7 @@ Please add \`${key}Action\` when creating your handler.`);
14689
14693
  },
14690
14694
  {
14691
14695
  type: "day",
14692
- range: [minDate2, maxDate2]
14696
+ range: [minDate, maxDate]
14693
14697
  },
14694
14698
  {
14695
14699
  type: "hour",
@@ -14729,7 +14733,7 @@ Please add \`${key}Action\` when creating your handler.`);
14729
14733
  }
14730
14734
  return result;
14731
14735
  };
14732
- const updateChooseValueCustmer = (cacheValueData, selectedValue, index) => {
14736
+ const updateChooseValueCustmer = (selectedOptions, selectedValue, index) => {
14733
14737
  if (["date", "datetime", "datehour", "month-day", "year-month"].includes(
14734
14738
  type2.toLocaleLowerCase()
14735
14739
  )) {
@@ -14739,11 +14743,13 @@ Please add \`${key}Action\` when creating your handler.`);
14739
14743
  });
14740
14744
  if (type2.toLocaleLowerCase() === "month-day" && formatDate.length < 3) {
14741
14745
  formatDate.unshift(
14742
- new Date(modelValue || minDate || maxDate).getFullYear()
14746
+ new Date(defaultValue || startDate || endDate).getFullYear()
14743
14747
  );
14744
14748
  }
14745
14749
  if (type2.toLocaleLowerCase() === "year-month" && formatDate.length < 3) {
14746
- formatDate.push(new Date(modelValue || minDate || maxDate).getDate());
14750
+ formatDate.push(
14751
+ new Date(defaultValue || startDate || endDate).getDate()
14752
+ );
14747
14753
  }
14748
14754
  const year = Number(formatDate[0]);
14749
14755
  const month = Number(formatDate[1]) - 1;
@@ -14768,7 +14774,7 @@ Please add \`${key}Action\` when creating your handler.`);
14768
14774
  const isEqual2 = (currentDate == null ? void 0 : currentDate.getTime()) === (date2 == null ? void 0 : date2.getTime());
14769
14775
  date2 && isDate(date2) && !isEqual2 && setCurrentDate(formatValue(date2));
14770
14776
  }
14771
- props.onChange && props.onChange(cacheValueData, selectedValue, index);
14777
+ props.onChange && props.onChange(selectedOptions, selectedValue, index);
14772
14778
  };
14773
14779
  const padZero = (num, targetLength = 2) => {
14774
14780
  let str = `${num}`;
@@ -14786,12 +14792,13 @@ Please add \`${key}Action\` when creating your handler.`);
14786
14792
  });
14787
14793
  } else {
14788
14794
  const padMin = padZero(value, 2);
14789
- const fatter = isShowChinese ? zhCNType[type22] : "";
14795
+ const fatter = showChinese ? zhCNType[type22] : "";
14790
14796
  fOption = { text: padMin + fatter, value: padMin };
14791
14797
  }
14792
14798
  return fOption;
14793
14799
  };
14794
14800
  const generateValue = (min, max, val, type22, columnIndex) => {
14801
+ var _a2;
14795
14802
  let cmin = min;
14796
14803
  const arr = [];
14797
14804
  let index = 0;
@@ -14806,8 +14813,8 @@ Please add \`${key}Action\` when creating your handler.`);
14806
14813
  index++;
14807
14814
  }
14808
14815
  }
14809
- defaultValue[columnIndex] = arr[index].value;
14810
- setDefaultValue([...defaultValue]);
14816
+ defaultValueOfPicker[columnIndex] = (_a2 = arr[index]) == null ? void 0 : _a2.value;
14817
+ setDefaultValueOfPicker([...defaultValueOfPicker]);
14811
14818
  if (props.filter && props.filter(type22, arr)) {
14812
14819
  return props.filter(type22, arr);
14813
14820
  }
@@ -14832,8 +14839,8 @@ Please add \`${key}Action\` when creating your handler.`);
14832
14839
  }
14833
14840
  return d;
14834
14841
  };
14835
- const columns = (date2) => {
14836
- const val = ranges(date2).map((res, columnIndex) => {
14842
+ const columns = () => {
14843
+ const val = ranges().map((res, columnIndex) => {
14837
14844
  return generateValue(
14838
14845
  res.range[0],
14839
14846
  res.range[1],
@@ -14844,42 +14851,24 @@ Please add \`${key}Action\` when creating your handler.`);
14844
14851
  });
14845
14852
  return val || [];
14846
14853
  };
14847
- React.useEffect(() => {
14848
- setCurrentDate(formatValue(modelValue));
14849
- }, []);
14850
- React.useEffect(() => {
14851
- setCurrentDate(formatValue(modelValue));
14852
- }, [modelValue]);
14853
- React.useEffect(() => {
14854
- setShow(visible);
14855
- }, [visible]);
14856
14854
  React.useEffect(() => {
14857
14855
  if (currentDate) {
14858
- setListData(columns());
14856
+ setOptions(columns());
14859
14857
  }
14860
- }, [currentDate]);
14861
- return /* @__PURE__ */ React.createElement(
14862
- "div",
14858
+ }, []);
14859
+ return /* @__PURE__ */ React.createElement("div", { className: `nut-datepicker ${className}`, style, ...rest }, options2.length && /* @__PURE__ */ React.createElement(
14860
+ Picker$1,
14863
14861
  {
14864
- className: `nut-datepicker ${className || ""}`,
14865
- style,
14866
- ...rest
14867
- },
14868
- options2.length > 0 && /* @__PURE__ */ React.createElement(
14869
- Picker$1,
14870
- {
14871
- title,
14872
- visible: show2,
14873
- options: options2,
14874
- onClose: onCloseDatePicker,
14875
- defaultValue,
14876
- onConfirm: (options22, values) => onConfirmDatePicker && onConfirmDatePicker(options22, values),
14877
- onChange: (list, value, index) => updateChooseValueCustmer(list, value, index),
14878
- threeDimensional,
14879
- ref: pickerRef
14880
- }
14881
- )
14882
- );
14862
+ title,
14863
+ visible,
14864
+ options: options2,
14865
+ onClose,
14866
+ defaultValue: defaultValueOfPicker,
14867
+ onConfirm: (options22, value) => onConfirm && onConfirm(options22, value),
14868
+ onChange: (options22, value, index) => updateChooseValueCustmer(options22, value, index),
14869
+ threeDimensional
14870
+ }
14871
+ ));
14883
14872
  };
14884
14873
  DatePicker.defaultProps = defaultProps$V;
14885
14874
  DatePicker.displayName = "NutDatePicker";
@@ -16745,6 +16734,7 @@ Please add \`${key}Action\` when creating your handler.`);
16745
16734
  };
16746
16735
  const hideMenuItem = (index) => {
16747
16736
  showMenuItem[index] = false;
16737
+ console.log([...showMenuItem]);
16748
16738
  setShowMenuItem([...showMenuItem]);
16749
16739
  };
16750
16740
  const updateTitle = (text, index) => {
@@ -16754,6 +16744,7 @@ Please add \`${key}Action\` when creating your handler.`);
16754
16744
  const cloneChildren = () => {
16755
16745
  return React.Children.map(children, (child, index) => {
16756
16746
  return React.cloneElement(child, {
16747
+ ...child.props,
16757
16748
  show: showMenuItem[index],
16758
16749
  index,
16759
16750
  activeColor,
@@ -16793,7 +16784,8 @@ Please add \`${key}Action\` when creating your handler.`);
16793
16784
  }),
16794
16785
  style: { color: showMenuItem[index] ? activeColor : "" },
16795
16786
  key: index,
16796
- onClick: () => {
16787
+ onClick: (e) => {
16788
+ e.stopPropagation();
16797
16789
  !disabled && toggleMenuItem(index);
16798
16790
  }
16799
16791
  },
@@ -16835,12 +16827,59 @@ Please add \`${key}Action\` when creating your handler.`);
16835
16827
  };
16836
16828
  Menu.defaultProps = defaultProps$Q;
16837
16829
  Menu.displayName = "NutMenu";
16830
+ const isObject = (val) => val !== null && typeof val === "object";
16831
+ const isFunction = (val) => typeof val === "function";
16832
+ const isPromise = (val) => {
16833
+ return isObject(val) && isFunction(val.then) && isFunction(val.catch);
16834
+ };
16835
+ const upperCaseFirst = (str) => {
16836
+ var str = str.toLowerCase();
16837
+ str = str.replace(
16838
+ /\b\w+\b/g,
16839
+ (word) => word.substring(0, 1).toUpperCase() + word.substring(1)
16840
+ );
16841
+ return str;
16842
+ };
16843
+ const getTargetElement = (target) => {
16844
+ let targetElement;
16845
+ if (isFunction(target)) {
16846
+ targetElement = target();
16847
+ } else if ("current" in target) {
16848
+ targetElement = target.current;
16849
+ } else {
16850
+ targetElement = target;
16851
+ }
16852
+ return targetElement;
16853
+ };
16854
+ function useClickAway(onClickAway, target, eventName = "click", isListener, outerVar) {
16855
+ const handler = (event) => {
16856
+ const targets = Array.isArray(target) ? target : [target];
16857
+ if (targets.some((item) => {
16858
+ const targetElement = getTargetElement(item);
16859
+ return !targetElement || targetElement.contains(event.target);
16860
+ })) {
16861
+ return;
16862
+ }
16863
+ if (outerVar) {
16864
+ onClickAway();
16865
+ }
16866
+ };
16867
+ React.useEffect(() => {
16868
+ if (isListener) {
16869
+ window.addEventListener(eventName, handler, false);
16870
+ } else {
16871
+ window.removeEventListener(eventName, handler, false);
16872
+ }
16873
+ return () => {
16874
+ window.removeEventListener(eventName, handler, true);
16875
+ };
16876
+ }, [target]);
16877
+ }
16838
16878
  const defaultProps$P = {
16839
16879
  ...ComponentDefaults,
16840
16880
  columns: 1,
16841
16881
  direction: "down",
16842
16882
  icon: null,
16843
- closeOnClickAway: false,
16844
16883
  activeTitleClass: "",
16845
16884
  inactiveTitleClass: "",
16846
16885
  onChange: (value) => void 0
@@ -16873,9 +16912,6 @@ Please add \`${key}Action\` when creating your handler.`);
16873
16912
  React.useEffect(() => {
16874
16913
  setShowPopup(show2);
16875
16914
  }, [show2]);
16876
- React.useEffect(() => {
16877
- getParentOffset();
16878
- }, [_showPopup]);
16879
16915
  React.useImperativeHandle(ref, () => ({
16880
16916
  toggle: parent.toggleMenuItem
16881
16917
  }));
@@ -16896,119 +16932,108 @@ Please add \`${key}Action\` when creating your handler.`);
16896
16932
  setValue(item.value);
16897
16933
  onChange && onChange(item);
16898
16934
  };
16899
- const [position, setPosition] = React.useState({
16900
- top: 0,
16901
- height: 0
16902
- });
16903
- const getParentOffset = () => {
16904
- setTimeout(() => {
16905
- const p = parent.menuRef.current;
16906
- const rect = p.getBoundingClientRect();
16907
- setPosition({
16908
- height: rect.height,
16909
- top: rect.top
16910
- });
16911
- });
16912
- };
16913
16935
  const isShow = () => {
16914
16936
  if (_showPopup)
16915
16937
  return {};
16916
16938
  return { display: "none" };
16917
16939
  };
16918
16940
  const getPosition = () => {
16919
- return direction === "down" ? { top: `${position.top + position.height}px` } : { bottom: `${window.innerHeight - position.top}px`, top: "auto" };
16920
- };
16921
- const placeholderStyle = () => {
16922
- if (direction === "down") {
16923
- return {
16924
- height: `${position.top + position.height}px`,
16925
- top: 0,
16926
- ...isShow()
16927
- };
16928
- }
16929
- return {
16930
- height: `${window.innerHeight - position.top}px`,
16931
- bottom: `0px`,
16941
+ return direction === "down" ? { position: "absolute", height: `${window.innerHeight}px` } : {
16942
+ position: "absolute",
16943
+ bottom: "100%",
16932
16944
  top: "auto",
16933
- ...isShow()
16945
+ height: `${window.innerHeight}px`
16934
16946
  };
16935
16947
  };
16936
- return /* @__PURE__ */ React.createElement(React.Fragment, null, closeOnClickAway ? /* @__PURE__ */ React.createElement(
16937
- "div",
16938
- {
16939
- className: `placeholder-element ${classNames({
16940
- up: direction === "up"
16941
- })}`,
16942
- style: placeholderStyle(),
16943
- onClick: () => parent.toggleMenuItem(index)
16944
- }
16945
- ) : null, /* @__PURE__ */ React.createElement(
16946
- Overlay,
16947
- {
16948
- className: "nut-menu__overlay",
16949
- style: getPosition(),
16950
- lockScroll: parent.lockScroll,
16951
- visible: _showPopup,
16952
- closeOnOverlayClick: parent.closeOnOverlayClick,
16953
- onClick: () => {
16954
- parent.closeOnOverlayClick && parent.toggleMenuItem(index);
16955
- }
16956
- }
16957
- ), /* @__PURE__ */ React.createElement(
16948
+ const micRef = React.useRef(null);
16949
+ const targetSet = [micRef.current];
16950
+ useClickAway(
16951
+ () => {
16952
+ parent.hideMenuItem(index);
16953
+ },
16954
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
16955
+ // @ts-ignore
16956
+ targetSet,
16957
+ "click",
16958
+ _showPopup,
16959
+ closeOnClickAway
16960
+ );
16961
+ return /* @__PURE__ */ React.createElement(
16958
16962
  "div",
16959
16963
  {
16960
- className: classNames(className, {
16961
- "nut-menu-item__wrap": direction === "down",
16962
- "nut-menu-item__wrap-up": direction !== "down"
16963
- }),
16964
- style: {
16965
- ...style,
16966
- ...isShow()
16967
- }
16964
+ className: "nut-menu-item-container",
16965
+ ref: micRef,
16966
+ style: { position: "absolute", left: 0, right: 0 }
16968
16967
  },
16969
16968
  /* @__PURE__ */ React.createElement(
16970
- CSSTransition$1,
16969
+ Overlay,
16971
16970
  {
16972
- in: _showPopup,
16973
- timeout: 100,
16974
- classNames: direction === "down" ? "menu-item" : "menu-item-up"
16971
+ className: "nut-menu__overlay",
16972
+ style: getPosition(),
16973
+ lockScroll: parent.lockScroll,
16974
+ visible: _showPopup,
16975
+ closeOnOverlayClick: parent.closeOnOverlayClick,
16976
+ onClick: () => {
16977
+ parent.closeOnOverlayClick && parent.toggleMenuItem(index);
16978
+ }
16979
+ }
16980
+ ),
16981
+ /* @__PURE__ */ React.createElement(
16982
+ "div",
16983
+ {
16984
+ className: classNames(className, {
16985
+ "nut-menu-item__wrap": direction === "down",
16986
+ "nut-menu-item__wrap-up": direction !== "down"
16987
+ }),
16988
+ style: {
16989
+ ...style,
16990
+ ...isShow()
16991
+ }
16975
16992
  },
16976
- /* @__PURE__ */ React.createElement("div", { className: "nut-menu-item__content" }, options2 == null ? void 0 : options2.map((item, index2) => {
16977
- return /* @__PURE__ */ React.createElement(
16978
- "div",
16979
- {
16980
- className: `nut-menu-item__option ${classNames({
16981
- active: item.value === _value
16982
- })}`,
16983
- key: item.text,
16984
- style: {
16985
- flexBasis: `${100 / columns}%`
16986
- },
16987
- onClick: () => {
16988
- handleClick2(item);
16989
- }
16990
- },
16991
- item.value === _value ? /* @__PURE__ */ React.createElement("i", null, icon || /* @__PURE__ */ React.createElement(
16992
- x$f,
16993
- {
16994
- color: activeColor,
16995
- className: getIconCName(item.value, value)
16996
- }
16997
- )) : null,
16998
- /* @__PURE__ */ React.createElement(
16993
+ /* @__PURE__ */ React.createElement(
16994
+ CSSTransition$1,
16995
+ {
16996
+ in: _showPopup,
16997
+ timeout: 100,
16998
+ classNames: direction === "down" ? "menu-item" : "menu-item-up"
16999
+ },
17000
+ /* @__PURE__ */ React.createElement("div", { className: "nut-menu-item__content" }, options2 == null ? void 0 : options2.map((item) => {
17001
+ return /* @__PURE__ */ React.createElement(
16999
17002
  "div",
17000
17003
  {
17001
- className: getIconCName(item.value, value),
17004
+ className: `nut-menu-item__option ${classNames({
17005
+ active: item.value === _value
17006
+ })}`,
17007
+ key: item.text,
17002
17008
  style: {
17003
- color: `${item.value === _value ? activeColor : ""}`
17009
+ flexBasis: `${100 / columns}%`
17010
+ },
17011
+ onClick: () => {
17012
+ handleClick2(item);
17004
17013
  }
17005
17014
  },
17006
- item.text
17007
- )
17008
- );
17009
- }), children)
17015
+ item.value === _value ? /* @__PURE__ */ React.createElement("i", null, icon || /* @__PURE__ */ React.createElement(
17016
+ x$f,
17017
+ {
17018
+ color: activeColor,
17019
+ className: getIconCName(item.value, value)
17020
+ }
17021
+ )) : null,
17022
+ /* @__PURE__ */ React.createElement(
17023
+ "div",
17024
+ {
17025
+ className: getIconCName(item.value, value),
17026
+ style: {
17027
+ color: `${item.value === _value ? activeColor : ""}`
17028
+ }
17029
+ },
17030
+ item.text
17031
+ )
17032
+ );
17033
+ }), children)
17034
+ )
17010
17035
  )
17011
- ));
17036
+ );
17012
17037
  });
17013
17038
  MenuItem.defaultProps = defaultProps$P;
17014
17039
  MenuItem.displayName = "NutMenuItem";
@@ -18474,19 +18499,6 @@ Please add \`${key}Action\` when creating your handler.`);
18474
18499
  }
18475
18500
  }
18476
18501
  }
18477
- const isObject = (val) => val !== null && typeof val === "object";
18478
- const isFunction = (val) => typeof val === "function";
18479
- const isPromise = (val) => {
18480
- return isObject(val) && isFunction(val.then) && isFunction(val.catch);
18481
- };
18482
- const upperCaseFirst = (str) => {
18483
- var str = str.toLowerCase();
18484
- str = str.replace(
18485
- /\b\w+\b/g,
18486
- (word) => word.substring(0, 1).toUpperCase() + word.substring(1)
18487
- );
18488
- return str;
18489
- };
18490
18502
  const funcInterceptor = (interceptor, {
18491
18503
  args = [],
18492
18504
  done,
@@ -19981,7 +19993,7 @@ Please add \`${key}Action\` when creating your handler.`);
19981
19993
  onClick: handleClick2
19982
19994
  },
19983
19995
  leftIcon ? /* @__PURE__ */ React.createElement("div", { className: "left-icon" }, leftIcon) : null,
19984
- children ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", { className: "nut-noticebar__inner", ref: innerRef }, scrollList.current.map((item, index) => {
19996
+ children ? /* @__PURE__ */ React.createElement("div", { className: "nut-noticebar__inner", ref: innerRef }, scrollList.current.map((item, index) => {
19985
19997
  return /* @__PURE__ */ React.createElement(
19986
19998
  "div",
19987
19999
  {
@@ -19994,7 +20006,7 @@ Please add \`${key}Action\` when creating your handler.`);
19994
20006
  },
19995
20007
  item
19996
20008
  );
19997
- }))) : /* @__PURE__ */ React.createElement("div", { className: "horseLamp_list", style: horseLampStyle }, scrollList.current.map((item, index) => {
20009
+ })) : /* @__PURE__ */ React.createElement("div", { className: "horseLamp_list", style: horseLampStyle }, scrollList.current.map((item, index) => {
19998
20010
  return (
19999
20011
  // eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions
20000
20012
  /* @__PURE__ */ React.createElement(
@@ -20188,41 +20200,6 @@ Please add \`${key}Action\` when creating your handler.`);
20188
20200
  }
20189
20201
  }
20190
20202
  };
20191
- const getTargetElement = (target) => {
20192
- let targetElement;
20193
- if (isFunction(target)) {
20194
- targetElement = target();
20195
- } else if ("current" in target) {
20196
- targetElement = target.current;
20197
- } else {
20198
- targetElement = target;
20199
- }
20200
- return targetElement;
20201
- };
20202
- function useClickAway(onClickAway, target, eventName = "click", isListener, outerVar) {
20203
- const handler = (event) => {
20204
- const targets = Array.isArray(target) ? target : [target];
20205
- if (targets.some((item) => {
20206
- const targetElement = getTargetElement(item);
20207
- return !targetElement || targetElement.contains(event.target);
20208
- })) {
20209
- return;
20210
- }
20211
- if (outerVar) {
20212
- onClickAway();
20213
- }
20214
- };
20215
- React.useEffect(() => {
20216
- if (isListener) {
20217
- window.addEventListener(eventName, handler, true);
20218
- } else {
20219
- window.removeEventListener(eventName, handler, true);
20220
- }
20221
- return () => {
20222
- window.removeEventListener(eventName, handler, true);
20223
- };
20224
- }, [target]);
20225
- }
20226
20203
  const defaultProps$w = {
20227
20204
  ...ComponentDefaults,
20228
20205
  list: [],
@@ -21039,11 +21016,20 @@ Please add \`${key}Action\` when creating your handler.`);
21039
21016
  this.close = this.close.bind(this);
21040
21017
  this.startCloseTimer = this.startCloseTimer.bind(this);
21041
21018
  this.clearCloseTimer = this.clearCloseTimer.bind(this);
21042
- this.close = this.close.bind(this);
21043
21019
  this.clickCover = this.clickCover.bind(this);
21020
+ this.state = {
21021
+ show: true
21022
+ };
21044
21023
  }
21045
21024
  close() {
21025
+ this.setState({
21026
+ show: false
21027
+ });
21046
21028
  this.clearCloseTimer();
21029
+ if (this.props.id) {
21030
+ const element = document.getElementById(this.props.id);
21031
+ element && element.parentNode && element.parentNode.removeChild(element);
21032
+ }
21047
21033
  this.props.onClose();
21048
21034
  }
21049
21035
  startCloseTimer() {
@@ -21108,6 +21094,7 @@ Please add \`${key}Action\` when creating your handler.`);
21108
21094
  contentClassName,
21109
21095
  contentStyle
21110
21096
  } = this.props;
21097
+ const { show: show2 } = this.state;
21111
21098
  const classes = classNames({
21112
21099
  "nut-toast-has-icon": icon,
21113
21100
  [`nut-toast-${size}`]: true
@@ -21115,11 +21102,10 @@ Please add \`${key}Action\` when creating your handler.`);
21115
21102
  return /* @__PURE__ */ React__namespace.createElement(React__namespace.Fragment, null, /* @__PURE__ */ React__namespace.createElement(
21116
21103
  Overlay,
21117
21104
  {
21118
- visible: true,
21105
+ visible: show2,
21119
21106
  style,
21120
21107
  className: `${classPrefix$7}__overlay-default ${className}`,
21121
21108
  onClick: () => {
21122
- console.log("onclick");
21123
21109
  this.clickCover();
21124
21110
  },
21125
21111
  closeOnOverlayClick
@@ -21140,9 +21126,9 @@ Please add \`${key}Action\` when creating your handler.`);
21140
21126
  __publicField(Notification, "newInstance");
21141
21127
  Notification.newInstance = (properties, callback) => {
21142
21128
  const element = document.createElement("div");
21143
- if (properties.id) {
21144
- element.setAttribute("id", `${properties.id}`);
21145
- }
21129
+ const id = properties.id ? properties.id : `${(/* @__PURE__ */ new Date()).getTime()}`;
21130
+ element.id = id;
21131
+ properties.id = id;
21146
21132
  document.body.appendChild(element);
21147
21133
  let called = false;
21148
21134
  function ref(instance) {