antd-mobile 5.0.0-rc.25 → 5.0.0-rc.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. package/2x/cjs/components/button/button.css +2 -2
  2. package/2x/cjs/components/calendar/calendar.js +3 -1
  3. package/2x/cjs/components/ellipsis/ellipsis.js +3 -1
  4. package/2x/cjs/components/floating-panel/floating-panel.d.ts +7 -5
  5. package/2x/cjs/components/floating-panel/floating-panel.js +11 -1
  6. package/2x/cjs/components/form/form-item.d.ts +1 -1
  7. package/2x/cjs/components/image-uploader/image-uploader.js +1 -1
  8. package/2x/cjs/components/image-viewer/image-viewer.js +12 -2
  9. package/2x/cjs/components/image-viewer/slide.js +2 -1
  10. package/2x/cjs/components/image-viewer/slides.d.ts +1 -1
  11. package/2x/cjs/components/input/input.js +4 -2
  12. package/2x/cjs/components/picker-view/wheel.js +4 -2
  13. package/2x/cjs/components/selector/selector.css +14 -6
  14. package/2x/cjs/components/selector/selector.d.ts +2 -1
  15. package/2x/cjs/components/selector/selector.js +3 -2
  16. package/2x/cjs/components/swiper/swiper.js +1 -1
  17. package/2x/cjs/components/tabs/tabs.js +2 -2
  18. package/2x/cjs/components/virtual-input/virtual-input.js +3 -1
  19. package/2x/cjs/utils/get-scroll-parent.js +1 -1
  20. package/2x/cjs/utils/use-ref-state.js +1 -1
  21. package/2x/cjs/utils/use-resize-effect.js +1 -3
  22. package/2x/cjs/utils/use-tab-list-scroll.js +1 -3
  23. package/2x/es/components/button/button.css +2 -2
  24. package/2x/es/components/calendar/calendar.js +3 -2
  25. package/2x/es/components/ellipsis/ellipsis.js +3 -2
  26. package/2x/es/components/floating-panel/floating-panel.d.ts +7 -5
  27. package/2x/es/components/floating-panel/floating-panel.js +9 -1
  28. package/2x/es/components/form/form-item.d.ts +1 -1
  29. package/2x/es/components/image-uploader/image-uploader.js +3 -3
  30. package/2x/es/components/image-viewer/image-viewer.js +13 -3
  31. package/2x/es/components/image-viewer/slide.js +2 -1
  32. package/2x/es/components/image-viewer/slides.d.ts +1 -1
  33. package/2x/es/components/input/input.js +4 -3
  34. package/2x/es/components/picker-view/wheel.js +4 -3
  35. package/2x/es/components/selector/selector.css +14 -6
  36. package/2x/es/components/selector/selector.d.ts +2 -1
  37. package/2x/es/components/selector/selector.js +3 -2
  38. package/2x/es/components/swiper/swiper.js +3 -3
  39. package/2x/es/components/tabs/tabs.js +4 -4
  40. package/2x/es/components/virtual-input/virtual-input.js +3 -2
  41. package/2x/es/utils/get-scroll-parent.js +1 -1
  42. package/2x/es/utils/use-ref-state.js +2 -2
  43. package/2x/es/utils/use-resize-effect.js +2 -3
  44. package/2x/es/utils/use-tab-list-scroll.js +2 -3
  45. package/2x/package.json +3 -3
  46. package/cjs/components/button/button.css +2 -2
  47. package/cjs/components/calendar/calendar.js +3 -1
  48. package/cjs/components/ellipsis/ellipsis.js +3 -1
  49. package/cjs/components/floating-panel/floating-panel.d.ts +7 -5
  50. package/cjs/components/floating-panel/floating-panel.js +11 -1
  51. package/cjs/components/form/form-item.d.ts +1 -1
  52. package/cjs/components/image-uploader/image-uploader.js +1 -1
  53. package/cjs/components/image-viewer/image-viewer.js +12 -2
  54. package/cjs/components/image-viewer/slide.js +2 -1
  55. package/cjs/components/image-viewer/slides.d.ts +1 -1
  56. package/cjs/components/input/input.js +4 -2
  57. package/cjs/components/picker-view/wheel.js +4 -2
  58. package/cjs/components/selector/selector.css +14 -6
  59. package/cjs/components/selector/selector.d.ts +2 -1
  60. package/cjs/components/selector/selector.js +3 -2
  61. package/cjs/components/swiper/swiper.js +1 -1
  62. package/cjs/components/tabs/tabs.js +2 -2
  63. package/cjs/components/virtual-input/virtual-input.js +3 -1
  64. package/cjs/utils/get-scroll-parent.js +1 -1
  65. package/cjs/utils/use-ref-state.js +1 -1
  66. package/cjs/utils/use-resize-effect.js +1 -3
  67. package/cjs/utils/use-tab-list-scroll.js +1 -3
  68. package/es/components/button/button.css +2 -2
  69. package/es/components/calendar/calendar.js +3 -2
  70. package/es/components/ellipsis/ellipsis.js +3 -2
  71. package/es/components/floating-panel/floating-panel.d.ts +7 -5
  72. package/es/components/floating-panel/floating-panel.js +9 -1
  73. package/es/components/form/form-item.d.ts +1 -1
  74. package/es/components/image-uploader/image-uploader.js +3 -3
  75. package/es/components/image-viewer/image-viewer.js +13 -3
  76. package/es/components/image-viewer/slide.js +2 -1
  77. package/es/components/image-viewer/slides.d.ts +1 -1
  78. package/es/components/input/input.js +4 -3
  79. package/es/components/picker-view/wheel.js +4 -3
  80. package/es/components/selector/selector.css +14 -6
  81. package/es/components/selector/selector.d.ts +2 -1
  82. package/es/components/selector/selector.js +3 -2
  83. package/es/components/swiper/swiper.js +3 -3
  84. package/es/components/tabs/tabs.js +4 -4
  85. package/es/components/virtual-input/virtual-input.js +3 -2
  86. package/es/utils/get-scroll-parent.js +1 -1
  87. package/es/utils/use-ref-state.js +2 -2
  88. package/es/utils/use-resize-effect.js +2 -3
  89. package/es/utils/use-tab-list-scroll.js +2 -3
  90. package/package.json +3 -3
  91. package/umd/antd-mobile.js +1 -1
@@ -1,9 +1,10 @@
1
- import React, { useState, forwardRef, useImperativeHandle, useRef, useLayoutEffect } from 'react';
1
+ import React, { useState, forwardRef, useImperativeHandle, useRef } from 'react';
2
2
  import { usePropsValue } from '../../utils/use-props-value';
3
3
  import { CloseCircleFill } from 'antd-mobile-icons';
4
4
  import { withNativeProps } from '../../utils/native-props';
5
5
  import { mergeProps } from '../../utils/with-default-props';
6
6
  import classNames from 'classnames';
7
+ import { useIsomorphicLayoutEffect } from 'ahooks';
7
8
  const classPrefix = `adm-input`;
8
9
  const defaultProps = {
9
10
  defaultValue: ''
@@ -39,7 +40,7 @@ export const Input = forwardRef((p, ref) => {
39
40
  (_a = props.onKeyDown) === null || _a === void 0 ? void 0 : _a.call(props, e);
40
41
  };
41
42
 
42
- useLayoutEffect(() => {
43
+ useIsomorphicLayoutEffect(() => {
43
44
  var _a;
44
45
 
45
46
  if (!props.enterKeyHint) return;
@@ -89,7 +90,7 @@ export const Input = forwardRef((p, ref) => {
89
90
  onKeyUp: props.onKeyUp,
90
91
  onCompositionStart: props.onCompositionStart,
91
92
  onCompositionEnd: props.onCompositionEnd
92
- }), props.clearable && !!value && React.createElement("div", {
93
+ }), props.clearable && !!value && !props.readOnly && React.createElement("div", {
93
94
  className: `${classPrefix}-clear`,
94
95
  onMouseDown: e => {
95
96
  e.preventDefault();
@@ -1,10 +1,11 @@
1
- import React, { memo, useLayoutEffect, useRef } from 'react';
1
+ import React, { memo, useRef } from 'react';
2
2
  import { useSpring, animated } from '@react-spring/web';
3
3
  import { useDrag } from '@use-gesture/react';
4
4
  import { convertPx } from '../../utils/convert-px';
5
5
  import { rubberbandIfOutOfBounds } from '../../utils/rubberband';
6
6
  import { bound } from '../../utils/bound';
7
7
  import isEqual from 'lodash/isEqual';
8
+ import { useIsomorphicLayoutEffect } from 'ahooks';
8
9
  const classPrefix = `adm-picker-view`;
9
10
  export const Wheel = memo(props => {
10
11
  const itemHeight = convertPx(34);
@@ -29,7 +30,7 @@ export const Wheel = memo(props => {
29
30
  }
30
31
  }));
31
32
  const draggingRef = useRef(false);
32
- useLayoutEffect(() => {
33
+ useIsomorphicLayoutEffect(() => {
33
34
  if (draggingRef.current) return;
34
35
  if (!value) return;
35
36
  const targetIndex = column.findIndex(item => item.value === value);
@@ -40,7 +41,7 @@ export const Wheel = memo(props => {
40
41
  immediate: y.goal !== finalPosition
41
42
  });
42
43
  }, [value, column]);
43
- useLayoutEffect(() => {
44
+ useIsomorphicLayoutEffect(() => {
44
45
  if (column.length === 0) {
45
46
  if (value !== null) {
46
47
  onSelect(null);
@@ -1,6 +1,12 @@
1
1
  .adm-selector {
2
- --color: var(--adm-color-text);
2
+ --color: #f5f5f5;
3
3
  --checked-color: #e7f1ff;
4
+ --text-color: var(--adm-color-text);
5
+ --checked-text-color: var(--adm-color-primary);
6
+ --border: none;
7
+ --checked-border: none;
8
+ --border-radius: 4px;
9
+ --padding: 16px 32px;
4
10
  overflow: hidden;
5
11
  font-size: 30px;
6
12
  line-height: 1.4;
@@ -11,11 +17,12 @@
11
17
  }
12
18
 
13
19
  .adm-selector-item {
14
- padding: 16px 32px;
20
+ padding: var(--padding);
15
21
  position: relative;
16
- background-color: #f5f5f5;
17
- border-radius: 4px;
18
- color: #333;
22
+ background-color: var(--color);
23
+ border: var(--border);
24
+ border-radius: var(--border-radius);
25
+ color: var(--text-color);
19
26
  opacity: 1;
20
27
  cursor: pointer;
21
28
  display: inline-block;
@@ -31,8 +38,9 @@
31
38
 
32
39
  .adm-selector-item-active,
33
40
  .adm-selector-item-multiple-active {
34
- color: var(--adm-color-primary);
41
+ color: var(--checked-text-color);
35
42
  background-color: var(--checked-color);
43
+ border: var(--checked-border);
36
44
  }
37
45
 
38
46
  .adm-selector-item .adm-selector-check-mark-wrapper {
@@ -16,5 +16,6 @@ export declare type SelectorProps<V> = {
16
16
  onChange?: (v: V[], extend: {
17
17
  items: SelectorOption<V>[];
18
18
  }) => void;
19
- } & NativeProps<'--checked-color'>;
19
+ showCheckMark?: boolean;
20
+ } & NativeProps<'--color' | '--checked-color' | '--text-color' | '--checked-text-color' | '--border' | '--checked-border' | '--border-radius' | '--padding'>;
20
21
  export declare const Selector: <V extends string | number>(p: SelectorProps<V>) => React.ReactElement<any, string | ((props: any) => React.ReactElement<any, any> | null) | (new (props: any) => React.Component<any, any, any>)>;
@@ -10,7 +10,8 @@ import { CheckMark } from './check-mark';
10
10
  const classPrefix = `adm-selector`;
11
11
  const defaultProps = {
12
12
  multiple: false,
13
- defaultValue: []
13
+ defaultValue: [],
14
+ showCheckMark: true
14
15
  };
15
16
  export const Selector = p => {
16
17
  const props = mergeProps(defaultProps, p);
@@ -55,7 +56,7 @@ export const Selector = p => {
55
56
  }
56
57
  }, option.label, option.description && React.createElement("div", {
57
58
  className: `${classPrefix}-item-description`
58
- }, option.description), active && React.createElement("div", {
59
+ }, option.description), active && props.showCheckMark && React.createElement("div", {
59
60
  className: `${classPrefix}-check-mark-wrapper`
60
61
  }, React.createElement(CheckMark, null)));
61
62
  });
@@ -1,4 +1,4 @@
1
- import React, { forwardRef, useEffect, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState } from 'react';
1
+ import React, { forwardRef, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
2
2
  import { withNativeProps } from '../../utils/native-props';
3
3
  import { mergeProps } from '../../utils/with-default-props';
4
4
  import classNames from 'classnames';
@@ -10,7 +10,7 @@ import PageIndicator from '../page-indicator';
10
10
  import { staged } from 'staged-components';
11
11
  import { useRefState } from '../../utils/use-ref-state';
12
12
  import { bound } from '../../utils/bound';
13
- import { useUpdateEffect } from 'ahooks';
13
+ import { useIsomorphicLayoutEffect, useUpdateEffect } from 'ahooks';
14
14
  const defaultProps = {
15
15
  defaultIndex: 0,
16
16
  allowTouchMove: true,
@@ -184,7 +184,7 @@ export const Swiper = forwardRef(staged((p, ref) => {
184
184
  swipeNext,
185
185
  swipePrev
186
186
  }));
187
- useLayoutEffect(() => {
187
+ useIsomorphicLayoutEffect(() => {
188
188
  const maxIndex = validChildren.length - 1;
189
189
 
190
190
  if (current > maxIndex) {
@@ -1,10 +1,10 @@
1
- import React, { useRef, useLayoutEffect } from 'react';
1
+ import React, { useRef } from 'react';
2
2
  import classNames from 'classnames';
3
3
  import { useSpring, animated } from '@react-spring/web';
4
4
  import { withNativeProps } from '../../utils/native-props';
5
5
  import { usePropsValue } from '../../utils/use-props-value';
6
6
  import { bound } from '../../utils/bound';
7
- import { useUpdateLayoutEffect, useThrottleFn } from 'ahooks';
7
+ import { useUpdateLayoutEffect, useThrottleFn, useIsomorphicLayoutEffect } from 'ahooks';
8
8
  import { useMutationEffect } from '../../utils/use-mutation-effect';
9
9
  import { useResizeEffect } from '../../utils/use-resize-effect';
10
10
  import { mergeProps } from '../../utils/with-default-props';
@@ -134,7 +134,7 @@ export const Tabs = p => {
134
134
  });
135
135
  }
136
136
 
137
- useLayoutEffect(() => {
137
+ useIsomorphicLayoutEffect(() => {
138
138
  animate(true);
139
139
  }, []);
140
140
  useUpdateLayoutEffect(() => {
@@ -168,7 +168,7 @@ export const Tabs = p => {
168
168
  trailing: true,
169
169
  leading: true
170
170
  });
171
- useLayoutEffect(() => {
171
+ useIsomorphicLayoutEffect(() => {
172
172
  updateMask(true);
173
173
  }, []);
174
174
  return withNativeProps(props, React.createElement("div", {
@@ -1,9 +1,10 @@
1
- import React, { forwardRef, useEffect, useImperativeHandle, useLayoutEffect, useRef, useState } from 'react';
1
+ import React, { forwardRef, useEffect, useImperativeHandle, useRef, useState } from 'react';
2
2
  import { withNativeProps } from '../../utils/native-props';
3
3
  import { mergeProps } from '../../utils/with-default-props';
4
4
  import { usePropsValue } from '../../utils/use-props-value';
5
5
  import classNames from 'classnames';
6
6
  import { CloseCircleFill } from 'antd-mobile-icons';
7
+ import { useIsomorphicLayoutEffect } from 'ahooks';
7
8
  const classPrefix = 'adm-virtual-input';
8
9
  const defaultProps = {
9
10
  defaultValue: ''
@@ -28,7 +29,7 @@ export const VirtualInput = forwardRef((p, ref) => {
28
29
  content.scrollLeft = content.clientWidth;
29
30
  }
30
31
 
31
- useLayoutEffect(() => {
32
+ useIsomorphicLayoutEffect(() => {
32
33
  scrollToEnd();
33
34
  }, [value]);
34
35
  useEffect(() => {
@@ -4,7 +4,7 @@ const defaultRoot = canUseDom ? window : undefined;
4
4
 
5
5
  function isElement(node) {
6
6
  const ELEMENT_NODE_TYPE = 1;
7
- return node.tagName !== 'HTML' && node.tagName !== 'BODY' && node.nodeType === ELEMENT_NODE_TYPE;
7
+ return node.nodeType === ELEMENT_NODE_TYPE;
8
8
  } // https://github.com/youzan/vant/issues/3823
9
9
 
10
10
 
@@ -1,8 +1,8 @@
1
- import { useLayoutEffect, useRef, useState } from 'react';
1
+ import { useEffect, useRef, useState } from 'react';
2
2
  export function useRefState(initialState) {
3
3
  const [state, setState] = useState(initialState);
4
4
  const ref = useRef(state);
5
- useLayoutEffect(() => {
5
+ useEffect(() => {
6
6
  ref.current = state;
7
7
  }, [state]);
8
8
  return [state, setState, ref];
@@ -1,8 +1,7 @@
1
- import { useLayoutEffect } from 'react';
2
- import { useMemoizedFn } from 'ahooks';
1
+ import { useIsomorphicLayoutEffect, useMemoizedFn } from 'ahooks';
3
2
  export function useResizeEffect(effect, targetRef) {
4
3
  const fn = useMemoizedFn(effect);
5
- useLayoutEffect(() => {
4
+ useIsomorphicLayoutEffect(() => {
6
5
  const target = targetRef.current;
7
6
  if (!target) return;
8
7
 
@@ -1,8 +1,7 @@
1
- import { useLayoutEffect } from 'react';
2
1
  import { useSpring } from '@react-spring/web';
3
2
  import { useMutationEffect } from './use-mutation-effect';
4
3
  import { bound } from './bound';
5
- import { useUpdateLayoutEffect } from 'ahooks';
4
+ import { useIsomorphicLayoutEffect, useUpdateLayoutEffect } from 'ahooks';
6
5
  export const useTabListScroll = (targetRef, activeIndex) => {
7
6
  const [{
8
7
  scrollLeft
@@ -37,7 +36,7 @@ export const useTabListScroll = (targetRef, activeIndex) => {
37
36
  });
38
37
  }
39
38
 
40
- useLayoutEffect(() => {
39
+ useIsomorphicLayoutEffect(() => {
41
40
  animate(true);
42
41
  }, []);
43
42
  useUpdateLayoutEffect(() => {
package/2x/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "antd-mobile",
3
- "version": "5.0.0-rc.25",
3
+ "version": "5.0.0-rc.26",
4
4
  "dependencies": {
5
5
  "@react-spring/web": "^9.4.2",
6
- "@types/resize-observer-browser": "^0.1.6",
7
- "@use-gesture/react": "^10.2.4",
6
+ "@types/resize-observer-browser": "^0.1.7",
7
+ "@use-gesture/react": "^10.2.5",
8
8
  "ahooks": "^3.1.9",
9
9
  "antd-mobile-icons": "^0.2.2",
10
10
  "antd-mobile-v5-count": "^1.0.1",
@@ -12,9 +12,9 @@
12
12
  display: inline-block;
13
13
  box-sizing: border-box;
14
14
  height: auto;
15
- padding: 8px 12px;
15
+ padding: 7px 12px;
16
16
  margin: 0;
17
- font-size: 15px;
17
+ font-size: 17px;
18
18
  line-height: 1.4;
19
19
  text-align: center;
20
20
  border: var(--border-width) var(--border-style) var(--border-color);
@@ -23,6 +23,8 @@ var _configProvider = require("../config-provider");
23
23
 
24
24
  var _isoWeek = _interopRequireDefault(require("dayjs/plugin/isoWeek"));
25
25
 
26
+ var _ahooks = require("ahooks");
27
+
26
28
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
27
29
 
28
30
  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); }
@@ -91,7 +93,7 @@ const Calendar = p => {
91
93
  }, [props.selectionMode, props.value, props.defaultValue]);
92
94
  const [begin, setBegin] = (0, _react.useState)(null);
93
95
  const [end, setEnd] = (0, _react.useState)(null);
94
- (0, _react.useLayoutEffect)(() => {
96
+ (0, _ahooks.useIsomorphicLayoutEffect)(() => {
95
97
  setBegin(dateRange[0] ? (0, _dayjs.default)(dateRange[0]) : null);
96
98
  setEnd(dateRange[1] ? (0, _dayjs.default)(dateRange[1]) : null);
97
99
  }, [dateRange[0], dateRange[1]]);
@@ -13,6 +13,8 @@ var _nativeProps = require("../../utils/native-props");
13
13
 
14
14
  var _useResizeEffect = require("../../utils/use-resize-effect");
15
15
 
16
+ var _ahooks = require("ahooks");
17
+
16
18
  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); }
17
19
 
18
20
  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; }
@@ -129,7 +131,7 @@ const Ellipsis = p => {
129
131
  }
130
132
 
131
133
  (0, _useResizeEffect.useResizeEffect)(calcEllipsised, rootRef);
132
- (0, _react.useLayoutEffect)(() => {
134
+ (0, _ahooks.useIsomorphicLayoutEffect)(() => {
133
135
  calcEllipsised();
134
136
  }, [props.content, props.direction, props.rows, props.expandText, props.collapseText]);
135
137
  const expandActionElement = exceeded && props.expandText ? _react.default.createElement("a", {
@@ -1,17 +1,19 @@
1
1
  import React, { ReactNode } from 'react';
2
2
  import { NativeProps } from '../../utils/native-props';
3
- export declare type FloatingPanelProps = {
4
- anchors: number[];
5
- children: ReactNode;
6
- onHeightChange?: (height: number, animating: boolean) => void;
7
- } & NativeProps<'--border-radius' | '--z-index'>;
8
3
  export declare type FloatingPanelRef = {
9
4
  setHeight: (height: number, options?: {
10
5
  immediate?: boolean;
11
6
  }) => void;
12
7
  };
8
+ export declare type FloatingPanelProps = {
9
+ anchors: number[];
10
+ children: ReactNode;
11
+ onHeightChange?: (height: number, animating: boolean) => void;
12
+ handleDraggingOfContent?: boolean;
13
+ } & NativeProps<'--border-radius' | '--z-index'>;
13
14
  export declare const FloatingPanel: React.ForwardRefExoticComponent<{
14
15
  anchors: number[];
15
16
  children: ReactNode;
16
17
  onHeightChange?: ((height: number, animating: boolean) => void) | undefined;
18
+ handleDraggingOfContent?: boolean | undefined;
17
19
  } & NativeProps<"--z-index" | "--border-radius"> & React.RefAttributes<FloatingPanelRef>>;
@@ -17,13 +17,21 @@ var _supportsPassive = require("../../utils/supports-passive");
17
17
 
18
18
  var _nearest = require("../../utils/nearest");
19
19
 
20
+ var _withDefaultProps = require("../../utils/with-default-props");
21
+
22
+ var _useLockScroll = require("../../utils/use-lock-scroll");
23
+
20
24
  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); }
21
25
 
22
26
  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
27
 
24
- const FloatingPanel = (0, _react.forwardRef)((props, ref) => {
28
+ const defaultProps = {
29
+ handleDraggingOfContent: true
30
+ };
31
+ const FloatingPanel = (0, _react.forwardRef)((p, ref) => {
25
32
  var _a;
26
33
 
34
+ const props = (0, _withDefaultProps.mergeProps)(defaultProps, p);
27
35
  const {
28
36
  anchors
29
37
  } = props;
@@ -61,6 +69,7 @@ const FloatingPanel = (0, _react.forwardRef)((props, ref) => {
61
69
  if (header === target || (header === null || header === void 0 ? void 0 : header.contains(target))) {
62
70
  pullingRef.current = true;
63
71
  } else {
72
+ if (!props.handleDraggingOfContent) return;
64
73
  const reachedTop = y.goal <= bounds.top;
65
74
  const content = contentRef.current;
66
75
  if (!content) return;
@@ -118,6 +127,7 @@ const FloatingPanel = (0, _react.forwardRef)((props, ref) => {
118
127
  });
119
128
  }
120
129
  }), [api]);
130
+ (0, _useLockScroll.useLockScroll)(elementRef, true);
121
131
  return (0, _nativeProps.withNativeProps)(props, _react.default.createElement(_web.animated.div, {
122
132
  ref: elementRef,
123
133
  className: 'adm-floating-panel',
@@ -7,7 +7,7 @@ import type { FormLayout } from './index';
7
7
  declare type RenderChildren<Values = any> = (form: FormInstance<Values>) => React.ReactNode;
8
8
  declare type ChildrenType<Values = any> = RenderChildren<Values> | React.ReactNode;
9
9
  declare type RcFieldProps = Omit<FieldProps, 'children'>;
10
- export declare type FormItemProps = Pick<RcFieldProps, 'dependencies' | 'valuePropName' | 'name' | 'rules' | 'messageVariables' | 'trigger' | 'validateTrigger' | 'shouldUpdate'> & Pick<ListItemProps, 'style' | 'onClick' | 'extra' | 'arrow'> & {
10
+ export declare type FormItemProps = Pick<RcFieldProps, 'dependencies' | 'valuePropName' | 'name' | 'rules' | 'messageVariables' | 'trigger' | 'validateTrigger' | 'shouldUpdate' | 'initialValue'> & Pick<ListItemProps, 'style' | 'onClick' | 'extra' | 'arrow'> & {
11
11
  label?: React.ReactNode;
12
12
  help?: React.ReactNode;
13
13
  hasFeedback?: boolean;
@@ -50,7 +50,7 @@ const ImageUploader = p => {
50
50
  setValue(updater(value));
51
51
  });
52
52
  const [tasks, setTasks] = (0, _react.useState)([]);
53
- (0, _react.useLayoutEffect)(() => {
53
+ (0, _ahooks.useIsomorphicLayoutEffect)(() => {
54
54
  setTasks(prev => prev.filter(task => {
55
55
  if (task.url === undefined) return true;
56
56
  return !value.some(fileItem => fileItem.url === task.url);
@@ -59,6 +59,16 @@ const multiDefaultProps = Object.assign(Object.assign({}, defaultProps), {
59
59
  });
60
60
  const MultiImageViewer = (0, _react.forwardRef)((p, ref) => {
61
61
  const props = (0, _withDefaultProps.mergeProps)(multiDefaultProps, p);
62
+ const [defaultIndex, setDefaultIndex] = (0, _react.useState)(props.defaultIndex);
63
+ const slidesRef = (0, _react.useRef)(null);
64
+ (0, _react.useImperativeHandle)(ref, () => ({
65
+ swipeTo: (index, immediate) => {
66
+ var _a;
67
+
68
+ setDefaultIndex(index);
69
+ (_a = slidesRef.current) === null || _a === void 0 ? void 0 : _a.swipeTo(index, immediate);
70
+ }
71
+ }));
62
72
 
63
73
  const node = _react.default.createElement(_mask.default, {
64
74
  visible: props.visible,
@@ -68,8 +78,8 @@ const MultiImageViewer = (0, _react.forwardRef)((p, ref) => {
68
78
  }, _react.default.createElement("div", {
69
79
  className: `${classPrefix}-content`
70
80
  }, props.images && _react.default.createElement(_slides.Slides, {
71
- ref: ref,
72
- defaultIndex: props.defaultIndex,
81
+ ref: slidesRef,
82
+ defaultIndex: defaultIndex,
73
83
  onIndexChange: props.onIndexChange,
74
84
  images: props.images,
75
85
  onTap: () => {
@@ -124,7 +124,8 @@ const Slide = props => {
124
124
  }
125
125
  }, _react.default.createElement("img", {
126
126
  src: props.image,
127
- draggable: false
127
+ draggable: false,
128
+ alt: props.image
128
129
  }))));
129
130
  };
130
131
 
@@ -7,6 +7,6 @@ export declare type SlidesType = {
7
7
  onIndexChange?: (index: number) => void;
8
8
  };
9
9
  export declare type SlidesRef = {
10
- swipeTo: (index: number, immediate: boolean) => void;
10
+ swipeTo: (index: number, immediate?: boolean) => void;
11
11
  };
12
12
  export declare const Slides: React.ForwardRefExoticComponent<SlidesType & React.RefAttributes<SlidesRef>>;
@@ -17,6 +17,8 @@ var _withDefaultProps = require("../../utils/with-default-props");
17
17
 
18
18
  var _classnames = _interopRequireDefault(require("classnames"));
19
19
 
20
+ var _ahooks = require("ahooks");
21
+
20
22
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
23
 
22
24
  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); }
@@ -58,7 +60,7 @@ const Input = (0, _react.forwardRef)((p, ref) => {
58
60
  (_a = props.onKeyDown) === null || _a === void 0 ? void 0 : _a.call(props, e);
59
61
  };
60
62
 
61
- (0, _react.useLayoutEffect)(() => {
63
+ (0, _ahooks.useIsomorphicLayoutEffect)(() => {
62
64
  var _a;
63
65
 
64
66
  if (!props.enterKeyHint) return;
@@ -108,7 +110,7 @@ const Input = (0, _react.forwardRef)((p, ref) => {
108
110
  onKeyUp: props.onKeyUp,
109
111
  onCompositionStart: props.onCompositionStart,
110
112
  onCompositionEnd: props.onCompositionEnd
111
- }), props.clearable && !!value && _react.default.createElement("div", {
113
+ }), props.clearable && !!value && !props.readOnly && _react.default.createElement("div", {
112
114
  className: `${classPrefix}-clear`,
113
115
  onMouseDown: e => {
114
116
  e.preventDefault();
@@ -19,6 +19,8 @@ var _bound = require("../../utils/bound");
19
19
 
20
20
  var _isEqual = _interopRequireDefault(require("lodash/isEqual"));
21
21
 
22
+ var _ahooks = require("ahooks");
23
+
22
24
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
23
25
 
24
26
  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); }
@@ -49,7 +51,7 @@ const Wheel = (0, _react.memo)(props => {
49
51
  }
50
52
  }));
51
53
  const draggingRef = (0, _react.useRef)(false);
52
- (0, _react.useLayoutEffect)(() => {
54
+ (0, _ahooks.useIsomorphicLayoutEffect)(() => {
53
55
  if (draggingRef.current) return;
54
56
  if (!value) return;
55
57
  const targetIndex = column.findIndex(item => item.value === value);
@@ -60,7 +62,7 @@ const Wheel = (0, _react.memo)(props => {
60
62
  immediate: y.goal !== finalPosition
61
63
  });
62
64
  }, [value, column]);
63
- (0, _react.useLayoutEffect)(() => {
65
+ (0, _ahooks.useIsomorphicLayoutEffect)(() => {
64
66
  if (column.length === 0) {
65
67
  if (value !== null) {
66
68
  onSelect(null);
@@ -1,6 +1,12 @@
1
1
  .adm-selector {
2
- --color: var(--adm-color-text);
2
+ --color: #f5f5f5;
3
3
  --checked-color: #e7f1ff;
4
+ --text-color: var(--adm-color-text);
5
+ --checked-text-color: var(--adm-color-primary);
6
+ --border: none;
7
+ --checked-border: none;
8
+ --border-radius: 2px;
9
+ --padding: 8px 16px;
4
10
  overflow: hidden;
5
11
  font-size: 15px;
6
12
  line-height: 1.4;
@@ -9,11 +15,12 @@
9
15
  --gap: 12px;
10
16
  }
11
17
  .adm-selector-item {
12
- padding: 8px 16px;
18
+ padding: var(--padding);
13
19
  position: relative;
14
- background-color: #f5f5f5;
15
- border-radius: 2px;
16
- color: #333;
20
+ background-color: var(--color);
21
+ border: var(--border);
22
+ border-radius: var(--border-radius);
23
+ color: var(--text-color);
17
24
  opacity: 1;
18
25
  cursor: pointer;
19
26
  display: inline-block;
@@ -27,8 +34,9 @@
27
34
  }
28
35
  .adm-selector-item-active,
29
36
  .adm-selector-item-multiple-active {
30
- color: var(--adm-color-primary);
37
+ color: var(--checked-text-color);
31
38
  background-color: var(--checked-color);
39
+ border: var(--checked-border);
32
40
  }
33
41
  .adm-selector-item .adm-selector-check-mark-wrapper {
34
42
  position: absolute;
@@ -16,5 +16,6 @@ export declare type SelectorProps<V> = {
16
16
  onChange?: (v: V[], extend: {
17
17
  items: SelectorOption<V>[];
18
18
  }) => void;
19
- } & NativeProps<'--checked-color'>;
19
+ showCheckMark?: boolean;
20
+ } & NativeProps<'--color' | '--checked-color' | '--text-color' | '--checked-text-color' | '--border' | '--checked-border' | '--border-radius' | '--padding'>;
20
21
  export declare const Selector: <V extends string | number>(p: SelectorProps<V>) => React.ReactElement<any, string | ((props: any) => React.ReactElement<any, any> | null) | (new (props: any) => React.Component<any, any, any>)>;
@@ -28,7 +28,8 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
28
28
  const classPrefix = `adm-selector`;
29
29
  const defaultProps = {
30
30
  multiple: false,
31
- defaultValue: []
31
+ defaultValue: [],
32
+ showCheckMark: true
32
33
  };
33
34
 
34
35
  const Selector = p => {
@@ -74,7 +75,7 @@ const Selector = p => {
74
75
  }
75
76
  }, option.label, option.description && _react.default.createElement("div", {
76
77
  className: `${classPrefix}-item-description`
77
- }, option.description), active && _react.default.createElement("div", {
78
+ }, option.description), active && props.showCheckMark && _react.default.createElement("div", {
78
79
  className: `${classPrefix}-check-mark-wrapper`
79
80
  }, _react.default.createElement(_checkMark.CheckMark, null)));
80
81
  });
@@ -212,7 +212,7 @@ const Swiper = (0, _react.forwardRef)((0, _stagedComponents.staged)((p, ref) =>
212
212
  swipeNext,
213
213
  swipePrev
214
214
  }));
215
- (0, _react.useLayoutEffect)(() => {
215
+ (0, _ahooks.useIsomorphicLayoutEffect)(() => {
216
216
  const maxIndex = validChildren.length - 1;
217
217
 
218
218
  if (current > maxIndex) {
@@ -163,7 +163,7 @@ const Tabs = p => {
163
163
  });
164
164
  }
165
165
 
166
- (0, _react.useLayoutEffect)(() => {
166
+ (0, _ahooks.useIsomorphicLayoutEffect)(() => {
167
167
  animate(true);
168
168
  }, []);
169
169
  (0, _ahooks.useUpdateLayoutEffect)(() => {
@@ -197,7 +197,7 @@ const Tabs = p => {
197
197
  trailing: true,
198
198
  leading: true
199
199
  });
200
- (0, _react.useLayoutEffect)(() => {
200
+ (0, _ahooks.useIsomorphicLayoutEffect)(() => {
201
201
  updateMask(true);
202
202
  }, []);
203
203
  return (0, _nativeProps.withNativeProps)(props, _react.default.createElement("div", {
@@ -17,6 +17,8 @@ var _classnames = _interopRequireDefault(require("classnames"));
17
17
 
18
18
  var _antdMobileIcons = require("antd-mobile-icons");
19
19
 
20
+ var _ahooks = require("ahooks");
21
+
20
22
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
23
 
22
24
  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); }
@@ -47,7 +49,7 @@ const VirtualInput = (0, _react.forwardRef)((p, ref) => {
47
49
  content.scrollLeft = content.clientWidth;
48
50
  }
49
51
 
50
- (0, _react.useLayoutEffect)(() => {
52
+ (0, _ahooks.useIsomorphicLayoutEffect)(() => {
51
53
  scrollToEnd();
52
54
  }, [value]);
53
55
  (0, _react.useEffect)(() => {
@@ -12,7 +12,7 @@ const defaultRoot = _canUseDom.canUseDom ? window : undefined;
12
12
 
13
13
  function isElement(node) {
14
14
  const ELEMENT_NODE_TYPE = 1;
15
- return node.tagName !== 'HTML' && node.tagName !== 'BODY' && node.nodeType === ELEMENT_NODE_TYPE;
15
+ return node.nodeType === ELEMENT_NODE_TYPE;
16
16
  } // https://github.com/youzan/vant/issues/3823
17
17
 
18
18