antd-mobile 5.5.1 → 5.6.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 (123) hide show
  1. package/2x/cjs/components/action-sheet/action-sheet.d.ts +5 -5
  2. package/2x/cjs/components/action-sheet/action-sheet.js +6 -46
  3. package/2x/cjs/components/action-sheet/index.d.ts +1 -1
  4. package/2x/cjs/components/badge/badge.js +1 -1
  5. package/2x/cjs/components/cascader-view/cascader-view.js +7 -0
  6. package/2x/cjs/components/checkbox/checkbox.js +4 -20
  7. package/2x/cjs/components/checkbox/native-input.d.ts +10 -0
  8. package/2x/cjs/components/checkbox/native-input.js +42 -0
  9. package/2x/cjs/components/dialog/index.d.ts +1 -1
  10. package/2x/cjs/components/dialog/show.d.ts +2 -4
  11. package/2x/cjs/components/dialog/show.js +9 -47
  12. package/2x/cjs/components/dot-loading/dot-loading.js +1 -2
  13. package/2x/cjs/components/error-block/error-block.js +4 -2
  14. package/2x/cjs/components/floating-bubble/floating-bubble.css +2 -1
  15. package/2x/cjs/components/floating-bubble/floating-bubble.d.ts +1 -1
  16. package/2x/cjs/components/image-viewer/index.d.ts +1 -1
  17. package/2x/cjs/components/image-viewer/methods.d.ts +3 -4
  18. package/2x/cjs/components/image-viewer/methods.js +41 -56
  19. package/2x/cjs/components/modal/index.d.ts +1 -1
  20. package/2x/cjs/components/modal/show.d.ts +2 -4
  21. package/2x/cjs/components/modal/show.js +9 -47
  22. package/2x/cjs/components/popover/popover.js +1 -0
  23. package/2x/cjs/components/popover/temp-floating-ui.min.js +1 -430
  24. package/2x/cjs/components/radio/radio.js +4 -20
  25. package/2x/cjs/components/search-bar/search-bar.d.ts +1 -1
  26. package/2x/cjs/components/tab-bar/tab-bar.d.ts +1 -1
  27. package/2x/cjs/components/tab-bar/tab-bar.js +1 -1
  28. package/2x/cjs/components/tree-select/tree-select.js +2 -2
  29. package/2x/cjs/utils/render-imperatively.d.ts +10 -0
  30. package/2x/cjs/utils/render-imperatively.js +58 -0
  31. package/2x/es/components/action-sheet/action-sheet.d.ts +5 -5
  32. package/2x/es/components/action-sheet/action-sheet.js +5 -41
  33. package/2x/es/components/action-sheet/index.d.ts +1 -1
  34. package/2x/es/components/badge/badge.js +1 -1
  35. package/2x/es/components/cascader-view/cascader-view.js +7 -0
  36. package/2x/es/components/checkbox/checkbox.js +4 -21
  37. package/2x/es/components/checkbox/native-input.d.ts +10 -0
  38. package/2x/es/components/checkbox/native-input.js +28 -0
  39. package/2x/es/components/dialog/index.d.ts +1 -1
  40. package/2x/es/components/dialog/show.d.ts +2 -4
  41. package/2x/es/components/dialog/show.js +8 -44
  42. package/2x/es/components/dot-loading/dot-loading.js +1 -2
  43. package/2x/es/components/error-block/error-block.js +4 -2
  44. package/2x/es/components/floating-bubble/floating-bubble.css +2 -1
  45. package/2x/es/components/floating-bubble/floating-bubble.d.ts +1 -1
  46. package/2x/es/components/image-viewer/index.d.ts +1 -1
  47. package/2x/es/components/image-viewer/methods.d.ts +3 -4
  48. package/2x/es/components/image-viewer/methods.js +38 -57
  49. package/2x/es/components/modal/index.d.ts +1 -1
  50. package/2x/es/components/modal/show.d.ts +2 -4
  51. package/2x/es/components/modal/show.js +8 -44
  52. package/2x/es/components/popover/popover.js +1 -0
  53. package/2x/es/components/popover/temp-floating-ui.min.js +1 -430
  54. package/2x/es/components/radio/radio.js +4 -21
  55. package/2x/es/components/search-bar/search-bar.d.ts +1 -1
  56. package/2x/es/components/tab-bar/tab-bar.d.ts +1 -1
  57. package/2x/es/components/tab-bar/tab-bar.js +1 -1
  58. package/2x/es/components/tree-select/tree-select.js +2 -2
  59. package/2x/es/utils/render-imperatively.d.ts +10 -0
  60. package/2x/es/utils/render-imperatively.js +45 -0
  61. package/2x/package.json +2 -3
  62. package/cjs/components/action-sheet/action-sheet.d.ts +5 -5
  63. package/cjs/components/action-sheet/action-sheet.js +6 -46
  64. package/cjs/components/action-sheet/index.d.ts +1 -1
  65. package/cjs/components/badge/badge.js +1 -1
  66. package/cjs/components/cascader-view/cascader-view.js +7 -0
  67. package/cjs/components/checkbox/checkbox.js +4 -20
  68. package/cjs/components/checkbox/native-input.d.ts +10 -0
  69. package/cjs/components/checkbox/native-input.js +42 -0
  70. package/cjs/components/dialog/index.d.ts +1 -1
  71. package/cjs/components/dialog/show.d.ts +2 -4
  72. package/cjs/components/dialog/show.js +9 -47
  73. package/cjs/components/dot-loading/dot-loading.js +1 -2
  74. package/cjs/components/error-block/error-block.js +4 -2
  75. package/cjs/components/floating-bubble/floating-bubble.css +2 -1
  76. package/cjs/components/floating-bubble/floating-bubble.d.ts +1 -1
  77. package/cjs/components/image-viewer/index.d.ts +1 -1
  78. package/cjs/components/image-viewer/methods.d.ts +3 -4
  79. package/cjs/components/image-viewer/methods.js +41 -56
  80. package/cjs/components/modal/index.d.ts +1 -1
  81. package/cjs/components/modal/show.d.ts +2 -4
  82. package/cjs/components/modal/show.js +9 -47
  83. package/cjs/components/popover/popover.js +1 -0
  84. package/cjs/components/popover/temp-floating-ui.min.js +1 -430
  85. package/cjs/components/radio/radio.js +4 -20
  86. package/cjs/components/search-bar/search-bar.d.ts +1 -1
  87. package/cjs/components/tab-bar/tab-bar.d.ts +1 -1
  88. package/cjs/components/tab-bar/tab-bar.js +1 -1
  89. package/cjs/components/tree-select/tree-select.js +2 -2
  90. package/cjs/utils/render-imperatively.d.ts +10 -0
  91. package/cjs/utils/render-imperatively.js +58 -0
  92. package/es/components/action-sheet/action-sheet.d.ts +5 -5
  93. package/es/components/action-sheet/action-sheet.js +5 -41
  94. package/es/components/action-sheet/index.d.ts +1 -1
  95. package/es/components/badge/badge.js +1 -1
  96. package/es/components/cascader-view/cascader-view.js +7 -0
  97. package/es/components/checkbox/checkbox.js +4 -21
  98. package/es/components/checkbox/native-input.d.ts +10 -0
  99. package/es/components/checkbox/native-input.js +28 -0
  100. package/es/components/dialog/index.d.ts +1 -1
  101. package/es/components/dialog/show.d.ts +2 -4
  102. package/es/components/dialog/show.js +8 -44
  103. package/es/components/dot-loading/dot-loading.js +1 -2
  104. package/es/components/error-block/error-block.js +4 -2
  105. package/es/components/floating-bubble/floating-bubble.css +2 -1
  106. package/es/components/floating-bubble/floating-bubble.d.ts +1 -1
  107. package/es/components/image-viewer/index.d.ts +1 -1
  108. package/es/components/image-viewer/methods.d.ts +3 -4
  109. package/es/components/image-viewer/methods.js +38 -57
  110. package/es/components/modal/index.d.ts +1 -1
  111. package/es/components/modal/show.d.ts +2 -4
  112. package/es/components/modal/show.js +8 -44
  113. package/es/components/popover/popover.js +1 -0
  114. package/es/components/popover/temp-floating-ui.min.js +1 -430
  115. package/es/components/radio/radio.js +4 -21
  116. package/es/components/search-bar/search-bar.d.ts +1 -1
  117. package/es/components/tab-bar/tab-bar.d.ts +1 -1
  118. package/es/components/tab-bar/tab-bar.js +1 -1
  119. package/es/components/tree-select/tree-select.js +2 -2
  120. package/es/utils/render-imperatively.d.ts +10 -0
  121. package/es/utils/render-imperatively.js +45 -0
  122. package/package.json +2 -3
  123. package/umd/antd-mobile.js +1 -1
@@ -10,7 +10,7 @@ export declare type Action = {
10
10
  onClick?: () => void;
11
11
  };
12
12
  export declare type ActionSheetProps = {
13
- visible: boolean;
13
+ visible?: boolean;
14
14
  actions: Action[];
15
15
  extra?: React.ReactNode;
16
16
  cancelText?: React.ReactNode;
@@ -22,11 +22,11 @@ export declare type ActionSheetProps = {
22
22
  closeOnMaskClick?: boolean;
23
23
  getContainer?: GetContainer;
24
24
  safeArea?: boolean;
25
+ popupClassName?: string;
26
+ popupStyle?: React.CSSProperties;
25
27
  } & NativeProps;
26
28
  export declare const ActionSheet: FC<ActionSheetProps>;
27
- export declare type ActionSheetRef = {
28
- close: () => void;
29
- };
30
- export declare function showActionSheet(props: Omit<ActionSheetProps, 'visible'>): {
29
+ export declare type ActionSheetShowHandler = {
31
30
  close: () => void;
32
31
  };
32
+ export declare function showActionSheet(props: Omit<ActionSheetProps, 'visible'>): ActionSheetShowHandler;
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.ActionSheet = void 0;
7
7
  exports.showActionSheet = showActionSheet;
8
8
 
9
- var _react = _interopRequireWildcard(require("react"));
9
+ var _react = _interopRequireDefault(require("react"));
10
10
 
11
11
  var _nativeProps = require("../../utils/native-props");
12
12
 
@@ -18,15 +18,11 @@ var _popup = _interopRequireDefault(require("../popup"));
18
18
 
19
19
  var _button = _interopRequireDefault(require("../button"));
20
20
 
21
- var _renderToBody = require("../../utils/render-to-body");
22
-
23
21
  var _safeArea = _interopRequireDefault(require("../safe-area"));
24
22
 
25
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
26
-
27
- 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
+ var _renderImperatively = require("../../utils/render-imperatively");
28
24
 
29
- 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; }
25
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
30
26
 
31
27
  const classPrefix = `adm-action-sheet`;
32
28
  const defaultProps = {
@@ -52,7 +48,8 @@ const ActionSheet = p => {
52
48
  }
53
49
  },
54
50
  afterClose: props.afterClose,
55
- className: `${classPrefix}-popup`,
51
+ className: (0, _classnames.default)(`${classPrefix}-popup`, props.popupClassName),
52
+ style: props.popupStyle,
56
53
  getContainer: props.getContainer
57
54
  }, (0, _nativeProps.withNativeProps)(props, _react.default.createElement("div", {
58
55
  className: classPrefix
@@ -109,42 +106,5 @@ const ActionSheet = p => {
109
106
  exports.ActionSheet = ActionSheet;
110
107
 
111
108
  function showActionSheet(props) {
112
- const Wrapper = (0, _react.forwardRef)((_, ref) => {
113
- const [visible, setVisible] = (0, _react.useState)(false);
114
- (0, _react.useEffect)(() => {
115
- setVisible(true);
116
- }, []);
117
-
118
- function handleClose() {
119
- var _a;
120
-
121
- (_a = props.onClose) === null || _a === void 0 ? void 0 : _a.call(props);
122
- setVisible(false);
123
- }
124
-
125
- (0, _react.useImperativeHandle)(ref, () => ({
126
- close: handleClose
127
- }));
128
- return _react.default.createElement(ActionSheet, Object.assign({}, props, {
129
- visible: visible,
130
- onClose: handleClose,
131
- afterClose: () => {
132
- var _a;
133
-
134
- (_a = props.afterClose) === null || _a === void 0 ? void 0 : _a.call(props);
135
- unmount();
136
- }
137
- }));
138
- });
139
- const ref = (0, _react.createRef)();
140
- const unmount = (0, _renderToBody.renderToBody)(_react.default.createElement(Wrapper, {
141
- ref: ref
142
- }));
143
- return {
144
- close: () => {
145
- var _a;
146
-
147
- (_a = ref.current) === null || _a === void 0 ? void 0 : _a.close();
148
- }
149
- };
109
+ return (0, _renderImperatively.renderImperatively)(_react.default.createElement(ActionSheet, Object.assign({}, props)));
150
110
  }
@@ -1,7 +1,7 @@
1
1
  /// <reference types="react" />
2
2
  import './action-sheet.less';
3
3
  import { showActionSheet } from './action-sheet';
4
- export type { Action, ActionSheetProps, ActionSheetRef } from './action-sheet';
4
+ export type { Action, ActionSheetProps, ActionSheetShowHandler, } from './action-sheet';
5
5
  declare const _default: import("react").FC<import("./action-sheet").ActionSheetProps> & {
6
6
  show: typeof showActionSheet;
7
7
  };
@@ -25,7 +25,7 @@ const Badge = props => {
25
25
  } = props;
26
26
  const isDot = content === dot;
27
27
  const badgeCls = (0, _classnames.default)(classPrefix, !!children && `${classPrefix}-fixed`, isDot && `${classPrefix}-dot`, props.bordered && `${classPrefix}-bordered`);
28
- const element = content ? (0, _nativeProps.withNativeProps)(props, _react.default.createElement("div", {
28
+ const element = content || content === 0 ? (0, _nativeProps.withNativeProps)(props, _react.default.createElement("div", {
29
29
  className: badgeCls,
30
30
  style: {
31
31
  '--color': color
@@ -86,6 +86,13 @@ const CascaderView = p => {
86
86
  (0, _react.useEffect)(() => {
87
87
  setTabActiveKey(levels.length - 1);
88
88
  }, [value]);
89
+ (0, _react.useEffect)(() => {
90
+ const max = levels.length - 1;
91
+
92
+ if (tabActiveKey > max) {
93
+ setTabActiveKey(max);
94
+ }
95
+ }, [tabActiveKey, levels]);
89
96
 
90
97
  const onItemSelect = (selectValue, depth) => {
91
98
  const next = value.slice(0, depth);
@@ -25,6 +25,8 @@ var _indeterminateIcon = require("./indeterminate-icon");
25
25
 
26
26
  var _isDev = require("../../utils/is-dev");
27
27
 
28
+ var _nativeInput = require("./native-input");
29
+
28
30
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
29
31
 
30
32
  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); }
@@ -90,35 +92,17 @@ const Checkbox = p => {
90
92
  }, props.indeterminate ? _react.default.createElement(_indeterminateIcon.IndeterminateIcon, null) : checked && _react.default.createElement(_checkIcon.CheckIcon, null));
91
93
  };
92
94
 
93
- const inputRef = (0, _react.useRef)(null);
94
- const labelRef = (0, _react.useRef)(null);
95
- (0, _react.useEffect)(() => {
96
- var _a;
97
-
98
- (_a = labelRef.current) === null || _a === void 0 ? void 0 : _a.addEventListener('click', e => {
99
- if (e.target !== inputRef.current) {
100
- e.stopPropagation();
101
- e.stopImmediatePropagation();
102
- }
103
- }, {
104
- capture: false
105
- });
106
- }, []);
107
95
  return (0, _nativeProps.withNativeProps)(props, _react.default.createElement("label", {
108
- ref: labelRef,
109
96
  className: (0, _classnames.default)(classPrefix, {
110
97
  [`${classPrefix}-checked`]: checked && !props.indeterminate,
111
98
  [`${classPrefix}-indeterminate`]: props.indeterminate,
112
99
  [`${classPrefix}-disabled`]: disabled,
113
100
  [`${classPrefix}-block`]: props.block
114
101
  })
115
- }, _react.default.createElement("input", {
116
- ref: inputRef,
102
+ }, _react.default.createElement(_nativeInput.NativeInput, {
117
103
  type: 'checkbox',
118
104
  checked: checked,
119
- onChange: e => {
120
- setChecked(e.target.checked);
121
- },
105
+ onChange: setChecked,
122
106
  disabled: disabled,
123
107
  id: props.id
124
108
  }), renderIcon(), props.children && _react.default.createElement("div", {
@@ -0,0 +1,10 @@
1
+ import { FC } from 'react';
2
+ interface Props {
3
+ type: 'checkbox' | 'radio';
4
+ checked: boolean;
5
+ onChange: (checked: boolean) => void;
6
+ disabled?: boolean;
7
+ id?: string;
8
+ }
9
+ export declare const NativeInput: FC<Props>;
10
+ export {};
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.NativeInput = void 0;
7
+
8
+ var _react = _interopRequireWildcard(require("react"));
9
+
10
+ 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); }
11
+
12
+ 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; }
13
+
14
+ const NativeInput = props => {
15
+ const inputRef = (0, _react.useRef)(null);
16
+ (0, _react.useEffect)(() => {
17
+ if (props.disabled) return;
18
+ if (!inputRef.current) return;
19
+ const input = inputRef.current;
20
+
21
+ function handleClick(e) {
22
+ e.stopPropagation();
23
+ e.stopImmediatePropagation();
24
+ props.onChange(input.checked);
25
+ }
26
+
27
+ input.addEventListener('click', handleClick);
28
+ return () => {
29
+ input.removeEventListener('click', handleClick);
30
+ };
31
+ }, [props.disabled, props.onChange]);
32
+ return _react.default.createElement("input", {
33
+ ref: inputRef,
34
+ type: 'checkbox',
35
+ checked: props.checked,
36
+ onChange: () => {},
37
+ disabled: props.disabled,
38
+ id: props.id
39
+ });
40
+ };
41
+
42
+ exports.NativeInput = NativeInput;
@@ -6,7 +6,7 @@ import { confirm } from './confirm';
6
6
  import { clear } from './clear';
7
7
  export type { DialogProps } from './dialog';
8
8
  export type { Action } from './dialog-action-button';
9
- export type { DialogShowProps, DialogShowRef } from './show';
9
+ export type { DialogShowProps, DialogShowHandler } from './show';
10
10
  export type { DialogAlertProps } from './alert';
11
11
  export type { DialogConfirmProps } from './confirm';
12
12
  declare const _default: import("react").FC<import("./dialog").DialogProps> & {
@@ -1,9 +1,7 @@
1
1
  import { DialogProps } from './dialog';
2
2
  export declare type DialogShowProps = Omit<DialogProps, 'visible'>;
3
- export declare type DialogShowRef = {
3
+ export declare type DialogShowHandler = {
4
4
  close: () => void;
5
5
  };
6
6
  export declare const closeFnSet: Set<() => void>;
7
- export declare function show(props: DialogShowProps): {
8
- close: () => void;
9
- };
7
+ export declare function show(props: DialogShowProps): DialogShowHandler;
@@ -6,64 +6,26 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.closeFnSet = void 0;
7
7
  exports.show = show;
8
8
 
9
- var _react = _interopRequireWildcard(require("react"));
10
-
11
- var _renderToBody = require("../../utils/render-to-body");
9
+ var _react = _interopRequireDefault(require("react"));
12
10
 
13
11
  var _dialog = require("./dialog");
14
12
 
15
- 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); }
13
+ var _renderImperatively = require("../../utils/render-imperatively");
16
14
 
17
- 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; }
15
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
18
16
 
19
17
  const closeFnSet = new Set();
20
18
  exports.closeFnSet = closeFnSet;
21
19
 
22
20
  function show(props) {
23
- const Wrapper = (0, _react.forwardRef)((_, ref) => {
24
- const [visible, setVisible] = (0, _react.useState)(false);
25
- (0, _react.useEffect)(() => {
26
- setVisible(true);
27
- }, []);
28
-
29
- function handleClose() {
30
- var _a;
31
-
32
- (_a = props.onClose) === null || _a === void 0 ? void 0 : _a.call(props);
33
- setVisible(false);
34
- }
35
-
36
- (0, _react.useImperativeHandle)(ref, () => ({
37
- close: handleClose
38
- }));
39
-
40
- function handleAfterClose() {
21
+ const handler = (0, _renderImperatively.renderImperatively)(_react.default.createElement(_dialog.Dialog, Object.assign({}, props, {
22
+ afterClose: () => {
41
23
  var _a;
42
24
 
25
+ closeFnSet.delete(handler.close);
43
26
  (_a = props.afterClose) === null || _a === void 0 ? void 0 : _a.call(props);
44
- unmount();
45
- closeFnSet.delete(close);
46
27
  }
47
-
48
- return _react.default.createElement(_dialog.Dialog, Object.assign({}, props, {
49
- visible: visible,
50
- onClose: handleClose,
51
- afterClose: handleAfterClose
52
- }));
53
- });
54
- const ref = (0, _react.createRef)();
55
- const unmount = (0, _renderToBody.renderToBody)(_react.default.createElement(Wrapper, {
56
- ref: ref
57
- }));
58
-
59
- const close = () => {
60
- var _a;
61
-
62
- (_a = ref.current) === null || _a === void 0 ? void 0 : _a.close();
63
- };
64
-
65
- closeFnSet.add(close);
66
- return {
67
- close
68
- };
28
+ })));
29
+ closeFnSet.add(handler.close);
30
+ return handler;
69
31
  }
@@ -70,8 +70,7 @@ const DotLoading = (0, _react.memo)(p => {
70
70
  begin: `${i * 0.2}s`,
71
71
  repeatCount: 'indefinite',
72
72
  values: '16; 6; 26; 16; 16',
73
- keyTimes: '0; 0.1; 0.3; 0.4; 1',
74
- id: 'circ-anim'
73
+ keyTimes: '0; 0.1; 0.3; 0.4; 1'
75
74
  }))))))))));
76
75
  });
77
76
  exports.DotLoading = DotLoading;
@@ -35,13 +35,15 @@ const ErrorBlock = p => {
35
35
  const title = 'title' in props ? props.title : contentPack.title;
36
36
 
37
37
  let imageNode = _react.default.createElement("img", {
38
- src: icon
38
+ src: icon,
39
+ alt: 'error block image'
39
40
  });
40
41
 
41
42
  if (props.image) {
42
43
  if (typeof props.image === 'string') {
43
44
  imageNode = _react.default.createElement("img", {
44
- src: props.image
45
+ src: props.image,
46
+ alt: 'error block image'
45
47
  });
46
48
  } else {
47
49
  imageNode = props.image;
@@ -7,6 +7,7 @@
7
7
  --edge-distance: 0;
8
8
  --size: 96px;
9
9
  --border-radius: 50%;
10
+ --background: var(--adm-color-primary);
10
11
  }
11
12
 
12
13
  .adm-floating-bubble-boundary-outer {
@@ -43,7 +44,7 @@
43
44
  transition: opacity ease 0.15s;
44
45
  user-select: none;
45
46
  touch-action: none;
46
- background: var(--adm-color-primary);
47
+ background: var(--background);
47
48
  color: var(--adm-color-white);
48
49
  border-radius: var(--border-radius);
49
50
  z-index: var(--z-index);
@@ -4,5 +4,5 @@ export declare type FloatingBubbleProps = {
4
4
  onClick?: (event: React.MouseEvent<HTMLDivElement, MouseEvent>) => void;
5
5
  axis?: 'x' | 'y' | 'xy' | 'lock';
6
6
  magnetic?: 'x' | 'y';
7
- } & NativeProps<'--initial-position-left' | '--initial-position-right' | '--initial-position-top' | '--initial-position-bottom' | '--z-index' | '--edge-distance' | '--size' | '--border-radius'>;
7
+ } & NativeProps<'--initial-position-left' | '--initial-position-right' | '--initial-position-top' | '--initial-position-bottom' | '--z-index' | '--edge-distance' | '--size' | '--border-radius' | '--background'>;
8
8
  export declare const FloatingBubble: FC<FloatingBubbleProps>;
@@ -2,7 +2,7 @@
2
2
  import './image-viewer.less';
3
3
  import { showMultiImageViewer, showImageViewer, clearImageViewer } from './methods';
4
4
  export type { ImageViewerProps, MultiImageViewerProps, MultiImageViewerRef, } from './image-viewer';
5
- export type { ImageViewerHandler } from './methods';
5
+ export type { ImageViewerShowHandler } from './methods';
6
6
  declare const _default: import("react").FC<import("./image-viewer").ImageViewerProps> & {
7
7
  Multi: import("react").ForwardRefExoticComponent<Omit<import("./image-viewer").ImageViewerProps, "image"> & {
8
8
  images?: string[] | undefined;
@@ -1,11 +1,10 @@
1
1
  import { ImageViewerProps, MultiImageViewerProps } from './image-viewer';
2
- export declare type ImageViewerHandler = {
3
- close: () => void;
4
- };
5
- export declare function showImageViewer(props: Omit<ImageViewerProps, 'visible'>): {
2
+ export declare type ImageViewerShowHandler = {
6
3
  close: () => void;
7
4
  };
5
+ export declare function showImageViewer(props: Omit<ImageViewerProps, 'visible'>): ImageViewerShowHandler;
8
6
  export declare function showMultiImageViewer(props: Omit<MultiImageViewerProps, 'visible'>): {
9
7
  close: () => void;
10
8
  };
11
9
  export declare function clearImageViewer(): void;
10
+ export declare const getH: () => void;
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.clearImageViewer = clearImageViewer;
7
+ exports.getH = void 0;
7
8
  exports.showImageViewer = showImageViewer;
8
9
  exports.showMultiImageViewer = showMultiImageViewer;
9
10
 
@@ -13,7 +14,7 @@ var _renderToBody = require("../../utils/render-to-body");
13
14
 
14
15
  var _imageViewer = require("./image-viewer");
15
16
 
16
- var _ahooks = require("ahooks");
17
+ var _renderImperatively = require("../../utils/render-imperatively");
17
18
 
18
19
  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); }
19
20
 
@@ -23,45 +24,14 @@ const handlerSet = new Set();
23
24
 
24
25
  function showImageViewer(props) {
25
26
  clearImageViewer();
26
- const Wrapper = (0, _react.forwardRef)((_, ref) => {
27
- const [visible, setVisible] = (0, _react.useState)(false);
28
- (0, _react.useEffect)(() => {
29
- setVisible(true);
30
- }, []);
31
- const isUnmountedRef = (0, _ahooks.useUnmountedRef)();
32
- (0, _react.useImperativeHandle)(ref, () => ({
33
- close: () => {
34
- if (isUnmountedRef.current) return;
35
- setVisible(false);
36
- }
37
- }));
38
- return _react.default.createElement(_imageViewer.ImageViewer, Object.assign({}, props, {
39
- visible: visible,
40
- onClose: () => {
41
- var _a;
42
-
43
- (_a = props.onClose) === null || _a === void 0 ? void 0 : _a.call(props);
44
- setVisible(false);
45
- },
46
- afterClose: () => {
47
- var _a;
48
-
49
- (_a = props.afterClose) === null || _a === void 0 ? void 0 : _a.call(props);
50
- unmount();
51
- }
52
- }));
53
- });
54
- const ref = (0, _react.createRef)();
55
- const unmount = (0, _renderToBody.renderToBody)(_react.default.createElement(Wrapper, {
56
- ref: ref
57
- }));
58
- const handler = {
59
- close: () => {
27
+ const handler = (0, _renderImperatively.renderImperatively)(_react.default.createElement(_imageViewer.ImageViewer, Object.assign({}, props, {
28
+ afterClose: () => {
60
29
  var _a;
61
30
 
62
- (_a = ref.current) === null || _a === void 0 ? void 0 : _a.close();
31
+ handlerSet.delete(handler);
32
+ (_a = props.afterClose) === null || _a === void 0 ? void 0 : _a.call(props);
63
33
  }
64
- };
34
+ })));
65
35
  handlerSet.add(handler);
66
36
  return handler;
67
37
  }
@@ -70,30 +40,39 @@ function showMultiImageViewer(props) {
70
40
  clearImageViewer();
71
41
  const Wrapper = (0, _react.forwardRef)((_, ref) => {
72
42
  const [visible, setVisible] = (0, _react.useState)(false);
43
+ const closedRef = (0, _react.useRef)(false);
73
44
  (0, _react.useEffect)(() => {
74
- setVisible(true);
45
+ if (!closedRef.current) {
46
+ setVisible(true);
47
+ } else {
48
+ handleAfterClose();
49
+ }
75
50
  }, []);
76
- const isUnmountedRef = (0, _ahooks.useUnmountedRef)();
51
+
52
+ function handleClose() {
53
+ var _a;
54
+
55
+ closedRef.current = true;
56
+ (_a = props.onClose) === null || _a === void 0 ? void 0 : _a.call(props);
57
+ setVisible(false);
58
+ }
59
+
77
60
  (0, _react.useImperativeHandle)(ref, () => ({
78
- close: () => {
79
- if (isUnmountedRef.current) return;
80
- setVisible(false);
81
- }
61
+ close: handleClose
82
62
  }));
83
- return _react.default.createElement(_imageViewer.MultiImageViewer, Object.assign({}, props, {
84
- visible: visible,
85
- onClose: () => {
86
- var _a;
87
63
 
88
- (_a = props.onClose) === null || _a === void 0 ? void 0 : _a.call(props);
89
- setVisible(false);
90
- },
91
- afterClose: () => {
92
- var _a;
64
+ function handleAfterClose() {
65
+ var _a;
93
66
 
94
- (_a = props.afterClose) === null || _a === void 0 ? void 0 : _a.call(props);
95
- unmount();
96
- }
67
+ (_a = props.afterClose) === null || _a === void 0 ? void 0 : _a.call(props);
68
+ unmount();
69
+ handlerSet.delete(handler);
70
+ }
71
+
72
+ return _react.default.createElement(_imageViewer.MultiImageViewer, Object.assign({}, props, {
73
+ visible: visible,
74
+ onClose: handleClose,
75
+ afterClose: handleAfterClose
97
76
  }));
98
77
  });
99
78
  const ref = (0, _react.createRef)();
@@ -116,4 +95,10 @@ function clearImageViewer() {
116
95
  handler.close();
117
96
  });
118
97
  handlerSet.clear();
119
- }
98
+ }
99
+
100
+ const getH = () => {
101
+ console.log(handlerSet);
102
+ };
103
+
104
+ exports.getH = getH;
@@ -6,7 +6,7 @@ import { confirm } from './confirm';
6
6
  import { clear } from './clear';
7
7
  export type { ModalProps } from './modal';
8
8
  export type { Action } from './modal-action-button';
9
- export type { ModalShowProps, ModalShowRef } from './show';
9
+ export type { ModalShowProps, ModalShowHandler } from './show';
10
10
  export type { ModalAlertProps } from './alert';
11
11
  export type { ModalConfirmProps } from './confirm';
12
12
  declare const _default: import("react").FC<import("./modal").ModalProps> & {
@@ -1,9 +1,7 @@
1
1
  import { ModalProps } from './modal';
2
2
  export declare type ModalShowProps = Omit<ModalProps, 'visible'>;
3
- export declare type ModalShowRef = {
3
+ export declare type ModalShowHandler = {
4
4
  close: () => void;
5
5
  };
6
6
  export declare const closeFnSet: Set<() => void>;
7
- export declare function show(props: ModalShowProps): {
8
- close: () => void;
9
- };
7
+ export declare function show(props: ModalShowProps): ModalShowHandler;
@@ -6,64 +6,26 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.closeFnSet = void 0;
7
7
  exports.show = show;
8
8
 
9
- var _react = _interopRequireWildcard(require("react"));
10
-
11
- var _renderToBody = require("../../utils/render-to-body");
9
+ var _react = _interopRequireDefault(require("react"));
12
10
 
13
11
  var _modal = require("./modal");
14
12
 
15
- 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); }
13
+ var _renderImperatively = require("../../utils/render-imperatively");
16
14
 
17
- 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; }
15
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
18
16
 
19
17
  const closeFnSet = new Set();
20
18
  exports.closeFnSet = closeFnSet;
21
19
 
22
20
  function show(props) {
23
- const Wrapper = (0, _react.forwardRef)((_, ref) => {
24
- const [visible, setVisible] = (0, _react.useState)(false);
25
- (0, _react.useEffect)(() => {
26
- setVisible(true);
27
- }, []);
28
-
29
- function handleClose() {
30
- var _a;
31
-
32
- (_a = props.onClose) === null || _a === void 0 ? void 0 : _a.call(props);
33
- setVisible(false);
34
- }
35
-
36
- (0, _react.useImperativeHandle)(ref, () => ({
37
- close: handleClose
38
- }));
39
-
40
- function handleAfterClose() {
21
+ const handler = (0, _renderImperatively.renderImperatively)(_react.default.createElement(_modal.Modal, Object.assign({}, props, {
22
+ afterClose: () => {
41
23
  var _a;
42
24
 
25
+ closeFnSet.delete(handler.close);
43
26
  (_a = props.afterClose) === null || _a === void 0 ? void 0 : _a.call(props);
44
- unmount();
45
- closeFnSet.delete(close);
46
27
  }
47
-
48
- return _react.default.createElement(_modal.Modal, Object.assign({}, props, {
49
- visible: visible,
50
- onClose: handleClose,
51
- afterClose: handleAfterClose
52
- }));
53
- });
54
- const ref = (0, _react.createRef)();
55
- const unmount = (0, _renderToBody.renderToBody)(_react.default.createElement(Wrapper, {
56
- ref: ref
57
- }));
58
-
59
- const close = () => {
60
- var _a;
61
-
62
- (_a = ref.current) === null || _a === void 0 ? void 0 : _a.close();
63
- };
64
-
65
- closeFnSet.add(close);
66
- return {
67
- close
68
- };
28
+ })));
29
+ closeFnSet.add(handler.close);
30
+ return handler;
69
31
  }