mp-taro-kit 0.0.1 → 0.0.4
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/README.md +3 -3
- package/dist/core/configure.cjs +75 -0
- package/dist/core/configure.d.ts +18 -0
- package/dist/core/configure.js +69 -0
- package/dist/core/faces.cjs +2 -0
- package/dist/core/faces.d.ts +42 -0
- package/dist/core/faces.js +1 -0
- package/dist/core/index.cjs +32 -0
- package/dist/core/index.d.ts +6 -0
- package/dist/core/index.js +5 -0
- package/dist/core/request.cjs +60 -0
- package/dist/core/request.d.ts +27 -0
- package/dist/core/request.js +51 -0
- package/dist/core/router.cjs +71 -0
- package/dist/core/router.d.ts +11 -0
- package/dist/core/router.js +63 -0
- package/dist/core/storage.cjs +63 -0
- package/dist/core/storage.d.ts +6 -0
- package/dist/core/storage.js +57 -0
- package/dist/core/weapp.cjs +37 -0
- package/dist/core/weapp.d.ts +7 -0
- package/dist/core/weapp.js +32 -0
- package/dist/design/index.cjs +2 -0
- package/dist/design/index.d.ts +1 -0
- package/dist/design/index.js +1 -0
- package/dist/design/tokens.css +60 -0
- package/dist/index.cjs +21 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +5 -0
- package/dist/runtime/index.cjs +15 -0
- package/dist/runtime/index.d.ts +5 -0
- package/dist/runtime/index.js +6 -0
- package/dist/runtime/loading-slot.cjs +44 -0
- package/dist/runtime/loading-slot.d.ts +15 -0
- package/dist/runtime/loading-slot.js +41 -0
- package/dist/runtime/notify.cjs +52 -0
- package/dist/runtime/notify.d.ts +19 -0
- package/dist/runtime/notify.js +49 -0
- package/dist/runtime/overlay-stack.cjs +49 -0
- package/dist/runtime/overlay-stack.d.ts +17 -0
- package/dist/runtime/overlay-stack.js +46 -0
- package/dist/runtime/singleton.cjs +17 -0
- package/dist/runtime/singleton.d.ts +6 -0
- package/dist/runtime/singleton.js +14 -0
- package/dist/runtime/thenable.cjs +17 -0
- package/dist/runtime/thenable.d.ts +7 -0
- package/dist/runtime/thenable.js +13 -0
- package/dist/styles/tokens.css +60 -0
- package/dist/ui/actions/Button.cjs +32 -0
- package/dist/ui/actions/Button.d.ts +13 -0
- package/dist/ui/actions/Button.js +29 -0
- package/dist/ui/actions/index.cjs +5 -0
- package/dist/ui/actions/index.d.ts +1 -0
- package/dist/ui/actions/index.js +1 -0
- package/dist/ui/actions/style/index.css +22 -0
- package/dist/ui/commands.cjs +86 -0
- package/dist/ui/commands.d.ts +21 -0
- package/dist/ui/commands.js +73 -0
- package/dist/ui/display/Badge.cjs +10 -0
- package/dist/ui/display/Badge.d.ts +9 -0
- package/dist/ui/display/Badge.js +7 -0
- package/dist/ui/display/Divider.cjs +9 -0
- package/dist/ui/display/Divider.d.ts +5 -0
- package/dist/ui/display/Divider.js +6 -0
- package/dist/ui/display/index.cjs +7 -0
- package/dist/ui/display/index.d.ts +2 -0
- package/dist/ui/display/index.js +2 -0
- package/dist/ui/display/style/index.css +30 -0
- package/dist/ui/feedback/Dialog.cjs +12 -0
- package/dist/ui/feedback/Dialog.d.ts +15 -0
- package/dist/ui/feedback/Dialog.js +9 -0
- package/dist/ui/feedback/Loading.cjs +12 -0
- package/dist/ui/feedback/Loading.d.ts +7 -0
- package/dist/ui/feedback/Loading.js +9 -0
- package/dist/ui/feedback/Toast.cjs +12 -0
- package/dist/ui/feedback/Toast.d.ts +9 -0
- package/dist/ui/feedback/Toast.js +9 -0
- package/dist/ui/feedback/index.cjs +9 -0
- package/dist/ui/feedback/index.d.ts +3 -0
- package/dist/ui/feedback/index.js +3 -0
- package/dist/ui/feedback/style/index.css +67 -0
- package/dist/ui/index.cjs +17 -0
- package/dist/ui/index.d.ts +4 -0
- package/dist/ui/index.js +2 -0
- package/dist/ui/infra/OverlayHost.cjs +33 -0
- package/dist/ui/infra/OverlayHost.d.ts +8 -0
- package/dist/ui/infra/OverlayHost.js +30 -0
- package/dist/ui/infra/SafeArea.cjs +10 -0
- package/dist/ui/infra/SafeArea.d.ts +8 -0
- package/dist/ui/infra/SafeArea.js +7 -0
- package/dist/ui/infra/index.cjs +11 -0
- package/dist/ui/infra/index.d.ts +3 -0
- package/dist/ui/infra/index.js +3 -0
- package/dist/ui/infra/style/index.css +83 -0
- package/dist/ui/infra/use-store.cjs +17 -0
- package/dist/ui/infra/use-store.d.ts +8 -0
- package/dist/ui/infra/use-store.js +12 -0
- package/dist/ui/layout/Mask.cjs +12 -0
- package/dist/ui/layout/Mask.d.ts +7 -0
- package/dist/ui/layout/Mask.js +9 -0
- package/dist/ui/layout/Overlay.cjs +11 -0
- package/dist/ui/layout/Overlay.d.ts +8 -0
- package/dist/ui/layout/Overlay.js +8 -0
- package/dist/ui/layout/Popup.cjs +13 -0
- package/dist/ui/layout/Popup.d.ts +11 -0
- package/dist/ui/layout/Popup.js +10 -0
- package/dist/ui/layout/index.cjs +9 -0
- package/dist/ui/layout/index.d.ts +3 -0
- package/dist/ui/layout/index.js +3 -0
- package/dist/ui/layout/style/index.css +51 -0
- package/dist/ui/navigation/Drawer.cjs +12 -0
- package/dist/ui/navigation/Drawer.d.ts +11 -0
- package/dist/ui/navigation/Drawer.js +9 -0
- package/dist/ui/navigation/Dropdown.cjs +12 -0
- package/dist/ui/navigation/Dropdown.d.ts +9 -0
- package/dist/ui/navigation/Dropdown.js +9 -0
- package/dist/ui/navigation/index.cjs +7 -0
- package/dist/ui/navigation/index.d.ts +2 -0
- package/dist/ui/navigation/index.js +2 -0
- package/dist/ui/navigation/style/index.css +42 -0
- package/dist/ui/state.cjs +20 -0
- package/dist/ui/state.d.ts +25 -0
- package/dist/ui/state.js +17 -0
- package/dist/utils/date.cjs +98 -0
- package/dist/utils/date.d.ts +18 -0
- package/dist/utils/date.js +89 -0
- package/dist/utils/i18n.cjs +31 -0
- package/dist/utils/i18n.d.ts +11 -0
- package/dist/utils/i18n.js +25 -0
- package/dist/utils/index.cjs +30 -0
- package/dist/utils/index.d.ts +5 -0
- package/dist/utils/index.js +6 -0
- package/dist/utils/messages.zh.cjs +13 -0
- package/dist/utils/messages.zh.d.ts +1 -0
- package/dist/utils/messages.zh.js +10 -0
- package/dist/utils/number.cjs +38 -0
- package/dist/utils/number.d.ts +6 -0
- package/dist/utils/number.js +33 -0
- package/dist/utils/path.cjs +33 -0
- package/dist/utils/path.d.ts +8 -0
- package/dist/utils/path.js +27 -0
- package/dist/utils/string.cjs +55 -0
- package/dist/utils/string.d.ts +8 -0
- package/dist/utils/string.js +50 -0
- package/package.json +68 -4
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
.mptk-fb-toast {
|
|
2
|
+
background-color: var(--mptk-surface-2);
|
|
3
|
+
border-radius: var(--mptk-radius-md);
|
|
4
|
+
padding-top: var(--mptk-space-2);
|
|
5
|
+
padding-right: var(--mptk-space-4);
|
|
6
|
+
padding-bottom: var(--mptk-space-2);
|
|
7
|
+
padding-left: var(--mptk-space-4);
|
|
8
|
+
color: var(--mptk-fg);
|
|
9
|
+
font-size: var(--mptk-font-md);
|
|
10
|
+
line-height: var(--mptk-line-md);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.mptk-fb-loading {
|
|
14
|
+
display: flex;
|
|
15
|
+
align-items: center;
|
|
16
|
+
justify-content: center;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.mptk-fb-loading__text {
|
|
20
|
+
color: var(--mptk-fg-2);
|
|
21
|
+
font-size: var(--mptk-font-md);
|
|
22
|
+
line-height: var(--mptk-line-md);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.mptk-fb-dialog {
|
|
26
|
+
display: flex;
|
|
27
|
+
align-items: center;
|
|
28
|
+
justify-content: center;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.mptk-fb-dialog__panel {
|
|
32
|
+
background-color: var(--mptk-surface-1);
|
|
33
|
+
border-radius: var(--mptk-radius-lg);
|
|
34
|
+
padding-top: var(--mptk-space-4);
|
|
35
|
+
padding-right: var(--mptk-space-4);
|
|
36
|
+
padding-bottom: var(--mptk-space-3);
|
|
37
|
+
padding-left: var(--mptk-space-4);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.mptk-fb-dialog__title {
|
|
41
|
+
color: var(--mptk-fg);
|
|
42
|
+
font-size: var(--mptk-font-xl);
|
|
43
|
+
line-height: var(--mptk-line-xl);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.mptk-fb-dialog__body {
|
|
47
|
+
color: var(--mptk-fg-2);
|
|
48
|
+
font-size: var(--mptk-font-md);
|
|
49
|
+
line-height: var(--mptk-line-md);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.mptk-fb-dialog__actions {
|
|
53
|
+
display: flex;
|
|
54
|
+
justify-content: flex-end;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.mptk-fb-dialog__action--confirm {
|
|
58
|
+
color: var(--mptk-business);
|
|
59
|
+
font-size: var(--mptk-font-lg);
|
|
60
|
+
line-height: var(--mptk-line-lg);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.mptk-fb-dialog__action--cancel {
|
|
64
|
+
color: var(--mptk-fg-3);
|
|
65
|
+
font-size: var(--mptk-font-lg);
|
|
66
|
+
line-height: var(--mptk-line-lg);
|
|
67
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resetUIForTests = exports.hideLoading = exports.showLoading = exports.clearToasts = exports.hideToast = exports.showToast = exports.isOverlayHostMounted = exports.markOverlayHostUnmounted = exports.markOverlayHostMounted = exports.uiState = void 0;
|
|
4
|
+
var state_js_1 = require("./state.cjs");
|
|
5
|
+
Object.defineProperty(exports, "uiState", { enumerable: true, get: function () { return state_js_1.uiState; } });
|
|
6
|
+
var commands_js_1 = require("./commands.cjs");
|
|
7
|
+
Object.defineProperty(exports, "markOverlayHostMounted", { enumerable: true, get: function () { return commands_js_1.markOverlayHostMounted; } });
|
|
8
|
+
Object.defineProperty(exports, "markOverlayHostUnmounted", { enumerable: true, get: function () { return commands_js_1.markOverlayHostUnmounted; } });
|
|
9
|
+
Object.defineProperty(exports, "isOverlayHostMounted", { enumerable: true, get: function () { return commands_js_1.isOverlayHostMounted; } });
|
|
10
|
+
Object.defineProperty(exports, "showToast", { enumerable: true, get: function () { return commands_js_1.showToast; } });
|
|
11
|
+
Object.defineProperty(exports, "hideToast", { enumerable: true, get: function () { return commands_js_1.hideToast; } });
|
|
12
|
+
Object.defineProperty(exports, "clearToasts", { enumerable: true, get: function () { return commands_js_1.clearToasts; } });
|
|
13
|
+
Object.defineProperty(exports, "showLoading", { enumerable: true, get: function () { return commands_js_1.showLoading; } });
|
|
14
|
+
Object.defineProperty(exports, "hideLoading", { enumerable: true, get: function () { return commands_js_1.hideLoading; } });
|
|
15
|
+
Object.defineProperty(exports, "alert", { enumerable: true, get: function () { return commands_js_1.alert; } });
|
|
16
|
+
Object.defineProperty(exports, "confirm", { enumerable: true, get: function () { return commands_js_1.confirm; } });
|
|
17
|
+
Object.defineProperty(exports, "resetUIForTests", { enumerable: true, get: function () { return commands_js_1.resetUIForTests; } });
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export type { DialogPayload, UIState } from './state.js';
|
|
2
|
+
export { uiState } from './state.js';
|
|
3
|
+
export { markOverlayHostMounted, markOverlayHostUnmounted, isOverlayHostMounted, showToast, hideToast, clearToasts, showLoading, hideLoading, alert, confirm, resetUIForTests, type DialogOptions, } from './commands.js';
|
|
4
|
+
export type { Notice, NoticeTone } from '../runtime/notify.js';
|
package/dist/ui/index.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OverlayHost = OverlayHost;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const components_1 = require("@tarojs/components");
|
|
7
|
+
const state_js_1 = require("../state.cjs");
|
|
8
|
+
const commands_js_1 = require("../commands.cjs");
|
|
9
|
+
const use_store_js_1 = require("./use-store.cjs");
|
|
10
|
+
/**
|
|
11
|
+
* 命令式 API 的渲染位置。宿主在页面基座挂一次即可;
|
|
12
|
+
* 弹窗 / toast / loading 的具体内容由库渲染,业务内容仍从 children 或 options 传入。
|
|
13
|
+
*/
|
|
14
|
+
function OverlayHost({ className }) {
|
|
15
|
+
const overlays = (0, use_store_js_1.useOverlayEntries)();
|
|
16
|
+
const notices = (0, use_store_js_1.useNotices)();
|
|
17
|
+
const loading = (0, use_store_js_1.useLoadingState)();
|
|
18
|
+
// 渲染期就置位:宿主的页面生命周期(如 onLoad)可能早于 useEffect,
|
|
19
|
+
// 那时组件其实已挂载,只是 effect 未跑,不该被判成「未挂载」而抛错。
|
|
20
|
+
(0, commands_js_1.markOverlayHostMounted)();
|
|
21
|
+
(0, react_1.useEffect)(() => {
|
|
22
|
+
// 幂等重置,兼容 StrictMode 的 mount → unmount → mount。
|
|
23
|
+
(0, commands_js_1.markOverlayHostMounted)();
|
|
24
|
+
return () => (0, commands_js_1.markOverlayHostUnmounted)();
|
|
25
|
+
}, []);
|
|
26
|
+
const close = (id, confirmed) => {
|
|
27
|
+
const entry = (0, state_js_1.uiState)().overlays.dismiss(id);
|
|
28
|
+
if (entry === undefined)
|
|
29
|
+
return;
|
|
30
|
+
entry.resolve(confirmed);
|
|
31
|
+
};
|
|
32
|
+
return ((0, jsx_runtime_1.jsxs)(components_1.View, { className: ['mptk-overlay-host', className].filter(Boolean).join(' '), children: [loading.active ? ((0, jsx_runtime_1.jsx)(components_1.View, { className: "mptk-loading", children: (0, jsx_runtime_1.jsx)(components_1.Text, { className: "mptk-loading__text", children: "\u52A0\u8F7D\u4E2D" }) })) : null, notices.map((notice) => ((0, jsx_runtime_1.jsx)(components_1.View, { className: `mptk-toast mptk-toast--${notice.tone}`, children: (0, jsx_runtime_1.jsx)(components_1.Text, { children: notice.text }) }, notice.id))), overlays.map((entry) => ((0, jsx_runtime_1.jsx)(components_1.View, { className: "mptk-dialog", children: (0, jsx_runtime_1.jsxs)(components_1.View, { className: "mptk-dialog__panel", children: [entry.payload.title === undefined ? null : ((0, jsx_runtime_1.jsx)(components_1.View, { className: "mptk-dialog__title", children: (0, jsx_runtime_1.jsx)(components_1.Text, { children: entry.payload.title }) })), (0, jsx_runtime_1.jsx)(components_1.View, { className: "mptk-dialog__body", children: (0, jsx_runtime_1.jsx)(components_1.Text, { children: entry.payload.message }) }), (0, jsx_runtime_1.jsxs)(components_1.View, { className: "mptk-dialog__actions", children: [entry.payload.kind === 'confirm' ? ((0, jsx_runtime_1.jsx)(components_1.View, { className: "mptk-dialog__action mptk-dialog__action--cancel", onClick: () => close(entry.id, false), children: (0, jsx_runtime_1.jsx)(components_1.Text, { children: entry.payload.cancelText }) })) : null, (0, jsx_runtime_1.jsx)(components_1.View, { className: "mptk-dialog__action mptk-dialog__action--confirm", onClick: () => close(entry.id, true), children: (0, jsx_runtime_1.jsx)(components_1.Text, { children: entry.payload.confirmText }) })] })] }) }, entry.id)))] }));
|
|
33
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export interface OverlayHostProps {
|
|
2
|
+
className?: string;
|
|
3
|
+
}
|
|
4
|
+
/**
|
|
5
|
+
* 命令式 API 的渲染位置。宿主在页面基座挂一次即可;
|
|
6
|
+
* 弹窗 / toast / loading 的具体内容由库渲染,业务内容仍从 children 或 options 传入。
|
|
7
|
+
*/
|
|
8
|
+
export declare function OverlayHost({ className }: OverlayHostProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect } from 'react';
|
|
3
|
+
import { View, Text } from '@tarojs/components';
|
|
4
|
+
import { uiState } from '../state.js';
|
|
5
|
+
import { markOverlayHostMounted, markOverlayHostUnmounted } from '../commands.js';
|
|
6
|
+
import { useLoadingState, useNotices, useOverlayEntries } from './use-store.js';
|
|
7
|
+
/**
|
|
8
|
+
* 命令式 API 的渲染位置。宿主在页面基座挂一次即可;
|
|
9
|
+
* 弹窗 / toast / loading 的具体内容由库渲染,业务内容仍从 children 或 options 传入。
|
|
10
|
+
*/
|
|
11
|
+
export function OverlayHost({ className }) {
|
|
12
|
+
const overlays = useOverlayEntries();
|
|
13
|
+
const notices = useNotices();
|
|
14
|
+
const loading = useLoadingState();
|
|
15
|
+
// 渲染期就置位:宿主的页面生命周期(如 onLoad)可能早于 useEffect,
|
|
16
|
+
// 那时组件其实已挂载,只是 effect 未跑,不该被判成「未挂载」而抛错。
|
|
17
|
+
markOverlayHostMounted();
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
// 幂等重置,兼容 StrictMode 的 mount → unmount → mount。
|
|
20
|
+
markOverlayHostMounted();
|
|
21
|
+
return () => markOverlayHostUnmounted();
|
|
22
|
+
}, []);
|
|
23
|
+
const close = (id, confirmed) => {
|
|
24
|
+
const entry = uiState().overlays.dismiss(id);
|
|
25
|
+
if (entry === undefined)
|
|
26
|
+
return;
|
|
27
|
+
entry.resolve(confirmed);
|
|
28
|
+
};
|
|
29
|
+
return (_jsxs(View, { className: ['mptk-overlay-host', className].filter(Boolean).join(' '), children: [loading.active ? (_jsx(View, { className: "mptk-loading", children: _jsx(Text, { className: "mptk-loading__text", children: "\u52A0\u8F7D\u4E2D" }) })) : null, notices.map((notice) => (_jsx(View, { className: `mptk-toast mptk-toast--${notice.tone}`, children: _jsx(Text, { children: notice.text }) }, notice.id))), overlays.map((entry) => (_jsx(View, { className: "mptk-dialog", children: _jsxs(View, { className: "mptk-dialog__panel", children: [entry.payload.title === undefined ? null : (_jsx(View, { className: "mptk-dialog__title", children: _jsx(Text, { children: entry.payload.title }) })), _jsx(View, { className: "mptk-dialog__body", children: _jsx(Text, { children: entry.payload.message }) }), _jsxs(View, { className: "mptk-dialog__actions", children: [entry.payload.kind === 'confirm' ? (_jsx(View, { className: "mptk-dialog__action mptk-dialog__action--cancel", onClick: () => close(entry.id, false), children: _jsx(Text, { children: entry.payload.cancelText }) })) : null, _jsx(View, { className: "mptk-dialog__action mptk-dialog__action--confirm", onClick: () => close(entry.id, true), children: _jsx(Text, { children: entry.payload.confirmText }) })] })] }) }, entry.id)))] }));
|
|
30
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SafeArea = SafeArea;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const components_1 = require("@tarojs/components");
|
|
6
|
+
/** 安全区容器:只提供留白,内容由 children 注入。 */
|
|
7
|
+
function SafeArea({ children, position = 'bottom', className }) {
|
|
8
|
+
const names = ['mptk-safe-area', `mptk-safe-area--${position}`, className].filter(Boolean);
|
|
9
|
+
return (0, jsx_runtime_1.jsx)(components_1.View, { className: names.join(' '), children: children });
|
|
10
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
export interface SafeAreaProps {
|
|
3
|
+
children?: ReactNode;
|
|
4
|
+
position?: 'top' | 'bottom';
|
|
5
|
+
className?: string;
|
|
6
|
+
}
|
|
7
|
+
/** 安全区容器:只提供留白,内容由 children 注入。 */
|
|
8
|
+
export declare function SafeArea({ children, position, className }: SafeAreaProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { View } from '@tarojs/components';
|
|
3
|
+
/** 安全区容器:只提供留白,内容由 children 注入。 */
|
|
4
|
+
export function SafeArea({ children, position = 'bottom', className }) {
|
|
5
|
+
const names = ['mptk-safe-area', `mptk-safe-area--${position}`, className].filter(Boolean);
|
|
6
|
+
return _jsx(View, { className: names.join(' '), children: children });
|
|
7
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useLoadingState = exports.useNotices = exports.useOverlayEntries = exports.SafeArea = exports.OverlayHost = void 0;
|
|
4
|
+
var OverlayHost_js_1 = require("./OverlayHost.cjs");
|
|
5
|
+
Object.defineProperty(exports, "OverlayHost", { enumerable: true, get: function () { return OverlayHost_js_1.OverlayHost; } });
|
|
6
|
+
var SafeArea_js_1 = require("./SafeArea.cjs");
|
|
7
|
+
Object.defineProperty(exports, "SafeArea", { enumerable: true, get: function () { return SafeArea_js_1.SafeArea; } });
|
|
8
|
+
var use_store_js_1 = require("./use-store.cjs");
|
|
9
|
+
Object.defineProperty(exports, "useOverlayEntries", { enumerable: true, get: function () { return use_store_js_1.useOverlayEntries; } });
|
|
10
|
+
Object.defineProperty(exports, "useNotices", { enumerable: true, get: function () { return use_store_js_1.useNotices; } });
|
|
11
|
+
Object.defineProperty(exports, "useLoadingState", { enumerable: true, get: function () { return use_store_js_1.useLoadingState; } });
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
.mptk-overlay-host {
|
|
2
|
+
position: fixed;
|
|
3
|
+
top: 0;
|
|
4
|
+
right: 0;
|
|
5
|
+
bottom: 0;
|
|
6
|
+
left: 0;
|
|
7
|
+
z-index: 1000;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.mptk-loading {
|
|
11
|
+
display: flex;
|
|
12
|
+
align-items: center;
|
|
13
|
+
justify-content: center;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.mptk-loading__text {
|
|
17
|
+
color: var(--mptk-fg-2);
|
|
18
|
+
font-size: var(--mptk-font-md);
|
|
19
|
+
line-height: var(--mptk-line-md);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.mptk-toast {
|
|
23
|
+
background-color: var(--mptk-surface-2);
|
|
24
|
+
border-radius: var(--mptk-radius-md);
|
|
25
|
+
padding-top: var(--mptk-space-2);
|
|
26
|
+
padding-right: var(--mptk-space-4);
|
|
27
|
+
padding-bottom: var(--mptk-space-2);
|
|
28
|
+
padding-left: var(--mptk-space-4);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.mptk-dialog {
|
|
32
|
+
display: flex;
|
|
33
|
+
align-items: center;
|
|
34
|
+
justify-content: center;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.mptk-dialog__panel {
|
|
38
|
+
background-color: var(--mptk-surface-1);
|
|
39
|
+
border-radius: var(--mptk-radius-lg);
|
|
40
|
+
padding-top: var(--mptk-space-4);
|
|
41
|
+
padding-right: var(--mptk-space-4);
|
|
42
|
+
padding-bottom: var(--mptk-space-3);
|
|
43
|
+
padding-left: var(--mptk-space-4);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.mptk-dialog__title {
|
|
47
|
+
color: var(--mptk-fg);
|
|
48
|
+
font-size: var(--mptk-font-xl);
|
|
49
|
+
line-height: var(--mptk-line-xl);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.mptk-dialog__body {
|
|
53
|
+
color: var(--mptk-fg-2);
|
|
54
|
+
font-size: var(--mptk-font-md);
|
|
55
|
+
line-height: var(--mptk-line-md);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.mptk-dialog__actions {
|
|
59
|
+
display: flex;
|
|
60
|
+
justify-content: flex-end;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.mptk-dialog__action {
|
|
64
|
+
color: var(--mptk-business);
|
|
65
|
+
font-size: var(--mptk-font-lg);
|
|
66
|
+
line-height: var(--mptk-line-lg);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.mptk-dialog__action--cancel {
|
|
70
|
+
color: var(--mptk-fg-3);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.mptk-safe-area {
|
|
74
|
+
width: 100%;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.mptk-safe-area--top {
|
|
78
|
+
padding-top: env(safe-area-inset-top);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.mptk-safe-area--bottom {
|
|
82
|
+
padding-bottom: env(safe-area-inset-bottom);
|
|
83
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useOverlayEntries = useOverlayEntries;
|
|
4
|
+
exports.useNotices = useNotices;
|
|
5
|
+
exports.useLoadingState = useLoadingState;
|
|
6
|
+
const react_1 = require("react");
|
|
7
|
+
const state_js_1 = require("../state.cjs");
|
|
8
|
+
/** runtime 的 observable 直接喂给 useSyncExternalStore;订阅桥只做转发,不复制状态。 */
|
|
9
|
+
function useOverlayEntries() {
|
|
10
|
+
return (0, react_1.useSyncExternalStore)((listener) => (0, state_js_1.uiState)().overlays.subscribe(listener), () => (0, state_js_1.uiState)().overlays.getSnapshot());
|
|
11
|
+
}
|
|
12
|
+
function useNotices() {
|
|
13
|
+
return (0, react_1.useSyncExternalStore)((listener) => (0, state_js_1.uiState)().notices.subscribe(listener), () => (0, state_js_1.uiState)().notices.getSnapshot());
|
|
14
|
+
}
|
|
15
|
+
function useLoadingState() {
|
|
16
|
+
return (0, react_1.useSyncExternalStore)((listener) => (0, state_js_1.uiState)().loading.subscribe(listener), () => (0, state_js_1.uiState)().loading.getSnapshot());
|
|
17
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { DialogPayload } from '../state.js';
|
|
2
|
+
import type { OverlayEntry } from '../../runtime/overlay-stack.js';
|
|
3
|
+
import type { Notice } from '../../runtime/notify.js';
|
|
4
|
+
import type { LoadingState } from '../../runtime/loading-slot.js';
|
|
5
|
+
/** runtime 的 observable 直接喂给 useSyncExternalStore;订阅桥只做转发,不复制状态。 */
|
|
6
|
+
export declare function useOverlayEntries(): readonly OverlayEntry<DialogPayload>[];
|
|
7
|
+
export declare function useNotices(): readonly Notice[];
|
|
8
|
+
export declare function useLoadingState(): LoadingState;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { useSyncExternalStore } from 'react';
|
|
2
|
+
import { uiState } from '../state.js';
|
|
3
|
+
/** runtime 的 observable 直接喂给 useSyncExternalStore;订阅桥只做转发,不复制状态。 */
|
|
4
|
+
export function useOverlayEntries() {
|
|
5
|
+
return useSyncExternalStore((listener) => uiState().overlays.subscribe(listener), () => uiState().overlays.getSnapshot());
|
|
6
|
+
}
|
|
7
|
+
export function useNotices() {
|
|
8
|
+
return useSyncExternalStore((listener) => uiState().notices.subscribe(listener), () => uiState().notices.getSnapshot());
|
|
9
|
+
}
|
|
10
|
+
export function useLoadingState() {
|
|
11
|
+
return useSyncExternalStore((listener) => uiState().loading.subscribe(listener), () => uiState().loading.getSnapshot());
|
|
12
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Mask = Mask;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const components_1 = require("@tarojs/components");
|
|
6
|
+
/** 遮罩:点击回调由宿主给,库不决定关闭策略。 */
|
|
7
|
+
function Mask({ visible = true, onClose, className }) {
|
|
8
|
+
if (!visible)
|
|
9
|
+
return null;
|
|
10
|
+
const names = ['mptk-mask', className];
|
|
11
|
+
return (0, jsx_runtime_1.jsx)(components_1.View, { className: names.filter(Boolean).join(' '), onClick: () => onClose?.() });
|
|
12
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { View } from '@tarojs/components';
|
|
3
|
+
/** 遮罩:点击回调由宿主给,库不决定关闭策略。 */
|
|
4
|
+
export function Mask({ visible = true, onClose, className }) {
|
|
5
|
+
if (!visible)
|
|
6
|
+
return null;
|
|
7
|
+
const names = ['mptk-mask', className];
|
|
8
|
+
return _jsx(View, { className: names.filter(Boolean).join(' '), onClick: () => onClose?.() });
|
|
9
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Overlay = Overlay;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const components_1 = require("@tarojs/components");
|
|
6
|
+
/** 浮层定位容器:只负责层级与定位,内容由 children 注入。 */
|
|
7
|
+
function Overlay({ visible = true, children, className }) {
|
|
8
|
+
if (!visible)
|
|
9
|
+
return null;
|
|
10
|
+
return (0, jsx_runtime_1.jsx)(components_1.View, { className: ['mptk-overlay', className].filter(Boolean).join(' '), children: children });
|
|
11
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
export interface OverlayProps {
|
|
3
|
+
visible?: boolean;
|
|
4
|
+
children?: ReactNode;
|
|
5
|
+
className?: string;
|
|
6
|
+
}
|
|
7
|
+
/** 浮层定位容器:只负责层级与定位,内容由 children 注入。 */
|
|
8
|
+
export declare function Overlay({ visible, children, className }: OverlayProps): import("react").JSX.Element | null;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { View } from '@tarojs/components';
|
|
3
|
+
/** 浮层定位容器:只负责层级与定位,内容由 children 注入。 */
|
|
4
|
+
export function Overlay({ visible = true, children, className }) {
|
|
5
|
+
if (!visible)
|
|
6
|
+
return null;
|
|
7
|
+
return _jsx(View, { className: ['mptk-overlay', className].filter(Boolean).join(' '), children: children });
|
|
8
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Popup = Popup;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const components_1 = require("@tarojs/components");
|
|
6
|
+
const Mask_js_1 = require("./Mask.cjs");
|
|
7
|
+
/** 弹出层:遮罩 + 定位面板,面板内容由 children 注入。 */
|
|
8
|
+
function Popup({ open, position = 'bottom', children, onClose, className }) {
|
|
9
|
+
if (!open)
|
|
10
|
+
return null;
|
|
11
|
+
const names = ['mptk-popup__panel', `mptk-popup__panel--${position}`, className];
|
|
12
|
+
return ((0, jsx_runtime_1.jsxs)(components_1.View, { className: "mptk-popup", children: [(0, jsx_runtime_1.jsx)(Mask_js_1.Mask, { onClose: onClose }), (0, jsx_runtime_1.jsx)(components_1.View, { className: names.filter(Boolean).join(' '), children: children })] }));
|
|
13
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
export type PopupPosition = 'top' | 'center' | 'bottom';
|
|
3
|
+
export interface PopupProps {
|
|
4
|
+
open: boolean;
|
|
5
|
+
position?: PopupPosition;
|
|
6
|
+
children?: ReactNode;
|
|
7
|
+
onClose?: () => void;
|
|
8
|
+
className?: string;
|
|
9
|
+
}
|
|
10
|
+
/** 弹出层:遮罩 + 定位面板,面板内容由 children 注入。 */
|
|
11
|
+
export declare function Popup({ open, position, children, onClose, className }: PopupProps): import("react").JSX.Element | null;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { View } from '@tarojs/components';
|
|
3
|
+
import { Mask } from './Mask.js';
|
|
4
|
+
/** 弹出层:遮罩 + 定位面板,面板内容由 children 注入。 */
|
|
5
|
+
export function Popup({ open, position = 'bottom', children, onClose, className }) {
|
|
6
|
+
if (!open)
|
|
7
|
+
return null;
|
|
8
|
+
const names = ['mptk-popup__panel', `mptk-popup__panel--${position}`, className];
|
|
9
|
+
return (_jsxs(View, { className: "mptk-popup", children: [_jsx(Mask, { onClose: onClose }), _jsx(View, { className: names.filter(Boolean).join(' '), children: children })] }));
|
|
10
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Popup = exports.Mask = exports.Overlay = void 0;
|
|
4
|
+
var Overlay_js_1 = require("./Overlay.cjs");
|
|
5
|
+
Object.defineProperty(exports, "Overlay", { enumerable: true, get: function () { return Overlay_js_1.Overlay; } });
|
|
6
|
+
var Mask_js_1 = require("./Mask.cjs");
|
|
7
|
+
Object.defineProperty(exports, "Mask", { enumerable: true, get: function () { return Mask_js_1.Mask; } });
|
|
8
|
+
var Popup_js_1 = require("./Popup.cjs");
|
|
9
|
+
Object.defineProperty(exports, "Popup", { enumerable: true, get: function () { return Popup_js_1.Popup; } });
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
.mptk-overlay {
|
|
2
|
+
position: fixed;
|
|
3
|
+
top: 0;
|
|
4
|
+
right: 0;
|
|
5
|
+
bottom: 0;
|
|
6
|
+
left: 0;
|
|
7
|
+
z-index: 900;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.mptk-mask {
|
|
11
|
+
position: fixed;
|
|
12
|
+
top: 0;
|
|
13
|
+
right: 0;
|
|
14
|
+
bottom: 0;
|
|
15
|
+
left: 0;
|
|
16
|
+
background-color: var(--mptk-fg);
|
|
17
|
+
opacity: 0.4;
|
|
18
|
+
z-index: 910;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.mptk-popup {
|
|
22
|
+
position: relative;
|
|
23
|
+
z-index: 920;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.mptk-popup__panel {
|
|
27
|
+
position: fixed;
|
|
28
|
+
left: 0;
|
|
29
|
+
right: 0;
|
|
30
|
+
background-color: var(--mptk-surface-1);
|
|
31
|
+
border-top-left-radius: var(--mptk-radius-lg);
|
|
32
|
+
border-top-right-radius: var(--mptk-radius-lg);
|
|
33
|
+
border-bottom-left-radius: var(--mptk-radius-lg);
|
|
34
|
+
border-bottom-right-radius: var(--mptk-radius-lg);
|
|
35
|
+
padding-top: var(--mptk-space-4);
|
|
36
|
+
padding-right: var(--mptk-space-4);
|
|
37
|
+
padding-bottom: var(--mptk-space-4);
|
|
38
|
+
padding-left: var(--mptk-space-4);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.mptk-popup__panel--top {
|
|
42
|
+
top: 0;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.mptk-popup__panel--bottom {
|
|
46
|
+
bottom: 0;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.mptk-popup__panel--center {
|
|
50
|
+
top: 50%;
|
|
51
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Drawer = Drawer;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const components_1 = require("@tarojs/components");
|
|
6
|
+
/** 侧滑面板:不用 Skyline 独占手势 API,两端表现一致。 */
|
|
7
|
+
function Drawer({ open, side = 'left', children, onClose, className }) {
|
|
8
|
+
if (!open)
|
|
9
|
+
return null;
|
|
10
|
+
const names = ['mptk-drawer__panel', `mptk-drawer__panel--${side}`, className];
|
|
11
|
+
return ((0, jsx_runtime_1.jsxs)(components_1.View, { className: "mptk-drawer", children: [(0, jsx_runtime_1.jsx)(components_1.View, { className: "mptk-drawer__mask", onClick: () => onClose?.() }), (0, jsx_runtime_1.jsx)(components_1.View, { className: names.filter(Boolean).join(' '), children: children })] }));
|
|
12
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
export type DrawerSide = 'left' | 'right';
|
|
3
|
+
export interface DrawerProps {
|
|
4
|
+
open: boolean;
|
|
5
|
+
side?: DrawerSide;
|
|
6
|
+
children?: ReactNode;
|
|
7
|
+
onClose?: () => void;
|
|
8
|
+
className?: string;
|
|
9
|
+
}
|
|
10
|
+
/** 侧滑面板:不用 Skyline 独占手势 API,两端表现一致。 */
|
|
11
|
+
export declare function Drawer({ open, side, children, onClose, className }: DrawerProps): import("react").JSX.Element | null;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { View } from '@tarojs/components';
|
|
3
|
+
/** 侧滑面板:不用 Skyline 独占手势 API,两端表现一致。 */
|
|
4
|
+
export function Drawer({ open, side = 'left', children, onClose, className }) {
|
|
5
|
+
if (!open)
|
|
6
|
+
return null;
|
|
7
|
+
const names = ['mptk-drawer__panel', `mptk-drawer__panel--${side}`, className];
|
|
8
|
+
return (_jsxs(View, { className: "mptk-drawer", children: [_jsx(View, { className: "mptk-drawer__mask", onClick: () => onClose?.() }), _jsx(View, { className: names.filter(Boolean).join(' '), children: children })] }));
|
|
9
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Dropdown = Dropdown;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const components_1 = require("@tarojs/components");
|
|
6
|
+
/** 下拉面板:只给容器与关闭回调,下拉项内容由 children 注入。 */
|
|
7
|
+
function Dropdown({ open, children, onClose, className }) {
|
|
8
|
+
if (!open)
|
|
9
|
+
return null;
|
|
10
|
+
const names = ['mptk-dropdown__panel', className];
|
|
11
|
+
return ((0, jsx_runtime_1.jsxs)(components_1.View, { className: "mptk-dropdown", children: [(0, jsx_runtime_1.jsx)(components_1.View, { className: "mptk-dropdown__mask", onClick: () => onClose?.() }), (0, jsx_runtime_1.jsx)(components_1.View, { className: names.filter(Boolean).join(' '), children: children })] }));
|
|
12
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
export interface DropdownProps {
|
|
3
|
+
open: boolean;
|
|
4
|
+
children?: ReactNode;
|
|
5
|
+
onClose?: () => void;
|
|
6
|
+
className?: string;
|
|
7
|
+
}
|
|
8
|
+
/** 下拉面板:只给容器与关闭回调,下拉项内容由 children 注入。 */
|
|
9
|
+
export declare function Dropdown({ open, children, onClose, className }: DropdownProps): import("react").JSX.Element | null;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { View } from '@tarojs/components';
|
|
3
|
+
/** 下拉面板:只给容器与关闭回调,下拉项内容由 children 注入。 */
|
|
4
|
+
export function Dropdown({ open, children, onClose, className }) {
|
|
5
|
+
if (!open)
|
|
6
|
+
return null;
|
|
7
|
+
const names = ['mptk-dropdown__panel', className];
|
|
8
|
+
return (_jsxs(View, { className: "mptk-dropdown", children: [_jsx(View, { className: "mptk-dropdown__mask", onClick: () => onClose?.() }), _jsx(View, { className: names.filter(Boolean).join(' '), children: children })] }));
|
|
9
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Dropdown = exports.Drawer = void 0;
|
|
4
|
+
var Drawer_js_1 = require("./Drawer.cjs");
|
|
5
|
+
Object.defineProperty(exports, "Drawer", { enumerable: true, get: function () { return Drawer_js_1.Drawer; } });
|
|
6
|
+
var Dropdown_js_1 = require("./Dropdown.cjs");
|
|
7
|
+
Object.defineProperty(exports, "Dropdown", { enumerable: true, get: function () { return Dropdown_js_1.Dropdown; } });
|