musae 1.0.27-beta.41 → 1.0.27-beta.42
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/action-sheet/index.d.ts +3 -4
- package/dist/components/action-sheet/use-action-sheet.cjs +60 -0
- package/dist/components/action-sheet/use-action-sheet.d.ts +9 -0
- package/dist/components/action-sheet/use-action-sheet.mjs +58 -0
- package/dist/components/notification/holder.cjs +2 -3
- package/dist/components/notification/holder.mjs +4 -5
- package/dist/index.cjs +22 -20
- package/dist/index.d.ts +1 -0
- package/dist/index.mjs +2 -1
- package/dist/types/action-sheet.d.ts +11 -0
- package/package.json +1 -1
- package/dist/components/action-sheet/index.cjs +0 -8
- package/dist/components/action-sheet/index.mjs +0 -6
- package/dist/components/action-sheet/notifier.cjs +0 -142
- package/dist/components/action-sheet/notifier.d.ts +0 -17
- package/dist/components/action-sheet/notifier.mjs +0 -138
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
};
|
|
4
|
-
export { ActionSheetWithApi as ActionSheet };
|
|
1
|
+
import ActionSheet from "./action-sheet";
|
|
2
|
+
import { useActionSheet } from "./use-action-sheet";
|
|
3
|
+
export { ActionSheet, useActionSheet };
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var _objectSpread = require('@babel/runtime/helpers/objectSpread2');
|
|
4
|
+
var _regenerator = require('@babel/runtime/helpers/regenerator');
|
|
5
|
+
var _asyncToGenerator = require('@babel/runtime/helpers/asyncToGenerator');
|
|
6
|
+
var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
|
|
7
|
+
var React = require('react');
|
|
8
|
+
var relax = require('@aiszlab/relax');
|
|
9
|
+
var actionSheet = require('./action-sheet.cjs');
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @zh useActionSheet hook。返回 show 函数和 holder 元素。
|
|
13
|
+
* 需要在组件树中渲染 holder,然后通过 show 函数调用。
|
|
14
|
+
* @en useActionSheet hook. Returns a show function and a holder element.
|
|
15
|
+
* Render the holder in the component tree, then call via the show function.
|
|
16
|
+
*/
|
|
17
|
+
var useActionSheet = function useActionSheet() {
|
|
18
|
+
var _useState = React.useState(null),
|
|
19
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
20
|
+
config = _useState2[0],
|
|
21
|
+
setConfig = _useState2[1];
|
|
22
|
+
var _useState3 = React.useState(false),
|
|
23
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
24
|
+
open = _useState4[0],
|
|
25
|
+
setOpen = _useState4[1];
|
|
26
|
+
var handleClose = React.useCallback(function () {
|
|
27
|
+
setOpen(false);
|
|
28
|
+
}, []);
|
|
29
|
+
var show = relax.useEvent(/*#__PURE__*/function () {
|
|
30
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(nextConfig) {
|
|
31
|
+
return _regenerator().w(function (_context) {
|
|
32
|
+
while (1) switch (_context.n) {
|
|
33
|
+
case 0:
|
|
34
|
+
setConfig(nextConfig);
|
|
35
|
+
setOpen(true);
|
|
36
|
+
case 1:
|
|
37
|
+
return _context.a(2);
|
|
38
|
+
}
|
|
39
|
+
}, _callee);
|
|
40
|
+
}));
|
|
41
|
+
return function (_x) {
|
|
42
|
+
return _ref.apply(this, arguments);
|
|
43
|
+
};
|
|
44
|
+
}());
|
|
45
|
+
var trigger = React.useMemo(function () {
|
|
46
|
+
return {
|
|
47
|
+
show: show
|
|
48
|
+
};
|
|
49
|
+
}, [show]);
|
|
50
|
+
var holder = React.useMemo(function () {
|
|
51
|
+
if (!config) return null;
|
|
52
|
+
return /*#__PURE__*/React.createElement(actionSheet.default, _objectSpread({
|
|
53
|
+
open: open,
|
|
54
|
+
onClose: handleClose
|
|
55
|
+
}, config));
|
|
56
|
+
}, [config, open, handleClose]);
|
|
57
|
+
return [trigger, holder];
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
exports.useActionSheet = useActionSheet;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
import type { ActionSheetTrigger } from "../../types/action-sheet";
|
|
3
|
+
/**
|
|
4
|
+
* @zh useActionSheet hook。返回 show 函数和 holder 元素。
|
|
5
|
+
* 需要在组件树中渲染 holder,然后通过 show 函数调用。
|
|
6
|
+
* @en useActionSheet hook. Returns a show function and a holder element.
|
|
7
|
+
* Render the holder in the component tree, then call via the show function.
|
|
8
|
+
*/
|
|
9
|
+
export declare const useActionSheet: () => [ActionSheetTrigger, ReactNode];
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import _objectSpread from '@babel/runtime/helpers/objectSpread2';
|
|
2
|
+
import _regenerator from '@babel/runtime/helpers/regenerator';
|
|
3
|
+
import _asyncToGenerator from '@babel/runtime/helpers/asyncToGenerator';
|
|
4
|
+
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
5
|
+
import React, { useState, useCallback, useMemo } from 'react';
|
|
6
|
+
import { useEvent } from '@aiszlab/relax';
|
|
7
|
+
import ActionSheet from './action-sheet.mjs';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @zh useActionSheet hook。返回 show 函数和 holder 元素。
|
|
11
|
+
* 需要在组件树中渲染 holder,然后通过 show 函数调用。
|
|
12
|
+
* @en useActionSheet hook. Returns a show function and a holder element.
|
|
13
|
+
* Render the holder in the component tree, then call via the show function.
|
|
14
|
+
*/
|
|
15
|
+
var useActionSheet = function useActionSheet() {
|
|
16
|
+
var _useState = useState(null),
|
|
17
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
18
|
+
config = _useState2[0],
|
|
19
|
+
setConfig = _useState2[1];
|
|
20
|
+
var _useState3 = useState(false),
|
|
21
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
22
|
+
open = _useState4[0],
|
|
23
|
+
setOpen = _useState4[1];
|
|
24
|
+
var handleClose = useCallback(function () {
|
|
25
|
+
setOpen(false);
|
|
26
|
+
}, []);
|
|
27
|
+
var show = useEvent(/*#__PURE__*/function () {
|
|
28
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(nextConfig) {
|
|
29
|
+
return _regenerator().w(function (_context) {
|
|
30
|
+
while (1) switch (_context.n) {
|
|
31
|
+
case 0:
|
|
32
|
+
setConfig(nextConfig);
|
|
33
|
+
setOpen(true);
|
|
34
|
+
case 1:
|
|
35
|
+
return _context.a(2);
|
|
36
|
+
}
|
|
37
|
+
}, _callee);
|
|
38
|
+
}));
|
|
39
|
+
return function (_x) {
|
|
40
|
+
return _ref.apply(this, arguments);
|
|
41
|
+
};
|
|
42
|
+
}());
|
|
43
|
+
var trigger = useMemo(function () {
|
|
44
|
+
return {
|
|
45
|
+
show: show
|
|
46
|
+
};
|
|
47
|
+
}, [show]);
|
|
48
|
+
var holder = useMemo(function () {
|
|
49
|
+
if (!config) return null;
|
|
50
|
+
return /*#__PURE__*/React.createElement(ActionSheet, _objectSpread({
|
|
51
|
+
open: open,
|
|
52
|
+
onClose: handleClose
|
|
53
|
+
}, config));
|
|
54
|
+
}, [config, open, handleClose]);
|
|
55
|
+
return [trigger, holder];
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
export { useActionSheet };
|
|
@@ -102,12 +102,11 @@ var Holder = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
102
102
|
return next;
|
|
103
103
|
});
|
|
104
104
|
});
|
|
105
|
-
|
|
105
|
+
relax.useMounted(function () {
|
|
106
106
|
defaultNotifications === null || defaultNotifications === void 0 || defaultNotifications.forEach(function (notification) {
|
|
107
107
|
add(notification);
|
|
108
108
|
});
|
|
109
|
-
|
|
110
|
-
}, []);
|
|
109
|
+
});
|
|
111
110
|
React.useImperativeHandle(ref, function () {
|
|
112
111
|
return {
|
|
113
112
|
add: add
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import _objectSpread from '@babel/runtime/helpers/objectSpread2';
|
|
2
2
|
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
3
3
|
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
4
|
-
import React, { forwardRef, useState,
|
|
4
|
+
import React, { forwardRef, useState, useImperativeHandle } from 'react';
|
|
5
5
|
import Portal from '../portal/portal.mjs';
|
|
6
6
|
import { AnimatePresence } from 'motion/react';
|
|
7
7
|
import Notification from './notification.mjs';
|
|
8
8
|
import { props } from '../../node_modules/.pnpm/@stylexjs_stylex@0.18.3/node_modules/@stylexjs/stylex/lib/es/stylex.mjs';
|
|
9
|
-
import { useIdentity, useEvent } from '@aiszlab/relax';
|
|
9
|
+
import { useIdentity, useEvent, useMounted } from '@aiszlab/relax';
|
|
10
10
|
|
|
11
11
|
var _excluded = ["placement", "key"],
|
|
12
12
|
_excluded2 = ["description"];
|
|
@@ -98,12 +98,11 @@ var Holder = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
98
98
|
return next;
|
|
99
99
|
});
|
|
100
100
|
});
|
|
101
|
-
|
|
101
|
+
useMounted(function () {
|
|
102
102
|
defaultNotifications === null || defaultNotifications === void 0 || defaultNotifications.forEach(function (notification) {
|
|
103
103
|
add(notification);
|
|
104
104
|
});
|
|
105
|
-
|
|
106
|
-
}, []);
|
|
105
|
+
});
|
|
107
106
|
useImperativeHandle(ref, function () {
|
|
108
107
|
return {
|
|
109
108
|
add: add
|
package/dist/index.cjs
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var index = require('./components/
|
|
4
|
-
var index$
|
|
5
|
-
var index$
|
|
6
|
-
var index$
|
|
7
|
-
var index$
|
|
8
|
-
var index$
|
|
9
|
-
var index$
|
|
10
|
-
var index$
|
|
11
|
-
var index$
|
|
12
|
-
var
|
|
3
|
+
var index = require('./components/avatar/index.cjs');
|
|
4
|
+
var index$7 = require('./components/radio/index.cjs');
|
|
5
|
+
var index$1 = require('./components/checkbox/index.cjs');
|
|
6
|
+
var index$3 = require('./components/grid/index.cjs');
|
|
7
|
+
var index$2 = require('./components/form/index.cjs');
|
|
8
|
+
var index$5 = require('./components/layout/index.cjs');
|
|
9
|
+
var index$4 = require('./components/image/index.cjs');
|
|
10
|
+
var index$8 = require('./components/rich-text-editor/index.cjs');
|
|
11
|
+
var index$6 = require('./components/markdown/index.cjs');
|
|
12
|
+
var actionSheet = require('./components/action-sheet/action-sheet.cjs');
|
|
13
13
|
var badge = require('./components/badge/badge.cjs');
|
|
14
14
|
var bench = require('./components/bench/bench.cjs');
|
|
15
15
|
var bottomSheet = require('./components/bottom-sheet/bottom-sheet.cjs');
|
|
@@ -72,22 +72,23 @@ var visuallyHidden = require('./components/visually-hidden/visually-hidden.cjs')
|
|
|
72
72
|
var waterfall = require('./components/waterfall/waterfall.cjs');
|
|
73
73
|
var watermark = require('./components/watermark/watermark.cjs');
|
|
74
74
|
var highlight = require('./components/highlight/highlight.cjs');
|
|
75
|
+
var useActionSheet = require('./components/action-sheet/use-action-sheet.cjs');
|
|
75
76
|
var hooks = require('./components/message/hooks.cjs');
|
|
76
77
|
var hooks$1 = require('./components/notification/hooks.cjs');
|
|
77
78
|
var hooks$2 = require('./components/theme/hooks.cjs');
|
|
78
79
|
|
|
79
80
|
|
|
80
81
|
|
|
81
|
-
exports.
|
|
82
|
-
exports.
|
|
83
|
-
exports.
|
|
84
|
-
exports.
|
|
85
|
-
exports.
|
|
86
|
-
exports.
|
|
87
|
-
exports.
|
|
88
|
-
exports.
|
|
89
|
-
exports.
|
|
90
|
-
exports.
|
|
82
|
+
exports.Avatar = index.Avatar;
|
|
83
|
+
exports.Radio = index$7.Radio;
|
|
84
|
+
exports.Checkbox = index$1.Checkbox;
|
|
85
|
+
exports.Grid = index$3.Grid;
|
|
86
|
+
exports.Form = index$2.Form;
|
|
87
|
+
exports.Layout = index$5.Layout;
|
|
88
|
+
exports.Image = index$4.Image;
|
|
89
|
+
exports.RichTextEditor = index$8.RichTextEditor;
|
|
90
|
+
exports.Markdown = index$6.Markdown;
|
|
91
|
+
exports.ActionSheet = actionSheet.default;
|
|
91
92
|
exports.Badge = badge.default;
|
|
92
93
|
exports.Bench = bench.default;
|
|
93
94
|
exports.BottomSheet = bottomSheet.default;
|
|
@@ -150,6 +151,7 @@ exports.VisuallyHidden = visuallyHidden.default;
|
|
|
150
151
|
exports.Waterfall = waterfall.default;
|
|
151
152
|
exports.Watermark = watermark.default;
|
|
152
153
|
exports.Highlight = highlight.default;
|
|
154
|
+
exports.useActionSheet = useActionSheet.useActionSheet;
|
|
153
155
|
exports.useMessage = hooks.useMessage;
|
|
154
156
|
exports.useNotification = hooks$1.useNotification;
|
|
155
157
|
exports.useTheme = hooks$2.useTheme;
|
package/dist/index.d.ts
CHANGED
|
@@ -77,4 +77,5 @@ export { Search } from "./components/search";
|
|
|
77
77
|
*/
|
|
78
78
|
export { useMessage, Message } from "./components/message";
|
|
79
79
|
export { useNotification, Notification } from "./components/notification";
|
|
80
|
+
export { useActionSheet } from "./components/action-sheet";
|
|
80
81
|
export { useTheme } from "./components/theme";
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
export { ActionSheet } from './components/action-sheet/index.mjs';
|
|
2
1
|
export { Avatar } from './components/avatar/index.mjs';
|
|
3
2
|
export { Radio } from './components/radio/index.mjs';
|
|
4
3
|
export { Checkbox } from './components/checkbox/index.mjs';
|
|
@@ -8,6 +7,7 @@ export { Layout } from './components/layout/index.mjs';
|
|
|
8
7
|
export { Image } from './components/image/index.mjs';
|
|
9
8
|
export { RichTextEditor } from './components/rich-text-editor/index.mjs';
|
|
10
9
|
export { Markdown } from './components/markdown/index.mjs';
|
|
10
|
+
export { default as ActionSheet } from './components/action-sheet/action-sheet.mjs';
|
|
11
11
|
export { default as Badge } from './components/badge/badge.mjs';
|
|
12
12
|
export { default as Bench } from './components/bench/bench.mjs';
|
|
13
13
|
export { default as BottomSheet } from './components/bottom-sheet/bottom-sheet.mjs';
|
|
@@ -70,6 +70,7 @@ export { default as VisuallyHidden } from './components/visually-hidden/visually
|
|
|
70
70
|
export { default as Waterfall } from './components/waterfall/waterfall.mjs';
|
|
71
71
|
export { default as Watermark } from './components/watermark/watermark.mjs';
|
|
72
72
|
export { default as Highlight } from './components/highlight/highlight.mjs';
|
|
73
|
+
export { useActionSheet } from './components/action-sheet/use-action-sheet.mjs';
|
|
73
74
|
export { useMessage } from './components/message/hooks.mjs';
|
|
74
75
|
export { useNotification } from './components/notification/hooks.mjs';
|
|
75
76
|
export { useTheme } from './components/theme/hooks.mjs';
|
|
@@ -72,3 +72,14 @@ export interface ActionSheetProps extends ComponentProps {
|
|
|
72
72
|
* @en Configuration for the imperative API `ActionSheet.show()`.
|
|
73
73
|
*/
|
|
74
74
|
export type ActionSheetShowConfig = Omit<ActionSheetProps, "open" | "onClose">;
|
|
75
|
+
/**
|
|
76
|
+
* @zh `useActionSheet` hook 返回的 show 函数类型。
|
|
77
|
+
* @en The type of the show function returned by `useActionSheet` hook.
|
|
78
|
+
*/
|
|
79
|
+
export type ActionSheetTrigger = {
|
|
80
|
+
/**
|
|
81
|
+
* @zh 显示 ActionSheet,返回 Promise 在面板关闭后 resolve。
|
|
82
|
+
* @en Show the ActionSheet, returns a Promise that resolves after the panel closes.
|
|
83
|
+
*/
|
|
84
|
+
show: (config: ActionSheetShowConfig) => Promise<void>;
|
|
85
|
+
};
|
package/package.json
CHANGED
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var _classCallCheck = require('@babel/runtime/helpers/classCallCheck');
|
|
6
|
-
var _createClass = require('@babel/runtime/helpers/createClass');
|
|
7
|
-
var _classPrivateMethodInitSpec = require('@babel/runtime/helpers/classPrivateMethodInitSpec');
|
|
8
|
-
var _classPrivateFieldInitSpec = require('@babel/runtime/helpers/classPrivateFieldInitSpec');
|
|
9
|
-
var _assertClassBrand = require('@babel/runtime/helpers/assertClassBrand');
|
|
10
|
-
var _classPrivateFieldSet = require('@babel/runtime/helpers/classPrivateFieldSet2');
|
|
11
|
-
var _classPrivateFieldGet = require('@babel/runtime/helpers/classPrivateFieldGet2');
|
|
12
|
-
var _objectSpread = require('@babel/runtime/helpers/objectSpread2');
|
|
13
|
-
var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
|
|
14
|
-
var React = require('react');
|
|
15
|
-
var client = require('react-dom/client');
|
|
16
|
-
var actionSheet = require('./action-sheet.cjs');
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* @zh 指令式 API 的内部 Holder 组件。
|
|
20
|
-
* 管理 open 状态,在退出动画完成后清理 root 并 resolve Promise。
|
|
21
|
-
* @en Internal Holder component for the imperative API.
|
|
22
|
-
* Manages open state, cleans up root and resolves Promise after exit animation.
|
|
23
|
-
*/
|
|
24
|
-
var ActionSheetHolder = function ActionSheetHolder(_ref) {
|
|
25
|
-
var config = _ref.config,
|
|
26
|
-
onResolve = _ref.onResolve;
|
|
27
|
-
var _useState = React.useState(true),
|
|
28
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
29
|
-
open = _useState2[0],
|
|
30
|
-
setOpen = _useState2[1];
|
|
31
|
-
/**
|
|
32
|
-
* @zh 关闭面板:设置 open=false 触发退出动画,
|
|
33
|
-
* 等待动画完成后调用 onResolve 清理 root。
|
|
34
|
-
* @en Close the panel: set open=false to trigger exit animation,
|
|
35
|
-
* wait for animation to complete then call onResolve to cleanup root.
|
|
36
|
-
*/
|
|
37
|
-
var handleClose = React.useCallback(function () {
|
|
38
|
-
setOpen(false);
|
|
39
|
-
setTimeout(function () {
|
|
40
|
-
onResolve();
|
|
41
|
-
}, 350);
|
|
42
|
-
}, [onResolve]);
|
|
43
|
-
return /*#__PURE__*/React.createElement(actionSheet.default, _objectSpread({
|
|
44
|
-
open: open,
|
|
45
|
-
onClose: handleClose
|
|
46
|
-
}, config));
|
|
47
|
-
};
|
|
48
|
-
/**
|
|
49
|
-
* @zh ActionSheet 指令式 API 的 Notifier 单例。
|
|
50
|
-
* 每次调用 show() 创建新的 React root,返回在面板关闭后 resolve 的 Promise。
|
|
51
|
-
* 如果重复调用 show(),会先清理旧面板(旧 Promise 立即 resolve)。
|
|
52
|
-
* @en Notifier singleton for the ActionSheet imperative API.
|
|
53
|
-
* Each show() call creates a new React root and returns a Promise that resolves after panel closes.
|
|
54
|
-
* If show() is called again while a panel is open, the old panel is cleaned up (old Promise resolves immediately).
|
|
55
|
-
*/
|
|
56
|
-
var _root = /*#__PURE__*/new WeakMap();
|
|
57
|
-
var _cleanup = /*#__PURE__*/new WeakMap();
|
|
58
|
-
var _ActionSheetNotifier_brand = /*#__PURE__*/new WeakSet();
|
|
59
|
-
var ActionSheetNotifier = /*#__PURE__*/function () {
|
|
60
|
-
function ActionSheetNotifier() {
|
|
61
|
-
_classCallCheck(this, ActionSheetNotifier);
|
|
62
|
-
/**
|
|
63
|
-
* @zh 清理当前面板(如果有)。
|
|
64
|
-
* @en Clean up the current panel if exists.
|
|
65
|
-
*/
|
|
66
|
-
_classPrivateMethodInitSpec(this, _ActionSheetNotifier_brand);
|
|
67
|
-
_classPrivateFieldInitSpec(this, _root, null);
|
|
68
|
-
_classPrivateFieldInitSpec(this, _cleanup, null);
|
|
69
|
-
if (_instance._) {
|
|
70
|
-
return _instance._;
|
|
71
|
-
}
|
|
72
|
-
_instance._ = this;
|
|
73
|
-
}
|
|
74
|
-
return _createClass(ActionSheetNotifier, [{
|
|
75
|
-
key: "show",
|
|
76
|
-
value:
|
|
77
|
-
/**
|
|
78
|
-
* @zh 显示 ActionSheet。返回的 Promise 在面板关闭动画完成后 resolve。
|
|
79
|
-
* 如果当前已有面板显示,会先清理旧面板再显示新的。
|
|
80
|
-
* @en Show the ActionSheet. Returns a Promise that resolves after the close animation completes.
|
|
81
|
-
* If a panel is already showing, it will be cleaned up before showing the new one.
|
|
82
|
-
*/
|
|
83
|
-
function show(config) {
|
|
84
|
-
var _this = this;
|
|
85
|
-
_assertClassBrand(_ActionSheetNotifier_brand, this, _disposeCurrent).call(this);
|
|
86
|
-
return new Promise(function (resolve) {
|
|
87
|
-
var fragment = document.createDocumentFragment();
|
|
88
|
-
var root = client.createRoot(fragment);
|
|
89
|
-
_classPrivateFieldSet(_root, _this, root);
|
|
90
|
-
var cleanup = function cleanup() {
|
|
91
|
-
_classPrivateFieldSet(_root, _this, null);
|
|
92
|
-
_classPrivateFieldSet(_cleanup, _this, null);
|
|
93
|
-
root.unmount();
|
|
94
|
-
resolve();
|
|
95
|
-
};
|
|
96
|
-
_classPrivateFieldSet(_cleanup, _this, function () {
|
|
97
|
-
_classPrivateFieldSet(_root, _this, null);
|
|
98
|
-
_classPrivateFieldSet(_cleanup, _this, null);
|
|
99
|
-
root.unmount();
|
|
100
|
-
resolve();
|
|
101
|
-
});
|
|
102
|
-
root.render(/*#__PURE__*/React.createElement(ActionSheetHolder, {
|
|
103
|
-
config: config,
|
|
104
|
-
onResolve: cleanup
|
|
105
|
-
}));
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
}]);
|
|
109
|
-
}();
|
|
110
|
-
function _disposeCurrent() {
|
|
111
|
-
if (_classPrivateFieldGet(_cleanup, this)) {
|
|
112
|
-
_classPrivateFieldGet(_cleanup, this).call(this);
|
|
113
|
-
_classPrivateFieldSet(_cleanup, this, null);
|
|
114
|
-
}
|
|
115
|
-
if (_classPrivateFieldGet(_root, this)) {
|
|
116
|
-
_classPrivateFieldGet(_root, this).unmount();
|
|
117
|
-
_classPrivateFieldSet(_root, this, null);
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
var _instance = {
|
|
121
|
-
_: null
|
|
122
|
-
};
|
|
123
|
-
var notifier = new ActionSheetNotifier();
|
|
124
|
-
/**
|
|
125
|
-
* @zh ActionSheet 的指令式 API。
|
|
126
|
-
* 调用 `ActionSheet.show(config)` 显示操作面板,返回 Promise。
|
|
127
|
-
* @en ActionSheet imperative API.
|
|
128
|
-
* Call `ActionSheet.show(config)` to display the action panel, returns a Promise.
|
|
129
|
-
*/
|
|
130
|
-
var ActionSheetApi = {
|
|
131
|
-
/**
|
|
132
|
-
* @zh 显示 ActionSheet 操作面板。
|
|
133
|
-
* 返回 Promise,在面板关闭动画完成后 resolve。
|
|
134
|
-
* @en Show the ActionSheet panel.
|
|
135
|
-
* Returns a Promise that resolves after the close animation completes.
|
|
136
|
-
*/
|
|
137
|
-
show: function show(config) {
|
|
138
|
-
return notifier.show(config);
|
|
139
|
-
}
|
|
140
|
-
};
|
|
141
|
-
|
|
142
|
-
exports.default = ActionSheetApi;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { ActionSheetShowConfig } from "../../types/action-sheet";
|
|
2
|
-
/**
|
|
3
|
-
* @zh ActionSheet 的指令式 API。
|
|
4
|
-
* 调用 `ActionSheet.show(config)` 显示操作面板,返回 Promise。
|
|
5
|
-
* @en ActionSheet imperative API.
|
|
6
|
-
* Call `ActionSheet.show(config)` to display the action panel, returns a Promise.
|
|
7
|
-
*/
|
|
8
|
-
declare const ActionSheetApi: {
|
|
9
|
-
/**
|
|
10
|
-
* @zh 显示 ActionSheet 操作面板。
|
|
11
|
-
* 返回 Promise,在面板关闭动画完成后 resolve。
|
|
12
|
-
* @en Show the ActionSheet panel.
|
|
13
|
-
* Returns a Promise that resolves after the close animation completes.
|
|
14
|
-
*/
|
|
15
|
-
show: (config: ActionSheetShowConfig) => Promise<void>;
|
|
16
|
-
};
|
|
17
|
-
export default ActionSheetApi;
|
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
import _classCallCheck from '@babel/runtime/helpers/classCallCheck';
|
|
2
|
-
import _createClass from '@babel/runtime/helpers/createClass';
|
|
3
|
-
import _classPrivateMethodInitSpec from '@babel/runtime/helpers/classPrivateMethodInitSpec';
|
|
4
|
-
import _classPrivateFieldInitSpec from '@babel/runtime/helpers/classPrivateFieldInitSpec';
|
|
5
|
-
import _assertClassBrand from '@babel/runtime/helpers/assertClassBrand';
|
|
6
|
-
import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet2';
|
|
7
|
-
import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet2';
|
|
8
|
-
import _objectSpread from '@babel/runtime/helpers/objectSpread2';
|
|
9
|
-
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
10
|
-
import React, { useState, useCallback } from 'react';
|
|
11
|
-
import { createRoot } from 'react-dom/client';
|
|
12
|
-
import ActionSheet from './action-sheet.mjs';
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* @zh 指令式 API 的内部 Holder 组件。
|
|
16
|
-
* 管理 open 状态,在退出动画完成后清理 root 并 resolve Promise。
|
|
17
|
-
* @en Internal Holder component for the imperative API.
|
|
18
|
-
* Manages open state, cleans up root and resolves Promise after exit animation.
|
|
19
|
-
*/
|
|
20
|
-
var ActionSheetHolder = function ActionSheetHolder(_ref) {
|
|
21
|
-
var config = _ref.config,
|
|
22
|
-
onResolve = _ref.onResolve;
|
|
23
|
-
var _useState = useState(true),
|
|
24
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
25
|
-
open = _useState2[0],
|
|
26
|
-
setOpen = _useState2[1];
|
|
27
|
-
/**
|
|
28
|
-
* @zh 关闭面板:设置 open=false 触发退出动画,
|
|
29
|
-
* 等待动画完成后调用 onResolve 清理 root。
|
|
30
|
-
* @en Close the panel: set open=false to trigger exit animation,
|
|
31
|
-
* wait for animation to complete then call onResolve to cleanup root.
|
|
32
|
-
*/
|
|
33
|
-
var handleClose = useCallback(function () {
|
|
34
|
-
setOpen(false);
|
|
35
|
-
setTimeout(function () {
|
|
36
|
-
onResolve();
|
|
37
|
-
}, 350);
|
|
38
|
-
}, [onResolve]);
|
|
39
|
-
return /*#__PURE__*/React.createElement(ActionSheet, _objectSpread({
|
|
40
|
-
open: open,
|
|
41
|
-
onClose: handleClose
|
|
42
|
-
}, config));
|
|
43
|
-
};
|
|
44
|
-
/**
|
|
45
|
-
* @zh ActionSheet 指令式 API 的 Notifier 单例。
|
|
46
|
-
* 每次调用 show() 创建新的 React root,返回在面板关闭后 resolve 的 Promise。
|
|
47
|
-
* 如果重复调用 show(),会先清理旧面板(旧 Promise 立即 resolve)。
|
|
48
|
-
* @en Notifier singleton for the ActionSheet imperative API.
|
|
49
|
-
* Each show() call creates a new React root and returns a Promise that resolves after panel closes.
|
|
50
|
-
* If show() is called again while a panel is open, the old panel is cleaned up (old Promise resolves immediately).
|
|
51
|
-
*/
|
|
52
|
-
var _root = /*#__PURE__*/new WeakMap();
|
|
53
|
-
var _cleanup = /*#__PURE__*/new WeakMap();
|
|
54
|
-
var _ActionSheetNotifier_brand = /*#__PURE__*/new WeakSet();
|
|
55
|
-
var ActionSheetNotifier = /*#__PURE__*/function () {
|
|
56
|
-
function ActionSheetNotifier() {
|
|
57
|
-
_classCallCheck(this, ActionSheetNotifier);
|
|
58
|
-
/**
|
|
59
|
-
* @zh 清理当前面板(如果有)。
|
|
60
|
-
* @en Clean up the current panel if exists.
|
|
61
|
-
*/
|
|
62
|
-
_classPrivateMethodInitSpec(this, _ActionSheetNotifier_brand);
|
|
63
|
-
_classPrivateFieldInitSpec(this, _root, null);
|
|
64
|
-
_classPrivateFieldInitSpec(this, _cleanup, null);
|
|
65
|
-
if (_instance._) {
|
|
66
|
-
return _instance._;
|
|
67
|
-
}
|
|
68
|
-
_instance._ = this;
|
|
69
|
-
}
|
|
70
|
-
return _createClass(ActionSheetNotifier, [{
|
|
71
|
-
key: "show",
|
|
72
|
-
value:
|
|
73
|
-
/**
|
|
74
|
-
* @zh 显示 ActionSheet。返回的 Promise 在面板关闭动画完成后 resolve。
|
|
75
|
-
* 如果当前已有面板显示,会先清理旧面板再显示新的。
|
|
76
|
-
* @en Show the ActionSheet. Returns a Promise that resolves after the close animation completes.
|
|
77
|
-
* If a panel is already showing, it will be cleaned up before showing the new one.
|
|
78
|
-
*/
|
|
79
|
-
function show(config) {
|
|
80
|
-
var _this = this;
|
|
81
|
-
_assertClassBrand(_ActionSheetNotifier_brand, this, _disposeCurrent).call(this);
|
|
82
|
-
return new Promise(function (resolve) {
|
|
83
|
-
var fragment = document.createDocumentFragment();
|
|
84
|
-
var root = createRoot(fragment);
|
|
85
|
-
_classPrivateFieldSet(_root, _this, root);
|
|
86
|
-
var cleanup = function cleanup() {
|
|
87
|
-
_classPrivateFieldSet(_root, _this, null);
|
|
88
|
-
_classPrivateFieldSet(_cleanup, _this, null);
|
|
89
|
-
root.unmount();
|
|
90
|
-
resolve();
|
|
91
|
-
};
|
|
92
|
-
_classPrivateFieldSet(_cleanup, _this, function () {
|
|
93
|
-
_classPrivateFieldSet(_root, _this, null);
|
|
94
|
-
_classPrivateFieldSet(_cleanup, _this, null);
|
|
95
|
-
root.unmount();
|
|
96
|
-
resolve();
|
|
97
|
-
});
|
|
98
|
-
root.render(/*#__PURE__*/React.createElement(ActionSheetHolder, {
|
|
99
|
-
config: config,
|
|
100
|
-
onResolve: cleanup
|
|
101
|
-
}));
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
}]);
|
|
105
|
-
}();
|
|
106
|
-
function _disposeCurrent() {
|
|
107
|
-
if (_classPrivateFieldGet(_cleanup, this)) {
|
|
108
|
-
_classPrivateFieldGet(_cleanup, this).call(this);
|
|
109
|
-
_classPrivateFieldSet(_cleanup, this, null);
|
|
110
|
-
}
|
|
111
|
-
if (_classPrivateFieldGet(_root, this)) {
|
|
112
|
-
_classPrivateFieldGet(_root, this).unmount();
|
|
113
|
-
_classPrivateFieldSet(_root, this, null);
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
var _instance = {
|
|
117
|
-
_: null
|
|
118
|
-
};
|
|
119
|
-
var notifier = new ActionSheetNotifier();
|
|
120
|
-
/**
|
|
121
|
-
* @zh ActionSheet 的指令式 API。
|
|
122
|
-
* 调用 `ActionSheet.show(config)` 显示操作面板,返回 Promise。
|
|
123
|
-
* @en ActionSheet imperative API.
|
|
124
|
-
* Call `ActionSheet.show(config)` to display the action panel, returns a Promise.
|
|
125
|
-
*/
|
|
126
|
-
var ActionSheetApi = {
|
|
127
|
-
/**
|
|
128
|
-
* @zh 显示 ActionSheet 操作面板。
|
|
129
|
-
* 返回 Promise,在面板关闭动画完成后 resolve。
|
|
130
|
-
* @en Show the ActionSheet panel.
|
|
131
|
-
* Returns a Promise that resolves after the close animation completes.
|
|
132
|
-
*/
|
|
133
|
-
show: function show(config) {
|
|
134
|
-
return notifier.show(config);
|
|
135
|
-
}
|
|
136
|
-
};
|
|
137
|
-
|
|
138
|
-
export { ActionSheetApi as default };
|