antd-mobile 5.2.2 → 5.4.0

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 (116) hide show
  1. package/2x/cjs/components/avatar/avatar.js +1 -0
  2. package/2x/cjs/components/calendar/calendar.js +23 -20
  3. package/2x/cjs/components/date-picker/date-picker.js +3 -7
  4. package/2x/cjs/components/ellipsis/ellipsis.d.ts +2 -0
  5. package/2x/cjs/components/ellipsis/ellipsis.js +8 -5
  6. package/2x/cjs/components/floating-bubble/floating-bubble.d.ts +2 -0
  7. package/2x/cjs/components/floating-bubble/floating-bubble.js +47 -16
  8. package/2x/cjs/components/form/context.d.ts +2 -1
  9. package/2x/cjs/components/form/context.js +6 -5
  10. package/2x/cjs/components/form/form-item.css +27 -1
  11. package/2x/cjs/components/form/form-item.d.ts +1 -0
  12. package/2x/cjs/components/form/form-item.js +44 -13
  13. package/2x/cjs/components/form/form.js +19 -10
  14. package/2x/cjs/components/form/index.css +27 -1
  15. package/2x/cjs/components/infinite-scroll/infinite-scroll.js +23 -19
  16. package/2x/cjs/components/input/input.js +2 -2
  17. package/2x/cjs/components/modal/modal.js +0 -1
  18. package/2x/cjs/components/notice-bar/notice-bar.js +1 -1
  19. package/2x/cjs/components/pull-to-refresh/pull-to-refresh.js +1 -1
  20. package/2x/cjs/components/search-bar/search-bar.js +0 -1
  21. package/2x/cjs/components/swiper/swiper.js +1 -1
  22. package/2x/cjs/components/text-area/text-area.css +4 -1
  23. package/2x/cjs/components/text-area/text-area.d.ts +2 -2
  24. package/2x/cjs/locales/base.d.ts +51 -0
  25. package/2x/cjs/locales/base.js +52 -0
  26. package/2x/cjs/locales/en-US.d.ts +51 -0
  27. package/2x/cjs/locales/zh-CN.d.ts +51 -0
  28. package/2x/cjs/locales/zh-CN.js +52 -0
  29. package/2x/es/components/avatar/avatar.js +1 -0
  30. package/2x/es/components/calendar/calendar.js +23 -19
  31. package/2x/es/components/date-picker/date-picker.js +3 -7
  32. package/2x/es/components/ellipsis/ellipsis.d.ts +2 -0
  33. package/2x/es/components/ellipsis/ellipsis.js +7 -5
  34. package/2x/es/components/floating-bubble/floating-bubble.d.ts +2 -0
  35. package/2x/es/components/floating-bubble/floating-bubble.js +48 -17
  36. package/2x/es/components/form/context.d.ts +2 -1
  37. package/2x/es/components/form/context.js +4 -3
  38. package/2x/es/components/form/form-item.css +27 -1
  39. package/2x/es/components/form/form-item.d.ts +1 -0
  40. package/2x/es/components/form/form-item.js +43 -13
  41. package/2x/es/components/form/form.js +19 -12
  42. package/2x/es/components/form/index.css +27 -1
  43. package/2x/es/components/infinite-scroll/infinite-scroll.js +22 -19
  44. package/2x/es/components/input/input.js +2 -2
  45. package/2x/es/components/modal/modal.js +0 -1
  46. package/2x/es/components/notice-bar/notice-bar.js +1 -1
  47. package/2x/es/components/pull-to-refresh/pull-to-refresh.js +1 -1
  48. package/2x/es/components/search-bar/search-bar.js +0 -1
  49. package/2x/es/components/swiper/swiper.js +1 -1
  50. package/2x/es/components/text-area/text-area.css +4 -1
  51. package/2x/es/components/text-area/text-area.d.ts +2 -2
  52. package/2x/es/locales/base.d.ts +51 -0
  53. package/2x/es/locales/base.js +52 -0
  54. package/2x/es/locales/en-US.d.ts +51 -0
  55. package/2x/es/locales/zh-CN.d.ts +51 -0
  56. package/2x/es/locales/zh-CN.js +52 -0
  57. package/2x/package.json +4 -4
  58. package/cjs/components/avatar/avatar.js +1 -0
  59. package/cjs/components/calendar/calendar.js +23 -20
  60. package/cjs/components/date-picker/date-picker.js +3 -7
  61. package/cjs/components/ellipsis/ellipsis.d.ts +2 -0
  62. package/cjs/components/ellipsis/ellipsis.js +8 -5
  63. package/cjs/components/floating-bubble/floating-bubble.d.ts +2 -0
  64. package/cjs/components/floating-bubble/floating-bubble.js +47 -16
  65. package/cjs/components/form/context.d.ts +2 -1
  66. package/cjs/components/form/context.js +6 -5
  67. package/cjs/components/form/form-item.css +21 -1
  68. package/cjs/components/form/form-item.d.ts +1 -0
  69. package/cjs/components/form/form-item.js +44 -13
  70. package/cjs/components/form/form.js +19 -10
  71. package/cjs/components/form/index.css +21 -1
  72. package/cjs/components/infinite-scroll/infinite-scroll.js +23 -19
  73. package/cjs/components/input/input.js +2 -2
  74. package/cjs/components/modal/modal.js +0 -1
  75. package/cjs/components/notice-bar/notice-bar.js +1 -1
  76. package/cjs/components/pull-to-refresh/pull-to-refresh.js +1 -1
  77. package/cjs/components/search-bar/search-bar.js +0 -1
  78. package/cjs/components/swiper/swiper.js +1 -1
  79. package/cjs/components/text-area/text-area.css +4 -1
  80. package/cjs/components/text-area/text-area.d.ts +2 -2
  81. package/cjs/locales/base.d.ts +51 -0
  82. package/cjs/locales/base.js +52 -0
  83. package/cjs/locales/en-US.d.ts +51 -0
  84. package/cjs/locales/zh-CN.d.ts +51 -0
  85. package/cjs/locales/zh-CN.js +52 -0
  86. package/es/components/avatar/avatar.js +1 -0
  87. package/es/components/calendar/calendar.js +23 -19
  88. package/es/components/date-picker/date-picker.js +3 -7
  89. package/es/components/ellipsis/ellipsis.d.ts +2 -0
  90. package/es/components/ellipsis/ellipsis.js +7 -5
  91. package/es/components/floating-bubble/floating-bubble.d.ts +2 -0
  92. package/es/components/floating-bubble/floating-bubble.js +48 -17
  93. package/es/components/form/context.d.ts +2 -1
  94. package/es/components/form/context.js +4 -3
  95. package/es/components/form/form-item.css +21 -1
  96. package/es/components/form/form-item.d.ts +1 -0
  97. package/es/components/form/form-item.js +43 -13
  98. package/es/components/form/form.js +19 -12
  99. package/es/components/form/index.css +21 -1
  100. package/es/components/infinite-scroll/infinite-scroll.js +22 -19
  101. package/es/components/input/input.js +2 -2
  102. package/es/components/modal/modal.js +0 -1
  103. package/es/components/notice-bar/notice-bar.js +1 -1
  104. package/es/components/pull-to-refresh/pull-to-refresh.js +1 -1
  105. package/es/components/search-bar/search-bar.js +0 -1
  106. package/es/components/swiper/swiper.js +1 -1
  107. package/es/components/text-area/text-area.css +4 -1
  108. package/es/components/text-area/text-area.d.ts +2 -2
  109. package/es/locales/base.d.ts +51 -0
  110. package/es/locales/base.js +52 -0
  111. package/es/locales/en-US.d.ts +51 -0
  112. package/es/locales/zh-CN.d.ts +51 -0
  113. package/es/locales/zh-CN.js +52 -0
  114. package/package.json +4 -4
  115. package/umd/antd-mobile.js +1 -1
  116. package/umd/antd-mobile.js.LICENSE.txt +0 -24
@@ -131,7 +131,7 @@ const PullToRefresh = p => {
131
131
  if (!element) return;
132
132
  const scrollParent = (0, _getScrollParent.getScrollParent)(element);
133
133
  if (!scrollParent) return;
134
- const top = 'scrollTop' in scrollParent ? scrollParent.scrollTop : scrollParent.pageYOffset;
134
+ const top = 'scrollTop' in scrollParent ? scrollParent.scrollTop : scrollParent.scrollY;
135
135
 
136
136
  if (top <= 0 && y > 0) {
137
137
  pullingRef.current = true;
@@ -67,7 +67,6 @@ const SearchBar = (0, _react.forwardRef)((p, ref) => {
67
67
 
68
68
  const renderCancelButton = () => {
69
69
  let isShowCancel = false;
70
- const showCancelButton = props.showCancelButton;
71
70
 
72
71
  if (typeof props.showCancelButton === 'function') {
73
72
  isShowCancel = props.showCancelButton(hasFocus, value);
@@ -258,7 +258,7 @@ const Swiper = (0, _react.forwardRef)((0, _stagedComponents.staged)((p, ref) =>
258
258
  style: {
259
259
  [isVertical ? 'y' : 'x']: position.to(position => `${-position}%`)
260
260
  }
261
- }, _react.default.Children.map(validChildren, (child, index) => {
261
+ }, _react.default.Children.map(validChildren, child => {
262
262
  return _react.default.createElement("div", {
263
263
  className: 'adm-swiper-slide'
264
264
  }, child);
@@ -3,6 +3,8 @@
3
3
  --color: var(--adm-color-text);
4
4
  --placeholder-color: var(--adm-color-light);
5
5
  --disabled-color: var(--adm-color-weak);
6
+ --text-align: left;
7
+ --count-text-align: right;
6
8
  width: 100%;
7
9
  max-width: 100%;
8
10
  max-height: 100%;
@@ -27,6 +29,7 @@
27
29
  outline: none;
28
30
  appearance: none;
29
31
  min-height: 1.5em;
32
+ text-align: var(--text-align);
30
33
  }
31
34
 
32
35
  .adm-text-area-element::placeholder {
@@ -62,7 +65,7 @@
62
65
  }
63
66
 
64
67
  .adm-text-area-count {
65
- text-align: right;
68
+ text-align: var(--count-text-align);
66
69
  color: var(--adm-color-weak);
67
70
  font-size: 34px;
68
71
  padding-top: 16px;
@@ -14,7 +14,7 @@ export declare type TextAreaProps = Pick<React.DetailedHTMLProps<React.TextareaH
14
14
  maxRows?: number;
15
15
  };
16
16
  id?: string;
17
- } & NativeProps<'--font-size' | '--color' | '--placeholder-color' | '--disabled-color'>;
17
+ } & NativeProps<'--font-size' | '--color' | '--placeholder-color' | '--disabled-color' | '--text-align' | '--count-text-align'>;
18
18
  export declare type TextAreaRef = {
19
19
  clear: () => void;
20
20
  focus: () => void;
@@ -33,4 +33,4 @@ export declare const TextArea: React.ForwardRefExoticComponent<Pick<React.Detail
33
33
  maxRows?: number | undefined;
34
34
  } | undefined;
35
35
  id?: string | undefined;
36
- } & NativeProps<"--color" | "--font-size" | "--placeholder-color" | "--disabled-color"> & React.RefAttributes<TextAreaRef>>;
36
+ } & NativeProps<"--color" | "--font-size" | "--placeholder-color" | "--text-align" | "--disabled-color" | "--count-text-align"> & React.RefAttributes<TextAreaRef>>;
@@ -31,6 +31,57 @@ export declare const base: {
31
31
  description: string;
32
32
  };
33
33
  };
34
+ Form: {
35
+ required: string;
36
+ optional: string;
37
+ defaultValidateMessages: {
38
+ default: string;
39
+ required: string;
40
+ enum: string;
41
+ whitespace: string;
42
+ date: {
43
+ format: string;
44
+ parse: string;
45
+ invalid: string;
46
+ };
47
+ types: {
48
+ string: string;
49
+ method: string;
50
+ array: string;
51
+ object: string;
52
+ number: string;
53
+ date: string;
54
+ boolean: string;
55
+ integer: string;
56
+ float: string;
57
+ regexp: string;
58
+ email: string;
59
+ url: string;
60
+ hex: string;
61
+ };
62
+ string: {
63
+ len: string;
64
+ min: string;
65
+ max: string;
66
+ range: string;
67
+ };
68
+ number: {
69
+ len: string;
70
+ min: string;
71
+ max: string;
72
+ range: string;
73
+ };
74
+ array: {
75
+ len: string;
76
+ min: string;
77
+ max: string;
78
+ range: string;
79
+ };
80
+ pattern: {
81
+ mismatch: string;
82
+ };
83
+ };
84
+ };
34
85
  ImageUploader: {
35
86
  uploading: string;
36
87
  };
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.base = void 0;
7
+ const typeTemplate = '${label} is not a valid ${type}';
7
8
  const base = {
8
9
  common: {
9
10
  confirm: 'Confirm',
@@ -37,6 +38,57 @@ const base = {
37
38
  description: 'Want to try a new search?'
38
39
  }
39
40
  },
41
+ Form: {
42
+ required: 'Required',
43
+ optional: 'Optional',
44
+ defaultValidateMessages: {
45
+ default: 'Field validation error for ${label}',
46
+ required: 'Please enter ${label}',
47
+ enum: '${label} must be one of [${enum}]',
48
+ whitespace: '${label} cannot be a blank character',
49
+ date: {
50
+ format: '${label} date format is invalid',
51
+ parse: '${label} cannot be converted to a date',
52
+ invalid: '${label} is an invalid date'
53
+ },
54
+ types: {
55
+ string: typeTemplate,
56
+ method: typeTemplate,
57
+ array: typeTemplate,
58
+ object: typeTemplate,
59
+ number: typeTemplate,
60
+ date: typeTemplate,
61
+ boolean: typeTemplate,
62
+ integer: typeTemplate,
63
+ float: typeTemplate,
64
+ regexp: typeTemplate,
65
+ email: typeTemplate,
66
+ url: typeTemplate,
67
+ hex: typeTemplate
68
+ },
69
+ string: {
70
+ len: '${label} must be ${len} characters',
71
+ min: '${label} must be at least ${min} characters',
72
+ max: '${label} must be up to ${max} characters',
73
+ range: '${label} must be between ${min}-${max} characters'
74
+ },
75
+ number: {
76
+ len: '${label} must be equal to ${len}',
77
+ min: '${label} must be minimum ${min}',
78
+ max: '${label} must be maximum ${max}',
79
+ range: '${label} must be between ${min}-${max}'
80
+ },
81
+ array: {
82
+ len: 'Must be ${len} ${label}',
83
+ min: 'At least ${min} ${label}',
84
+ max: 'At most ${max} ${label}',
85
+ range: 'The amount of ${label} must be between ${min}-${max}'
86
+ },
87
+ pattern: {
88
+ mismatch: '${label} does not match the pattern ${pattern}'
89
+ }
90
+ }
91
+ },
40
92
  ImageUploader: {
41
93
  uploading: 'Uploading...'
42
94
  },
@@ -31,6 +31,57 @@ declare const enUS: {
31
31
  description: string;
32
32
  };
33
33
  };
34
+ Form: {
35
+ required: string;
36
+ optional: string;
37
+ defaultValidateMessages: {
38
+ default: string;
39
+ required: string;
40
+ enum: string;
41
+ whitespace: string;
42
+ date: {
43
+ format: string;
44
+ parse: string;
45
+ invalid: string;
46
+ };
47
+ types: {
48
+ string: string;
49
+ method: string;
50
+ array: string;
51
+ object: string;
52
+ number: string;
53
+ date: string;
54
+ boolean: string;
55
+ integer: string;
56
+ float: string;
57
+ regexp: string;
58
+ email: string;
59
+ url: string;
60
+ hex: string;
61
+ };
62
+ string: {
63
+ len: string;
64
+ min: string;
65
+ max: string;
66
+ range: string;
67
+ };
68
+ number: {
69
+ len: string;
70
+ min: string;
71
+ max: string;
72
+ range: string;
73
+ };
74
+ array: {
75
+ len: string;
76
+ min: string;
77
+ max: string;
78
+ range: string;
79
+ };
80
+ pattern: {
81
+ mismatch: string;
82
+ };
83
+ };
84
+ };
34
85
  ImageUploader: {
35
86
  uploading: string;
36
87
  };
@@ -31,6 +31,57 @@ declare const zhCN: {
31
31
  description: string;
32
32
  };
33
33
  };
34
+ Form: {
35
+ required: string;
36
+ optional: string;
37
+ defaultValidateMessages: {
38
+ default: string;
39
+ required: string;
40
+ enum: string;
41
+ whitespace: string;
42
+ date: {
43
+ format: string;
44
+ parse: string;
45
+ invalid: string;
46
+ };
47
+ types: {
48
+ string: string;
49
+ method: string;
50
+ array: string;
51
+ object: string;
52
+ number: string;
53
+ date: string;
54
+ boolean: string;
55
+ integer: string;
56
+ float: string;
57
+ regexp: string;
58
+ email: string;
59
+ url: string;
60
+ hex: string;
61
+ };
62
+ string: {
63
+ len: string;
64
+ min: string;
65
+ max: string;
66
+ range: string;
67
+ };
68
+ number: {
69
+ len: string;
70
+ min: string;
71
+ max: string;
72
+ range: string;
73
+ };
74
+ array: {
75
+ len: string;
76
+ min: string;
77
+ max: string;
78
+ range: string;
79
+ };
80
+ pattern: {
81
+ mismatch: string;
82
+ };
83
+ };
84
+ };
34
85
  ImageUploader: {
35
86
  uploading: string;
36
87
  };
@@ -9,6 +9,7 @@ var _mergeLocale = require("../utils/merge-locale");
9
9
 
10
10
  var _base = require("./base");
11
11
 
12
+ const typeTemplate = '${label}不是一个有效的${type}';
12
13
  const zhCN = (0, _mergeLocale.mergeLocale)(_base.base, {
13
14
  common: {
14
15
  confirm: '确定',
@@ -42,6 +43,57 @@ const zhCN = (0, _mergeLocale.mergeLocale)(_base.base, {
42
43
  description: '找找其他的吧'
43
44
  }
44
45
  },
46
+ Form: {
47
+ required: '必填',
48
+ optional: '选填',
49
+ defaultValidateMessages: {
50
+ default: '字段验证错误${label}',
51
+ required: '请输入${label}',
52
+ enum: '${label}必须是其中一个[${enum}]',
53
+ whitespace: '${label}不能为空字符',
54
+ date: {
55
+ format: '${label}日期格式无效',
56
+ parse: '${label}不能转换为日期',
57
+ invalid: '${label}是一个无效日期'
58
+ },
59
+ types: {
60
+ string: typeTemplate,
61
+ method: typeTemplate,
62
+ array: typeTemplate,
63
+ object: typeTemplate,
64
+ number: typeTemplate,
65
+ date: typeTemplate,
66
+ boolean: typeTemplate,
67
+ integer: typeTemplate,
68
+ float: typeTemplate,
69
+ regexp: typeTemplate,
70
+ email: typeTemplate,
71
+ url: typeTemplate,
72
+ hex: typeTemplate
73
+ },
74
+ string: {
75
+ len: '${label}须为${len}个字符',
76
+ min: '${label}最少${min}个字符',
77
+ max: '${label}最多${max}个字符',
78
+ range: '${label}须在${min}-${max}字符之间'
79
+ },
80
+ number: {
81
+ len: '${label}必须等于${len}',
82
+ min: '${label}最小值为${min}',
83
+ max: '${label}最大值为${max}',
84
+ range: '${label}须在${min}-${max}之间'
85
+ },
86
+ array: {
87
+ len: '须为${len}个${label}',
88
+ min: '最少${min}个${label}',
89
+ max: '最多${max}个${label}',
90
+ range: '${label}数量须在${min}-${max}之间'
91
+ },
92
+ pattern: {
93
+ mismatch: '${label}与模式不匹配${pattern}'
94
+ }
95
+ }
96
+ },
45
97
  ImageUploader: {
46
98
  uploading: '上传中...'
47
99
  },
@@ -17,6 +17,7 @@ export const Avatar = p => {
17
17
  placeholder: props.fallback,
18
18
  alt: props.alt,
19
19
  lazy: props.lazy,
20
+ fit: props.fit,
20
21
  onClick: props.onClick,
21
22
  onError: props.onError
22
23
  }));
@@ -26,7 +26,29 @@ export const Calendar = forwardRef((p, ref) => {
26
26
  if (item) markItems.unshift(item);
27
27
  }
28
28
 
29
- const [current, setCurrent] = useState(() => dayjs().date(1));
29
+ const dateRange = useMemo(() => {
30
+ var _a, _b, _c, _d;
31
+
32
+ if (props.selectionMode === 'single') {
33
+ const value = (_b = (_a = props.value) !== null && _a !== void 0 ? _a : props.defaultValue) !== null && _b !== void 0 ? _b : null;
34
+ return [value, value];
35
+ } else if (props.selectionMode === 'range') {
36
+ return (_d = (_c = props.value) !== null && _c !== void 0 ? _c : props.defaultValue) !== null && _d !== void 0 ? _d : [null, null];
37
+ } else {
38
+ return [null, null];
39
+ }
40
+ }, [props.selectionMode, props.value, props.defaultValue]);
41
+ const [begin, setBegin] = useState(null);
42
+ const [end, setEnd] = useState(null);
43
+ useIsomorphicLayoutEffect(() => {
44
+ setBegin(dateRange[0] ? dayjs(dateRange[0]) : null);
45
+ setEnd(dateRange[1] ? dayjs(dateRange[1]) : null);
46
+ }, [dateRange[0], dateRange[1]]);
47
+ const [current, setCurrent] = useState(() => {
48
+ var _a;
49
+
50
+ return dayjs((_a = dateRange[0]) !== null && _a !== void 0 ? _a : today).date(1);
51
+ });
30
52
  useUpdateEffect(() => {
31
53
  var _a;
32
54
 
@@ -76,24 +98,6 @@ export const Calendar = forwardRef((p, ref) => {
76
98
  setCurrent(current.add(1, 'year'));
77
99
  }
78
100
  }, React.createElement(ArrowLeftDouble, null)));
79
- const dateRange = useMemo(() => {
80
- var _a, _b, _c, _d;
81
-
82
- if (props.selectionMode === 'single') {
83
- const value = (_b = (_a = props.value) !== null && _a !== void 0 ? _a : props.defaultValue) !== null && _b !== void 0 ? _b : null;
84
- return [value, value];
85
- } else if (props.selectionMode === 'range') {
86
- return (_d = (_c = props.value) !== null && _c !== void 0 ? _c : props.defaultValue) !== null && _d !== void 0 ? _d : [null, null];
87
- } else {
88
- return [null, null];
89
- }
90
- }, [props.selectionMode, props.value, props.defaultValue]);
91
- const [begin, setBegin] = useState(null);
92
- const [end, setEnd] = useState(null);
93
- useIsomorphicLayoutEffect(() => {
94
- setBegin(dateRange[0] ? dayjs(dateRange[0]) : null);
95
- setEnd(dateRange[1] ? dayjs(dateRange[1]) : null);
96
- }, [dateRange[0], dateRange[1]]);
97
101
 
98
102
  function renderCells() {
99
103
  var _a;
@@ -28,14 +28,10 @@ export const DatePicker = p => {
28
28
  });
29
29
  const now = useMemo(() => new Date(), []);
30
30
  const pickerValue = useMemo(() => {
31
- let date = value;
32
-
33
- if (date === null) {
34
- date = new Date(bound(now.getTime(), props.min.getTime(), props.max.getTime()));
35
- }
36
-
31
+ let date = value !== null && value !== void 0 ? value : now;
32
+ date = new Date(bound(date.getTime(), props.min.getTime(), props.max.getTime()));
37
33
  return convertDateToStringArray(date, props.precision);
38
- }, [value, props.precision]);
34
+ }, [value, props.precision, props.min, props.max]);
39
35
  const onConfirm = useCallback(val => {
40
36
  setValue(convertStringArrayToDate(val, props.precision));
41
37
  }, [setValue, props.precision]);
@@ -1,10 +1,12 @@
1
1
  import { FC } from 'react';
2
2
  import { NativeProps } from '../../utils/native-props';
3
+ import { PropagationEvent } from '../../utils/with-stop-propagation';
3
4
  export declare type EllipsisProps = {
4
5
  content: string;
5
6
  direction?: 'start' | 'end' | 'middle';
6
7
  rows?: number;
7
8
  expandText?: string;
8
9
  collapseText?: string;
10
+ stopPropagationForActionButtons?: PropagationEvent[];
9
11
  } & NativeProps;
10
12
  export declare const Ellipsis: FC<EllipsisProps>;
@@ -3,12 +3,14 @@ import { mergeProps } from '../../utils/with-default-props';
3
3
  import { withNativeProps } from '../../utils/native-props';
4
4
  import { useResizeEffect } from '../../utils/use-resize-effect';
5
5
  import { useIsomorphicLayoutEffect } from 'ahooks';
6
+ import { withStopPropagation } from '../../utils/with-stop-propagation';
6
7
  const classPrefix = `adm-ellipsis`;
7
8
  const defaultProps = {
8
9
  direction: 'end',
9
10
  rows: 1,
10
11
  expandText: '',
11
- collapseText: ''
12
+ collapseText: '',
13
+ stopPropagationForActionButtons: []
12
14
  };
13
15
  export const Ellipsis = p => {
14
16
  const props = mergeProps(defaultProps, p);
@@ -117,16 +119,16 @@ export const Ellipsis = p => {
117
119
  useIsomorphicLayoutEffect(() => {
118
120
  calcEllipsised();
119
121
  }, [props.content, props.direction, props.rows, props.expandText, props.collapseText]);
120
- const expandActionElement = exceeded && props.expandText ? React.createElement("a", {
122
+ const expandActionElement = exceeded && props.expandText ? withStopPropagation(props.stopPropagationForActionButtons, React.createElement("a", {
121
123
  onClick: () => {
122
124
  setExpanded(true);
123
125
  }
124
- }, props.expandText) : null;
125
- const collapseActionElement = exceeded && props.expandText ? React.createElement("a", {
126
+ }, props.expandText)) : null;
127
+ const collapseActionElement = exceeded && props.expandText ? withStopPropagation(props.stopPropagationForActionButtons, React.createElement("a", {
126
128
  onClick: () => {
127
129
  setExpanded(false);
128
130
  }
129
- }, props.collapseText) : null;
131
+ }, props.collapseText)) : null;
130
132
 
131
133
  const renderContent = () => {
132
134
  if (!exceeded) {
@@ -2,5 +2,7 @@ import React, { FC } from 'react';
2
2
  import { NativeProps } from '../../utils/native-props';
3
3
  export declare type FloatingBubbleProps = {
4
4
  onClick?: (event: React.MouseEvent<HTMLDivElement, MouseEvent>) => void;
5
+ axis?: 'x' | 'y' | 'xy' | 'lock';
6
+ magnetic?: 'x' | 'y';
5
7
  } & NativeProps<'--initial-position-left' | '--initial-position-right' | '--initial-position-top' | '--initial-position-bottom' | '--z-index' | '--edge-distance' | '--size' | '--border-radius'>;
6
8
  export declare const FloatingBubble: FC<FloatingBubbleProps>;
@@ -1,47 +1,74 @@
1
1
  import React, { useRef } from 'react';
2
- import { useSpring, animated } from '@react-spring/web';
2
+ import { useSpring, animated, to } from '@react-spring/web';
3
3
  import { useDrag } from '@use-gesture/react';
4
4
  import { mergeProps } from '../../utils/with-default-props';
5
5
  import { withNativeProps } from '../../utils/native-props';
6
6
  const classPrefix = `adm-floating-bubble`;
7
- const defaultProps = {};
7
+ const defaultProps = {
8
+ axis: 'y'
9
+ };
8
10
  export const FloatingBubble = p => {
9
11
  const props = mergeProps(defaultProps, p);
10
12
  const boundaryRef = useRef(null);
13
+ const buttonRef = useRef(null);
11
14
  /**
12
15
  * memoize the `to` function
13
16
  * inside a component that renders frequently
14
17
  * to prevent an unintended restart
15
18
  */
16
19
 
17
- const [animationStyles, animation] = useSpring(() => ({
20
+ const [{
21
+ x,
22
+ y,
23
+ opacity
24
+ }, api] = useSpring(() => ({
25
+ x: 0,
18
26
  y: 0,
19
- scale: 1,
20
27
  opacity: 1
21
28
  }));
22
29
  const bind = useDrag(state => {
23
- if (state.down) {
24
- // be movable in y axis
25
- animation.start({
26
- y: state.offset[1]
27
- });
28
- } // active status
30
+ let nextX = state.offset[0];
31
+ let nextY = state.offset[1];
29
32
 
33
+ if (state.last) {
34
+ const boundary = boundaryRef.current;
35
+ const button = buttonRef.current;
36
+ if (!boundary || !button) return;
30
37
 
31
- animation.start({
32
- scale: state.active ? 1.1 : 1,
38
+ if (props.magnetic === 'x') {
39
+ const compensation = x.goal - x.get();
40
+ const boundaryRect = boundary.getBoundingClientRect();
41
+ const buttonRect = button.getBoundingClientRect();
42
+ const leftDistance = buttonRect.left + compensation - boundaryRect.left;
43
+ const rightDistance = boundaryRect.right - (buttonRect.right + compensation);
44
+
45
+ if (rightDistance <= leftDistance) {
46
+ nextX += rightDistance;
47
+ } else {
48
+ nextX -= leftDistance;
49
+ }
50
+ }
51
+ }
52
+
53
+ api.start({
54
+ x: nextX,
55
+ y: nextY // immediate: !state.last,
56
+
57
+ }); // active status
58
+
59
+ api.start({
33
60
  opacity: state.active ? 0.8 : 1
34
61
  });
35
62
  }, {
36
- // only trigger if a movement is detected on the specified axis.
37
- axis: 'y',
63
+ axis: props.axis === 'xy' ? undefined : props.axis,
38
64
  pointer: {
39
65
  touch: true
40
66
  },
41
67
  // the component won't trigger drag logic if the user just clicked on the component.
42
68
  filterTaps: true,
43
69
  // set constraints to the user gesture
44
- bounds: boundaryRef
70
+ bounds: boundaryRef,
71
+ from: () => [x.get(), y.get()]
45
72
  });
46
73
  return withNativeProps(props, React.createElement("div", {
47
74
  className: classPrefix
@@ -51,8 +78,12 @@ export const FloatingBubble = p => {
51
78
  className: `${classPrefix}-boundary`,
52
79
  ref: boundaryRef
53
80
  })), React.createElement(animated.div, Object.assign({}, bind(), {
54
- style: Object.assign({}, animationStyles),
81
+ style: {
82
+ opacity,
83
+ transform: to([x, y], (x, y) => `translate(${x}px, ${y}px)`)
84
+ },
55
85
  onClick: props.onClick,
56
- className: `${classPrefix}-button`
86
+ className: `${classPrefix}-button`,
87
+ ref: buttonRef
57
88
  }), props.children)));
58
89
  };
@@ -4,8 +4,9 @@ import type { Meta, InternalNamePath } from 'rc-field-form/lib/interface';
4
4
  export declare type FormContextType = {
5
5
  hasFeedback: boolean;
6
6
  layout: FormLayout;
7
+ requiredMarkStyle: 'asterisk' | 'text-required' | 'text-optional';
7
8
  };
8
- export declare const DEFAULT_FORM_CONTEXT: FormContextType;
9
+ export declare const defaultFormContext: FormContextType;
9
10
  export declare const FormContext: React.Context<FormContextType>;
10
11
  export declare type OnSubMetaChange = (meta: Meta & {
11
12
  destroy?: boolean;
@@ -1,7 +1,8 @@
1
1
  import React from 'react';
2
- export const DEFAULT_FORM_CONTEXT = {
2
+ export const defaultFormContext = {
3
3
  hasFeedback: true,
4
- layout: 'vertical'
4
+ layout: 'vertical',
5
+ requiredMarkStyle: 'asterisk'
5
6
  };
6
- export const FormContext = React.createContext(DEFAULT_FORM_CONTEXT);
7
+ export const FormContext = React.createContext(defaultFormContext);
7
8
  export const NoStyleItemContext = React.createContext(null);