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.
@@ -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 _dayjs = _interopRequireDefault(require("dayjs"));
10
- var _classnames = _interopRequireDefault(require("classnames"));
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
- cells.push(_react.default.createElement("div", {
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 React, { forwardRef, useState, useImperativeHandle, useMemo, useEffect } from 'react';
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 { useConfig } from '../config-provider';
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
- cells.push(React.createElement("div", {
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;
package/2x/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "antd-mobile",
3
- "version": "5.41.0-alpha.0",
3
+ "version": "5.41.0-alpha.1",
4
4
  "homepage": "https://github.com/ant-design/ant-design-mobile#readme",
5
5
  "bugs": {
6
6
  "url": "https://github.com/ant-design/ant-design-mobile/issues"
@@ -9685,6 +9685,73 @@ const Button = React$2.forwardRef((p, ref2) => {
9685
9685
  className: `${classPrefix$1h}-loading-wrapper`
9686
9686
  }, props.loadingIcon, props.loadingText) : React$2.createElement("span", null, props.children)));
9687
9687
  });
9688
+ var isoWeek$1 = { exports: {} };
9689
+ (function(module2, exports2) {
9690
+ !function(e2, t) {
9691
+ module2.exports = t();
9692
+ }(commonjsGlobal, function() {
9693
+ var e2 = "day";
9694
+ return function(t, i2, s) {
9695
+ var a = function(t2) {
9696
+ return t2.add(4 - t2.isoWeekday(), e2);
9697
+ }, d = i2.prototype;
9698
+ d.isoWeekYear = function() {
9699
+ return a(this).year();
9700
+ }, d.isoWeek = function(t2) {
9701
+ if (!this.$utils().u(t2))
9702
+ return this.add(7 * (t2 - this.isoWeek()), e2);
9703
+ var i3, d2, n3, o, r = a(this), u = (i3 = this.isoWeekYear(), d2 = this.$u, n3 = (d2 ? s.utc : s)().year(i3).startOf("year"), o = 4 - n3.isoWeekday(), n3.isoWeekday() > 4 && (o += 7), n3.add(o, e2));
9704
+ return r.diff(u, "week") + 1;
9705
+ }, d.isoWeekday = function(e3) {
9706
+ return this.$utils().u(e3) ? this.day() || 7 : this.day(this.day() % 7 ? e3 : e3 - 7);
9707
+ };
9708
+ var n2 = d.startOf;
9709
+ d.startOf = function(e3, t2) {
9710
+ var i3 = this.$utils(), s2 = !!i3.u(t2) || t2;
9711
+ return "isoweek" === i3.p(e3) ? s2 ? this.date(this.date() - (this.isoWeekday() - 1)).startOf("day") : this.date(this.date() - 1 - (this.isoWeekday() - 1) + 7).endOf("day") : n2.bind(this)(e3, t2);
9712
+ };
9713
+ };
9714
+ });
9715
+ })(isoWeek$1);
9716
+ var isoWeekExports = isoWeek$1.exports;
9717
+ const isoWeek = /* @__PURE__ */ getDefaultExportFromCjs(isoWeekExports);
9718
+ function devWarning(component, message) {
9719
+ {
9720
+ console.warn(`[antd-mobile: ${component}] ${message}`);
9721
+ }
9722
+ }
9723
+ function devError(component, message) {
9724
+ {
9725
+ console.error(`[antd-mobile: ${component}] ${message}`);
9726
+ }
9727
+ }
9728
+ function replaceMessage$1(template, kv) {
9729
+ return template.replace(/\$\{\w+\}/g, (str) => {
9730
+ const key = str.slice(2, -1);
9731
+ return kv[key];
9732
+ });
9733
+ }
9734
+ function usePropsValue(options) {
9735
+ const {
9736
+ value,
9737
+ defaultValue,
9738
+ onChange
9739
+ } = options;
9740
+ const update2 = useUpdate$1();
9741
+ const stateRef = React$2.useRef(value !== void 0 ? value : defaultValue);
9742
+ if (value !== void 0) {
9743
+ stateRef.current = value;
9744
+ }
9745
+ const setState = useMemoizedFn((v, forceTrigger = false) => {
9746
+ const nextValue = typeof v === "function" ? v(stateRef.current) : v;
9747
+ if (!forceTrigger && nextValue === stateRef.current)
9748
+ return;
9749
+ stateRef.current = nextValue;
9750
+ update2();
9751
+ return onChange === null || onChange === void 0 ? void 0 : onChange(nextValue);
9752
+ });
9753
+ return [stateRef.current, setState];
9754
+ }
9688
9755
  const ArrowLeft = () => {
9689
9756
  return React$2.createElement("svg", {
9690
9757
  height: "1em",
@@ -9739,73 +9806,6 @@ const ArrowLeftDouble = () => {
9739
9806
  d: "M19.5305114,17.0699744 C19.0173831,17.5315665 18.9752295,18.3220903 19.436308,18.8357433 C19.4660129,18.8688164 19.4974585,18.9002801 19.5305113,18.9300007 L29.4833057,27.2801611 C30.1234001,27.8559077 30.1759552,28.8420707 29.6007967,29.4827774 C29.0256382,30.1235263 28.0404824,30.1761351 27.400388,29.6003885 L17.4475937,21.2502703 C17.3320874,21.1463692 17.2222026,21.036372 17.1184079,20.920748 C15.5069703,19.1256817 15.6543605,16.3628317 17.4475933,14.7497465 L27.4003877,6.39962828 C28.0404821,5.82383957 29.0256378,5.87649058 29.6007963,6.51723942 C30.1759548,7.1579461 30.1233997,8.14410915 29.4833053,8.7198557 L19.5305114,17.0699744 Z"
9740
9807
  }))))));
9741
9808
  };
9742
- var isoWeek$1 = { exports: {} };
9743
- (function(module2, exports2) {
9744
- !function(e2, t) {
9745
- module2.exports = t();
9746
- }(commonjsGlobal, function() {
9747
- var e2 = "day";
9748
- return function(t, i2, s) {
9749
- var a = function(t2) {
9750
- return t2.add(4 - t2.isoWeekday(), e2);
9751
- }, d = i2.prototype;
9752
- d.isoWeekYear = function() {
9753
- return a(this).year();
9754
- }, d.isoWeek = function(t2) {
9755
- if (!this.$utils().u(t2))
9756
- return this.add(7 * (t2 - this.isoWeek()), e2);
9757
- var i3, d2, n3, o, r = a(this), u = (i3 = this.isoWeekYear(), d2 = this.$u, n3 = (d2 ? s.utc : s)().year(i3).startOf("year"), o = 4 - n3.isoWeekday(), n3.isoWeekday() > 4 && (o += 7), n3.add(o, e2));
9758
- return r.diff(u, "week") + 1;
9759
- }, d.isoWeekday = function(e3) {
9760
- return this.$utils().u(e3) ? this.day() || 7 : this.day(this.day() % 7 ? e3 : e3 - 7);
9761
- };
9762
- var n2 = d.startOf;
9763
- d.startOf = function(e3, t2) {
9764
- var i3 = this.$utils(), s2 = !!i3.u(t2) || t2;
9765
- return "isoweek" === i3.p(e3) ? s2 ? this.date(this.date() - (this.isoWeekday() - 1)).startOf("day") : this.date(this.date() - 1 - (this.isoWeekday() - 1) + 7).endOf("day") : n2.bind(this)(e3, t2);
9766
- };
9767
- };
9768
- });
9769
- })(isoWeek$1);
9770
- var isoWeekExports = isoWeek$1.exports;
9771
- const isoWeek = /* @__PURE__ */ getDefaultExportFromCjs(isoWeekExports);
9772
- function usePropsValue(options) {
9773
- const {
9774
- value,
9775
- defaultValue,
9776
- onChange
9777
- } = options;
9778
- const update2 = useUpdate$1();
9779
- const stateRef = React$2.useRef(value !== void 0 ? value : defaultValue);
9780
- if (value !== void 0) {
9781
- stateRef.current = value;
9782
- }
9783
- const setState = useMemoizedFn((v, forceTrigger = false) => {
9784
- const nextValue = typeof v === "function" ? v(stateRef.current) : v;
9785
- if (!forceTrigger && nextValue === stateRef.current)
9786
- return;
9787
- stateRef.current = nextValue;
9788
- update2();
9789
- return onChange === null || onChange === void 0 ? void 0 : onChange(nextValue);
9790
- });
9791
- return [stateRef.current, setState];
9792
- }
9793
- function replaceMessage$1(template, kv) {
9794
- return template.replace(/\$\{\w+\}/g, (str) => {
9795
- const key = str.slice(2, -1);
9796
- return kv[key];
9797
- });
9798
- }
9799
- function devWarning(component, message) {
9800
- {
9801
- console.warn(`[antd-mobile: ${component}] ${message}`);
9802
- }
9803
- }
9804
- function devError(component, message) {
9805
- {
9806
- console.error(`[antd-mobile: ${component}] ${message}`);
9807
- }
9808
- }
9809
9809
  function convertValueToRange$1(selectionMode, value) {
9810
9810
  if (selectionMode === void 0 || value === null)
9811
9811
  return null;
@@ -9947,7 +9947,7 @@ const Calendar = React$2.forwardRef((p, ref2) => {
9947
9947
  }
9948
9948
  const inThisMonth = d.month() === current.month();
9949
9949
  const disabled = props.shouldDisableDate ? props.shouldDisableDate(d.toDate()) : maxDay && d.isAfter(maxDay, "day") || minDay && d.isBefore(minDay, "day");
9950
- cells.push(React$2.createElement("div", {
9950
+ const originalCell = React$2.createElement("div", {
9951
9951
  key: d.valueOf(),
9952
9952
  className: classNames(`${classPrefix$1g}-cell`, (disabled || !inThisMonth) && `${classPrefix$1g}-cell-disabled`, inThisMonth && {
9953
9953
  [`${classPrefix$1g}-cell-today`]: d.isSame(today, "day"),
@@ -10005,7 +10005,13 @@ const Calendar = React$2.forwardRef((p, ref2) => {
10005
10005
  className: `${classPrefix$1g}-cell-top`
10006
10006
  }, props.renderDate ? props.renderDate(d.toDate()) : d.date()), React$2.createElement("div", {
10007
10007
  className: `${classPrefix$1g}-cell-bottom`
10008
- }, (_a = props.renderLabel) === null || _a === void 0 ? void 0 : _a.call(props, d.toDate()))));
10008
+ }, (_a = props.renderLabel) === null || _a === void 0 ? void 0 : _a.call(props, d.toDate())));
10009
+ const cellWithKey = props.cellRender ? React$2.createElement(React$2.Fragment, {
10010
+ key: d.valueOf()
10011
+ }, props.cellRender(originalCell, {
10012
+ date: d.toDate()
10013
+ })) : originalCell;
10014
+ cells.push(cellWithKey);
10009
10015
  iterator = iterator.add(1, "day");
10010
10016
  }
10011
10017
  return cells;