musae 1.0.27-beta.40 → 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.
Files changed (31) hide show
  1. package/dist/components/action-sheet/__test__/index.test.d.ts +1 -0
  2. package/dist/components/action-sheet/action-sheet.cjs +168 -0
  3. package/dist/components/action-sheet/action-sheet.d.ts +10 -0
  4. package/dist/components/action-sheet/action-sheet.mjs +164 -0
  5. package/dist/components/action-sheet/context.cjs +19 -0
  6. package/dist/components/action-sheet/context.d.ts +15 -0
  7. package/dist/components/action-sheet/context.mjs +17 -0
  8. package/dist/components/action-sheet/index.d.ts +3 -0
  9. package/dist/components/action-sheet/use-action-sheet.cjs +60 -0
  10. package/dist/components/action-sheet/use-action-sheet.d.ts +9 -0
  11. package/dist/components/action-sheet/use-action-sheet.mjs +58 -0
  12. package/dist/components/button/styles.d.ts +6 -6
  13. package/dist/components/fab/fab.d.ts +1 -1
  14. package/dist/components/image/image.d.ts +1 -1
  15. package/dist/components/image/index.d.ts +1 -1
  16. package/dist/components/notification/holder.cjs +2 -3
  17. package/dist/components/notification/holder.mjs +4 -5
  18. package/dist/components/popper/dropdown.d.ts +1 -1
  19. package/dist/components/select/selector.d.ts +1 -1
  20. package/dist/components/theme/tokens.stylex.d.ts +2 -2
  21. package/dist/index.cjs +4 -0
  22. package/dist/index.d.ts +2 -0
  23. package/dist/index.mjs +2 -0
  24. package/dist/locale/locales/en_US.cjs +3 -0
  25. package/dist/locale/locales/en_US.mjs +3 -0
  26. package/dist/locale/locales/zh_CN.cjs +3 -0
  27. package/dist/locale/locales/zh_CN.mjs +3 -0
  28. package/dist/styles.css +16 -0
  29. package/dist/types/action-sheet.d.ts +85 -0
  30. package/dist/types/locale.d.ts +3 -0
  31. package/package.json +1 -1
@@ -0,0 +1 @@
1
+ import "@testing-library/jest-dom";
@@ -0,0 +1,168 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var _objectSpread = require('@babel/runtime/helpers/objectSpread2');
6
+ var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
7
+ var React = require('react');
8
+ var stylex = require('../../node_modules/.pnpm/@stylexjs_stylex@0.18.3/node_modules/@stylexjs/stylex/lib/es/stylex.cjs');
9
+ var className = require('@aiszlab/relax/class-name');
10
+ var relax = require('@aiszlab/relax');
11
+ var useClassNames = require('../../hooks/use-class-names.cjs');
12
+ var sheet = require('../sheet/sheet.cjs');
13
+ var useLocale = require('../../locale/use-locale.cjs');
14
+ var useThemeColorVars = require('../../hooks/use-theme-color-vars.cjs');
15
+ var theme = require('../theme/theme.cjs');
16
+ var context = require('./context.cjs');
17
+
18
+ /**
19
+ * @zh ActionSheet 专用样式:面板背景、拖拽手柄、操作项和取消按钮的样式。
20
+ * @en ActionSheet-specific styles: panel background, drag handle, action items and cancel button.
21
+ */
22
+ var styles = {
23
+ title: {
24
+ kg3NbH: "musaex-1v4gb6w",
25
+ kLKAdn: "musaex-3nylsr",
26
+ k9WMMc: "musaex-2b8uid",
27
+ $$css: true
28
+ },
29
+ description: {
30
+ kg3NbH: "musaex-1v4gb6w",
31
+ kLKAdn: "musaex-3nylsr",
32
+ k9WMMc: "musaex-2b8uid",
33
+ $$css: true
34
+ },
35
+ actionText: {
36
+ k9WMMc: "musaex-2b8uid",
37
+ $$css: true
38
+ },
39
+ actionDesc: {
40
+ k9WMMc: "musaex-2b8uid",
41
+ keoZOQ: "musaex-1khtc51",
42
+ $$css: true
43
+ },
44
+ cancel: {
45
+ k1xSpc: "musaex-78zum5",
46
+ kGNEyG: "musaex-6s0dn4",
47
+ kjj79g: "musaex-l56j7k",
48
+ k8WAf4: "musaex-1aur8i7",
49
+ kg3NbH: "musaex-1v4gb6w",
50
+ kkrTdU: "musaex-1ypdohk",
51
+ kAzted: "musaex-qi4gqz",
52
+ kEafiO: "musaex-2k45e9",
53
+ kPef9Z: "musaex-13fuv20",
54
+ kVAM5u: "musaex-axmpxa",
55
+ keoZOQ: "musaex-1eodh35",
56
+ kfSwDN: "musaex-87ps6o",
57
+ $$css: true
58
+ }
59
+ };
60
+ /**
61
+ * @zh ActionSheet 组件。基于 Sheet 的移动端底部操作面板,
62
+ * 支持操作列表和二次确认场景,同时提供声明式和指令式 API。
63
+ * @en ActionSheet component. A mobile bottom action panel built on Sheet,
64
+ * supporting action lists and confirmation scenarios, with both declarative and imperative APIs.
65
+ */
66
+ var ActionSheet = function ActionSheet(_ref) {
67
+ var open = _ref.open,
68
+ onClose = _ref.onClose,
69
+ actions = _ref.actions,
70
+ title = _ref.title,
71
+ description = _ref.description,
72
+ cancelText = _ref.cancelText,
73
+ height = _ref.height,
74
+ className$1 = _ref.className,
75
+ style = _ref.style;
76
+ var classNames = useClassNames.useClassNames(context.CLASS_NAMES);
77
+ var _useLocale = useLocale.useLocale("action-sheet"),
78
+ _useLocale2 = _slicedToArray(_useLocale, 1),
79
+ locale = _useLocale2[0];
80
+ var themeColorVars = useThemeColorVars.useThemeColorVars(["on-surface-variant", "surface-container", "outline-variant"]);
81
+ var styled = {
82
+ handle: {
83
+ className: "musaex-1po6ib musaex-rntz3j musaex-1xa9b2s musaex-9ip8r5 musaex-1eodh35 musaex-19i5tse musaex-vueqy4 musaex-2lah0s"
84
+ },
85
+ panel: {
86
+ className: "musaex-17o6occ musaex-zbxit7 musaex-1ei9pc5 musaex-15q9lfd"
87
+ },
88
+ header: {
89
+ className: "musaex-1b38e8b musaex-7gss4w"
90
+ },
91
+ title: stylex.props(styles.title, theme.$title.medium),
92
+ description: stylex.props(styles.description, theme.$body.medium),
93
+ actions: {
94
+ className: "musaex-ltmd5o"
95
+ },
96
+ action: {
97
+ className: "musaex-78zum5 musaex-dt5ytf musaex-6s0dn4 musaex-l56j7k musaex-1aur8i7 musaex-1v4gb6w musaex-1ypdohk musaex-qi4gqz musaex-uvson1 musaex-13fuv20 musaex-axmpxa musaex-87ps6o"
98
+ },
99
+ actionText: stylex.props(styles.actionText, theme.$body.large),
100
+ actionDesc: stylex.props(styles.actionDesc, theme.$body.small),
101
+ cancel: stylex.props(styles.cancel, theme.$label.large)
102
+ };
103
+ /**
104
+ * @zh 处理操作项点击:先执行回调,再关闭面板。
105
+ * @en Handle action click: execute callback first, then close the panel.
106
+ */
107
+ var handleAction = relax.useEvent(function (action) {
108
+ try {
109
+ var _action$onClick;
110
+ (_action$onClick = action.onClick) === null || _action$onClick === void 0 || _action$onClick.call(action);
111
+ } catch (_unused) {
112
+ // noop — close the panel regardless of onClick result
113
+ } finally {
114
+ onClose();
115
+ }
116
+ });
117
+ /**
118
+ * @zh 头部区域:拖拽手柄 + 标题 + 描述。
119
+ * @en Header area: drag handle + title + description.
120
+ */
121
+ var header = /*#__PURE__*/React.createElement("div", {
122
+ className: className.stringify(classNames.header, styled.header.className),
123
+ style: styled.header.style
124
+ }, /*#__PURE__*/React.createElement("div", {
125
+ className: className.stringify(styled.handle.className),
126
+ style: _objectSpread(_objectSpread({}, styled.handle.style), themeColorVars)
127
+ }), !!title && (/*#__PURE__*/React.createElement("div", {
128
+ className: className.stringify(classNames.title, styled.title.className),
129
+ style: styled.title.style
130
+ }, title)), !!description && (/*#__PURE__*/React.createElement("div", {
131
+ className: className.stringify(classNames.description, styled.description.className),
132
+ style: styled.description.style
133
+ }, description)));
134
+ return /*#__PURE__*/React.createElement(sheet.default, {
135
+ visible: open,
136
+ placement: "bottom",
137
+ size: height !== null && height !== void 0 ? height : "fit-content",
138
+ onClose: onClose,
139
+ header: header,
140
+ className: className.stringify(classNames.sheet, className$1),
141
+ panelClassName: styled.panel.className,
142
+ panelStyle: _objectSpread(_objectSpread(_objectSpread({}, styled.panel.style), themeColorVars), style)
143
+ }, actions.length > 0 && (/*#__PURE__*/React.createElement("div", {
144
+ className: className.stringify(classNames.actions, styled.actions.className),
145
+ style: styled.actions.style
146
+ }, actions.map(function (action) {
147
+ return /*#__PURE__*/React.createElement("div", {
148
+ key: action.key,
149
+ className: className.stringify(classNames.action, styled.action.className),
150
+ style: styled.action.style,
151
+ onClick: function onClick() {
152
+ return handleAction(action);
153
+ }
154
+ }, /*#__PURE__*/React.createElement("span", {
155
+ className: className.stringify(classNames.actionText, styled.actionText.className),
156
+ style: styled.actionText.style
157
+ }, action.text), !!action.description && (/*#__PURE__*/React.createElement("span", {
158
+ className: className.stringify(classNames.actionDesc, styled.actionDesc.className),
159
+ style: styled.actionDesc.style
160
+ }, action.description)));
161
+ }))), /*#__PURE__*/React.createElement("div", {
162
+ className: className.stringify(classNames.cancel, styled.cancel.className),
163
+ style: styled.cancel.style,
164
+ onClick: onClose
165
+ }, cancelText !== null && cancelText !== void 0 ? cancelText : locale.cancel));
166
+ };
167
+
168
+ exports.default = ActionSheet;
@@ -0,0 +1,10 @@
1
+ import React from "react";
2
+ import type { ActionSheetProps } from "../../types/action-sheet";
3
+ /**
4
+ * @zh ActionSheet 组件。基于 Sheet 的移动端底部操作面板,
5
+ * 支持操作列表和二次确认场景,同时提供声明式和指令式 API。
6
+ * @en ActionSheet component. A mobile bottom action panel built on Sheet,
7
+ * supporting action lists and confirmation scenarios, with both declarative and imperative APIs.
8
+ */
9
+ declare const ActionSheet: ({ open, onClose, actions, title, description, cancelText, height, className, style, }: ActionSheetProps) => React.JSX.Element;
10
+ export default ActionSheet;
@@ -0,0 +1,164 @@
1
+ import _objectSpread from '@babel/runtime/helpers/objectSpread2';
2
+ import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
3
+ import React from 'react';
4
+ import { props } from '../../node_modules/.pnpm/@stylexjs_stylex@0.18.3/node_modules/@stylexjs/stylex/lib/es/stylex.mjs';
5
+ import { stringify } from '@aiszlab/relax/class-name';
6
+ import { useEvent } from '@aiszlab/relax';
7
+ import { useClassNames } from '../../hooks/use-class-names.mjs';
8
+ import Sheet from '../sheet/sheet.mjs';
9
+ import { useLocale } from '../../locale/use-locale.mjs';
10
+ import { useThemeColorVars } from '../../hooks/use-theme-color-vars.mjs';
11
+ import { $label, $body, $title } from '../theme/theme.mjs';
12
+ import { CLASS_NAMES } from './context.mjs';
13
+
14
+ /**
15
+ * @zh ActionSheet 专用样式:面板背景、拖拽手柄、操作项和取消按钮的样式。
16
+ * @en ActionSheet-specific styles: panel background, drag handle, action items and cancel button.
17
+ */
18
+ var styles = {
19
+ title: {
20
+ kg3NbH: "musaex-1v4gb6w",
21
+ kLKAdn: "musaex-3nylsr",
22
+ k9WMMc: "musaex-2b8uid",
23
+ $$css: true
24
+ },
25
+ description: {
26
+ kg3NbH: "musaex-1v4gb6w",
27
+ kLKAdn: "musaex-3nylsr",
28
+ k9WMMc: "musaex-2b8uid",
29
+ $$css: true
30
+ },
31
+ actionText: {
32
+ k9WMMc: "musaex-2b8uid",
33
+ $$css: true
34
+ },
35
+ actionDesc: {
36
+ k9WMMc: "musaex-2b8uid",
37
+ keoZOQ: "musaex-1khtc51",
38
+ $$css: true
39
+ },
40
+ cancel: {
41
+ k1xSpc: "musaex-78zum5",
42
+ kGNEyG: "musaex-6s0dn4",
43
+ kjj79g: "musaex-l56j7k",
44
+ k8WAf4: "musaex-1aur8i7",
45
+ kg3NbH: "musaex-1v4gb6w",
46
+ kkrTdU: "musaex-1ypdohk",
47
+ kAzted: "musaex-qi4gqz",
48
+ kEafiO: "musaex-2k45e9",
49
+ kPef9Z: "musaex-13fuv20",
50
+ kVAM5u: "musaex-axmpxa",
51
+ keoZOQ: "musaex-1eodh35",
52
+ kfSwDN: "musaex-87ps6o",
53
+ $$css: true
54
+ }
55
+ };
56
+ /**
57
+ * @zh ActionSheet 组件。基于 Sheet 的移动端底部操作面板,
58
+ * 支持操作列表和二次确认场景,同时提供声明式和指令式 API。
59
+ * @en ActionSheet component. A mobile bottom action panel built on Sheet,
60
+ * supporting action lists and confirmation scenarios, with both declarative and imperative APIs.
61
+ */
62
+ var ActionSheet = function ActionSheet(_ref) {
63
+ var open = _ref.open,
64
+ onClose = _ref.onClose,
65
+ actions = _ref.actions,
66
+ title = _ref.title,
67
+ description = _ref.description,
68
+ cancelText = _ref.cancelText,
69
+ height = _ref.height,
70
+ className = _ref.className,
71
+ style = _ref.style;
72
+ var classNames = useClassNames(CLASS_NAMES);
73
+ var _useLocale = useLocale("action-sheet"),
74
+ _useLocale2 = _slicedToArray(_useLocale, 1),
75
+ locale = _useLocale2[0];
76
+ var themeColorVars = useThemeColorVars(["on-surface-variant", "surface-container", "outline-variant"]);
77
+ var styled = {
78
+ handle: {
79
+ className: "musaex-1po6ib musaex-rntz3j musaex-1xa9b2s musaex-9ip8r5 musaex-1eodh35 musaex-19i5tse musaex-vueqy4 musaex-2lah0s"
80
+ },
81
+ panel: {
82
+ className: "musaex-17o6occ musaex-zbxit7 musaex-1ei9pc5 musaex-15q9lfd"
83
+ },
84
+ header: {
85
+ className: "musaex-1b38e8b musaex-7gss4w"
86
+ },
87
+ title: props(styles.title, $title.medium),
88
+ description: props(styles.description, $body.medium),
89
+ actions: {
90
+ className: "musaex-ltmd5o"
91
+ },
92
+ action: {
93
+ className: "musaex-78zum5 musaex-dt5ytf musaex-6s0dn4 musaex-l56j7k musaex-1aur8i7 musaex-1v4gb6w musaex-1ypdohk musaex-qi4gqz musaex-uvson1 musaex-13fuv20 musaex-axmpxa musaex-87ps6o"
94
+ },
95
+ actionText: props(styles.actionText, $body.large),
96
+ actionDesc: props(styles.actionDesc, $body.small),
97
+ cancel: props(styles.cancel, $label.large)
98
+ };
99
+ /**
100
+ * @zh 处理操作项点击:先执行回调,再关闭面板。
101
+ * @en Handle action click: execute callback first, then close the panel.
102
+ */
103
+ var handleAction = useEvent(function (action) {
104
+ try {
105
+ var _action$onClick;
106
+ (_action$onClick = action.onClick) === null || _action$onClick === void 0 || _action$onClick.call(action);
107
+ } catch (_unused) {
108
+ // noop — close the panel regardless of onClick result
109
+ } finally {
110
+ onClose();
111
+ }
112
+ });
113
+ /**
114
+ * @zh 头部区域:拖拽手柄 + 标题 + 描述。
115
+ * @en Header area: drag handle + title + description.
116
+ */
117
+ var header = /*#__PURE__*/React.createElement("div", {
118
+ className: stringify(classNames.header, styled.header.className),
119
+ style: styled.header.style
120
+ }, /*#__PURE__*/React.createElement("div", {
121
+ className: stringify(styled.handle.className),
122
+ style: _objectSpread(_objectSpread({}, styled.handle.style), themeColorVars)
123
+ }), !!title && (/*#__PURE__*/React.createElement("div", {
124
+ className: stringify(classNames.title, styled.title.className),
125
+ style: styled.title.style
126
+ }, title)), !!description && (/*#__PURE__*/React.createElement("div", {
127
+ className: stringify(classNames.description, styled.description.className),
128
+ style: styled.description.style
129
+ }, description)));
130
+ return /*#__PURE__*/React.createElement(Sheet, {
131
+ visible: open,
132
+ placement: "bottom",
133
+ size: height !== null && height !== void 0 ? height : "fit-content",
134
+ onClose: onClose,
135
+ header: header,
136
+ className: stringify(classNames.sheet, className),
137
+ panelClassName: styled.panel.className,
138
+ panelStyle: _objectSpread(_objectSpread(_objectSpread({}, styled.panel.style), themeColorVars), style)
139
+ }, actions.length > 0 && (/*#__PURE__*/React.createElement("div", {
140
+ className: stringify(classNames.actions, styled.actions.className),
141
+ style: styled.actions.style
142
+ }, actions.map(function (action) {
143
+ return /*#__PURE__*/React.createElement("div", {
144
+ key: action.key,
145
+ className: stringify(classNames.action, styled.action.className),
146
+ style: styled.action.style,
147
+ onClick: function onClick() {
148
+ return handleAction(action);
149
+ }
150
+ }, /*#__PURE__*/React.createElement("span", {
151
+ className: stringify(classNames.actionText, styled.actionText.className),
152
+ style: styled.actionText.style
153
+ }, action.text), !!action.description && (/*#__PURE__*/React.createElement("span", {
154
+ className: stringify(classNames.actionDesc, styled.actionDesc.className),
155
+ style: styled.actionDesc.style
156
+ }, action.description)));
157
+ }))), /*#__PURE__*/React.createElement("div", {
158
+ className: stringify(classNames.cancel, styled.cancel.className),
159
+ style: styled.cancel.style,
160
+ onClick: onClose
161
+ }, cancelText !== null && cancelText !== void 0 ? cancelText : locale.cancel));
162
+ };
163
+
164
+ export { ActionSheet as default };
@@ -0,0 +1,19 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * @zh ActionSheet 的 BEM class 名称
5
+ * @en BEM class names for ActionSheet
6
+ */
7
+ var CLASS_NAMES = {
8
+ sheet: "action-sheet",
9
+ header: "action-sheet__header",
10
+ title: "action-sheet__title",
11
+ description: "action-sheet__description",
12
+ actions: "action-sheet__actions",
13
+ action: "action-sheet__action",
14
+ actionText: "action-sheet__action-text",
15
+ actionDesc: "action-sheet__action-desc",
16
+ cancel: "action-sheet__cancel"
17
+ };
18
+
19
+ exports.CLASS_NAMES = CLASS_NAMES;
@@ -0,0 +1,15 @@
1
+ /**
2
+ * @zh ActionSheet 的 BEM class 名称
3
+ * @en BEM class names for ActionSheet
4
+ */
5
+ export declare const CLASS_NAMES: {
6
+ readonly sheet: "action-sheet";
7
+ readonly header: "action-sheet__header";
8
+ readonly title: "action-sheet__title";
9
+ readonly description: "action-sheet__description";
10
+ readonly actions: "action-sheet__actions";
11
+ readonly action: "action-sheet__action";
12
+ readonly actionText: "action-sheet__action-text";
13
+ readonly actionDesc: "action-sheet__action-desc";
14
+ readonly cancel: "action-sheet__cancel";
15
+ };
@@ -0,0 +1,17 @@
1
+ /**
2
+ * @zh ActionSheet 的 BEM class 名称
3
+ * @en BEM class names for ActionSheet
4
+ */
5
+ var CLASS_NAMES = {
6
+ sheet: "action-sheet",
7
+ header: "action-sheet__header",
8
+ title: "action-sheet__title",
9
+ description: "action-sheet__description",
10
+ actions: "action-sheet__actions",
11
+ action: "action-sheet__action",
12
+ actionText: "action-sheet__action-text",
13
+ actionDesc: "action-sheet__action-desc",
14
+ cancel: "action-sheet__cancel"
15
+ };
16
+
17
+ export { CLASS_NAMES };
@@ -0,0 +1,3 @@
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 };
@@ -58,6 +58,9 @@ declare const styles: {
58
58
  }>;
59
59
  shape: {
60
60
  round: Readonly<{
61
+ xsmall?: Readonly<{
62
+ borderRadius: import("@stylexjs/stylex").StyleXClassNameFor<"borderRadius", string>;
63
+ } | undefined>;
61
64
  small?: Readonly<{
62
65
  borderRadius: import("@stylexjs/stylex").StyleXClassNameFor<"borderRadius", string>;
63
66
  } | undefined>;
@@ -67,14 +70,14 @@ declare const styles: {
67
70
  large?: Readonly<{
68
71
  borderRadius: import("@stylexjs/stylex").StyleXClassNameFor<"borderRadius", string>;
69
72
  } | undefined>;
70
- xsmall?: Readonly<{
71
- borderRadius: import("@stylexjs/stylex").StyleXClassNameFor<"borderRadius", string>;
72
- } | undefined>;
73
73
  xlarge?: Readonly<{
74
74
  borderRadius: import("@stylexjs/stylex").StyleXClassNameFor<"borderRadius", string>;
75
75
  } | undefined>;
76
76
  }>;
77
77
  square: Readonly<{
78
+ xsmall?: Readonly<{
79
+ borderRadius: import("@stylexjs/stylex").StyleXClassNameFor<"borderRadius", string>;
80
+ } | undefined>;
78
81
  small?: Readonly<{
79
82
  borderRadius: import("@stylexjs/stylex").StyleXClassNameFor<"borderRadius", string>;
80
83
  } | undefined>;
@@ -84,9 +87,6 @@ declare const styles: {
84
87
  large?: Readonly<{
85
88
  borderRadius: import("@stylexjs/stylex").StyleXClassNameFor<"borderRadius", string>;
86
89
  } | undefined>;
87
- xsmall?: Readonly<{
88
- borderRadius: import("@stylexjs/stylex").StyleXClassNameFor<"borderRadius", string>;
89
- } | undefined>;
90
90
  xlarge?: Readonly<{
91
91
  borderRadius: import("@stylexjs/stylex").StyleXClassNameFor<"borderRadius", string>;
92
92
  } | undefined>;
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
- declare const Fab: React.ForwardRefExoticComponent<Pick<React.ButtonHTMLAttributes<HTMLButtonElement>, "onMouseEnter" | "onMouseLeave" | "onPointerEnter" | "onPointerLeave"> & {
2
+ declare const Fab: React.ForwardRefExoticComponent<Pick<React.ButtonHTMLAttributes<HTMLButtonElement>, "onPointerEnter" | "onPointerLeave" | "onMouseEnter" | "onMouseLeave"> & {
3
3
  container?: import("../../types/portal").PortalProps["container"];
4
4
  children?: React.ReactNode;
5
5
  onClick?: import("../../types/button").ButtonProps["onClick"];
@@ -1,6 +1,6 @@
1
1
  import React from "react";
2
2
  import type { ImageRef } from "../../types/image";
3
- declare const Image: React.ForwardRefExoticComponent<import("../../types/element").ComponentProps & Pick<React.ImgHTMLAttributes<HTMLImageElement>, "alt" | "width" | "height" | "crossOrigin" | "referrerPolicy"> & {
3
+ declare const Image: React.ForwardRefExoticComponent<import("../../types/element").ComponentProps & Pick<React.ImgHTMLAttributes<HTMLImageElement>, "height" | "width" | "alt" | "crossOrigin" | "referrerPolicy"> & {
4
4
  src?: string;
5
5
  previewable?: boolean;
6
6
  fallback?: React.ReactNode;
@@ -1,4 +1,4 @@
1
- declare const Image: import("react").ForwardRefExoticComponent<import("../../types/element").ComponentProps & Pick<import("react").ImgHTMLAttributes<HTMLImageElement>, "alt" | "width" | "height" | "crossOrigin" | "referrerPolicy"> & {
1
+ declare const Image: import("react").ForwardRefExoticComponent<import("../../types/element").ComponentProps & Pick<import("react").ImgHTMLAttributes<HTMLImageElement>, "height" | "width" | "alt" | "crossOrigin" | "referrerPolicy"> & {
2
2
  src?: string;
3
3
  previewable?: boolean;
4
4
  fallback?: import("react").ReactNode;
@@ -102,12 +102,11 @@ var Holder = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
102
102
  return next;
103
103
  });
104
104
  });
105
- React.useEffect(function () {
105
+ relax.useMounted(function () {
106
106
  defaultNotifications === null || defaultNotifications === void 0 || defaultNotifications.forEach(function (notification) {
107
107
  add(notification);
108
108
  });
109
- // eslint-disable-next-line react-hooks/exhaustive-deps
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, useEffect, useImperativeHandle } from 'react';
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
- useEffect(function () {
101
+ useMounted(function () {
102
102
  defaultNotifications === null || defaultNotifications === void 0 || defaultNotifications.forEach(function (notification) {
103
103
  add(notification);
104
104
  });
105
- // eslint-disable-next-line react-hooks/exhaustive-deps
106
- }, []);
105
+ });
107
106
  useImperativeHandle(ref, function () {
108
107
  return {
109
108
  add: add
@@ -1,6 +1,6 @@
1
1
  import React from "react";
2
2
  import type { PopperRef } from "../../types/popper";
3
- declare const Dropdown: React.ForwardRefExoticComponent<Omit<import("../../types/popper").PopperProps, "container" | "placement" | "portal"> & {
3
+ declare const Dropdown: React.ForwardRefExoticComponent<Omit<import("../../types/popper").PopperProps, "placement" | "container" | "portal"> & {
4
4
  placement: import("@floating-ui/dom").Placement;
5
5
  } & React.RefAttributes<PopperRef>>;
6
6
  export default Dropdown;
@@ -1,6 +1,6 @@
1
1
  import React from "react";
2
2
  import type { SelectorRef } from "../../types/select";
3
- declare const Selector: React.ForwardRefExoticComponent<Pick<import("@aiszlab/relax/types").RequiredIn<import("../../types/select").SelectProps<import("../../types/select").ValueOrValues>, "searchable" | "onSearch">, "onBlur" | "mode" | "disabled" | "placeholder" | "searchable" | "onSearch"> & {
3
+ declare const Selector: React.ForwardRefExoticComponent<Pick<import("@aiszlab/relax/types").RequiredIn<import("../../types/select").SelectProps<import("../../types/select").ValueOrValues>, "searchable" | "onSearch">, "disabled" | "onBlur" | "mode" | "placeholder" | "searchable" | "onSearch"> & {
4
4
  value: Map<React.Key, React.ReactNode>;
5
5
  keyword: string;
6
6
  onChange: (key: React.Key) => void;
@@ -4,11 +4,11 @@ import { ValueOf } from "@aiszlab/relax/types";
4
4
  * elevations
5
5
  */
6
6
  export declare const elevations: import("@stylexjs/stylex").VarGroup<Readonly<{
7
+ none: string;
8
+ xsmall: string;
7
9
  small: string;
8
10
  medium: string;
9
11
  large: string;
10
- none: string;
11
- xsmall: string;
12
12
  xlarge: string;
13
13
  }>, symbol>;
14
14
  /**
package/dist/index.cjs CHANGED
@@ -9,6 +9,7 @@ var index$5 = require('./components/layout/index.cjs');
9
9
  var index$4 = require('./components/image/index.cjs');
10
10
  var index$8 = require('./components/rich-text-editor/index.cjs');
11
11
  var index$6 = require('./components/markdown/index.cjs');
12
+ var actionSheet = require('./components/action-sheet/action-sheet.cjs');
12
13
  var badge = require('./components/badge/badge.cjs');
13
14
  var bench = require('./components/bench/bench.cjs');
14
15
  var bottomSheet = require('./components/bottom-sheet/bottom-sheet.cjs');
@@ -71,6 +72,7 @@ var visuallyHidden = require('./components/visually-hidden/visually-hidden.cjs')
71
72
  var waterfall = require('./components/waterfall/waterfall.cjs');
72
73
  var watermark = require('./components/watermark/watermark.cjs');
73
74
  var highlight = require('./components/highlight/highlight.cjs');
75
+ var useActionSheet = require('./components/action-sheet/use-action-sheet.cjs');
74
76
  var hooks = require('./components/message/hooks.cjs');
75
77
  var hooks$1 = require('./components/notification/hooks.cjs');
76
78
  var hooks$2 = require('./components/theme/hooks.cjs');
@@ -86,6 +88,7 @@ exports.Layout = index$5.Layout;
86
88
  exports.Image = index$4.Image;
87
89
  exports.RichTextEditor = index$8.RichTextEditor;
88
90
  exports.Markdown = index$6.Markdown;
91
+ exports.ActionSheet = actionSheet.default;
89
92
  exports.Badge = badge.default;
90
93
  exports.Bench = bench.default;
91
94
  exports.BottomSheet = bottomSheet.default;
@@ -148,6 +151,7 @@ exports.VisuallyHidden = visuallyHidden.default;
148
151
  exports.Waterfall = waterfall.default;
149
152
  exports.Watermark = watermark.default;
150
153
  exports.Highlight = highlight.default;
154
+ exports.useActionSheet = useActionSheet.useActionSheet;
151
155
  exports.useMessage = hooks.useMessage;
152
156
  exports.useNotification = hooks$1.useNotification;
153
157
  exports.useTheme = hooks$2.useTheme;
package/dist/index.d.ts CHANGED
@@ -2,6 +2,7 @@
2
2
  * @description
3
3
  * components
4
4
  */
5
+ export { ActionSheet } from "./components/action-sheet";
5
6
  export { Avatar } from "./components/avatar";
6
7
  export { Menu } from "./components/menu";
7
8
  export { Loading } from "./components/loading";
@@ -76,4 +77,5 @@ export { Search } from "./components/search";
76
77
  */
77
78
  export { useMessage, Message } from "./components/message";
78
79
  export { useNotification, Notification } from "./components/notification";
80
+ export { useActionSheet } from "./components/action-sheet";
79
81
  export { useTheme } from "./components/theme";
package/dist/index.mjs CHANGED
@@ -7,6 +7,7 @@ export { Layout } from './components/layout/index.mjs';
7
7
  export { Image } from './components/image/index.mjs';
8
8
  export { RichTextEditor } from './components/rich-text-editor/index.mjs';
9
9
  export { Markdown } from './components/markdown/index.mjs';
10
+ export { default as ActionSheet } from './components/action-sheet/action-sheet.mjs';
10
11
  export { default as Badge } from './components/badge/badge.mjs';
11
12
  export { default as Bench } from './components/bench/bench.mjs';
12
13
  export { default as BottomSheet } from './components/bottom-sheet/bottom-sheet.mjs';
@@ -69,6 +70,7 @@ export { default as VisuallyHidden } from './components/visually-hidden/visually
69
70
  export { default as Waterfall } from './components/waterfall/waterfall.mjs';
70
71
  export { default as Watermark } from './components/watermark/watermark.mjs';
71
72
  export { default as Highlight } from './components/highlight/highlight.mjs';
73
+ export { useActionSheet } from './components/action-sheet/use-action-sheet.mjs';
72
74
  export { useMessage } from './components/message/hooks.mjs';
73
75
  export { useNotification } from './components/notification/hooks.mjs';
74
76
  export { useTheme } from './components/theme/hooks.mjs';
@@ -56,6 +56,9 @@ var en_US = {
56
56
  "rich-text-editor": {
57
57
  checkList: "Check List",
58
58
  codeBlock: "Code Block"
59
+ },
60
+ "action-sheet": {
61
+ cancel: "Cancel"
59
62
  }
60
63
  };
61
64
 
@@ -52,6 +52,9 @@ var en_US = {
52
52
  "rich-text-editor": {
53
53
  checkList: "Check List",
54
54
  codeBlock: "Code Block"
55
+ },
56
+ "action-sheet": {
57
+ cancel: "Cancel"
55
58
  }
56
59
  };
57
60
 
@@ -56,6 +56,9 @@ var zh_CN = {
56
56
  "rich-text-editor": {
57
57
  checkList: "任务列表",
58
58
  codeBlock: "代码块"
59
+ },
60
+ "action-sheet": {
61
+ cancel: "取消"
59
62
  }
60
63
  };
61
64
 
@@ -52,6 +52,9 @@ var zh_CN = {
52
52
  "rich-text-editor": {
53
53
  checkList: "任务列表",
54
54
  codeBlock: "代码块"
55
+ },
56
+ "action-sheet": {
57
+ cancel: "取消"
55
58
  }
56
59
  };
57
60
 
package/dist/styles.css CHANGED
@@ -1833,6 +1833,10 @@
1833
1833
  border-top-style: solid;
1834
1834
  }
1835
1835
 
1836
+ .musaex-2k45e9 {
1837
+ border-top-width: var(--musaex-1t2jekz);
1838
+ }
1839
+
1836
1840
  .musaex-uvson1 {
1837
1841
  border-top-width: var(--musaex-1xf102v);
1838
1842
  }
@@ -2101,6 +2105,10 @@
2101
2105
  min-height: var(--musaex-19fxx0u);
2102
2106
  }
2103
2107
 
2108
+ .musaex-qi4gqz {
2109
+ min-height: var(--musaex-1rxoe21);
2110
+ }
2111
+
2104
2112
  .musaex-5g0ifs {
2105
2113
  min-height: var(--musaex-1w5d7ii);
2106
2114
  }
@@ -2229,6 +2237,14 @@
2229
2237
  padding-top: var(--musaex-16suft8);
2230
2238
  }
2231
2239
 
2240
+ .musaex-1b38e8b {
2241
+ padding-top: var(--musaex-1fxazvh);
2242
+ }
2243
+
2244
+ .musaex-3nylsr {
2245
+ padding-top: var(--musaex-48i97p);
2246
+ }
2247
+
2232
2248
  .musaex-ltmd5o {
2233
2249
  padding-top: var(--musaex-jo49ah);
2234
2250
  }
@@ -0,0 +1,85 @@
1
+ import type { ReactNode } from "react";
2
+ import type { ComponentProps } from "./element";
3
+ /**
4
+ * @zh 操作项,用于 ActionSheet 的操作列表。
5
+ * @en An action item for the ActionSheet's action list.
6
+ */
7
+ export interface ActionItem {
8
+ /**
9
+ * @zh 操作项唯一标识
10
+ * @en Unique identifier for the action item
11
+ */
12
+ key: string;
13
+ /**
14
+ * @zh 操作项显示文本
15
+ * @en Display text for the action item
16
+ */
17
+ text: ReactNode;
18
+ /**
19
+ * @zh 操作项描述文本(可选副标题),显示在 text 下方
20
+ * @en Optional description text displayed below the main text
21
+ */
22
+ description?: ReactNode;
23
+ /**
24
+ * @zh 点击操作项时的回调
25
+ * @en Callback when the action item is clicked
26
+ */
27
+ onClick?: () => void;
28
+ }
29
+ /**
30
+ * @zh ActionSheet 组件的属性。
31
+ * @en Props for the ActionSheet component.
32
+ */
33
+ export interface ActionSheetProps extends ComponentProps {
34
+ /**
35
+ * @zh 控制 ActionSheet 的可见状态
36
+ * @en Controls the visibility state of the ActionSheet
37
+ */
38
+ open: boolean;
39
+ /**
40
+ * @zh 当 ActionSheet 请求关闭时的回调
41
+ * @en Called when the ActionSheet requests to close
42
+ */
43
+ onClose: VoidFunction;
44
+ /**
45
+ * @zh 操作项列表
46
+ * @en List of action items
47
+ */
48
+ actions: ActionItem[];
49
+ /**
50
+ * @zh 顶部标题(可选)
51
+ * @en Optional title displayed at the top
52
+ */
53
+ title?: ReactNode;
54
+ /**
55
+ * @zh 标题下方的描述文本(可选)
56
+ * @en Optional description text displayed below the title
57
+ */
58
+ description?: ReactNode;
59
+ /**
60
+ * @zh 取消按钮文本。默认使用 locale 中的 cancel 文案
61
+ * @en Cancel button text. Uses locale cancel text by default
62
+ */
63
+ cancelText?: ReactNode;
64
+ /**
65
+ * @zh 面板高度。接受数字(px)或任意 CSS 高度值
66
+ * @en Height of the panel. Accepts number (px) or any CSS height value
67
+ */
68
+ height?: number | string;
69
+ }
70
+ /**
71
+ * @zh 指令式 API `ActionSheet.show()` 的配置参数。
72
+ * @en Configuration for the imperative API `ActionSheet.show()`.
73
+ */
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
+ };
@@ -47,4 +47,7 @@ export interface Locale {
47
47
  checkList: string;
48
48
  codeBlock: string;
49
49
  };
50
+ "action-sheet": {
51
+ cancel: string;
52
+ };
50
53
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "musae",
3
- "version": "1.0.27-beta.40",
3
+ "version": "1.0.27-beta.42",
4
4
  "description": "musae-ui",
5
5
  "author": "tutu@fantufantu.com",
6
6
  "license": "MIT",