@nutui/nutui-react-taro 2.7.6 → 2.7.8

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 (54) hide show
  1. package/CHANGELOG.md +29 -7
  2. package/dist/esm/Address/style/style.css +1 -1
  3. package/dist/esm/Address.js +1 -1
  4. package/dist/esm/Animate/style/style.css +1 -1
  5. package/dist/esm/Animate.js +1 -1
  6. package/dist/esm/Calendar/style/style.css +1 -1
  7. package/dist/esm/Calendar.js +1 -1
  8. package/dist/esm/CalendarCard.js +1 -1
  9. package/dist/esm/CalendarItem.js +1 -1
  10. package/dist/esm/Cascader/style/style.css +1 -1
  11. package/dist/esm/Cascader.js +1 -1
  12. package/dist/esm/DatePicker.js +1 -1
  13. package/dist/esm/Empty.js +1 -1
  14. package/dist/esm/Form.js +2 -1
  15. package/dist/esm/FormItem.js +1 -1
  16. package/dist/esm/TabPane.js +1 -1
  17. package/dist/esm/Tabs/style/style.css +1 -1
  18. package/dist/esm/Tabs.js +1 -1
  19. package/dist/esm/{address.taro-BCoDZM6h.js → address.taro-Ck0ZmxRg.js} +1 -1
  20. package/dist/esm/{animate.taro-CQVEyDKL.js → animate.taro-BHDZMzJF.js} +9 -12
  21. package/dist/esm/{calendar.taro-CM4yWFlF.js → calendar.taro-CUDVpJBa.js} +3 -3
  22. package/dist/esm/{calendarcard.taro-CvWyBqnr.js → calendarcard.taro-BiOnui_b.js} +4 -4
  23. package/dist/esm/{calendaritem.taro-BGbbuJOS.js → calendaritem.taro-DveeC4_t.js} +237 -219
  24. package/dist/esm/{cascader.taro-BwRnRQXE.js → cascader.taro-DUJvcGw0.js} +1 -1
  25. package/dist/esm/date-BmUWlDuN.js +147 -0
  26. package/dist/esm/{datepicker.taro-DicskhhH.js → datepicker.taro-Dwh8sKhJ.js} +8 -0
  27. package/dist/esm/{empty.taro-DhCHSdca.js → empty.taro-ChtnK90s.js} +1 -1
  28. package/dist/esm/{formitem.taro-CU6rrcJD.js → formitem.taro-Bee3MWwq.js} +121 -31
  29. package/dist/esm/nutui-react.es.js +11 -11
  30. package/dist/esm/{tabpane.taro-BAe86j3t.js → tabpane.taro-BAihO3w8.js} +2 -1
  31. package/dist/esm/{tabs.taro-CnXiMR_B.js → tabs.taro-sp_DNWis.js} +26 -44
  32. package/dist/locales/base.js +1 -1
  33. package/dist/locales/en-US.js +1 -1
  34. package/dist/locales/id-ID.js +1 -1
  35. package/dist/locales/tr-TR.js +1 -1
  36. package/dist/locales/zh-CN.js +1 -1
  37. package/dist/locales/zh-TW.js +1 -1
  38. package/dist/locales/zh-UG.js +1 -1
  39. package/dist/nutui.react.es.js +529 -555
  40. package/dist/nutui.react.umd.js +529 -555
  41. package/dist/packages/animate/animate.scss +63 -105
  42. package/dist/packages/calendar/calendar.scss +9 -9
  43. package/dist/packages/tabs/tabs.scss +72 -115
  44. package/dist/style.css +1 -1
  45. package/dist/types/packages/animate/animate.taro.d.ts +2 -1
  46. package/dist/types/packages/form/__tests__/merge.spec.d.ts +1 -0
  47. package/dist/types/packages/form/index.d.ts +2 -1
  48. package/dist/types/packages/form/index.taro.d.ts +2 -1
  49. package/dist/types/packages/form/useform.d.ts +2 -1
  50. package/dist/types/packages/form/useform.taro.d.ts +2 -1
  51. package/dist/types/utils/date.d.ts +54 -52
  52. package/dist/types/utils/merge.d.ts +14 -1
  53. package/package.json +1 -1
  54. package/dist/esm/date-CYwRNlGq.js +0 -219
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @nutui/nutui-react-taro v2.7.6 Fri Jan 10 2025 10:43:35 GMT+0800 (China Standard Time)
2
+ * @nutui/nutui-react-taro v2.7.8 Fri Feb 14 2025 16:17:59 GMT+0800 (China Standard Time)
3
3
  * (c) 2023 @jdf2e.
4
4
  * Released under the MIT License.
5
5
  */
@@ -1349,7 +1349,7 @@ lodash_isequal.exports;
1349
1349
  return value != null && isLength(value.length) && !isFunction2(value);
1350
1350
  }
1351
1351
  var isBuffer = nativeIsBuffer || stubFalse;
1352
- function isEqual(value, other) {
1352
+ function isEqual2(value, other) {
1353
1353
  return baseIsEqual(value, other);
1354
1354
  }
1355
1355
  function isFunction2(value) {
@@ -1379,7 +1379,7 @@ lodash_isequal.exports;
1379
1379
  function stubFalse() {
1380
1380
  return false;
1381
1381
  }
1382
- module.exports = isEqual;
1382
+ module.exports = isEqual2;
1383
1383
  })(lodash_isequal, lodash_isequal.exports);
1384
1384
  var lodash_isequalExports = lodash_isequal.exports;
1385
1385
  const isequal = /* @__PURE__ */ getDefaultExportFromCjs(lodash_isequalExports);
@@ -3922,7 +3922,7 @@ const Space = (props) => {
3922
3922
  }));
3923
3923
  };
3924
3924
  Space.displayName = "NutSpace";
3925
- function useWatch(dep, callback, config2 = { immediate: false }) {
3925
+ function useWatch$1(dep, callback, config2 = { immediate: false }) {
3926
3926
  const { immediate } = config2;
3927
3927
  const prev = useRef();
3928
3928
  const inited = useRef(false);
@@ -4058,7 +4058,7 @@ const Sticky = (props) => {
4058
4058
  const [rootRect, setRootRect] = useState({});
4059
4059
  const [fixed, setFixed] = useState(false);
4060
4060
  const [transform, setTransform] = useState(0);
4061
- useWatch(fixed, () => {
4061
+ useWatch$1(fixed, () => {
4062
4062
  onChange && onChange(fixed);
4063
4063
  });
4064
4064
  const rootStyle = useMemo$1(() => {
@@ -5253,7 +5253,7 @@ const TabPane = (props) => {
5253
5253
  autoHeightClassName,
5254
5254
  className
5255
5255
  );
5256
- return children ? /* @__PURE__ */ React__default.createElement("div", { className: classes }, !disabled && children) : null;
5256
+ return children && /* @__PURE__ */ React__default.createElement(View, { className: classes }, !disabled && children);
5257
5257
  };
5258
5258
  const inBrowser = typeof window !== "undefined";
5259
5259
  function requestAniFrame() {
@@ -5297,24 +5297,19 @@ const Tabs = (props) => {
5297
5297
  value: outerValue,
5298
5298
  defaultValue: outerDefaultValue,
5299
5299
  ...rest
5300
- } = {
5301
- ...defaultProps$18,
5302
- ...props
5303
- };
5300
+ } = { ...defaultProps$18, ...props };
5304
5301
  const uuid = useUuid();
5305
5302
  const [value, setValue] = usePropsValue({
5306
5303
  value: outerValue,
5307
5304
  defaultValue: outerDefaultValue,
5308
- finalValue: 0,
5309
5305
  onChange
5310
5306
  });
5311
5307
  const titleItemsRef = useRef([]);
5312
- const navRef = useRef(null);
5313
5308
  const getTitles = () => {
5314
5309
  const titles2 = [];
5315
5310
  React__default.Children.forEach(children, (child, idx) => {
5316
5311
  if (React__default.isValidElement(child)) {
5317
- const props2 = child == null ? void 0 : child.props;
5312
+ const { props: props2 } = child;
5318
5313
  if ((props2 == null ? void 0 : props2.title) || (props2 == null ? void 0 : props2.value)) {
5319
5314
  titles2.push({
5320
5315
  title: props2.title,
@@ -5349,13 +5344,8 @@ const Tabs = (props) => {
5349
5344
  );
5350
5345
  const classesTitle = classNames(`${classPrefix$k}-titles`, {
5351
5346
  [`${classPrefix$k}-titles-${activeType}`]: activeType,
5352
- [`${classPrefix$k}-titles-scrollable`]: true,
5353
5347
  [`${classPrefix$k}-titles-${align}`]: align
5354
5348
  });
5355
- const tabsActiveStyle = {
5356
- color: activeType === "smile" ? activeColor : "",
5357
- background: activeType === "line" ? activeColor : ""
5358
- };
5359
5349
  const getRect2 = (selector) => {
5360
5350
  return new Promise((resolve) => {
5361
5351
  createSelectorQuery().select(selector).boundingClientRect().exec((rect = []) => {
@@ -5371,22 +5361,15 @@ const Tabs = (props) => {
5371
5361
  });
5372
5362
  };
5373
5363
  const scrollWithAnimation = useRef(false);
5374
- const navRectRef = useRef();
5375
- const titleRectRef = useRef([]);
5376
5364
  const [scrollLeft, setScrollLeft] = useState(0);
5377
5365
  const [scrollTop, setScrollTop] = useState(0);
5378
5366
  const scrollDirection = (to, direction2) => {
5379
5367
  let count = 0;
5380
5368
  const frames = 1;
5381
5369
  function animate() {
5382
- if (direction2 === "horizontal") {
5383
- setScrollLeft(to);
5384
- } else {
5385
- setScrollTop(to);
5386
- }
5387
- if (++count < frames) {
5388
- requestAniFrame$1(animate);
5389
- }
5370
+ if (direction2 === "horizontal") setScrollLeft(to);
5371
+ else setScrollTop(to);
5372
+ if (++count < frames) requestAniFrame$1(animate);
5390
5373
  }
5391
5374
  animate();
5392
5375
  };
@@ -5396,17 +5379,17 @@ const Tabs = (props) => {
5396
5379
  getRect2(`#nut-tabs-titles-${name || uuid} .nut-tabs-list`),
5397
5380
  getAllRect(`#nut-tabs-titles-${name || uuid} .nut-tabs-titles-item`)
5398
5381
  ]).then(([navRect, titleRects]) => {
5399
- navRectRef.current = navRect;
5400
- titleRectRef.current = titleRects;
5401
- const titleRect = titleRectRef.current[index];
5382
+ const titleRect = titleRects[index];
5402
5383
  if (!titleRect) return;
5403
5384
  let to = 0;
5404
5385
  if (direction === "vertical") {
5405
5386
  const top = titleRects.slice(0, index).reduce((prev, curr) => prev + curr.height, 0);
5406
- to = top - (navRectRef.current.height - titleRect.height) / 2;
5387
+ to = top - (navRect.height - titleRect.height) / 2;
5407
5388
  } else {
5408
5389
  const left2 = titleRects.slice(0, index).reduce((prev, curr) => prev + curr.width, 0);
5409
- to = rtl ? -left2 : left2;
5390
+ to = left2 - (navRect.width - titleRect.width) / 2;
5391
+ if (to < 0) return;
5392
+ to = rtl ? -to : to;
5410
5393
  }
5411
5394
  nextTick(() => {
5412
5395
  scrollWithAnimation.current = true;
@@ -5421,7 +5404,7 @@ const Tabs = (props) => {
5421
5404
  );
5422
5405
  index = index < 0 ? 0 : index;
5423
5406
  return {
5424
- transform: direction === "horizontal" ? `translate3d(${rtl ? "" : "-"}${index * 100}%, 0, 0)` : `translate3d( 0,-${index * 100}%, 0)`,
5407
+ transform: direction === "horizontal" ? `translate3d(${rtl ? "" : "-"}${index * 100}%, 0, 0)` : `translate3d( 0, -${index * 100}%, 0)`,
5425
5408
  transitionDuration: `${duration}ms`
5426
5409
  };
5427
5410
  };
@@ -5432,12 +5415,11 @@ const Tabs = (props) => {
5432
5415
  index = index < 0 ? 0 : index;
5433
5416
  scrollIntoView(index);
5434
5417
  }, [value]);
5435
- const tabChange = (item, index) => {
5418
+ const tabChange = (item) => {
5436
5419
  onClick && onClick(item.value);
5437
- if (item.disabled) {
5438
- return;
5420
+ if (!item.disabled) {
5421
+ setValue(item.value);
5439
5422
  }
5440
- setValue(item.value);
5441
5423
  };
5442
5424
  return /* @__PURE__ */ React__default.createElement(View, { className: classes, ...rest }, /* @__PURE__ */ React__default.createElement(
5443
5425
  ScrollView,
@@ -5452,71 +5434,55 @@ const Tabs = (props) => {
5452
5434
  scrollWithAnimation: rtl && Taro.getEnv() !== "WEB" ? false : scrollWithAnimation.current,
5453
5435
  id: `nut-tabs-titles-${name || uuid}`,
5454
5436
  className: classesTitle,
5455
- style: { ...tabStyle }
5437
+ style: tabStyle
5456
5438
  },
5457
- /* @__PURE__ */ React__default.createElement(View, { className: "nut-tabs-list", ref: navRef }, !!title && typeof title === "function" ? title() : titles.current.map((item, index) => {
5439
+ /* @__PURE__ */ React__default.createElement(View, { className: "nut-tabs-list" }, !!title && typeof title === "function" ? title() : titles.current.map((item, index) => {
5458
5440
  return /* @__PURE__ */ React__default.createElement(
5459
5441
  View,
5460
5442
  {
5443
+ key: item.value,
5461
5444
  ref: (ref) => titleItemsRef.current.push(ref),
5462
5445
  id: `scrollIntoView${index}`,
5463
- onClick: (e2) => {
5464
- tabChange(item);
5465
- },
5446
+ onClick: () => tabChange(item),
5466
5447
  className: classNames(`${classPrefix$k}-titles-item`, {
5467
5448
  [`nut-tabs-titles-item-active`]: !item.disabled && String(item.value) === String(value),
5468
5449
  [`nut-tabs-titles-item-disabled`]: item.disabled,
5469
5450
  [`nut-tabs-titles-item-${align}`]: align
5470
- }),
5471
- key: item.value
5451
+ })
5472
5452
  },
5473
5453
  activeType === "line" && /* @__PURE__ */ React__default.createElement(
5474
5454
  View,
5475
5455
  {
5476
5456
  className: classNames(
5477
5457
  `${classPrefix$k}-titles-item-line`,
5478
- {
5479
- [`${classPrefix$k}-titles-item-line-${direction}`]: true
5480
- }
5458
+ `${classPrefix$k}-titles-item-line-${direction}`
5481
5459
  ),
5482
- style: tabsActiveStyle
5460
+ style: { background: activeColor }
5483
5461
  }
5484
5462
  ),
5485
- activeType === "smile" && /* @__PURE__ */ React__default.createElement(
5486
- View,
5487
- {
5488
- className: `${classPrefix$k}-titles-item-smile`,
5489
- style: tabsActiveStyle
5490
- },
5491
- /* @__PURE__ */ React__default.createElement(L$1, { color: activeColor })
5492
- ),
5463
+ activeType === "smile" && /* @__PURE__ */ React__default.createElement(View, { className: `${classPrefix$k}-titles-item-smile` }, /* @__PURE__ */ React__default.createElement(L$1, { color: activeColor })),
5493
5464
  /* @__PURE__ */ React__default.createElement(
5494
5465
  View,
5495
5466
  {
5496
5467
  className: classNames(
5497
- `${classPrefix$k}-ellipsis`,
5468
+ {
5469
+ [`${classPrefix$k}-ellipsis`]: direction === "vertical"
5470
+ },
5498
5471
  `${classPrefix$k}-titles-item-text`
5499
- )
5472
+ ),
5473
+ style: { color: activeColor }
5500
5474
  },
5501
5475
  item.title
5502
5476
  )
5503
5477
  );
5504
5478
  }))
5505
5479
  ), /* @__PURE__ */ React__default.createElement(View, { className: `${classPrefix$k}-content-wrap` }, /* @__PURE__ */ React__default.createElement(View, { className: `${classPrefix$k}-content`, style: getContentStyle() }, React__default.Children.map(children, (child, idx) => {
5506
- if (!React__default.isValidElement(child)) {
5507
- return null;
5508
- }
5509
- let childProps = {
5480
+ if (!React__default.isValidElement(child)) return null;
5481
+ return React__default.cloneElement(child, {
5510
5482
  ...child.props,
5511
- active: value === child.props.value
5512
- };
5513
- if (String(value) !== String(child.props.value || idx) && autoHeight) {
5514
- childProps = {
5515
- ...childProps,
5516
- autoHeightClassName: "inactive"
5517
- };
5518
- }
5519
- return React__default.cloneElement(child, childProps);
5483
+ active: value === child.props.value,
5484
+ autoHeightClassName: autoHeight && String(value) !== String(child.props.value || idx) ? "inactive" : void 0
5485
+ });
5520
5486
  }))));
5521
5487
  };
5522
5488
  Tabs.displayName = "NutTabs";
@@ -6246,189 +6212,106 @@ const InternalAddress = (props, ref) => {
6246
6212
  };
6247
6213
  const Address = forwardRef(InternalAddress);
6248
6214
  Address.displayName = "NutAddress";
6249
- const Utils = {
6250
- /**
6251
- * 是否为闫年
6252
- * @return {Boolse} true|false
6253
- */
6254
- isLeapYear(y2) {
6255
- return y2 % 4 === 0 && y2 % 100 !== 0 || y2 % 400 === 0;
6256
- },
6257
- /**
6258
- * 返回星期数
6259
- * @return {String}
6260
- */
6261
- getWhatDay(year, month, day) {
6262
- const date4 = /* @__PURE__ */ new Date(`${year}/${month}/${day}`);
6263
- const index = date4.getDay();
6264
- const dayNames = [
6265
- "星期日",
6266
- "星期一",
6267
- "星期二",
6268
- "星期三",
6269
- "星期四",
6270
- "星期五",
6271
- "星期六"
6272
- ];
6273
- return dayNames[index];
6274
- },
6275
- /**
6276
- * 返回上一个月在当前面板中的天数
6277
- * @return {Number}
6278
- */
6279
- getMonthPreDay(year, month) {
6280
- const date4 = /* @__PURE__ */ new Date(`${year}/${month}/01`);
6281
- let day = date4.getDay();
6282
- if (day === 0) {
6283
- day = 7;
6284
- }
6285
- return day;
6286
- },
6287
- /**
6288
- * 返回月份天数
6289
- * @return {Number}
6290
- */
6291
- getMonthDays(year, month) {
6292
- if (/^0/.test(month)) {
6293
- month = month.split("")[1];
6294
- }
6295
- return [
6296
- 0,
6297
- 31,
6298
- this.isLeapYear(Number(year)) ? 29 : 28,
6299
- 31,
6300
- 30,
6301
- 31,
6302
- 30,
6303
- 31,
6304
- 31,
6305
- 30,
6306
- 31,
6307
- 30,
6308
- 31
6309
- ][month];
6310
- },
6311
- /**
6312
- * 补齐数字位数
6313
- * @return {string}
6314
- */
6315
- getNumTwoBit(n2) {
6316
- n2 = Number(n2);
6317
- return (n2 > 9 ? "" : "0") + n2;
6318
- },
6319
- /**
6320
- * 日期对象转成字符串
6321
- * @return {string}
6322
- */
6323
- date2Str(date4, split) {
6324
- split = split || "-";
6325
- const y2 = date4.getFullYear();
6326
- const m2 = this.getNumTwoBit(date4.getMonth() + 1);
6327
- const d = this.getNumTwoBit(date4.getDate());
6328
- return [y2, m2, d].join(split);
6329
- },
6330
- /**
6331
- * 返回日期格式字符串
6332
- * @param {Number} 0返回今天的日期、1返回明天的日期,2返回后天得日期,依次类推
6333
- * @return {string} '2014-12-31'
6334
- */
6335
- getDay(i2) {
6336
- i2 = i2 || 0;
6337
- let date4 = /* @__PURE__ */ new Date();
6338
- const diff = i2 * (1e3 * 60 * 60 * 24);
6339
- date4 = new Date(date4.getTime() + diff);
6340
- return this.date2Str(date4);
6341
- },
6342
- /**
6343
- * 时间比较
6344
- * @return {Boolean}
6345
- */
6346
- compareDate(date1, date22) {
6347
- const startTime = new Date(date1.replace("-", "/").replace("-", "/"));
6348
- const endTime = new Date(date22.replace("-", "/").replace("-", "/"));
6349
- if (startTime >= endTime) {
6350
- return false;
6351
- }
6352
- return true;
6353
- },
6354
- /**
6355
- * 时间是否相等
6356
- * @return {Boolean}
6357
- */
6358
- isEqual(date1, date22) {
6359
- const startTime = new Date((date1 || "").replace(/-/g, "/")).getTime();
6360
- const endTime = new Date(date22.replace(/-/g, "/")).getTime();
6361
- if (startTime === endTime) {
6362
- return true;
6363
- }
6364
- return false;
6365
- },
6366
- getMonthWeek(year, month, date4, firstDayOfWeek = 0) {
6367
- const dateNow = new Date(Number(year), parseInt(month) - 1, Number(date4));
6368
- let w = dateNow.getDay();
6369
- const d = dateNow.getDate();
6370
- let remainder = 6 - w;
6371
- if (firstDayOfWeek !== 0) {
6372
- w = w === 0 ? 7 : w;
6373
- remainder = 7 - w;
6374
- }
6375
- return Math.ceil((d + remainder) / 7);
6376
- },
6377
- getYearWeek(year, month, date4, firstDayOfWeek = 0) {
6378
- const dateNow = new Date(Number(year), parseInt(month) - 1, Number(date4));
6379
- const dateFirst = new Date(Number(year), 0, 1);
6380
- const dataNumber = Math.round(
6381
- (dateNow.valueOf() - dateFirst.valueOf()) / 864e5
6382
- );
6383
- return Math.ceil((dataNumber + (dateFirst.getDay() + 1 - 1)) / 7);
6384
- },
6385
- getWeekDate(year, month, date4, firstDayOfWeek = 0) {
6386
- const dateNow = new Date(Number(year), parseInt(month) - 1, Number(date4));
6387
- const nowTime = dateNow.getTime();
6388
- let day = dateNow.getDay();
6389
- if (firstDayOfWeek === 0) {
6390
- const oneDayTime2 = 24 * 60 * 60 * 1e3;
6391
- const SundayTime2 = nowTime - day * oneDayTime2;
6392
- const SaturdayTime = nowTime + (6 - day) * oneDayTime2;
6393
- const sunday2 = this.date2Str(new Date(SundayTime2));
6394
- const saturday = this.date2Str(new Date(SaturdayTime));
6395
- return [sunday2, saturday];
6396
- }
6397
- day = day === 0 ? 7 : day;
6398
- const oneDayTime = 24 * 60 * 60 * 1e3;
6399
- const MondayTime = nowTime - (day - 1) * oneDayTime;
6400
- const SundayTime = nowTime + (7 - day) * oneDayTime;
6401
- const monday = this.date2Str(new Date(MondayTime));
6402
- const sunday = this.date2Str(new Date(SundayTime));
6403
- return [monday, sunday];
6404
- },
6405
- formatResultDate(date4) {
6406
- const days = [...date4.split("-")];
6407
- days[2] = Utils.getNumTwoBit(Number(days[2]));
6408
- days[3] = `${days[0]}-${days[1]}-${days[2]}`;
6409
- days[4] = Utils.getWhatDay(+days[0], +days[1], +days[2]);
6410
- return days;
6215
+ const isLeapYear = (y2) => {
6216
+ return y2 % 4 === 0 && y2 % 100 !== 0 || y2 % 400 === 0;
6217
+ };
6218
+ const getWhatDay = (year, month, day) => {
6219
+ const date4 = new Date(year, month - 1, day);
6220
+ const dayNames = [
6221
+ "星期日",
6222
+ "星期一",
6223
+ "星期二",
6224
+ "星期三",
6225
+ "星期四",
6226
+ "星期五",
6227
+ "星期六"
6228
+ ];
6229
+ return dayNames[date4.getDay()];
6230
+ };
6231
+ const getMonthPreDay = (year, month) => {
6232
+ const day = new Date(year, month - 1, 1).getDay();
6233
+ return day === 0 ? 7 : day;
6234
+ };
6235
+ const getMonthDays = (year, month) => {
6236
+ if (/^0/.test(month)) {
6237
+ month = month.split("")[1];
6238
+ }
6239
+ return [
6240
+ 0,
6241
+ 31,
6242
+ isLeapYear(Number(year)) ? 29 : 28,
6243
+ 31,
6244
+ 30,
6245
+ 31,
6246
+ 30,
6247
+ 31,
6248
+ 31,
6249
+ 30,
6250
+ 31,
6251
+ 30,
6252
+ 31
6253
+ ][month];
6254
+ };
6255
+ const getNumTwoBit = (n2) => {
6256
+ return n2 > 9 ? `${n2}` : `0${n2}`;
6257
+ };
6258
+ const date2Str = (date4, split = "-") => {
6259
+ const y2 = date4.getFullYear();
6260
+ const m2 = getNumTwoBit(date4.getMonth() + 1);
6261
+ const d = getNumTwoBit(date4.getDate());
6262
+ return [y2, m2, d].join(split);
6263
+ };
6264
+ const getDateString = (offset = 0) => {
6265
+ const date4 = /* @__PURE__ */ new Date();
6266
+ date4.setDate(date4.getDate() + offset);
6267
+ return date2Str(date4, "-");
6268
+ };
6269
+ const compareDate = (date1, date22) => {
6270
+ const startTime = new Date(date1.replace("-", "/").replace("-", "/"));
6271
+ const endTime = new Date(date22.replace("-", "/").replace("-", "/"));
6272
+ return startTime < endTime;
6273
+ };
6274
+ const isEqual = (date1, date22) => {
6275
+ const startTime = new Date((date1 || "").replace(/-/g, "/")).getTime();
6276
+ const endTime = new Date(date22.replace(/-/g, "/")).getTime();
6277
+ return startTime === endTime;
6278
+ };
6279
+ const getWeekDate = (year, month, date4, firstDayOfWeek = 0) => {
6280
+ const dateNow = new Date(Number(year), parseInt(month) - 1, Number(date4));
6281
+ const nowTime = dateNow.getTime();
6282
+ let day = dateNow.getDay();
6283
+ if (firstDayOfWeek === 0) {
6284
+ const oneDayTime2 = 24 * 60 * 60 * 1e3;
6285
+ const SundayTime2 = nowTime - day * oneDayTime2;
6286
+ const SaturdayTime = nowTime + (6 - day) * oneDayTime2;
6287
+ const sunday2 = date2Str(new Date(SundayTime2));
6288
+ const saturday = date2Str(new Date(SaturdayTime));
6289
+ return [sunday2, saturday];
6411
6290
  }
6291
+ day = day === 0 ? 7 : day;
6292
+ const oneDayTime = 24 * 60 * 60 * 1e3;
6293
+ const MondayTime = nowTime - (day - 1) * oneDayTime;
6294
+ const SundayTime = nowTime + (7 - day) * oneDayTime;
6295
+ const monday = date2Str(new Date(MondayTime));
6296
+ const sunday = date2Str(new Date(SundayTime));
6297
+ return [monday, sunday];
6298
+ };
6299
+ const formatResultDate = (date4) => {
6300
+ const [year, month, day] = [...date4.split("-")];
6301
+ const formatterDay = getNumTwoBit(Number(day));
6302
+ const formatterDate = `${year}-${month}-${day}`;
6303
+ const dayOfWeek = getWhatDay(Number(year), Number(month), Number(day));
6304
+ return [year, month, formatterDay, formatterDate, dayOfWeek];
6412
6305
  };
6413
6306
  const getCurrMonthData = (type4, year, month) => {
6414
- switch (type4) {
6415
- case "prev":
6416
- month === 1 && (year -= 1);
6417
- month = month === 1 ? 12 : --month;
6418
- break;
6419
- case "next":
6420
- month === 12 && (year += 1);
6421
- month = month === 12 ? 1 : ++month;
6422
- break;
6307
+ {
6308
+ month === 12 && (year += 1);
6309
+ month = month === 12 ? 1 : ++month;
6423
6310
  }
6424
- return [
6425
- year,
6426
- Utils.getNumTwoBit(month),
6427
- Utils.getMonthDays(String(year), String(month))
6428
- ];
6311
+ return [year, getNumTwoBit(month), getMonthDays(String(year), String(month))];
6429
6312
  };
6430
6313
  const getDaysStatus = (type4, year, month) => {
6431
- let days = Utils.getMonthDays(`${year}`, `${month}`);
6314
+ let days = getMonthDays(`${year}`, `${month}`);
6432
6315
  return Array.from(Array(days), (v, k) => {
6433
6316
  return {
6434
6317
  day: k + 1,
@@ -6445,12 +6328,12 @@ const getPreMonthDates = (type4, year, month, firstDayOfWeek) => {
6445
6328
  preMonth = 12;
6446
6329
  preYear += 1;
6447
6330
  }
6448
- let days = Utils.getMonthPreDay(+year, +month);
6331
+ let days = getMonthPreDay(+year, +month);
6449
6332
  days -= firstDayOfWeek;
6450
6333
  if (days >= 7) {
6451
6334
  days -= 7;
6452
6335
  }
6453
- const preDates = Utils.getMonthDays(`${preYear}`, `${preMonth}`);
6336
+ const preDates = getMonthDays(`${preYear}`, `${preMonth}`);
6454
6337
  const months = Array.from(Array(preDates), (v, k) => {
6455
6338
  return {
6456
6339
  day: k + 1,
@@ -6468,28 +6351,26 @@ const splitDate = (date4) => {
6468
6351
  const isMultiple = (day, days) => {
6469
6352
  if (days.length > 0) {
6470
6353
  return days.some((item) => {
6471
- return Utils.isEqual(item, day);
6354
+ return isEqual(item, day);
6472
6355
  });
6473
6356
  }
6474
6357
  return false;
6475
6358
  };
6476
6359
  const isCurrDay = (month, day) => {
6477
6360
  const date4 = `${month.curData[0]}/${month.curData[1]}/${day}`;
6478
- return Utils.isEqual(date4, Utils.date2Str(/* @__PURE__ */ new Date(), "/"));
6361
+ return isEqual(date4, date2Str(/* @__PURE__ */ new Date(), "/"));
6479
6362
  };
6480
6363
  const getCurrDate = (day, month) => {
6481
- return `${month.curData[0]}/${month.curData[1]}/${Utils.getNumTwoBit(
6482
- +day.day
6483
- )}`;
6364
+ return `${month.curData[0]}/${month.curData[1]}/${getNumTwoBit(+day.day)}`;
6484
6365
  };
6485
6366
  const isStart = (day, days) => {
6486
- return Utils.isEqual(days[0], day);
6367
+ return isEqual(days[0], day);
6487
6368
  };
6488
6369
  const isEnd = (day, days) => {
6489
- return Utils.isEqual(days[1], day);
6370
+ return isEqual(days[1], day);
6490
6371
  };
6491
6372
  const isStartAndEnd = (days) => {
6492
- return days.length >= 2 && Utils.isEqual(days[0], days[1]);
6373
+ return days.length >= 2 && isEqual(days[0], days[1]);
6493
6374
  };
6494
6375
  const defaultProps$13 = {
6495
6376
  ...ComponentDefaults,
@@ -6497,8 +6378,8 @@ const defaultProps$13 = {
6497
6378
  autoBackfill: false,
6498
6379
  popup: true,
6499
6380
  title: "",
6500
- startDate: Utils.getDay(0),
6501
- endDate: Utils.getDay(365),
6381
+ startDate: getDateString(0),
6382
+ endDate: getDateString(365),
6502
6383
  showToday: true,
6503
6384
  startText: "",
6504
6385
  endText: "",
@@ -6531,6 +6412,7 @@ const CalendarItem = React__default.forwardRef((props, ref) => {
6531
6412
  type: type4,
6532
6413
  autoBackfill,
6533
6414
  title,
6415
+ value,
6534
6416
  defaultValue,
6535
6417
  startDate,
6536
6418
  endDate,
@@ -6548,12 +6430,13 @@ const CalendarItem = React__default.forwardRef((props, ref) => {
6548
6430
  renderDayTop,
6549
6431
  renderDayBottom,
6550
6432
  renderBottomButton,
6551
- value,
6552
6433
  onConfirm,
6553
6434
  onUpdate,
6554
6435
  onDayClick,
6555
6436
  onPageChange
6556
6437
  } = { ...defaultProps$13, ...props };
6438
+ const classPrefix2 = "nut-calendar";
6439
+ const dayPrefix = "nut-calendar-day";
6557
6440
  const weekdays = locale.calendaritem.weekdays;
6558
6441
  const weeks = [
6559
6442
  ...weekdays.slice(firstDayOfWeek, 7),
@@ -6567,19 +6450,13 @@ const CalendarItem = React__default.forwardRef((props, ref) => {
6567
6450
  const [monthDefaultRange, setMonthDefaultRange] = useState([]);
6568
6451
  const [scrollTop, setScrollTop] = useState(0);
6569
6452
  const [scrollWithAnimation, setScrollWithAnimation] = useState(false);
6570
- const propStartDate = startDate || Utils.getDay(0);
6571
- const propEndDate = endDate || Utils.getDay(365);
6453
+ const propStartDate = startDate || getDateString(0);
6454
+ const propEndDate = endDate || getDateString(365);
6572
6455
  const startDates = splitDate(propStartDate);
6573
6456
  const endDates = splitDate(propEndDate);
6574
6457
  const [state] = useState({
6575
6458
  currDateArray: []
6576
6459
  });
6577
- const getMonthsPanel = () => {
6578
- return monthsPanel.current;
6579
- };
6580
- const getMonthsRef = () => {
6581
- return monthsRef.current;
6582
- };
6583
6460
  const resetDefaultValue = () => {
6584
6461
  if (defaultValue || Array.isArray(defaultValue) && defaultValue.length > 0) {
6585
6462
  return type4 !== "single" ? [...defaultValue] : defaultValue;
@@ -6599,9 +6476,7 @@ const CalendarItem = React__default.forwardRef((props, ref) => {
6599
6476
  const viewAreaRef = useRef(null);
6600
6477
  const [avgHeight, setAvgHeight] = useState(0);
6601
6478
  let viewHeight = 0;
6602
- const classPrefix2 = "nut-calendar";
6603
- const dayPrefix = "nut-calendar-day";
6604
- const getMonthData = (curData, monthNum, type22) => {
6479
+ const getMonthData = (curData, monthNum) => {
6605
6480
  let i2 = 0;
6606
6481
  let date4 = curData;
6607
6482
  const monthData = monthsData;
@@ -6612,12 +6487,12 @@ const CalendarItem = React__default.forwardRef((props, ref) => {
6612
6487
  ...getPreMonthDates("prev", y2, m2, firstDayOfWeek),
6613
6488
  ...getDaysStatus("active", y2, m2)
6614
6489
  ];
6615
- const cssHeight = 39 + (days.length > 35 ? 384 : 320);
6616
6490
  let scrollTop2 = 0;
6617
6491
  if (monthData.length > 0) {
6618
6492
  const monthEle = monthData[monthData.length - 1];
6619
6493
  scrollTop2 = monthEle.scrollTop + monthEle.cssHeight;
6620
6494
  }
6495
+ const cssHeight = 39 + (days.length > 35 ? 384 : 320);
6621
6496
  const monthInfo = {
6622
6497
  curData: date4,
6623
6498
  title: monthTitle(y2, m2),
@@ -6625,16 +6500,14 @@ const CalendarItem = React__default.forwardRef((props, ref) => {
6625
6500
  cssHeight,
6626
6501
  scrollTop: scrollTop2
6627
6502
  };
6628
- {
6629
- if (!endDates || !Utils.compareDate(
6630
- `${endDates[0]}/${endDates[1]}/${Utils.getMonthDays(
6631
- endDates[0],
6632
- endDates[1]
6633
- )}`,
6634
- `${curData[0]}/${curData[1]}/${curData[2]}`
6635
- )) {
6636
- monthData.push(monthInfo);
6637
- }
6503
+ if (!endDates || !compareDate(
6504
+ `${endDates[0]}/${endDates[1]}/${getMonthDays(
6505
+ endDates[0],
6506
+ endDates[1]
6507
+ )}`,
6508
+ `${curData[0]}/${curData[1]}/${curData[2]}`
6509
+ )) {
6510
+ monthData.push(monthInfo);
6638
6511
  }
6639
6512
  date4 = getCurrMonthData("next", y2, m2);
6640
6513
  } while (i2++ < monthNum);
@@ -6642,8 +6515,8 @@ const CalendarItem = React__default.forwardRef((props, ref) => {
6642
6515
  };
6643
6516
  const setReachedYearMonthInfo = (current) => {
6644
6517
  const currentMonthsData = monthsData[current];
6645
- const [year, month] = currentMonthsData.curData;
6646
6518
  if (currentMonthsData.title === yearMonthTitle) return;
6519
+ const [year, month] = currentMonthsData.curData;
6647
6520
  onPageChange && onPageChange([year, month, `${year}-${month}`]);
6648
6521
  setYearMonthTitle(currentMonthsData.title);
6649
6522
  };
@@ -6669,75 +6542,67 @@ const CalendarItem = React__default.forwardRef((props, ref) => {
6669
6542
  setTranslateY(monthsData[start].scrollTop);
6670
6543
  setReachedYearMonthInfo(current);
6671
6544
  };
6672
- const getMonthNum = () => {
6673
- let monthNum = Number(endDates[1]) - Number(startDates[1]);
6674
- const yearNum = Number(endDates[0]) - Number(startDates[0]);
6675
- if (yearNum > 0) {
6676
- monthNum += 12 * yearNum;
6677
- }
6678
- if (monthNum <= 0) {
6679
- monthNum = 1;
6680
- }
6681
- setMonthsNum(monthNum);
6682
- return monthNum;
6683
- };
6684
6545
  const setDefaultDate = () => {
6685
6546
  let defaultData = [];
6686
- if (type4 === "range" && Array.isArray(currentDate)) {
6687
- if (currentDate.length > 0) {
6688
- if (propStartDate && Utils.compareDate(currentDate[0], propStartDate)) {
6689
- currentDate.splice(0, 1, propStartDate);
6690
- }
6691
- if (propEndDate && Utils.compareDate(propEndDate, currentDate[1])) {
6692
- currentDate.splice(1, 1, propEndDate);
6693
- }
6694
- defaultData = [
6695
- ...splitDate(currentDate[0]),
6696
- ...splitDate(currentDate[1])
6697
- ];
6547
+ if (type4 === "single" && typeof currentDate === "string") {
6548
+ if (!currentDate.length) {
6549
+ return defaultData;
6550
+ }
6551
+ if (compareDate(currentDate, propStartDate)) {
6552
+ defaultData = [...splitDate(propStartDate)];
6553
+ } else if (!compareDate(currentDate, propEndDate)) {
6554
+ defaultData = [...splitDate(propEndDate)];
6555
+ } else {
6556
+ defaultData = [...splitDate(currentDate)];
6698
6557
  }
6699
- } else if (type4 === "multiple" && Array.isArray(currentDate)) {
6700
- if (currentDate.length > 0) {
6701
- const defaultArr = [];
6702
- const obj = {};
6703
- currentDate.forEach((item) => {
6704
- if (propStartDate && !Utils.compareDate(item, propStartDate) && propEndDate && !Utils.compareDate(propEndDate, item)) {
6705
- if (!Object.hasOwnProperty.call(obj, item)) {
6706
- defaultArr.push(item);
6707
- obj[item] = item;
6708
- }
6558
+ return defaultData;
6559
+ }
6560
+ if (Array.isArray(currentDate) && currentDate.length) {
6561
+ switch (type4) {
6562
+ case "range": {
6563
+ if (compareDate(currentDate[0], propStartDate)) {
6564
+ currentDate[0] = propStartDate;
6709
6565
  }
6710
- });
6711
- currentDate.splice(0) && currentDate.push(...defaultArr);
6712
- defaultData = [...splitDate(defaultArr[0])];
6713
- }
6714
- } else if (type4 === "week" && Array.isArray(currentDate)) {
6715
- if (currentDate.length > 0) {
6716
- const [y2, m2, d] = splitDate(currentDate[0]);
6717
- const weekArr = Utils.getWeekDate(y2, m2, d, firstDayOfWeek);
6718
- currentDate.splice(0) && currentDate.push(...weekArr);
6719
- if (propStartDate && Utils.compareDate(currentDate[0], propStartDate)) {
6720
- currentDate.splice(0, 1, propStartDate);
6566
+ if (compareDate(propEndDate, currentDate[1])) {
6567
+ currentDate[1] = propEndDate;
6568
+ }
6569
+ defaultData = [
6570
+ ...splitDate(currentDate[0]),
6571
+ ...splitDate(currentDate[1])
6572
+ ];
6573
+ break;
6721
6574
  }
6722
- if (propEndDate && Utils.compareDate(propEndDate, currentDate[1])) {
6723
- currentDate.splice(1, 1, propEndDate);
6575
+ case "multiple": {
6576
+ const defaultArr = [];
6577
+ const obj = {};
6578
+ currentDate.forEach((item) => {
6579
+ if (!compareDate(item, propStartDate) && !compareDate(propEndDate, item)) {
6580
+ if (!Object.hasOwnProperty.call(obj, item)) {
6581
+ defaultArr.push(item);
6582
+ obj[item] = item;
6583
+ }
6584
+ }
6585
+ });
6586
+ currentDate.splice(0, currentDate.length, ...defaultArr);
6587
+ defaultData = [...splitDate(defaultArr[0])];
6588
+ break;
6724
6589
  }
6725
- defaultData = [
6726
- ...splitDate(currentDate[0]),
6727
- ...splitDate(currentDate[1])
6728
- ];
6729
- }
6730
- } else if (currentDate) {
6731
- if (currentDate.length > 0) {
6732
- if (propStartDate && Utils.compareDate(currentDate, propStartDate)) {
6733
- defaultData = [...splitDate(propStartDate)];
6734
- } else if (propEndDate && !Utils.compareDate(currentDate, propEndDate)) {
6735
- defaultData = [...splitDate(propEndDate)];
6736
- } else {
6737
- defaultData = [...splitDate(currentDate)];
6590
+ case "week": {
6591
+ const [y2, m2, d] = splitDate(currentDate[0]);
6592
+ const weekArr = getWeekDate(y2, m2, d, firstDayOfWeek);
6593
+ currentDate.splice(0, currentDate.length, ...weekArr);
6594
+ if (compareDate(currentDate[0], propStartDate)) {
6595
+ currentDate.splice(0, 1, propStartDate);
6596
+ }
6597
+ if (compareDate(propEndDate, currentDate[1])) {
6598
+ currentDate.splice(1, 1, propEndDate);
6599
+ }
6600
+ defaultData = [
6601
+ ...splitDate(currentDate[0]),
6602
+ ...splitDate(currentDate[1])
6603
+ ];
6604
+ break;
6738
6605
  }
6739
- } else {
6740
- defaultData = [];
6741
6606
  }
6742
6607
  }
6743
6608
  return defaultData;
@@ -6760,63 +6625,57 @@ const CalendarItem = React__default.forwardRef((props, ref) => {
6760
6625
  const date4 = /* @__PURE__ */ new Date();
6761
6626
  const year = date4.getFullYear();
6762
6627
  const month = date4.getMonth() + 1;
6763
- const index = monthsData.findIndex((item) => {
6764
- return +item.curData[0] === year && +item.curData[1] === month;
6765
- });
6766
- if (index > -1) {
6767
- current = index;
6768
- }
6628
+ const index = monthsData.findIndex(
6629
+ (item) => +item.curData[0] === year && +item.curData[1] === month
6630
+ );
6631
+ if (index > -1) current = index;
6769
6632
  }
6770
6633
  return {
6771
6634
  current,
6772
6635
  lastCurrent
6773
6636
  };
6774
6637
  };
6775
- const renderCurrentDate = () => {
6776
- const defaultData = setDefaultDate();
6777
- const current = getCurrentIndex(defaultData);
6778
- if (defaultData.length > 0) {
6779
- if (type4 === "range") {
6780
- chooseDay(
6781
- { day: defaultData[2], type: "active" },
6782
- monthsData[current.current],
6783
- true
6784
- );
6785
- chooseDay(
6638
+ const renderCurrentDate = (defaultData, current) => {
6639
+ if (!defaultData.length) return;
6640
+ const date4 = monthsData[current.current];
6641
+ switch (type4) {
6642
+ case "range": {
6643
+ handleDayClick({ day: defaultData[2], type: "active" }, date4);
6644
+ handleDayClick(
6786
6645
  { day: defaultData[5], type: "active" },
6787
- monthsData[current.lastCurrent],
6788
- true
6789
- );
6790
- } else if (type4 === "week") {
6791
- chooseDay(
6792
- { day: defaultData[2], type: "curr" },
6793
- monthsData[current.current],
6794
- true
6646
+ monthsData[current.lastCurrent]
6795
6647
  );
6796
- } else if (type4 === "multiple") {
6648
+ break;
6649
+ }
6650
+ case "week": {
6651
+ handleDayClick({ day: defaultData[2], type: "curr" }, date4);
6652
+ break;
6653
+ }
6654
+ case "multiple": {
6797
6655
  [...currentDate].forEach((item) => {
6798
6656
  const dateArr = splitDate(item);
6799
6657
  let currentIndex = current.current;
6800
- monthsData.forEach((item2, index) => {
6801
- if (item2.title === monthTitle(dateArr[0], dateArr[1])) {
6802
- currentIndex = index;
6803
- }
6804
- });
6805
- chooseDay(
6658
+ currentIndex = monthsData.findIndex(
6659
+ (item2) => item2.title === monthTitle(dateArr[0], dateArr[1])
6660
+ );
6661
+ handleDayClick(
6806
6662
  { day: dateArr[2], type: "active" },
6807
- monthsData[currentIndex],
6808
- true
6663
+ monthsData[currentIndex]
6809
6664
  );
6810
6665
  });
6811
- } else {
6812
- chooseDay(
6813
- { day: defaultData[2], type: "active" },
6814
- monthsData[current.current],
6815
- true
6816
- );
6666
+ break;
6667
+ }
6668
+ default: {
6669
+ handleDayClick({ day: defaultData[2], type: "active" }, date4);
6670
+ break;
6817
6671
  }
6818
6672
  }
6819
- return current.current;
6673
+ };
6674
+ const getMonthsPanel = () => {
6675
+ return monthsPanel.current;
6676
+ };
6677
+ const getMonthsRef = () => {
6678
+ return monthsRef.current;
6820
6679
  };
6821
6680
  const requestAniFrameFunc = (current, monthNum) => {
6822
6681
  const lastItem = monthsData[monthsData.length - 1];
@@ -6825,19 +6684,31 @@ const CalendarItem = React__default.forwardRef((props, ref) => {
6825
6684
  if (monthsRef && monthsPanel && viewAreaRef) {
6826
6685
  viewHeight = getMonthsRef().clientHeight;
6827
6686
  getMonthsPanel().style.height = `${containerHeight}px`;
6828
- getMonthsRef().scrollTop = monthsData[current].scrollTop;
6829
- setScrollTop(monthsData[current].scrollTop);
6687
+ const currTop = monthsData[current].scrollTop;
6688
+ getMonthsRef().scrollTop = currTop;
6689
+ setScrollTop(currTop);
6830
6690
  nextTick(() => setScrollWithAnimation(true));
6831
6691
  }
6832
6692
  });
6833
6693
  setAvgHeight(Math.floor(containerHeight / (monthNum + 1)));
6834
6694
  };
6695
+ const getMonthNum = () => {
6696
+ let monthNum = Number(endDates[1]) - Number(startDates[1]);
6697
+ const yearNum = Number(endDates[0]) - Number(startDates[0]);
6698
+ if (yearNum > 0) monthNum += 12 * yearNum;
6699
+ if (monthNum <= 0) monthNum = 1;
6700
+ setMonthsNum(monthNum);
6701
+ return monthNum;
6702
+ };
6835
6703
  const initData = () => {
6836
6704
  const monthNum = getMonthNum();
6837
6705
  getMonthData(startDates, monthNum);
6838
- const current = renderCurrentDate();
6839
- setDefaultRange(monthNum, current);
6840
- requestAniFrameFunc(current, monthNum);
6706
+ const defaultData = setDefaultDate();
6707
+ const current = getCurrentIndex(defaultData);
6708
+ const currentIndex = current.current;
6709
+ renderCurrentDate(defaultData, current);
6710
+ setDefaultRange(monthNum, currentIndex);
6711
+ requestAniFrameFunc(currentIndex, monthNum);
6841
6712
  };
6842
6713
  useEffect(() => {
6843
6714
  initData();
@@ -6854,9 +6725,9 @@ const CalendarItem = React__default.forwardRef((props, ref) => {
6854
6725
  popup && resetRender();
6855
6726
  }, [currentDate]);
6856
6727
  const scrollToDate = (date4) => {
6857
- if (Utils.compareDate(date4, propStartDate)) {
6728
+ if (compareDate(date4, propStartDate)) {
6858
6729
  date4 = propStartDate;
6859
- } else if (!Utils.compareDate(date4, propEndDate)) {
6730
+ } else if (!compareDate(date4, propEndDate)) {
6860
6731
  date4 = propEndDate;
6861
6732
  }
6862
6733
  const dateArr = splitDate(date4);
@@ -6877,22 +6748,20 @@ const CalendarItem = React__default.forwardRef((props, ref) => {
6877
6748
  clearInterval(interval);
6878
6749
  if (monthsRef.current) {
6879
6750
  monthsRef.current.scrollTop = currTop;
6880
- setScrollTop(monthsRef.current.scrollTop);
6751
+ setScrollTop(currTop);
6881
6752
  }
6882
6753
  }
6883
6754
  }, 40);
6884
6755
  } else {
6885
6756
  monthsRef.current.scrollTop = currTop;
6886
- setScrollTop(monthsRef.current.scrollTop);
6757
+ setScrollTop(currTop);
6887
6758
  }
6888
6759
  }
6889
6760
  }
6890
6761
  });
6891
6762
  };
6892
6763
  const monthsViewScroll = (e2) => {
6893
- if (monthsData.length <= 1) {
6894
- return;
6895
- }
6764
+ if (monthsData.length <= 1) return;
6896
6765
  const scrollTop2 = e2.target.scrollTop;
6897
6766
  Taro.getEnv() === "WEB" && setScrollTop(scrollTop2);
6898
6767
  let current = Math.floor(scrollTop2 / avgHeight);
@@ -6901,16 +6770,10 @@ const CalendarItem = React__default.forwardRef((props, ref) => {
6901
6770
  const nextTop = monthsData[current + 1].scrollTop;
6902
6771
  const nextHeight = monthsData[current + 1].cssHeight;
6903
6772
  if (current === 0) {
6904
- if (scrollTop2 >= nextTop) {
6905
- current += 1;
6906
- }
6773
+ if (scrollTop2 >= nextTop) current += 1;
6907
6774
  } else if (current > 0 && current < monthsNum - 1) {
6908
- if (scrollTop2 >= nextTop) {
6909
- current += 1;
6910
- }
6911
- if (scrollTop2 < monthsData[current].scrollTop) {
6912
- current -= 1;
6913
- }
6775
+ if (scrollTop2 >= nextTop) current += 1;
6776
+ if (scrollTop2 < monthsData[current].scrollTop) current -= 1;
6914
6777
  } else {
6915
6778
  const viewPosition = Math.round(scrollTop2 + viewHeight);
6916
6779
  if (current + 1 <= monthsNum && viewPosition >= nextTop + nextHeight) {
@@ -6925,90 +6788,96 @@ const CalendarItem = React__default.forwardRef((props, ref) => {
6925
6788
  React__default.useImperativeHandle(ref, () => ({
6926
6789
  scrollToDate
6927
6790
  }));
6791
+ const isDisable = (day, month) => {
6792
+ if (day.type !== "active") return true;
6793
+ const dateStr = getCurrDate(day, month);
6794
+ if (compareDate(dateStr, propStartDate)) return true;
6795
+ if (compareDate(propEndDate, dateStr)) return true;
6796
+ return false;
6797
+ };
6928
6798
  const getClasses = (day, month) => {
6929
6799
  const dateStr = getCurrDate(day, month);
6930
- if (day.type === "active") {
6931
- if (propStartDate && Utils.compareDate(dateStr, propStartDate) || propEndDate && Utils.compareDate(propEndDate, dateStr)) {
6932
- return `${dayPrefix}-disabled`;
6933
- }
6934
- if (type4 === "range" || type4 === "week") {
6935
- if (isStart(dateStr, currentDate) || isEnd(dateStr, currentDate)) {
6936
- return `${dayPrefix}-active ${isStart(dateStr, currentDate) ? "active-start" : ""} ${isEnd(dateStr, currentDate) ? "active-end" : ""}`;
6937
- }
6938
- if (Array.isArray(currentDate) && Object.values(currentDate).length === 2 && Utils.compareDate(currentDate[0], dateStr) && Utils.compareDate(dateStr, currentDate[1])) {
6939
- if (disableDate(day)) {
6940
- return `${dayPrefix}-choose-disabled`;
6941
- }
6942
- return `${dayPrefix}-choose`;
6943
- }
6944
- } else if (type4 === "multiple" && isMultiple(dateStr, currentDate) || !Array.isArray(currentDate) && Utils.isEqual(currentDate, dateStr)) {
6945
- return `${dayPrefix}-active`;
6800
+ if (isDisable(day, month)) return `${dayPrefix}-disabled`;
6801
+ const activeCls = `${dayPrefix}-active`;
6802
+ if (type4 === "range" || type4 === "week") {
6803
+ if (isStart(dateStr, currentDate))
6804
+ return `${activeCls} active-start`;
6805
+ if (isEnd(dateStr, currentDate)) {
6806
+ return `${activeCls} active-end`;
6946
6807
  }
6947
- if (disableDate(day)) {
6948
- return `${dayPrefix}-disabled`;
6808
+ if (currentDate.length === 2 && compareDate(currentDate[0], dateStr) && compareDate(dateStr, currentDate[1])) {
6809
+ return disableDate(day) ? `${dayPrefix}-choose-disabled` : `${dayPrefix}-choose`;
6949
6810
  }
6950
- return null;
6811
+ } else if (type4 === "multiple" && isMultiple(dateStr, currentDate) || !Array.isArray(currentDate) && isEqual(currentDate, dateStr)) {
6812
+ return activeCls;
6951
6813
  }
6952
- return `${dayPrefix}-disabled`;
6814
+ if (disableDate(day)) return `${dayPrefix}-disabled`;
6815
+ return null;
6953
6816
  };
6954
- const chooseDay = (day, month, isFirst) => {
6955
- if (getClasses(day, month) === `${dayPrefix}-disabled`) {
6956
- return;
6957
- }
6817
+ const handleDayClick = (day, month, isFirst = true) => {
6818
+ if (isDisable(day, month) || disableDate(day)) return;
6958
6819
  const days = [...month.curData];
6959
6820
  const [y2, m2] = month.curData;
6960
- days[2] = typeof day.day === "number" ? Utils.getNumTwoBit(day.day) : day.day;
6821
+ days[2] = typeof day.day === "number" ? getNumTwoBit(day.day) : day.day;
6961
6822
  days[3] = `${days[0]}/${days[1]}/${days[2]}`;
6962
- days[4] = Utils.getWhatDay(+days[0], +days[1], +days[2]);
6963
- if (type4 === "multiple") {
6964
- if (currentDate.length > 0) {
6965
- let hasIndex = "";
6966
- currentDate.forEach((item, index) => {
6967
- if (item === days[3]) {
6968
- hasIndex = index;
6823
+ days[4] = getWhatDay(+days[0], +days[1], +days[2]);
6824
+ const newDate = days[3];
6825
+ switch (type4) {
6826
+ case "multiple": {
6827
+ if (Array.isArray(currentDate)) {
6828
+ if (currentDate.length > 0) {
6829
+ const hasIndex = currentDate.findIndex((item) => item === newDate);
6830
+ if (isFirst) {
6831
+ state.currDateArray.push([...days]);
6832
+ } else if (hasIndex > -1) {
6833
+ currentDate.splice(hasIndex, 1);
6834
+ state.currDateArray.splice(hasIndex, 1);
6835
+ } else {
6836
+ currentDate.push(newDate);
6837
+ state.currDateArray.push([...days]);
6838
+ }
6839
+ } else {
6840
+ currentDate.push(newDate);
6841
+ state.currDateArray = [[...days]];
6969
6842
  }
6970
- });
6971
- if (isFirst) {
6972
- state.currDateArray.push([...days]);
6973
- } else if (hasIndex !== "") {
6974
- currentDate.splice(hasIndex, 1);
6975
- state.currDateArray.splice(hasIndex, 1);
6976
- } else {
6977
- currentDate.push(days[3]);
6978
- state.currDateArray.push([...days]);
6979
6843
  }
6980
- } else {
6981
- currentDate.push(days[3]);
6982
- state.currDateArray = [[...days]];
6983
- }
6984
- } else if (type4 === "range") {
6985
- const curDataLength = Object.values(currentDate).length;
6986
- if (curDataLength === 2 || curDataLength === 0) {
6987
- Array.isArray(currentDate) && currentDate.splice(0) && currentDate.push(days[3]);
6988
- state.currDateArray = [[...days]];
6989
- } else if (Utils.compareDate(currentDate[0], days[3])) {
6990
- Array.isArray(currentDate) && currentDate.push(days[3]);
6991
- state.currDateArray = [...state.currDateArray, [...days]];
6992
- } else {
6993
- Array.isArray(currentDate) && currentDate.unshift(days[3]);
6994
- state.currDateArray = [[...days], ...state.currDateArray];
6844
+ break;
6995
6845
  }
6996
- } else if (type4 === "week") {
6997
- const weekArr = Utils.getWeekDate(y2, m2, `${day.day}`, firstDayOfWeek);
6998
- if (propStartDate && Utils.compareDate(weekArr[0], propStartDate)) {
6999
- weekArr.splice(0, 1, propStartDate);
6846
+ case "range": {
6847
+ if (Array.isArray(currentDate)) {
6848
+ if (currentDate.length === 2 || currentDate.length === 0) {
6849
+ currentDate.splice(0, currentDate.length, newDate);
6850
+ state.currDateArray = [[...days]];
6851
+ } else if (compareDate(currentDate[0], newDate)) {
6852
+ currentDate.push(newDate);
6853
+ state.currDateArray = [...state.currDateArray, [...days]];
6854
+ } else {
6855
+ currentDate.unshift(newDate);
6856
+ state.currDateArray = [[...days], ...state.currDateArray];
6857
+ }
6858
+ }
6859
+ break;
6860
+ }
6861
+ case "week": {
6862
+ const weekArr = getWeekDate(y2, m2, `${day.day}`, firstDayOfWeek);
6863
+ if (compareDate(weekArr[0], propStartDate)) {
6864
+ weekArr[0] = propStartDate;
6865
+ }
6866
+ if (compareDate(propEndDate, weekArr[1])) {
6867
+ weekArr[1] = propEndDate;
6868
+ }
6869
+ currentDate.splice(0, currentDate.length, ...weekArr);
6870
+ state.currDateArray = [
6871
+ formatResultDate(weekArr[0]),
6872
+ formatResultDate(weekArr[1])
6873
+ ];
6874
+ break;
7000
6875
  }
7001
- if (propEndDate && Utils.compareDate(propEndDate, weekArr[1])) {
7002
- weekArr.splice(1, 1, propEndDate);
6876
+ default: {
6877
+ setCurrentDate(newDate);
6878
+ state.currDateArray = [...days];
6879
+ break;
7003
6880
  }
7004
- Array.isArray(currentDate) && currentDate.splice(0) && currentDate.push(...weekArr);
7005
- state.currDateArray = [
7006
- Utils.formatResultDate(weekArr[0]),
7007
- Utils.formatResultDate(weekArr[1])
7008
- ];
7009
- } else {
7010
- setCurrentDate(days[3]);
7011
- state.currDateArray = [...days];
7012
6881
  }
7013
6882
  if (!isFirst) {
7014
6883
  onDayClick && onDayClick(state.currDateArray);
@@ -7028,11 +6897,11 @@ const CalendarItem = React__default.forwardRef((props, ref) => {
7028
6897
  }
7029
6898
  };
7030
6899
  const classes = classNames(
6900
+ classPrefix2,
7031
6901
  {
7032
6902
  [`${classPrefix2}-title`]: !popup,
7033
6903
  [`${classPrefix2}-nofooter`]: !!autoBackfill
7034
6904
  },
7035
- classPrefix2,
7036
6905
  className
7037
6906
  );
7038
6907
  const headerClasses = classNames({
@@ -7048,6 +6917,40 @@ const CalendarItem = React__default.forwardRef((props, ref) => {
7048
6917
  const renderHeader = () => {
7049
6918
  return /* @__PURE__ */ React__default.createElement("div", { className: headerClasses }, showTitle && /* @__PURE__ */ React__default.createElement("div", { className: `${classPrefix2}-title` }, title || locale.calendaritem.title), renderHeaderButtons && /* @__PURE__ */ React__default.createElement("div", { className: `${classPrefix2}-header-buttons` }, renderHeaderButtons()), showSubTitle && /* @__PURE__ */ React__default.createElement("div", { className: `${classPrefix2}-sub-title` }, yearMonthTitle), /* @__PURE__ */ React__default.createElement("div", { className: `${classPrefix2}-weeks`, ref: weeksPanel }, weeks.map((item) => /* @__PURE__ */ React__default.createElement("div", { className: `${classPrefix2}-week-item`, key: item }, item))));
7050
6919
  };
6920
+ const renderItem = (month, day, index) => {
6921
+ const startTip = isStartTip(day, month);
6922
+ const endTip = isEndTip(day, month);
6923
+ const noStartNorEnd = !startTip && !endTip;
6924
+ return /* @__PURE__ */ React__default.createElement(
6925
+ "div",
6926
+ {
6927
+ className: classNames("nut-calendar-day", getClasses(day, month)),
6928
+ onClick: () => handleDayClick(day, month, false),
6929
+ key: index
6930
+ },
6931
+ /* @__PURE__ */ React__default.createElement("div", { className: `${classPrefix2}-day-day` }, renderDay ? renderDay(day) : day.day),
6932
+ !startTip && renderDayTop && /* @__PURE__ */ React__default.createElement("div", { className: `${classPrefix2}-day-info-top` }, renderDayTop(day)),
6933
+ noStartNorEnd && renderDayBottom && /* @__PURE__ */ React__default.createElement("div", { className: `${classPrefix2}-day-info-bottom` }, renderDayBottom(day)),
6934
+ noStartNorEnd && isCurrDay(month, day.day) && !renderDayBottom && showToday && /* @__PURE__ */ React__default.createElement("div", { className: `${classPrefix2}-day-info-curr` }, locale.calendaritem.today),
6935
+ startTip && /* @__PURE__ */ React__default.createElement(
6936
+ "div",
6937
+ {
6938
+ className: classNames("nut-calendar-day-info", {
6939
+ "nut-calendar-day-info-top": isStartAndEnd(
6940
+ currentDate
6941
+ )
6942
+ })
6943
+ },
6944
+ startText || locale.calendaritem.start
6945
+ ),
6946
+ endTip && /* @__PURE__ */ React__default.createElement("div", { className: `${classPrefix2}-day-info` }, endText || locale.calendaritem.end)
6947
+ );
6948
+ };
6949
+ const renderPanel = (month, key) => {
6950
+ return /* @__PURE__ */ React__default.createElement("div", { className: `${classPrefix2}-month`, key }, /* @__PURE__ */ React__default.createElement("div", { className: `${classPrefix2}-month-title` }, month.title), /* @__PURE__ */ React__default.createElement("div", { className: `${classPrefix2}-days` }, month.monthData.map(
6951
+ (day, i2) => renderItem(month, day, i2)
6952
+ )));
6953
+ };
7051
6954
  const renderContent = () => {
7052
6955
  return /* @__PURE__ */ React__default.createElement(
7053
6956
  ScrollView,
@@ -7068,31 +6971,7 @@ const CalendarItem = React__default.forwardRef((props, ref) => {
7068
6971
  style: { transform: `translateY(${translateY}px)` }
7069
6972
  },
7070
6973
  monthsData.slice(monthDefaultRange[0], monthDefaultRange[1]).map((month, key) => {
7071
- return /* @__PURE__ */ React__default.createElement("div", { className: `${classPrefix2}-month`, key }, /* @__PURE__ */ React__default.createElement("div", { className: `${classPrefix2}-month-title` }, month.title), /* @__PURE__ */ React__default.createElement("div", { className: `${classPrefix2}-days` }, month.monthData.map((day, i2) => /* @__PURE__ */ React__default.createElement(
7072
- "div",
7073
- {
7074
- className: [
7075
- `${classPrefix2}-day`,
7076
- getClasses(day, month)
7077
- ].join(" "),
7078
- onClick: () => {
7079
- chooseDay(day, month);
7080
- },
7081
- key: i2
7082
- },
7083
- /* @__PURE__ */ React__default.createElement("div", { className: `${classPrefix2}-day-day` }, renderDay ? renderDay(day) : day.day),
7084
- !isStartTip(day, month) && renderDayTop && /* @__PURE__ */ React__default.createElement("div", { className: `${classPrefix2}-day-info-top` }, renderDayTop(day)),
7085
- !isStartTip(day, month) && !isEndTip(day, month) && renderDayBottom && /* @__PURE__ */ React__default.createElement("div", { className: `${classPrefix2}-day-info-bottom` }, renderDayBottom(day)),
7086
- !isStartTip(day, month) && !isEndTip(day, month) && !renderDayBottom && showToday && isCurrDay(month, day.day) && /* @__PURE__ */ React__default.createElement("div", { className: `${classPrefix2}-day-info-curr` }, locale.calendaritem.today),
7087
- isStartTip(day, month) && /* @__PURE__ */ React__default.createElement(
7088
- "div",
7089
- {
7090
- className: `${classPrefix2}-day-info ${isStartAndEnd(currentDate) ? `${classPrefix2}-day-info-top` : ""}`
7091
- },
7092
- startText || locale.calendaritem.start
7093
- ),
7094
- isEndTip(day, month) && /* @__PURE__ */ React__default.createElement("div", { className: `${classPrefix2}-day-info` }, endText || locale.calendaritem.end)
7095
- ))));
6974
+ return renderPanel(month, key);
7096
6975
  })
7097
6976
  ))
7098
6977
  );
@@ -7111,8 +6990,8 @@ const defaultProps$12 = {
7111
6990
  visible: false,
7112
6991
  title: "",
7113
6992
  defaultValue: "",
7114
- startDate: Utils.getDay(0),
7115
- endDate: Utils.getDay(365),
6993
+ startDate: getDateString(0),
6994
+ endDate: getDateString(365),
7116
6995
  showToday: true,
7117
6996
  startText: "",
7118
6997
  endText: "",
@@ -7280,12 +7159,12 @@ const getPrevMonthDays = (year, month, firstDayOfWeek) => {
7280
7159
  prevMonth = 12;
7281
7160
  prevYear -= 1;
7282
7161
  }
7283
- let days = Utils.getMonthPreDay(year, month);
7162
+ let days = getMonthPreDay(year, month);
7284
7163
  days -= firstDayOfWeek;
7285
7164
  if (days >= 7) {
7286
7165
  days -= 7;
7287
7166
  }
7288
- const preDates = Utils.getMonthDays(`${prevYear}`, `${prevMonth}`);
7167
+ const preDates = getMonthDays(`${prevYear}`, `${prevMonth}`);
7289
7168
  const months = Array.from(Array(preDates), (_, k) => {
7290
7169
  return {
7291
7170
  type: "prev",
@@ -7297,7 +7176,7 @@ const getPrevMonthDays = (year, month, firstDayOfWeek) => {
7297
7176
  return months.slice(preDates - days);
7298
7177
  };
7299
7178
  const getCurrentMonthDays = (year, month) => {
7300
- const days = Utils.getMonthDays(`${year}`, `${month}`);
7179
+ const days = getMonthDays(`${year}`, `${month}`);
7301
7180
  return Array.from(Array(days), (_, k) => {
7302
7181
  return {
7303
7182
  type: "current",
@@ -8660,9 +8539,9 @@ const DatePicker = (props) => {
8660
8539
  };
8661
8540
  const compareDateChange = (currentDate, newDate, selectedOptions, index) => {
8662
8541
  var _a;
8663
- const isEqual = ((_a = new Date(currentDate)) == null ? void 0 : _a.getTime()) === (newDate == null ? void 0 : newDate.getTime());
8542
+ const isEqual2 = ((_a = new Date(currentDate)) == null ? void 0 : _a.getTime()) === (newDate == null ? void 0 : newDate.getTime());
8664
8543
  if (newDate && isDate(newDate)) {
8665
- if (!isEqual) {
8544
+ if (!isEqual2) {
8666
8545
  setSelectedDate(formatValue(newDate));
8667
8546
  }
8668
8547
  onChange == null ? void 0 : onChange(
@@ -8701,6 +8580,14 @@ const DatePicker = (props) => {
8701
8580
  Number(formatDate[2]),
8702
8581
  getMonthEndDay(Number(formatDate[0]), Number(formatDate[1]))
8703
8582
  );
8583
+ if (selectedOptions.length >= 2 && ["date", "datehour", "datetime", "month-day"].includes(rangeType)) {
8584
+ const dayOption = formatOption("day", day);
8585
+ if (rangeType === "month-day") {
8586
+ selectedOptions[1] = dayOption;
8587
+ } else {
8588
+ selectedOptions[2] = dayOption;
8589
+ }
8590
+ }
8704
8591
  let date4 = null;
8705
8592
  if (rangeType === "date" || rangeType === "month-day" || rangeType === "year-month") {
8706
8593
  date4 = new Date(year, month, day);
@@ -9614,7 +9501,7 @@ function newMessages() {
9614
9501
  pattern: {
9615
9502
  mismatch: "%s value %s does not match pattern %s"
9616
9503
  },
9617
- clone: function clone() {
9504
+ clone: function clone2() {
9618
9505
  var cloned = JSON.parse(JSON.stringify(this));
9619
9506
  cloned.clone = this.clone;
9620
9507
  return cloned;
@@ -9878,23 +9765,55 @@ Schema.register = function register(type4, validator) {
9878
9765
  Schema.warning = warning;
9879
9766
  Schema.messages = messages;
9880
9767
  Schema.validators = validators;
9881
- function merge(...objects) {
9882
- const result = Array.isArray(objects[0]) ? [] : {};
9883
- function mergeHelper(obj, path = []) {
9884
- for (const [key, value] of Object.entries(obj)) {
9885
- const newPath = [...path, key];
9886
- if (Array.isArray(value)) {
9887
- result[key] = [...value];
9888
- } else if (typeof value === "object" && value !== null) {
9889
- if (path.some((p) => p === value)) continue;
9890
- if (!result[key]) result[key] = {};
9891
- mergeHelper(value, newPath);
9892
- } else {
9893
- result[key] = value;
9894
- }
9768
+ function merge(...items) {
9769
+ return _merge(items[0] === true, false, items);
9770
+ }
9771
+ function recursive(...items) {
9772
+ return _merge(items[0] === true, true, items);
9773
+ }
9774
+ function clone(input) {
9775
+ if (Array.isArray(input)) {
9776
+ const output = [];
9777
+ for (let index = 0; index < input.length; ++index)
9778
+ output.push(clone(input[index]));
9779
+ return output;
9780
+ }
9781
+ if (isPlainObject(input)) {
9782
+ const output = {};
9783
+ for (const index in input) output[index] = clone(input[index]);
9784
+ return output;
9785
+ }
9786
+ return input;
9787
+ }
9788
+ function isPlainObject(input) {
9789
+ if (input === null || typeof input !== "object") return false;
9790
+ if (Object.getPrototypeOf(input) === null) return true;
9791
+ let ref = input;
9792
+ while (Object.getPrototypeOf(ref) !== null) ref = Object.getPrototypeOf(ref);
9793
+ return Object.getPrototypeOf(input) === ref;
9794
+ }
9795
+ function _recursiveMerge(base, extend) {
9796
+ if (!isPlainObject(base) || !isPlainObject(extend)) return extend;
9797
+ for (const key in extend) {
9798
+ if (key === "__proto__" || key === "constructor" || key === "prototype")
9799
+ continue;
9800
+ base[key] = isPlainObject(base[key]) && isPlainObject(extend[key]) ? _recursiveMerge(base[key], extend[key]) : extend[key];
9801
+ }
9802
+ return base;
9803
+ }
9804
+ function _merge(isClone, isRecursive, items) {
9805
+ let result;
9806
+ if (isClone || !isPlainObject(result = items.shift())) result = {};
9807
+ for (let index = 0; index < items.length; ++index) {
9808
+ const item = items[index];
9809
+ if (!isPlainObject(item)) continue;
9810
+ for (const key in item) {
9811
+ if (key === "__proto__" || key === "constructor" || key === "prototype")
9812
+ continue;
9813
+ const value = isClone ? clone(item[key]) : item[key];
9814
+ result[key] = isRecursive ? _recursiveMerge(result[key], value) : value;
9895
9815
  }
9896
9816
  }
9897
- objects.filter((obj) => !!obj).forEach((obj) => mergeHelper(obj));
9898
9817
  return result;
9899
9818
  }
9900
9819
  const SECRET = "NUT_FORM_INTERNAL";
@@ -9910,9 +9829,6 @@ class FormStore {
9910
9829
  this.fieldEntities.push(field);
9911
9830
  return () => {
9912
9831
  this.fieldEntities = this.fieldEntities.filter((item) => item !== field);
9913
- if (this.store) {
9914
- delete this.store[field.props.name];
9915
- }
9916
9832
  };
9917
9833
  };
9918
9834
  this.getFieldValue = (name) => {
@@ -9934,10 +9850,11 @@ class FormStore {
9934
9850
  if (init) {
9935
9851
  const nextStore = merge(initialValues, this.store);
9936
9852
  this.updateStore(nextStore);
9853
+ this.notifyWatch();
9937
9854
  }
9938
9855
  };
9939
9856
  this.setFieldsValue = (newStore) => {
9940
- const nextStore = merge(this.store, newStore);
9857
+ const nextStore = recursive(true, this.store, newStore);
9941
9858
  this.updateStore(nextStore);
9942
9859
  this.fieldEntities.forEach((entity) => {
9943
9860
  const { name } = entity.props;
@@ -9956,12 +9873,14 @@ class FormStore {
9956
9873
  item.entity.onStoreChange("update");
9957
9874
  }
9958
9875
  });
9876
+ this.notifyWatch();
9959
9877
  };
9960
9878
  this.setFieldValue = (name, value) => {
9961
9879
  const store = {
9962
9880
  [name]: value
9963
9881
  };
9964
9882
  this.setFieldsValue(store);
9883
+ this.notifyWatch([name]);
9965
9884
  };
9966
9885
  this.setCallback = (callback) => {
9967
9886
  this.callbacks = {
@@ -10004,7 +9923,6 @@ class FormStore {
10004
9923
  };
10005
9924
  this.validateFields = async (nameList) => {
10006
9925
  let filterEntities = [];
10007
- this.errors.length = 0;
10008
9926
  if (!nameList || nameList.length === 0) {
10009
9927
  filterEntities = this.fieldEntities;
10010
9928
  } else {
@@ -10029,13 +9947,29 @@ class FormStore {
10029
9947
  (_d = (_c = this.callbacks).onFinishFailed) == null ? void 0 : _d.call(_c, this.store, errors);
10030
9948
  }
10031
9949
  };
10032
- this.resetFields = () => {
10033
- this.errors.length = 0;
10034
- const nextStore = merge({}, this.initialValues);
10035
- this.updateStore(nextStore);
10036
- this.fieldEntities.forEach((entity) => {
10037
- entity.onStoreChange("reset");
10038
- });
9950
+ this.resetFields = (namePaths) => {
9951
+ if (namePaths && namePaths.length) {
9952
+ namePaths.forEach((path) => {
9953
+ this.errors[path] = null;
9954
+ this.fieldEntities.forEach((entity) => {
9955
+ const name = entity.props.name;
9956
+ if (name === path) {
9957
+ if (path in this.initialValues) {
9958
+ this.updateStore({ [path]: this.initialValues[path] });
9959
+ } else {
9960
+ delete this.store[path];
9961
+ }
9962
+ entity.onStoreChange("reset");
9963
+ }
9964
+ });
9965
+ });
9966
+ } else {
9967
+ const nextStore = merge({}, this.initialValues);
9968
+ this.updateStore(nextStore);
9969
+ this.fieldEntities.forEach((entity) => {
9970
+ entity.onStoreChange("reset");
9971
+ });
9972
+ }
10039
9973
  };
10040
9974
  this.registerUpdate = (field, shouldUpdate) => {
10041
9975
  this.updateList.push({
@@ -10058,7 +9992,8 @@ class FormStore {
10058
9992
  dispatch: this.dispatch,
10059
9993
  store: this.store,
10060
9994
  fieldEntities: this.fieldEntities,
10061
- registerUpdate: this.registerUpdate
9995
+ registerUpdate: this.registerUpdate,
9996
+ registerWatch: this.registerWatch
10062
9997
  };
10063
9998
  }
10064
9999
  };
@@ -10075,6 +10010,26 @@ class FormStore {
10075
10010
  getInternal: this.getInternal
10076
10011
  };
10077
10012
  };
10013
+ this.watchList = [];
10014
+ this.registerWatch = (callback) => {
10015
+ this.watchList.push(callback);
10016
+ return () => {
10017
+ this.watchList = this.watchList.filter((fn) => fn !== callback);
10018
+ };
10019
+ };
10020
+ this.notifyWatch = (namePath = []) => {
10021
+ if (this.watchList.length) {
10022
+ let allValues;
10023
+ if (!namePath || namePath.length === 0) {
10024
+ allValues = this.getFieldsValue(true);
10025
+ } else {
10026
+ allValues = this.getFieldsValue(namePath);
10027
+ }
10028
+ this.watchList.forEach((callback) => {
10029
+ callback(allValues, namePath);
10030
+ });
10031
+ }
10032
+ };
10078
10033
  this.callbacks = {
10079
10034
  onFinish: () => {
10080
10035
  },
@@ -10098,6 +10053,24 @@ const useForm = (form) => {
10098
10053
  }
10099
10054
  return [formRef.current];
10100
10055
  };
10056
+ const useWatch = (path, form) => {
10057
+ const formInstance = form.getInternal(SECRET);
10058
+ const [value, setValue] = useState();
10059
+ useEffect(() => {
10060
+ const unsubscribe = formInstance.registerWatch(
10061
+ (data, namePath) => {
10062
+ const value2 = data[path];
10063
+ setValue(value2);
10064
+ }
10065
+ );
10066
+ const initialValue = form.getFieldsValue(true);
10067
+ if (value !== initialValue[path]) {
10068
+ setValue(initialValue[path]);
10069
+ }
10070
+ return () => unsubscribe();
10071
+ }, [form]);
10072
+ return value;
10073
+ };
10101
10074
  const defaultProps$Y = {
10102
10075
  ...ComponentDefaults,
10103
10076
  labelPosition: "right",
@@ -10403,6 +10376,7 @@ let FormItem = _FormItem;
10403
10376
  const InnerForm = Form;
10404
10377
  InnerForm.Item = FormItem;
10405
10378
  InnerForm.useForm = useForm;
10379
+ InnerForm.useWatch = useWatch;
10406
10380
  function trimExtraChar(value, char, regExp) {
10407
10381
  const index = value.indexOf(char);
10408
10382
  if (index === -1) {
@@ -13953,7 +13927,7 @@ const Empty = (props) => {
13953
13927
  const imageNode = typeof imageUrl === "string" ? /* @__PURE__ */ React__default.createElement("img", { className: "img", src: imageUrl, alt: "empty" }) : imageUrl;
13954
13928
  useEffect(() => {
13955
13929
  setImgStyle(() => {
13956
- if (!imageSize) {
13930
+ if (typeof imageSize !== "number" && typeof imageSize !== "string") {
13957
13931
  return {};
13958
13932
  }
13959
13933
  if (typeof imageSize === "number") {
@@ -15685,29 +15659,29 @@ const defaultProps$r = {
15685
15659
  onClick: (event) => {
15686
15660
  }
15687
15661
  };
15688
- const classPrefix$8 = `nut-animate`;
15662
+ const classPrefix$8 = "nut-animate";
15689
15663
  const Animate = (props) => {
15690
- const { className, type: type4, action, loop, onClick, children, ...rest } = {
15664
+ const { className, type: type4, action, loop, onClick, children, style } = {
15691
15665
  ...defaultProps$r,
15692
15666
  ...props
15693
15667
  };
15694
15668
  const [clicked, setClicked] = useState(false);
15695
- const classes = classNames({
15696
- "nut-ani-container": true,
15697
- [`${classPrefix$8}-${type4}`]: action === "initial" || clicked ? type4 : false,
15698
- loop
15699
- });
15700
- const cls = classNames(classes, className);
15669
+ const classes = classNames(
15670
+ {
15671
+ "nut-ani-container": true,
15672
+ [`${classPrefix$8}-${type4}`]: action === "initial" || clicked,
15673
+ loop
15674
+ },
15675
+ className
15676
+ );
15701
15677
  const handleClick = (event) => {
15702
15678
  setClicked(true);
15703
15679
  if (!loop) {
15704
- setTimeout(() => {
15705
- setClicked(false);
15706
- }, 1e3);
15680
+ setTimeout(() => setClicked(false), 1e3);
15707
15681
  }
15708
- onClick && onClick(event);
15682
+ onClick(event);
15709
15683
  };
15710
- return /* @__PURE__ */ React__default.createElement("div", { className: "nut-animate" }, /* @__PURE__ */ React__default.createElement("div", { className: cls, onClick: handleClick, ...rest }, children));
15684
+ return /* @__PURE__ */ React__default.createElement(View, { className: "nut-animate" }, /* @__PURE__ */ React__default.createElement(View, { className: classes, onClick: handleClick, style }, children));
15711
15685
  };
15712
15686
  Animate.displayName = "NutAnimate";
15713
15687
  const defaultProps$q = {