@taicode/common-web 1.1.2 → 1.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/output/cache-api/cache-api.d.ts +7 -1
- package/output/cache-api/cache-api.d.ts.map +1 -1
- package/output/cache-api/cache-api.js +26 -6
- package/output/cache-api/cache-api.test.js +134 -33
- package/output/catalyst/alert.d.ts +5 -5
- package/output/catalyst/alert.d.ts.map +1 -1
- package/output/catalyst/alert.js +46 -0
- package/output/catalyst/auth-layout.d.ts +1 -1
- package/output/catalyst/auth-layout.d.ts.map +1 -1
- package/output/catalyst/auth-layout.js +4 -0
- package/output/catalyst/avatar.d.ts +1 -1
- package/output/catalyst/avatar.d.ts.map +1 -1
- package/output/catalyst/{avatar.jsx → avatar.js} +5 -20
- package/output/catalyst/badge.d.ts +1 -1
- package/output/catalyst/badge.d.ts.map +1 -1
- package/output/catalyst/{badge.jsx → badge.js} +4 -11
- package/output/catalyst/button.d.ts +1 -1
- package/output/catalyst/button.d.ts.map +1 -1
- package/output/catalyst/{button.jsx → button.js} +4 -10
- package/output/catalyst/checkbox.d.ts +3 -3
- package/output/catalyst/checkbox.d.ts.map +1 -1
- package/output/catalyst/{checkbox.jsx → checkbox.js} +6 -14
- package/output/catalyst/combobox.d.ts +4 -4
- package/output/catalyst/combobox.d.ts.map +1 -1
- package/output/catalyst/combobox.js +101 -0
- package/output/catalyst/description-list.d.ts +3 -3
- package/output/catalyst/description-list.d.ts.map +1 -1
- package/output/catalyst/{description-list.jsx → description-list.js} +4 -3
- package/output/catalyst/dialog.d.ts +5 -5
- package/output/catalyst/dialog.d.ts.map +1 -1
- package/output/catalyst/dialog.js +46 -0
- package/output/catalyst/divider.d.ts +1 -1
- package/output/catalyst/divider.d.ts.map +1 -1
- package/output/catalyst/{divider.jsx → divider.js} +2 -1
- package/output/catalyst/dropdown.d.ts +11 -11
- package/output/catalyst/dropdown.d.ts.map +1 -1
- package/output/catalyst/{dropdown.jsx → dropdown.js} +15 -18
- package/output/catalyst/fieldset.d.ts +7 -7
- package/output/catalyst/fieldset.d.ts.map +1 -1
- package/output/catalyst/fieldset.js +42 -0
- package/output/catalyst/heading.d.ts +2 -2
- package/output/catalyst/heading.d.ts.map +1 -1
- package/output/catalyst/{heading.jsx → heading.js} +3 -2
- package/output/catalyst/input.d.ts +1 -1
- package/output/catalyst/input.d.ts.map +1 -1
- package/output/catalyst/input.js +70 -0
- package/output/catalyst/{link.jsx → link.js} +3 -4
- package/output/catalyst/listbox.d.ts +4 -4
- package/output/catalyst/listbox.d.ts.map +1 -1
- package/output/catalyst/listbox.js +99 -0
- package/output/catalyst/navbar.d.ts +5 -5
- package/output/catalyst/navbar.d.ts.map +1 -1
- package/output/catalyst/{navbar.jsx → navbar.js} +8 -16
- package/output/catalyst/pagination.d.ts +6 -6
- package/output/catalyst/pagination.d.ts.map +1 -1
- package/output/catalyst/pagination.js +35 -0
- package/output/catalyst/radio.d.ts +3 -3
- package/output/catalyst/radio.d.ts.map +1 -1
- package/output/catalyst/{radio.jsx → radio.js} +8 -11
- package/output/catalyst/select.js +52 -0
- package/output/catalyst/sidebar-layout.d.ts +1 -1
- package/output/catalyst/sidebar-layout.d.ts.map +1 -1
- package/output/catalyst/sidebar-layout.js +18 -0
- package/output/catalyst/sidebar.d.ts +9 -9
- package/output/catalyst/sidebar.d.ts.map +1 -1
- package/output/catalyst/{sidebar.jsx → sidebar.js} +12 -20
- package/output/catalyst/stacked-layout.d.ts +1 -1
- package/output/catalyst/stacked-layout.d.ts.map +1 -1
- package/output/catalyst/stacked-layout.js +18 -0
- package/output/catalyst/switch.d.ts +3 -3
- package/output/catalyst/switch.d.ts.map +1 -1
- package/output/catalyst/{switch.jsx → switch.js} +19 -20
- package/output/catalyst/table.d.ts +6 -6
- package/output/catalyst/table.d.ts.map +1 -1
- package/output/catalyst/table.js +56 -0
- package/output/catalyst/text.d.ts +4 -4
- package/output/catalyst/text.d.ts.map +1 -1
- package/output/catalyst/{text.jsx → text.js} +5 -4
- package/output/catalyst/{textarea.jsx → textarea.js} +21 -22
- package/output/service/{service.test.jsx → service.test.js} +6 -15
- package/output/side-cache/side-cache.d.ts +1 -0
- package/output/side-cache/side-cache.d.ts.map +1 -1
- package/output/side-cache/side-cache.js +25 -1
- package/output/side-cache/side-cache.test.js +92 -0
- package/package.json +1 -1
- package/output/catalyst/alert.jsx +0 -55
- package/output/catalyst/auth-layout.jsx +0 -7
- package/output/catalyst/combobox.jsx +0 -120
- package/output/catalyst/dialog.jsx +0 -55
- package/output/catalyst/fieldset.jsx +0 -41
- package/output/catalyst/input.jsx +0 -73
- package/output/catalyst/listbox.jsx +0 -120
- package/output/catalyst/pagination.jsx +0 -52
- package/output/catalyst/select.jsx +0 -59
- package/output/catalyst/sidebar-layout.jsx +0 -58
- package/output/catalyst/stacked-layout.jsx +0 -55
- package/output/catalyst/table.jsx +0 -68
- 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/use-observer/use-observer.test.jsx +0 -134
- /package/output/{helpers/use-observer/use-observer.test.jsx → use-observer/use-observer.test.js} +0 -0
|
@@ -43,7 +43,8 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (
|
|
|
43
43
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
44
44
|
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
45
45
|
};
|
|
46
|
-
import
|
|
46
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
47
|
+
import { act } from 'react';
|
|
47
48
|
import { Service } from '@taicode/common-base';
|
|
48
49
|
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
49
50
|
import { render, renderHook, waitFor } from '@testing-library/react';
|
|
@@ -171,9 +172,7 @@ let SimpleService = (() => {
|
|
|
171
172
|
// 创建测试用的 Provider 组件
|
|
172
173
|
function createTestProvider(services) {
|
|
173
174
|
return function TestProvider({ children }) {
|
|
174
|
-
return (
|
|
175
|
-
{children}
|
|
176
|
-
</ServiceProvider>);
|
|
175
|
+
return (_jsx(ServiceProvider, { services: services, children: children }));
|
|
177
176
|
};
|
|
178
177
|
}
|
|
179
178
|
describe('service integration', () => {
|
|
@@ -236,9 +235,7 @@ describe('service integration', () => {
|
|
|
236
235
|
});
|
|
237
236
|
describe('ServiceProvider', () => {
|
|
238
237
|
it('应该能够渲染子组件', () => {
|
|
239
|
-
const { container } = render(
|
|
240
|
-
<div data-testid="child">Test Child</div>
|
|
241
|
-
</ServiceProvider>);
|
|
238
|
+
const { container } = render(_jsx(ServiceProvider, { services: [TestService], children: _jsx("div", { "data-testid": "child", children: "Test Child" }) }));
|
|
242
239
|
expect(container.querySelector('[data-testid="child"]')).toBeTruthy();
|
|
243
240
|
});
|
|
244
241
|
it('应该能够嵌套使用', () => {
|
|
@@ -248,11 +245,7 @@ describe('service integration', () => {
|
|
|
248
245
|
count: useService(TestService, service => service.count),
|
|
249
246
|
value: useService(AnotherService, service => service.value)
|
|
250
247
|
}), {
|
|
251
|
-
wrapper: ({ children }) => (
|
|
252
|
-
<ChildProvider>
|
|
253
|
-
{children}
|
|
254
|
-
</ChildProvider>
|
|
255
|
-
</ParentProvider>)
|
|
248
|
+
wrapper: ({ children }) => (_jsx(ParentProvider, { children: _jsx(ChildProvider, { children: children }) }))
|
|
256
249
|
});
|
|
257
250
|
expect(result.current.count).toBe(0);
|
|
258
251
|
expect(result.current.value).toBe('initial');
|
|
@@ -275,9 +268,7 @@ describe('service integration', () => {
|
|
|
275
268
|
expect(result.current).toBe('simple');
|
|
276
269
|
});
|
|
277
270
|
it('应该能够处理空的服务数组', () => {
|
|
278
|
-
const { container } = render(
|
|
279
|
-
<div data-testid="child">Test Child</div>
|
|
280
|
-
</ServiceProvider>);
|
|
271
|
+
const { container } = render(_jsx(ServiceProvider, { services: [], children: _jsx("div", { "data-testid": "child", children: "Test Child" }) }));
|
|
281
272
|
expect(container.querySelector('[data-testid="child"]')).toBeTruthy();
|
|
282
273
|
});
|
|
283
274
|
it('应该能够处理初始化失败的服务', async () => {
|
|
@@ -6,5 +6,6 @@ export declare class SideCache<T> {
|
|
|
6
6
|
get empty(): boolean;
|
|
7
7
|
handle<F extends ((...args: unknown[]) => T)>(key: unknown, func: F): T;
|
|
8
8
|
handle<F extends ((...args: unknown[]) => Promise<T> | T)>(key: unknown, func: F): Promise<T> | T;
|
|
9
|
+
clear(key?: unknown): void;
|
|
9
10
|
}
|
|
10
11
|
//# sourceMappingURL=side-cache.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"side-cache.d.ts","sourceRoot":"","sources":["../../source/side-cache/side-cache.ts"],"names":[],"mappings":"AAWA,qBAAa,SAAS,CAAC,CAAC;IAEtB,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAgB;IAG1C,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAoB;IAG/C,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAoC;IAE1D,IACW,KAAK,IAAI,CAAC,GAAG,SAAS,CAIhC;IAED,IACW,KAAK,IAAI,OAAO,CAE1B;IAED,MAAM,CAAC,CAAC,SAAS,CAAC,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,GAAG,CAAC;IACvE,MAAM,CAAC,CAAC,SAAS,CAAC,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC;
|
|
1
|
+
{"version":3,"file":"side-cache.d.ts","sourceRoot":"","sources":["../../source/side-cache/side-cache.ts"],"names":[],"mappings":"AAWA,qBAAa,SAAS,CAAC,CAAC;IAEtB,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAgB;IAG1C,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAoB;IAG/C,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAoC;IAE1D,IACW,KAAK,IAAI,CAAC,GAAG,SAAS,CAIhC;IAED,IACW,KAAK,IAAI,OAAO,CAE1B;IAED,MAAM,CAAC,CAAC,SAAS,CAAC,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,GAAG,CAAC;IACvE,MAAM,CAAC,CAAC,SAAS,CAAC,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC;IAyC1F,KAAK,CAAC,GAAG,CAAC,EAAE,OAAO,GAAG,IAAI;CAoBlC"}
|
|
@@ -49,7 +49,7 @@ function isPromiseLike(value) {
|
|
|
49
49
|
}
|
|
50
50
|
let SideCache = (() => {
|
|
51
51
|
var _a, _SideCache_emptyFlag_accessor_storage, _SideCache_currentKey_accessor_storage, _SideCache_cache_accessor_storage;
|
|
52
|
-
var _b, _c;
|
|
52
|
+
var _b, _c, _d;
|
|
53
53
|
let _instanceExtraInitializers = [];
|
|
54
54
|
let _emptyFlag_decorators;
|
|
55
55
|
let _emptyFlag_initializers = [];
|
|
@@ -63,6 +63,7 @@ let SideCache = (() => {
|
|
|
63
63
|
let _get_value_decorators;
|
|
64
64
|
let _get_empty_decorators;
|
|
65
65
|
let _handle_decorators;
|
|
66
|
+
let _clear_decorators;
|
|
66
67
|
return _a = class SideCache {
|
|
67
68
|
get emptyFlag() { return __classPrivateFieldGet(this, _SideCache_emptyFlag_accessor_storage, "f"); }
|
|
68
69
|
set emptyFlag(value) { __classPrivateFieldSet(this, _SideCache_emptyFlag_accessor_storage, value, "f"); }
|
|
@@ -106,6 +107,27 @@ let SideCache = (() => {
|
|
|
106
107
|
});
|
|
107
108
|
return funcReturn;
|
|
108
109
|
}
|
|
110
|
+
clear(key) {
|
|
111
|
+
var _b;
|
|
112
|
+
if (key === undefined) {
|
|
113
|
+
// 清除所有缓存
|
|
114
|
+
this.cache = {};
|
|
115
|
+
this.emptyFlag = true;
|
|
116
|
+
this.currentKey = undefined;
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
// 清除指定 key 的缓存
|
|
120
|
+
const keyStringify = (_b = JSON.stringify(key)) !== null && _b !== void 0 ? _b : 'undefined';
|
|
121
|
+
const newCache = Object.assign({}, this.cache);
|
|
122
|
+
delete newCache[keyStringify];
|
|
123
|
+
this.cache = newCache;
|
|
124
|
+
// 如果清除的是当前 key,需要重置状态
|
|
125
|
+
if (this.currentKey === keyStringify) {
|
|
126
|
+
this.emptyFlag = Object.keys(this.cache).length === 0;
|
|
127
|
+
this.currentKey = undefined;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
109
131
|
constructor() {
|
|
110
132
|
_SideCache_emptyFlag_accessor_storage.set(this, (__runInitializers(this, _instanceExtraInitializers), __runInitializers(this, _emptyFlag_initializers, true)));
|
|
111
133
|
_SideCache_currentKey_accessor_storage.set(this, (__runInitializers(this, _emptyFlag_extraInitializers), __runInitializers(this, _currentKey_initializers, void 0)));
|
|
@@ -124,12 +146,14 @@ let SideCache = (() => {
|
|
|
124
146
|
_get_value_decorators = [computed];
|
|
125
147
|
_get_empty_decorators = [computed];
|
|
126
148
|
_handle_decorators = [(_c = action).bound.bind(_c)];
|
|
149
|
+
_clear_decorators = [(_d = action).bound.bind(_d)];
|
|
127
150
|
__esDecorate(_a, null, _emptyFlag_decorators, { kind: "accessor", name: "emptyFlag", static: false, private: false, access: { has: obj => "emptyFlag" in obj, get: obj => obj.emptyFlag, set: (obj, value) => { obj.emptyFlag = value; } }, metadata: _metadata }, _emptyFlag_initializers, _emptyFlag_extraInitializers);
|
|
128
151
|
__esDecorate(_a, null, _currentKey_decorators, { kind: "accessor", name: "currentKey", static: false, private: false, access: { has: obj => "currentKey" in obj, get: obj => obj.currentKey, set: (obj, value) => { obj.currentKey = value; } }, metadata: _metadata }, _currentKey_initializers, _currentKey_extraInitializers);
|
|
129
152
|
__esDecorate(_a, null, _cache_decorators, { kind: "accessor", name: "cache", static: false, private: false, access: { has: obj => "cache" in obj, get: obj => obj.cache, set: (obj, value) => { obj.cache = value; } }, metadata: _metadata }, _cache_initializers, _cache_extraInitializers);
|
|
130
153
|
__esDecorate(_a, null, _get_value_decorators, { kind: "getter", name: "value", static: false, private: false, access: { has: obj => "value" in obj, get: obj => obj.value }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
131
154
|
__esDecorate(_a, null, _get_empty_decorators, { kind: "getter", name: "empty", static: false, private: false, access: { has: obj => "empty" in obj, get: obj => obj.empty }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
132
155
|
__esDecorate(_a, null, _handle_decorators, { kind: "method", name: "handle", static: false, private: false, access: { has: obj => "handle" in obj, get: obj => obj.handle }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
156
|
+
__esDecorate(_a, null, _clear_decorators, { kind: "method", name: "clear", static: false, private: false, access: { has: obj => "clear" in obj, get: obj => obj.clear }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
133
157
|
if (_metadata) Object.defineProperty(_a, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
134
158
|
})(),
|
|
135
159
|
_a;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
2
|
+
import { runInAction } from 'mobx';
|
|
2
3
|
import { SideCache } from './side-cache';
|
|
3
4
|
describe('SideCache', () => {
|
|
4
5
|
let cache;
|
|
@@ -176,4 +177,95 @@ describe('SideCache', () => {
|
|
|
176
177
|
}
|
|
177
178
|
});
|
|
178
179
|
});
|
|
180
|
+
describe('clear 方法', () => {
|
|
181
|
+
it('应该能够清除指定 key 的缓存', () => {
|
|
182
|
+
const mockFunc = vi.fn(() => 'test-result');
|
|
183
|
+
const key = 'test-key';
|
|
184
|
+
// 先添加缓存
|
|
185
|
+
cache.handle(key, mockFunc);
|
|
186
|
+
expect(cache.empty).toBe(false);
|
|
187
|
+
expect(cache.value).toBe('test-result');
|
|
188
|
+
// 清除指定 key 的缓存
|
|
189
|
+
cache.clear(key);
|
|
190
|
+
expect(cache.empty).toBe(true);
|
|
191
|
+
expect(cache.value).toBe(undefined);
|
|
192
|
+
});
|
|
193
|
+
it('应该能够清除当前激活的缓存', () => {
|
|
194
|
+
const mockFunc = vi.fn(() => 'active-result');
|
|
195
|
+
const key = 'active-key';
|
|
196
|
+
cache.handle(key, mockFunc);
|
|
197
|
+
expect(cache.value).toBe('active-result');
|
|
198
|
+
// 清除当前激活的 key
|
|
199
|
+
cache.clear(key);
|
|
200
|
+
expect(cache.value).toBe(undefined);
|
|
201
|
+
expect(cache.empty).toBe(true);
|
|
202
|
+
});
|
|
203
|
+
it('应该能够清除所有缓存', () => {
|
|
204
|
+
const mockFunc1 = vi.fn(() => 'result1');
|
|
205
|
+
const mockFunc2 = vi.fn(() => 'result2');
|
|
206
|
+
// 添加多个缓存
|
|
207
|
+
cache.handle('key1', mockFunc1);
|
|
208
|
+
cache.handle('key2', mockFunc2);
|
|
209
|
+
expect(cache.value).toBe('result2');
|
|
210
|
+
expect(cache.empty).toBe(false);
|
|
211
|
+
// 清除所有缓存
|
|
212
|
+
cache.clear();
|
|
213
|
+
expect(cache.value).toBe(undefined);
|
|
214
|
+
expect(cache.empty).toBe(true);
|
|
215
|
+
});
|
|
216
|
+
it('应该能够清除非当前激活的缓存而不影响当前状态', () => {
|
|
217
|
+
const mockFunc1 = vi.fn(() => 'result1');
|
|
218
|
+
const mockFunc2 = vi.fn(() => 'result2');
|
|
219
|
+
// 添加两个缓存
|
|
220
|
+
cache.handle('key1', mockFunc1);
|
|
221
|
+
cache.handle('key2', mockFunc2);
|
|
222
|
+
expect(cache.value).toBe('result2'); // 当前激活的是 key2
|
|
223
|
+
// 清除非当前激活的 key1
|
|
224
|
+
cache.clear('key1');
|
|
225
|
+
expect(cache.value).toBe('result2'); // 当前值不变
|
|
226
|
+
expect(cache.empty).toBe(false); // 仍有缓存存在
|
|
227
|
+
});
|
|
228
|
+
it('应该正确处理清除不存在的 key', () => {
|
|
229
|
+
const mockFunc = vi.fn(() => 'test-result');
|
|
230
|
+
cache.handle('existing-key', mockFunc);
|
|
231
|
+
// 清除不存在的 key 不应该影响现有缓存
|
|
232
|
+
cache.clear('non-existing-key');
|
|
233
|
+
expect(cache.value).toBe('test-result');
|
|
234
|
+
expect(cache.empty).toBe(false);
|
|
235
|
+
});
|
|
236
|
+
it('应该正确处理复杂对象作为 key', () => {
|
|
237
|
+
const complexKey = { id: 1, data: { nested: 'value' } };
|
|
238
|
+
const mockFunc = vi.fn(() => 'complex-result');
|
|
239
|
+
// 使用复杂对象作为 key
|
|
240
|
+
cache.handle(complexKey, mockFunc);
|
|
241
|
+
expect(cache.value).toBe('complex-result');
|
|
242
|
+
// 清除复杂对象 key
|
|
243
|
+
cache.clear(complexKey);
|
|
244
|
+
expect(cache.value).toBe(undefined);
|
|
245
|
+
expect(cache.empty).toBe(true);
|
|
246
|
+
});
|
|
247
|
+
it('应该正确处理 undefined 作为 key', () => {
|
|
248
|
+
const mockFunc = vi.fn(() => 'undefined-key-result');
|
|
249
|
+
// 使用 undefined 作为 key
|
|
250
|
+
cache.handle(undefined, mockFunc);
|
|
251
|
+
expect(cache.value).toBe('undefined-key-result');
|
|
252
|
+
// 清除 undefined key
|
|
253
|
+
cache.clear(undefined);
|
|
254
|
+
expect(cache.value).toBe(undefined);
|
|
255
|
+
expect(cache.empty).toBe(true);
|
|
256
|
+
});
|
|
257
|
+
it('应该在 MobX action 中正确更新状态', () => {
|
|
258
|
+
const mockFunc = vi.fn(() => 'action-result');
|
|
259
|
+
const key = 'action-key';
|
|
260
|
+
runInAction(() => {
|
|
261
|
+
cache.handle(key, mockFunc);
|
|
262
|
+
});
|
|
263
|
+
expect(cache.value).toBe('action-result');
|
|
264
|
+
runInAction(() => {
|
|
265
|
+
cache.clear(key);
|
|
266
|
+
});
|
|
267
|
+
expect(cache.value).toBe(undefined);
|
|
268
|
+
expect(cache.empty).toBe(true);
|
|
269
|
+
});
|
|
270
|
+
});
|
|
179
271
|
});
|
package/package.json
CHANGED
|
@@ -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,120 +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 * as Headless from '@headlessui/react';
|
|
14
|
-
import clsx from 'clsx';
|
|
15
|
-
import { useState } from 'react';
|
|
16
|
-
export function Combobox(_a) {
|
|
17
|
-
var { options, displayValue, filter, anchor = 'bottom', className, placeholder, autoFocus, 'aria-label': ariaLabel, children } = _a, props = __rest(_a, ["options", "displayValue", "filter", "anchor", "className", "placeholder", "autoFocus", 'aria-label', "children"]);
|
|
18
|
-
const [query, setQuery] = useState('');
|
|
19
|
-
const filteredOptions = query === ''
|
|
20
|
-
? options
|
|
21
|
-
: options.filter((option) => { var _a; return filter ? filter(option, query) : (_a = displayValue(option)) === null || _a === void 0 ? void 0 : _a.toLowerCase().includes(query.toLowerCase()); });
|
|
22
|
-
return (<Headless.Combobox {...props} multiple={false} virtual={{ options: filteredOptions }} onClose={() => setQuery('')}>
|
|
23
|
-
<span data-slot="control" className={clsx([
|
|
24
|
-
className,
|
|
25
|
-
// Basic layout
|
|
26
|
-
'relative block w-full',
|
|
27
|
-
// Background color + shadow applied to inset pseudo element, so shadow blends with border in light mode
|
|
28
|
-
'before:absolute before:inset-px before:rounded-[calc(var(--radius-lg)-1px)] before:bg-white before:shadow-sm',
|
|
29
|
-
// Background color is moved to control and shadow is removed in dark mode so hide `before` pseudo
|
|
30
|
-
'dark:before:hidden',
|
|
31
|
-
// Focus ring
|
|
32
|
-
'after:pointer-events-none after:absolute after:inset-0 after:rounded-lg after:ring-transparent after:ring-inset sm:focus-within:after:ring-2 sm:focus-within:after:ring-blue-500',
|
|
33
|
-
// Disabled state
|
|
34
|
-
'has-data-disabled:opacity-50 has-data-disabled:before:bg-zinc-950/5 has-data-disabled:before:shadow-none',
|
|
35
|
-
// Invalid state
|
|
36
|
-
'has-data-invalid:before:shadow-red-500/10',
|
|
37
|
-
])}>
|
|
38
|
-
<Headless.ComboboxInput autoFocus={autoFocus} data-slot="control" aria-label={ariaLabel} displayValue={(option) => { var _a; return (_a = displayValue(option)) !== null && _a !== void 0 ? _a : ''; }} onChange={(event) => setQuery(event.target.value)} placeholder={placeholder} className={clsx([
|
|
39
|
-
className,
|
|
40
|
-
// Basic layout
|
|
41
|
-
'relative block w-full appearance-none rounded-lg py-[calc(--spacing(2.5)-1px)] sm:py-[calc(--spacing(1.5)-1px)]',
|
|
42
|
-
// Horizontal padding
|
|
43
|
-
'pr-[calc(--spacing(10)-1px)] pl-[calc(--spacing(3.5)-1px)] sm:pr-[calc(--spacing(9)-1px)] sm:pl-[calc(--spacing(3)-1px)]',
|
|
44
|
-
// Typography
|
|
45
|
-
'text-base/6 text-zinc-950 placeholder:text-zinc-500 sm:text-sm/6 dark:text-white',
|
|
46
|
-
// Border
|
|
47
|
-
'border border-zinc-950/10 data-hover:border-zinc-950/20 dark:border-white/10 dark:data-hover:border-white/20',
|
|
48
|
-
// Background color
|
|
49
|
-
'bg-transparent dark:bg-white/5',
|
|
50
|
-
// Hide default focus styles
|
|
51
|
-
'focus:outline-hidden',
|
|
52
|
-
// Invalid state
|
|
53
|
-
'data-invalid:border-red-500 data-invalid:data-hover:border-red-500 dark:data-invalid:border-red-500 dark:data-invalid:data-hover:border-red-500',
|
|
54
|
-
// Disabled state
|
|
55
|
-
'data-disabled:border-zinc-950/20 dark:data-disabled:border-white/15 dark:data-disabled:bg-white/2.5 dark:data-hover:data-disabled:border-white/15',
|
|
56
|
-
// System icons
|
|
57
|
-
'dark:scheme-dark',
|
|
58
|
-
])}/>
|
|
59
|
-
<Headless.ComboboxButton className="group absolute inset-y-0 right-0 flex items-center px-2">
|
|
60
|
-
<svg className="size-5 stroke-zinc-500 group-data-disabled:stroke-zinc-600 group-data-hover:stroke-zinc-700 sm:size-4 dark:stroke-zinc-400 dark:group-data-hover:stroke-zinc-300 forced-colors:stroke-[CanvasText]" viewBox="0 0 16 16" aria-hidden="true" fill="none">
|
|
61
|
-
<path d="M5.75 10.75L8 13L10.25 10.75" strokeWidth={1.5} strokeLinecap="round" strokeLinejoin="round"/>
|
|
62
|
-
<path d="M10.25 5.25L8 3L5.75 5.25" strokeWidth={1.5} strokeLinecap="round" strokeLinejoin="round"/>
|
|
63
|
-
</svg>
|
|
64
|
-
</Headless.ComboboxButton>
|
|
65
|
-
</span>
|
|
66
|
-
<Headless.ComboboxOptions transition anchor={anchor} className={clsx(
|
|
67
|
-
// Anchor positioning
|
|
68
|
-
'[--anchor-gap:--spacing(2)] [--anchor-padding:--spacing(4)] sm:data-[anchor~=start]:[--anchor-offset:-4px]',
|
|
69
|
-
// Base styles,
|
|
70
|
-
'isolate min-w-[calc(var(--input-width)+8px)] scroll-py-1 rounded-xl p-1 select-none empty:invisible',
|
|
71
|
-
// Invisible border that is only visible in `forced-colors` mode for accessibility purposes
|
|
72
|
-
'outline outline-transparent focus:outline-hidden',
|
|
73
|
-
// Handle scrolling when menu won't fit in viewport
|
|
74
|
-
'overflow-y-scroll overscroll-contain',
|
|
75
|
-
// Popover background
|
|
76
|
-
'bg-white/75 backdrop-blur-xl dark:bg-zinc-800/75',
|
|
77
|
-
// Shadows
|
|
78
|
-
'shadow-lg ring-1 ring-zinc-950/10 dark:ring-white/10 dark:ring-inset',
|
|
79
|
-
// Transitions
|
|
80
|
-
'transition-opacity duration-100 ease-in data-closed:data-leave:opacity-0 data-transition:pointer-events-none')}>
|
|
81
|
-
{({ option }) => children(option)}
|
|
82
|
-
</Headless.ComboboxOptions>
|
|
83
|
-
</Headless.Combobox>);
|
|
84
|
-
}
|
|
85
|
-
export function ComboboxOption(_a) {
|
|
86
|
-
var { children, className } = _a, props = __rest(_a, ["children", "className"]);
|
|
87
|
-
let sharedClasses = clsx(
|
|
88
|
-
// Base
|
|
89
|
-
'flex min-w-0 items-center',
|
|
90
|
-
// Icons
|
|
91
|
-
'*:data-[slot=icon]:size-5 *:data-[slot=icon]:shrink-0 sm:*:data-[slot=icon]:size-4', '*:data-[slot=icon]:text-zinc-500 group-data-focus/option:*:data-[slot=icon]:text-white dark:*:data-[slot=icon]:text-zinc-400', 'forced-colors:*:data-[slot=icon]:text-[CanvasText] forced-colors:group-data-focus/option:*:data-[slot=icon]:text-[Canvas]',
|
|
92
|
-
// Avatars
|
|
93
|
-
'*:data-[slot=avatar]:-mx-0.5 *:data-[slot=avatar]:size-6 sm:*:data-[slot=avatar]:size-5');
|
|
94
|
-
return (<Headless.ComboboxOption {...props} className={clsx(
|
|
95
|
-
// Basic layout
|
|
96
|
-
'group/option grid w-full cursor-default grid-cols-[1fr_--spacing(5)] items-baseline gap-x-2 rounded-lg py-2.5 pr-2 pl-3.5 sm:grid-cols-[1fr_--spacing(4)] sm:py-1.5 sm:pr-2 sm:pl-3',
|
|
97
|
-
// Typography
|
|
98
|
-
'text-base/6 text-zinc-950 sm:text-sm/6 dark:text-white forced-colors:text-[CanvasText]',
|
|
99
|
-
// Focus
|
|
100
|
-
'outline-hidden data-focus:bg-blue-500 data-focus:text-white',
|
|
101
|
-
// Forced colors mode
|
|
102
|
-
'forced-color-adjust-none forced-colors:data-focus:bg-[Highlight] forced-colors:data-focus:text-[HighlightText]',
|
|
103
|
-
// Disabled
|
|
104
|
-
'data-disabled:opacity-50')}>
|
|
105
|
-
<span className={clsx(className, sharedClasses)}>{children}</span>
|
|
106
|
-
<svg className="relative col-start-2 hidden size-5 self-center stroke-current group-data-selected/option:inline sm:size-4" viewBox="0 0 16 16" fill="none" aria-hidden="true">
|
|
107
|
-
<path d="M4 8.5l3 3L12 4" strokeWidth={1.5} strokeLinecap="round" strokeLinejoin="round"/>
|
|
108
|
-
</svg>
|
|
109
|
-
</Headless.ComboboxOption>);
|
|
110
|
-
}
|
|
111
|
-
export function ComboboxLabel(_a) {
|
|
112
|
-
var { className } = _a, props = __rest(_a, ["className"]);
|
|
113
|
-
return <span {...props} className={clsx(className, 'ml-2.5 truncate first:ml-0 sm:ml-2 sm:first:ml-0')}/>;
|
|
114
|
-
}
|
|
115
|
-
export function ComboboxDescription(_a) {
|
|
116
|
-
var { className, children } = _a, props = __rest(_a, ["className", "children"]);
|
|
117
|
-
return (<span {...props} className={clsx(className, 'flex flex-1 overflow-hidden text-zinc-500 group-data-focus/option:text-white before:w-2 before:min-w-0 before:shrink dark:text-zinc-400')}>
|
|
118
|
-
<span className="flex-1 truncate">{children}</span>
|
|
119
|
-
</span>);
|
|
120
|
-
}
|
|
@@ -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 Dialog(_a) {
|
|
27
|
-
var { size = 'lg', 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/25 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] justify-items-center sm:grid-rows-[1fr_auto_3fr] sm:p-4">
|
|
33
|
-
<Headless.DialogPanel transition className={clsx(className, sizes[size], 'row-start-2 w-full min-w-0 rounded-t-3xl bg-white p-(--gutter) shadow-lg ring-1 ring-zinc-950/10 [--gutter:--spacing(8)] sm:mb-auto sm:rounded-2xl dark:bg-zinc-900 dark:ring-white/10 forced-colors:outline', 'transition duration-100 will-change-transform data-closed:translate-y-12 data-closed:opacity-0 data-enter:ease-out data-leave:ease-in sm:data-closed:translate-y-0 sm:data-closed:data-enter:scale-95')}>
|
|
34
|
-
{children}
|
|
35
|
-
</Headless.DialogPanel>
|
|
36
|
-
</div>
|
|
37
|
-
</div>
|
|
38
|
-
</Headless.Dialog>);
|
|
39
|
-
}
|
|
40
|
-
export function DialogTitle(_a) {
|
|
41
|
-
var { className } = _a, props = __rest(_a, ["className"]);
|
|
42
|
-
return (<Headless.DialogTitle {...props} className={clsx(className, 'text-lg/6 font-semibold text-balance text-zinc-950 sm:text-base/6 dark:text-white')}/>);
|
|
43
|
-
}
|
|
44
|
-
export function DialogDescription(_a) {
|
|
45
|
-
var { className } = _a, props = __rest(_a, ["className"]);
|
|
46
|
-
return <Headless.Description as={Text} {...props} className={clsx(className, 'mt-2 text-pretty')}/>;
|
|
47
|
-
}
|
|
48
|
-
export function DialogBody(_a) {
|
|
49
|
-
var { className } = _a, props = __rest(_a, ["className"]);
|
|
50
|
-
return <div {...props} className={clsx(className, 'mt-6')}/>;
|
|
51
|
-
}
|
|
52
|
-
export function DialogActions(_a) {
|
|
53
|
-
var { className } = _a, props = __rest(_a, ["className"]);
|
|
54
|
-
return (<div {...props} className={clsx(className, 'mt-8 flex flex-col-reverse items-center justify-end gap-3 *:w-full sm:flex-row sm:*:w-auto')}/>);
|
|
55
|
-
}
|
|
@@ -1,41 +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
|
-
export function Fieldset(_a) {
|
|
15
|
-
var { className } = _a, props = __rest(_a, ["className"]);
|
|
16
|
-
return (<Headless.Fieldset {...props} className={clsx(className, '*:data-[slot=text]:mt-1 [&>*+[data-slot=control]]:mt-6')}/>);
|
|
17
|
-
}
|
|
18
|
-
export function Legend(_a) {
|
|
19
|
-
var { className } = _a, props = __rest(_a, ["className"]);
|
|
20
|
-
return (<Headless.Legend data-slot="legend" {...props} className={clsx(className, 'text-base/6 font-semibold text-zinc-950 data-disabled:opacity-50 sm:text-sm/6 dark:text-white')}/>);
|
|
21
|
-
}
|
|
22
|
-
export function FieldGroup(_a) {
|
|
23
|
-
var { className } = _a, props = __rest(_a, ["className"]);
|
|
24
|
-
return <div data-slot="control" {...props} className={clsx(className, 'space-y-8')}/>;
|
|
25
|
-
}
|
|
26
|
-
export function Field(_a) {
|
|
27
|
-
var { className } = _a, props = __rest(_a, ["className"]);
|
|
28
|
-
return (<Headless.Field {...props} className={clsx(className, '[&>[data-slot=label]+[data-slot=control]]:mt-3', '[&>[data-slot=label]+[data-slot=description]]:mt-1', '[&>[data-slot=description]+[data-slot=control]]:mt-3', '[&>[data-slot=control]+[data-slot=description]]:mt-3', '[&>[data-slot=control]+[data-slot=error]]:mt-3', '*:data-[slot=label]:font-medium')}/>);
|
|
29
|
-
}
|
|
30
|
-
export function Label(_a) {
|
|
31
|
-
var { className } = _a, props = __rest(_a, ["className"]);
|
|
32
|
-
return (<Headless.Label data-slot="label" {...props} className={clsx(className, 'text-base/6 text-zinc-950 select-none data-disabled:opacity-50 sm:text-sm/6 dark:text-white')}/>);
|
|
33
|
-
}
|
|
34
|
-
export function Description(_a) {
|
|
35
|
-
var { className } = _a, props = __rest(_a, ["className"]);
|
|
36
|
-
return (<Headless.Description data-slot="description" {...props} className={clsx(className, 'text-base/6 text-zinc-500 data-disabled:opacity-50 sm:text-sm/6 dark:text-zinc-400')}/>);
|
|
37
|
-
}
|
|
38
|
-
export function ErrorMessage(_a) {
|
|
39
|
-
var { className } = _a, props = __rest(_a, ["className"]);
|
|
40
|
-
return (<Headless.Description data-slot="error" {...props} className={clsx(className, 'text-base/6 text-red-600 data-disabled:opacity-50 sm:text-sm/6 dark:text-red-500')}/>);
|
|
41
|
-
}
|
|
@@ -1,73 +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
|
-
export function InputGroup({ children }) {
|
|
16
|
-
return (<span data-slot="control" className={clsx('relative isolate block', 'has-[[data-slot=icon]:first-child]:[&_input]:pl-10 has-[[data-slot=icon]:last-child]:[&_input]:pr-10 sm:has-[[data-slot=icon]:first-child]:[&_input]:pl-8 sm:has-[[data-slot=icon]:last-child]:[&_input]:pr-8', '*:data-[slot=icon]:pointer-events-none *:data-[slot=icon]:absolute *:data-[slot=icon]:top-3 *:data-[slot=icon]:z-10 *:data-[slot=icon]:size-5 sm:*:data-[slot=icon]:top-2.5 sm:*:data-[slot=icon]:size-4', '[&>[data-slot=icon]:first-child]:left-3 sm:[&>[data-slot=icon]:first-child]:left-2.5 [&>[data-slot=icon]:last-child]:right-3 sm:[&>[data-slot=icon]:last-child]:right-2.5', '*:data-[slot=icon]:text-zinc-500 dark:*:data-[slot=icon]:text-zinc-400')}>
|
|
17
|
-
{children}
|
|
18
|
-
</span>);
|
|
19
|
-
}
|
|
20
|
-
const dateTypes = ['date', 'datetime-local', 'month', 'time', 'week'];
|
|
21
|
-
export const Input = forwardRef(function Input(_a, ref) {
|
|
22
|
-
var { className } = _a, props = __rest(_a, ["className"]);
|
|
23
|
-
return (<span data-slot="control" className={clsx([
|
|
24
|
-
className,
|
|
25
|
-
// Basic layout
|
|
26
|
-
'relative block w-full',
|
|
27
|
-
// Background color + shadow applied to inset pseudo element, so shadow blends with border in light mode
|
|
28
|
-
'before:absolute before:inset-px before:rounded-[calc(var(--radius-lg)-1px)] before:bg-white before:shadow-sm',
|
|
29
|
-
// Background color is moved to control and shadow is removed in dark mode so hide `before` pseudo
|
|
30
|
-
'dark:before:hidden',
|
|
31
|
-
// Focus ring
|
|
32
|
-
'after:pointer-events-none after:absolute after:inset-0 after:rounded-lg after:ring-transparent after:ring-inset sm:focus-within:after:ring-2 sm:focus-within:after:ring-blue-500',
|
|
33
|
-
// Disabled state
|
|
34
|
-
'has-data-disabled:opacity-50 has-data-disabled:before:bg-zinc-950/5 has-data-disabled:before:shadow-none',
|
|
35
|
-
// Invalid state
|
|
36
|
-
'has-data-invalid:before:shadow-red-500/10',
|
|
37
|
-
])}>
|
|
38
|
-
<Headless.Input ref={ref} {...props} className={clsx([
|
|
39
|
-
// Date classes
|
|
40
|
-
props.type &&
|
|
41
|
-
dateTypes.includes(props.type) && [
|
|
42
|
-
'[&::-webkit-datetime-edit-fields-wrapper]:p-0',
|
|
43
|
-
'[&::-webkit-date-and-time-value]:min-h-[1.5em]',
|
|
44
|
-
'[&::-webkit-datetime-edit]:inline-flex',
|
|
45
|
-
'[&::-webkit-datetime-edit]:p-0',
|
|
46
|
-
'[&::-webkit-datetime-edit-year-field]:p-0',
|
|
47
|
-
'[&::-webkit-datetime-edit-month-field]:p-0',
|
|
48
|
-
'[&::-webkit-datetime-edit-day-field]:p-0',
|
|
49
|
-
'[&::-webkit-datetime-edit-hour-field]:p-0',
|
|
50
|
-
'[&::-webkit-datetime-edit-minute-field]:p-0',
|
|
51
|
-
'[&::-webkit-datetime-edit-second-field]:p-0',
|
|
52
|
-
'[&::-webkit-datetime-edit-millisecond-field]:p-0',
|
|
53
|
-
'[&::-webkit-datetime-edit-meridiem-field]:p-0',
|
|
54
|
-
],
|
|
55
|
-
// Basic layout
|
|
56
|
-
'relative block w-full appearance-none rounded-lg px-[calc(--spacing(3.5)-1px)] py-[calc(--spacing(2.5)-1px)] sm:px-[calc(--spacing(3)-1px)] sm:py-[calc(--spacing(1.5)-1px)]',
|
|
57
|
-
// Typography
|
|
58
|
-
'text-base/6 text-zinc-950 placeholder:text-zinc-500 sm:text-sm/6 dark:text-white',
|
|
59
|
-
// Border
|
|
60
|
-
'border border-zinc-950/10 data-hover:border-zinc-950/20 dark:border-white/10 dark:data-hover:border-white/20',
|
|
61
|
-
// Background color
|
|
62
|
-
'bg-transparent dark:bg-white/5',
|
|
63
|
-
// Hide default focus styles
|
|
64
|
-
'focus:outline-hidden',
|
|
65
|
-
// Invalid state
|
|
66
|
-
'data-invalid:border-red-500 data-invalid:data-hover:border-red-500 dark:data-invalid:border-red-500 dark:data-invalid:data-hover:border-red-500',
|
|
67
|
-
// Disabled state
|
|
68
|
-
'data-disabled:border-zinc-950/20 dark:data-disabled:border-white/15 dark:data-disabled:bg-white/2.5 dark:data-hover:data-disabled:border-white/15',
|
|
69
|
-
// System icons
|
|
70
|
-
'dark:scheme-dark',
|
|
71
|
-
])}/>
|
|
72
|
-
</span>);
|
|
73
|
-
});
|