@taicode/common-web 3.0.1 → 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 +1 -1
- package/output/loading-button/index.d.ts.map +1 -1
- package/output/loading-button/index.js +1 -1
- package/output/loading-button/index.test.js +1 -1
- 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 +9 -9
- package/output/signin/service.d.ts +1 -1
- package/output/signin/service.d.ts.map +1 -1
- package/output/signin/service.js +1 -4
- package/output/signin/service.test.js +1 -1
- 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.js +1 -1
- 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 +8 -6
- 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
|
@@ -45,7 +45,7 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (
|
|
|
45
45
|
};
|
|
46
46
|
import { action, computed, observable, when } from 'mobx';
|
|
47
47
|
import { catchIt } from '@taicode/common-base';
|
|
48
|
-
import { SideCache } from '../side-cache';
|
|
48
|
+
import { SideCache } from '../side-cache/index.js';
|
|
49
49
|
let CacheApi = (() => {
|
|
50
50
|
var _a, _CacheApi_pendingRequests_accessor_storage;
|
|
51
51
|
var _b, _c, _d;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
|
|
2
2
|
import { runInAction, configure } from 'mobx';
|
|
3
|
-
import { CacheApi } from './cache-api';
|
|
3
|
+
import { CacheApi } from './cache-api.js';
|
|
4
4
|
// 配置 MobX 在测试环境中的行为
|
|
5
5
|
configure({
|
|
6
6
|
enforceActions: 'never',
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { CacheApi } from './cache-api';
|
|
1
|
+
export { CacheApi } from './cache-api.js';
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/cache-api/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/cache-api/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { CacheApi } from './cache-api';
|
|
1
|
+
export { CacheApi } from './cache-api.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LoadingButtonDemo.d.ts","sourceRoot":"","sources":["../../source/loading-button/LoadingButtonDemo.tsx"],"names":[],"mappings":"AAGA;;GAEG;AACH,wBAAgB,iBAAiB,4CAsKhC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import { LoadingButton } from '../loading-button';
|
|
4
|
+
/**
|
|
5
|
+
* LoadingButton 组件演示
|
|
6
|
+
*/
|
|
7
|
+
export function LoadingButtonDemo() {
|
|
8
|
+
const [result, setResult] = useState('');
|
|
9
|
+
// 模拟异步保存操作
|
|
10
|
+
const handleSave = async () => {
|
|
11
|
+
setResult('正在保存...');
|
|
12
|
+
await new Promise(resolve => setTimeout(resolve, 2000));
|
|
13
|
+
setResult('保存成功!');
|
|
14
|
+
};
|
|
15
|
+
// 模拟可能失败的操作
|
|
16
|
+
const handleDelete = async () => {
|
|
17
|
+
setResult('正在删除...');
|
|
18
|
+
await new Promise(resolve => setTimeout(resolve, 1500));
|
|
19
|
+
// 模拟随机失败
|
|
20
|
+
if (Math.random() > 0.5) {
|
|
21
|
+
setResult('删除成功!');
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
setResult('删除失败!');
|
|
25
|
+
throw new Error('删除失败');
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
// 同步操作
|
|
29
|
+
const handleClick = () => {
|
|
30
|
+
setResult('立即点击!');
|
|
31
|
+
};
|
|
32
|
+
return (_jsxs("div", { className: "space-y-8 p-8", children: [_jsxs("div", { children: [_jsx("h2", { className: "text-2xl font-bold mb-4", children: "LoadingButton \u7EC4\u4EF6\u6F14\u793A" }), _jsx("p", { className: "text-gray-600 mb-4", children: "\u6F14\u793A\u5982\u4F55\u4F7F\u7528 LoadingButton \u7EC4\u4EF6\u5904\u7406\u5F02\u6B65\u64CD\u4F5C" })] }), result && (_jsx("div", { className: "p-4 bg-gray-100 dark:bg-gray-800 rounded-lg", children: _jsx("p", { className: "text-sm font-medium", children: result }) })), _jsxs("section", { className: "space-y-4", children: [_jsx("h3", { className: "text-lg font-semibold", children: "\u57FA\u7840\u7528\u6CD5" }), _jsxs("div", { className: "flex gap-3 flex-wrap", children: [_jsx(LoadingButton, { color: "blue", onClick: handleSave, children: "\u4FDD\u5B58\u6570\u636E" }), _jsx(LoadingButton, { color: "red", onClick: handleDelete, children: "\u5220\u9664\u6570\u636E" }), _jsx(LoadingButton, { color: "green", onClick: handleClick, children: "\u540C\u6B65\u64CD\u4F5C" })] })] }), _jsxs("section", { className: "space-y-4", children: [_jsx("h3", { className: "text-lg font-semibold", children: "\u4E0D\u540C\u6837\u5F0F" }), _jsxs("div", { className: "flex gap-3 flex-wrap", children: [_jsx(LoadingButton, { color: "emerald", onClick: handleSave, children: "Solid \u6837\u5F0F" }), _jsx(LoadingButton, { outline: true, onClick: handleSave, children: "Outline \u6837\u5F0F" }), _jsx(LoadingButton, { plain: true, onClick: handleSave, children: "Plain \u6837\u5F0F" })] })] }), _jsxs("section", { className: "space-y-4", children: [_jsx("h3", { className: "text-lg font-semibold", children: "\u81EA\u5B9A\u4E49\u52A0\u8F7D\u6587\u672C" }), _jsxs("div", { className: "flex gap-3 flex-wrap", children: [_jsx(LoadingButton, { color: "blue", onClick: handleSave, loadingText: "\u6B63\u5728\u4FDD\u5B58\u6570\u636E...", children: "\u81EA\u5B9A\u4E49\u6587\u672C" }), _jsx(LoadingButton, { color: "purple", onClick: handleSave, loadingText: _jsxs("span", { className: "flex items-center gap-2", children: [_jsxs("svg", { className: "animate-spin h-4 w-4", viewBox: "0 0 24 24", children: [_jsx("circle", { className: "opacity-25", cx: "12", cy: "12", r: "10", stroke: "currentColor", strokeWidth: "4", fill: "none" }), _jsx("path", { className: "opacity-75", fill: "currentColor", d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z" })] }), "\u5904\u7406\u4E2D"] }), children: "\u81EA\u5B9A\u4E49\u56FE\u6807" })] })] }), _jsxs("section", { className: "space-y-4", children: [_jsx("h3", { className: "text-lg font-semibold", children: "\u989C\u8272\u9009\u9879" }), _jsxs("div", { className: "flex gap-3 flex-wrap", children: [_jsx(LoadingButton, { color: "red", onClick: handleSave, children: "Red" }), _jsx(LoadingButton, { color: "orange", onClick: handleSave, children: "Orange" }), _jsx(LoadingButton, { color: "amber", onClick: handleSave, children: "Amber" }), _jsx(LoadingButton, { color: "yellow", onClick: handleSave, children: "Yellow" }), _jsx(LoadingButton, { color: "lime", onClick: handleSave, children: "Lime" }), _jsx(LoadingButton, { color: "green", onClick: handleSave, children: "Green" }), _jsx(LoadingButton, { color: "emerald", onClick: handleSave, children: "Emerald" }), _jsx(LoadingButton, { color: "teal", onClick: handleSave, children: "Teal" }), _jsx(LoadingButton, { color: "cyan", onClick: handleSave, children: "Cyan" }), _jsx(LoadingButton, { color: "sky", onClick: handleSave, children: "Sky" }), _jsx(LoadingButton, { color: "blue", onClick: handleSave, children: "Blue" }), _jsx(LoadingButton, { color: "indigo", onClick: handleSave, children: "Indigo" }), _jsx(LoadingButton, { color: "violet", onClick: handleSave, children: "Violet" }), _jsx(LoadingButton, { color: "purple", onClick: handleSave, children: "Purple" }), _jsx(LoadingButton, { color: "fuchsia", onClick: handleSave, children: "Fuchsia" }), _jsx(LoadingButton, { color: "pink", onClick: handleSave, children: "Pink" }), _jsx(LoadingButton, { color: "rose", onClick: handleSave, children: "Rose" })] })] }), _jsxs("section", { className: "space-y-4", children: [_jsx("h3", { className: "text-lg font-semibold", children: "\u7981\u7528\u72B6\u6001" }), _jsxs("div", { className: "flex gap-3 flex-wrap", children: [_jsx(LoadingButton, { color: "blue", disabled: true, onClick: handleSave, children: "\u7981\u7528\u6309\u94AE" }), _jsx(LoadingButton, { color: "green", onClick: handleSave, disableOnLoading: false, children: "\u52A0\u8F7D\u65F6\u4E0D\u7981\u7528" })] })] })] }));
|
|
33
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/loading-button/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAqC,wBAAwB,EAAE,WAAW,EAAE,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/loading-button/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAqC,KAAK,wBAAwB,EAAE,KAAK,WAAW,EAAE,MAAM,OAAO,CAAA;AAkCjH;;GAEG;AACH,KAAK,gBAAgB,CAAC,CAAC,SAAS,WAAW,IAAI;IAC7C,EAAE,CAAC,EAAE,CAAC,CAAA;IACN,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,WAAW,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IAC7B,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,UAAU,CAAC,iBAAiB,CAAC,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAC9E,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;CAC3B,GAAG,IAAI,CAAC,wBAAwB,CAAC,CAAC,CAAC,EAAE,IAAI,GAAG,SAAS,GAAG,aAAa,GAAG,aAAa,GAAG,SAAS,CAAC,CAAA;AAEnG;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,eAAO,MAAM,aAAa,4HAsEzB,CAAA"}
|
|
@@ -10,7 +10,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
12
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
13
|
-
import { useState, useCallback, forwardRef } from 'react';
|
|
13
|
+
import React, { useState, useCallback, forwardRef } from 'react';
|
|
14
14
|
function isPromiseLike(value) {
|
|
15
15
|
return value != null && typeof value === 'object' && 'then' in value && typeof value.then === 'function';
|
|
16
16
|
}
|
|
@@ -13,7 +13,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
13
13
|
import '@testing-library/jest-dom/vitest';
|
|
14
14
|
import { describe, it, expect, vi } from 'vitest';
|
|
15
15
|
import { render, screen, fireEvent, waitFor } from '@testing-library/react';
|
|
16
|
-
import { LoadingButton } from './index';
|
|
16
|
+
import { LoadingButton } from './index.js';
|
|
17
17
|
describe('LoadingButton', () => {
|
|
18
18
|
describe('基础功能', () => {
|
|
19
19
|
it('应该渲染按钮和子元素', () => {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { useService, useLocalService, ServiceProvider } from './service';
|
|
1
|
+
export { useService, useLocalService, ServiceProvider } from './service.js';
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/service/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/service/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA"}
|
package/output/service/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { useService, useLocalService, ServiceProvider } from './service';
|
|
1
|
+
export { useService, useLocalService, ServiceProvider } from './service.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../source/service/service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAIH,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;
|
|
1
|
+
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../source/service/service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAIH,OAAO,EAAE,KAAK,KAAK,EAAE,SAAS,EAAE,KAAK,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AACtE,OAAO,KAA0E,MAAM,OAAO,CAAA;AA+D9F;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwEG;AAEH,wBAAgB,UAAU,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAA;AAClD,wBAAgB,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;AAgDlF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwEG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,YAAY,EAAE,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,GAAG,CAAC,CAAA;AAC9E,wBAAgB,eAAe,CAAC,CAAC,EAAE,CAAC,EAAE,YAAY,EAAE,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,EAAE,QAAQ,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;AAyF9G;;GAEG;AACH,UAAU,oBAAoB;IAC5B;;;;;OAKG;IACH,QAAQ,EAAE,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAA;IAC7B,UAAU;IACV,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAC1B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiFG;AACH,6CAA6C;AAE7C,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB,8EA2B1D"}
|
|
@@ -33,8 +33,9 @@
|
|
|
33
33
|
* ```
|
|
34
34
|
*/
|
|
35
35
|
import { reaction, runInAction } from 'mobx';
|
|
36
|
+
import { Service } from '@taicode/common-base';
|
|
36
37
|
import { Container } from '@needle-di/core';
|
|
37
|
-
import React, { useContext, useEffect, useMemo, useState, useRef } from 'react';
|
|
38
|
+
import React, { useContext, useEffect, useMemo, useState, useRef, createElement } from 'react';
|
|
38
39
|
/**
|
|
39
40
|
* React Context 用于传递 DI 容器实例
|
|
40
41
|
* 通过上下文在组件树中共享依赖注入容器
|
|
@@ -88,7 +89,7 @@ export function useService(target, selector) {
|
|
|
88
89
|
const container = useContext(ctx);
|
|
89
90
|
// 使用 useState 强制组件重新渲染
|
|
90
91
|
const [, refresh] = useState({});
|
|
91
|
-
|
|
92
|
+
useEffect(() => {
|
|
92
93
|
if (container == null)
|
|
93
94
|
return;
|
|
94
95
|
// 从容器中获取服务实例
|
|
@@ -141,7 +142,7 @@ export function useLocalService(ServiceClass, selector) {
|
|
|
141
142
|
serviceInstanceRef.current = localContainerRef.current.get(ServiceClass);
|
|
142
143
|
}
|
|
143
144
|
// 模仿 useService 的结构:在 useEffect 中设置 reaction 和初始化
|
|
144
|
-
|
|
145
|
+
useEffect(() => {
|
|
145
146
|
if (parentContainer == null)
|
|
146
147
|
return;
|
|
147
148
|
const service = serviceInstanceRef.current;
|
|
@@ -166,7 +167,7 @@ export function useLocalService(ServiceClass, selector) {
|
|
|
166
167
|
return dispose;
|
|
167
168
|
}, [parentContainer, selector, ServiceClass]);
|
|
168
169
|
// 单独的 useEffect 处理服务初始化,避免与 selector 变化的冲突
|
|
169
|
-
|
|
170
|
+
useEffect(() => {
|
|
170
171
|
if (parentContainer == null)
|
|
171
172
|
return;
|
|
172
173
|
let disposed = false;
|
|
@@ -284,9 +285,9 @@ export function ServiceProvider(props) {
|
|
|
284
285
|
});
|
|
285
286
|
return currentContainer;
|
|
286
287
|
}, [parentContainer, services]);
|
|
287
|
-
// 使用
|
|
288
|
-
const init =
|
|
289
|
-
return
|
|
288
|
+
// 使用 createElement 避免将文件改为 .tsx
|
|
289
|
+
const init = createElement(InitService, { services, children });
|
|
290
|
+
return createElement(ctx.Provider, { value: container, children: container ? init : null });
|
|
290
291
|
}
|
|
291
292
|
/**
|
|
292
293
|
* 服务初始化组件
|
|
@@ -310,7 +311,7 @@ export function ServiceProvider(props) {
|
|
|
310
311
|
function InitService(props) {
|
|
311
312
|
const { services, children } = props;
|
|
312
313
|
const container = useContext(ctx);
|
|
313
|
-
const [initError, setInitError] =
|
|
314
|
+
const [initError, setInitError] = useState(null);
|
|
314
315
|
useEffect(() => {
|
|
315
316
|
if (container == null)
|
|
316
317
|
return;
|
|
@@ -49,7 +49,8 @@ import { Service } from '@taicode/common-base';
|
|
|
49
49
|
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
50
50
|
import { render, renderHook, waitFor } from '@testing-library/react';
|
|
51
51
|
import { observable, makeObservable, runInAction, action } from 'mobx';
|
|
52
|
-
import {
|
|
52
|
+
import { inject } from '@needle-di/core';
|
|
53
|
+
import { useService, useLocalService, ServiceProvider } from './service.js';
|
|
53
54
|
class TestErrorBoundary extends React.Component {
|
|
54
55
|
constructor() {
|
|
55
56
|
super(...arguments);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { SideCache } from './side-cache';
|
|
1
|
+
export { SideCache } from './side-cache.js';
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/side-cache/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/side-cache/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { SideCache } from './side-cache';
|
|
1
|
+
export { SideCache } from './side-cache.js';
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
1
|
/**
|
|
3
2
|
* 登录上下文值
|
|
4
3
|
*/
|
|
5
4
|
interface SigninContextValue {
|
|
6
5
|
signin: () => Promise<void>;
|
|
7
6
|
}
|
|
8
|
-
export declare const SigninContext:
|
|
7
|
+
export declare const SigninContext: import("react").Context<SigninContextValue | null>;
|
|
9
8
|
/**
|
|
10
9
|
* 使用登录上下文
|
|
11
10
|
* 用于在任何子组件中调用登录方法
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../source/signin/context.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../source/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"}
|
package/output/signin/context.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import
|
|
2
|
-
export const SigninContext =
|
|
1
|
+
import { createContext, useContext } from 'react';
|
|
2
|
+
export const SigninContext = createContext(null);
|
|
3
3
|
/**
|
|
4
4
|
* 使用登录上下文
|
|
5
5
|
* 用于在任何子组件中调用登录方法
|
|
6
6
|
*/
|
|
7
7
|
export function useSignin() {
|
|
8
|
-
const context =
|
|
8
|
+
const context = useContext(SigninContext);
|
|
9
9
|
if (!context) {
|
|
10
10
|
throw new Error('useSigninContext must be used within SigninDialogProvider');
|
|
11
11
|
}
|
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
|
@@ -10,15 +10,15 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
12
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
-
import React from 'react';
|
|
13
|
+
import React, { useRef, useMemo, useCallback } from 'react';
|
|
14
14
|
import { observer } from 'mobx-react-lite';
|
|
15
15
|
import { motion, AnimatePresence } from 'framer-motion';
|
|
16
16
|
import * as DialogPrimitive from '@radix-ui/react-dialog';
|
|
17
17
|
import { CheckCircleIcon, XCircleIcon, ExclamationTriangleIcon, ClockIcon } from '@heroicons/react/24/outline';
|
|
18
|
-
import { SigninService } from './service';
|
|
19
|
-
import { SigninContext } from './context';
|
|
20
|
-
import { ServiceProvider } from '../service';
|
|
21
|
-
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';
|
|
22
22
|
/**
|
|
23
23
|
* 默认文案
|
|
24
24
|
*/
|
|
@@ -114,21 +114,21 @@ const SigninDialog = observer((props) => {
|
|
|
114
114
|
export const SigninDialogProvider = observer((props) => {
|
|
115
115
|
const { children, apis: apiConfig, texts: customTexts } = props;
|
|
116
116
|
// 创建服务实例,使用 useRef 保持引用稳定
|
|
117
|
-
const signinService =
|
|
117
|
+
const signinService = useRef();
|
|
118
118
|
if (!signinService.current) {
|
|
119
119
|
signinService.current = new SigninService(apiConfig);
|
|
120
120
|
signinService.current.init();
|
|
121
121
|
}
|
|
122
122
|
// 合并默认文案和自定义文案
|
|
123
|
-
const texts =
|
|
124
|
-
const handleSignin =
|
|
123
|
+
const texts = useMemo(() => (Object.assign(Object.assign({}, defaultTexts), customTexts)), [customTexts]);
|
|
124
|
+
const handleSignin = useCallback(async () => {
|
|
125
125
|
var _a;
|
|
126
126
|
const url = await ((_a = signinService.current) === null || _a === void 0 ? void 0 : _a.start());
|
|
127
127
|
if (url) {
|
|
128
128
|
window.open(url, '_blank');
|
|
129
129
|
}
|
|
130
130
|
}, []);
|
|
131
|
-
const contextValue =
|
|
131
|
+
const contextValue = useMemo(() => ({
|
|
132
132
|
signin: handleSignin
|
|
133
133
|
}), [handleSignin]);
|
|
134
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
|
@@ -454,10 +454,7 @@ let SigninService = (() => {
|
|
|
454
454
|
}
|
|
455
455
|
}, { delay: 100 }));
|
|
456
456
|
// 尝试恢复持久化状态
|
|
457
|
-
|
|
458
|
-
if (restored) {
|
|
459
|
-
console.log('Signin state restored from localStorage');
|
|
460
|
-
}
|
|
457
|
+
this.restoreState();
|
|
461
458
|
return true;
|
|
462
459
|
}
|
|
463
460
|
/**
|
|
@@ -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);
|
package/output/toaster/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useEffect, useRef } from 'react';
|
|
2
|
+
import React, { useEffect, useRef } from 'react';
|
|
3
3
|
import { toast, Toaster as SonnerToaster } from 'sonner';
|
|
4
4
|
import { SystemError, UserError } from '@taicode/common-base';
|
|
5
5
|
/** 自动捕获和处理异步错误,无法识别的错误会保持原样 */
|
|
@@ -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.0
|
|
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": [
|
|
@@ -30,7 +32,7 @@
|
|
|
30
32
|
"peerDependencies": {
|
|
31
33
|
"@heroicons/react": "^2.2.0",
|
|
32
34
|
"@needle-di/core": ">=1.0.0",
|
|
33
|
-
"@taicode/common-base": "^3.0
|
|
35
|
+
"@taicode/common-base": "^3.1.0",
|
|
34
36
|
"@types/react": ">=18",
|
|
35
37
|
"mobx": ">=6",
|
|
36
38
|
"mobx-react-lite": "^4.1.1",
|
|
@@ -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
|
-
}
|