@taicode/common-web 1.1.21 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/output/cache-api/cache-api.js +1 -1
- package/output/cache-api/cache-api.test.js +1 -1
- package/output/cache-api/index.d.ts +1 -1
- package/output/cache-api/index.d.ts.map +1 -1
- package/output/cache-api/index.js +1 -1
- package/output/loading-button/LoadingButtonDemo.d.ts +5 -0
- package/output/loading-button/LoadingButtonDemo.d.ts.map +1 -0
- package/output/loading-button/LoadingButtonDemo.js +33 -0
- package/output/loading-button/index.d.ts +31 -13
- package/output/loading-button/index.d.ts.map +1 -1
- package/output/loading-button/index.js +50 -26
- package/output/loading-button/index.test.d.ts +2 -0
- package/output/loading-button/index.test.d.ts.map +1 -0
- package/output/loading-button/index.test.js +203 -0
- package/output/service/index.d.ts +1 -1
- package/output/service/index.d.ts.map +1 -1
- package/output/service/index.js +1 -1
- package/output/service/service.d.ts +1 -1
- package/output/service/service.d.ts.map +1 -1
- package/output/service/service.js +9 -8
- package/output/service/service.test.js +2 -1
- package/output/side-cache/index.d.ts +1 -1
- package/output/side-cache/index.d.ts.map +1 -1
- package/output/side-cache/index.js +1 -1
- package/output/side-cache/side-cache.test.js +1 -1
- package/output/signin/context.d.ts +1 -2
- package/output/signin/context.d.ts.map +1 -1
- package/output/signin/context.js +3 -3
- package/output/signin/index.d.ts +3 -3
- package/output/signin/index.d.ts.map +1 -1
- package/output/signin/index.js +36 -18
- package/output/signin/service.d.ts +1 -1
- package/output/signin/service.d.ts.map +1 -1
- package/output/signin/service.js +6 -6
- package/output/signin/service.test.js +7 -3
- package/output/size-provider/index.d.ts +1 -1
- package/output/size-provider/index.d.ts.map +1 -1
- package/output/size-provider/index.js +1 -1
- package/output/size-provider/size-provider.d.ts +1 -1
- package/output/size-provider/size-provider.d.ts.map +1 -1
- package/output/size-provider/size-provider.js +1 -1
- package/output/toaster/index.d.ts +0 -1
- package/output/toaster/index.d.ts.map +1 -1
- package/output/toaster/index.js +7 -8
- package/output/use-observer/index.d.ts +1 -1
- package/output/use-observer/index.d.ts.map +1 -1
- package/output/use-observer/index.js +1 -1
- package/output/use-observer/use-observer.js +2 -2
- package/output/use-observer/use-observer.test.js +2 -2
- package/package.json +26 -18
- package/output/catalyst/alert.jsx +0 -55
- package/output/catalyst/auth-layout.jsx +0 -7
- package/output/catalyst/avatar.jsx +0 -45
- package/output/catalyst/badge.jsx +0 -53
- package/output/catalyst/button.jsx +0 -187
- package/output/catalyst/checkbox.jsx +0 -105
- package/output/catalyst/combobox.jsx +0 -120
- package/output/catalyst/description-list.jsx +0 -24
- package/output/catalyst/dialog.jsx +0 -55
- package/output/catalyst/divider.jsx +0 -16
- package/output/catalyst/dropdown.jsx +0 -102
- package/output/catalyst/fieldset.jsx +0 -41
- package/output/catalyst/heading.jsx +0 -22
- package/output/catalyst/input.jsx +0 -73
- package/output/catalyst/link.jsx +0 -14
- package/output/catalyst/listbox.jsx +0 -120
- package/output/catalyst/navbar.jsx +0 -67
- package/output/catalyst/pagination.jsx +0 -52
- package/output/catalyst/radio.jsx +0 -103
- package/output/catalyst/select.jsx +0 -59
- package/output/catalyst/sidebar-layout.jsx +0 -58
- package/output/catalyst/sidebar.jsx +0 -85
- package/output/catalyst/stacked-layout.jsx +0 -55
- package/output/catalyst/switch.jsx +0 -161
- package/output/catalyst/table.jsx +0 -68
- package/output/catalyst/text.jsx +0 -29
- package/output/catalyst/textarea.jsx +0 -49
- package/output/helpers/cache-api/cache-api.d.ts +0 -13
- package/output/helpers/cache-api/cache-api.d.ts.map +0 -1
- package/output/helpers/cache-api/cache-api.js +0 -114
- package/output/helpers/cache-api/cache-api.test.d.ts +0 -2
- package/output/helpers/cache-api/cache-api.test.d.ts.map +0 -1
- package/output/helpers/cache-api/cache-api.test.js +0 -348
- package/output/helpers/cache-api/index.d.ts +0 -2
- package/output/helpers/cache-api/index.d.ts.map +0 -1
- package/output/helpers/cache-api/index.js +0 -1
- package/output/helpers/service/index.d.ts +0 -1
- package/output/helpers/service/index.d.ts.map +0 -1
- package/output/helpers/service/index.js +0 -1
- package/output/helpers/service/service.d.ts +0 -5
- package/output/helpers/service/service.d.ts.map +0 -1
- package/output/helpers/service/service.js +0 -2
- package/output/helpers/side-cache/index.d.ts +0 -2
- package/output/helpers/side-cache/index.d.ts.map +0 -1
- package/output/helpers/side-cache/index.js +0 -1
- package/output/helpers/side-cache/side-cache.d.ts +0 -10
- package/output/helpers/side-cache/side-cache.d.ts.map +0 -1
- package/output/helpers/side-cache/side-cache.js +0 -137
- package/output/helpers/side-cache/side-cache.test.d.ts +0 -2
- package/output/helpers/side-cache/side-cache.test.d.ts.map +0 -1
- package/output/helpers/side-cache/side-cache.test.js +0 -179
- package/output/helpers/use-observer/index.d.ts +0 -2
- package/output/helpers/use-observer/index.d.ts.map +0 -1
- package/output/helpers/use-observer/index.js +0 -1
- package/output/helpers/use-observer/use-observer.d.ts +0 -3
- package/output/helpers/use-observer/use-observer.d.ts.map +0 -1
- package/output/helpers/use-observer/use-observer.js +0 -16
- package/output/helpers/use-observer/use-observer.test.d.ts +0 -2
- package/output/helpers/use-observer/use-observer.test.d.ts.map +0 -1
- package/output/helpers/use-observer/use-observer.test.jsx +0 -134
- package/output/service/service.test.jsx +0 -367
- package/output/use-observer/use-observer.test.jsx +0 -134
package/output/signin/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import type { SigninApi } from './types';
|
|
3
|
-
export { useSignin } from './context';
|
|
4
|
-
export type { SigninApi, SigninStatus, SigninApiError, ApplySigninResult, CheckStatusResult, } from './types';
|
|
2
|
+
import type { SigninApi } from './types.js';
|
|
3
|
+
export { useSignin } from './context.js';
|
|
4
|
+
export type { SigninApi, SigninStatus, SigninApiError, ApplySigninResult, CheckStatusResult, } from './types.js';
|
|
5
5
|
/**
|
|
6
6
|
* 登录弹窗文案配置
|
|
7
7
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/signin/index.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/signin/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAuC,MAAM,OAAO,CAAA;AAY3D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AAI3C,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAGxC,YAAY,EACV,SAAS,EACT,YAAY,EACZ,cAAc,EACd,iBAAiB,EACjB,iBAAiB,GAClB,MAAM,YAAY,CAAA;AAEnB;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,cAAc;IACd,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,aAAa;IACb,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,aAAa;IACb,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,aAAa;IACb,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,cAAc;IACd,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,cAAc;IACd,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,iBAAiB;IACjB,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B,mBAAmB;IACnB,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B,aAAa;IACb,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B,sBAAsB;IACtB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,kBAAkB;IAClB,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,eAAe;IACf,oBAAoB,CAAC,EAAE,MAAM,CAAA;IAC7B,cAAc;IACd,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B,mBAAmB;IACnB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,eAAe;IACf,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,aAAa;IACb,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,aAAa;IACb,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB;AAwWD;;;GAGG;AACH,UAAU,yBAAyB;IACjC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;IACzB,yBAAyB;IACzB,IAAI,EAAE,SAAS,CAAA;IACf,mBAAmB;IACnB,KAAK,CAAC,EAAE,iBAAiB,CAAA;CAC1B;AAED,eAAO,MAAM,oBAAoB,WAAoB,yBAAyB;;CAmC5E,CAAA"}
|
package/output/signin/index.js
CHANGED
|
@@ -1,14 +1,24 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
1
12
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import React from 'react';
|
|
13
|
+
import React, { useRef, useMemo, useCallback } from 'react';
|
|
3
14
|
import { observer } from 'mobx-react-lite';
|
|
4
15
|
import { motion, AnimatePresence } from 'framer-motion';
|
|
16
|
+
import * as DialogPrimitive from '@radix-ui/react-dialog';
|
|
5
17
|
import { CheckCircleIcon, XCircleIcon, ExclamationTriangleIcon, ClockIcon } from '@heroicons/react/24/outline';
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
import { ServiceProvider } from '../service';
|
|
11
|
-
export { useSignin } from './context';
|
|
18
|
+
import { SigninService } from './service.js';
|
|
19
|
+
import { SigninContext } from './context.js';
|
|
20
|
+
import { ServiceProvider } from '../service/index.js';
|
|
21
|
+
export { useSignin } from './context.js';
|
|
12
22
|
/**
|
|
13
23
|
* 默认文案
|
|
14
24
|
*/
|
|
@@ -31,6 +41,14 @@ const defaultTexts = {
|
|
|
31
41
|
cancelButton: '取消',
|
|
32
42
|
closeButton: '关闭'
|
|
33
43
|
};
|
|
44
|
+
const Button = (_a) => {
|
|
45
|
+
var { variant = 'primary', className = '', children } = _a, props = __rest(_a, ["variant", "className", "children"]);
|
|
46
|
+
const baseStyles = 'inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-[var(--radius)] text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--ring)] focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 h-10 px-4 py-2';
|
|
47
|
+
const variantStyles = variant === 'primary'
|
|
48
|
+
? 'bg-[var(--primary)] text-[var(--primary-foreground)] hover:opacity-90'
|
|
49
|
+
: 'border border-[var(--input)] bg-[var(--background)] hover:bg-[var(--accent)] hover:text-[var(--accent-foreground)]';
|
|
50
|
+
return (_jsx("button", Object.assign({ className: `${baseStyles} ${variantStyles} ${className}` }, props, { children: children })));
|
|
51
|
+
};
|
|
34
52
|
const SigninDialog = observer((props) => {
|
|
35
53
|
const { service, texts } = props;
|
|
36
54
|
// 禁止关闭弹窗,防止用户误操作
|
|
@@ -70,47 +88,47 @@ const SigninDialog = observer((props) => {
|
|
|
70
88
|
const OpeningState = () => (_jsxs(motion.div, { initial: { opacity: 0, scale: 0.9 }, animate: { opacity: 1, scale: 1 }, exit: { opacity: 0, scale: 0.9 }, transition: { duration: 0.2 }, className: "flex flex-col items-center gap-4", children: [_jsxs("div", { className: "relative flex items-center justify-center mb-8", children: [_jsx(motion.div, { className: "absolute size-16 rounded-full border-4 border-transparent border-t-emerald-600 border-r-emerald-600", animate: { rotate: 360 }, transition: { duration: 1, repeat: Infinity, ease: 'linear' } }), _jsx(motion.div, { className: "absolute size-12 rounded-full border-4 border-transparent border-b-emerald-400 border-l-emerald-400", animate: { rotate: -360 }, transition: { duration: 1.5, repeat: Infinity, ease: 'linear' } }), _jsx(motion.div, { className: "size-3 rounded-full bg-emerald-600", animate: {
|
|
71
89
|
scale: [1, 1.2, 1],
|
|
72
90
|
opacity: [1, 0.7, 1]
|
|
73
|
-
}, transition: { duration: 1, repeat: Infinity } })] }), _jsx(motion.p, { initial: { opacity: 0 }, animate: { opacity: 1 }, transition: { delay: 0.1 }, className: "text-base font-semibold text-
|
|
91
|
+
}, transition: { duration: 1, repeat: Infinity } })] }), _jsx(motion.p, { initial: { opacity: 0 }, animate: { opacity: 1 }, transition: { delay: 0.1 }, className: "text-base font-semibold text-[var(--foreground)]", children: texts.openingDescription }), _jsxs(motion.div, { initial: { opacity: 0, y: 10 }, animate: { opacity: 1, y: 0 }, transition: { delay: 0.2 }, className: "mt-2 flex gap-2", children: [_jsx(Button, { variant: "primary", onClick: handleReopenWindow, children: texts.reopenButton }), _jsx(Button, { variant: "outline", onClick: handleCancel, children: texts.cancelButton })] })] }, "opening"));
|
|
74
92
|
/**
|
|
75
93
|
* Waiting 状态 - 等待用户登录
|
|
76
94
|
*/
|
|
77
|
-
const WaitingState = () => (_jsxs(motion.div, { initial: { opacity: 0, scale: 0.9 }, animate: { opacity: 1, scale: 1 }, exit: { opacity: 0, scale: 0.9 }, transition: { duration: 0.2 }, className: "flex flex-col items-center gap-4", children: [_jsxs("div", { className: "relative mb-2", children: [_jsx(motion.div, { className: "size-16 rounded-full border-4 border-emerald-200 dark:border-emerald-900", animate: { scale: [1, 1.1, 1] }, transition: { duration: 2, repeat: Infinity } }), _jsx(motion.div, { className: "absolute inset-0 size-16 rounded-full border-4 border-emerald-400", animate: { scale: [1, 1.3, 1], opacity: [0.75, 0, 0.75] }, transition: { duration: 2, repeat: Infinity } }), _jsx(motion.svg, { className: "absolute inset-0 m-auto size-8 text-emerald-600", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", initial: { scale: 0 }, animate: { scale: 1 }, transition: { delay: 0.1 }, children: _jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z" }) })] }), _jsx("p", { className: "text-base font-semibold text-
|
|
95
|
+
const WaitingState = () => (_jsxs(motion.div, { initial: { opacity: 0, scale: 0.9 }, animate: { opacity: 1, scale: 1 }, exit: { opacity: 0, scale: 0.9 }, transition: { duration: 0.2 }, className: "flex flex-col items-center gap-4", children: [_jsxs("div", { className: "relative mb-2", children: [_jsx(motion.div, { className: "size-16 rounded-full border-4 border-emerald-200 dark:border-emerald-900", animate: { scale: [1, 1.1, 1] }, transition: { duration: 2, repeat: Infinity } }), _jsx(motion.div, { className: "absolute inset-0 size-16 rounded-full border-4 border-emerald-400", animate: { scale: [1, 1.3, 1], opacity: [0.75, 0, 0.75] }, transition: { duration: 2, repeat: Infinity } }), _jsx(motion.svg, { className: "absolute inset-0 m-auto size-8 text-emerald-600", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", initial: { scale: 0 }, animate: { scale: 1 }, transition: { delay: 0.1 }, children: _jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z" }) })] }), _jsx("p", { className: "text-base font-semibold text-[var(--foreground)]", children: texts.waitingDescription }), _jsx("p", { className: "text-xs text-[var(--muted-foreground)]", children: texts.waitingHint }), _jsxs("div", { className: "mt-2 flex gap-2", children: [_jsx(Button, { variant: "primary", onClick: handleReopenWindow, children: texts.reopenButton }), _jsx(Button, { variant: "outline", onClick: handleCancel, children: texts.cancelButton })] })] }, "waiting"));
|
|
78
96
|
/**
|
|
79
97
|
* Success 状态 - 登录成功
|
|
80
98
|
*/
|
|
81
|
-
const SuccessState = () => (_jsxs(motion.div, { initial: { opacity: 0, scale: 0.5 }, animate: { opacity: 1, scale: 1 }, exit: { opacity: 0, scale: 0.5 }, transition: { duration: 0.3, type: 'spring' }, className: "flex flex-col items-center gap-4", children: [_jsx(motion.div, { className: "mb-2", initial: { scale: 0 }, animate: { scale: 1 }, transition: { delay: 0.1, type: 'spring', stiffness: 200 }, children: _jsx(CheckCircleIcon, { className: "size-16 text-emerald-600 dark:text-emerald-400" }) }), _jsx(motion.p, { initial: { opacity: 0, y: 10 }, animate: { opacity: 1, y: 0 }, transition: { delay: 0.2 }, className: "text-base font-semibold text-
|
|
99
|
+
const SuccessState = () => (_jsxs(motion.div, { initial: { opacity: 0, scale: 0.5 }, animate: { opacity: 1, scale: 1 }, exit: { opacity: 0, scale: 0.5 }, transition: { duration: 0.3, type: 'spring' }, className: "flex flex-col items-center gap-4", children: [_jsx(motion.div, { className: "mb-2", initial: { scale: 0 }, animate: { scale: 1 }, transition: { delay: 0.1, type: 'spring', stiffness: 200 }, children: _jsx(CheckCircleIcon, { className: "size-16 text-emerald-600 dark:text-emerald-400" }) }), _jsx(motion.p, { initial: { opacity: 0, y: 10 }, animate: { opacity: 1, y: 0 }, transition: { delay: 0.2 }, className: "text-base font-semibold text-[var(--primary)]", children: texts.successDescription })] }, "success"));
|
|
82
100
|
/**
|
|
83
101
|
* Error 状态 - 登录失败
|
|
84
102
|
*/
|
|
85
|
-
const ErrorState = () => (_jsxs(motion.div, { initial: { opacity: 0, scale: 0.9 }, animate: { opacity: 1, scale: 1 }, exit: { opacity: 0, scale: 0.9 }, transition: { duration: 0.2 }, className: "flex flex-col items-center gap-4", children: [_jsx(motion.div, { className: "mb-2", initial: { scale: 0 }, animate: { scale: 1, rotate: [0, -10, 10, -10, 0] }, transition: { scale: { delay: 0.1 }, rotate: { delay: 0.2, duration: 0.5 } }, children: _jsx(XCircleIcon, { className: "size-16 text-red-600 dark:text-red-400" }) }), _jsx("p", { className: "text-base font-semibold text-
|
|
103
|
+
const ErrorState = () => (_jsxs(motion.div, { initial: { opacity: 0, scale: 0.9 }, animate: { opacity: 1, scale: 1 }, exit: { opacity: 0, scale: 0.9 }, transition: { duration: 0.2 }, className: "flex flex-col items-center gap-4", children: [_jsx(motion.div, { className: "mb-2", initial: { scale: 0 }, animate: { scale: 1, rotate: [0, -10, 10, -10, 0] }, transition: { scale: { delay: 0.1 }, rotate: { delay: 0.2, duration: 0.5 } }, children: _jsx(XCircleIcon, { className: "size-16 text-red-600 dark:text-red-400" }) }), _jsx("p", { className: "text-base font-semibold text-[var(--destructive)]", children: service.errorMessage || texts.errorDescription }), _jsxs("div", { className: "mt-2 flex gap-2", children: [_jsx(Button, { variant: "primary", onClick: handleRetry, children: texts.retryButton }), _jsx(Button, { variant: "outline", onClick: handleClose, children: texts.closeButton })] })] }, "error"));
|
|
86
104
|
/**
|
|
87
105
|
* Cancelled 状态 - 用户取消登录
|
|
88
106
|
*/
|
|
89
|
-
const CancelledState = () => (_jsxs(motion.div, { initial: { opacity: 0, scale: 0.9 }, animate: { opacity: 1, scale: 1 }, exit: { opacity: 0, scale: 0.9 }, transition: { duration: 0.2 }, className: "flex flex-col items-center gap-4", children: [_jsx(motion.div, { className: "mb-2", initial: { scale: 0 }, animate: { scale: 1 }, transition: { delay: 0.1, type: 'spring' }, children: _jsx(ExclamationTriangleIcon, { className: "size-16 text-amber-600 dark:text-amber-400" }) }), _jsx("p", { className: "text-base font-semibold text-
|
|
107
|
+
const CancelledState = () => (_jsxs(motion.div, { initial: { opacity: 0, scale: 0.9 }, animate: { opacity: 1, scale: 1 }, exit: { opacity: 0, scale: 0.9 }, transition: { duration: 0.2 }, className: "flex flex-col items-center gap-4", children: [_jsx(motion.div, { className: "mb-2", initial: { scale: 0 }, animate: { scale: 1 }, transition: { delay: 0.1, type: 'spring' }, children: _jsx(ExclamationTriangleIcon, { className: "size-16 text-amber-600 dark:text-amber-400" }) }), _jsx("p", { className: "text-base font-semibold text-[var(--muted-foreground)]", children: texts.cancelledDescription }), _jsxs("div", { className: "mt-2 flex gap-2", children: [_jsx(Button, { variant: "primary", onClick: handleRetry, children: texts.retryButton }), _jsx(Button, { variant: "outline", onClick: handleClose, children: texts.closeButton })] })] }, "cancelled"));
|
|
90
108
|
/**
|
|
91
109
|
* Expired 状态 - 票据过期
|
|
92
110
|
*/
|
|
93
|
-
const ExpiredState = () => (_jsxs(motion.div, { initial: { opacity: 0, scale: 0.9 }, animate: { opacity: 1, scale: 1 }, exit: { opacity: 0, scale: 0.9 }, transition: { duration: 0.2 }, className: "flex flex-col items-center gap-4", children: [_jsx(motion.div, { className: "mb-2", initial: { scale: 0 }, animate: { scale: 1 }, transition: { delay: 0.1, type: 'spring' }, children: _jsx(ClockIcon, { className: "size-16 text-orange-600 dark:text-orange-400" }) }), _jsx("p", { className: "text-base font-semibold text-
|
|
94
|
-
return (_jsx(
|
|
111
|
+
const ExpiredState = () => (_jsxs(motion.div, { initial: { opacity: 0, scale: 0.9 }, animate: { opacity: 1, scale: 1 }, exit: { opacity: 0, scale: 0.9 }, transition: { duration: 0.2 }, className: "flex flex-col items-center gap-4", children: [_jsx(motion.div, { className: "mb-2", initial: { scale: 0 }, animate: { scale: 1 }, transition: { delay: 0.1, type: 'spring' }, children: _jsx(ClockIcon, { className: "size-16 text-orange-600 dark:text-orange-400" }) }), _jsx("p", { className: "text-base font-semibold text-[var(--muted-foreground)]", children: texts.expiredDescription }), _jsxs("div", { className: "mt-2 flex gap-2", children: [_jsx(Button, { variant: "primary", onClick: handleRetry, children: texts.retryButton }), _jsx(Button, { variant: "outline", onClick: handleClose, children: texts.closeButton })] })] }, "expired"));
|
|
112
|
+
return (_jsx(DialogPrimitive.Root, { open: service.isDialogOpen, onOpenChange: (open) => !open && preventClose(), children: _jsxs(DialogPrimitive.Portal, { children: [_jsx(DialogPrimitive.Overlay, { className: "fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0" }), _jsx(DialogPrimitive.Content, { className: "fixed left-[50%] top-[50%] z-50 w-full max-w-md translate-x-[-50%] translate-y-[-50%] border border-[var(--border)] bg-[var(--background)] p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] rounded-[var(--radius)]", children: _jsx("div", { className: "flex flex-col items-center justify-center py-8", children: _jsxs(AnimatePresence, { mode: "wait", children: [service.dialogStatus === 'opening' && _jsx(OpeningState, {}), service.dialogStatus === 'waiting' && _jsx(WaitingState, {}), service.dialogStatus === 'success' && _jsx(SuccessState, {}), service.dialogStatus === 'error' && _jsx(ErrorState, {}), service.dialogStatus === 'cancelled' && _jsx(CancelledState, {}), service.dialogStatus === 'expired' && _jsx(ExpiredState, {})] }) }) })] }) }));
|
|
95
113
|
});
|
|
96
114
|
export const SigninDialogProvider = observer((props) => {
|
|
97
115
|
const { children, apis: apiConfig, texts: customTexts } = props;
|
|
98
116
|
// 创建服务实例,使用 useRef 保持引用稳定
|
|
99
|
-
const signinService =
|
|
117
|
+
const signinService = useRef();
|
|
100
118
|
if (!signinService.current) {
|
|
101
119
|
signinService.current = new SigninService(apiConfig);
|
|
102
120
|
signinService.current.init();
|
|
103
121
|
}
|
|
104
122
|
// 合并默认文案和自定义文案
|
|
105
|
-
const texts =
|
|
106
|
-
const handleSignin =
|
|
123
|
+
const texts = useMemo(() => (Object.assign(Object.assign({}, defaultTexts), customTexts)), [customTexts]);
|
|
124
|
+
const handleSignin = useCallback(async () => {
|
|
107
125
|
var _a;
|
|
108
126
|
const url = await ((_a = signinService.current) === null || _a === void 0 ? void 0 : _a.start());
|
|
109
127
|
if (url) {
|
|
110
128
|
window.open(url, '_blank');
|
|
111
129
|
}
|
|
112
130
|
}, []);
|
|
113
|
-
const contextValue =
|
|
131
|
+
const contextValue = useMemo(() => ({
|
|
114
132
|
signin: handleSignin
|
|
115
133
|
}), [handleSignin]);
|
|
116
134
|
return (_jsx(SigninContext.Provider, { value: contextValue, children: _jsxs(ServiceProvider, { services: [{ provide: SigninService, useValue: signinService.current }], children: [children, signinService.current && _jsx(SigninDialog, { service: signinService.current, texts: texts })] }) }));
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Service } from '@taicode/common-base';
|
|
2
|
-
import type { SigninApi, SigninStatus } from './types';
|
|
2
|
+
import type { SigninApi, SigninStatus } from './types.js';
|
|
3
3
|
export type SigninDialogStatus = 'idle' | 'opening' | 'waiting' | 'success' | 'error' | 'cancelled' | 'expired';
|
|
4
4
|
/**
|
|
5
5
|
* 登录服务配置
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../source/signin/service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAsB,MAAM,sBAAsB,CAAA;AAElE,OAAO,KAAK,EAAE,SAAS,EAAwC,YAAY,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../source/signin/service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAsB,MAAM,sBAAsB,CAAA;AAElE,OAAO,KAAK,EAAE,SAAS,EAAwC,YAAY,EAAE,MAAM,YAAY,CAAA;AAE/F,MAAM,MAAM,kBAAkB,GAAG,MAAM,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,GAAG,WAAW,GAAG,SAAS,CAAA;AAE/G;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,2BAA2B;IAC3B,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,6BAA6B;IAC7B,mBAAmB,CAAC,EAAE,MAAM,CAAA;IAC5B,6BAA6B;IAC7B,sBAAsB,CAAC,EAAE,MAAM,CAAA;CAChC;AAoBD,qBAAa,aAAc,SAAQ,OAAO;IACxC,SACgB,MAAM,EAAE,OAAO,CAAQ;IAEvC,OAAO,CAAC,SAAS,CAAiB;IAClC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAiB;IAC1C,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAW;IACrC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA+B;IACtD,OAAO,CAAC,YAAY,CAA6C;IAGjE,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAiC;IAGvD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAiC;IAGxD,SACgB,YAAY,EAAE,kBAAkB,CAAS;IAEzD,SACgB,YAAY,EAAE,MAAM,CAAK;gBAE7B,SAAS,EAAE,SAAS,EAAE,MAAM,GAAE,mBAAwB;IAMlE,IACW,MAAM,IAAI,YAAY,GAAG,IAAI,CAIvC;IAED,IACW,SAAS,IAAI,MAAM,GAAG,IAAI,CAEpC;IAED,IACW,YAAY,IAAI,OAAO,CAEjC;IAED,IACW,eAAe,IAAI,OAAO,CAEpC;IAED;;OAEG;IACH,OAAO,CAAC,eAAe;IAKvB;;OAEG;IACH,OAAO,CAAC,SAAS;IAgBjB;;OAEG;IACH,OAAO,CAAC,YAAY;IAuCpB;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAU3B;;OAEG;IACH,OAAO,CAAC,QAAQ;IAehB;;OAEG;IACH,OAAO,CAAC,WAAW;IAQnB;;OAEG;YACW,iBAAiB;IAyB/B;;OAEG;YACW,iBAAiB;IA4G/B;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAQxB;;OAEG;IAEG,KAAK,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IA+CrC;;OAEG;IAEG,WAAW;IASjB;;OAEG;IAEG,MAAM;IAqBZ;;OAEG;IAEU,IAAI,IAAI,OAAO,CAAC,OAAO,CAAC;IA0BrC;;OAEG;IACH,OAAO,CAAC,OAAO;IAWf;;OAEG;IACI,OAAO;CAIf"}
|
package/output/signin/service.js
CHANGED
|
@@ -445,16 +445,16 @@ let SigninService = (() => {
|
|
|
445
445
|
dialogStatus: this.dialogStatus,
|
|
446
446
|
errorMessage: this.errorMessage
|
|
447
447
|
}), () => {
|
|
448
|
-
//
|
|
449
|
-
if (this.ticket || this.dialogStatus
|
|
448
|
+
// 只在需要恢复的状态时保存(等待或打开中且有有效票据)
|
|
449
|
+
if (this.ticket && (this.dialogStatus === 'waiting' || this.dialogStatus === 'opening')) {
|
|
450
450
|
this.saveState();
|
|
451
451
|
}
|
|
452
|
+
else {
|
|
453
|
+
this.clearPersistedState();
|
|
454
|
+
}
|
|
452
455
|
}, { delay: 100 }));
|
|
453
456
|
// 尝试恢复持久化状态
|
|
454
|
-
|
|
455
|
-
if (restored) {
|
|
456
|
-
console.log('Signin state restored from localStorage');
|
|
457
|
-
}
|
|
457
|
+
this.restoreState();
|
|
458
458
|
return true;
|
|
459
459
|
}
|
|
460
460
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest';
|
|
2
|
-
import { SigninService } from './service';
|
|
2
|
+
import { SigninService } from './service.js';
|
|
3
3
|
// Mock localStorage
|
|
4
4
|
const localStorageMock = (() => {
|
|
5
5
|
let store = {};
|
|
@@ -150,8 +150,10 @@ describe('SigninService', () => {
|
|
|
150
150
|
await service.start();
|
|
151
151
|
// 等待状态保存
|
|
152
152
|
await new Promise(resolve => setTimeout(resolve, 150));
|
|
153
|
-
// 模拟页面刷新 -
|
|
153
|
+
// 模拟页面刷新 - 保存 localStorage(浏览器刷新时不会调用 dispose,但会保留 localStorage)
|
|
154
|
+
const savedData = localStorageMock.getItem('__signin_service_state__');
|
|
154
155
|
service.dispose();
|
|
156
|
+
localStorageMock.setItem('__signin_service_state__', savedData);
|
|
155
157
|
// 创建新服务实例(模拟页面重新加载)
|
|
156
158
|
const newService = new SigninService(mockApi, {
|
|
157
159
|
pollInterval: 100,
|
|
@@ -173,8 +175,10 @@ describe('SigninService', () => {
|
|
|
173
175
|
// 等待状态保存
|
|
174
176
|
await new Promise(resolve => setTimeout(resolve, 150));
|
|
175
177
|
expect(service.isDialogOpen).toBe(true);
|
|
176
|
-
// 模拟页面刷新
|
|
178
|
+
// 模拟页面刷新 - 保存 localStorage(浏览器刷新时不会调用 dispose,但会保留 localStorage)
|
|
179
|
+
const savedData = localStorageMock.getItem('__signin_service_state__');
|
|
177
180
|
service.dispose();
|
|
181
|
+
localStorageMock.setItem('__signin_service_state__', savedData);
|
|
178
182
|
// 创建新服务实例
|
|
179
183
|
const newService = new SigninService(mockApi);
|
|
180
184
|
await newService.init();
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { SizeProvider } from './size-provider';
|
|
1
|
+
export { SizeProvider } from './size-provider.js';
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/size-provider/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/size-provider/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { SizeProvider } from './size-provider';
|
|
1
|
+
export { SizeProvider } from './size-provider.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"size-provider.d.ts","sourceRoot":"","sources":["../../source/size-provider/size-provider.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAA+B,SAAS,EAAE,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"size-provider.d.ts","sourceRoot":"","sources":["../../source/size-provider/size-provider.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAA+B,KAAK,SAAS,EAAE,MAAM,OAAO,CAAA;AAE1E,UAAU,iBAAiB;IACzB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,SAAS,CAAA;IACrD,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,SAAS,CAAA;CACxD;AAED,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CAuCpD,CAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import clsx from 'clsx';
|
|
3
|
-
import { useRef, useState, useEffect } from 'react';
|
|
3
|
+
import React, { useRef, useState, useEffect } from 'react';
|
|
4
4
|
export const SizeProvider = (props) => {
|
|
5
5
|
const { children, className } = props;
|
|
6
6
|
const [width, setWidth] = useState(0);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/toaster/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA4B,MAAM,OAAO,CAAA;AAIhD,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/toaster/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA4B,MAAM,OAAO,CAAA;AAIhD,UAAU,iBAAiB;IACzB,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;IACzB,QAAQ,EAAE,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAA;CAC1C;AAED,+BAA+B;AAC/B,wBAAgB,OAAO,CAAC,KAAK,EAAE,iBAAiB,2CAkE/C;yBAlEe,OAAO;wBA2EE,KAAK,CAAC,SAAS;yBAId,KAAK,CAAC,SAAS;2BAIb,KAAK,CAAC,SAAS;2BAIf,KAAK,CAAC,SAAS"}
|
package/output/toaster/index.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useEffect, useRef } from 'react';
|
|
3
|
-
import {
|
|
2
|
+
import React, { useEffect, useRef } from 'react';
|
|
3
|
+
import { toast, Toaster as SonnerToaster } from 'sonner';
|
|
4
4
|
import { SystemError, UserError } from '@taicode/common-base';
|
|
5
|
-
import 'react-toastify/dist/ReactToastify.css';
|
|
6
5
|
/** 自动捕获和处理异步错误,无法识别的错误会保持原样 */
|
|
7
6
|
export function Toaster(props) {
|
|
8
7
|
const addEventListened = useRef(false);
|
|
@@ -55,17 +54,17 @@ export function Toaster(props) {
|
|
|
55
54
|
handledErrors.current = new WeakSet();
|
|
56
55
|
};
|
|
57
56
|
}, []);
|
|
58
|
-
return (_jsxs(_Fragment, { children: [props.children, _jsx(
|
|
57
|
+
return (_jsxs(_Fragment, { children: [props.children, _jsx(SonnerToaster, { position: "top-center", closeButton: true })] }));
|
|
59
58
|
}
|
|
60
59
|
Toaster.info = (content) => {
|
|
61
|
-
|
|
60
|
+
toast.info(content);
|
|
62
61
|
};
|
|
63
62
|
Toaster.error = (content) => {
|
|
64
|
-
|
|
63
|
+
toast.error(content);
|
|
65
64
|
};
|
|
66
65
|
Toaster.success = (content) => {
|
|
67
|
-
|
|
66
|
+
toast.success(content);
|
|
68
67
|
};
|
|
69
68
|
Toaster.warning = (content) => {
|
|
70
|
-
|
|
69
|
+
toast.warning(content);
|
|
71
70
|
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { useObserver } from './use-observer';
|
|
1
|
+
export { useObserver } from './use-observer.js';
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/use-observer/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/use-observer/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { useObserver } from './use-observer';
|
|
1
|
+
export { useObserver } from './use-observer.js';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { reaction } from 'mobx';
|
|
2
|
-
import
|
|
2
|
+
import { useState, useEffect } from 'react';
|
|
3
3
|
export function useObserver(initialValue, selector) {
|
|
4
4
|
const [, refresh] = useState({});
|
|
5
|
-
|
|
5
|
+
useEffect(() => {
|
|
6
6
|
if (initialValue == null)
|
|
7
7
|
return;
|
|
8
8
|
if (selector == null)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { describe, it, expect } from 'vitest';
|
|
1
|
+
import { describe, it, expect, vi } from 'vitest';
|
|
2
2
|
import { renderHook, act } from '@testing-library/react';
|
|
3
3
|
import { observable, action } from 'mobx';
|
|
4
|
-
import { useObserver } from './use-observer';
|
|
4
|
+
import { useObserver } from './use-observer.js';
|
|
5
5
|
describe('useObserver', () => {
|
|
6
6
|
it('应该返回初始值当没有selector时', () => {
|
|
7
7
|
const initialValue = '初始值';
|
package/package.json
CHANGED
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@taicode/common-web",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.1.0",
|
|
4
4
|
"author": "Alain",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"description": "",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"engines": {
|
|
9
|
+
"node": ">=16.0.0"
|
|
10
|
+
},
|
|
7
11
|
"exports": {
|
|
8
12
|
"./*": {
|
|
9
13
|
"types": "./output/*/index.d.ts",
|
|
10
|
-
"
|
|
11
|
-
"require": "./output/*/index.js"
|
|
14
|
+
"default": "./output/*/index.js"
|
|
12
15
|
},
|
|
13
16
|
"./catalyst/*": {
|
|
14
17
|
"types": "./output/catalyst/*.d.ts",
|
|
15
|
-
"
|
|
16
|
-
"require": "./output/catalyst/*.js"
|
|
18
|
+
"default": "./output/catalyst/*.js"
|
|
17
19
|
}
|
|
18
20
|
},
|
|
19
21
|
"files": [
|
|
@@ -28,31 +30,37 @@
|
|
|
28
30
|
"dev": "tsc -p tsconfig.json --watch"
|
|
29
31
|
},
|
|
30
32
|
"peerDependencies": {
|
|
31
|
-
"@taicode/common-base": ">=1.1.0",
|
|
32
|
-
"@needle-di/core": ">=1.0.0",
|
|
33
33
|
"@heroicons/react": "^2.2.0",
|
|
34
|
-
"
|
|
34
|
+
"@needle-di/core": ">=1.0.0",
|
|
35
|
+
"@taicode/common-base": "^3.1.0",
|
|
35
36
|
"@types/react": ">=18",
|
|
36
37
|
"mobx": ">=6",
|
|
38
|
+
"mobx-react-lite": "^4.1.1",
|
|
37
39
|
"react": ">=18"
|
|
38
40
|
},
|
|
39
41
|
"dependencies": {
|
|
40
|
-
"react-toastify": "^11.0.5",
|
|
41
|
-
"@heroicons/react": "^2.2.0",
|
|
42
42
|
"@headlessui/react": "^2.2.4",
|
|
43
|
+
"@heroicons/react": "^2.2.0",
|
|
44
|
+
"@radix-ui/react-dialog": "^1.1.15",
|
|
45
|
+
"@radix-ui/react-slot": "^1.2.4",
|
|
46
|
+
"class-variance-authority": "^0.7.1",
|
|
47
|
+
"clsx": "^2.1.1",
|
|
43
48
|
"framer-motion": "^12.19.2",
|
|
44
|
-
"
|
|
49
|
+
"sonner": "^1.7.1",
|
|
50
|
+
"tailwind-merge": "^3.4.0"
|
|
45
51
|
},
|
|
46
52
|
"devDependencies": {
|
|
47
|
-
"@
|
|
53
|
+
"@needle-di/core": "^1.0.0",
|
|
48
54
|
"@testing-library/jest-dom": "^6.1.0",
|
|
49
|
-
"
|
|
50
|
-
"vitest": "^1.0.0",
|
|
51
|
-
"@vitest/ui": "^1.0.0",
|
|
55
|
+
"@testing-library/react": "^14.0.0",
|
|
52
56
|
"@types/react": "^18.0.0",
|
|
53
|
-
"@
|
|
54
|
-
"
|
|
57
|
+
"@vitest/ui": "^1.0.0",
|
|
58
|
+
"execa": "^8.0.1",
|
|
59
|
+
"jsdom": "^23.0.0",
|
|
55
60
|
"mobx": "^6.0.0",
|
|
56
|
-
"react": "^
|
|
61
|
+
"mobx-react-lite": "^4.1.1",
|
|
62
|
+
"react": "^18.0.0",
|
|
63
|
+
"type-detect": "^4.1.0",
|
|
64
|
+
"vitest": "^1.0.0"
|
|
57
65
|
}
|
|
58
66
|
}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
-
var t = {};
|
|
3
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
-
t[p] = s[p];
|
|
5
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
-
t[p[i]] = s[p[i]];
|
|
9
|
-
}
|
|
10
|
-
return t;
|
|
11
|
-
};
|
|
12
|
-
import * as Headless from '@headlessui/react';
|
|
13
|
-
import clsx from 'clsx';
|
|
14
|
-
import { Text } from './text';
|
|
15
|
-
const sizes = {
|
|
16
|
-
xs: 'sm:max-w-xs',
|
|
17
|
-
sm: 'sm:max-w-sm',
|
|
18
|
-
md: 'sm:max-w-md',
|
|
19
|
-
lg: 'sm:max-w-lg',
|
|
20
|
-
xl: 'sm:max-w-xl',
|
|
21
|
-
'2xl': 'sm:max-w-2xl',
|
|
22
|
-
'3xl': 'sm:max-w-3xl',
|
|
23
|
-
'4xl': 'sm:max-w-4xl',
|
|
24
|
-
'5xl': 'sm:max-w-5xl',
|
|
25
|
-
};
|
|
26
|
-
export function Alert(_a) {
|
|
27
|
-
var { size = 'md', className, children } = _a, props = __rest(_a, ["size", "className", "children"]);
|
|
28
|
-
return (<Headless.Dialog {...props}>
|
|
29
|
-
<Headless.DialogBackdrop transition className="fixed inset-0 flex w-screen justify-center overflow-y-auto bg-zinc-950/15 px-2 py-2 transition duration-100 focus:outline-0 data-closed:opacity-0 data-enter:ease-out data-leave:ease-in sm:px-6 sm:py-8 lg:px-8 lg:py-16 dark:bg-zinc-950/50"/>
|
|
30
|
-
|
|
31
|
-
<div className="fixed inset-0 w-screen overflow-y-auto pt-6 sm:pt-0">
|
|
32
|
-
<div className="grid min-h-full grid-rows-[1fr_auto_1fr] justify-items-center p-8 sm:grid-rows-[1fr_auto_3fr] sm:p-4">
|
|
33
|
-
<Headless.DialogPanel transition className={clsx(className, sizes[size], 'row-start-2 w-full rounded-2xl bg-white p-8 shadow-lg ring-1 ring-zinc-950/10 sm:rounded-2xl sm:p-6 dark:bg-zinc-900 dark:ring-white/10 forced-colors:outline', 'transition duration-100 will-change-transform data-closed:opacity-0 data-enter:ease-out data-closed:data-enter:scale-95 data-leave:ease-in')}>
|
|
34
|
-
{children}
|
|
35
|
-
</Headless.DialogPanel>
|
|
36
|
-
</div>
|
|
37
|
-
</div>
|
|
38
|
-
</Headless.Dialog>);
|
|
39
|
-
}
|
|
40
|
-
export function AlertTitle(_a) {
|
|
41
|
-
var { className } = _a, props = __rest(_a, ["className"]);
|
|
42
|
-
return (<Headless.DialogTitle {...props} className={clsx(className, 'text-center text-base/6 font-semibold text-balance text-zinc-950 sm:text-left sm:text-sm/6 sm:text-wrap dark:text-white')}/>);
|
|
43
|
-
}
|
|
44
|
-
export function AlertDescription(_a) {
|
|
45
|
-
var { className } = _a, props = __rest(_a, ["className"]);
|
|
46
|
-
return (<Headless.Description as={Text} {...props} className={clsx(className, 'mt-2 text-center text-pretty sm:text-left')}/>);
|
|
47
|
-
}
|
|
48
|
-
export function AlertBody(_a) {
|
|
49
|
-
var { className } = _a, props = __rest(_a, ["className"]);
|
|
50
|
-
return <div {...props} className={clsx(className, 'mt-4')}/>;
|
|
51
|
-
}
|
|
52
|
-
export function AlertActions(_a) {
|
|
53
|
-
var { className } = _a, props = __rest(_a, ["className"]);
|
|
54
|
-
return (<div {...props} className={clsx(className, 'mt-6 flex flex-col-reverse items-center justify-end gap-3 *:w-full sm:mt-4 sm:flex-row sm:*:w-auto')}/>);
|
|
55
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export function AuthLayout({ children }) {
|
|
2
|
-
return (<main className="flex min-h-dvh flex-col p-2">
|
|
3
|
-
<div className="flex grow items-center justify-center p-6 lg:rounded-lg lg:bg-white lg:p-10 lg:shadow-xs lg:ring-1 lg:ring-zinc-950/5 dark:lg:bg-zinc-900 dark:lg:ring-white/10">
|
|
4
|
-
{children}
|
|
5
|
-
</div>
|
|
6
|
-
</main>);
|
|
7
|
-
}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
-
var t = {};
|
|
3
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
-
t[p] = s[p];
|
|
5
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
-
t[p[i]] = s[p[i]];
|
|
9
|
-
}
|
|
10
|
-
return t;
|
|
11
|
-
};
|
|
12
|
-
import * as Headless from '@headlessui/react';
|
|
13
|
-
import clsx from 'clsx';
|
|
14
|
-
import React, { forwardRef } from 'react';
|
|
15
|
-
import { TouchTarget } from './button';
|
|
16
|
-
import { Link } from './link';
|
|
17
|
-
export function Avatar(_a) {
|
|
18
|
-
var { src = null, square = false, initials, alt = '', className } = _a, props = __rest(_a, ["src", "square", "initials", "alt", "className"]);
|
|
19
|
-
return (<span data-slot="avatar" {...props} className={clsx(className,
|
|
20
|
-
// Basic layout
|
|
21
|
-
'inline-grid shrink-0 align-middle [--avatar-radius:20%] *:col-start-1 *:row-start-1', 'outline -outline-offset-1 outline-black/10 dark:outline-white/10',
|
|
22
|
-
// Border radius
|
|
23
|
-
square ? 'rounded-(--avatar-radius) *:rounded-(--avatar-radius)' : 'rounded-full *:rounded-full')}>
|
|
24
|
-
{initials && (<svg className="size-full fill-current p-[5%] text-[48px] font-medium uppercase select-none" viewBox="0 0 100 100" aria-hidden={alt ? undefined : 'true'}>
|
|
25
|
-
{alt && <title>{alt}</title>}
|
|
26
|
-
<text x="50%" y="50%" alignmentBaseline="middle" dominantBaseline="middle" textAnchor="middle" dy=".125em">
|
|
27
|
-
{initials}
|
|
28
|
-
</text>
|
|
29
|
-
</svg>)}
|
|
30
|
-
{src && <img className="size-full" src={src} alt={alt}/>}
|
|
31
|
-
</span>);
|
|
32
|
-
}
|
|
33
|
-
export const AvatarButton = forwardRef(function AvatarButton(_a, ref) {
|
|
34
|
-
var { src, square = false, initials, alt, className } = _a, props = __rest(_a, ["src", "square", "initials", "alt", "className"]);
|
|
35
|
-
let classes = clsx(className, square ? 'rounded-[20%]' : 'rounded-full', 'relative inline-grid focus:not-data-focus:outline-hidden data-focus:outline-2 data-focus:outline-offset-2 data-focus:outline-blue-500');
|
|
36
|
-
return 'href' in props ? (<Link {...props} className={classes} ref={ref}>
|
|
37
|
-
<TouchTarget>
|
|
38
|
-
<Avatar src={src} square={square} initials={initials} alt={alt}/>
|
|
39
|
-
</TouchTarget>
|
|
40
|
-
</Link>) : (<Headless.Button {...props} className={classes} ref={ref}>
|
|
41
|
-
<TouchTarget>
|
|
42
|
-
<Avatar src={src} square={square} initials={initials} alt={alt}/>
|
|
43
|
-
</TouchTarget>
|
|
44
|
-
</Headless.Button>);
|
|
45
|
-
});
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
-
var t = {};
|
|
3
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
-
t[p] = s[p];
|
|
5
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
-
t[p[i]] = s[p[i]];
|
|
9
|
-
}
|
|
10
|
-
return t;
|
|
11
|
-
};
|
|
12
|
-
import * as Headless from '@headlessui/react';
|
|
13
|
-
import clsx from 'clsx';
|
|
14
|
-
import React, { forwardRef } from 'react';
|
|
15
|
-
import { TouchTarget } from './button';
|
|
16
|
-
import { Link } from './link';
|
|
17
|
-
const colors = {
|
|
18
|
-
red: 'bg-red-500/15 text-red-700 group-data-hover:bg-red-500/25 dark:bg-red-500/10 dark:text-red-400 dark:group-data-hover:bg-red-500/20',
|
|
19
|
-
orange: 'bg-orange-500/15 text-orange-700 group-data-hover:bg-orange-500/25 dark:bg-orange-500/10 dark:text-orange-400 dark:group-data-hover:bg-orange-500/20',
|
|
20
|
-
amber: 'bg-amber-400/20 text-amber-700 group-data-hover:bg-amber-400/30 dark:bg-amber-400/10 dark:text-amber-400 dark:group-data-hover:bg-amber-400/15',
|
|
21
|
-
yellow: 'bg-yellow-400/20 text-yellow-700 group-data-hover:bg-yellow-400/30 dark:bg-yellow-400/10 dark:text-yellow-300 dark:group-data-hover:bg-yellow-400/15',
|
|
22
|
-
lime: 'bg-lime-400/20 text-lime-700 group-data-hover:bg-lime-400/30 dark:bg-lime-400/10 dark:text-lime-300 dark:group-data-hover:bg-lime-400/15',
|
|
23
|
-
green: 'bg-green-500/15 text-green-700 group-data-hover:bg-green-500/25 dark:bg-green-500/10 dark:text-green-400 dark:group-data-hover:bg-green-500/20',
|
|
24
|
-
emerald: 'bg-emerald-500/15 text-emerald-700 group-data-hover:bg-emerald-500/25 dark:bg-emerald-500/10 dark:text-emerald-400 dark:group-data-hover:bg-emerald-500/20',
|
|
25
|
-
teal: 'bg-teal-500/15 text-teal-700 group-data-hover:bg-teal-500/25 dark:bg-teal-500/10 dark:text-teal-300 dark:group-data-hover:bg-teal-500/20',
|
|
26
|
-
cyan: 'bg-cyan-400/20 text-cyan-700 group-data-hover:bg-cyan-400/30 dark:bg-cyan-400/10 dark:text-cyan-300 dark:group-data-hover:bg-cyan-400/15',
|
|
27
|
-
sky: 'bg-sky-500/15 text-sky-700 group-data-hover:bg-sky-500/25 dark:bg-sky-500/10 dark:text-sky-300 dark:group-data-hover:bg-sky-500/20',
|
|
28
|
-
blue: 'bg-blue-500/15 text-blue-700 group-data-hover:bg-blue-500/25 dark:text-blue-400 dark:group-data-hover:bg-blue-500/25',
|
|
29
|
-
indigo: 'bg-indigo-500/15 text-indigo-700 group-data-hover:bg-indigo-500/25 dark:text-indigo-400 dark:group-data-hover:bg-indigo-500/20',
|
|
30
|
-
violet: 'bg-violet-500/15 text-violet-700 group-data-hover:bg-violet-500/25 dark:text-violet-400 dark:group-data-hover:bg-violet-500/20',
|
|
31
|
-
purple: 'bg-purple-500/15 text-purple-700 group-data-hover:bg-purple-500/25 dark:text-purple-400 dark:group-data-hover:bg-purple-500/20',
|
|
32
|
-
fuchsia: 'bg-fuchsia-400/15 text-fuchsia-700 group-data-hover:bg-fuchsia-400/25 dark:bg-fuchsia-400/10 dark:text-fuchsia-400 dark:group-data-hover:bg-fuchsia-400/20',
|
|
33
|
-
pink: 'bg-pink-400/15 text-pink-700 group-data-hover:bg-pink-400/25 dark:bg-pink-400/10 dark:text-pink-400 dark:group-data-hover:bg-pink-400/20',
|
|
34
|
-
rose: 'bg-rose-400/15 text-rose-700 group-data-hover:bg-rose-400/25 dark:bg-rose-400/10 dark:text-rose-400 dark:group-data-hover:bg-rose-400/20',
|
|
35
|
-
zinc: 'bg-zinc-600/10 text-zinc-700 group-data-hover:bg-zinc-600/20 dark:bg-white/5 dark:text-zinc-400 dark:group-data-hover:bg-white/10',
|
|
36
|
-
};
|
|
37
|
-
export function Badge(_a) {
|
|
38
|
-
var { color = 'zinc', className } = _a, props = __rest(_a, ["color", "className"]);
|
|
39
|
-
return (<span {...props} className={clsx(className, 'inline-flex items-center gap-x-1.5 rounded-md px-1.5 py-0.5 text-sm/5 font-medium sm:text-xs/5 forced-colors:outline', colors[color])}/>);
|
|
40
|
-
}
|
|
41
|
-
export const BadgeButton = forwardRef(function BadgeButton(_a, ref) {
|
|
42
|
-
var { color = 'zinc', className, children } = _a, props = __rest(_a, ["color", "className", "children"]);
|
|
43
|
-
let classes = clsx(className, 'group relative inline-flex rounded-md focus:not-data-focus:outline-hidden data-focus:outline-2 data-focus:outline-offset-2 data-focus:outline-blue-500');
|
|
44
|
-
return 'href' in props ? (<Link {...props} className={classes} ref={ref}>
|
|
45
|
-
<TouchTarget>
|
|
46
|
-
<Badge color={color}>{children}</Badge>
|
|
47
|
-
</TouchTarget>
|
|
48
|
-
</Link>) : (<Headless.Button {...props} className={classes} ref={ref}>
|
|
49
|
-
<TouchTarget>
|
|
50
|
-
<Badge color={color}>{children}</Badge>
|
|
51
|
-
</TouchTarget>
|
|
52
|
-
</Headless.Button>);
|
|
53
|
-
});
|