@taicode/common-web 3.7.4 → 3.7.7
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/LICENSE +21 -0
- package/package.json +12 -13
- package/styles.css +2 -0
- package/output/components/alert-dialog.d.ts +0 -20
- package/output/components/alert-dialog.d.ts.map +0 -1
- package/output/components/alert-dialog.js +0 -65
- package/output/components/alert.d.ts +0 -11
- package/output/components/alert.d.ts.map +0 -1
- package/output/components/alert.js +0 -38
- package/output/components/avatar.d.ts +0 -13
- package/output/components/avatar.d.ts.map +0 -1
- package/output/components/avatar.js +0 -40
- package/output/components/badge.d.ts +0 -11
- package/output/components/badge.d.ts.map +0 -1
- package/output/components/badge.js +0 -39
- package/output/components/button.d.ts +0 -12
- package/output/components/button.d.ts.map +0 -1
- package/output/components/button.js +0 -48
- package/output/components/calendar.d.ts +0 -13
- package/output/components/calendar.d.ts.map +0 -1
- package/output/components/calendar.js +0 -57
- package/output/components/card.d.ts +0 -13
- package/output/components/card.d.ts.map +0 -1
- package/output/components/card.js +0 -43
- package/output/components/chart.d.ts +0 -56
- package/output/components/chart.d.ts.map +0 -1
- package/output/components/chart.js +0 -127
- package/output/components/checkbox.d.ts +0 -5
- package/output/components/checkbox.d.ts.map +0 -1
- package/output/components/checkbox.js +0 -21
- package/output/components/command.d.ts +0 -20
- package/output/components/command.d.ts.map +0 -1
- package/output/components/command.js +0 -55
- package/output/components/dialog.d.ts +0 -20
- package/output/components/dialog.d.ts.map +0 -1
- package/output/components/dialog.js +0 -58
- package/output/components/direction.d.ts +0 -9
- package/output/components/direction.d.ts.map +0 -1
- package/output/components/direction.js +0 -10
- package/output/components/drawer.d.ts +0 -14
- package/output/components/drawer.d.ts.map +0 -1
- package/output/components/drawer.js +0 -56
- package/output/components/dropdown-menu.d.ts +0 -29
- package/output/components/dropdown-menu.d.ts.map +0 -1
- package/output/components/dropdown-menu.js +0 -78
- package/output/components/field.d.ts +0 -39
- package/output/components/field.d.ts.map +0 -1
- package/output/components/field.js +0 -102
- package/output/components/footer/index.d.ts +0 -27
- package/output/components/footer/index.d.ts.map +0 -1
- package/output/components/footer/index.js +0 -17
- package/output/components/form.d.ts +0 -26
- package/output/components/form.d.ts.map +0 -1
- package/output/components/form.js +0 -69
- package/output/components/index.d.ts +0 -46
- package/output/components/index.d.ts.map +0 -1
- package/output/components/index.js +0 -45
- package/output/components/input-group.d.ts +0 -17
- package/output/components/input-group.d.ts.map +0 -1
- package/output/components/input-group.js +0 -75
- package/output/components/input.d.ts +0 -4
- package/output/components/input.d.ts.map +0 -1
- package/output/components/input.js +0 -19
- package/output/components/item.d.ts +0 -25
- package/output/components/item.d.ts.map +0 -1
- package/output/components/item.js +0 -89
- package/output/components/json-view/index.d.ts +0 -11
- package/output/components/json-view/index.d.ts.map +0 -1
- package/output/components/json-view/index.js +0 -52
- package/output/components/json-view/lazy/index.d.ts +0 -18
- package/output/components/json-view/lazy/index.d.ts.map +0 -1
- package/output/components/json-view/lazy/index.js +0 -22
- package/output/components/kbd.d.ts +0 -4
- package/output/components/kbd.d.ts.map +0 -1
- package/output/components/kbd.js +0 -22
- package/output/components/label.d.ts +0 -5
- package/output/components/label.d.ts.map +0 -1
- package/output/components/label.js +0 -20
- package/output/components/list-actions/index.d.ts +0 -23
- package/output/components/list-actions/index.d.ts.map +0 -1
- package/output/components/list-actions/index.js +0 -15
- package/output/components/loading-button/index.d.ts +0 -44
- package/output/components/loading-button/index.d.ts.map +0 -1
- package/output/components/loading-button/index.js +0 -75
- package/output/components/loading-button/index.test.d.ts +0 -2
- package/output/components/loading-button/index.test.d.ts.map +0 -1
- package/output/components/loading-button/index.test.js +0 -203
- package/output/components/native-select.d.ts +0 -9
- package/output/components/native-select.d.ts.map +0 -1
- package/output/components/native-select.js +0 -28
- package/output/components/page-back-button/index.d.ts +0 -8
- package/output/components/page-back-button/index.d.ts.map +0 -1
- package/output/components/page-back-button/index.js +0 -7
- package/output/components/page-state.d.ts +0 -19
- package/output/components/page-state.d.ts.map +0 -1
- package/output/components/page-state.js +0 -13
- package/output/components/pagination/index.d.ts +0 -34
- package/output/components/pagination/index.d.ts.map +0 -1
- package/output/components/pagination/index.js +0 -75
- package/output/components/popover.d.ts +0 -11
- package/output/components/popover.d.ts.map +0 -1
- package/output/components/popover.js +0 -44
- package/output/components/progress.d.ts +0 -5
- package/output/components/progress.d.ts.map +0 -1
- package/output/components/progress.js +0 -21
- package/output/components/radio-group.d.ts +0 -6
- package/output/components/radio-group.d.ts.map +0 -1
- package/output/components/radio-group.js +0 -25
- package/output/components/route-pending-indicator/index.d.ts +0 -20
- package/output/components/route-pending-indicator/index.d.ts.map +0 -1
- package/output/components/route-pending-indicator/index.js +0 -17
- package/output/components/scroll-area.d.ts +0 -6
- package/output/components/scroll-area.d.ts.map +0 -1
- package/output/components/scroll-area.js +0 -24
- package/output/components/searchable-select/index.d.ts +0 -41
- package/output/components/searchable-select/index.d.ts.map +0 -1
- package/output/components/searchable-select/index.js +0 -46
- package/output/components/select.d.ts +0 -17
- package/output/components/select.d.ts.map +0 -1
- package/output/components/select.js +0 -58
- package/output/components/separator.d.ts +0 -5
- package/output/components/separator.d.ts.map +0 -1
- package/output/components/separator.js +0 -20
- package/output/components/sheet.d.ts +0 -16
- package/output/components/sheet.d.ts.map +0 -1
- package/output/components/sheet.js +0 -58
- package/output/components/sidebar.d.ts +0 -78
- package/output/components/sidebar.d.ts.map +0 -1
- package/output/components/sidebar.js +0 -233
- package/output/components/size-provider/index.d.ts +0 -2
- package/output/components/size-provider/index.d.ts.map +0 -1
- package/output/components/size-provider/index.js +0 -1
- package/output/components/size-provider/size-provider.d.ts +0 -9
- package/output/components/size-provider/size-provider.d.ts.map +0 -1
- package/output/components/size-provider/size-provider.js +0 -29
- package/output/components/skeleton.d.ts +0 -3
- package/output/components/skeleton.d.ts.map +0 -1
- package/output/components/skeleton.js +0 -18
- package/output/components/sonner.d.ts +0 -8
- package/output/components/sonner.d.ts.map +0 -1
- package/output/components/sonner.js +0 -34
- package/output/components/spinner.d.ts +0 -3
- package/output/components/spinner.d.ts.map +0 -1
- package/output/components/spinner.js +0 -19
- package/output/components/switch.d.ts +0 -8
- package/output/components/switch.d.ts.map +0 -1
- package/output/components/switch.js +0 -20
- package/output/components/table.d.ts +0 -11
- package/output/components/table.d.ts.map +0 -1
- package/output/components/table.js +0 -47
- package/output/components/tabs.d.ts +0 -12
- package/output/components/tabs.d.ts.map +0 -1
- package/output/components/tabs.js +0 -45
- package/output/components/textarea.d.ts +0 -4
- package/output/components/textarea.d.ts.map +0 -1
- package/output/components/textarea.js +0 -19
- package/output/components/theme-switcher.d.ts +0 -6
- package/output/components/theme-switcher.d.ts.map +0 -1
- package/output/components/theme-switcher.js +0 -19
- package/output/components/toaster/index.d.ts +0 -16
- package/output/components/toaster/index.d.ts.map +0 -1
- package/output/components/toaster/index.js +0 -70
- package/output/components/toggle-group.d.ts +0 -12
- package/output/components/toggle-group.d.ts.map +0 -1
- package/output/components/toggle-group.js +0 -38
- package/output/components/toggle.d.ts +0 -10
- package/output/components/toggle.d.ts.map +0 -1
- package/output/components/toggle.js +0 -38
- package/output/components/tooltip.d.ts +0 -8
- package/output/components/tooltip.d.ts.map +0 -1
- package/output/components/tooltip.js +0 -33
- package/output/features/confirm-dialog/index.d.ts +0 -41
- package/output/features/confirm-dialog/index.d.ts.map +0 -1
- package/output/features/confirm-dialog/index.js +0 -19
- package/output/features/input-confirm/index.d.ts +0 -26
- package/output/features/input-confirm/index.d.ts.map +0 -1
- package/output/features/input-confirm/index.js +0 -59
- package/output/features/signin/context.d.ts +0 -14
- package/output/features/signin/context.d.ts.map +0 -1
- package/output/features/signin/context.js +0 -13
- package/output/features/signin/index.d.ts +0 -58
- package/output/features/signin/index.d.ts.map +0 -1
- package/output/features/signin/index.js +0 -137
- package/output/features/signin/service.d.ts +0 -92
- package/output/features/signin/service.d.ts.map +0 -1
- package/output/features/signin/service.js +0 -519
- package/output/features/signin/service.test.d.ts +0 -2
- package/output/features/signin/service.test.d.ts.map +0 -1
- package/output/features/signin/service.test.js +0 -211
- package/output/features/signin/types.d.ts +0 -63
- package/output/features/signin/types.d.ts.map +0 -1
- package/output/features/signin/types.js +0 -1
- package/output/hooks/use-loading/index.d.ts +0 -6
- package/output/hooks/use-loading/index.d.ts.map +0 -1
- package/output/hooks/use-loading/index.js +0 -14
- package/output/hooks/use-loading/index.test.d.ts +0 -2
- package/output/hooks/use-loading/index.test.d.ts.map +0 -1
- package/output/hooks/use-loading/index.test.js +0 -24
- package/output/hooks/use-mobile/index.d.ts +0 -2
- package/output/hooks/use-mobile/index.d.ts.map +0 -1
- package/output/hooks/use-mobile/index.js +0 -16
- package/output/hooks/use-observer/index.d.ts +0 -2
- package/output/hooks/use-observer/index.d.ts.map +0 -1
- package/output/hooks/use-observer/index.js +0 -1
- package/output/hooks/use-observer/use-observer.d.ts +0 -3
- package/output/hooks/use-observer/use-observer.d.ts.map +0 -1
- package/output/hooks/use-observer/use-observer.js +0 -16
- package/output/hooks/use-observer/use-observer.test.d.ts +0 -2
- package/output/hooks/use-observer/use-observer.test.d.ts.map +0 -1
- package/output/hooks/use-observer/use-observer.test.js +0 -134
- package/output/hooks/use-offline/index.d.ts +0 -6
- package/output/hooks/use-offline/index.d.ts.map +0 -1
- package/output/hooks/use-offline/index.js +0 -19
- package/output/layout/app/index.d.ts +0 -34
- package/output/layout/app/index.d.ts.map +0 -1
- package/output/layout/app/index.js +0 -34
- package/output/layout/dashboard/index.d.ts +0 -76
- package/output/layout/dashboard/index.d.ts.map +0 -1
- package/output/layout/dashboard/index.js +0 -84
- package/output/layout/index.d.ts +0 -3
- package/output/layout/index.d.ts.map +0 -1
- package/output/layout/index.js +0 -2
- package/output/services/cache-api/cache-api.d.ts +0 -23
- package/output/services/cache-api/cache-api.d.ts.map +0 -1
- package/output/services/cache-api/cache-api.js +0 -145
- package/output/services/cache-api/cache-api.test.d.ts +0 -2
- package/output/services/cache-api/cache-api.test.d.ts.map +0 -1
- package/output/services/cache-api/cache-api.test.js +0 -610
- package/output/services/cache-api/index.d.ts +0 -2
- package/output/services/cache-api/index.d.ts.map +0 -1
- package/output/services/cache-api/index.js +0 -1
- package/output/services/cached-fetch/index.d.ts +0 -50
- package/output/services/cached-fetch/index.d.ts.map +0 -1
- package/output/services/cached-fetch/index.js +0 -196
- package/output/services/service/index.d.ts +0 -2
- package/output/services/service/index.d.ts.map +0 -1
- package/output/services/service/index.js +0 -1
- package/output/services/service/service.d.ts +0 -135
- package/output/services/service/service.d.ts.map +0 -1
- package/output/services/service/service.js +0 -276
- package/output/services/service/service.test.d.ts +0 -2
- package/output/services/service/service.test.d.ts.map +0 -1
- package/output/services/service/service.test.js +0 -1399
- package/output/services/side-cache/index.d.ts +0 -2
- package/output/services/side-cache/index.d.ts.map +0 -1
- package/output/services/side-cache/index.js +0 -1
- package/output/services/side-cache/side-cache.d.ts +0 -11
- package/output/services/side-cache/side-cache.d.ts.map +0 -1
- package/output/services/side-cache/side-cache.js +0 -161
- package/output/services/side-cache/side-cache.test.d.ts +0 -2
- package/output/services/side-cache/side-cache.test.d.ts.map +0 -1
- package/output/services/side-cache/side-cache.test.js +0 -271
- package/output/utils/avatar/index.d.ts +0 -28
- package/output/utils/avatar/index.d.ts.map +0 -1
- package/output/utils/avatar/index.js +0 -35
- package/output/utils/delay/index.d.ts +0 -2
- package/output/utils/delay/index.d.ts.map +0 -1
- package/output/utils/delay/index.js +0 -5
- package/output/utils/form/index.d.ts +0 -3
- package/output/utils/form/index.d.ts.map +0 -1
- package/output/utils/form/index.js +0 -1
- package/output/utils/merge-class-names/index.d.ts +0 -3
- package/output/utils/merge-class-names/index.d.ts.map +0 -1
- package/output/utils/merge-class-names/index.js +0 -5
- package/output/utils/merge-class-names/index.test.d.ts +0 -2
- package/output/utils/merge-class-names/index.test.d.ts.map +0 -1
- package/output/utils/merge-class-names/index.test.js +0 -7
- package/output/utils/performance/index.d.ts +0 -82
- package/output/utils/performance/index.d.ts.map +0 -1
- package/output/utils/performance/index.js +0 -129
- package/output/utils/redirect/index.d.ts +0 -6
- package/output/utils/redirect/index.d.ts.map +0 -1
- package/output/utils/redirect/index.js +0 -32
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"theme-switcher.d.ts","sourceRoot":"","sources":["../../source/components/theme-switcher.tsx"],"names":[],"mappings":"AAOA,MAAM,WAAW,kBAAkB;IACjC,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,kBAAkB,+BA2BtD"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useEffect, useState } from 'react';
|
|
3
|
-
import { Moon, Sun } from 'lucide-react';
|
|
4
|
-
import { Button } from './button.js';
|
|
5
|
-
export function ThemeSwitcher(props) {
|
|
6
|
-
const { toLightLabel = 'Switch to light mode', toDarkLabel = 'Switch to dark mode' } = props;
|
|
7
|
-
const [theme, setTheme] = useState(() => {
|
|
8
|
-
const savedTheme = localStorage.getItem('theme');
|
|
9
|
-
if (savedTheme === 'dark' || savedTheme === 'light')
|
|
10
|
-
return savedTheme;
|
|
11
|
-
return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
|
|
12
|
-
});
|
|
13
|
-
useEffect(() => {
|
|
14
|
-
document.documentElement.classList.toggle('dark', theme === 'dark');
|
|
15
|
-
localStorage.setItem('theme', theme);
|
|
16
|
-
}, [theme]);
|
|
17
|
-
const label = theme === 'dark' ? toLightLabel : toDarkLabel;
|
|
18
|
-
return (_jsx(Button, { type: "button", variant: "ghost", size: "icon-sm", onClick: () => setTheme(current => current === 'light' ? 'dark' : 'light'), "aria-label": label, title: label, children: theme === 'dark' ? _jsx(Sun, { className: "size-4" }) : _jsx(Moon, { className: "size-4" }) }));
|
|
19
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
interface ToastCatcherProps {
|
|
3
|
-
defaultMessage?: string;
|
|
4
|
-
children: React.ReactNode;
|
|
5
|
-
messages: Partial<Record<string, string>>;
|
|
6
|
-
}
|
|
7
|
-
/** 自动捕获和处理异步错误,无法识别的错误会保持原样 */
|
|
8
|
-
export declare function Toaster(props: ToastCatcherProps): React.JSX.Element;
|
|
9
|
-
export declare namespace Toaster {
|
|
10
|
-
var info: (content: React.ReactNode) => void;
|
|
11
|
-
var error: (content: React.ReactNode) => void;
|
|
12
|
-
var success: (content: React.ReactNode) => void;
|
|
13
|
-
var warning: (content: React.ReactNode) => void;
|
|
14
|
-
}
|
|
15
|
-
export {};
|
|
16
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../source/components/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,qBAkE/C;yBAlEe,OAAO;wBA2EE,KAAK,CAAC,SAAS;yBAId,KAAK,CAAC,SAAS;2BAIb,KAAK,CAAC,SAAS;2BAIf,KAAK,CAAC,SAAS"}
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import React, { useEffect, useRef } from 'react';
|
|
3
|
-
import { toast, Toaster as SonnerToaster } from 'sonner';
|
|
4
|
-
import { SystemError, UserError } from '@taicode/common-base';
|
|
5
|
-
/** 自动捕获和处理异步错误,无法识别的错误会保持原样 */
|
|
6
|
-
export function Toaster(props) {
|
|
7
|
-
const addEventListened = useRef(false);
|
|
8
|
-
const { messages = {}, defaultMessage } = props;
|
|
9
|
-
const handledErrors = useRef(new WeakSet());
|
|
10
|
-
useEffect(() => {
|
|
11
|
-
if (addEventListened.current)
|
|
12
|
-
return;
|
|
13
|
-
const errorHandler = (event) => {
|
|
14
|
-
const errorObject = event.error;
|
|
15
|
-
// 检查是否已经处理过这个错误对象
|
|
16
|
-
if (errorObject && handledErrors.current.has(errorObject)) {
|
|
17
|
-
event.preventDefault();
|
|
18
|
-
event.stopPropagation();
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
if (SystemError.is(errorObject) || UserError.is(errorObject)) {
|
|
22
|
-
console.error('Caught error:', errorObject);
|
|
23
|
-
// 标记此错误已处理
|
|
24
|
-
handledErrors.current.add(errorObject);
|
|
25
|
-
event.preventDefault();
|
|
26
|
-
event.stopPropagation();
|
|
27
|
-
Toaster.error(messages[errorObject.type] || defaultMessage);
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
const unhandledRejectionHandler = (event) => {
|
|
31
|
-
const errorObject = event.reason;
|
|
32
|
-
// 检查是否已经处理过这个错误对象
|
|
33
|
-
if (errorObject && handledErrors.current.has(errorObject)) {
|
|
34
|
-
event.preventDefault();
|
|
35
|
-
event.stopPropagation();
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
if (SystemError.is(errorObject) || UserError.is(errorObject)) {
|
|
39
|
-
console.error('Caught error:', errorObject);
|
|
40
|
-
// 标记此错误已处理
|
|
41
|
-
handledErrors.current.add(errorObject);
|
|
42
|
-
event.preventDefault();
|
|
43
|
-
event.stopPropagation();
|
|
44
|
-
Toaster.error(messages[errorObject.type] || defaultMessage);
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
window.addEventListener('error', errorHandler, true);
|
|
48
|
-
window.addEventListener('unhandledrejection', unhandledRejectionHandler, true);
|
|
49
|
-
addEventListened.current = true;
|
|
50
|
-
return () => {
|
|
51
|
-
window.removeEventListener('error', errorHandler, true);
|
|
52
|
-
window.removeEventListener('unhandledrejection', unhandledRejectionHandler, true);
|
|
53
|
-
addEventListened.current = false;
|
|
54
|
-
handledErrors.current = new WeakSet();
|
|
55
|
-
};
|
|
56
|
-
}, []);
|
|
57
|
-
return (_jsxs(_Fragment, { children: [props.children, _jsx(SonnerToaster, { position: "top-center", closeButton: true })] }));
|
|
58
|
-
}
|
|
59
|
-
Toaster.info = (content) => {
|
|
60
|
-
toast.info(content);
|
|
61
|
-
};
|
|
62
|
-
Toaster.error = (content) => {
|
|
63
|
-
toast.error(content);
|
|
64
|
-
};
|
|
65
|
-
Toaster.success = (content) => {
|
|
66
|
-
toast.success(content);
|
|
67
|
-
};
|
|
68
|
-
Toaster.warning = (content) => {
|
|
69
|
-
toast.warning(content);
|
|
70
|
-
};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { type VariantProps } from 'class-variance-authority';
|
|
3
|
-
import { ToggleGroup as ToggleGroupPrimitive } from 'radix-ui';
|
|
4
|
-
import { toggleVariants } from './toggle.js';
|
|
5
|
-
type ToggleGroupParams = {
|
|
6
|
-
spacing?: number;
|
|
7
|
-
orientation?: 'horizontal' | 'vertical';
|
|
8
|
-
};
|
|
9
|
-
declare function ToggleGroup(params: React.ComponentProps<typeof ToggleGroupPrimitive.Root> & VariantProps<typeof toggleVariants> & ToggleGroupParams): React.JSX.Element;
|
|
10
|
-
declare function ToggleGroupItem(params: React.ComponentProps<typeof ToggleGroupPrimitive.Item> & VariantProps<typeof toggleVariants>): React.JSX.Element;
|
|
11
|
-
export { ToggleGroup, ToggleGroupItem };
|
|
12
|
-
//# sourceMappingURL=toggle-group.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"toggle-group.d.ts","sourceRoot":"","sources":["../../source/components/toggle-group.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAC5D,OAAO,EAAE,WAAW,IAAI,oBAAoB,EAAE,MAAM,UAAU,CAAA;AAG9D,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAE5C,KAAK,iBAAiB,GAAG;IACvB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,WAAW,CAAC,EAAE,YAAY,GAAG,UAAU,CAAA;CACxC,CAAA;AAcD,iBAAS,WAAW,CAClB,MAAM,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,oBAAoB,CAAC,IAAI,CAAC,GAC5D,YAAY,CAAC,OAAO,cAAc,CAAC,GACnC,iBAAiB,qBAsBpB;AAED,iBAAS,eAAe,CACtB,MAAM,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,oBAAoB,CAAC,IAAI,CAAC,GAAG,YAAY,CAAC,OAAO,cAAc,CAAC,qBAwBrG;AAED,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,CAAA"}
|
|
@@ -1,38 +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 { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
-
import * as React from 'react';
|
|
14
|
-
import { useContext } from 'react';
|
|
15
|
-
import {} from 'class-variance-authority';
|
|
16
|
-
import { ToggleGroup as ToggleGroupPrimitive } from 'radix-ui';
|
|
17
|
-
import { mergeClassNames } from '../utils/merge-class-names/index.js';
|
|
18
|
-
import { toggleVariants } from './toggle.js';
|
|
19
|
-
const ToggleGroupContext = React.createContext({
|
|
20
|
-
size: 'default',
|
|
21
|
-
variant: 'default',
|
|
22
|
-
spacing: 0,
|
|
23
|
-
orientation: 'horizontal',
|
|
24
|
-
});
|
|
25
|
-
function ToggleGroup(params) {
|
|
26
|
-
const { className, variant, size, spacing = 0, orientation = 'horizontal', children } = params, props = __rest(params, ["className", "variant", "size", "spacing", "orientation", "children"]);
|
|
27
|
-
return (_jsx(ToggleGroupPrimitive.Root, Object.assign({ "data-slot": "toggle-group", "data-variant": variant, "data-size": size, "data-spacing": spacing, "data-orientation": orientation, style: { '--gap': spacing }, className: mergeClassNames('rounded-md data-[spacing=0]:data-[variant=outline]:shadow-xs group/toggle-group flex w-fit flex-row items-center gap-(--spacing(var(--gap))) data-[orientation=vertical]:flex-col data-[orientation=vertical]:items-stretch', className) }, props, { children: _jsx(ToggleGroupContext.Provider, { value: { variant, size, spacing, orientation }, children: children }) })));
|
|
28
|
-
}
|
|
29
|
-
function ToggleGroupItem(params) {
|
|
30
|
-
var _a, _b, _c, _d;
|
|
31
|
-
const { className, children, variant = 'default', size = 'default' } = params, props = __rest(params, ["className", "children", "variant", "size"]);
|
|
32
|
-
const context = useContext(ToggleGroupContext);
|
|
33
|
-
return (_jsx(ToggleGroupPrimitive.Item, Object.assign({ "data-slot": "toggle-group-item", "data-variant": (_a = context.variant) !== null && _a !== void 0 ? _a : variant, "data-size": (_b = context.size) !== null && _b !== void 0 ? _b : size, "data-spacing": context.spacing, className: mergeClassNames('data-[state=on]:bg-muted group-data-[spacing=0]/toggle-group:rounded-none group-data-[spacing=0]/toggle-group:px-2 group-data-[spacing=0]/toggle-group:shadow-none group-data-horizontal/toggle-group:data-[spacing=0]:first:rounded-l-md group-data-vertical/toggle-group:data-[spacing=0]:first:rounded-t-md group-data-horizontal/toggle-group:data-[spacing=0]:last:rounded-r-md group-data-vertical/toggle-group:data-[spacing=0]:last:rounded-b-md shrink-0 focus:z-10 focus-visible:z-10 group-data-horizontal/toggle-group:data-[spacing=0]:data-[variant=outline]:border-l-0 group-data-vertical/toggle-group:data-[spacing=0]:data-[variant=outline]:border-t-0 group-data-horizontal/toggle-group:data-[spacing=0]:data-[variant=outline]:first:border-l group-data-vertical/toggle-group:data-[spacing=0]:data-[variant=outline]:first:border-t', toggleVariants({
|
|
34
|
-
variant: (_c = context.variant) !== null && _c !== void 0 ? _c : variant,
|
|
35
|
-
size: (_d = context.size) !== null && _d !== void 0 ? _d : size,
|
|
36
|
-
}), className) }, props, { children: children })));
|
|
37
|
-
}
|
|
38
|
-
export { ToggleGroup, ToggleGroupItem };
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { type VariantProps } from 'class-variance-authority';
|
|
3
|
-
import { Toggle as TogglePrimitive } from 'radix-ui';
|
|
4
|
-
declare const toggleVariants: (props?: ({
|
|
5
|
-
variant?: "default" | "outline" | null | undefined;
|
|
6
|
-
size?: "default" | "sm" | "lg" | null | undefined;
|
|
7
|
-
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
8
|
-
declare function Toggle(params: React.ComponentProps<typeof TogglePrimitive.Root> & VariantProps<typeof toggleVariants>): React.JSX.Element;
|
|
9
|
-
export { Toggle, toggleVariants };
|
|
10
|
-
//# sourceMappingURL=toggle.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"toggle.d.ts","sourceRoot":"","sources":["../../source/components/toggle.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAA;AACjE,OAAO,EAAE,MAAM,IAAI,eAAe,EAAE,MAAM,UAAU,CAAA;AAIpD,QAAA,MAAM,cAAc;;;8EAmBnB,CAAA;AAED,iBAAS,MAAM,CACb,MAAM,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,eAAe,CAAC,IAAI,CAAC,GAAG,YAAY,CAAC,OAAO,cAAc,CAAC,qBAUhG;AAED,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,CAAA"}
|
|
@@ -1,38 +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 { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
-
import * as React from 'react';
|
|
14
|
-
import { cva } from 'class-variance-authority';
|
|
15
|
-
import { Toggle as TogglePrimitive } from 'radix-ui';
|
|
16
|
-
import { mergeClassNames } from '../utils/merge-class-names/index.js';
|
|
17
|
-
const toggleVariants = cva("hover:text-foreground aria-pressed:bg-muted focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive gap-1 rounded-md text-sm font-medium transition-[color,box-shadow] [&_svg:not([class*='size-'])]:size-4 group/toggle hover:bg-muted inline-flex items-center justify-center whitespace-nowrap outline-none focus-visible:ring-[3px] disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0", {
|
|
18
|
-
variants: {
|
|
19
|
-
variant: {
|
|
20
|
-
default: 'bg-transparent',
|
|
21
|
-
outline: 'border-input hover:bg-muted border bg-transparent shadow-xs',
|
|
22
|
-
},
|
|
23
|
-
size: {
|
|
24
|
-
default: 'h-9 min-w-9 px-2',
|
|
25
|
-
sm: 'h-8 min-w-8 px-1.5',
|
|
26
|
-
lg: 'h-10 min-w-10 px-2.5',
|
|
27
|
-
},
|
|
28
|
-
},
|
|
29
|
-
defaultVariants: {
|
|
30
|
-
variant: 'default',
|
|
31
|
-
size: 'default',
|
|
32
|
-
},
|
|
33
|
-
});
|
|
34
|
-
function Toggle(params) {
|
|
35
|
-
const { className, variant = 'default', size = 'default' } = params, props = __rest(params, ["className", "variant", "size"]);
|
|
36
|
-
return (_jsx(TogglePrimitive.Root, Object.assign({ "data-slot": "toggle", className: mergeClassNames(toggleVariants({ variant, size, className })) }, props)));
|
|
37
|
-
}
|
|
38
|
-
export { Toggle, toggleVariants };
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import { Tooltip as TooltipPrimitive } from "radix-ui";
|
|
3
|
-
declare function TooltipProvider(params: React.ComponentProps<typeof TooltipPrimitive.Provider>): React.JSX.Element;
|
|
4
|
-
declare function Tooltip(params: React.ComponentProps<typeof TooltipPrimitive.Root>): React.JSX.Element;
|
|
5
|
-
declare function TooltipTrigger(params: React.ComponentProps<typeof TooltipPrimitive.Trigger>): React.JSX.Element;
|
|
6
|
-
declare function TooltipContent(params: React.ComponentProps<typeof TooltipPrimitive.Content>): React.JSX.Element;
|
|
7
|
-
export { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger };
|
|
8
|
-
//# sourceMappingURL=tooltip.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tooltip.d.ts","sourceRoot":"","sources":["../../source/components/tooltip.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,UAAU,CAAA;AAItD,iBAAS,eAAe,CAAC,MAAM,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,gBAAgB,CAAC,QAAQ,CAAC,qBAYtF;AAED,iBAAS,OAAO,CAAC,MAAM,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,gBAAgB,CAAC,IAAI,CAAC,qBAK1E;AAED,iBAAS,cAAc,CAAC,MAAM,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,gBAAgB,CAAC,OAAO,CAAC,qBAKpF;AAED,iBAAS,cAAc,CAAC,MAAM,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,gBAAgB,CAAC,OAAO,CAAC,qBAuBpF;AAED,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,cAAc,EAAE,CAAA"}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
-
var t = {};
|
|
4
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
-
t[p] = s[p];
|
|
6
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
-
t[p[i]] = s[p[i]];
|
|
10
|
-
}
|
|
11
|
-
return t;
|
|
12
|
-
};
|
|
13
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
|
-
import * as React from "react";
|
|
15
|
-
import { Tooltip as TooltipPrimitive } from "radix-ui";
|
|
16
|
-
import { mergeClassNames } from "../utils/merge-class-names/index.js";
|
|
17
|
-
function TooltipProvider(params) {
|
|
18
|
-
const { delayDuration = 0 } = params, props = __rest(params, ["delayDuration"]);
|
|
19
|
-
return (_jsx(TooltipPrimitive.Provider, Object.assign({ "data-slot": "tooltip-provider", delayDuration: delayDuration }, props)));
|
|
20
|
-
}
|
|
21
|
-
function Tooltip(params) {
|
|
22
|
-
const props = __rest(params, []);
|
|
23
|
-
return _jsx(TooltipPrimitive.Root, Object.assign({ "data-slot": "tooltip" }, props));
|
|
24
|
-
}
|
|
25
|
-
function TooltipTrigger(params) {
|
|
26
|
-
const props = __rest(params, []);
|
|
27
|
-
return _jsx(TooltipPrimitive.Trigger, Object.assign({ "data-slot": "tooltip-trigger" }, props));
|
|
28
|
-
}
|
|
29
|
-
function TooltipContent(params) {
|
|
30
|
-
const { className, sideOffset = 0, children } = params, props = __rest(params, ["className", "sideOffset", "children"]);
|
|
31
|
-
return (_jsx(TooltipPrimitive.Portal, { children: _jsxs(TooltipPrimitive.Content, Object.assign({ "data-slot": "tooltip-content", sideOffset: sideOffset, className: mergeClassNames("data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-[state=delayed-open]:animate-in data-[state=delayed-open]:fade-in-0 data-[state=delayed-open]:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 rounded-md px-3 py-1.5 text-xs bg-foreground text-background z-50 w-fit max-w-xs origin-(--radix-tooltip-content-transform-origin)", className) }, props, { children: [children, _jsx(TooltipPrimitive.Arrow, { className: "size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px] bg-foreground fill-foreground z-50 translate-y-[calc(-50%_-_2px)]" })] })) }));
|
|
32
|
-
}
|
|
33
|
-
export { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger };
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { type ReactNode } from 'react';
|
|
2
|
-
import { buttonVariants } from '../../components/button.js';
|
|
3
|
-
import type { VariantProps } from 'class-variance-authority';
|
|
4
|
-
interface ConfirmDialogProps {
|
|
5
|
-
/** 是否打开对话框 */
|
|
6
|
-
open: boolean;
|
|
7
|
-
/** 打开状态变化回调 */
|
|
8
|
-
onOpenChange: (open: boolean) => void;
|
|
9
|
-
/** 对话框标题 */
|
|
10
|
-
title: string;
|
|
11
|
-
/** 对话框描述 */
|
|
12
|
-
description?: string | ReactNode;
|
|
13
|
-
/** 确认按钮文本 */
|
|
14
|
-
confirmText?: string;
|
|
15
|
-
/** 取消按钮文本 */
|
|
16
|
-
cancelText?: string;
|
|
17
|
-
/** 确认按钮变体 */
|
|
18
|
-
variant?: VariantProps<typeof buttonVariants>['variant'];
|
|
19
|
-
/** 确认回调 */
|
|
20
|
-
onConfirm: () => void | Promise<void>;
|
|
21
|
-
/** 是否正在执行(显示加载状态) */
|
|
22
|
-
loading?: boolean;
|
|
23
|
-
/** 危险操作的影响范围提示 */
|
|
24
|
-
impact?: ReactNode;
|
|
25
|
-
/** 设置后需要输入完全一致的短语才能确认 */
|
|
26
|
-
confirmPhrase?: string;
|
|
27
|
-
/** 确认短语当前输入值 */
|
|
28
|
-
confirmValue?: string;
|
|
29
|
-
/** 确认短语输入回调 */
|
|
30
|
-
onConfirmValueChange?: (value: string) => void;
|
|
31
|
-
/** 确认短语输入标签模板 */
|
|
32
|
-
confirmPhraseLabel?: (phrase: string) => string;
|
|
33
|
-
/** 加载中按钮文本 */
|
|
34
|
-
loadingText?: string;
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* 统一的确认对话框组件
|
|
38
|
-
*/
|
|
39
|
-
export declare function ConfirmDialog(params: ConfirmDialogProps): import("react").JSX.Element;
|
|
40
|
-
export {};
|
|
41
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../source/features/confirm-dialog/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAmB,KAAK,SAAS,EAAE,MAAM,OAAO,CAAA;AAavD,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAA;AAC3D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAI5D,UAAU,kBAAkB;IAC1B,cAAc;IACd,IAAI,EAAE,OAAO,CAAA;IACb,eAAe;IACf,YAAY,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAA;IACrC,YAAY;IACZ,KAAK,EAAE,MAAM,CAAA;IACb,YAAY;IACZ,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAChC,aAAa;IACb,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,aAAa;IACb,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,aAAa;IACb,OAAO,CAAC,EAAE,YAAY,CAAC,OAAO,cAAc,CAAC,CAAC,SAAS,CAAC,CAAA;IACxD,WAAW;IACX,SAAS,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IACrC,qBAAqB;IACrB,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,kBAAkB;IAClB,MAAM,CAAC,EAAE,SAAS,CAAA;IAClB,yBAAyB;IACzB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,gBAAgB;IAChB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,eAAe;IACf,oBAAoB,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;IAC9C,iBAAiB;IACjB,kBAAkB,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,MAAM,CAAA;IAC/C,cAAc;IACd,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,kBAAkB,+BA2DvD"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import {} from 'react';
|
|
3
|
-
import { AlertTriangle } from 'lucide-react';
|
|
4
|
-
import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, } from '../../components/alert-dialog.js';
|
|
5
|
-
import { buttonVariants } from '../../components/button.js';
|
|
6
|
-
import { mergeClassNames } from '../../utils/merge-class-names/index.js';
|
|
7
|
-
/**
|
|
8
|
-
* 统一的确认对话框组件
|
|
9
|
-
*/
|
|
10
|
-
export function ConfirmDialog(params) {
|
|
11
|
-
const { open, onOpenChange, title, description, confirmText = 'Confirm', cancelText = 'Cancel', variant = 'default', onConfirm, loading = false, impact, confirmPhrase, confirmValue = '', onConfirmValueChange, confirmPhraseLabel = (phrase) => `Type "${phrase}" to confirm`, loadingText = 'Processing...', } = params;
|
|
12
|
-
const phraseValid = !confirmPhrase || confirmValue === confirmPhrase;
|
|
13
|
-
return (_jsx(AlertDialog, { open: open, onOpenChange: onOpenChange, children: _jsxs(AlertDialogContent, { children: [_jsxs(AlertDialogHeader, { children: [_jsxs(AlertDialogTitle, { className: mergeClassNames(variant === 'destructive' && 'flex items-center gap-2'), children: [variant === 'destructive' && _jsx(AlertTriangle, { className: "size-5 text-destructive" }), title] }), description && _jsx(AlertDialogDescription, { children: description }), impact && _jsx("div", { className: "rounded-md border border-destructive/30 bg-destructive/5 px-3 py-2 text-sm text-destructive", children: impact }), confirmPhrase && onConfirmValueChange && (_jsxs("div", { className: "space-y-2 text-sm", children: [_jsx("label", { htmlFor: "confirm-phrase", children: confirmPhraseLabel(confirmPhrase) }), _jsx("input", { id: "confirm-phrase", value: confirmValue, onChange: event => onConfirmValueChange(event.target.value), className: "w-full rounded-md border bg-background px-3 py-2 outline-none focus-visible:ring-2 focus-visible:ring-ring", autoComplete: "off" })] }))] }), _jsxs(AlertDialogFooter, { children: [_jsx(AlertDialogCancel, { disabled: loading, children: cancelText }), _jsx(AlertDialogAction, { className: mergeClassNames(buttonVariants({ variant }), loading && 'opacity-50 cursor-not-allowed'), onClick: (e) => {
|
|
14
|
-
e.preventDefault();
|
|
15
|
-
if (!loading) {
|
|
16
|
-
onConfirm();
|
|
17
|
-
}
|
|
18
|
-
}, disabled: loading || !phraseValid, children: loading ? loadingText : confirmText })] })] }) }));
|
|
19
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
type InputConfirmContextType = {
|
|
3
|
-
resolve: (value: string) => Promise<unknown>;
|
|
4
|
-
};
|
|
5
|
-
export interface InputConfirmProviderProps extends React.PropsWithChildren {
|
|
6
|
-
/**
|
|
7
|
-
* 标题文案
|
|
8
|
-
*/
|
|
9
|
-
title?: string;
|
|
10
|
-
/**
|
|
11
|
-
* 描述文案模板
|
|
12
|
-
*/
|
|
13
|
-
description?: (value?: string) => string;
|
|
14
|
-
/**
|
|
15
|
-
* 取消按钮文案
|
|
16
|
-
*/
|
|
17
|
-
cancelText?: string;
|
|
18
|
-
/**
|
|
19
|
-
* 确认按钮文案
|
|
20
|
-
*/
|
|
21
|
-
confirmText?: string;
|
|
22
|
-
}
|
|
23
|
-
export declare function InputConfirmProvider(props: InputConfirmProviderProps): React.JSX.Element;
|
|
24
|
-
export declare function useInputConfirm(): InputConfirmContextType;
|
|
25
|
-
export {};
|
|
26
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../source/features/input-confirm/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoD,MAAM,OAAO,CAAA;AAexE,KAAK,uBAAuB,GAAG;IAC7B,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAA;CAC7C,CAAA;AAQD,MAAM,WAAW,yBAA0B,SAAQ,KAAK,CAAC,iBAAiB;IACxE;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;OAEG;IACH,WAAW,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,MAAM,KAAK,MAAM,CAAA;IACxC;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,yBAAyB,qBAmFpE;AAGD,wBAAgB,eAAe,4BAK9B"}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import React, { useCallback, useContext, useRef, useState } from 'react';
|
|
3
|
-
import { useForm } from 'react-hook-form';
|
|
4
|
-
import { LoadingButton } from '../../components/loading-button/index.js';
|
|
5
|
-
import { Button } from '../../components/button.js';
|
|
6
|
-
import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, } from '../../components/dialog.js';
|
|
7
|
-
import { Input } from '../../components/input.js';
|
|
8
|
-
const InputConfirmContext = React.createContext(null);
|
|
9
|
-
export function InputConfirmProvider(props) {
|
|
10
|
-
const { title = 'Confirm Action', description = (value) => `Type "${value}" to confirm`, cancelText = 'Cancel', confirmText = 'Confirm', children, } = props;
|
|
11
|
-
const [open, setOpen] = useState(false);
|
|
12
|
-
const [value, setValue] = useState();
|
|
13
|
-
const rejectRef = useRef(undefined);
|
|
14
|
-
const resolveRef = useRef(undefined);
|
|
15
|
-
const form = useForm({ defaultValues: { value: '' } });
|
|
16
|
-
const handleResolve = useCallback((value) => {
|
|
17
|
-
if (rejectRef.current != null || resolveRef.current != null) {
|
|
18
|
-
throw new Error('There are previous confirmations that are not completed');
|
|
19
|
-
}
|
|
20
|
-
const promise = new Promise((resolve, reject) => {
|
|
21
|
-
resolveRef.current = resolve;
|
|
22
|
-
rejectRef.current = reject;
|
|
23
|
-
setValue(value);
|
|
24
|
-
setOpen(true);
|
|
25
|
-
});
|
|
26
|
-
return promise;
|
|
27
|
-
}, []);
|
|
28
|
-
const clearPromiseRef = () => {
|
|
29
|
-
rejectRef.current = undefined;
|
|
30
|
-
resolveRef.current = undefined;
|
|
31
|
-
};
|
|
32
|
-
const handleClose = () => {
|
|
33
|
-
var _a;
|
|
34
|
-
(_a = rejectRef.current) === null || _a === void 0 ? void 0 : _a.call(rejectRef, undefined);
|
|
35
|
-
clearPromiseRef();
|
|
36
|
-
form.reset();
|
|
37
|
-
setOpen(false);
|
|
38
|
-
};
|
|
39
|
-
const handleTry = useCallback((formData) => {
|
|
40
|
-
var _a;
|
|
41
|
-
if (formData.value === value) {
|
|
42
|
-
(_a = resolveRef.current) === null || _a === void 0 ? void 0 : _a.call(resolveRef, undefined);
|
|
43
|
-
clearPromiseRef();
|
|
44
|
-
form.reset();
|
|
45
|
-
setOpen(false);
|
|
46
|
-
}
|
|
47
|
-
}, [value, form]);
|
|
48
|
-
const onSubmit = useCallback(() => {
|
|
49
|
-
form.handleSubmit(handleTry)();
|
|
50
|
-
}, [form, handleTry]);
|
|
51
|
-
return (_jsxs(InputConfirmContext.Provider, { value: { resolve: handleResolve }, children: [_jsx(Dialog, { open: open, onOpenChange: (isOpen) => !isOpen && handleClose(), children: _jsxs(DialogContent, { children: [_jsxs(DialogHeader, { children: [_jsx(DialogTitle, { children: title }), _jsx(DialogDescription, { children: description(value) })] }), _jsx("div", { className: "py-4", children: _jsx(Input, Object.assign({}, form.register('value', { validate: v => v === value }))) }), _jsxs(DialogFooter, { children: [_jsx(LoadingButton, { as: Button, variant: "outline", onClick: handleClose, children: cancelText }), _jsx(Button, { disabled: !form.formState.isValid, onClick: onSubmit, children: confirmText })] })] }) }), children] }));
|
|
52
|
-
}
|
|
53
|
-
// eslint-disable-next-line react-refresh/only-export-components
|
|
54
|
-
export function useInputConfirm() {
|
|
55
|
-
const ctx = useContext(InputConfirmContext);
|
|
56
|
-
if (ctx == null)
|
|
57
|
-
throw new Error('InputConfirm context not found');
|
|
58
|
-
return ctx;
|
|
59
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 登录上下文值
|
|
3
|
-
*/
|
|
4
|
-
interface SigninContextValue {
|
|
5
|
-
signin: () => Promise<void>;
|
|
6
|
-
}
|
|
7
|
-
export declare const SigninContext: import("react").Context<SigninContextValue | null>;
|
|
8
|
-
/**
|
|
9
|
-
* 使用登录上下文
|
|
10
|
-
* 用于在任何子组件中调用登录方法
|
|
11
|
-
*/
|
|
12
|
-
export declare function useSignin(): SigninContextValue;
|
|
13
|
-
export {};
|
|
14
|
-
//# sourceMappingURL=context.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../source/features/signin/context.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,UAAU,kBAAkB;IAC1B,MAAM,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;CAC5B;AAED,eAAO,MAAM,aAAa,oDAAiD,CAAA;AAE3E;;;GAGG;AACH,wBAAgB,SAAS,uBAMxB"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { createContext, useContext } from 'react';
|
|
2
|
-
export const SigninContext = createContext(null);
|
|
3
|
-
/**
|
|
4
|
-
* 使用登录上下文
|
|
5
|
-
* 用于在任何子组件中调用登录方法
|
|
6
|
-
*/
|
|
7
|
-
export function useSignin() {
|
|
8
|
-
const context = useContext(SigninContext);
|
|
9
|
-
if (!context) {
|
|
10
|
-
throw new Error('useSigninContext must be used within SigninDialogProvider');
|
|
11
|
-
}
|
|
12
|
-
return context;
|
|
13
|
-
}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
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
|
-
/**
|
|
6
|
-
* 登录弹窗文案配置
|
|
7
|
-
*/
|
|
8
|
-
export interface SigninDialogTexts {
|
|
9
|
-
/** 打开登录页标题 */
|
|
10
|
-
openingTitle?: string;
|
|
11
|
-
/** 等待登录标题 */
|
|
12
|
-
waitingTitle?: string;
|
|
13
|
-
/** 登录成功标题 */
|
|
14
|
-
successTitle?: string;
|
|
15
|
-
/** 登录失败标题 */
|
|
16
|
-
errorTitle?: string;
|
|
17
|
-
/** 登录已取消标题 */
|
|
18
|
-
cancelledTitle?: string;
|
|
19
|
-
/** 票据已过期标题 */
|
|
20
|
-
expiredTitle?: string;
|
|
21
|
-
/** 正在打开登录窗口描述 */
|
|
22
|
-
openingDescription?: string;
|
|
23
|
-
/** 请在新窗口中完成登录描述 */
|
|
24
|
-
waitingDescription?: string;
|
|
25
|
-
/** 登录成功描述 */
|
|
26
|
-
successDescription?: string;
|
|
27
|
-
/** 登录成功后此窗口将自动关闭提示 */
|
|
28
|
-
waitingHint?: string;
|
|
29
|
-
/** 登录过程中出现错误描述 */
|
|
30
|
-
errorDescription?: string;
|
|
31
|
-
/** 登录已被取消描述 */
|
|
32
|
-
cancelledDescription?: string;
|
|
33
|
-
/** 票据已过期描述 */
|
|
34
|
-
expiredDescription?: string;
|
|
35
|
-
/** 重新打开登录窗口按钮文字 */
|
|
36
|
-
reopenButton?: string;
|
|
37
|
-
/** 重新登录按钮文字 */
|
|
38
|
-
retryButton?: string;
|
|
39
|
-
/** 取消按钮文字 */
|
|
40
|
-
cancelButton?: string;
|
|
41
|
-
/** 关闭按钮文字 */
|
|
42
|
-
closeButton?: string;
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* 登录弹窗 Provider
|
|
46
|
-
* 提供登录方法给子组件使用
|
|
47
|
-
*/
|
|
48
|
-
interface SigninDialogProviderProps {
|
|
49
|
-
children: React.ReactNode;
|
|
50
|
-
/** API 配置,用于适配不同的认证系统 */
|
|
51
|
-
apis: SigninApi;
|
|
52
|
-
/** 文案配置,用于 i18n */
|
|
53
|
-
texts?: SigninDialogTexts;
|
|
54
|
-
}
|
|
55
|
-
export declare const SigninDialogProvider: ((props: SigninDialogProviderProps) => React.JSX.Element) & {
|
|
56
|
-
displayName: string;
|
|
57
|
-
};
|
|
58
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../source/features/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;AAkXD;;;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"}
|