antd-mobile 5.41.0-alpha.0 → 5.41.0-alpha.1
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/2x/bundle/antd-mobile.cjs.development.js +75 -69
- package/2x/bundle/antd-mobile.cjs.js +4 -4
- package/2x/bundle/antd-mobile.es.development.js +75 -69
- package/2x/bundle/antd-mobile.es.js +2763 -2758
- package/2x/bundle/antd-mobile.umd.development.js +75 -69
- package/2x/bundle/antd-mobile.umd.js +4 -4
- package/2x/cjs/components/calendar/calendar.d.ts +4 -1
- package/2x/cjs/components/calendar/calendar.js +18 -11
- package/2x/es/components/calendar/calendar.d.ts +4 -1
- package/2x/es/components/calendar/calendar.js +19 -12
- package/2x/package.json +1 -1
- package/bundle/antd-mobile.cjs.development.js +75 -69
- package/bundle/antd-mobile.cjs.js +4 -4
- package/bundle/antd-mobile.compatible.umd.js +1 -1
- package/bundle/antd-mobile.es.development.js +75 -69
- package/bundle/antd-mobile.es.js +2763 -2758
- package/bundle/antd-mobile.umd.development.js +75 -69
- package/bundle/antd-mobile.umd.js +4 -4
- package/cjs/components/calendar/calendar.d.ts +4 -1
- package/cjs/components/calendar/calendar.js +18 -11
- package/es/components/calendar/calendar.d.ts +4 -1
- package/es/components/calendar/calendar.js +19 -12
- package/package.json +1 -1
- package/umd/antd-mobile.js +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
2
|
import { NativeProps } from '../../utils/native-props';
|
|
3
3
|
import { Page } from './convert';
|
|
4
4
|
export declare type CalendarRef = {
|
|
@@ -14,6 +14,9 @@ export declare type CalendarProps = {
|
|
|
14
14
|
weekStartsOn?: 'Monday' | 'Sunday';
|
|
15
15
|
renderLabel?: (date: Date) => React.ReactNode;
|
|
16
16
|
renderDate?: (date: Date) => React.ReactNode;
|
|
17
|
+
cellRender?: (oriNode: React.ReactElement, info: {
|
|
18
|
+
date: Date;
|
|
19
|
+
}) => ReactNode;
|
|
17
20
|
allowClear?: boolean;
|
|
18
21
|
max?: Date;
|
|
19
22
|
min?: Date;
|
|
@@ -4,23 +4,23 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.Calendar = void 0;
|
|
7
|
+
var _ahooks = require("ahooks");
|
|
8
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
9
|
+
var _dayjs = _interopRequireDefault(require("dayjs"));
|
|
10
|
+
var _isoWeek = _interopRequireDefault(require("dayjs/plugin/isoWeek"));
|
|
7
11
|
var _react = _interopRequireWildcard(require("react"));
|
|
12
|
+
var _devLog = require("../../utils/dev-log");
|
|
8
13
|
var _nativeProps = require("../../utils/native-props");
|
|
9
|
-
var
|
|
10
|
-
var
|
|
14
|
+
var _replaceMessage = require("../../utils/replace-message");
|
|
15
|
+
var _usePropsValue = require("../../utils/use-props-value");
|
|
11
16
|
var _withDefaultProps = require("../../utils/with-default-props");
|
|
17
|
+
var _configProvider = require("../config-provider");
|
|
12
18
|
var _arrowLeft = require("./arrow-left");
|
|
13
19
|
var _arrowLeftDouble = require("./arrow-left-double");
|
|
14
|
-
var _configProvider = require("../config-provider");
|
|
15
|
-
var _isoWeek = _interopRequireDefault(require("dayjs/plugin/isoWeek"));
|
|
16
|
-
var _ahooks = require("ahooks");
|
|
17
|
-
var _usePropsValue = require("../../utils/use-props-value");
|
|
18
|
-
var _replaceMessage = require("../../utils/replace-message");
|
|
19
|
-
var _devLog = require("../../utils/dev-log");
|
|
20
20
|
var _convert = require("./convert");
|
|
21
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
22
21
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
23
22
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
23
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
24
24
|
_dayjs.default.extend(_isoWeek.default);
|
|
25
25
|
const classPrefix = 'adm-calendar';
|
|
26
26
|
const defaultProps = {
|
|
@@ -150,7 +150,7 @@ const Calendar = (0, _react.forwardRef)((p, ref) => {
|
|
|
150
150
|
}
|
|
151
151
|
const inThisMonth = d.month() === current.month();
|
|
152
152
|
const disabled = props.shouldDisableDate ? props.shouldDisableDate(d.toDate()) : maxDay && d.isAfter(maxDay, 'day') || minDay && d.isBefore(minDay, 'day');
|
|
153
|
-
|
|
153
|
+
const originalCell = _react.default.createElement("div", {
|
|
154
154
|
key: d.valueOf(),
|
|
155
155
|
className: (0, _classnames.default)(`${classPrefix}-cell`, (disabled || !inThisMonth) && `${classPrefix}-cell-disabled`, inThisMonth && {
|
|
156
156
|
[`${classPrefix}-cell-today`]: d.isSame(today, 'day'),
|
|
@@ -204,7 +204,14 @@ const Calendar = (0, _react.forwardRef)((p, ref) => {
|
|
|
204
204
|
className: `${classPrefix}-cell-top`
|
|
205
205
|
}, props.renderDate ? props.renderDate(d.toDate()) : d.date()), _react.default.createElement("div", {
|
|
206
206
|
className: `${classPrefix}-cell-bottom`
|
|
207
|
-
}, (_a = props.renderLabel) === null || _a === void 0 ? void 0 : _a.call(props, d.toDate())))
|
|
207
|
+
}, (_a = props.renderLabel) === null || _a === void 0 ? void 0 : _a.call(props, d.toDate())));
|
|
208
|
+
// Wrap with Fragment to ensure key is properly set
|
|
209
|
+
const cellWithKey = props.cellRender ? _react.default.createElement(_react.default.Fragment, {
|
|
210
|
+
key: d.valueOf()
|
|
211
|
+
}, props.cellRender(originalCell, {
|
|
212
|
+
date: d.toDate()
|
|
213
|
+
})) : originalCell;
|
|
214
|
+
cells.push(cellWithKey);
|
|
208
215
|
iterator = iterator.add(1, 'day');
|
|
209
216
|
}
|
|
210
217
|
return cells;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
2
|
import { NativeProps } from '../../utils/native-props';
|
|
3
3
|
import { Page } from './convert';
|
|
4
4
|
export declare type CalendarRef = {
|
|
@@ -14,6 +14,9 @@ export declare type CalendarProps = {
|
|
|
14
14
|
weekStartsOn?: 'Monday' | 'Sunday';
|
|
15
15
|
renderLabel?: (date: Date) => React.ReactNode;
|
|
16
16
|
renderDate?: (date: Date) => React.ReactNode;
|
|
17
|
+
cellRender?: (oriNode: React.ReactElement, info: {
|
|
18
|
+
date: Date;
|
|
19
|
+
}) => ReactNode;
|
|
17
20
|
allowClear?: boolean;
|
|
18
21
|
max?: Date;
|
|
19
22
|
min?: Date;
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { withNativeProps } from '../../utils/native-props';
|
|
3
|
-
import dayjs from 'dayjs';
|
|
1
|
+
import { useUpdateEffect } from 'ahooks';
|
|
4
2
|
import classNames from 'classnames';
|
|
3
|
+
import dayjs from 'dayjs';
|
|
4
|
+
import isoWeek from 'dayjs/plugin/isoWeek';
|
|
5
|
+
import React, { forwardRef, useEffect, useImperativeHandle, useMemo, useState } from 'react';
|
|
6
|
+
import { devWarning } from '../../utils/dev-log';
|
|
7
|
+
import { withNativeProps } from '../../utils/native-props';
|
|
8
|
+
import { replaceMessage } from '../../utils/replace-message';
|
|
9
|
+
import { usePropsValue } from '../../utils/use-props-value';
|
|
5
10
|
import { mergeProps } from '../../utils/with-default-props';
|
|
11
|
+
import { useConfig } from '../config-provider';
|
|
6
12
|
import { ArrowLeft } from './arrow-left';
|
|
7
13
|
import { ArrowLeftDouble } from './arrow-left-double';
|
|
8
|
-
import {
|
|
9
|
-
import isoWeek from 'dayjs/plugin/isoWeek';
|
|
10
|
-
import { useUpdateEffect } from 'ahooks';
|
|
11
|
-
import { usePropsValue } from '../../utils/use-props-value';
|
|
12
|
-
import { replaceMessage } from '../../utils/replace-message';
|
|
13
|
-
import { devWarning } from '../../utils/dev-log';
|
|
14
|
-
import { convertValueToRange, convertPageToDayjs } from './convert';
|
|
14
|
+
import { convertPageToDayjs, convertValueToRange } from './convert';
|
|
15
15
|
dayjs.extend(isoWeek);
|
|
16
16
|
const classPrefix = 'adm-calendar';
|
|
17
17
|
const defaultProps = {
|
|
@@ -141,7 +141,7 @@ export const Calendar = forwardRef((p, ref) => {
|
|
|
141
141
|
}
|
|
142
142
|
const inThisMonth = d.month() === current.month();
|
|
143
143
|
const disabled = props.shouldDisableDate ? props.shouldDisableDate(d.toDate()) : maxDay && d.isAfter(maxDay, 'day') || minDay && d.isBefore(minDay, 'day');
|
|
144
|
-
|
|
144
|
+
const originalCell = React.createElement("div", {
|
|
145
145
|
key: d.valueOf(),
|
|
146
146
|
className: classNames(`${classPrefix}-cell`, (disabled || !inThisMonth) && `${classPrefix}-cell-disabled`, inThisMonth && {
|
|
147
147
|
[`${classPrefix}-cell-today`]: d.isSame(today, 'day'),
|
|
@@ -195,7 +195,14 @@ export const Calendar = forwardRef((p, ref) => {
|
|
|
195
195
|
className: `${classPrefix}-cell-top`
|
|
196
196
|
}, props.renderDate ? props.renderDate(d.toDate()) : d.date()), React.createElement("div", {
|
|
197
197
|
className: `${classPrefix}-cell-bottom`
|
|
198
|
-
}, (_a = props.renderLabel) === null || _a === void 0 ? void 0 : _a.call(props, d.toDate())))
|
|
198
|
+
}, (_a = props.renderLabel) === null || _a === void 0 ? void 0 : _a.call(props, d.toDate())));
|
|
199
|
+
// Wrap with Fragment to ensure key is properly set
|
|
200
|
+
const cellWithKey = props.cellRender ? React.createElement(React.Fragment, {
|
|
201
|
+
key: d.valueOf()
|
|
202
|
+
}, props.cellRender(originalCell, {
|
|
203
|
+
date: d.toDate()
|
|
204
|
+
})) : originalCell;
|
|
205
|
+
cells.push(cellWithKey);
|
|
199
206
|
iterator = iterator.add(1, 'day');
|
|
200
207
|
}
|
|
201
208
|
return cells;
|