@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.
- package/CHANGELOG.md +29 -7
- package/dist/esm/Address/style/style.css +1 -1
- package/dist/esm/Address.js +1 -1
- package/dist/esm/Animate/style/style.css +1 -1
- package/dist/esm/Animate.js +1 -1
- package/dist/esm/Calendar/style/style.css +1 -1
- package/dist/esm/Calendar.js +1 -1
- package/dist/esm/CalendarCard.js +1 -1
- package/dist/esm/CalendarItem.js +1 -1
- package/dist/esm/Cascader/style/style.css +1 -1
- package/dist/esm/Cascader.js +1 -1
- package/dist/esm/DatePicker.js +1 -1
- package/dist/esm/Empty.js +1 -1
- package/dist/esm/Form.js +2 -1
- package/dist/esm/FormItem.js +1 -1
- package/dist/esm/TabPane.js +1 -1
- package/dist/esm/Tabs/style/style.css +1 -1
- package/dist/esm/Tabs.js +1 -1
- package/dist/esm/{address.taro-BCoDZM6h.js → address.taro-Ck0ZmxRg.js} +1 -1
- package/dist/esm/{animate.taro-CQVEyDKL.js → animate.taro-BHDZMzJF.js} +9 -12
- package/dist/esm/{calendar.taro-CM4yWFlF.js → calendar.taro-CUDVpJBa.js} +3 -3
- package/dist/esm/{calendarcard.taro-CvWyBqnr.js → calendarcard.taro-BiOnui_b.js} +4 -4
- package/dist/esm/{calendaritem.taro-BGbbuJOS.js → calendaritem.taro-DveeC4_t.js} +237 -219
- package/dist/esm/{cascader.taro-BwRnRQXE.js → cascader.taro-DUJvcGw0.js} +1 -1
- package/dist/esm/date-BmUWlDuN.js +147 -0
- package/dist/esm/{datepicker.taro-DicskhhH.js → datepicker.taro-Dwh8sKhJ.js} +8 -0
- package/dist/esm/{empty.taro-DhCHSdca.js → empty.taro-ChtnK90s.js} +1 -1
- package/dist/esm/{formitem.taro-CU6rrcJD.js → formitem.taro-Bee3MWwq.js} +121 -31
- package/dist/esm/nutui-react.es.js +11 -11
- package/dist/esm/{tabpane.taro-BAe86j3t.js → tabpane.taro-BAihO3w8.js} +2 -1
- package/dist/esm/{tabs.taro-CnXiMR_B.js → tabs.taro-sp_DNWis.js} +26 -44
- package/dist/locales/base.js +1 -1
- package/dist/locales/en-US.js +1 -1
- package/dist/locales/id-ID.js +1 -1
- package/dist/locales/tr-TR.js +1 -1
- package/dist/locales/zh-CN.js +1 -1
- package/dist/locales/zh-TW.js +1 -1
- package/dist/locales/zh-UG.js +1 -1
- package/dist/nutui.react.es.js +529 -555
- package/dist/nutui.react.umd.js +529 -555
- package/dist/packages/animate/animate.scss +63 -105
- package/dist/packages/calendar/calendar.scss +9 -9
- package/dist/packages/tabs/tabs.scss +72 -115
- package/dist/style.css +1 -1
- package/dist/types/packages/animate/animate.taro.d.ts +2 -1
- package/dist/types/packages/form/__tests__/merge.spec.d.ts +1 -0
- package/dist/types/packages/form/index.d.ts +2 -1
- package/dist/types/packages/form/index.taro.d.ts +2 -1
- package/dist/types/packages/form/useform.d.ts +2 -1
- package/dist/types/packages/form/useform.taro.d.ts +2 -1
- package/dist/types/utils/date.d.ts +54 -52
- package/dist/types/utils/merge.d.ts +14 -1
- package/package.json +1 -1
- package/dist/esm/date-CYwRNlGq.js +0 -219
package/dist/nutui.react.umd.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("react"), require("@tarojs/taro"), require("@tarojs/components"), require("react-dom")) : typeof define === "function" && define.amd ? define(["exports", "react", "@tarojs/taro", "@tarojs/components", "react-dom"], factory) : (global2 = typeof globalThis !== "undefined" ? globalThis : global2 || self, factory((global2.nutui = global2.nutui || {}, global2.nutui.react = {}), global2.React, global2.Taro, global2.components, global2.ReactDOM));
|
|
3
3
|
})(this, function(exports2, React, Taro, components, ReactDOM) {
|
|
4
4
|
"use strict";/*!
|
|
5
|
-
* @nutui/nutui-react-taro v2.7.
|
|
5
|
+
* @nutui/nutui-react-taro v2.7.8 Fri Feb 14 2025 16:17:59 GMT+0800 (China Standard Time)
|
|
6
6
|
* (c) 2023 @jdf2e.
|
|
7
7
|
* Released under the MIT License.
|
|
8
8
|
*/
|
|
@@ -1365,7 +1365,7 @@
|
|
|
1365
1365
|
return value != null && isLength(value.length) && !isFunction2(value);
|
|
1366
1366
|
}
|
|
1367
1367
|
var isBuffer = nativeIsBuffer || stubFalse;
|
|
1368
|
-
function
|
|
1368
|
+
function isEqual2(value, other) {
|
|
1369
1369
|
return baseIsEqual(value, other);
|
|
1370
1370
|
}
|
|
1371
1371
|
function isFunction2(value) {
|
|
@@ -1395,7 +1395,7 @@
|
|
|
1395
1395
|
function stubFalse() {
|
|
1396
1396
|
return false;
|
|
1397
1397
|
}
|
|
1398
|
-
module2.exports =
|
|
1398
|
+
module2.exports = isEqual2;
|
|
1399
1399
|
})(lodash_isequal, lodash_isequal.exports);
|
|
1400
1400
|
var lodash_isequalExports = lodash_isequal.exports;
|
|
1401
1401
|
const isequal = /* @__PURE__ */ getDefaultExportFromCjs(lodash_isequalExports);
|
|
@@ -3938,7 +3938,7 @@
|
|
|
3938
3938
|
}));
|
|
3939
3939
|
};
|
|
3940
3940
|
Space.displayName = "NutSpace";
|
|
3941
|
-
function useWatch(dep, callback, config2 = { immediate: false }) {
|
|
3941
|
+
function useWatch$1(dep, callback, config2 = { immediate: false }) {
|
|
3942
3942
|
const { immediate } = config2;
|
|
3943
3943
|
const prev = React.useRef();
|
|
3944
3944
|
const inited = React.useRef(false);
|
|
@@ -4074,7 +4074,7 @@
|
|
|
4074
4074
|
const [rootRect, setRootRect] = React.useState({});
|
|
4075
4075
|
const [fixed, setFixed] = React.useState(false);
|
|
4076
4076
|
const [transform, setTransform] = React.useState(0);
|
|
4077
|
-
useWatch(fixed, () => {
|
|
4077
|
+
useWatch$1(fixed, () => {
|
|
4078
4078
|
onChange && onChange(fixed);
|
|
4079
4079
|
});
|
|
4080
4080
|
const rootStyle = React.useMemo(() => {
|
|
@@ -5269,7 +5269,7 @@
|
|
|
5269
5269
|
autoHeightClassName,
|
|
5270
5270
|
className
|
|
5271
5271
|
);
|
|
5272
|
-
return children
|
|
5272
|
+
return children && /* @__PURE__ */ React.createElement(components.View, { className: classes }, !disabled && children);
|
|
5273
5273
|
};
|
|
5274
5274
|
const inBrowser = typeof window !== "undefined";
|
|
5275
5275
|
function requestAniFrame() {
|
|
@@ -5313,24 +5313,19 @@
|
|
|
5313
5313
|
value: outerValue,
|
|
5314
5314
|
defaultValue: outerDefaultValue,
|
|
5315
5315
|
...rest
|
|
5316
|
-
} = {
|
|
5317
|
-
...defaultProps$18,
|
|
5318
|
-
...props
|
|
5319
|
-
};
|
|
5316
|
+
} = { ...defaultProps$18, ...props };
|
|
5320
5317
|
const uuid = useUuid();
|
|
5321
5318
|
const [value, setValue] = usePropsValue({
|
|
5322
5319
|
value: outerValue,
|
|
5323
5320
|
defaultValue: outerDefaultValue,
|
|
5324
|
-
finalValue: 0,
|
|
5325
5321
|
onChange
|
|
5326
5322
|
});
|
|
5327
5323
|
const titleItemsRef = React.useRef([]);
|
|
5328
|
-
const navRef = React.useRef(null);
|
|
5329
5324
|
const getTitles = () => {
|
|
5330
5325
|
const titles2 = [];
|
|
5331
5326
|
React.Children.forEach(children, (child, idx) => {
|
|
5332
5327
|
if (React.isValidElement(child)) {
|
|
5333
|
-
const
|
|
5328
|
+
const { props: props2 } = child;
|
|
5334
5329
|
if ((props2 == null ? void 0 : props2.title) || (props2 == null ? void 0 : props2.value)) {
|
|
5335
5330
|
titles2.push({
|
|
5336
5331
|
title: props2.title,
|
|
@@ -5365,13 +5360,8 @@
|
|
|
5365
5360
|
);
|
|
5366
5361
|
const classesTitle = classNames(`${classPrefix$k}-titles`, {
|
|
5367
5362
|
[`${classPrefix$k}-titles-${activeType}`]: activeType,
|
|
5368
|
-
[`${classPrefix$k}-titles-scrollable`]: true,
|
|
5369
5363
|
[`${classPrefix$k}-titles-${align}`]: align
|
|
5370
5364
|
});
|
|
5371
|
-
const tabsActiveStyle = {
|
|
5372
|
-
color: activeType === "smile" ? activeColor : "",
|
|
5373
|
-
background: activeType === "line" ? activeColor : ""
|
|
5374
|
-
};
|
|
5375
5365
|
const getRect2 = (selector) => {
|
|
5376
5366
|
return new Promise((resolve) => {
|
|
5377
5367
|
Taro.createSelectorQuery().select(selector).boundingClientRect().exec((rect = []) => {
|
|
@@ -5387,22 +5377,15 @@
|
|
|
5387
5377
|
});
|
|
5388
5378
|
};
|
|
5389
5379
|
const scrollWithAnimation = React.useRef(false);
|
|
5390
|
-
const navRectRef = React.useRef();
|
|
5391
|
-
const titleRectRef = React.useRef([]);
|
|
5392
5380
|
const [scrollLeft, setScrollLeft] = React.useState(0);
|
|
5393
5381
|
const [scrollTop, setScrollTop] = React.useState(0);
|
|
5394
5382
|
const scrollDirection = (to, direction2) => {
|
|
5395
5383
|
let count = 0;
|
|
5396
5384
|
const frames = 1;
|
|
5397
5385
|
function animate() {
|
|
5398
|
-
if (direction2 === "horizontal")
|
|
5399
|
-
|
|
5400
|
-
|
|
5401
|
-
setScrollTop(to);
|
|
5402
|
-
}
|
|
5403
|
-
if (++count < frames) {
|
|
5404
|
-
requestAniFrame$1(animate);
|
|
5405
|
-
}
|
|
5386
|
+
if (direction2 === "horizontal") setScrollLeft(to);
|
|
5387
|
+
else setScrollTop(to);
|
|
5388
|
+
if (++count < frames) requestAniFrame$1(animate);
|
|
5406
5389
|
}
|
|
5407
5390
|
animate();
|
|
5408
5391
|
};
|
|
@@ -5412,17 +5395,17 @@
|
|
|
5412
5395
|
getRect2(`#nut-tabs-titles-${name || uuid} .nut-tabs-list`),
|
|
5413
5396
|
getAllRect(`#nut-tabs-titles-${name || uuid} .nut-tabs-titles-item`)
|
|
5414
5397
|
]).then(([navRect, titleRects]) => {
|
|
5415
|
-
|
|
5416
|
-
titleRectRef.current = titleRects;
|
|
5417
|
-
const titleRect = titleRectRef.current[index];
|
|
5398
|
+
const titleRect = titleRects[index];
|
|
5418
5399
|
if (!titleRect) return;
|
|
5419
5400
|
let to = 0;
|
|
5420
5401
|
if (direction === "vertical") {
|
|
5421
5402
|
const top = titleRects.slice(0, index).reduce((prev, curr) => prev + curr.height, 0);
|
|
5422
|
-
to = top - (
|
|
5403
|
+
to = top - (navRect.height - titleRect.height) / 2;
|
|
5423
5404
|
} else {
|
|
5424
5405
|
const left2 = titleRects.slice(0, index).reduce((prev, curr) => prev + curr.width, 0);
|
|
5425
|
-
to =
|
|
5406
|
+
to = left2 - (navRect.width - titleRect.width) / 2;
|
|
5407
|
+
if (to < 0) return;
|
|
5408
|
+
to = rtl ? -to : to;
|
|
5426
5409
|
}
|
|
5427
5410
|
Taro.nextTick(() => {
|
|
5428
5411
|
scrollWithAnimation.current = true;
|
|
@@ -5437,7 +5420,7 @@
|
|
|
5437
5420
|
);
|
|
5438
5421
|
index = index < 0 ? 0 : index;
|
|
5439
5422
|
return {
|
|
5440
|
-
transform: direction === "horizontal" ? `translate3d(${rtl ? "" : "-"}${index * 100}%, 0, 0)` : `translate3d( 0
|
|
5423
|
+
transform: direction === "horizontal" ? `translate3d(${rtl ? "" : "-"}${index * 100}%, 0, 0)` : `translate3d( 0, -${index * 100}%, 0)`,
|
|
5441
5424
|
transitionDuration: `${duration}ms`
|
|
5442
5425
|
};
|
|
5443
5426
|
};
|
|
@@ -5448,12 +5431,11 @@
|
|
|
5448
5431
|
index = index < 0 ? 0 : index;
|
|
5449
5432
|
scrollIntoView(index);
|
|
5450
5433
|
}, [value]);
|
|
5451
|
-
const tabChange = (item
|
|
5434
|
+
const tabChange = (item) => {
|
|
5452
5435
|
onClick && onClick(item.value);
|
|
5453
|
-
if (item.disabled) {
|
|
5454
|
-
|
|
5436
|
+
if (!item.disabled) {
|
|
5437
|
+
setValue(item.value);
|
|
5455
5438
|
}
|
|
5456
|
-
setValue(item.value);
|
|
5457
5439
|
};
|
|
5458
5440
|
return /* @__PURE__ */ React.createElement(components.View, { className: classes, ...rest }, /* @__PURE__ */ React.createElement(
|
|
5459
5441
|
components.ScrollView,
|
|
@@ -5468,71 +5450,55 @@
|
|
|
5468
5450
|
scrollWithAnimation: rtl && Taro.getEnv() !== "WEB" ? false : scrollWithAnimation.current,
|
|
5469
5451
|
id: `nut-tabs-titles-${name || uuid}`,
|
|
5470
5452
|
className: classesTitle,
|
|
5471
|
-
style:
|
|
5453
|
+
style: tabStyle
|
|
5472
5454
|
},
|
|
5473
|
-
/* @__PURE__ */ React.createElement(components.View, { className: "nut-tabs-list"
|
|
5455
|
+
/* @__PURE__ */ React.createElement(components.View, { className: "nut-tabs-list" }, !!title && typeof title === "function" ? title() : titles.current.map((item, index) => {
|
|
5474
5456
|
return /* @__PURE__ */ React.createElement(
|
|
5475
5457
|
components.View,
|
|
5476
5458
|
{
|
|
5459
|
+
key: item.value,
|
|
5477
5460
|
ref: (ref) => titleItemsRef.current.push(ref),
|
|
5478
5461
|
id: `scrollIntoView${index}`,
|
|
5479
|
-
onClick: (
|
|
5480
|
-
tabChange(item);
|
|
5481
|
-
},
|
|
5462
|
+
onClick: () => tabChange(item),
|
|
5482
5463
|
className: classNames(`${classPrefix$k}-titles-item`, {
|
|
5483
5464
|
[`nut-tabs-titles-item-active`]: !item.disabled && String(item.value) === String(value),
|
|
5484
5465
|
[`nut-tabs-titles-item-disabled`]: item.disabled,
|
|
5485
5466
|
[`nut-tabs-titles-item-${align}`]: align
|
|
5486
|
-
})
|
|
5487
|
-
key: item.value
|
|
5467
|
+
})
|
|
5488
5468
|
},
|
|
5489
5469
|
activeType === "line" && /* @__PURE__ */ React.createElement(
|
|
5490
5470
|
components.View,
|
|
5491
5471
|
{
|
|
5492
5472
|
className: classNames(
|
|
5493
5473
|
`${classPrefix$k}-titles-item-line`,
|
|
5494
|
-
{
|
|
5495
|
-
[`${classPrefix$k}-titles-item-line-${direction}`]: true
|
|
5496
|
-
}
|
|
5474
|
+
`${classPrefix$k}-titles-item-line-${direction}`
|
|
5497
5475
|
),
|
|
5498
|
-
style:
|
|
5476
|
+
style: { background: activeColor }
|
|
5499
5477
|
}
|
|
5500
5478
|
),
|
|
5501
|
-
activeType === "smile" && /* @__PURE__ */ React.createElement(
|
|
5502
|
-
components.View,
|
|
5503
|
-
{
|
|
5504
|
-
className: `${classPrefix$k}-titles-item-smile`,
|
|
5505
|
-
style: tabsActiveStyle
|
|
5506
|
-
},
|
|
5507
|
-
/* @__PURE__ */ React.createElement(L$1, { color: activeColor })
|
|
5508
|
-
),
|
|
5479
|
+
activeType === "smile" && /* @__PURE__ */ React.createElement(components.View, { className: `${classPrefix$k}-titles-item-smile` }, /* @__PURE__ */ React.createElement(L$1, { color: activeColor })),
|
|
5509
5480
|
/* @__PURE__ */ React.createElement(
|
|
5510
5481
|
components.View,
|
|
5511
5482
|
{
|
|
5512
5483
|
className: classNames(
|
|
5513
|
-
|
|
5484
|
+
{
|
|
5485
|
+
[`${classPrefix$k}-ellipsis`]: direction === "vertical"
|
|
5486
|
+
},
|
|
5514
5487
|
`${classPrefix$k}-titles-item-text`
|
|
5515
|
-
)
|
|
5488
|
+
),
|
|
5489
|
+
style: { color: activeColor }
|
|
5516
5490
|
},
|
|
5517
5491
|
item.title
|
|
5518
5492
|
)
|
|
5519
5493
|
);
|
|
5520
5494
|
}))
|
|
5521
5495
|
), /* @__PURE__ */ React.createElement(components.View, { className: `${classPrefix$k}-content-wrap` }, /* @__PURE__ */ React.createElement(components.View, { className: `${classPrefix$k}-content`, style: getContentStyle() }, React.Children.map(children, (child, idx) => {
|
|
5522
|
-
if (!React.isValidElement(child))
|
|
5523
|
-
|
|
5524
|
-
}
|
|
5525
|
-
let childProps = {
|
|
5496
|
+
if (!React.isValidElement(child)) return null;
|
|
5497
|
+
return React.cloneElement(child, {
|
|
5526
5498
|
...child.props,
|
|
5527
|
-
active: value === child.props.value
|
|
5528
|
-
|
|
5529
|
-
|
|
5530
|
-
childProps = {
|
|
5531
|
-
...childProps,
|
|
5532
|
-
autoHeightClassName: "inactive"
|
|
5533
|
-
};
|
|
5534
|
-
}
|
|
5535
|
-
return React.cloneElement(child, childProps);
|
|
5499
|
+
active: value === child.props.value,
|
|
5500
|
+
autoHeightClassName: autoHeight && String(value) !== String(child.props.value || idx) ? "inactive" : void 0
|
|
5501
|
+
});
|
|
5536
5502
|
}))));
|
|
5537
5503
|
};
|
|
5538
5504
|
Tabs.displayName = "NutTabs";
|
|
@@ -6262,189 +6228,106 @@
|
|
|
6262
6228
|
};
|
|
6263
6229
|
const Address = React.forwardRef(InternalAddress);
|
|
6264
6230
|
Address.displayName = "NutAddress";
|
|
6265
|
-
const
|
|
6266
|
-
|
|
6267
|
-
|
|
6268
|
-
|
|
6269
|
-
|
|
6270
|
-
|
|
6271
|
-
|
|
6272
|
-
|
|
6273
|
-
|
|
6274
|
-
|
|
6275
|
-
|
|
6276
|
-
|
|
6277
|
-
|
|
6278
|
-
|
|
6279
|
-
|
|
6280
|
-
|
|
6281
|
-
|
|
6282
|
-
|
|
6283
|
-
|
|
6284
|
-
|
|
6285
|
-
|
|
6286
|
-
|
|
6287
|
-
|
|
6288
|
-
|
|
6289
|
-
|
|
6290
|
-
|
|
6291
|
-
|
|
6292
|
-
|
|
6293
|
-
|
|
6294
|
-
|
|
6295
|
-
|
|
6296
|
-
|
|
6297
|
-
|
|
6298
|
-
|
|
6299
|
-
|
|
6300
|
-
|
|
6301
|
-
|
|
6302
|
-
|
|
6303
|
-
|
|
6304
|
-
|
|
6305
|
-
|
|
6306
|
-
|
|
6307
|
-
|
|
6308
|
-
|
|
6309
|
-
|
|
6310
|
-
|
|
6311
|
-
|
|
6312
|
-
|
|
6313
|
-
|
|
6314
|
-
|
|
6315
|
-
|
|
6316
|
-
|
|
6317
|
-
|
|
6318
|
-
|
|
6319
|
-
|
|
6320
|
-
|
|
6321
|
-
|
|
6322
|
-
|
|
6323
|
-
|
|
6324
|
-
|
|
6325
|
-
|
|
6326
|
-
|
|
6327
|
-
|
|
6328
|
-
|
|
6329
|
-
|
|
6330
|
-
|
|
6331
|
-
|
|
6332
|
-
|
|
6333
|
-
|
|
6334
|
-
|
|
6335
|
-
|
|
6336
|
-
|
|
6337
|
-
|
|
6338
|
-
|
|
6339
|
-
|
|
6340
|
-
split = split || "-";
|
|
6341
|
-
const y2 = date2.getFullYear();
|
|
6342
|
-
const m2 = this.getNumTwoBit(date2.getMonth() + 1);
|
|
6343
|
-
const d = this.getNumTwoBit(date2.getDate());
|
|
6344
|
-
return [y2, m2, d].join(split);
|
|
6345
|
-
},
|
|
6346
|
-
/**
|
|
6347
|
-
* 返回日期格式字符串
|
|
6348
|
-
* @param {Number} 0返回今天的日期、1返回明天的日期,2返回后天得日期,依次类推
|
|
6349
|
-
* @return {string} '2014-12-31'
|
|
6350
|
-
*/
|
|
6351
|
-
getDay(i2) {
|
|
6352
|
-
i2 = i2 || 0;
|
|
6353
|
-
let date2 = /* @__PURE__ */ new Date();
|
|
6354
|
-
const diff = i2 * (1e3 * 60 * 60 * 24);
|
|
6355
|
-
date2 = new Date(date2.getTime() + diff);
|
|
6356
|
-
return this.date2Str(date2);
|
|
6357
|
-
},
|
|
6358
|
-
/**
|
|
6359
|
-
* 时间比较
|
|
6360
|
-
* @return {Boolean}
|
|
6361
|
-
*/
|
|
6362
|
-
compareDate(date1, date2) {
|
|
6363
|
-
const startTime = new Date(date1.replace("-", "/").replace("-", "/"));
|
|
6364
|
-
const endTime = new Date(date2.replace("-", "/").replace("-", "/"));
|
|
6365
|
-
if (startTime >= endTime) {
|
|
6366
|
-
return false;
|
|
6367
|
-
}
|
|
6368
|
-
return true;
|
|
6369
|
-
},
|
|
6370
|
-
/**
|
|
6371
|
-
* 时间是否相等
|
|
6372
|
-
* @return {Boolean}
|
|
6373
|
-
*/
|
|
6374
|
-
isEqual(date1, date2) {
|
|
6375
|
-
const startTime = new Date((date1 || "").replace(/-/g, "/")).getTime();
|
|
6376
|
-
const endTime = new Date(date2.replace(/-/g, "/")).getTime();
|
|
6377
|
-
if (startTime === endTime) {
|
|
6378
|
-
return true;
|
|
6379
|
-
}
|
|
6380
|
-
return false;
|
|
6381
|
-
},
|
|
6382
|
-
getMonthWeek(year, month, date2, firstDayOfWeek = 0) {
|
|
6383
|
-
const dateNow = new Date(Number(year), parseInt(month) - 1, Number(date2));
|
|
6384
|
-
let w = dateNow.getDay();
|
|
6385
|
-
const d = dateNow.getDate();
|
|
6386
|
-
let remainder = 6 - w;
|
|
6387
|
-
if (firstDayOfWeek !== 0) {
|
|
6388
|
-
w = w === 0 ? 7 : w;
|
|
6389
|
-
remainder = 7 - w;
|
|
6390
|
-
}
|
|
6391
|
-
return Math.ceil((d + remainder) / 7);
|
|
6392
|
-
},
|
|
6393
|
-
getYearWeek(year, month, date2, firstDayOfWeek = 0) {
|
|
6394
|
-
const dateNow = new Date(Number(year), parseInt(month) - 1, Number(date2));
|
|
6395
|
-
const dateFirst = new Date(Number(year), 0, 1);
|
|
6396
|
-
const dataNumber = Math.round(
|
|
6397
|
-
(dateNow.valueOf() - dateFirst.valueOf()) / 864e5
|
|
6398
|
-
);
|
|
6399
|
-
return Math.ceil((dataNumber + (dateFirst.getDay() + 1 - 1)) / 7);
|
|
6400
|
-
},
|
|
6401
|
-
getWeekDate(year, month, date2, firstDayOfWeek = 0) {
|
|
6402
|
-
const dateNow = new Date(Number(year), parseInt(month) - 1, Number(date2));
|
|
6403
|
-
const nowTime = dateNow.getTime();
|
|
6404
|
-
let day = dateNow.getDay();
|
|
6405
|
-
if (firstDayOfWeek === 0) {
|
|
6406
|
-
const oneDayTime2 = 24 * 60 * 60 * 1e3;
|
|
6407
|
-
const SundayTime2 = nowTime - day * oneDayTime2;
|
|
6408
|
-
const SaturdayTime = nowTime + (6 - day) * oneDayTime2;
|
|
6409
|
-
const sunday2 = this.date2Str(new Date(SundayTime2));
|
|
6410
|
-
const saturday = this.date2Str(new Date(SaturdayTime));
|
|
6411
|
-
return [sunday2, saturday];
|
|
6412
|
-
}
|
|
6413
|
-
day = day === 0 ? 7 : day;
|
|
6414
|
-
const oneDayTime = 24 * 60 * 60 * 1e3;
|
|
6415
|
-
const MondayTime = nowTime - (day - 1) * oneDayTime;
|
|
6416
|
-
const SundayTime = nowTime + (7 - day) * oneDayTime;
|
|
6417
|
-
const monday = this.date2Str(new Date(MondayTime));
|
|
6418
|
-
const sunday = this.date2Str(new Date(SundayTime));
|
|
6419
|
-
return [monday, sunday];
|
|
6420
|
-
},
|
|
6421
|
-
formatResultDate(date2) {
|
|
6422
|
-
const days = [...date2.split("-")];
|
|
6423
|
-
days[2] = Utils.getNumTwoBit(Number(days[2]));
|
|
6424
|
-
days[3] = `${days[0]}-${days[1]}-${days[2]}`;
|
|
6425
|
-
days[4] = Utils.getWhatDay(+days[0], +days[1], +days[2]);
|
|
6426
|
-
return days;
|
|
6231
|
+
const isLeapYear = (y2) => {
|
|
6232
|
+
return y2 % 4 === 0 && y2 % 100 !== 0 || y2 % 400 === 0;
|
|
6233
|
+
};
|
|
6234
|
+
const getWhatDay = (year, month, day) => {
|
|
6235
|
+
const date2 = new Date(year, month - 1, day);
|
|
6236
|
+
const dayNames = [
|
|
6237
|
+
"星期日",
|
|
6238
|
+
"星期一",
|
|
6239
|
+
"星期二",
|
|
6240
|
+
"星期三",
|
|
6241
|
+
"星期四",
|
|
6242
|
+
"星期五",
|
|
6243
|
+
"星期六"
|
|
6244
|
+
];
|
|
6245
|
+
return dayNames[date2.getDay()];
|
|
6246
|
+
};
|
|
6247
|
+
const getMonthPreDay = (year, month) => {
|
|
6248
|
+
const day = new Date(year, month - 1, 1).getDay();
|
|
6249
|
+
return day === 0 ? 7 : day;
|
|
6250
|
+
};
|
|
6251
|
+
const getMonthDays = (year, month) => {
|
|
6252
|
+
if (/^0/.test(month)) {
|
|
6253
|
+
month = month.split("")[1];
|
|
6254
|
+
}
|
|
6255
|
+
return [
|
|
6256
|
+
0,
|
|
6257
|
+
31,
|
|
6258
|
+
isLeapYear(Number(year)) ? 29 : 28,
|
|
6259
|
+
31,
|
|
6260
|
+
30,
|
|
6261
|
+
31,
|
|
6262
|
+
30,
|
|
6263
|
+
31,
|
|
6264
|
+
31,
|
|
6265
|
+
30,
|
|
6266
|
+
31,
|
|
6267
|
+
30,
|
|
6268
|
+
31
|
|
6269
|
+
][month];
|
|
6270
|
+
};
|
|
6271
|
+
const getNumTwoBit = (n2) => {
|
|
6272
|
+
return n2 > 9 ? `${n2}` : `0${n2}`;
|
|
6273
|
+
};
|
|
6274
|
+
const date2Str = (date2, split = "-") => {
|
|
6275
|
+
const y2 = date2.getFullYear();
|
|
6276
|
+
const m2 = getNumTwoBit(date2.getMonth() + 1);
|
|
6277
|
+
const d = getNumTwoBit(date2.getDate());
|
|
6278
|
+
return [y2, m2, d].join(split);
|
|
6279
|
+
};
|
|
6280
|
+
const getDateString = (offset = 0) => {
|
|
6281
|
+
const date2 = /* @__PURE__ */ new Date();
|
|
6282
|
+
date2.setDate(date2.getDate() + offset);
|
|
6283
|
+
return date2Str(date2, "-");
|
|
6284
|
+
};
|
|
6285
|
+
const compareDate = (date1, date2) => {
|
|
6286
|
+
const startTime = new Date(date1.replace("-", "/").replace("-", "/"));
|
|
6287
|
+
const endTime = new Date(date2.replace("-", "/").replace("-", "/"));
|
|
6288
|
+
return startTime < endTime;
|
|
6289
|
+
};
|
|
6290
|
+
const isEqual = (date1, date2) => {
|
|
6291
|
+
const startTime = new Date((date1 || "").replace(/-/g, "/")).getTime();
|
|
6292
|
+
const endTime = new Date(date2.replace(/-/g, "/")).getTime();
|
|
6293
|
+
return startTime === endTime;
|
|
6294
|
+
};
|
|
6295
|
+
const getWeekDate = (year, month, date2, firstDayOfWeek = 0) => {
|
|
6296
|
+
const dateNow = new Date(Number(year), parseInt(month) - 1, Number(date2));
|
|
6297
|
+
const nowTime = dateNow.getTime();
|
|
6298
|
+
let day = dateNow.getDay();
|
|
6299
|
+
if (firstDayOfWeek === 0) {
|
|
6300
|
+
const oneDayTime2 = 24 * 60 * 60 * 1e3;
|
|
6301
|
+
const SundayTime2 = nowTime - day * oneDayTime2;
|
|
6302
|
+
const SaturdayTime = nowTime + (6 - day) * oneDayTime2;
|
|
6303
|
+
const sunday2 = date2Str(new Date(SundayTime2));
|
|
6304
|
+
const saturday = date2Str(new Date(SaturdayTime));
|
|
6305
|
+
return [sunday2, saturday];
|
|
6427
6306
|
}
|
|
6307
|
+
day = day === 0 ? 7 : day;
|
|
6308
|
+
const oneDayTime = 24 * 60 * 60 * 1e3;
|
|
6309
|
+
const MondayTime = nowTime - (day - 1) * oneDayTime;
|
|
6310
|
+
const SundayTime = nowTime + (7 - day) * oneDayTime;
|
|
6311
|
+
const monday = date2Str(new Date(MondayTime));
|
|
6312
|
+
const sunday = date2Str(new Date(SundayTime));
|
|
6313
|
+
return [monday, sunday];
|
|
6314
|
+
};
|
|
6315
|
+
const formatResultDate = (date2) => {
|
|
6316
|
+
const [year, month, day] = [...date2.split("-")];
|
|
6317
|
+
const formatterDay = getNumTwoBit(Number(day));
|
|
6318
|
+
const formatterDate = `${year}-${month}-${day}`;
|
|
6319
|
+
const dayOfWeek = getWhatDay(Number(year), Number(month), Number(day));
|
|
6320
|
+
return [year, month, formatterDay, formatterDate, dayOfWeek];
|
|
6428
6321
|
};
|
|
6429
6322
|
const getCurrMonthData = (type2, year, month) => {
|
|
6430
|
-
|
|
6431
|
-
|
|
6432
|
-
|
|
6433
|
-
month = month === 1 ? 12 : --month;
|
|
6434
|
-
break;
|
|
6435
|
-
case "next":
|
|
6436
|
-
month === 12 && (year += 1);
|
|
6437
|
-
month = month === 12 ? 1 : ++month;
|
|
6438
|
-
break;
|
|
6323
|
+
{
|
|
6324
|
+
month === 12 && (year += 1);
|
|
6325
|
+
month = month === 12 ? 1 : ++month;
|
|
6439
6326
|
}
|
|
6440
|
-
return [
|
|
6441
|
-
year,
|
|
6442
|
-
Utils.getNumTwoBit(month),
|
|
6443
|
-
Utils.getMonthDays(String(year), String(month))
|
|
6444
|
-
];
|
|
6327
|
+
return [year, getNumTwoBit(month), getMonthDays(String(year), String(month))];
|
|
6445
6328
|
};
|
|
6446
6329
|
const getDaysStatus = (type2, year, month) => {
|
|
6447
|
-
let days =
|
|
6330
|
+
let days = getMonthDays(`${year}`, `${month}`);
|
|
6448
6331
|
return Array.from(Array(days), (v, k) => {
|
|
6449
6332
|
return {
|
|
6450
6333
|
day: k + 1,
|
|
@@ -6461,12 +6344,12 @@
|
|
|
6461
6344
|
preMonth = 12;
|
|
6462
6345
|
preYear += 1;
|
|
6463
6346
|
}
|
|
6464
|
-
let days =
|
|
6347
|
+
let days = getMonthPreDay(+year, +month);
|
|
6465
6348
|
days -= firstDayOfWeek;
|
|
6466
6349
|
if (days >= 7) {
|
|
6467
6350
|
days -= 7;
|
|
6468
6351
|
}
|
|
6469
|
-
const preDates =
|
|
6352
|
+
const preDates = getMonthDays(`${preYear}`, `${preMonth}`);
|
|
6470
6353
|
const months = Array.from(Array(preDates), (v, k) => {
|
|
6471
6354
|
return {
|
|
6472
6355
|
day: k + 1,
|
|
@@ -6484,28 +6367,26 @@
|
|
|
6484
6367
|
const isMultiple = (day, days) => {
|
|
6485
6368
|
if (days.length > 0) {
|
|
6486
6369
|
return days.some((item) => {
|
|
6487
|
-
return
|
|
6370
|
+
return isEqual(item, day);
|
|
6488
6371
|
});
|
|
6489
6372
|
}
|
|
6490
6373
|
return false;
|
|
6491
6374
|
};
|
|
6492
6375
|
const isCurrDay = (month, day) => {
|
|
6493
6376
|
const date2 = `${month.curData[0]}/${month.curData[1]}/${day}`;
|
|
6494
|
-
return
|
|
6377
|
+
return isEqual(date2, date2Str(/* @__PURE__ */ new Date(), "/"));
|
|
6495
6378
|
};
|
|
6496
6379
|
const getCurrDate = (day, month) => {
|
|
6497
|
-
return `${month.curData[0]}/${month.curData[1]}/${
|
|
6498
|
-
+day.day
|
|
6499
|
-
)}`;
|
|
6380
|
+
return `${month.curData[0]}/${month.curData[1]}/${getNumTwoBit(+day.day)}`;
|
|
6500
6381
|
};
|
|
6501
6382
|
const isStart = (day, days) => {
|
|
6502
|
-
return
|
|
6383
|
+
return isEqual(days[0], day);
|
|
6503
6384
|
};
|
|
6504
6385
|
const isEnd = (day, days) => {
|
|
6505
|
-
return
|
|
6386
|
+
return isEqual(days[1], day);
|
|
6506
6387
|
};
|
|
6507
6388
|
const isStartAndEnd = (days) => {
|
|
6508
|
-
return days.length >= 2 &&
|
|
6389
|
+
return days.length >= 2 && isEqual(days[0], days[1]);
|
|
6509
6390
|
};
|
|
6510
6391
|
const defaultProps$13 = {
|
|
6511
6392
|
...ComponentDefaults,
|
|
@@ -6513,8 +6394,8 @@
|
|
|
6513
6394
|
autoBackfill: false,
|
|
6514
6395
|
popup: true,
|
|
6515
6396
|
title: "",
|
|
6516
|
-
startDate:
|
|
6517
|
-
endDate:
|
|
6397
|
+
startDate: getDateString(0),
|
|
6398
|
+
endDate: getDateString(365),
|
|
6518
6399
|
showToday: true,
|
|
6519
6400
|
startText: "",
|
|
6520
6401
|
endText: "",
|
|
@@ -6547,6 +6428,7 @@
|
|
|
6547
6428
|
type: type2,
|
|
6548
6429
|
autoBackfill,
|
|
6549
6430
|
title,
|
|
6431
|
+
value,
|
|
6550
6432
|
defaultValue,
|
|
6551
6433
|
startDate,
|
|
6552
6434
|
endDate,
|
|
@@ -6564,12 +6446,13 @@
|
|
|
6564
6446
|
renderDayTop,
|
|
6565
6447
|
renderDayBottom,
|
|
6566
6448
|
renderBottomButton,
|
|
6567
|
-
value,
|
|
6568
6449
|
onConfirm,
|
|
6569
6450
|
onUpdate,
|
|
6570
6451
|
onDayClick,
|
|
6571
6452
|
onPageChange
|
|
6572
6453
|
} = { ...defaultProps$13, ...props };
|
|
6454
|
+
const classPrefix2 = "nut-calendar";
|
|
6455
|
+
const dayPrefix = "nut-calendar-day";
|
|
6573
6456
|
const weekdays = locale.calendaritem.weekdays;
|
|
6574
6457
|
const weeks = [
|
|
6575
6458
|
...weekdays.slice(firstDayOfWeek, 7),
|
|
@@ -6583,19 +6466,13 @@
|
|
|
6583
6466
|
const [monthDefaultRange, setMonthDefaultRange] = React.useState([]);
|
|
6584
6467
|
const [scrollTop, setScrollTop] = React.useState(0);
|
|
6585
6468
|
const [scrollWithAnimation, setScrollWithAnimation] = React.useState(false);
|
|
6586
|
-
const propStartDate = startDate ||
|
|
6587
|
-
const propEndDate = endDate ||
|
|
6469
|
+
const propStartDate = startDate || getDateString(0);
|
|
6470
|
+
const propEndDate = endDate || getDateString(365);
|
|
6588
6471
|
const startDates = splitDate(propStartDate);
|
|
6589
6472
|
const endDates = splitDate(propEndDate);
|
|
6590
6473
|
const [state] = React.useState({
|
|
6591
6474
|
currDateArray: []
|
|
6592
6475
|
});
|
|
6593
|
-
const getMonthsPanel = () => {
|
|
6594
|
-
return monthsPanel.current;
|
|
6595
|
-
};
|
|
6596
|
-
const getMonthsRef = () => {
|
|
6597
|
-
return monthsRef.current;
|
|
6598
|
-
};
|
|
6599
6476
|
const resetDefaultValue = () => {
|
|
6600
6477
|
if (defaultValue || Array.isArray(defaultValue) && defaultValue.length > 0) {
|
|
6601
6478
|
return type2 !== "single" ? [...defaultValue] : defaultValue;
|
|
@@ -6615,9 +6492,7 @@
|
|
|
6615
6492
|
const viewAreaRef = React.useRef(null);
|
|
6616
6493
|
const [avgHeight, setAvgHeight] = React.useState(0);
|
|
6617
6494
|
let viewHeight = 0;
|
|
6618
|
-
const
|
|
6619
|
-
const dayPrefix = "nut-calendar-day";
|
|
6620
|
-
const getMonthData = (curData, monthNum, type22) => {
|
|
6495
|
+
const getMonthData = (curData, monthNum) => {
|
|
6621
6496
|
let i2 = 0;
|
|
6622
6497
|
let date2 = curData;
|
|
6623
6498
|
const monthData = monthsData;
|
|
@@ -6628,12 +6503,12 @@
|
|
|
6628
6503
|
...getPreMonthDates("prev", y2, m2, firstDayOfWeek),
|
|
6629
6504
|
...getDaysStatus("active", y2, m2)
|
|
6630
6505
|
];
|
|
6631
|
-
const cssHeight = 39 + (days.length > 35 ? 384 : 320);
|
|
6632
6506
|
let scrollTop2 = 0;
|
|
6633
6507
|
if (monthData.length > 0) {
|
|
6634
6508
|
const monthEle = monthData[monthData.length - 1];
|
|
6635
6509
|
scrollTop2 = monthEle.scrollTop + monthEle.cssHeight;
|
|
6636
6510
|
}
|
|
6511
|
+
const cssHeight = 39 + (days.length > 35 ? 384 : 320);
|
|
6637
6512
|
const monthInfo = {
|
|
6638
6513
|
curData: date2,
|
|
6639
6514
|
title: monthTitle(y2, m2),
|
|
@@ -6641,16 +6516,14 @@
|
|
|
6641
6516
|
cssHeight,
|
|
6642
6517
|
scrollTop: scrollTop2
|
|
6643
6518
|
};
|
|
6644
|
-
|
|
6645
|
-
|
|
6646
|
-
|
|
6647
|
-
|
|
6648
|
-
|
|
6649
|
-
|
|
6650
|
-
|
|
6651
|
-
)
|
|
6652
|
-
monthData.push(monthInfo);
|
|
6653
|
-
}
|
|
6519
|
+
if (!endDates || !compareDate(
|
|
6520
|
+
`${endDates[0]}/${endDates[1]}/${getMonthDays(
|
|
6521
|
+
endDates[0],
|
|
6522
|
+
endDates[1]
|
|
6523
|
+
)}`,
|
|
6524
|
+
`${curData[0]}/${curData[1]}/${curData[2]}`
|
|
6525
|
+
)) {
|
|
6526
|
+
monthData.push(monthInfo);
|
|
6654
6527
|
}
|
|
6655
6528
|
date2 = getCurrMonthData("next", y2, m2);
|
|
6656
6529
|
} while (i2++ < monthNum);
|
|
@@ -6658,8 +6531,8 @@
|
|
|
6658
6531
|
};
|
|
6659
6532
|
const setReachedYearMonthInfo = (current) => {
|
|
6660
6533
|
const currentMonthsData = monthsData[current];
|
|
6661
|
-
const [year, month] = currentMonthsData.curData;
|
|
6662
6534
|
if (currentMonthsData.title === yearMonthTitle) return;
|
|
6535
|
+
const [year, month] = currentMonthsData.curData;
|
|
6663
6536
|
onPageChange && onPageChange([year, month, `${year}-${month}`]);
|
|
6664
6537
|
setYearMonthTitle(currentMonthsData.title);
|
|
6665
6538
|
};
|
|
@@ -6685,75 +6558,67 @@
|
|
|
6685
6558
|
setTranslateY(monthsData[start].scrollTop);
|
|
6686
6559
|
setReachedYearMonthInfo(current);
|
|
6687
6560
|
};
|
|
6688
|
-
const getMonthNum = () => {
|
|
6689
|
-
let monthNum = Number(endDates[1]) - Number(startDates[1]);
|
|
6690
|
-
const yearNum = Number(endDates[0]) - Number(startDates[0]);
|
|
6691
|
-
if (yearNum > 0) {
|
|
6692
|
-
monthNum += 12 * yearNum;
|
|
6693
|
-
}
|
|
6694
|
-
if (monthNum <= 0) {
|
|
6695
|
-
monthNum = 1;
|
|
6696
|
-
}
|
|
6697
|
-
setMonthsNum(monthNum);
|
|
6698
|
-
return monthNum;
|
|
6699
|
-
};
|
|
6700
6561
|
const setDefaultDate = () => {
|
|
6701
6562
|
let defaultData = [];
|
|
6702
|
-
if (type2 === "
|
|
6703
|
-
if (currentDate.length
|
|
6704
|
-
|
|
6705
|
-
|
|
6706
|
-
|
|
6707
|
-
|
|
6708
|
-
|
|
6709
|
-
|
|
6710
|
-
|
|
6711
|
-
|
|
6712
|
-
...splitDate(currentDate[1])
|
|
6713
|
-
];
|
|
6563
|
+
if (type2 === "single" && typeof currentDate === "string") {
|
|
6564
|
+
if (!currentDate.length) {
|
|
6565
|
+
return defaultData;
|
|
6566
|
+
}
|
|
6567
|
+
if (compareDate(currentDate, propStartDate)) {
|
|
6568
|
+
defaultData = [...splitDate(propStartDate)];
|
|
6569
|
+
} else if (!compareDate(currentDate, propEndDate)) {
|
|
6570
|
+
defaultData = [...splitDate(propEndDate)];
|
|
6571
|
+
} else {
|
|
6572
|
+
defaultData = [...splitDate(currentDate)];
|
|
6714
6573
|
}
|
|
6715
|
-
|
|
6716
|
-
|
|
6717
|
-
|
|
6718
|
-
|
|
6719
|
-
|
|
6720
|
-
if (
|
|
6721
|
-
|
|
6722
|
-
defaultArr.push(item);
|
|
6723
|
-
obj[item] = item;
|
|
6724
|
-
}
|
|
6574
|
+
return defaultData;
|
|
6575
|
+
}
|
|
6576
|
+
if (Array.isArray(currentDate) && currentDate.length) {
|
|
6577
|
+
switch (type2) {
|
|
6578
|
+
case "range": {
|
|
6579
|
+
if (compareDate(currentDate[0], propStartDate)) {
|
|
6580
|
+
currentDate[0] = propStartDate;
|
|
6725
6581
|
}
|
|
6726
|
-
|
|
6727
|
-
|
|
6728
|
-
|
|
6729
|
-
|
|
6730
|
-
|
|
6731
|
-
|
|
6732
|
-
|
|
6733
|
-
|
|
6734
|
-
currentDate.splice(0) && currentDate.push(...weekArr);
|
|
6735
|
-
if (propStartDate && Utils.compareDate(currentDate[0], propStartDate)) {
|
|
6736
|
-
currentDate.splice(0, 1, propStartDate);
|
|
6582
|
+
if (compareDate(propEndDate, currentDate[1])) {
|
|
6583
|
+
currentDate[1] = propEndDate;
|
|
6584
|
+
}
|
|
6585
|
+
defaultData = [
|
|
6586
|
+
...splitDate(currentDate[0]),
|
|
6587
|
+
...splitDate(currentDate[1])
|
|
6588
|
+
];
|
|
6589
|
+
break;
|
|
6737
6590
|
}
|
|
6738
|
-
|
|
6739
|
-
|
|
6591
|
+
case "multiple": {
|
|
6592
|
+
const defaultArr = [];
|
|
6593
|
+
const obj = {};
|
|
6594
|
+
currentDate.forEach((item) => {
|
|
6595
|
+
if (!compareDate(item, propStartDate) && !compareDate(propEndDate, item)) {
|
|
6596
|
+
if (!Object.hasOwnProperty.call(obj, item)) {
|
|
6597
|
+
defaultArr.push(item);
|
|
6598
|
+
obj[item] = item;
|
|
6599
|
+
}
|
|
6600
|
+
}
|
|
6601
|
+
});
|
|
6602
|
+
currentDate.splice(0, currentDate.length, ...defaultArr);
|
|
6603
|
+
defaultData = [...splitDate(defaultArr[0])];
|
|
6604
|
+
break;
|
|
6740
6605
|
}
|
|
6741
|
-
|
|
6742
|
-
|
|
6743
|
-
|
|
6744
|
-
|
|
6745
|
-
|
|
6746
|
-
|
|
6747
|
-
|
|
6748
|
-
|
|
6749
|
-
|
|
6750
|
-
|
|
6751
|
-
defaultData = [
|
|
6752
|
-
|
|
6753
|
-
|
|
6606
|
+
case "week": {
|
|
6607
|
+
const [y2, m2, d] = splitDate(currentDate[0]);
|
|
6608
|
+
const weekArr = getWeekDate(y2, m2, d, firstDayOfWeek);
|
|
6609
|
+
currentDate.splice(0, currentDate.length, ...weekArr);
|
|
6610
|
+
if (compareDate(currentDate[0], propStartDate)) {
|
|
6611
|
+
currentDate.splice(0, 1, propStartDate);
|
|
6612
|
+
}
|
|
6613
|
+
if (compareDate(propEndDate, currentDate[1])) {
|
|
6614
|
+
currentDate.splice(1, 1, propEndDate);
|
|
6615
|
+
}
|
|
6616
|
+
defaultData = [
|
|
6617
|
+
...splitDate(currentDate[0]),
|
|
6618
|
+
...splitDate(currentDate[1])
|
|
6619
|
+
];
|
|
6620
|
+
break;
|
|
6754
6621
|
}
|
|
6755
|
-
} else {
|
|
6756
|
-
defaultData = [];
|
|
6757
6622
|
}
|
|
6758
6623
|
}
|
|
6759
6624
|
return defaultData;
|
|
@@ -6776,63 +6641,57 @@
|
|
|
6776
6641
|
const date2 = /* @__PURE__ */ new Date();
|
|
6777
6642
|
const year = date2.getFullYear();
|
|
6778
6643
|
const month = date2.getMonth() + 1;
|
|
6779
|
-
const index = monthsData.findIndex(
|
|
6780
|
-
|
|
6781
|
-
|
|
6782
|
-
if (index > -1)
|
|
6783
|
-
current = index;
|
|
6784
|
-
}
|
|
6644
|
+
const index = monthsData.findIndex(
|
|
6645
|
+
(item) => +item.curData[0] === year && +item.curData[1] === month
|
|
6646
|
+
);
|
|
6647
|
+
if (index > -1) current = index;
|
|
6785
6648
|
}
|
|
6786
6649
|
return {
|
|
6787
6650
|
current,
|
|
6788
6651
|
lastCurrent
|
|
6789
6652
|
};
|
|
6790
6653
|
};
|
|
6791
|
-
const renderCurrentDate = () => {
|
|
6792
|
-
|
|
6793
|
-
const
|
|
6794
|
-
|
|
6795
|
-
|
|
6796
|
-
|
|
6797
|
-
|
|
6798
|
-
monthsData[current.current],
|
|
6799
|
-
true
|
|
6800
|
-
);
|
|
6801
|
-
chooseDay(
|
|
6654
|
+
const renderCurrentDate = (defaultData, current) => {
|
|
6655
|
+
if (!defaultData.length) return;
|
|
6656
|
+
const date2 = monthsData[current.current];
|
|
6657
|
+
switch (type2) {
|
|
6658
|
+
case "range": {
|
|
6659
|
+
handleDayClick({ day: defaultData[2], type: "active" }, date2);
|
|
6660
|
+
handleDayClick(
|
|
6802
6661
|
{ day: defaultData[5], type: "active" },
|
|
6803
|
-
monthsData[current.lastCurrent]
|
|
6804
|
-
true
|
|
6805
|
-
);
|
|
6806
|
-
} else if (type2 === "week") {
|
|
6807
|
-
chooseDay(
|
|
6808
|
-
{ day: defaultData[2], type: "curr" },
|
|
6809
|
-
monthsData[current.current],
|
|
6810
|
-
true
|
|
6662
|
+
monthsData[current.lastCurrent]
|
|
6811
6663
|
);
|
|
6812
|
-
|
|
6664
|
+
break;
|
|
6665
|
+
}
|
|
6666
|
+
case "week": {
|
|
6667
|
+
handleDayClick({ day: defaultData[2], type: "curr" }, date2);
|
|
6668
|
+
break;
|
|
6669
|
+
}
|
|
6670
|
+
case "multiple": {
|
|
6813
6671
|
[...currentDate].forEach((item) => {
|
|
6814
6672
|
const dateArr = splitDate(item);
|
|
6815
6673
|
let currentIndex = current.current;
|
|
6816
|
-
monthsData.
|
|
6817
|
-
|
|
6818
|
-
|
|
6819
|
-
|
|
6820
|
-
});
|
|
6821
|
-
chooseDay(
|
|
6674
|
+
currentIndex = monthsData.findIndex(
|
|
6675
|
+
(item2) => item2.title === monthTitle(dateArr[0], dateArr[1])
|
|
6676
|
+
);
|
|
6677
|
+
handleDayClick(
|
|
6822
6678
|
{ day: dateArr[2], type: "active" },
|
|
6823
|
-
monthsData[currentIndex]
|
|
6824
|
-
true
|
|
6679
|
+
monthsData[currentIndex]
|
|
6825
6680
|
);
|
|
6826
6681
|
});
|
|
6827
|
-
|
|
6828
|
-
|
|
6829
|
-
|
|
6830
|
-
|
|
6831
|
-
|
|
6832
|
-
);
|
|
6682
|
+
break;
|
|
6683
|
+
}
|
|
6684
|
+
default: {
|
|
6685
|
+
handleDayClick({ day: defaultData[2], type: "active" }, date2);
|
|
6686
|
+
break;
|
|
6833
6687
|
}
|
|
6834
6688
|
}
|
|
6835
|
-
|
|
6689
|
+
};
|
|
6690
|
+
const getMonthsPanel = () => {
|
|
6691
|
+
return monthsPanel.current;
|
|
6692
|
+
};
|
|
6693
|
+
const getMonthsRef = () => {
|
|
6694
|
+
return monthsRef.current;
|
|
6836
6695
|
};
|
|
6837
6696
|
const requestAniFrameFunc = (current, monthNum) => {
|
|
6838
6697
|
const lastItem = monthsData[monthsData.length - 1];
|
|
@@ -6841,19 +6700,31 @@
|
|
|
6841
6700
|
if (monthsRef && monthsPanel && viewAreaRef) {
|
|
6842
6701
|
viewHeight = getMonthsRef().clientHeight;
|
|
6843
6702
|
getMonthsPanel().style.height = `${containerHeight}px`;
|
|
6844
|
-
|
|
6845
|
-
|
|
6703
|
+
const currTop = monthsData[current].scrollTop;
|
|
6704
|
+
getMonthsRef().scrollTop = currTop;
|
|
6705
|
+
setScrollTop(currTop);
|
|
6846
6706
|
Taro.nextTick(() => setScrollWithAnimation(true));
|
|
6847
6707
|
}
|
|
6848
6708
|
});
|
|
6849
6709
|
setAvgHeight(Math.floor(containerHeight / (monthNum + 1)));
|
|
6850
6710
|
};
|
|
6711
|
+
const getMonthNum = () => {
|
|
6712
|
+
let monthNum = Number(endDates[1]) - Number(startDates[1]);
|
|
6713
|
+
const yearNum = Number(endDates[0]) - Number(startDates[0]);
|
|
6714
|
+
if (yearNum > 0) monthNum += 12 * yearNum;
|
|
6715
|
+
if (monthNum <= 0) monthNum = 1;
|
|
6716
|
+
setMonthsNum(monthNum);
|
|
6717
|
+
return monthNum;
|
|
6718
|
+
};
|
|
6851
6719
|
const initData = () => {
|
|
6852
6720
|
const monthNum = getMonthNum();
|
|
6853
6721
|
getMonthData(startDates, monthNum);
|
|
6854
|
-
const
|
|
6855
|
-
|
|
6856
|
-
|
|
6722
|
+
const defaultData = setDefaultDate();
|
|
6723
|
+
const current = getCurrentIndex(defaultData);
|
|
6724
|
+
const currentIndex = current.current;
|
|
6725
|
+
renderCurrentDate(defaultData, current);
|
|
6726
|
+
setDefaultRange(monthNum, currentIndex);
|
|
6727
|
+
requestAniFrameFunc(currentIndex, monthNum);
|
|
6857
6728
|
};
|
|
6858
6729
|
React.useEffect(() => {
|
|
6859
6730
|
initData();
|
|
@@ -6870,9 +6741,9 @@
|
|
|
6870
6741
|
popup && resetRender();
|
|
6871
6742
|
}, [currentDate]);
|
|
6872
6743
|
const scrollToDate = (date2) => {
|
|
6873
|
-
if (
|
|
6744
|
+
if (compareDate(date2, propStartDate)) {
|
|
6874
6745
|
date2 = propStartDate;
|
|
6875
|
-
} else if (!
|
|
6746
|
+
} else if (!compareDate(date2, propEndDate)) {
|
|
6876
6747
|
date2 = propEndDate;
|
|
6877
6748
|
}
|
|
6878
6749
|
const dateArr = splitDate(date2);
|
|
@@ -6893,22 +6764,20 @@
|
|
|
6893
6764
|
clearInterval(interval);
|
|
6894
6765
|
if (monthsRef.current) {
|
|
6895
6766
|
monthsRef.current.scrollTop = currTop;
|
|
6896
|
-
setScrollTop(
|
|
6767
|
+
setScrollTop(currTop);
|
|
6897
6768
|
}
|
|
6898
6769
|
}
|
|
6899
6770
|
}, 40);
|
|
6900
6771
|
} else {
|
|
6901
6772
|
monthsRef.current.scrollTop = currTop;
|
|
6902
|
-
setScrollTop(
|
|
6773
|
+
setScrollTop(currTop);
|
|
6903
6774
|
}
|
|
6904
6775
|
}
|
|
6905
6776
|
}
|
|
6906
6777
|
});
|
|
6907
6778
|
};
|
|
6908
6779
|
const monthsViewScroll = (e2) => {
|
|
6909
|
-
if (monthsData.length <= 1)
|
|
6910
|
-
return;
|
|
6911
|
-
}
|
|
6780
|
+
if (monthsData.length <= 1) return;
|
|
6912
6781
|
const scrollTop2 = e2.target.scrollTop;
|
|
6913
6782
|
Taro.getEnv() === "WEB" && setScrollTop(scrollTop2);
|
|
6914
6783
|
let current = Math.floor(scrollTop2 / avgHeight);
|
|
@@ -6917,16 +6786,10 @@
|
|
|
6917
6786
|
const nextTop = monthsData[current + 1].scrollTop;
|
|
6918
6787
|
const nextHeight = monthsData[current + 1].cssHeight;
|
|
6919
6788
|
if (current === 0) {
|
|
6920
|
-
if (scrollTop2 >= nextTop)
|
|
6921
|
-
current += 1;
|
|
6922
|
-
}
|
|
6789
|
+
if (scrollTop2 >= nextTop) current += 1;
|
|
6923
6790
|
} else if (current > 0 && current < monthsNum - 1) {
|
|
6924
|
-
if (scrollTop2 >= nextTop)
|
|
6925
|
-
|
|
6926
|
-
}
|
|
6927
|
-
if (scrollTop2 < monthsData[current].scrollTop) {
|
|
6928
|
-
current -= 1;
|
|
6929
|
-
}
|
|
6791
|
+
if (scrollTop2 >= nextTop) current += 1;
|
|
6792
|
+
if (scrollTop2 < monthsData[current].scrollTop) current -= 1;
|
|
6930
6793
|
} else {
|
|
6931
6794
|
const viewPosition = Math.round(scrollTop2 + viewHeight);
|
|
6932
6795
|
if (current + 1 <= monthsNum && viewPosition >= nextTop + nextHeight) {
|
|
@@ -6941,90 +6804,96 @@
|
|
|
6941
6804
|
React.useImperativeHandle(ref, () => ({
|
|
6942
6805
|
scrollToDate
|
|
6943
6806
|
}));
|
|
6807
|
+
const isDisable = (day, month) => {
|
|
6808
|
+
if (day.type !== "active") return true;
|
|
6809
|
+
const dateStr = getCurrDate(day, month);
|
|
6810
|
+
if (compareDate(dateStr, propStartDate)) return true;
|
|
6811
|
+
if (compareDate(propEndDate, dateStr)) return true;
|
|
6812
|
+
return false;
|
|
6813
|
+
};
|
|
6944
6814
|
const getClasses = (day, month) => {
|
|
6945
6815
|
const dateStr = getCurrDate(day, month);
|
|
6946
|
-
if (day
|
|
6947
|
-
|
|
6948
|
-
|
|
6949
|
-
|
|
6950
|
-
|
|
6951
|
-
|
|
6952
|
-
|
|
6953
|
-
}
|
|
6954
|
-
if (Array.isArray(currentDate) && Object.values(currentDate).length === 2 && Utils.compareDate(currentDate[0], dateStr) && Utils.compareDate(dateStr, currentDate[1])) {
|
|
6955
|
-
if (disableDate(day)) {
|
|
6956
|
-
return `${dayPrefix}-choose-disabled`;
|
|
6957
|
-
}
|
|
6958
|
-
return `${dayPrefix}-choose`;
|
|
6959
|
-
}
|
|
6960
|
-
} else if (type2 === "multiple" && isMultiple(dateStr, currentDate) || !Array.isArray(currentDate) && Utils.isEqual(currentDate, dateStr)) {
|
|
6961
|
-
return `${dayPrefix}-active`;
|
|
6816
|
+
if (isDisable(day, month)) return `${dayPrefix}-disabled`;
|
|
6817
|
+
const activeCls = `${dayPrefix}-active`;
|
|
6818
|
+
if (type2 === "range" || type2 === "week") {
|
|
6819
|
+
if (isStart(dateStr, currentDate))
|
|
6820
|
+
return `${activeCls} active-start`;
|
|
6821
|
+
if (isEnd(dateStr, currentDate)) {
|
|
6822
|
+
return `${activeCls} active-end`;
|
|
6962
6823
|
}
|
|
6963
|
-
if (
|
|
6964
|
-
return `${dayPrefix}-disabled`;
|
|
6824
|
+
if (currentDate.length === 2 && compareDate(currentDate[0], dateStr) && compareDate(dateStr, currentDate[1])) {
|
|
6825
|
+
return disableDate(day) ? `${dayPrefix}-choose-disabled` : `${dayPrefix}-choose`;
|
|
6965
6826
|
}
|
|
6966
|
-
|
|
6827
|
+
} else if (type2 === "multiple" && isMultiple(dateStr, currentDate) || !Array.isArray(currentDate) && isEqual(currentDate, dateStr)) {
|
|
6828
|
+
return activeCls;
|
|
6967
6829
|
}
|
|
6968
|
-
return `${dayPrefix}-disabled`;
|
|
6830
|
+
if (disableDate(day)) return `${dayPrefix}-disabled`;
|
|
6831
|
+
return null;
|
|
6969
6832
|
};
|
|
6970
|
-
const
|
|
6971
|
-
if (
|
|
6972
|
-
return;
|
|
6973
|
-
}
|
|
6833
|
+
const handleDayClick = (day, month, isFirst = true) => {
|
|
6834
|
+
if (isDisable(day, month) || disableDate(day)) return;
|
|
6974
6835
|
const days = [...month.curData];
|
|
6975
6836
|
const [y2, m2] = month.curData;
|
|
6976
|
-
days[2] = typeof day.day === "number" ?
|
|
6837
|
+
days[2] = typeof day.day === "number" ? getNumTwoBit(day.day) : day.day;
|
|
6977
6838
|
days[3] = `${days[0]}/${days[1]}/${days[2]}`;
|
|
6978
|
-
days[4] =
|
|
6979
|
-
|
|
6980
|
-
|
|
6981
|
-
|
|
6982
|
-
|
|
6983
|
-
if (
|
|
6984
|
-
hasIndex =
|
|
6839
|
+
days[4] = getWhatDay(+days[0], +days[1], +days[2]);
|
|
6840
|
+
const newDate = days[3];
|
|
6841
|
+
switch (type2) {
|
|
6842
|
+
case "multiple": {
|
|
6843
|
+
if (Array.isArray(currentDate)) {
|
|
6844
|
+
if (currentDate.length > 0) {
|
|
6845
|
+
const hasIndex = currentDate.findIndex((item) => item === newDate);
|
|
6846
|
+
if (isFirst) {
|
|
6847
|
+
state.currDateArray.push([...days]);
|
|
6848
|
+
} else if (hasIndex > -1) {
|
|
6849
|
+
currentDate.splice(hasIndex, 1);
|
|
6850
|
+
state.currDateArray.splice(hasIndex, 1);
|
|
6851
|
+
} else {
|
|
6852
|
+
currentDate.push(newDate);
|
|
6853
|
+
state.currDateArray.push([...days]);
|
|
6854
|
+
}
|
|
6855
|
+
} else {
|
|
6856
|
+
currentDate.push(newDate);
|
|
6857
|
+
state.currDateArray = [[...days]];
|
|
6985
6858
|
}
|
|
6986
|
-
});
|
|
6987
|
-
if (isFirst) {
|
|
6988
|
-
state.currDateArray.push([...days]);
|
|
6989
|
-
} else if (hasIndex !== "") {
|
|
6990
|
-
currentDate.splice(hasIndex, 1);
|
|
6991
|
-
state.currDateArray.splice(hasIndex, 1);
|
|
6992
|
-
} else {
|
|
6993
|
-
currentDate.push(days[3]);
|
|
6994
|
-
state.currDateArray.push([...days]);
|
|
6995
6859
|
}
|
|
6996
|
-
|
|
6997
|
-
currentDate.push(days[3]);
|
|
6998
|
-
state.currDateArray = [[...days]];
|
|
6999
|
-
}
|
|
7000
|
-
} else if (type2 === "range") {
|
|
7001
|
-
const curDataLength = Object.values(currentDate).length;
|
|
7002
|
-
if (curDataLength === 2 || curDataLength === 0) {
|
|
7003
|
-
Array.isArray(currentDate) && currentDate.splice(0) && currentDate.push(days[3]);
|
|
7004
|
-
state.currDateArray = [[...days]];
|
|
7005
|
-
} else if (Utils.compareDate(currentDate[0], days[3])) {
|
|
7006
|
-
Array.isArray(currentDate) && currentDate.push(days[3]);
|
|
7007
|
-
state.currDateArray = [...state.currDateArray, [...days]];
|
|
7008
|
-
} else {
|
|
7009
|
-
Array.isArray(currentDate) && currentDate.unshift(days[3]);
|
|
7010
|
-
state.currDateArray = [[...days], ...state.currDateArray];
|
|
6860
|
+
break;
|
|
7011
6861
|
}
|
|
7012
|
-
|
|
7013
|
-
|
|
7014
|
-
|
|
7015
|
-
|
|
6862
|
+
case "range": {
|
|
6863
|
+
if (Array.isArray(currentDate)) {
|
|
6864
|
+
if (currentDate.length === 2 || currentDate.length === 0) {
|
|
6865
|
+
currentDate.splice(0, currentDate.length, newDate);
|
|
6866
|
+
state.currDateArray = [[...days]];
|
|
6867
|
+
} else if (compareDate(currentDate[0], newDate)) {
|
|
6868
|
+
currentDate.push(newDate);
|
|
6869
|
+
state.currDateArray = [...state.currDateArray, [...days]];
|
|
6870
|
+
} else {
|
|
6871
|
+
currentDate.unshift(newDate);
|
|
6872
|
+
state.currDateArray = [[...days], ...state.currDateArray];
|
|
6873
|
+
}
|
|
6874
|
+
}
|
|
6875
|
+
break;
|
|
6876
|
+
}
|
|
6877
|
+
case "week": {
|
|
6878
|
+
const weekArr = getWeekDate(y2, m2, `${day.day}`, firstDayOfWeek);
|
|
6879
|
+
if (compareDate(weekArr[0], propStartDate)) {
|
|
6880
|
+
weekArr[0] = propStartDate;
|
|
6881
|
+
}
|
|
6882
|
+
if (compareDate(propEndDate, weekArr[1])) {
|
|
6883
|
+
weekArr[1] = propEndDate;
|
|
6884
|
+
}
|
|
6885
|
+
currentDate.splice(0, currentDate.length, ...weekArr);
|
|
6886
|
+
state.currDateArray = [
|
|
6887
|
+
formatResultDate(weekArr[0]),
|
|
6888
|
+
formatResultDate(weekArr[1])
|
|
6889
|
+
];
|
|
6890
|
+
break;
|
|
7016
6891
|
}
|
|
7017
|
-
|
|
7018
|
-
|
|
6892
|
+
default: {
|
|
6893
|
+
setCurrentDate(newDate);
|
|
6894
|
+
state.currDateArray = [...days];
|
|
6895
|
+
break;
|
|
7019
6896
|
}
|
|
7020
|
-
Array.isArray(currentDate) && currentDate.splice(0) && currentDate.push(...weekArr);
|
|
7021
|
-
state.currDateArray = [
|
|
7022
|
-
Utils.formatResultDate(weekArr[0]),
|
|
7023
|
-
Utils.formatResultDate(weekArr[1])
|
|
7024
|
-
];
|
|
7025
|
-
} else {
|
|
7026
|
-
setCurrentDate(days[3]);
|
|
7027
|
-
state.currDateArray = [...days];
|
|
7028
6897
|
}
|
|
7029
6898
|
if (!isFirst) {
|
|
7030
6899
|
onDayClick && onDayClick(state.currDateArray);
|
|
@@ -7044,11 +6913,11 @@
|
|
|
7044
6913
|
}
|
|
7045
6914
|
};
|
|
7046
6915
|
const classes = classNames(
|
|
6916
|
+
classPrefix2,
|
|
7047
6917
|
{
|
|
7048
6918
|
[`${classPrefix2}-title`]: !popup,
|
|
7049
6919
|
[`${classPrefix2}-nofooter`]: !!autoBackfill
|
|
7050
6920
|
},
|
|
7051
|
-
classPrefix2,
|
|
7052
6921
|
className
|
|
7053
6922
|
);
|
|
7054
6923
|
const headerClasses = classNames({
|
|
@@ -7064,6 +6933,40 @@
|
|
|
7064
6933
|
const renderHeader = () => {
|
|
7065
6934
|
return /* @__PURE__ */ React.createElement("div", { className: headerClasses }, showTitle && /* @__PURE__ */ React.createElement("div", { className: `${classPrefix2}-title` }, title || locale.calendaritem.title), renderHeaderButtons && /* @__PURE__ */ React.createElement("div", { className: `${classPrefix2}-header-buttons` }, renderHeaderButtons()), showSubTitle && /* @__PURE__ */ React.createElement("div", { className: `${classPrefix2}-sub-title` }, yearMonthTitle), /* @__PURE__ */ React.createElement("div", { className: `${classPrefix2}-weeks`, ref: weeksPanel }, weeks.map((item) => /* @__PURE__ */ React.createElement("div", { className: `${classPrefix2}-week-item`, key: item }, item))));
|
|
7066
6935
|
};
|
|
6936
|
+
const renderItem = (month, day, index) => {
|
|
6937
|
+
const startTip = isStartTip(day, month);
|
|
6938
|
+
const endTip = isEndTip(day, month);
|
|
6939
|
+
const noStartNorEnd = !startTip && !endTip;
|
|
6940
|
+
return /* @__PURE__ */ React.createElement(
|
|
6941
|
+
"div",
|
|
6942
|
+
{
|
|
6943
|
+
className: classNames("nut-calendar-day", getClasses(day, month)),
|
|
6944
|
+
onClick: () => handleDayClick(day, month, false),
|
|
6945
|
+
key: index
|
|
6946
|
+
},
|
|
6947
|
+
/* @__PURE__ */ React.createElement("div", { className: `${classPrefix2}-day-day` }, renderDay ? renderDay(day) : day.day),
|
|
6948
|
+
!startTip && renderDayTop && /* @__PURE__ */ React.createElement("div", { className: `${classPrefix2}-day-info-top` }, renderDayTop(day)),
|
|
6949
|
+
noStartNorEnd && renderDayBottom && /* @__PURE__ */ React.createElement("div", { className: `${classPrefix2}-day-info-bottom` }, renderDayBottom(day)),
|
|
6950
|
+
noStartNorEnd && isCurrDay(month, day.day) && !renderDayBottom && showToday && /* @__PURE__ */ React.createElement("div", { className: `${classPrefix2}-day-info-curr` }, locale.calendaritem.today),
|
|
6951
|
+
startTip && /* @__PURE__ */ React.createElement(
|
|
6952
|
+
"div",
|
|
6953
|
+
{
|
|
6954
|
+
className: classNames("nut-calendar-day-info", {
|
|
6955
|
+
"nut-calendar-day-info-top": isStartAndEnd(
|
|
6956
|
+
currentDate
|
|
6957
|
+
)
|
|
6958
|
+
})
|
|
6959
|
+
},
|
|
6960
|
+
startText || locale.calendaritem.start
|
|
6961
|
+
),
|
|
6962
|
+
endTip && /* @__PURE__ */ React.createElement("div", { className: `${classPrefix2}-day-info` }, endText || locale.calendaritem.end)
|
|
6963
|
+
);
|
|
6964
|
+
};
|
|
6965
|
+
const renderPanel = (month, key) => {
|
|
6966
|
+
return /* @__PURE__ */ React.createElement("div", { className: `${classPrefix2}-month`, key }, /* @__PURE__ */ React.createElement("div", { className: `${classPrefix2}-month-title` }, month.title), /* @__PURE__ */ React.createElement("div", { className: `${classPrefix2}-days` }, month.monthData.map(
|
|
6967
|
+
(day, i2) => renderItem(month, day, i2)
|
|
6968
|
+
)));
|
|
6969
|
+
};
|
|
7067
6970
|
const renderContent = () => {
|
|
7068
6971
|
return /* @__PURE__ */ React.createElement(
|
|
7069
6972
|
components.ScrollView,
|
|
@@ -7084,31 +6987,7 @@
|
|
|
7084
6987
|
style: { transform: `translateY(${translateY}px)` }
|
|
7085
6988
|
},
|
|
7086
6989
|
monthsData.slice(monthDefaultRange[0], monthDefaultRange[1]).map((month, key) => {
|
|
7087
|
-
return
|
|
7088
|
-
"div",
|
|
7089
|
-
{
|
|
7090
|
-
className: [
|
|
7091
|
-
`${classPrefix2}-day`,
|
|
7092
|
-
getClasses(day, month)
|
|
7093
|
-
].join(" "),
|
|
7094
|
-
onClick: () => {
|
|
7095
|
-
chooseDay(day, month);
|
|
7096
|
-
},
|
|
7097
|
-
key: i2
|
|
7098
|
-
},
|
|
7099
|
-
/* @__PURE__ */ React.createElement("div", { className: `${classPrefix2}-day-day` }, renderDay ? renderDay(day) : day.day),
|
|
7100
|
-
!isStartTip(day, month) && renderDayTop && /* @__PURE__ */ React.createElement("div", { className: `${classPrefix2}-day-info-top` }, renderDayTop(day)),
|
|
7101
|
-
!isStartTip(day, month) && !isEndTip(day, month) && renderDayBottom && /* @__PURE__ */ React.createElement("div", { className: `${classPrefix2}-day-info-bottom` }, renderDayBottom(day)),
|
|
7102
|
-
!isStartTip(day, month) && !isEndTip(day, month) && !renderDayBottom && showToday && isCurrDay(month, day.day) && /* @__PURE__ */ React.createElement("div", { className: `${classPrefix2}-day-info-curr` }, locale.calendaritem.today),
|
|
7103
|
-
isStartTip(day, month) && /* @__PURE__ */ React.createElement(
|
|
7104
|
-
"div",
|
|
7105
|
-
{
|
|
7106
|
-
className: `${classPrefix2}-day-info ${isStartAndEnd(currentDate) ? `${classPrefix2}-day-info-top` : ""}`
|
|
7107
|
-
},
|
|
7108
|
-
startText || locale.calendaritem.start
|
|
7109
|
-
),
|
|
7110
|
-
isEndTip(day, month) && /* @__PURE__ */ React.createElement("div", { className: `${classPrefix2}-day-info` }, endText || locale.calendaritem.end)
|
|
7111
|
-
))));
|
|
6990
|
+
return renderPanel(month, key);
|
|
7112
6991
|
})
|
|
7113
6992
|
))
|
|
7114
6993
|
);
|
|
@@ -7127,8 +7006,8 @@
|
|
|
7127
7006
|
visible: false,
|
|
7128
7007
|
title: "",
|
|
7129
7008
|
defaultValue: "",
|
|
7130
|
-
startDate:
|
|
7131
|
-
endDate:
|
|
7009
|
+
startDate: getDateString(0),
|
|
7010
|
+
endDate: getDateString(365),
|
|
7132
7011
|
showToday: true,
|
|
7133
7012
|
startText: "",
|
|
7134
7013
|
endText: "",
|
|
@@ -7296,12 +7175,12 @@
|
|
|
7296
7175
|
prevMonth = 12;
|
|
7297
7176
|
prevYear -= 1;
|
|
7298
7177
|
}
|
|
7299
|
-
let days =
|
|
7178
|
+
let days = getMonthPreDay(year, month);
|
|
7300
7179
|
days -= firstDayOfWeek;
|
|
7301
7180
|
if (days >= 7) {
|
|
7302
7181
|
days -= 7;
|
|
7303
7182
|
}
|
|
7304
|
-
const preDates =
|
|
7183
|
+
const preDates = getMonthDays(`${prevYear}`, `${prevMonth}`);
|
|
7305
7184
|
const months = Array.from(Array(preDates), (_, k) => {
|
|
7306
7185
|
return {
|
|
7307
7186
|
type: "prev",
|
|
@@ -7313,7 +7192,7 @@
|
|
|
7313
7192
|
return months.slice(preDates - days);
|
|
7314
7193
|
};
|
|
7315
7194
|
const getCurrentMonthDays = (year, month) => {
|
|
7316
|
-
const days =
|
|
7195
|
+
const days = getMonthDays(`${year}`, `${month}`);
|
|
7317
7196
|
return Array.from(Array(days), (_, k) => {
|
|
7318
7197
|
return {
|
|
7319
7198
|
type: "current",
|
|
@@ -8676,9 +8555,9 @@
|
|
|
8676
8555
|
};
|
|
8677
8556
|
const compareDateChange = (currentDate, newDate, selectedOptions, index) => {
|
|
8678
8557
|
var _a;
|
|
8679
|
-
const
|
|
8558
|
+
const isEqual2 = ((_a = new Date(currentDate)) == null ? void 0 : _a.getTime()) === (newDate == null ? void 0 : newDate.getTime());
|
|
8680
8559
|
if (newDate && isDate(newDate)) {
|
|
8681
|
-
if (!
|
|
8560
|
+
if (!isEqual2) {
|
|
8682
8561
|
setSelectedDate(formatValue(newDate));
|
|
8683
8562
|
}
|
|
8684
8563
|
onChange == null ? void 0 : onChange(
|
|
@@ -8717,6 +8596,14 @@
|
|
|
8717
8596
|
Number(formatDate[2]),
|
|
8718
8597
|
getMonthEndDay(Number(formatDate[0]), Number(formatDate[1]))
|
|
8719
8598
|
);
|
|
8599
|
+
if (selectedOptions.length >= 2 && ["date", "datehour", "datetime", "month-day"].includes(rangeType)) {
|
|
8600
|
+
const dayOption = formatOption("day", day);
|
|
8601
|
+
if (rangeType === "month-day") {
|
|
8602
|
+
selectedOptions[1] = dayOption;
|
|
8603
|
+
} else {
|
|
8604
|
+
selectedOptions[2] = dayOption;
|
|
8605
|
+
}
|
|
8606
|
+
}
|
|
8720
8607
|
let date2 = null;
|
|
8721
8608
|
if (rangeType === "date" || rangeType === "month-day" || rangeType === "year-month") {
|
|
8722
8609
|
date2 = new Date(year, month, day);
|
|
@@ -9630,7 +9517,7 @@
|
|
|
9630
9517
|
pattern: {
|
|
9631
9518
|
mismatch: "%s value %s does not match pattern %s"
|
|
9632
9519
|
},
|
|
9633
|
-
clone: function
|
|
9520
|
+
clone: function clone2() {
|
|
9634
9521
|
var cloned = JSON.parse(JSON.stringify(this));
|
|
9635
9522
|
cloned.clone = this.clone;
|
|
9636
9523
|
return cloned;
|
|
@@ -9894,23 +9781,55 @@
|
|
|
9894
9781
|
Schema.warning = warning;
|
|
9895
9782
|
Schema.messages = messages;
|
|
9896
9783
|
Schema.validators = validators;
|
|
9897
|
-
function merge(...
|
|
9898
|
-
|
|
9899
|
-
|
|
9900
|
-
|
|
9901
|
-
|
|
9902
|
-
|
|
9903
|
-
|
|
9904
|
-
|
|
9905
|
-
|
|
9906
|
-
|
|
9907
|
-
|
|
9908
|
-
|
|
9909
|
-
|
|
9910
|
-
|
|
9784
|
+
function merge(...items) {
|
|
9785
|
+
return _merge(items[0] === true, false, items);
|
|
9786
|
+
}
|
|
9787
|
+
function recursive(...items) {
|
|
9788
|
+
return _merge(items[0] === true, true, items);
|
|
9789
|
+
}
|
|
9790
|
+
function clone(input) {
|
|
9791
|
+
if (Array.isArray(input)) {
|
|
9792
|
+
const output = [];
|
|
9793
|
+
for (let index = 0; index < input.length; ++index)
|
|
9794
|
+
output.push(clone(input[index]));
|
|
9795
|
+
return output;
|
|
9796
|
+
}
|
|
9797
|
+
if (isPlainObject(input)) {
|
|
9798
|
+
const output = {};
|
|
9799
|
+
for (const index in input) output[index] = clone(input[index]);
|
|
9800
|
+
return output;
|
|
9801
|
+
}
|
|
9802
|
+
return input;
|
|
9803
|
+
}
|
|
9804
|
+
function isPlainObject(input) {
|
|
9805
|
+
if (input === null || typeof input !== "object") return false;
|
|
9806
|
+
if (Object.getPrototypeOf(input) === null) return true;
|
|
9807
|
+
let ref = input;
|
|
9808
|
+
while (Object.getPrototypeOf(ref) !== null) ref = Object.getPrototypeOf(ref);
|
|
9809
|
+
return Object.getPrototypeOf(input) === ref;
|
|
9810
|
+
}
|
|
9811
|
+
function _recursiveMerge(base, extend) {
|
|
9812
|
+
if (!isPlainObject(base) || !isPlainObject(extend)) return extend;
|
|
9813
|
+
for (const key in extend) {
|
|
9814
|
+
if (key === "__proto__" || key === "constructor" || key === "prototype")
|
|
9815
|
+
continue;
|
|
9816
|
+
base[key] = isPlainObject(base[key]) && isPlainObject(extend[key]) ? _recursiveMerge(base[key], extend[key]) : extend[key];
|
|
9817
|
+
}
|
|
9818
|
+
return base;
|
|
9819
|
+
}
|
|
9820
|
+
function _merge(isClone, isRecursive, items) {
|
|
9821
|
+
let result;
|
|
9822
|
+
if (isClone || !isPlainObject(result = items.shift())) result = {};
|
|
9823
|
+
for (let index = 0; index < items.length; ++index) {
|
|
9824
|
+
const item = items[index];
|
|
9825
|
+
if (!isPlainObject(item)) continue;
|
|
9826
|
+
for (const key in item) {
|
|
9827
|
+
if (key === "__proto__" || key === "constructor" || key === "prototype")
|
|
9828
|
+
continue;
|
|
9829
|
+
const value = isClone ? clone(item[key]) : item[key];
|
|
9830
|
+
result[key] = isRecursive ? _recursiveMerge(result[key], value) : value;
|
|
9911
9831
|
}
|
|
9912
9832
|
}
|
|
9913
|
-
objects.filter((obj) => !!obj).forEach((obj) => mergeHelper(obj));
|
|
9914
9833
|
return result;
|
|
9915
9834
|
}
|
|
9916
9835
|
const SECRET = "NUT_FORM_INTERNAL";
|
|
@@ -9926,9 +9845,6 @@
|
|
|
9926
9845
|
this.fieldEntities.push(field);
|
|
9927
9846
|
return () => {
|
|
9928
9847
|
this.fieldEntities = this.fieldEntities.filter((item) => item !== field);
|
|
9929
|
-
if (this.store) {
|
|
9930
|
-
delete this.store[field.props.name];
|
|
9931
|
-
}
|
|
9932
9848
|
};
|
|
9933
9849
|
};
|
|
9934
9850
|
this.getFieldValue = (name) => {
|
|
@@ -9950,10 +9866,11 @@
|
|
|
9950
9866
|
if (init) {
|
|
9951
9867
|
const nextStore = merge(initialValues, this.store);
|
|
9952
9868
|
this.updateStore(nextStore);
|
|
9869
|
+
this.notifyWatch();
|
|
9953
9870
|
}
|
|
9954
9871
|
};
|
|
9955
9872
|
this.setFieldsValue = (newStore) => {
|
|
9956
|
-
const nextStore =
|
|
9873
|
+
const nextStore = recursive(true, this.store, newStore);
|
|
9957
9874
|
this.updateStore(nextStore);
|
|
9958
9875
|
this.fieldEntities.forEach((entity) => {
|
|
9959
9876
|
const { name } = entity.props;
|
|
@@ -9972,12 +9889,14 @@
|
|
|
9972
9889
|
item.entity.onStoreChange("update");
|
|
9973
9890
|
}
|
|
9974
9891
|
});
|
|
9892
|
+
this.notifyWatch();
|
|
9975
9893
|
};
|
|
9976
9894
|
this.setFieldValue = (name, value) => {
|
|
9977
9895
|
const store = {
|
|
9978
9896
|
[name]: value
|
|
9979
9897
|
};
|
|
9980
9898
|
this.setFieldsValue(store);
|
|
9899
|
+
this.notifyWatch([name]);
|
|
9981
9900
|
};
|
|
9982
9901
|
this.setCallback = (callback) => {
|
|
9983
9902
|
this.callbacks = {
|
|
@@ -10020,7 +9939,6 @@
|
|
|
10020
9939
|
};
|
|
10021
9940
|
this.validateFields = async (nameList) => {
|
|
10022
9941
|
let filterEntities = [];
|
|
10023
|
-
this.errors.length = 0;
|
|
10024
9942
|
if (!nameList || nameList.length === 0) {
|
|
10025
9943
|
filterEntities = this.fieldEntities;
|
|
10026
9944
|
} else {
|
|
@@ -10045,13 +9963,29 @@
|
|
|
10045
9963
|
(_d = (_c = this.callbacks).onFinishFailed) == null ? void 0 : _d.call(_c, this.store, errors);
|
|
10046
9964
|
}
|
|
10047
9965
|
};
|
|
10048
|
-
this.resetFields = () => {
|
|
10049
|
-
|
|
10050
|
-
|
|
10051
|
-
|
|
10052
|
-
|
|
10053
|
-
|
|
10054
|
-
|
|
9966
|
+
this.resetFields = (namePaths) => {
|
|
9967
|
+
if (namePaths && namePaths.length) {
|
|
9968
|
+
namePaths.forEach((path) => {
|
|
9969
|
+
this.errors[path] = null;
|
|
9970
|
+
this.fieldEntities.forEach((entity) => {
|
|
9971
|
+
const name = entity.props.name;
|
|
9972
|
+
if (name === path) {
|
|
9973
|
+
if (path in this.initialValues) {
|
|
9974
|
+
this.updateStore({ [path]: this.initialValues[path] });
|
|
9975
|
+
} else {
|
|
9976
|
+
delete this.store[path];
|
|
9977
|
+
}
|
|
9978
|
+
entity.onStoreChange("reset");
|
|
9979
|
+
}
|
|
9980
|
+
});
|
|
9981
|
+
});
|
|
9982
|
+
} else {
|
|
9983
|
+
const nextStore = merge({}, this.initialValues);
|
|
9984
|
+
this.updateStore(nextStore);
|
|
9985
|
+
this.fieldEntities.forEach((entity) => {
|
|
9986
|
+
entity.onStoreChange("reset");
|
|
9987
|
+
});
|
|
9988
|
+
}
|
|
10055
9989
|
};
|
|
10056
9990
|
this.registerUpdate = (field, shouldUpdate) => {
|
|
10057
9991
|
this.updateList.push({
|
|
@@ -10074,7 +10008,8 @@
|
|
|
10074
10008
|
dispatch: this.dispatch,
|
|
10075
10009
|
store: this.store,
|
|
10076
10010
|
fieldEntities: this.fieldEntities,
|
|
10077
|
-
registerUpdate: this.registerUpdate
|
|
10011
|
+
registerUpdate: this.registerUpdate,
|
|
10012
|
+
registerWatch: this.registerWatch
|
|
10078
10013
|
};
|
|
10079
10014
|
}
|
|
10080
10015
|
};
|
|
@@ -10091,6 +10026,26 @@
|
|
|
10091
10026
|
getInternal: this.getInternal
|
|
10092
10027
|
};
|
|
10093
10028
|
};
|
|
10029
|
+
this.watchList = [];
|
|
10030
|
+
this.registerWatch = (callback) => {
|
|
10031
|
+
this.watchList.push(callback);
|
|
10032
|
+
return () => {
|
|
10033
|
+
this.watchList = this.watchList.filter((fn) => fn !== callback);
|
|
10034
|
+
};
|
|
10035
|
+
};
|
|
10036
|
+
this.notifyWatch = (namePath = []) => {
|
|
10037
|
+
if (this.watchList.length) {
|
|
10038
|
+
let allValues;
|
|
10039
|
+
if (!namePath || namePath.length === 0) {
|
|
10040
|
+
allValues = this.getFieldsValue(true);
|
|
10041
|
+
} else {
|
|
10042
|
+
allValues = this.getFieldsValue(namePath);
|
|
10043
|
+
}
|
|
10044
|
+
this.watchList.forEach((callback) => {
|
|
10045
|
+
callback(allValues, namePath);
|
|
10046
|
+
});
|
|
10047
|
+
}
|
|
10048
|
+
};
|
|
10094
10049
|
this.callbacks = {
|
|
10095
10050
|
onFinish: () => {
|
|
10096
10051
|
},
|
|
@@ -10114,6 +10069,24 @@
|
|
|
10114
10069
|
}
|
|
10115
10070
|
return [formRef.current];
|
|
10116
10071
|
};
|
|
10072
|
+
const useWatch = (path, form) => {
|
|
10073
|
+
const formInstance = form.getInternal(SECRET);
|
|
10074
|
+
const [value, setValue] = React.useState();
|
|
10075
|
+
React.useEffect(() => {
|
|
10076
|
+
const unsubscribe = formInstance.registerWatch(
|
|
10077
|
+
(data, namePath) => {
|
|
10078
|
+
const value2 = data[path];
|
|
10079
|
+
setValue(value2);
|
|
10080
|
+
}
|
|
10081
|
+
);
|
|
10082
|
+
const initialValue = form.getFieldsValue(true);
|
|
10083
|
+
if (value !== initialValue[path]) {
|
|
10084
|
+
setValue(initialValue[path]);
|
|
10085
|
+
}
|
|
10086
|
+
return () => unsubscribe();
|
|
10087
|
+
}, [form]);
|
|
10088
|
+
return value;
|
|
10089
|
+
};
|
|
10117
10090
|
const defaultProps$Y = {
|
|
10118
10091
|
...ComponentDefaults,
|
|
10119
10092
|
labelPosition: "right",
|
|
@@ -10419,6 +10392,7 @@
|
|
|
10419
10392
|
const InnerForm = Form;
|
|
10420
10393
|
InnerForm.Item = FormItem;
|
|
10421
10394
|
InnerForm.useForm = useForm;
|
|
10395
|
+
InnerForm.useWatch = useWatch;
|
|
10422
10396
|
function trimExtraChar(value, char, regExp) {
|
|
10423
10397
|
const index = value.indexOf(char);
|
|
10424
10398
|
if (index === -1) {
|
|
@@ -13969,7 +13943,7 @@
|
|
|
13969
13943
|
const imageNode = typeof imageUrl === "string" ? /* @__PURE__ */ React.createElement("img", { className: "img", src: imageUrl, alt: "empty" }) : imageUrl;
|
|
13970
13944
|
React.useEffect(() => {
|
|
13971
13945
|
setImgStyle(() => {
|
|
13972
|
-
if (
|
|
13946
|
+
if (typeof imageSize !== "number" && typeof imageSize !== "string") {
|
|
13973
13947
|
return {};
|
|
13974
13948
|
}
|
|
13975
13949
|
if (typeof imageSize === "number") {
|
|
@@ -15701,29 +15675,29 @@
|
|
|
15701
15675
|
onClick: (event) => {
|
|
15702
15676
|
}
|
|
15703
15677
|
};
|
|
15704
|
-
const classPrefix$8 =
|
|
15678
|
+
const classPrefix$8 = "nut-animate";
|
|
15705
15679
|
const Animate = (props) => {
|
|
15706
|
-
const { className, type: type2, action, loop, onClick, children,
|
|
15680
|
+
const { className, type: type2, action, loop, onClick, children, style } = {
|
|
15707
15681
|
...defaultProps$r,
|
|
15708
15682
|
...props
|
|
15709
15683
|
};
|
|
15710
15684
|
const [clicked, setClicked] = React.useState(false);
|
|
15711
|
-
const classes = classNames(
|
|
15712
|
-
|
|
15713
|
-
|
|
15714
|
-
|
|
15715
|
-
|
|
15716
|
-
|
|
15685
|
+
const classes = classNames(
|
|
15686
|
+
{
|
|
15687
|
+
"nut-ani-container": true,
|
|
15688
|
+
[`${classPrefix$8}-${type2}`]: action === "initial" || clicked,
|
|
15689
|
+
loop
|
|
15690
|
+
},
|
|
15691
|
+
className
|
|
15692
|
+
);
|
|
15717
15693
|
const handleClick = (event) => {
|
|
15718
15694
|
setClicked(true);
|
|
15719
15695
|
if (!loop) {
|
|
15720
|
-
setTimeout(() =>
|
|
15721
|
-
setClicked(false);
|
|
15722
|
-
}, 1e3);
|
|
15696
|
+
setTimeout(() => setClicked(false), 1e3);
|
|
15723
15697
|
}
|
|
15724
|
-
onClick
|
|
15698
|
+
onClick(event);
|
|
15725
15699
|
};
|
|
15726
|
-
return /* @__PURE__ */ React.createElement(
|
|
15700
|
+
return /* @__PURE__ */ React.createElement(components.View, { className: "nut-animate" }, /* @__PURE__ */ React.createElement(components.View, { className: classes, onClick: handleClick, style }, children));
|
|
15727
15701
|
};
|
|
15728
15702
|
Animate.displayName = "NutAnimate";
|
|
15729
15703
|
const defaultProps$q = {
|