@nutui/nutui-react 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/Animate/style/style.css +1 -1
- package/dist/esm/Animate.js +6 -9
- package/dist/esm/Calendar/style/style.css +1 -1
- package/dist/esm/Calendar.js +2 -2
- package/dist/esm/CalendarCard.js +4 -4
- package/dist/esm/CalendarItem.js +177 -180
- package/dist/esm/Cascader/style/style.css +1 -1
- package/dist/esm/DatePicker.js +8 -0
- package/dist/esm/Empty.js +1 -1
- package/dist/esm/Form.js +2 -1
- package/dist/esm/TabPane.js +1 -1
- package/dist/esm/Tabs/style/style.css +1 -1
- package/dist/esm/date.js +109 -181
- package/dist/esm/formitem2.js +121 -31
- package/dist/esm/tabs2.js +26 -42
- 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 +477 -517
- package/dist/nutui.react.umd.js +477 -517
- 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/nutui.react.es.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @nutui/nutui-react v2.7.
|
|
2
|
+
* @nutui/nutui-react v2.7.8 Fri Feb 14 2025 16:19:28 GMT+0800 (China Standard Time)
|
|
3
3
|
* (c) 2023 @jdf2e.
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
@@ -3153,7 +3153,7 @@ const getRect = (elementRef) => {
|
|
|
3153
3153
|
height: 0
|
|
3154
3154
|
};
|
|
3155
3155
|
};
|
|
3156
|
-
function useWatch(dep, callback, config2 = { immediate: false }) {
|
|
3156
|
+
function useWatch$1(dep, callback, config2 = { immediate: false }) {
|
|
3157
3157
|
const { immediate } = config2;
|
|
3158
3158
|
const prev = useRef();
|
|
3159
3159
|
const inited = useRef(false);
|
|
@@ -3283,7 +3283,7 @@ const Sticky = (props) => {
|
|
|
3283
3283
|
});
|
|
3284
3284
|
setIsFixed(fixed.fixed);
|
|
3285
3285
|
}, [position, threshold, container]);
|
|
3286
|
-
useWatch(isFixed, () => {
|
|
3286
|
+
useWatch$1(isFixed, () => {
|
|
3287
3287
|
onChange && onChange(isFixed);
|
|
3288
3288
|
});
|
|
3289
3289
|
useEffect(() => {
|
|
@@ -5290,7 +5290,7 @@ const is = {
|
|
|
5290
5290
|
num: (a) => typeof a === "number",
|
|
5291
5291
|
und: (a) => a === void 0
|
|
5292
5292
|
};
|
|
5293
|
-
function isEqual(a, b) {
|
|
5293
|
+
function isEqual$1(a, b) {
|
|
5294
5294
|
if (is.arr(a)) {
|
|
5295
5295
|
if (!is.arr(b) || a.length !== b.length) return false;
|
|
5296
5296
|
for (let i2 = 0; i2 < a.length; i2++) {
|
|
@@ -7154,12 +7154,12 @@ class SpringValue extends FrameValue {
|
|
|
7154
7154
|
to2 = from;
|
|
7155
7155
|
}
|
|
7156
7156
|
if (props.reverse) [to2, from] = [from, to2];
|
|
7157
|
-
const hasFromChanged = !isEqual(from, prevFrom);
|
|
7157
|
+
const hasFromChanged = !isEqual$1(from, prevFrom);
|
|
7158
7158
|
if (hasFromChanged) {
|
|
7159
7159
|
anim.from = from;
|
|
7160
7160
|
}
|
|
7161
7161
|
from = getFluidValue(from);
|
|
7162
|
-
const hasToChanged = !isEqual(to2, prevTo);
|
|
7162
|
+
const hasToChanged = !isEqual$1(to2, prevTo);
|
|
7163
7163
|
if (hasToChanged) {
|
|
7164
7164
|
this._focus(to2);
|
|
7165
7165
|
}
|
|
@@ -7200,10 +7200,10 @@ class SpringValue extends FrameValue {
|
|
|
7200
7200
|
if (!started) {
|
|
7201
7201
|
const hasValueChanged = reset || !hasAnimated(this) && hasFromChanged;
|
|
7202
7202
|
if (hasToChanged || hasValueChanged) {
|
|
7203
|
-
finished = isEqual(computeGoal(value), goal);
|
|
7203
|
+
finished = isEqual$1(computeGoal(value), goal);
|
|
7204
7204
|
started = !finished;
|
|
7205
7205
|
}
|
|
7206
|
-
if (!isEqual(anim.immediate, immediate) && !immediate || !isEqual(config2.decay, decay) || !isEqual(config2.velocity, velocity)) {
|
|
7206
|
+
if (!isEqual$1(anim.immediate, immediate) && !immediate || !isEqual$1(config2.decay, decay) || !isEqual$1(config2.velocity, velocity)) {
|
|
7207
7207
|
started = true;
|
|
7208
7208
|
}
|
|
7209
7209
|
}
|
|
@@ -7294,7 +7294,7 @@ class SpringValue extends FrameValue {
|
|
|
7294
7294
|
const value = getFluidValue(arg);
|
|
7295
7295
|
if (!is.und(value)) {
|
|
7296
7296
|
const oldNode = getAnimated(this);
|
|
7297
|
-
if (!oldNode || !isEqual(value, oldNode.getValue())) {
|
|
7297
|
+
if (!oldNode || !isEqual$1(value, oldNode.getValue())) {
|
|
7298
7298
|
const nodeType = getAnimatedType(value);
|
|
7299
7299
|
if (!oldNode || oldNode.constructor != nodeType) {
|
|
7300
7300
|
setAnimated(this, nodeType.create(value));
|
|
@@ -7371,7 +7371,7 @@ class SpringValue extends FrameValue {
|
|
|
7371
7371
|
function checkFinished(target, to2) {
|
|
7372
7372
|
const goal = computeGoal(to2);
|
|
7373
7373
|
const value = computeGoal(target.get());
|
|
7374
|
-
return isEqual(value, goal);
|
|
7374
|
+
return isEqual$1(value, goal);
|
|
7375
7375
|
}
|
|
7376
7376
|
function createLoopUpdate(props, loop2 = props.loop, to2 = props.to) {
|
|
7377
7377
|
let loopRet = callProp(loop2);
|
|
@@ -7945,7 +7945,7 @@ class Interpolation extends FrameValue {
|
|
|
7945
7945
|
advance(_dt) {
|
|
7946
7946
|
const value = this._get();
|
|
7947
7947
|
const oldValue = this.get();
|
|
7948
|
-
if (!isEqual(value, oldValue)) {
|
|
7948
|
+
if (!isEqual$1(value, oldValue)) {
|
|
7949
7949
|
getAnimated(this).setValue(value);
|
|
7950
7950
|
this._onChange(value, this.idle);
|
|
7951
7951
|
}
|
|
@@ -9204,7 +9204,7 @@ const TabPane = (props) => {
|
|
|
9204
9204
|
autoHeightClassName,
|
|
9205
9205
|
className
|
|
9206
9206
|
);
|
|
9207
|
-
return children
|
|
9207
|
+
return children && /* @__PURE__ */ React__default.createElement("div", { className: classes }, !disabled && children);
|
|
9208
9208
|
};
|
|
9209
9209
|
const defaultProps$17 = {
|
|
9210
9210
|
...ComponentDefaults,
|
|
@@ -9234,39 +9234,30 @@ const Tabs = (props) => {
|
|
|
9234
9234
|
value: outerValue,
|
|
9235
9235
|
defaultValue: outerDefaultValue,
|
|
9236
9236
|
...rest
|
|
9237
|
-
} = {
|
|
9238
|
-
...defaultProps$17,
|
|
9239
|
-
...props
|
|
9240
|
-
};
|
|
9237
|
+
} = { ...defaultProps$17, ...props };
|
|
9241
9238
|
const [value, setValue] = usePropsValue({
|
|
9242
9239
|
value: outerValue,
|
|
9243
9240
|
defaultValue: outerDefaultValue,
|
|
9244
|
-
finalValue: 0,
|
|
9245
9241
|
onChange
|
|
9246
9242
|
});
|
|
9247
9243
|
const titleItemsRef = useRef([]);
|
|
9248
9244
|
const navRef = useRef(null);
|
|
9249
|
-
const scrollDirection = (nav, to2, duration2
|
|
9250
|
-
|
|
9251
|
-
const from = direction2 === "horizontal" ? nav.scrollLeft : nav.scrollTop;
|
|
9245
|
+
const scrollDirection = (nav, to2, duration2) => {
|
|
9246
|
+
const from = direction === "horizontal" ? nav.scrollLeft : nav.scrollTop;
|
|
9252
9247
|
const frames = Math.round(duration2 * 1e3 / 16);
|
|
9253
|
-
|
|
9254
|
-
|
|
9255
|
-
|
|
9256
|
-
|
|
9257
|
-
|
|
9258
|
-
|
|
9259
|
-
if (++count < frames) {
|
|
9260
|
-
requestAniFrame$1(animate);
|
|
9261
|
-
}
|
|
9262
|
-
}
|
|
9248
|
+
let count = 0;
|
|
9249
|
+
const animate = () => {
|
|
9250
|
+
if (direction === "horizontal") nav.scrollLeft += (to2 - from) / frames;
|
|
9251
|
+
else nav.scrollTop += (to2 - from) / frames;
|
|
9252
|
+
if (++count < frames) requestAniFrame$1(animate);
|
|
9253
|
+
};
|
|
9263
9254
|
animate();
|
|
9264
9255
|
};
|
|
9265
9256
|
const scrollIntoView = (index, immediate) => {
|
|
9266
9257
|
const nav = navRef.current;
|
|
9267
9258
|
const titleItem = titleItemsRef.current;
|
|
9268
9259
|
const titlesLength = titles.current.length;
|
|
9269
|
-
const itemLength =
|
|
9260
|
+
const itemLength = titleItem.length;
|
|
9270
9261
|
if (!nav || !titleItem || !titleItem[itemLength - titlesLength + index]) {
|
|
9271
9262
|
return;
|
|
9272
9263
|
}
|
|
@@ -9278,13 +9269,13 @@ const Tabs = (props) => {
|
|
|
9278
9269
|
} else {
|
|
9279
9270
|
to2 = title2.offsetLeft - (nav.offsetWidth - title2.offsetWidth) / 2;
|
|
9280
9271
|
}
|
|
9281
|
-
scrollDirection(nav, to2, 0.3
|
|
9272
|
+
scrollDirection(nav, to2, 0.3);
|
|
9282
9273
|
};
|
|
9283
9274
|
const getTitles = () => {
|
|
9284
9275
|
const titles2 = [];
|
|
9285
9276
|
React__default.Children.forEach(children, (child, idx) => {
|
|
9286
9277
|
if (React__default.isValidElement(child)) {
|
|
9287
|
-
const
|
|
9278
|
+
const { props: props2 } = child;
|
|
9288
9279
|
if ((props2 == null ? void 0 : props2.title) || (props2 == null ? void 0 : props2.value)) {
|
|
9289
9280
|
titles2.push({
|
|
9290
9281
|
title: props2.title,
|
|
@@ -9319,23 +9310,18 @@ const Tabs = (props) => {
|
|
|
9319
9310
|
);
|
|
9320
9311
|
const classesTitle = classNames(`${classPrefix$j}-titles`, {
|
|
9321
9312
|
[`${classPrefix$j}-titles-${activeType}`]: activeType,
|
|
9322
|
-
[`${classPrefix$j}-titles-scrollable`]: true,
|
|
9323
9313
|
[`${classPrefix$j}-titles-${align}`]: align
|
|
9324
9314
|
});
|
|
9325
|
-
const tabsActiveStyle = {
|
|
9326
|
-
color: activeType === "smile" ? activeColor : "",
|
|
9327
|
-
background: activeType === "line" ? activeColor : ""
|
|
9328
|
-
};
|
|
9329
9315
|
const getContentStyle = () => {
|
|
9330
|
-
let index = titles.current.findIndex((t) => t.value
|
|
9316
|
+
let index = titles.current.findIndex((t) => t.value === value);
|
|
9331
9317
|
index = index < 0 ? 0 : index;
|
|
9332
9318
|
return {
|
|
9333
|
-
transform: direction === "horizontal" ? `translate3d(${rtl ? "" : "-"}${index * 100}%, 0, 0)` : `translate3d( 0
|
|
9319
|
+
transform: direction === "horizontal" ? `translate3d(${rtl ? "" : "-"}${index * 100}%, 0, 0)` : `translate3d( 0, -${index * 100}%, 0)`,
|
|
9334
9320
|
transitionDuration: `${duration}ms`
|
|
9335
9321
|
};
|
|
9336
9322
|
};
|
|
9337
9323
|
useEffect(() => {
|
|
9338
|
-
let index = titles.current.findIndex((t) => t.value
|
|
9324
|
+
let index = titles.current.findIndex((t) => t.value === value);
|
|
9339
9325
|
index = index < 0 ? 0 : index;
|
|
9340
9326
|
setTimeout(() => {
|
|
9341
9327
|
scrollIntoView(index);
|
|
@@ -9343,69 +9329,55 @@ const Tabs = (props) => {
|
|
|
9343
9329
|
}, [value]);
|
|
9344
9330
|
const tabChange = (item) => {
|
|
9345
9331
|
onClick && onClick(item.value);
|
|
9346
|
-
if (item.disabled) {
|
|
9347
|
-
|
|
9332
|
+
if (!item.disabled) {
|
|
9333
|
+
setValue(item.value);
|
|
9348
9334
|
}
|
|
9349
|
-
setValue(item.value);
|
|
9350
9335
|
};
|
|
9351
|
-
return /* @__PURE__ */ React__default.createElement("div", { className: classes, ...rest }, /* @__PURE__ */ React__default.createElement("div", { className: classesTitle, style:
|
|
9336
|
+
return /* @__PURE__ */ React__default.createElement("div", { className: classes, ...rest }, /* @__PURE__ */ React__default.createElement("div", { className: classesTitle, style: tabStyle, ref: navRef }, !!title && typeof title === "function" ? title() : titles.current.map((item) => {
|
|
9352
9337
|
return /* @__PURE__ */ React__default.createElement(
|
|
9353
9338
|
"div",
|
|
9354
9339
|
{
|
|
9355
|
-
|
|
9356
|
-
|
|
9357
|
-
|
|
9340
|
+
key: item.value,
|
|
9341
|
+
ref: (ref) => titleItemsRef.current.push(ref),
|
|
9342
|
+
onClick: () => tabChange(item),
|
|
9358
9343
|
className: classNames(`${classPrefix$j}-titles-item`, {
|
|
9359
9344
|
[`nut-tabs-titles-item-active`]: !item.disabled && String(item.value) === String(value),
|
|
9360
9345
|
[`nut-tabs-titles-item-disabled`]: item.disabled,
|
|
9361
9346
|
[`nut-tabs-titles-item-${align}`]: align
|
|
9362
|
-
})
|
|
9363
|
-
ref: (ref) => titleItemsRef.current.push(ref),
|
|
9364
|
-
key: item.value
|
|
9347
|
+
})
|
|
9365
9348
|
},
|
|
9366
9349
|
activeType === "line" && /* @__PURE__ */ React__default.createElement(
|
|
9367
9350
|
"div",
|
|
9368
9351
|
{
|
|
9369
|
-
className: classNames(
|
|
9370
|
-
|
|
9371
|
-
|
|
9372
|
-
|
|
9352
|
+
className: classNames(
|
|
9353
|
+
`${classPrefix$j}-titles-item-line`,
|
|
9354
|
+
`${classPrefix$j}-titles-item-line-${direction}`
|
|
9355
|
+
),
|
|
9356
|
+
style: { background: activeColor }
|
|
9373
9357
|
}
|
|
9374
9358
|
),
|
|
9375
|
-
activeType === "smile" && /* @__PURE__ */ React__default.createElement(
|
|
9376
|
-
"div",
|
|
9377
|
-
{
|
|
9378
|
-
className: `${classPrefix$j}-titles-item-smile`,
|
|
9379
|
-
style: tabsActiveStyle
|
|
9380
|
-
},
|
|
9381
|
-
/* @__PURE__ */ React__default.createElement(c$3, { color: activeColor, width: 40, height: 20 })
|
|
9382
|
-
),
|
|
9359
|
+
activeType === "smile" && /* @__PURE__ */ React__default.createElement("div", { className: `${classPrefix$j}-titles-item-smile` }, /* @__PURE__ */ React__default.createElement(c$3, { color: activeColor, width: 40, height: 20 })),
|
|
9383
9360
|
/* @__PURE__ */ React__default.createElement(
|
|
9384
9361
|
"div",
|
|
9385
9362
|
{
|
|
9386
9363
|
className: classNames(
|
|
9387
|
-
|
|
9364
|
+
{
|
|
9365
|
+
[`${classPrefix$j}-ellipsis`]: direction === "vertical"
|
|
9366
|
+
},
|
|
9388
9367
|
`${classPrefix$j}-titles-item-text`
|
|
9389
|
-
)
|
|
9368
|
+
),
|
|
9369
|
+
style: { color: activeColor }
|
|
9390
9370
|
},
|
|
9391
9371
|
item.title
|
|
9392
9372
|
)
|
|
9393
9373
|
);
|
|
9394
9374
|
})), /* @__PURE__ */ React__default.createElement("div", { className: `${classPrefix$j}-content-wrap` }, /* @__PURE__ */ React__default.createElement("div", { className: `${classPrefix$j}-content`, style: getContentStyle() }, React__default.Children.map(children, (child, idx) => {
|
|
9395
|
-
if (!React__default.isValidElement(child))
|
|
9396
|
-
|
|
9397
|
-
}
|
|
9398
|
-
let childProps = {
|
|
9375
|
+
if (!React__default.isValidElement(child)) return null;
|
|
9376
|
+
return React__default.cloneElement(child, {
|
|
9399
9377
|
...child.props,
|
|
9400
|
-
active: value === child.props.value
|
|
9401
|
-
|
|
9402
|
-
|
|
9403
|
-
childProps = {
|
|
9404
|
-
...childProps,
|
|
9405
|
-
autoHeightClassName: "inactive"
|
|
9406
|
-
};
|
|
9407
|
-
}
|
|
9408
|
-
return React__default.cloneElement(child, childProps);
|
|
9378
|
+
active: value === child.props.value,
|
|
9379
|
+
autoHeightClassName: autoHeight && String(value) !== String(child.props.value || idx) ? "inactive" : void 0
|
|
9380
|
+
});
|
|
9409
9381
|
}))));
|
|
9410
9382
|
};
|
|
9411
9383
|
Tabs.displayName = "NutTabs";
|
|
@@ -10134,189 +10106,106 @@ const InternalAddress = (props, ref) => {
|
|
|
10134
10106
|
};
|
|
10135
10107
|
const Address = forwardRef(InternalAddress);
|
|
10136
10108
|
Address.displayName = "NutAddress";
|
|
10137
|
-
const
|
|
10138
|
-
|
|
10139
|
-
|
|
10140
|
-
|
|
10141
|
-
|
|
10142
|
-
|
|
10143
|
-
|
|
10144
|
-
|
|
10145
|
-
|
|
10146
|
-
|
|
10147
|
-
|
|
10148
|
-
|
|
10149
|
-
|
|
10150
|
-
|
|
10151
|
-
|
|
10152
|
-
|
|
10153
|
-
|
|
10154
|
-
|
|
10155
|
-
|
|
10156
|
-
|
|
10157
|
-
|
|
10158
|
-
|
|
10159
|
-
|
|
10160
|
-
];
|
|
10161
|
-
return dayNames[index];
|
|
10162
|
-
},
|
|
10163
|
-
/**
|
|
10164
|
-
* 返回上一个月在当前面板中的天数
|
|
10165
|
-
* @return {Number}
|
|
10166
|
-
*/
|
|
10167
|
-
getMonthPreDay(year, month) {
|
|
10168
|
-
const date4 = /* @__PURE__ */ new Date(`${year}/${month}/01`);
|
|
10169
|
-
let day = date4.getDay();
|
|
10170
|
-
if (day === 0) {
|
|
10171
|
-
day = 7;
|
|
10172
|
-
}
|
|
10173
|
-
return day;
|
|
10174
|
-
},
|
|
10175
|
-
/**
|
|
10176
|
-
* 返回月份天数
|
|
10177
|
-
* @return {Number}
|
|
10178
|
-
*/
|
|
10179
|
-
getMonthDays(year, month) {
|
|
10180
|
-
if (/^0/.test(month)) {
|
|
10181
|
-
month = month.split("")[1];
|
|
10182
|
-
}
|
|
10183
|
-
return [
|
|
10184
|
-
0,
|
|
10185
|
-
31,
|
|
10186
|
-
this.isLeapYear(Number(year)) ? 29 : 28,
|
|
10187
|
-
31,
|
|
10188
|
-
30,
|
|
10189
|
-
31,
|
|
10190
|
-
30,
|
|
10191
|
-
31,
|
|
10192
|
-
31,
|
|
10193
|
-
30,
|
|
10194
|
-
31,
|
|
10195
|
-
30,
|
|
10196
|
-
31
|
|
10197
|
-
][month];
|
|
10198
|
-
},
|
|
10199
|
-
/**
|
|
10200
|
-
* 补齐数字位数
|
|
10201
|
-
* @return {string}
|
|
10202
|
-
*/
|
|
10203
|
-
getNumTwoBit(n2) {
|
|
10204
|
-
n2 = Number(n2);
|
|
10205
|
-
return (n2 > 9 ? "" : "0") + n2;
|
|
10206
|
-
},
|
|
10207
|
-
/**
|
|
10208
|
-
* 日期对象转成字符串
|
|
10209
|
-
* @return {string}
|
|
10210
|
-
*/
|
|
10211
|
-
date2Str(date4, split) {
|
|
10212
|
-
split = split || "-";
|
|
10213
|
-
const y = date4.getFullYear();
|
|
10214
|
-
const m2 = this.getNumTwoBit(date4.getMonth() + 1);
|
|
10215
|
-
const d2 = this.getNumTwoBit(date4.getDate());
|
|
10216
|
-
return [y, m2, d2].join(split);
|
|
10217
|
-
},
|
|
10218
|
-
/**
|
|
10219
|
-
* 返回日期格式字符串
|
|
10220
|
-
* @param {Number} 0返回今天的日期、1返回明天的日期,2返回后天得日期,依次类推
|
|
10221
|
-
* @return {string} '2014-12-31'
|
|
10222
|
-
*/
|
|
10223
|
-
getDay(i2) {
|
|
10224
|
-
i2 = i2 || 0;
|
|
10225
|
-
let date4 = /* @__PURE__ */ new Date();
|
|
10226
|
-
const diff = i2 * (1e3 * 60 * 60 * 24);
|
|
10227
|
-
date4 = new Date(date4.getTime() + diff);
|
|
10228
|
-
return this.date2Str(date4);
|
|
10229
|
-
},
|
|
10230
|
-
/**
|
|
10231
|
-
* 时间比较
|
|
10232
|
-
* @return {Boolean}
|
|
10233
|
-
*/
|
|
10234
|
-
compareDate(date1, date22) {
|
|
10235
|
-
const startTime = new Date(date1.replace("-", "/").replace("-", "/"));
|
|
10236
|
-
const endTime = new Date(date22.replace("-", "/").replace("-", "/"));
|
|
10237
|
-
if (startTime >= endTime) {
|
|
10238
|
-
return false;
|
|
10239
|
-
}
|
|
10240
|
-
return true;
|
|
10241
|
-
},
|
|
10242
|
-
/**
|
|
10243
|
-
* 时间是否相等
|
|
10244
|
-
* @return {Boolean}
|
|
10245
|
-
*/
|
|
10246
|
-
isEqual(date1, date22) {
|
|
10247
|
-
const startTime = new Date((date1 || "").replace(/-/g, "/")).getTime();
|
|
10248
|
-
const endTime = new Date(date22.replace(/-/g, "/")).getTime();
|
|
10249
|
-
if (startTime === endTime) {
|
|
10250
|
-
return true;
|
|
10251
|
-
}
|
|
10252
|
-
return false;
|
|
10253
|
-
},
|
|
10254
|
-
getMonthWeek(year, month, date4, firstDayOfWeek = 0) {
|
|
10255
|
-
const dateNow = new Date(Number(year), parseInt(month) - 1, Number(date4));
|
|
10256
|
-
let w = dateNow.getDay();
|
|
10257
|
-
const d2 = dateNow.getDate();
|
|
10258
|
-
let remainder = 6 - w;
|
|
10259
|
-
if (firstDayOfWeek !== 0) {
|
|
10260
|
-
w = w === 0 ? 7 : w;
|
|
10261
|
-
remainder = 7 - w;
|
|
10262
|
-
}
|
|
10263
|
-
return Math.ceil((d2 + remainder) / 7);
|
|
10264
|
-
},
|
|
10265
|
-
getYearWeek(year, month, date4, firstDayOfWeek = 0) {
|
|
10266
|
-
const dateNow = new Date(Number(year), parseInt(month) - 1, Number(date4));
|
|
10267
|
-
const dateFirst = new Date(Number(year), 0, 1);
|
|
10268
|
-
const dataNumber = Math.round(
|
|
10269
|
-
(dateNow.valueOf() - dateFirst.valueOf()) / 864e5
|
|
10270
|
-
);
|
|
10271
|
-
return Math.ceil((dataNumber + (dateFirst.getDay() + 1 - 1)) / 7);
|
|
10272
|
-
},
|
|
10273
|
-
getWeekDate(year, month, date4, firstDayOfWeek = 0) {
|
|
10274
|
-
const dateNow = new Date(Number(year), parseInt(month) - 1, Number(date4));
|
|
10275
|
-
const nowTime = dateNow.getTime();
|
|
10276
|
-
let day = dateNow.getDay();
|
|
10277
|
-
if (firstDayOfWeek === 0) {
|
|
10278
|
-
const oneDayTime2 = 24 * 60 * 60 * 1e3;
|
|
10279
|
-
const SundayTime2 = nowTime - day * oneDayTime2;
|
|
10280
|
-
const SaturdayTime = nowTime + (6 - day) * oneDayTime2;
|
|
10281
|
-
const sunday2 = this.date2Str(new Date(SundayTime2));
|
|
10282
|
-
const saturday = this.date2Str(new Date(SaturdayTime));
|
|
10283
|
-
return [sunday2, saturday];
|
|
10284
|
-
}
|
|
10285
|
-
day = day === 0 ? 7 : day;
|
|
10286
|
-
const oneDayTime = 24 * 60 * 60 * 1e3;
|
|
10287
|
-
const MondayTime = nowTime - (day - 1) * oneDayTime;
|
|
10288
|
-
const SundayTime = nowTime + (7 - day) * oneDayTime;
|
|
10289
|
-
const monday = this.date2Str(new Date(MondayTime));
|
|
10290
|
-
const sunday = this.date2Str(new Date(SundayTime));
|
|
10291
|
-
return [monday, sunday];
|
|
10292
|
-
},
|
|
10293
|
-
formatResultDate(date4) {
|
|
10294
|
-
const days = [...date4.split("-")];
|
|
10295
|
-
days[2] = Utils.getNumTwoBit(Number(days[2]));
|
|
10296
|
-
days[3] = `${days[0]}-${days[1]}-${days[2]}`;
|
|
10297
|
-
days[4] = Utils.getWhatDay(+days[0], +days[1], +days[2]);
|
|
10298
|
-
return days;
|
|
10109
|
+
const isLeapYear = (y) => {
|
|
10110
|
+
return y % 4 === 0 && y % 100 !== 0 || y % 400 === 0;
|
|
10111
|
+
};
|
|
10112
|
+
const getWhatDay = (year, month, day) => {
|
|
10113
|
+
const date4 = new Date(year, month - 1, day);
|
|
10114
|
+
const dayNames = [
|
|
10115
|
+
"星期日",
|
|
10116
|
+
"星期一",
|
|
10117
|
+
"星期二",
|
|
10118
|
+
"星期三",
|
|
10119
|
+
"星期四",
|
|
10120
|
+
"星期五",
|
|
10121
|
+
"星期六"
|
|
10122
|
+
];
|
|
10123
|
+
return dayNames[date4.getDay()];
|
|
10124
|
+
};
|
|
10125
|
+
const getMonthPreDay = (year, month) => {
|
|
10126
|
+
const day = new Date(year, month - 1, 1).getDay();
|
|
10127
|
+
return day === 0 ? 7 : day;
|
|
10128
|
+
};
|
|
10129
|
+
const getMonthDays = (year, month) => {
|
|
10130
|
+
if (/^0/.test(month)) {
|
|
10131
|
+
month = month.split("")[1];
|
|
10299
10132
|
}
|
|
10133
|
+
return [
|
|
10134
|
+
0,
|
|
10135
|
+
31,
|
|
10136
|
+
isLeapYear(Number(year)) ? 29 : 28,
|
|
10137
|
+
31,
|
|
10138
|
+
30,
|
|
10139
|
+
31,
|
|
10140
|
+
30,
|
|
10141
|
+
31,
|
|
10142
|
+
31,
|
|
10143
|
+
30,
|
|
10144
|
+
31,
|
|
10145
|
+
30,
|
|
10146
|
+
31
|
|
10147
|
+
][month];
|
|
10148
|
+
};
|
|
10149
|
+
const getNumTwoBit = (n2) => {
|
|
10150
|
+
return n2 > 9 ? `${n2}` : `0${n2}`;
|
|
10151
|
+
};
|
|
10152
|
+
const date2Str = (date4, split = "-") => {
|
|
10153
|
+
const y = date4.getFullYear();
|
|
10154
|
+
const m2 = getNumTwoBit(date4.getMonth() + 1);
|
|
10155
|
+
const d2 = getNumTwoBit(date4.getDate());
|
|
10156
|
+
return [y, m2, d2].join(split);
|
|
10157
|
+
};
|
|
10158
|
+
const getDateString = (offset = 0) => {
|
|
10159
|
+
const date4 = /* @__PURE__ */ new Date();
|
|
10160
|
+
date4.setDate(date4.getDate() + offset);
|
|
10161
|
+
return date2Str(date4, "-");
|
|
10162
|
+
};
|
|
10163
|
+
const compareDate = (date1, date22) => {
|
|
10164
|
+
const startTime = new Date(date1.replace("-", "/").replace("-", "/"));
|
|
10165
|
+
const endTime = new Date(date22.replace("-", "/").replace("-", "/"));
|
|
10166
|
+
return startTime < endTime;
|
|
10167
|
+
};
|
|
10168
|
+
const isEqual = (date1, date22) => {
|
|
10169
|
+
const startTime = new Date((date1 || "").replace(/-/g, "/")).getTime();
|
|
10170
|
+
const endTime = new Date(date22.replace(/-/g, "/")).getTime();
|
|
10171
|
+
return startTime === endTime;
|
|
10172
|
+
};
|
|
10173
|
+
const getWeekDate = (year, month, date4, firstDayOfWeek = 0) => {
|
|
10174
|
+
const dateNow = new Date(Number(year), parseInt(month) - 1, Number(date4));
|
|
10175
|
+
const nowTime = dateNow.getTime();
|
|
10176
|
+
let day = dateNow.getDay();
|
|
10177
|
+
if (firstDayOfWeek === 0) {
|
|
10178
|
+
const oneDayTime2 = 24 * 60 * 60 * 1e3;
|
|
10179
|
+
const SundayTime2 = nowTime - day * oneDayTime2;
|
|
10180
|
+
const SaturdayTime = nowTime + (6 - day) * oneDayTime2;
|
|
10181
|
+
const sunday2 = date2Str(new Date(SundayTime2));
|
|
10182
|
+
const saturday = date2Str(new Date(SaturdayTime));
|
|
10183
|
+
return [sunday2, saturday];
|
|
10184
|
+
}
|
|
10185
|
+
day = day === 0 ? 7 : day;
|
|
10186
|
+
const oneDayTime = 24 * 60 * 60 * 1e3;
|
|
10187
|
+
const MondayTime = nowTime - (day - 1) * oneDayTime;
|
|
10188
|
+
const SundayTime = nowTime + (7 - day) * oneDayTime;
|
|
10189
|
+
const monday = date2Str(new Date(MondayTime));
|
|
10190
|
+
const sunday = date2Str(new Date(SundayTime));
|
|
10191
|
+
return [monday, sunday];
|
|
10192
|
+
};
|
|
10193
|
+
const formatResultDate = (date4) => {
|
|
10194
|
+
const [year, month, day] = [...date4.split("-")];
|
|
10195
|
+
const formatterDay = getNumTwoBit(Number(day));
|
|
10196
|
+
const formatterDate = `${year}-${month}-${day}`;
|
|
10197
|
+
const dayOfWeek = getWhatDay(Number(year), Number(month), Number(day));
|
|
10198
|
+
return [year, month, formatterDay, formatterDate, dayOfWeek];
|
|
10300
10199
|
};
|
|
10301
10200
|
const getCurrMonthData = (type4, year, month) => {
|
|
10302
|
-
|
|
10303
|
-
|
|
10304
|
-
|
|
10305
|
-
month = month === 1 ? 12 : --month;
|
|
10306
|
-
break;
|
|
10307
|
-
case "next":
|
|
10308
|
-
month === 12 && (year += 1);
|
|
10309
|
-
month = month === 12 ? 1 : ++month;
|
|
10310
|
-
break;
|
|
10201
|
+
{
|
|
10202
|
+
month === 12 && (year += 1);
|
|
10203
|
+
month = month === 12 ? 1 : ++month;
|
|
10311
10204
|
}
|
|
10312
|
-
return [
|
|
10313
|
-
year,
|
|
10314
|
-
Utils.getNumTwoBit(month),
|
|
10315
|
-
Utils.getMonthDays(String(year), String(month))
|
|
10316
|
-
];
|
|
10205
|
+
return [year, getNumTwoBit(month), getMonthDays(String(year), String(month))];
|
|
10317
10206
|
};
|
|
10318
10207
|
const getDaysStatus = (type4, year, month) => {
|
|
10319
|
-
let days =
|
|
10208
|
+
let days = getMonthDays(`${year}`, `${month}`);
|
|
10320
10209
|
return Array.from(Array(days), (v, k) => {
|
|
10321
10210
|
return {
|
|
10322
10211
|
day: k + 1,
|
|
@@ -10333,12 +10222,12 @@ const getPreMonthDates = (type4, year, month, firstDayOfWeek) => {
|
|
|
10333
10222
|
preMonth = 12;
|
|
10334
10223
|
preYear += 1;
|
|
10335
10224
|
}
|
|
10336
|
-
let days =
|
|
10225
|
+
let days = getMonthPreDay(+year, +month);
|
|
10337
10226
|
days -= firstDayOfWeek;
|
|
10338
10227
|
if (days >= 7) {
|
|
10339
10228
|
days -= 7;
|
|
10340
10229
|
}
|
|
10341
|
-
const preDates =
|
|
10230
|
+
const preDates = getMonthDays(`${preYear}`, `${preMonth}`);
|
|
10342
10231
|
const months = Array.from(Array(preDates), (v, k) => {
|
|
10343
10232
|
return {
|
|
10344
10233
|
day: k + 1,
|
|
@@ -10356,28 +10245,26 @@ const splitDate = (date4) => {
|
|
|
10356
10245
|
const isMultiple = (day, days) => {
|
|
10357
10246
|
if (days.length > 0) {
|
|
10358
10247
|
return days.some((item) => {
|
|
10359
|
-
return
|
|
10248
|
+
return isEqual(item, day);
|
|
10360
10249
|
});
|
|
10361
10250
|
}
|
|
10362
10251
|
return false;
|
|
10363
10252
|
};
|
|
10364
10253
|
const isCurrDay = (month, day) => {
|
|
10365
10254
|
const date4 = `${month.curData[0]}/${month.curData[1]}/${day}`;
|
|
10366
|
-
return
|
|
10255
|
+
return isEqual(date4, date2Str(/* @__PURE__ */ new Date(), "/"));
|
|
10367
10256
|
};
|
|
10368
10257
|
const getCurrDate = (day, month) => {
|
|
10369
|
-
return `${month.curData[0]}/${month.curData[1]}/${
|
|
10370
|
-
+day.day
|
|
10371
|
-
)}`;
|
|
10258
|
+
return `${month.curData[0]}/${month.curData[1]}/${getNumTwoBit(+day.day)}`;
|
|
10372
10259
|
};
|
|
10373
10260
|
const isStart = (day, days) => {
|
|
10374
|
-
return
|
|
10261
|
+
return isEqual(days[0], day);
|
|
10375
10262
|
};
|
|
10376
10263
|
const isEnd = (day, days) => {
|
|
10377
|
-
return
|
|
10264
|
+
return isEqual(days[1], day);
|
|
10378
10265
|
};
|
|
10379
10266
|
const isStartAndEnd = (days) => {
|
|
10380
|
-
return days.length >= 2 &&
|
|
10267
|
+
return days.length >= 2 && isEqual(days[0], days[1]);
|
|
10381
10268
|
};
|
|
10382
10269
|
const defaultProps$12 = {
|
|
10383
10270
|
...ComponentDefaults,
|
|
@@ -10385,8 +10272,8 @@ const defaultProps$12 = {
|
|
|
10385
10272
|
autoBackfill: false,
|
|
10386
10273
|
popup: true,
|
|
10387
10274
|
title: "",
|
|
10388
|
-
startDate:
|
|
10389
|
-
endDate:
|
|
10275
|
+
startDate: getDateString(0),
|
|
10276
|
+
endDate: getDateString(365),
|
|
10390
10277
|
showToday: true,
|
|
10391
10278
|
startText: "",
|
|
10392
10279
|
endText: "",
|
|
@@ -10442,6 +10329,8 @@ const CalendarItem = React__default.forwardRef((props, ref) => {
|
|
|
10442
10329
|
onDayClick,
|
|
10443
10330
|
onPageChange
|
|
10444
10331
|
} = { ...defaultProps$12, ...props };
|
|
10332
|
+
const classPrefix2 = "nut-calendar";
|
|
10333
|
+
const dayPrefix = "nut-calendar-day";
|
|
10445
10334
|
const weekdays = locale.calendaritem.weekdays;
|
|
10446
10335
|
const weeks = [
|
|
10447
10336
|
...weekdays.slice(firstDayOfWeek, 7),
|
|
@@ -10453,19 +10342,13 @@ const CalendarItem = React__default.forwardRef((props, ref) => {
|
|
|
10453
10342
|
const [monthsNum, setMonthsNum] = useState(0);
|
|
10454
10343
|
const [translateY, setTranslateY] = useState(0);
|
|
10455
10344
|
const [monthDefaultRange, setMonthDefaultRange] = useState([]);
|
|
10456
|
-
const propStartDate = startDate ||
|
|
10457
|
-
const propEndDate = endDate ||
|
|
10345
|
+
const propStartDate = startDate || getDateString(0);
|
|
10346
|
+
const propEndDate = endDate || getDateString(365);
|
|
10458
10347
|
const startDates = splitDate(propStartDate);
|
|
10459
10348
|
const endDates = splitDate(propEndDate);
|
|
10460
10349
|
const [state] = useState({
|
|
10461
10350
|
currDateArray: []
|
|
10462
10351
|
});
|
|
10463
|
-
const getMonthsPanel = () => {
|
|
10464
|
-
return monthsPanel.current;
|
|
10465
|
-
};
|
|
10466
|
-
const getMonthsRef = () => {
|
|
10467
|
-
return monthsRef.current;
|
|
10468
|
-
};
|
|
10469
10352
|
const resetDefaultValue = () => {
|
|
10470
10353
|
if (defaultValue || Array.isArray(defaultValue) && defaultValue.length > 0) {
|
|
10471
10354
|
return type4 !== "single" ? [...defaultValue] : defaultValue;
|
|
@@ -10485,9 +10368,7 @@ const CalendarItem = React__default.forwardRef((props, ref) => {
|
|
|
10485
10368
|
const viewAreaRef = useRef(null);
|
|
10486
10369
|
const [avgHeight, setAvgHeight] = useState(0);
|
|
10487
10370
|
let viewHeight = 0;
|
|
10488
|
-
const
|
|
10489
|
-
const dayPrefix = "nut-calendar-day";
|
|
10490
|
-
const getMonthData = (curData, monthNum, type22) => {
|
|
10371
|
+
const getMonthData = (curData, monthNum) => {
|
|
10491
10372
|
let i2 = 0;
|
|
10492
10373
|
let date4 = curData;
|
|
10493
10374
|
const monthData = monthsData;
|
|
@@ -10511,16 +10392,14 @@ const CalendarItem = React__default.forwardRef((props, ref) => {
|
|
|
10511
10392
|
cssHeight,
|
|
10512
10393
|
scrollTop
|
|
10513
10394
|
};
|
|
10514
|
-
|
|
10515
|
-
|
|
10516
|
-
|
|
10517
|
-
|
|
10518
|
-
|
|
10519
|
-
|
|
10520
|
-
|
|
10521
|
-
)
|
|
10522
|
-
monthData.push(monthInfo);
|
|
10523
|
-
}
|
|
10395
|
+
if (!endDates || !compareDate(
|
|
10396
|
+
`${endDates[0]}/${endDates[1]}/${getMonthDays(
|
|
10397
|
+
endDates[0],
|
|
10398
|
+
endDates[1]
|
|
10399
|
+
)}`,
|
|
10400
|
+
`${curData[0]}/${curData[1]}/${curData[2]}`
|
|
10401
|
+
)) {
|
|
10402
|
+
monthData.push(monthInfo);
|
|
10524
10403
|
}
|
|
10525
10404
|
date4 = getCurrMonthData("next", y, m2);
|
|
10526
10405
|
} while (i2++ < monthNum);
|
|
@@ -10528,8 +10407,8 @@ const CalendarItem = React__default.forwardRef((props, ref) => {
|
|
|
10528
10407
|
};
|
|
10529
10408
|
const setReachedYearMonthInfo = (current) => {
|
|
10530
10409
|
const currentMonthsData = monthsData[current];
|
|
10531
|
-
const [year, month] = currentMonthsData.curData;
|
|
10532
10410
|
if (currentMonthsData.title === yearMonthTitle) return;
|
|
10411
|
+
const [year, month] = currentMonthsData.curData;
|
|
10533
10412
|
onPageChange && onPageChange([year, month, `${year}-${month}`]);
|
|
10534
10413
|
setYearMonthTitle(currentMonthsData.title);
|
|
10535
10414
|
};
|
|
@@ -10555,57 +10434,54 @@ const CalendarItem = React__default.forwardRef((props, ref) => {
|
|
|
10555
10434
|
setTranslateY(monthsData[start2].scrollTop);
|
|
10556
10435
|
setReachedYearMonthInfo(current);
|
|
10557
10436
|
};
|
|
10558
|
-
const getMonthNum = () => {
|
|
10559
|
-
let monthNum = Number(endDates[1]) - Number(startDates[1]);
|
|
10560
|
-
const yearNum = Number(endDates[0]) - Number(startDates[0]);
|
|
10561
|
-
if (yearNum > 0) {
|
|
10562
|
-
monthNum += 12 * yearNum;
|
|
10563
|
-
}
|
|
10564
|
-
if (monthNum <= 0) {
|
|
10565
|
-
monthNum = 1;
|
|
10566
|
-
}
|
|
10567
|
-
setMonthsNum(monthNum);
|
|
10568
|
-
return monthNum;
|
|
10569
|
-
};
|
|
10570
10437
|
const setDefaultDate = () => {
|
|
10571
10438
|
let defaultData = [];
|
|
10572
|
-
if (type4 === "
|
|
10573
|
-
if (currentDate.length
|
|
10574
|
-
|
|
10575
|
-
|
|
10439
|
+
if (type4 === "single" && typeof currentDate === "string") {
|
|
10440
|
+
if (!currentDate.length) {
|
|
10441
|
+
return defaultData;
|
|
10442
|
+
}
|
|
10443
|
+
if (compareDate(currentDate, propStartDate)) {
|
|
10444
|
+
defaultData = [...splitDate(propStartDate)];
|
|
10445
|
+
} else if (!compareDate(currentDate, propEndDate)) {
|
|
10446
|
+
defaultData = [...splitDate(propEndDate)];
|
|
10447
|
+
} else {
|
|
10448
|
+
defaultData = [...splitDate(currentDate)];
|
|
10449
|
+
}
|
|
10450
|
+
return defaultData;
|
|
10451
|
+
}
|
|
10452
|
+
if (Array.isArray(currentDate) && currentDate.length) {
|
|
10453
|
+
if (type4 === "range") {
|
|
10454
|
+
if (compareDate(currentDate[0], propStartDate)) {
|
|
10455
|
+
currentDate[0] = propStartDate;
|
|
10576
10456
|
}
|
|
10577
|
-
if (
|
|
10578
|
-
currentDate
|
|
10457
|
+
if (compareDate(propEndDate, currentDate[1])) {
|
|
10458
|
+
currentDate[1] = propEndDate;
|
|
10579
10459
|
}
|
|
10580
10460
|
defaultData = [
|
|
10581
10461
|
...splitDate(currentDate[0]),
|
|
10582
10462
|
...splitDate(currentDate[1])
|
|
10583
10463
|
];
|
|
10584
|
-
}
|
|
10585
|
-
} else if (type4 === "multiple" && Array.isArray(currentDate)) {
|
|
10586
|
-
if (currentDate.length > 0) {
|
|
10464
|
+
} else if (type4 === "multiple") {
|
|
10587
10465
|
const defaultArr = [];
|
|
10588
10466
|
const obj = {};
|
|
10589
10467
|
currentDate.forEach((item) => {
|
|
10590
|
-
if (
|
|
10468
|
+
if (!compareDate(item, propStartDate) && !compareDate(propEndDate, item)) {
|
|
10591
10469
|
if (!Object.hasOwnProperty.call(obj, item)) {
|
|
10592
10470
|
defaultArr.push(item);
|
|
10593
10471
|
obj[item] = item;
|
|
10594
10472
|
}
|
|
10595
10473
|
}
|
|
10596
10474
|
});
|
|
10597
|
-
currentDate.splice(0
|
|
10475
|
+
currentDate.splice(0, currentDate.length, ...defaultArr);
|
|
10598
10476
|
defaultData = [...splitDate(defaultArr[0])];
|
|
10599
|
-
}
|
|
10600
|
-
} else if (type4 === "week" && Array.isArray(currentDate)) {
|
|
10601
|
-
if (currentDate.length > 0) {
|
|
10477
|
+
} else if (type4 === "week") {
|
|
10602
10478
|
const [y, m2, d2] = splitDate(currentDate[0]);
|
|
10603
|
-
const weekArr =
|
|
10604
|
-
currentDate.splice(0
|
|
10605
|
-
if (
|
|
10479
|
+
const weekArr = getWeekDate(y, m2, d2, firstDayOfWeek);
|
|
10480
|
+
currentDate.splice(0, currentDate.length, ...weekArr);
|
|
10481
|
+
if (compareDate(currentDate[0], propStartDate)) {
|
|
10606
10482
|
currentDate.splice(0, 1, propStartDate);
|
|
10607
10483
|
}
|
|
10608
|
-
if (
|
|
10484
|
+
if (compareDate(propEndDate, currentDate[1])) {
|
|
10609
10485
|
currentDate.splice(1, 1, propEndDate);
|
|
10610
10486
|
}
|
|
10611
10487
|
defaultData = [
|
|
@@ -10613,18 +10489,6 @@ const CalendarItem = React__default.forwardRef((props, ref) => {
|
|
|
10613
10489
|
...splitDate(currentDate[1])
|
|
10614
10490
|
];
|
|
10615
10491
|
}
|
|
10616
|
-
} else if (currentDate) {
|
|
10617
|
-
if (currentDate.length > 0) {
|
|
10618
|
-
if (propStartDate && Utils.compareDate(currentDate, propStartDate)) {
|
|
10619
|
-
defaultData = [...splitDate(propStartDate)];
|
|
10620
|
-
} else if (propEndDate && !Utils.compareDate(currentDate, propEndDate)) {
|
|
10621
|
-
defaultData = [...splitDate(propEndDate)];
|
|
10622
|
-
} else {
|
|
10623
|
-
defaultData = [...splitDate(currentDate)];
|
|
10624
|
-
}
|
|
10625
|
-
} else {
|
|
10626
|
-
defaultData = [];
|
|
10627
|
-
}
|
|
10628
10492
|
}
|
|
10629
10493
|
return defaultData;
|
|
10630
10494
|
};
|
|
@@ -10658,51 +10522,38 @@ const CalendarItem = React__default.forwardRef((props, ref) => {
|
|
|
10658
10522
|
lastCurrent
|
|
10659
10523
|
};
|
|
10660
10524
|
};
|
|
10661
|
-
const renderCurrentDate = () => {
|
|
10662
|
-
|
|
10663
|
-
const
|
|
10664
|
-
if (
|
|
10665
|
-
|
|
10666
|
-
|
|
10667
|
-
|
|
10668
|
-
|
|
10669
|
-
|
|
10670
|
-
|
|
10671
|
-
|
|
10672
|
-
|
|
10673
|
-
|
|
10674
|
-
|
|
10525
|
+
const renderCurrentDate = (defaultData, current) => {
|
|
10526
|
+
if (!defaultData.length) return;
|
|
10527
|
+
const date4 = monthsData[current.current];
|
|
10528
|
+
if (type4 === "range") {
|
|
10529
|
+
handleDayClick({ day: defaultData[2], type: "active" }, date4);
|
|
10530
|
+
handleDayClick(
|
|
10531
|
+
{ day: defaultData[5], type: "active" },
|
|
10532
|
+
monthsData[current.lastCurrent]
|
|
10533
|
+
);
|
|
10534
|
+
} else if (type4 === "week") {
|
|
10535
|
+
handleDayClick({ day: defaultData[2], type: "curr" }, date4);
|
|
10536
|
+
} else if (type4 === "multiple") {
|
|
10537
|
+
[...currentDate].forEach((item) => {
|
|
10538
|
+
const dateArr = splitDate(item);
|
|
10539
|
+
let currentIndex = current.current;
|
|
10540
|
+
currentIndex = monthsData.findIndex(
|
|
10541
|
+
(item2) => item2.title === monthTitle(dateArr[0], dateArr[1])
|
|
10675
10542
|
);
|
|
10676
|
-
|
|
10677
|
-
|
|
10678
|
-
|
|
10679
|
-
monthsData[current.current],
|
|
10680
|
-
true
|
|
10543
|
+
handleDayClick(
|
|
10544
|
+
{ day: dateArr[2], type: "active" },
|
|
10545
|
+
monthsData[currentIndex]
|
|
10681
10546
|
);
|
|
10682
|
-
}
|
|
10683
|
-
|
|
10684
|
-
|
|
10685
|
-
let currentIndex = current.current;
|
|
10686
|
-
monthsData.forEach((item2, index) => {
|
|
10687
|
-
if (item2.title === monthTitle(dateArr[0], dateArr[1])) {
|
|
10688
|
-
currentIndex = index;
|
|
10689
|
-
}
|
|
10690
|
-
});
|
|
10691
|
-
chooseDay(
|
|
10692
|
-
{ day: dateArr[2], type: "active" },
|
|
10693
|
-
monthsData[currentIndex],
|
|
10694
|
-
true
|
|
10695
|
-
);
|
|
10696
|
-
});
|
|
10697
|
-
} else {
|
|
10698
|
-
chooseDay(
|
|
10699
|
-
{ day: defaultData[2], type: "active" },
|
|
10700
|
-
monthsData[current.current],
|
|
10701
|
-
true
|
|
10702
|
-
);
|
|
10703
|
-
}
|
|
10547
|
+
});
|
|
10548
|
+
} else {
|
|
10549
|
+
handleDayClick({ day: defaultData[2], type: "active" }, date4);
|
|
10704
10550
|
}
|
|
10705
|
-
|
|
10551
|
+
};
|
|
10552
|
+
const getMonthsPanel = () => {
|
|
10553
|
+
return monthsPanel.current;
|
|
10554
|
+
};
|
|
10555
|
+
const getMonthsRef = () => {
|
|
10556
|
+
return monthsRef.current;
|
|
10706
10557
|
};
|
|
10707
10558
|
const requestAniFrameFunc = (current, monthNum) => {
|
|
10708
10559
|
const lastItem = monthsData[monthsData.length - 1];
|
|
@@ -10716,12 +10567,27 @@ const CalendarItem = React__default.forwardRef((props, ref) => {
|
|
|
10716
10567
|
});
|
|
10717
10568
|
setAvgHeight(Math.floor(containerHeight / (monthNum + 1)));
|
|
10718
10569
|
};
|
|
10570
|
+
const getMonthNum = () => {
|
|
10571
|
+
let monthNum = Number(endDates[1]) - Number(startDates[1]);
|
|
10572
|
+
const yearNum = Number(endDates[0]) - Number(startDates[0]);
|
|
10573
|
+
if (yearNum > 0) {
|
|
10574
|
+
monthNum += 12 * yearNum;
|
|
10575
|
+
}
|
|
10576
|
+
if (monthNum <= 0) {
|
|
10577
|
+
monthNum = 1;
|
|
10578
|
+
}
|
|
10579
|
+
setMonthsNum(monthNum);
|
|
10580
|
+
return monthNum;
|
|
10581
|
+
};
|
|
10719
10582
|
const initData = () => {
|
|
10720
10583
|
const monthNum = getMonthNum();
|
|
10721
10584
|
getMonthData(startDates, monthNum);
|
|
10722
|
-
const
|
|
10723
|
-
|
|
10724
|
-
|
|
10585
|
+
const defaultData = setDefaultDate();
|
|
10586
|
+
const current = getCurrentIndex(defaultData);
|
|
10587
|
+
const currentIndex = current.current;
|
|
10588
|
+
renderCurrentDate(defaultData, current);
|
|
10589
|
+
setDefaultRange(monthNum, currentIndex);
|
|
10590
|
+
requestAniFrameFunc(currentIndex, monthNum);
|
|
10725
10591
|
};
|
|
10726
10592
|
useEffect(() => {
|
|
10727
10593
|
initData();
|
|
@@ -10738,9 +10604,9 @@ const CalendarItem = React__default.forwardRef((props, ref) => {
|
|
|
10738
10604
|
popup && resetRender();
|
|
10739
10605
|
}, [currentDate]);
|
|
10740
10606
|
const scrollToDate = (date4) => {
|
|
10741
|
-
if (
|
|
10607
|
+
if (compareDate(date4, propStartDate)) {
|
|
10742
10608
|
date4 = propStartDate;
|
|
10743
|
-
} else if (!
|
|
10609
|
+
} else if (!compareDate(date4, propEndDate)) {
|
|
10744
10610
|
date4 = propEndDate;
|
|
10745
10611
|
}
|
|
10746
10612
|
const dateArr = splitDate(date4);
|
|
@@ -10782,16 +10648,10 @@ const CalendarItem = React__default.forwardRef((props, ref) => {
|
|
|
10782
10648
|
const nextTop = monthsData[current + 1].scrollTop;
|
|
10783
10649
|
const nextHeight = monthsData[current + 1].cssHeight;
|
|
10784
10650
|
if (current === 0) {
|
|
10785
|
-
if (scrollTop >= nextTop)
|
|
10786
|
-
current += 1;
|
|
10787
|
-
}
|
|
10651
|
+
if (scrollTop >= nextTop) current += 1;
|
|
10788
10652
|
} else if (current > 0 && current < monthsNum - 1) {
|
|
10789
|
-
if (scrollTop >= nextTop)
|
|
10790
|
-
|
|
10791
|
-
}
|
|
10792
|
-
if (scrollTop < monthsData[current].scrollTop) {
|
|
10793
|
-
current -= 1;
|
|
10794
|
-
}
|
|
10653
|
+
if (scrollTop >= nextTop) current += 1;
|
|
10654
|
+
if (scrollTop < monthsData[current].scrollTop) current -= 1;
|
|
10795
10655
|
} else {
|
|
10796
10656
|
const viewPosition = Math.round(scrollTop + viewHeight);
|
|
10797
10657
|
if (current + 1 <= monthsNum && viewPosition >= nextTop + nextHeight) {
|
|
@@ -10806,86 +10666,85 @@ const CalendarItem = React__default.forwardRef((props, ref) => {
|
|
|
10806
10666
|
React__default.useImperativeHandle(ref, () => ({
|
|
10807
10667
|
scrollToDate
|
|
10808
10668
|
}));
|
|
10669
|
+
const isDisable = (day, month) => {
|
|
10670
|
+
if (day.type !== "active") return true;
|
|
10671
|
+
const dateStr = getCurrDate(day, month);
|
|
10672
|
+
if (compareDate(dateStr, propStartDate)) return true;
|
|
10673
|
+
if (compareDate(propEndDate, dateStr)) return true;
|
|
10674
|
+
return false;
|
|
10675
|
+
};
|
|
10809
10676
|
const getClasses = (day, month) => {
|
|
10810
10677
|
const dateStr = getCurrDate(day, month);
|
|
10811
|
-
if (day
|
|
10812
|
-
|
|
10813
|
-
|
|
10814
|
-
|
|
10815
|
-
|
|
10816
|
-
|
|
10817
|
-
|
|
10818
|
-
}
|
|
10819
|
-
if (Array.isArray(currentDate) && Object.values(currentDate).length === 2 && Utils.compareDate(currentDate[0], dateStr) && Utils.compareDate(dateStr, currentDate[1])) {
|
|
10820
|
-
if (disableDate(day)) {
|
|
10821
|
-
return `${dayPrefix}-choose-disabled`;
|
|
10822
|
-
}
|
|
10823
|
-
return `${dayPrefix}-choose`;
|
|
10824
|
-
}
|
|
10825
|
-
} else if (type4 === "multiple" && isMultiple(dateStr, currentDate) || !Array.isArray(currentDate) && Utils.isEqual(currentDate, dateStr)) {
|
|
10826
|
-
return `${dayPrefix}-active`;
|
|
10678
|
+
if (isDisable(day, month)) return `${dayPrefix}-disabled`;
|
|
10679
|
+
const activeCls = `${dayPrefix}-active`;
|
|
10680
|
+
if (type4 === "range" || type4 === "week") {
|
|
10681
|
+
if (isStart(dateStr, currentDate))
|
|
10682
|
+
return `${activeCls} active-start`;
|
|
10683
|
+
if (isEnd(dateStr, currentDate)) {
|
|
10684
|
+
return `${activeCls} active-end`;
|
|
10827
10685
|
}
|
|
10828
|
-
if (
|
|
10829
|
-
return `${dayPrefix}-disabled`;
|
|
10686
|
+
if (currentDate.length === 2 && compareDate(currentDate[0], dateStr) && compareDate(dateStr, currentDate[1])) {
|
|
10687
|
+
return disableDate(day) ? `${dayPrefix}-choose-disabled` : `${dayPrefix}-choose`;
|
|
10830
10688
|
}
|
|
10831
|
-
|
|
10689
|
+
} else if (type4 === "multiple" && isMultiple(dateStr, currentDate) || type4 === "single" && isEqual(currentDate, dateStr)) {
|
|
10690
|
+
return activeCls;
|
|
10832
10691
|
}
|
|
10833
|
-
return `${dayPrefix}-disabled`;
|
|
10692
|
+
if (disableDate(day)) return `${dayPrefix}-disabled`;
|
|
10693
|
+
return null;
|
|
10834
10694
|
};
|
|
10835
|
-
const
|
|
10695
|
+
const handleDayClick = (day, month, isFirst = true) => {
|
|
10836
10696
|
if (getClasses(day, month) === `${dayPrefix}-disabled`) {
|
|
10837
10697
|
return;
|
|
10838
10698
|
}
|
|
10839
10699
|
const days = [...month.curData];
|
|
10840
10700
|
const [y, m2] = month.curData;
|
|
10841
|
-
days[2] = typeof day.day === "number" ?
|
|
10701
|
+
days[2] = typeof day.day === "number" ? getNumTwoBit(day.day) : day.day;
|
|
10842
10702
|
days[3] = `${days[0]}/${days[1]}/${days[2]}`;
|
|
10843
|
-
days[4] =
|
|
10703
|
+
days[4] = getWhatDay(+days[0], +days[1], +days[2]);
|
|
10704
|
+
const newDate = days[3];
|
|
10844
10705
|
if (type4 === "multiple") {
|
|
10845
|
-
if (currentDate
|
|
10846
|
-
|
|
10847
|
-
|
|
10848
|
-
if (
|
|
10849
|
-
|
|
10706
|
+
if (Array.isArray(currentDate)) {
|
|
10707
|
+
if (currentDate.length > 0) {
|
|
10708
|
+
const hasIndex = currentDate.findIndex((item) => item === newDate);
|
|
10709
|
+
if (isFirst) {
|
|
10710
|
+
state.currDateArray.push([...days]);
|
|
10711
|
+
} else if (hasIndex > -1) {
|
|
10712
|
+
currentDate.splice(hasIndex, 1);
|
|
10713
|
+
state.currDateArray.splice(hasIndex, 1);
|
|
10714
|
+
} else {
|
|
10715
|
+
currentDate.push(newDate);
|
|
10716
|
+
state.currDateArray.push([...days]);
|
|
10850
10717
|
}
|
|
10851
|
-
});
|
|
10852
|
-
if (isFirst) {
|
|
10853
|
-
state.currDateArray.push([...days]);
|
|
10854
|
-
} else if (hasIndex !== "") {
|
|
10855
|
-
currentDate.splice(hasIndex, 1);
|
|
10856
|
-
state.currDateArray.splice(hasIndex, 1);
|
|
10857
10718
|
} else {
|
|
10858
|
-
currentDate.push(
|
|
10859
|
-
state.currDateArray
|
|
10719
|
+
currentDate.push(newDate);
|
|
10720
|
+
state.currDateArray = [[...days]];
|
|
10860
10721
|
}
|
|
10861
|
-
} else {
|
|
10862
|
-
currentDate.push(days[3]);
|
|
10863
|
-
state.currDateArray = [[...days]];
|
|
10864
10722
|
}
|
|
10865
10723
|
} else if (type4 === "range") {
|
|
10866
|
-
|
|
10867
|
-
|
|
10868
|
-
|
|
10869
|
-
|
|
10870
|
-
|
|
10871
|
-
|
|
10872
|
-
|
|
10873
|
-
|
|
10874
|
-
|
|
10875
|
-
|
|
10724
|
+
if (Array.isArray(currentDate)) {
|
|
10725
|
+
if (currentDate.length === 2 || currentDate.length === 0) {
|
|
10726
|
+
currentDate.splice(0, currentDate.length, newDate);
|
|
10727
|
+
state.currDateArray = [[...days]];
|
|
10728
|
+
} else if (compareDate(currentDate[0], newDate)) {
|
|
10729
|
+
currentDate.push(newDate);
|
|
10730
|
+
state.currDateArray = [...state.currDateArray, [...days]];
|
|
10731
|
+
} else {
|
|
10732
|
+
currentDate.unshift(newDate);
|
|
10733
|
+
state.currDateArray = [[...days], ...state.currDateArray];
|
|
10734
|
+
}
|
|
10876
10735
|
}
|
|
10877
10736
|
} else if (type4 === "week") {
|
|
10878
|
-
const weekArr =
|
|
10879
|
-
if (
|
|
10880
|
-
weekArr
|
|
10737
|
+
const weekArr = getWeekDate(y, m2, `${day.day}`, firstDayOfWeek);
|
|
10738
|
+
if (compareDate(weekArr[0], propStartDate)) {
|
|
10739
|
+
weekArr[0] = propStartDate;
|
|
10881
10740
|
}
|
|
10882
|
-
if (
|
|
10883
|
-
weekArr
|
|
10741
|
+
if (compareDate(propEndDate, weekArr[1])) {
|
|
10742
|
+
weekArr[1] = propEndDate;
|
|
10884
10743
|
}
|
|
10885
|
-
|
|
10744
|
+
currentDate.splice(0, currentDate.length, ...weekArr);
|
|
10886
10745
|
state.currDateArray = [
|
|
10887
|
-
|
|
10888
|
-
|
|
10746
|
+
formatResultDate(weekArr[0]),
|
|
10747
|
+
formatResultDate(weekArr[1])
|
|
10889
10748
|
];
|
|
10890
10749
|
} else {
|
|
10891
10750
|
setCurrentDate(days[3]);
|
|
@@ -10909,11 +10768,11 @@ const CalendarItem = React__default.forwardRef((props, ref) => {
|
|
|
10909
10768
|
}
|
|
10910
10769
|
};
|
|
10911
10770
|
const classes = classNames(
|
|
10771
|
+
classPrefix2,
|
|
10912
10772
|
{
|
|
10913
10773
|
[`${classPrefix2}-title`]: !popup,
|
|
10914
10774
|
[`${classPrefix2}-nofooter`]: !!autoBackfill
|
|
10915
10775
|
},
|
|
10916
|
-
classPrefix2,
|
|
10917
10776
|
className
|
|
10918
10777
|
);
|
|
10919
10778
|
const headerClasses = classNames({
|
|
@@ -10929,6 +10788,36 @@ const CalendarItem = React__default.forwardRef((props, ref) => {
|
|
|
10929
10788
|
const renderHeader = () => {
|
|
10930
10789
|
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))));
|
|
10931
10790
|
};
|
|
10791
|
+
const renderItem = (month, day, index) => {
|
|
10792
|
+
const startTip = isStartTip(day, month);
|
|
10793
|
+
const endTip = isEndTip(day, month);
|
|
10794
|
+
const noStartNorEnd = !startTip && !endTip;
|
|
10795
|
+
return /* @__PURE__ */ React__default.createElement(
|
|
10796
|
+
"div",
|
|
10797
|
+
{
|
|
10798
|
+
className: [`${classPrefix2}-day`, getClasses(day, month)].join(" "),
|
|
10799
|
+
onClick: () => handleDayClick(day, month, false),
|
|
10800
|
+
key: index
|
|
10801
|
+
},
|
|
10802
|
+
/* @__PURE__ */ React__default.createElement("div", { className: `${classPrefix2}-day-day` }, renderDay ? renderDay(day) : day.day),
|
|
10803
|
+
!startTip && renderDayTop && /* @__PURE__ */ React__default.createElement("div", { className: `${classPrefix2}-day-info-top` }, renderDayTop(day)),
|
|
10804
|
+
noStartNorEnd && renderDayBottom && /* @__PURE__ */ React__default.createElement("div", { className: `${classPrefix2}-day-info-bottom` }, renderDayBottom(day)),
|
|
10805
|
+
noStartNorEnd && !renderDayBottom && showToday && isCurrDay(month, day.day) && /* @__PURE__ */ React__default.createElement("div", { className: `${classPrefix2}-day-info-curr` }, locale.calendaritem.today),
|
|
10806
|
+
startTip && /* @__PURE__ */ React__default.createElement(
|
|
10807
|
+
"div",
|
|
10808
|
+
{
|
|
10809
|
+
className: `${classPrefix2}-day-info ${isStartAndEnd(currentDate) ? `${classPrefix2}-day-info-top` : ""}`
|
|
10810
|
+
},
|
|
10811
|
+
startText || locale.calendaritem.start
|
|
10812
|
+
),
|
|
10813
|
+
endTip && /* @__PURE__ */ React__default.createElement("div", { className: `${classPrefix2}-day-info` }, endText || locale.calendaritem.end)
|
|
10814
|
+
);
|
|
10815
|
+
};
|
|
10816
|
+
const renderPanel = (month, key) => {
|
|
10817
|
+
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(
|
|
10818
|
+
(day, i2) => renderItem(month, day, i2)
|
|
10819
|
+
)));
|
|
10820
|
+
};
|
|
10932
10821
|
const renderContent = () => {
|
|
10933
10822
|
return /* @__PURE__ */ React__default.createElement(
|
|
10934
10823
|
"div",
|
|
@@ -10945,31 +10834,7 @@ const CalendarItem = React__default.forwardRef((props, ref) => {
|
|
|
10945
10834
|
style: { transform: `translateY(${translateY}px)` }
|
|
10946
10835
|
},
|
|
10947
10836
|
monthsData.slice(monthDefaultRange[0], monthDefaultRange[1]).map((month, key) => {
|
|
10948
|
-
return
|
|
10949
|
-
"div",
|
|
10950
|
-
{
|
|
10951
|
-
className: [
|
|
10952
|
-
`${classPrefix2}-day`,
|
|
10953
|
-
getClasses(day, month)
|
|
10954
|
-
].join(" "),
|
|
10955
|
-
onClick: () => {
|
|
10956
|
-
chooseDay(day, month);
|
|
10957
|
-
},
|
|
10958
|
-
key: i2
|
|
10959
|
-
},
|
|
10960
|
-
/* @__PURE__ */ React__default.createElement("div", { className: `${classPrefix2}-day-day` }, renderDay ? renderDay(day) : day.day),
|
|
10961
|
-
!isStartTip(day, month) && renderDayTop && /* @__PURE__ */ React__default.createElement("div", { className: `${classPrefix2}-day-info-top` }, renderDayTop(day)),
|
|
10962
|
-
!isStartTip(day, month) && !isEndTip(day, month) && renderDayBottom && /* @__PURE__ */ React__default.createElement("div", { className: `${classPrefix2}-day-info-bottom` }, renderDayBottom(day)),
|
|
10963
|
-
!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),
|
|
10964
|
-
isStartTip(day, month) && /* @__PURE__ */ React__default.createElement(
|
|
10965
|
-
"div",
|
|
10966
|
-
{
|
|
10967
|
-
className: `${classPrefix2}-day-info ${isStartAndEnd(currentDate) ? `${classPrefix2}-day-info-top` : ""}`
|
|
10968
|
-
},
|
|
10969
|
-
startText || locale.calendaritem.start
|
|
10970
|
-
),
|
|
10971
|
-
isEndTip(day, month) && /* @__PURE__ */ React__default.createElement("div", { className: `${classPrefix2}-day-info` }, endText || locale.calendaritem.end)
|
|
10972
|
-
))));
|
|
10837
|
+
return renderPanel(month, key);
|
|
10973
10838
|
})
|
|
10974
10839
|
))
|
|
10975
10840
|
);
|
|
@@ -10988,8 +10853,8 @@ const defaultProps$11 = {
|
|
|
10988
10853
|
visible: false,
|
|
10989
10854
|
title: "",
|
|
10990
10855
|
defaultValue: "",
|
|
10991
|
-
startDate:
|
|
10992
|
-
endDate:
|
|
10856
|
+
startDate: getDateString(0),
|
|
10857
|
+
endDate: getDateString(365),
|
|
10993
10858
|
showToday: true,
|
|
10994
10859
|
startText: "",
|
|
10995
10860
|
endText: "",
|
|
@@ -11188,12 +11053,12 @@ const getPrevMonthDays = (year, month, firstDayOfWeek) => {
|
|
|
11188
11053
|
prevMonth = 12;
|
|
11189
11054
|
prevYear -= 1;
|
|
11190
11055
|
}
|
|
11191
|
-
let days =
|
|
11056
|
+
let days = getMonthPreDay(year, month);
|
|
11192
11057
|
days -= firstDayOfWeek;
|
|
11193
11058
|
if (days >= 7) {
|
|
11194
11059
|
days -= 7;
|
|
11195
11060
|
}
|
|
11196
|
-
const preDates =
|
|
11061
|
+
const preDates = getMonthDays(`${prevYear}`, `${prevMonth}`);
|
|
11197
11062
|
const months = Array.from(Array(preDates), (_, k) => {
|
|
11198
11063
|
return {
|
|
11199
11064
|
type: "prev",
|
|
@@ -11205,7 +11070,7 @@ const getPrevMonthDays = (year, month, firstDayOfWeek) => {
|
|
|
11205
11070
|
return months.slice(preDates - days);
|
|
11206
11071
|
};
|
|
11207
11072
|
const getCurrentMonthDays = (year, month) => {
|
|
11208
|
-
const days =
|
|
11073
|
+
const days = getMonthDays(`${year}`, `${month}`);
|
|
11209
11074
|
return Array.from(Array(days), (_, k) => {
|
|
11210
11075
|
return {
|
|
11211
11076
|
type: "current",
|
|
@@ -12533,6 +12398,14 @@ const DatePicker = (props) => {
|
|
|
12533
12398
|
Number(formatDate[2]),
|
|
12534
12399
|
getMonthEndDay(Number(formatDate[0]), Number(formatDate[1]))
|
|
12535
12400
|
);
|
|
12401
|
+
if (selectedOptions.length >= 2 && ["date", "datehour", "datetime", "month-day"].includes(rangeType)) {
|
|
12402
|
+
const dayOption = formatOption("day", day);
|
|
12403
|
+
if (rangeType === "month-day") {
|
|
12404
|
+
selectedOptions[1] = dayOption;
|
|
12405
|
+
} else {
|
|
12406
|
+
selectedOptions[2] = dayOption;
|
|
12407
|
+
}
|
|
12408
|
+
}
|
|
12536
12409
|
let date4 = null;
|
|
12537
12410
|
if (rangeType === "date" || rangeType === "month-day" || rangeType === "year-month") {
|
|
12538
12411
|
date4 = new Date(year, month, day);
|
|
@@ -13437,7 +13310,7 @@ function newMessages() {
|
|
|
13437
13310
|
pattern: {
|
|
13438
13311
|
mismatch: "%s value %s does not match pattern %s"
|
|
13439
13312
|
},
|
|
13440
|
-
clone: function
|
|
13313
|
+
clone: function clone2() {
|
|
13441
13314
|
var cloned = JSON.parse(JSON.stringify(this));
|
|
13442
13315
|
cloned.clone = this.clone;
|
|
13443
13316
|
return cloned;
|
|
@@ -13701,23 +13574,55 @@ Schema.register = function register(type4, validator) {
|
|
|
13701
13574
|
Schema.warning = warning;
|
|
13702
13575
|
Schema.messages = messages;
|
|
13703
13576
|
Schema.validators = validators;
|
|
13704
|
-
function merge(...
|
|
13705
|
-
|
|
13706
|
-
|
|
13707
|
-
|
|
13708
|
-
|
|
13709
|
-
|
|
13710
|
-
|
|
13711
|
-
|
|
13712
|
-
|
|
13713
|
-
|
|
13714
|
-
|
|
13715
|
-
|
|
13716
|
-
|
|
13717
|
-
|
|
13577
|
+
function merge(...items) {
|
|
13578
|
+
return _merge(items[0] === true, false, items);
|
|
13579
|
+
}
|
|
13580
|
+
function recursive(...items) {
|
|
13581
|
+
return _merge(items[0] === true, true, items);
|
|
13582
|
+
}
|
|
13583
|
+
function clone(input) {
|
|
13584
|
+
if (Array.isArray(input)) {
|
|
13585
|
+
const output = [];
|
|
13586
|
+
for (let index = 0; index < input.length; ++index)
|
|
13587
|
+
output.push(clone(input[index]));
|
|
13588
|
+
return output;
|
|
13589
|
+
}
|
|
13590
|
+
if (isPlainObject(input)) {
|
|
13591
|
+
const output = {};
|
|
13592
|
+
for (const index in input) output[index] = clone(input[index]);
|
|
13593
|
+
return output;
|
|
13594
|
+
}
|
|
13595
|
+
return input;
|
|
13596
|
+
}
|
|
13597
|
+
function isPlainObject(input) {
|
|
13598
|
+
if (input === null || typeof input !== "object") return false;
|
|
13599
|
+
if (Object.getPrototypeOf(input) === null) return true;
|
|
13600
|
+
let ref = input;
|
|
13601
|
+
while (Object.getPrototypeOf(ref) !== null) ref = Object.getPrototypeOf(ref);
|
|
13602
|
+
return Object.getPrototypeOf(input) === ref;
|
|
13603
|
+
}
|
|
13604
|
+
function _recursiveMerge(base, extend) {
|
|
13605
|
+
if (!isPlainObject(base) || !isPlainObject(extend)) return extend;
|
|
13606
|
+
for (const key in extend) {
|
|
13607
|
+
if (key === "__proto__" || key === "constructor" || key === "prototype")
|
|
13608
|
+
continue;
|
|
13609
|
+
base[key] = isPlainObject(base[key]) && isPlainObject(extend[key]) ? _recursiveMerge(base[key], extend[key]) : extend[key];
|
|
13610
|
+
}
|
|
13611
|
+
return base;
|
|
13612
|
+
}
|
|
13613
|
+
function _merge(isClone, isRecursive, items) {
|
|
13614
|
+
let result;
|
|
13615
|
+
if (isClone || !isPlainObject(result = items.shift())) result = {};
|
|
13616
|
+
for (let index = 0; index < items.length; ++index) {
|
|
13617
|
+
const item = items[index];
|
|
13618
|
+
if (!isPlainObject(item)) continue;
|
|
13619
|
+
for (const key in item) {
|
|
13620
|
+
if (key === "__proto__" || key === "constructor" || key === "prototype")
|
|
13621
|
+
continue;
|
|
13622
|
+
const value = isClone ? clone(item[key]) : item[key];
|
|
13623
|
+
result[key] = isRecursive ? _recursiveMerge(result[key], value) : value;
|
|
13718
13624
|
}
|
|
13719
13625
|
}
|
|
13720
|
-
objects.filter((obj) => !!obj).forEach((obj) => mergeHelper(obj));
|
|
13721
13626
|
return result;
|
|
13722
13627
|
}
|
|
13723
13628
|
const SECRET = "NUT_FORM_INTERNAL";
|
|
@@ -13733,9 +13638,6 @@ class FormStore {
|
|
|
13733
13638
|
this.fieldEntities.push(field);
|
|
13734
13639
|
return () => {
|
|
13735
13640
|
this.fieldEntities = this.fieldEntities.filter((item) => item !== field);
|
|
13736
|
-
if (this.store) {
|
|
13737
|
-
delete this.store[field.props.name];
|
|
13738
|
-
}
|
|
13739
13641
|
};
|
|
13740
13642
|
};
|
|
13741
13643
|
this.getFieldValue = (name) => {
|
|
@@ -13757,10 +13659,11 @@ class FormStore {
|
|
|
13757
13659
|
if (init) {
|
|
13758
13660
|
const nextStore = merge(initialValues, this.store);
|
|
13759
13661
|
this.updateStore(nextStore);
|
|
13662
|
+
this.notifyWatch();
|
|
13760
13663
|
}
|
|
13761
13664
|
};
|
|
13762
13665
|
this.setFieldsValue = (newStore) => {
|
|
13763
|
-
const nextStore =
|
|
13666
|
+
const nextStore = recursive(true, this.store, newStore);
|
|
13764
13667
|
this.updateStore(nextStore);
|
|
13765
13668
|
this.fieldEntities.forEach((entity) => {
|
|
13766
13669
|
const { name } = entity.props;
|
|
@@ -13779,12 +13682,14 @@ class FormStore {
|
|
|
13779
13682
|
item.entity.onStoreChange("update");
|
|
13780
13683
|
}
|
|
13781
13684
|
});
|
|
13685
|
+
this.notifyWatch();
|
|
13782
13686
|
};
|
|
13783
13687
|
this.setFieldValue = (name, value) => {
|
|
13784
13688
|
const store = {
|
|
13785
13689
|
[name]: value
|
|
13786
13690
|
};
|
|
13787
13691
|
this.setFieldsValue(store);
|
|
13692
|
+
this.notifyWatch([name]);
|
|
13788
13693
|
};
|
|
13789
13694
|
this.setCallback = (callback) => {
|
|
13790
13695
|
this.callbacks = {
|
|
@@ -13827,7 +13732,6 @@ class FormStore {
|
|
|
13827
13732
|
};
|
|
13828
13733
|
this.validateFields = async (nameList) => {
|
|
13829
13734
|
let filterEntities = [];
|
|
13830
|
-
this.errors.length = 0;
|
|
13831
13735
|
if (!nameList || nameList.length === 0) {
|
|
13832
13736
|
filterEntities = this.fieldEntities;
|
|
13833
13737
|
} else {
|
|
@@ -13852,13 +13756,29 @@ class FormStore {
|
|
|
13852
13756
|
(_d = (_c = this.callbacks).onFinishFailed) == null ? void 0 : _d.call(_c, this.store, errors);
|
|
13853
13757
|
}
|
|
13854
13758
|
};
|
|
13855
|
-
this.resetFields = () => {
|
|
13856
|
-
|
|
13857
|
-
|
|
13858
|
-
|
|
13859
|
-
|
|
13860
|
-
|
|
13861
|
-
|
|
13759
|
+
this.resetFields = (namePaths) => {
|
|
13760
|
+
if (namePaths && namePaths.length) {
|
|
13761
|
+
namePaths.forEach((path) => {
|
|
13762
|
+
this.errors[path] = null;
|
|
13763
|
+
this.fieldEntities.forEach((entity) => {
|
|
13764
|
+
const name = entity.props.name;
|
|
13765
|
+
if (name === path) {
|
|
13766
|
+
if (path in this.initialValues) {
|
|
13767
|
+
this.updateStore({ [path]: this.initialValues[path] });
|
|
13768
|
+
} else {
|
|
13769
|
+
delete this.store[path];
|
|
13770
|
+
}
|
|
13771
|
+
entity.onStoreChange("reset");
|
|
13772
|
+
}
|
|
13773
|
+
});
|
|
13774
|
+
});
|
|
13775
|
+
} else {
|
|
13776
|
+
const nextStore = merge({}, this.initialValues);
|
|
13777
|
+
this.updateStore(nextStore);
|
|
13778
|
+
this.fieldEntities.forEach((entity) => {
|
|
13779
|
+
entity.onStoreChange("reset");
|
|
13780
|
+
});
|
|
13781
|
+
}
|
|
13862
13782
|
};
|
|
13863
13783
|
this.registerUpdate = (field, shouldUpdate) => {
|
|
13864
13784
|
this.updateList.push({
|
|
@@ -13881,7 +13801,8 @@ class FormStore {
|
|
|
13881
13801
|
dispatch: this.dispatch,
|
|
13882
13802
|
store: this.store,
|
|
13883
13803
|
fieldEntities: this.fieldEntities,
|
|
13884
|
-
registerUpdate: this.registerUpdate
|
|
13804
|
+
registerUpdate: this.registerUpdate,
|
|
13805
|
+
registerWatch: this.registerWatch
|
|
13885
13806
|
};
|
|
13886
13807
|
}
|
|
13887
13808
|
};
|
|
@@ -13898,6 +13819,26 @@ class FormStore {
|
|
|
13898
13819
|
getInternal: this.getInternal
|
|
13899
13820
|
};
|
|
13900
13821
|
};
|
|
13822
|
+
this.watchList = [];
|
|
13823
|
+
this.registerWatch = (callback) => {
|
|
13824
|
+
this.watchList.push(callback);
|
|
13825
|
+
return () => {
|
|
13826
|
+
this.watchList = this.watchList.filter((fn) => fn !== callback);
|
|
13827
|
+
};
|
|
13828
|
+
};
|
|
13829
|
+
this.notifyWatch = (namePath = []) => {
|
|
13830
|
+
if (this.watchList.length) {
|
|
13831
|
+
let allValues;
|
|
13832
|
+
if (!namePath || namePath.length === 0) {
|
|
13833
|
+
allValues = this.getFieldsValue(true);
|
|
13834
|
+
} else {
|
|
13835
|
+
allValues = this.getFieldsValue(namePath);
|
|
13836
|
+
}
|
|
13837
|
+
this.watchList.forEach((callback) => {
|
|
13838
|
+
callback(allValues, namePath);
|
|
13839
|
+
});
|
|
13840
|
+
}
|
|
13841
|
+
};
|
|
13901
13842
|
this.callbacks = {
|
|
13902
13843
|
onFinish: () => {
|
|
13903
13844
|
},
|
|
@@ -13921,6 +13862,24 @@ const useForm = (form) => {
|
|
|
13921
13862
|
}
|
|
13922
13863
|
return [formRef.current];
|
|
13923
13864
|
};
|
|
13865
|
+
const useWatch = (path, form) => {
|
|
13866
|
+
const formInstance = form.getInternal(SECRET);
|
|
13867
|
+
const [value, setValue] = useState();
|
|
13868
|
+
useEffect(() => {
|
|
13869
|
+
const unsubscribe = formInstance.registerWatch(
|
|
13870
|
+
(data, namePath) => {
|
|
13871
|
+
const value2 = data[path];
|
|
13872
|
+
setValue(value2);
|
|
13873
|
+
}
|
|
13874
|
+
);
|
|
13875
|
+
const initialValue = form.getFieldsValue(true);
|
|
13876
|
+
if (value !== initialValue[path]) {
|
|
13877
|
+
setValue(initialValue[path]);
|
|
13878
|
+
}
|
|
13879
|
+
return () => unsubscribe();
|
|
13880
|
+
}, [form]);
|
|
13881
|
+
return value;
|
|
13882
|
+
};
|
|
13924
13883
|
const defaultProps$X = {
|
|
13925
13884
|
...ComponentDefaults,
|
|
13926
13885
|
labelPosition: "right",
|
|
@@ -14208,6 +14167,7 @@ let FormItem = _FormItem;
|
|
|
14208
14167
|
const InnerForm = Form;
|
|
14209
14168
|
InnerForm.Item = FormItem;
|
|
14210
14169
|
InnerForm.useForm = useForm;
|
|
14170
|
+
InnerForm.useWatch = useWatch;
|
|
14211
14171
|
function trimExtraChar(value, char, regExp) {
|
|
14212
14172
|
const index = value.indexOf(char);
|
|
14213
14173
|
if (index === -1) {
|
|
@@ -17690,7 +17650,7 @@ const Empty = (props) => {
|
|
|
17690
17650
|
const imageNode = typeof imageUrl === "string" ? /* @__PURE__ */ React__default.createElement("img", { className: "img", src: imageUrl, alt: "empty" }) : imageUrl;
|
|
17691
17651
|
useEffect(() => {
|
|
17692
17652
|
setImgStyle(() => {
|
|
17693
|
-
if (
|
|
17653
|
+
if (typeof imageSize !== "number" && typeof imageSize !== "string") {
|
|
17694
17654
|
return {};
|
|
17695
17655
|
}
|
|
17696
17656
|
if (typeof imageSize === "number") {
|
|
@@ -19555,29 +19515,29 @@ const defaultProps$s = {
|
|
|
19555
19515
|
onClick: (event) => {
|
|
19556
19516
|
}
|
|
19557
19517
|
};
|
|
19558
|
-
const classPrefix$7 =
|
|
19518
|
+
const classPrefix$7 = "nut-animate";
|
|
19559
19519
|
const Animate = (props) => {
|
|
19560
19520
|
const { className, type: type4, action, loop: loop2, onClick, children, ...rest } = {
|
|
19561
19521
|
...defaultProps$s,
|
|
19562
19522
|
...props
|
|
19563
19523
|
};
|
|
19564
19524
|
const [clicked, setClicked] = useState(false);
|
|
19565
|
-
const classes = classNames(
|
|
19566
|
-
|
|
19567
|
-
|
|
19568
|
-
|
|
19569
|
-
|
|
19570
|
-
|
|
19525
|
+
const classes = classNames(
|
|
19526
|
+
{
|
|
19527
|
+
"nut-ani-container": true,
|
|
19528
|
+
[`${classPrefix$7}-${type4}`]: action === "initial" || clicked,
|
|
19529
|
+
loop: loop2
|
|
19530
|
+
},
|
|
19531
|
+
className
|
|
19532
|
+
);
|
|
19571
19533
|
const handleClick2 = (event) => {
|
|
19572
19534
|
setClicked(true);
|
|
19573
19535
|
if (!loop2) {
|
|
19574
|
-
setTimeout(() =>
|
|
19575
|
-
setClicked(false);
|
|
19576
|
-
}, 1e3);
|
|
19536
|
+
setTimeout(() => setClicked(false), 1e3);
|
|
19577
19537
|
}
|
|
19578
|
-
onClick
|
|
19538
|
+
onClick(event);
|
|
19579
19539
|
};
|
|
19580
|
-
return /* @__PURE__ */ React__default.createElement("div", { className: "nut-animate" }, /* @__PURE__ */ React__default.createElement("div", { className:
|
|
19540
|
+
return /* @__PURE__ */ React__default.createElement("div", { className: "nut-animate" }, /* @__PURE__ */ React__default.createElement("div", { className: classes, onClick: handleClick2, ...rest }, children));
|
|
19581
19541
|
};
|
|
19582
19542
|
Animate.displayName = "NutAnimate";
|
|
19583
19543
|
const defaultProps$r = {
|