@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
|
@@ -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 { Fragment } from 'react';
|
|
16
|
-
export function Listbox(_a) {
|
|
17
|
-
var { className, placeholder, autoFocus, 'aria-label': ariaLabel, children: options } = _a, props = __rest(_a, ["className", "placeholder", "autoFocus", 'aria-label', "children"]);
|
|
18
|
-
return (<Headless.Listbox {...props} multiple={false}>
|
|
19
|
-
<Headless.ListboxButton autoFocus={autoFocus} data-slot="control" aria-label={ariaLabel} className={clsx([
|
|
20
|
-
className,
|
|
21
|
-
// Basic layout
|
|
22
|
-
'group relative block w-full',
|
|
23
|
-
// Background color + shadow applied to inset pseudo element, so shadow blends with border in light mode
|
|
24
|
-
'before:absolute before:inset-px before:rounded-[calc(var(--radius-lg)-1px)] before:bg-white before:shadow-sm',
|
|
25
|
-
// Background color is moved to control and shadow is removed in dark mode so hide `before` pseudo
|
|
26
|
-
'dark:before:hidden',
|
|
27
|
-
// Hide default focus styles
|
|
28
|
-
'focus:outline-hidden',
|
|
29
|
-
// Focus ring
|
|
30
|
-
'after:pointer-events-none after:absolute after:inset-0 after:rounded-lg after:ring-transparent after:ring-inset data-focus:after:ring-2 data-focus:after:ring-blue-500',
|
|
31
|
-
// Disabled state
|
|
32
|
-
'data-disabled:opacity-50 data-disabled:before:bg-zinc-950/5 data-disabled:before:shadow-none',
|
|
33
|
-
])}>
|
|
34
|
-
<Headless.ListboxSelectedOption as="span" options={options} placeholder={placeholder && <span className="block truncate text-zinc-500">{placeholder}</span>} className={clsx([
|
|
35
|
-
// Basic layout
|
|
36
|
-
'relative block w-full appearance-none rounded-lg py-[calc(--spacing(2.5)-1px)] sm:py-[calc(--spacing(1.5)-1px)]',
|
|
37
|
-
// Set minimum height for when no value is selected
|
|
38
|
-
'min-h-11 sm:min-h-9',
|
|
39
|
-
// Horizontal padding
|
|
40
|
-
'pr-[calc(--spacing(7)-1px)] pl-[calc(--spacing(3.5)-1px)] sm:pl-[calc(--spacing(3)-1px)]',
|
|
41
|
-
// Typography
|
|
42
|
-
'text-left text-base/6 text-zinc-950 placeholder:text-zinc-500 sm:text-sm/6 dark:text-white forced-colors:text-[CanvasText]',
|
|
43
|
-
// Border
|
|
44
|
-
'border border-zinc-950/10 group-data-active:border-zinc-950/20 group-data-hover:border-zinc-950/20 dark:border-white/10 dark:group-data-active:border-white/20 dark:group-data-hover:border-white/20',
|
|
45
|
-
// Background color
|
|
46
|
-
'bg-transparent dark:bg-white/5',
|
|
47
|
-
// Invalid state
|
|
48
|
-
'group-data-invalid:border-red-500 group-data-hover:group-data-invalid:border-red-500 dark:group-data-invalid:border-red-600 dark:data-hover:group-data-invalid:border-red-600',
|
|
49
|
-
// Disabled state
|
|
50
|
-
'group-data-disabled:border-zinc-950/20 group-data-disabled:opacity-100 dark:group-data-disabled:border-white/15 dark:group-data-disabled:bg-white/2.5 dark:group-data-disabled:data-hover:border-white/15',
|
|
51
|
-
])}/>
|
|
52
|
-
<span className="pointer-events-none absolute inset-y-0 right-0 flex items-center pr-2">
|
|
53
|
-
<svg className="size-5 stroke-zinc-500 group-data-disabled:stroke-zinc-600 sm:size-4 dark:stroke-zinc-400 forced-colors:stroke-[CanvasText]" viewBox="0 0 16 16" aria-hidden="true" fill="none">
|
|
54
|
-
<path d="M5.75 10.75L8 13L10.25 10.75" strokeWidth={1.5} strokeLinecap="round" strokeLinejoin="round"/>
|
|
55
|
-
<path d="M10.25 5.25L8 3L5.75 5.25" strokeWidth={1.5} strokeLinecap="round" strokeLinejoin="round"/>
|
|
56
|
-
</svg>
|
|
57
|
-
</span>
|
|
58
|
-
</Headless.ListboxButton>
|
|
59
|
-
<Headless.ListboxOptions transition anchor="selection start" className={clsx(
|
|
60
|
-
// Anchor positioning
|
|
61
|
-
'[--anchor-offset:-1.625rem] [--anchor-padding:--spacing(4)] sm:[--anchor-offset:-1.375rem]',
|
|
62
|
-
// Base styles
|
|
63
|
-
'isolate w-max min-w-[calc(var(--button-width)+1.75rem)] scroll-py-1 rounded-xl p-1 select-none',
|
|
64
|
-
// Invisible border that is only visible in `forced-colors` mode for accessibility purposes
|
|
65
|
-
'outline outline-transparent focus:outline-hidden',
|
|
66
|
-
// Handle scrolling when menu won't fit in viewport
|
|
67
|
-
'overflow-y-scroll overscroll-contain',
|
|
68
|
-
// Popover background
|
|
69
|
-
'bg-white/75 backdrop-blur-xl dark:bg-zinc-800/75',
|
|
70
|
-
// Shadows
|
|
71
|
-
'shadow-lg ring-1 ring-zinc-950/10 dark:ring-white/10 dark:ring-inset',
|
|
72
|
-
// Transitions
|
|
73
|
-
'transition-opacity duration-100 ease-in data-closed:data-leave:opacity-0 data-transition:pointer-events-none')}>
|
|
74
|
-
{options}
|
|
75
|
-
</Headless.ListboxOptions>
|
|
76
|
-
</Headless.Listbox>);
|
|
77
|
-
}
|
|
78
|
-
export function ListboxOption(_a) {
|
|
79
|
-
var { children, className } = _a, props = __rest(_a, ["children", "className"]);
|
|
80
|
-
let sharedClasses = clsx(
|
|
81
|
-
// Base
|
|
82
|
-
'flex min-w-0 items-center',
|
|
83
|
-
// Icons
|
|
84
|
-
'*: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]',
|
|
85
|
-
// Avatars
|
|
86
|
-
'*:data-[slot=avatar]:-mx-0.5 *:data-[slot=avatar]:size-6 sm:*:data-[slot=avatar]:size-5');
|
|
87
|
-
return (<Headless.ListboxOption as={Fragment} {...props}>
|
|
88
|
-
{({ selectedOption }) => {
|
|
89
|
-
if (selectedOption) {
|
|
90
|
-
return <div className={clsx(className, sharedClasses)}>{children}</div>;
|
|
91
|
-
}
|
|
92
|
-
return (<div className={clsx(
|
|
93
|
-
// Basic layout
|
|
94
|
-
'group/option grid cursor-default grid-cols-[--spacing(5)_1fr] items-baseline gap-x-2 rounded-lg py-2.5 pr-3.5 pl-2 sm:grid-cols-[--spacing(4)_1fr] sm:py-1.5 sm:pr-3 sm:pl-1.5',
|
|
95
|
-
// Typography
|
|
96
|
-
'text-base/6 text-zinc-950 sm:text-sm/6 dark:text-white forced-colors:text-[CanvasText]',
|
|
97
|
-
// Focus
|
|
98
|
-
'outline-hidden data-focus:bg-blue-500 data-focus:text-white',
|
|
99
|
-
// Forced colors mode
|
|
100
|
-
'forced-color-adjust-none forced-colors:data-focus:bg-[Highlight] forced-colors:data-focus:text-[HighlightText]',
|
|
101
|
-
// Disabled
|
|
102
|
-
'data-disabled:opacity-50')}>
|
|
103
|
-
<svg className="relative 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">
|
|
104
|
-
<path d="M4 8.5l3 3L12 4" strokeWidth={1.5} strokeLinecap="round" strokeLinejoin="round"/>
|
|
105
|
-
</svg>
|
|
106
|
-
<span className={clsx(className, sharedClasses, 'col-start-2')}>{children}</span>
|
|
107
|
-
</div>);
|
|
108
|
-
}}
|
|
109
|
-
</Headless.ListboxOption>);
|
|
110
|
-
}
|
|
111
|
-
export function ListboxLabel(_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 ListboxDescription(_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,52 +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 clsx from 'clsx';
|
|
13
|
-
import { Button } from './button';
|
|
14
|
-
export function Pagination(_a) {
|
|
15
|
-
var { 'aria-label': ariaLabel = 'Page navigation', className } = _a, props = __rest(_a, ['aria-label', "className"]);
|
|
16
|
-
return <nav aria-label={ariaLabel} {...props} className={clsx(className, 'flex gap-x-2')}/>;
|
|
17
|
-
}
|
|
18
|
-
export function PaginationPrevious({ href = null, className, children = 'Previous', }) {
|
|
19
|
-
return (<span className={clsx(className, 'grow basis-0')}>
|
|
20
|
-
<Button {...(href === null ? { disabled: true } : { href })} plain aria-label="Previous page">
|
|
21
|
-
<svg className="stroke-current" data-slot="icon" viewBox="0 0 16 16" fill="none" aria-hidden="true">
|
|
22
|
-
<path d="M2.75 8H13.25M2.75 8L5.25 5.5M2.75 8L5.25 10.5" strokeWidth={1.5} strokeLinecap="round" strokeLinejoin="round"/>
|
|
23
|
-
</svg>
|
|
24
|
-
{children}
|
|
25
|
-
</Button>
|
|
26
|
-
</span>);
|
|
27
|
-
}
|
|
28
|
-
export function PaginationNext({ href = null, className, children = 'Next', }) {
|
|
29
|
-
return (<span className={clsx(className, 'flex grow basis-0 justify-end')}>
|
|
30
|
-
<Button {...(href === null ? { disabled: true } : { href })} plain aria-label="Next page">
|
|
31
|
-
{children}
|
|
32
|
-
<svg className="stroke-current" data-slot="icon" viewBox="0 0 16 16" fill="none" aria-hidden="true">
|
|
33
|
-
<path d="M13.25 8L2.75 8M13.25 8L10.75 10.5M13.25 8L10.75 5.5" strokeWidth={1.5} strokeLinecap="round" strokeLinejoin="round"/>
|
|
34
|
-
</svg>
|
|
35
|
-
</Button>
|
|
36
|
-
</span>);
|
|
37
|
-
}
|
|
38
|
-
export function PaginationList(_a) {
|
|
39
|
-
var { className } = _a, props = __rest(_a, ["className"]);
|
|
40
|
-
return <span {...props} className={clsx(className, 'hidden items-baseline gap-x-2 sm:flex')}/>;
|
|
41
|
-
}
|
|
42
|
-
export function PaginationPage({ href, className, current = false, children, }) {
|
|
43
|
-
return (<Button href={href} plain aria-label={`Page ${children}`} aria-current={current ? 'page' : undefined} className={clsx(className, 'min-w-9 before:absolute before:-inset-px before:rounded-lg', current && 'before:bg-zinc-950/5 dark:before:bg-white/10')}>
|
|
44
|
-
<span className="-mx-0.5">{children}</span>
|
|
45
|
-
</Button>);
|
|
46
|
-
}
|
|
47
|
-
export function PaginationGap(_a) {
|
|
48
|
-
var { className, children = <>…</> } = _a, props = __rest(_a, ["className", "children"]);
|
|
49
|
-
return (<span aria-hidden="true" {...props} className={clsx(className, 'w-9 text-center text-sm/6 font-semibold text-zinc-950 select-none dark:text-white')}>
|
|
50
|
-
{children}
|
|
51
|
-
</span>);
|
|
52
|
-
}
|
|
@@ -1,59 +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 const Select = forwardRef(function Select(_a, ref) {
|
|
16
|
-
var { className, multiple } = _a, props = __rest(_a, ["className", "multiple"]);
|
|
17
|
-
return (<span data-slot="control" className={clsx([
|
|
18
|
-
className,
|
|
19
|
-
// Basic layout
|
|
20
|
-
'group relative block w-full',
|
|
21
|
-
// Background color + shadow applied to inset pseudo element, so shadow blends with border in light mode
|
|
22
|
-
'before:absolute before:inset-px before:rounded-[calc(var(--radius-lg)-1px)] before:bg-white before:shadow-sm',
|
|
23
|
-
// Background color is moved to control and shadow is removed in dark mode so hide `before` pseudo
|
|
24
|
-
'dark:before:hidden',
|
|
25
|
-
// Focus ring
|
|
26
|
-
'after:pointer-events-none after:absolute after:inset-0 after:rounded-lg after:ring-transparent after:ring-inset has-data-focus:after:ring-2 has-data-focus:after:ring-blue-500',
|
|
27
|
-
// Disabled state
|
|
28
|
-
'has-data-disabled:opacity-50 has-data-disabled:before:bg-zinc-950/5 has-data-disabled:before:shadow-none',
|
|
29
|
-
])}>
|
|
30
|
-
<Headless.Select ref={ref} multiple={multiple} {...props} className={clsx([
|
|
31
|
-
// Basic layout
|
|
32
|
-
'relative block w-full appearance-none rounded-lg py-[calc(--spacing(2.5)-1px)] sm:py-[calc(--spacing(1.5)-1px)]',
|
|
33
|
-
// Horizontal padding
|
|
34
|
-
multiple
|
|
35
|
-
? 'px-[calc(--spacing(3.5)-1px)] sm:px-[calc(--spacing(3)-1px)]'
|
|
36
|
-
: 'pr-[calc(--spacing(10)-1px)] pl-[calc(--spacing(3.5)-1px)] sm:pr-[calc(--spacing(9)-1px)] sm:pl-[calc(--spacing(3)-1px)]',
|
|
37
|
-
// Options (multi-select)
|
|
38
|
-
'[&_optgroup]:font-semibold',
|
|
39
|
-
// Typography
|
|
40
|
-
'text-base/6 text-zinc-950 placeholder:text-zinc-500 sm:text-sm/6 dark:text-white dark:*:text-white',
|
|
41
|
-
// Border
|
|
42
|
-
'border border-zinc-950/10 data-hover:border-zinc-950/20 dark:border-white/10 dark:data-hover:border-white/20',
|
|
43
|
-
// Background color
|
|
44
|
-
'bg-transparent dark:bg-white/5 dark:*:bg-zinc-800',
|
|
45
|
-
// Hide default focus styles
|
|
46
|
-
'focus:outline-hidden',
|
|
47
|
-
// Invalid state
|
|
48
|
-
'data-invalid:border-red-500 data-invalid:data-hover:border-red-500 dark:data-invalid:border-red-600 dark:data-invalid:data-hover:border-red-600',
|
|
49
|
-
// Disabled state
|
|
50
|
-
'data-disabled:border-zinc-950/20 data-disabled:opacity-100 dark:data-disabled:border-white/15 dark:data-disabled:bg-white/2.5 dark:data-hover:data-disabled:border-white/15',
|
|
51
|
-
])}/>
|
|
52
|
-
{!multiple && (<span className="pointer-events-none absolute inset-y-0 right-0 flex items-center pr-2">
|
|
53
|
-
<svg className="size-5 stroke-zinc-500 group-has-data-disabled:stroke-zinc-600 sm:size-4 dark:stroke-zinc-400 forced-colors:stroke-[CanvasText]" viewBox="0 0 16 16" aria-hidden="true" fill="none">
|
|
54
|
-
<path d="M5.75 10.75L8 13L10.25 10.75" strokeWidth={1.5} strokeLinecap="round" strokeLinejoin="round"/>
|
|
55
|
-
<path d="M10.25 5.25L8 3L5.75 5.25" strokeWidth={1.5} strokeLinecap="round" strokeLinejoin="round"/>
|
|
56
|
-
</svg>
|
|
57
|
-
</span>)}
|
|
58
|
-
</span>);
|
|
59
|
-
});
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import * as Headless from '@headlessui/react';
|
|
3
|
-
import React, { useState } from 'react';
|
|
4
|
-
import { NavbarItem } from './navbar';
|
|
5
|
-
function OpenMenuIcon() {
|
|
6
|
-
return (<svg data-slot="icon" viewBox="0 0 20 20" aria-hidden="true">
|
|
7
|
-
<path d="M2 6.75C2 6.33579 2.33579 6 2.75 6H17.25C17.6642 6 18 6.33579 18 6.75C18 7.16421 17.6642 7.5 17.25 7.5H2.75C2.33579 7.5 2 7.16421 2 6.75ZM2 13.25C2 12.8358 2.33579 12.5 2.75 12.5H17.25C17.6642 12.5 18 12.8358 18 13.25C18 13.6642 17.6642 14 17.25 14H2.75C2.33579 14 2 13.6642 2 13.25Z"/>
|
|
8
|
-
</svg>);
|
|
9
|
-
}
|
|
10
|
-
function CloseMenuIcon() {
|
|
11
|
-
return (<svg data-slot="icon" viewBox="0 0 20 20" aria-hidden="true">
|
|
12
|
-
<path d="M6.28 5.22a.75.75 0 0 0-1.06 1.06L8.94 10l-3.72 3.72a.75.75 0 1 0 1.06 1.06L10 11.06l3.72 3.72a.75.75 0 1 0 1.06-1.06L11.06 10l3.72-3.72a.75.75 0 0 0-1.06-1.06L10 8.94 6.28 5.22Z"/>
|
|
13
|
-
</svg>);
|
|
14
|
-
}
|
|
15
|
-
function MobileSidebar({ open, close, children }) {
|
|
16
|
-
return (<Headless.Dialog open={open} onClose={close} className="lg:hidden">
|
|
17
|
-
<Headless.DialogBackdrop transition className="fixed inset-0 bg-black/30 transition data-closed:opacity-0 data-enter:duration-300 data-enter:ease-out data-leave:duration-200 data-leave:ease-in"/>
|
|
18
|
-
<Headless.DialogPanel transition className="fixed inset-y-0 w-full max-w-80 p-2 transition duration-300 ease-in-out data-closed:-translate-x-full">
|
|
19
|
-
<div className="flex h-full flex-col rounded-lg bg-white shadow-xs ring-1 ring-zinc-950/5 dark:bg-zinc-900 dark:ring-white/10">
|
|
20
|
-
<div className="-mb-3 px-4 pt-3">
|
|
21
|
-
<Headless.CloseButton as={NavbarItem} aria-label="Close navigation">
|
|
22
|
-
<CloseMenuIcon />
|
|
23
|
-
</Headless.CloseButton>
|
|
24
|
-
</div>
|
|
25
|
-
{children}
|
|
26
|
-
</div>
|
|
27
|
-
</Headless.DialogPanel>
|
|
28
|
-
</Headless.Dialog>);
|
|
29
|
-
}
|
|
30
|
-
export function SidebarLayout({ navbar, sidebar, children, }) {
|
|
31
|
-
let [showSidebar, setShowSidebar] = useState(false);
|
|
32
|
-
return (<div className="relative isolate flex min-h-svh w-full bg-white max-lg:flex-col lg:bg-zinc-100 dark:bg-zinc-900 dark:lg:bg-zinc-950">
|
|
33
|
-
{/* Sidebar on desktop */}
|
|
34
|
-
<div className="fixed inset-y-0 left-0 w-64 max-lg:hidden">{sidebar}</div>
|
|
35
|
-
|
|
36
|
-
{/* Sidebar on mobile */}
|
|
37
|
-
<MobileSidebar open={showSidebar} close={() => setShowSidebar(false)}>
|
|
38
|
-
{sidebar}
|
|
39
|
-
</MobileSidebar>
|
|
40
|
-
|
|
41
|
-
{/* Navbar on mobile */}
|
|
42
|
-
<header className="flex items-center px-4 lg:hidden">
|
|
43
|
-
<div className="py-2.5">
|
|
44
|
-
<NavbarItem onClick={() => setShowSidebar(true)} aria-label="Open navigation">
|
|
45
|
-
<OpenMenuIcon />
|
|
46
|
-
</NavbarItem>
|
|
47
|
-
</div>
|
|
48
|
-
<div className="min-w-0 flex-1">{navbar}</div>
|
|
49
|
-
</header>
|
|
50
|
-
|
|
51
|
-
{/* Content */}
|
|
52
|
-
<main className="flex flex-1 flex-col pb-2 lg:min-w-0 lg:pt-2 lg:pr-2 lg:pl-64">
|
|
53
|
-
<div className="grow 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">
|
|
54
|
-
<div className="mx-auto max-w-6xl">{children}</div>
|
|
55
|
-
</div>
|
|
56
|
-
</main>
|
|
57
|
-
</div>);
|
|
58
|
-
}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import * as Headless from '@headlessui/react';
|
|
3
|
-
import React, { useState } from 'react';
|
|
4
|
-
import { NavbarItem } from './navbar';
|
|
5
|
-
function OpenMenuIcon() {
|
|
6
|
-
return (<svg data-slot="icon" viewBox="0 0 20 20" aria-hidden="true">
|
|
7
|
-
<path d="M2 6.75C2 6.33579 2.33579 6 2.75 6H17.25C17.6642 6 18 6.33579 18 6.75C18 7.16421 17.6642 7.5 17.25 7.5H2.75C2.33579 7.5 2 7.16421 2 6.75ZM2 13.25C2 12.8358 2.33579 12.5 2.75 12.5H17.25C17.6642 12.5 18 12.8358 18 13.25C18 13.6642 17.6642 14 17.25 14H2.75C2.33579 14 2 13.6642 2 13.25Z"/>
|
|
8
|
-
</svg>);
|
|
9
|
-
}
|
|
10
|
-
function CloseMenuIcon() {
|
|
11
|
-
return (<svg data-slot="icon" viewBox="0 0 20 20" aria-hidden="true">
|
|
12
|
-
<path d="M6.28 5.22a.75.75 0 0 0-1.06 1.06L8.94 10l-3.72 3.72a.75.75 0 1 0 1.06 1.06L10 11.06l3.72 3.72a.75.75 0 1 0 1.06-1.06L11.06 10l3.72-3.72a.75.75 0 0 0-1.06-1.06L10 8.94 6.28 5.22Z"/>
|
|
13
|
-
</svg>);
|
|
14
|
-
}
|
|
15
|
-
function MobileSidebar({ open, close, children }) {
|
|
16
|
-
return (<Headless.Dialog open={open} onClose={close} className="lg:hidden">
|
|
17
|
-
<Headless.DialogBackdrop transition className="fixed inset-0 bg-black/30 transition data-closed:opacity-0 data-enter:duration-300 data-enter:ease-out data-leave:duration-200 data-leave:ease-in"/>
|
|
18
|
-
<Headless.DialogPanel transition className="fixed inset-y-0 w-full max-w-80 p-2 transition duration-300 ease-in-out data-closed:-translate-x-full">
|
|
19
|
-
<div className="flex h-full flex-col rounded-lg bg-white shadow-xs ring-1 ring-zinc-950/5 dark:bg-zinc-900 dark:ring-white/10">
|
|
20
|
-
<div className="-mb-3 px-4 pt-3">
|
|
21
|
-
<Headless.CloseButton as={NavbarItem} aria-label="Close navigation">
|
|
22
|
-
<CloseMenuIcon />
|
|
23
|
-
</Headless.CloseButton>
|
|
24
|
-
</div>
|
|
25
|
-
{children}
|
|
26
|
-
</div>
|
|
27
|
-
</Headless.DialogPanel>
|
|
28
|
-
</Headless.Dialog>);
|
|
29
|
-
}
|
|
30
|
-
export function StackedLayout({ navbar, sidebar, children, }) {
|
|
31
|
-
let [showSidebar, setShowSidebar] = useState(false);
|
|
32
|
-
return (<div className="relative isolate flex min-h-svh w-full flex-col bg-white lg:bg-zinc-100 dark:bg-zinc-900 dark:lg:bg-zinc-950">
|
|
33
|
-
{/* Sidebar on mobile */}
|
|
34
|
-
<MobileSidebar open={showSidebar} close={() => setShowSidebar(false)}>
|
|
35
|
-
{sidebar}
|
|
36
|
-
</MobileSidebar>
|
|
37
|
-
|
|
38
|
-
{/* Navbar */}
|
|
39
|
-
<header className="flex items-center px-4">
|
|
40
|
-
<div className="py-2.5 lg:hidden">
|
|
41
|
-
<NavbarItem onClick={() => setShowSidebar(true)} aria-label="Open navigation">
|
|
42
|
-
<OpenMenuIcon />
|
|
43
|
-
</NavbarItem>
|
|
44
|
-
</div>
|
|
45
|
-
<div className="min-w-0 flex-1">{navbar}</div>
|
|
46
|
-
</header>
|
|
47
|
-
|
|
48
|
-
{/* Content */}
|
|
49
|
-
<main className="flex flex-1 flex-col pb-2 lg:px-2">
|
|
50
|
-
<div className="grow 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">
|
|
51
|
-
<div className="mx-auto max-w-6xl">{children}</div>
|
|
52
|
-
</div>
|
|
53
|
-
</main>
|
|
54
|
-
</div>);
|
|
55
|
-
}
|
|
@@ -1,68 +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 clsx from 'clsx';
|
|
14
|
-
import { createContext, useContext, useState } from 'react';
|
|
15
|
-
import { Link } from './link';
|
|
16
|
-
const TableContext = createContext({
|
|
17
|
-
bleed: false,
|
|
18
|
-
dense: false,
|
|
19
|
-
grid: false,
|
|
20
|
-
striped: false,
|
|
21
|
-
});
|
|
22
|
-
export function Table(_a) {
|
|
23
|
-
var { bleed = false, dense = false, grid = false, striped = false, className, children } = _a, props = __rest(_a, ["bleed", "dense", "grid", "striped", "className", "children"]);
|
|
24
|
-
return (<TableContext.Provider value={{ bleed, dense, grid, striped }}>
|
|
25
|
-
<div className="flow-root">
|
|
26
|
-
<div {...props} className={clsx(className, '-mx-(--gutter) overflow-x-auto whitespace-nowrap')}>
|
|
27
|
-
<div className={clsx('inline-block min-w-full align-middle', !bleed && 'sm:px-(--gutter)')}>
|
|
28
|
-
<table className="min-w-full text-left text-sm/6 text-zinc-950 dark:text-white">{children}</table>
|
|
29
|
-
</div>
|
|
30
|
-
</div>
|
|
31
|
-
</div>
|
|
32
|
-
</TableContext.Provider>);
|
|
33
|
-
}
|
|
34
|
-
export function TableHead(_a) {
|
|
35
|
-
var { className } = _a, props = __rest(_a, ["className"]);
|
|
36
|
-
return <thead {...props} className={clsx(className, 'text-zinc-500 dark:text-zinc-400')}/>;
|
|
37
|
-
}
|
|
38
|
-
export function TableBody(props) {
|
|
39
|
-
return <tbody {...props}/>;
|
|
40
|
-
}
|
|
41
|
-
const TableRowContext = createContext({
|
|
42
|
-
href: undefined,
|
|
43
|
-
target: undefined,
|
|
44
|
-
title: undefined,
|
|
45
|
-
});
|
|
46
|
-
export function TableRow(_a) {
|
|
47
|
-
var { href, target, title, className } = _a, props = __rest(_a, ["href", "target", "title", "className"]);
|
|
48
|
-
let { striped } = useContext(TableContext);
|
|
49
|
-
return (<TableRowContext.Provider value={{ href, target, title }}>
|
|
50
|
-
<tr {...props} className={clsx(className, href &&
|
|
51
|
-
'has-[[data-row-link][data-focus]]:outline-2 has-[[data-row-link][data-focus]]:-outline-offset-2 has-[[data-row-link][data-focus]]:outline-blue-500 dark:focus-within:bg-white/2.5', striped && 'even:bg-zinc-950/2.5 dark:even:bg-white/2.5', href && striped && 'hover:bg-zinc-950/5 dark:hover:bg-white/5', href && !striped && 'hover:bg-zinc-950/2.5 dark:hover:bg-white/2.5')}/>
|
|
52
|
-
</TableRowContext.Provider>);
|
|
53
|
-
}
|
|
54
|
-
export function TableHeader(_a) {
|
|
55
|
-
var { className } = _a, props = __rest(_a, ["className"]);
|
|
56
|
-
let { bleed, grid } = useContext(TableContext);
|
|
57
|
-
return (<th {...props} className={clsx(className, 'border-b border-b-zinc-950/10 px-4 py-2 font-medium first:pl-(--gutter,--spacing(2)) last:pr-(--gutter,--spacing(2)) dark:border-b-white/10', grid && 'border-l border-l-zinc-950/5 first:border-l-0 dark:border-l-white/5', !bleed && 'sm:first:pl-1 sm:last:pr-1')}/>);
|
|
58
|
-
}
|
|
59
|
-
export function TableCell(_a) {
|
|
60
|
-
var { className, children } = _a, props = __rest(_a, ["className", "children"]);
|
|
61
|
-
let { bleed, dense, grid, striped } = useContext(TableContext);
|
|
62
|
-
let { href, target, title } = useContext(TableRowContext);
|
|
63
|
-
let [cellRef, setCellRef] = useState(null);
|
|
64
|
-
return (<td ref={href ? setCellRef : undefined} {...props} className={clsx(className, 'relative px-4 first:pl-(--gutter,--spacing(2)) last:pr-(--gutter,--spacing(2))', !striped && 'border-b border-zinc-950/5 dark:border-white/5', grid && 'border-l border-l-zinc-950/5 first:border-l-0 dark:border-l-white/5', dense ? 'py-2.5' : 'py-4', !bleed && 'sm:first:pl-1 sm:last:pr-1')}>
|
|
65
|
-
{href && (<Link data-row-link href={href} target={target} aria-label={title} tabIndex={(cellRef === null || cellRef === void 0 ? void 0 : cellRef.previousElementSibling) === null ? 0 : -1} className="absolute inset-0 focus:outline-hidden"/>)}
|
|
66
|
-
{children}
|
|
67
|
-
</td>);
|
|
68
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
type ApiFunc<P extends unknown[], R = unknown> = (...args: P) => Promise<R>;
|
|
2
|
-
export declare class CacheApi<P extends unknown[], R> {
|
|
3
|
-
private func;
|
|
4
|
-
private cache;
|
|
5
|
-
private accessor pendingRequests;
|
|
6
|
-
constructor(func: ApiFunc<P, R>);
|
|
7
|
-
get loading(): boolean;
|
|
8
|
-
get empty(): boolean;
|
|
9
|
-
get value(): R | undefined;
|
|
10
|
-
send(...args: P): Promise<R>;
|
|
11
|
-
}
|
|
12
|
-
export {};
|
|
13
|
-
//# sourceMappingURL=cache-api.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cache-api.d.ts","sourceRoot":"","sources":["../../../source/helpers/cache-api/cache-api.ts"],"names":[],"mappings":"AAKA,KAAK,OAAO,CAAC,CAAC,SAAS,OAAO,EAAE,EAAE,CAAC,GAAG,OAAO,IAAI,CAAC,GAAG,IAAI,EAAE,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,CAAA;AAE3E,qBAAa,QAAQ,CAAC,CAAC,SAAS,OAAO,EAAE,EAAE,CAAC;IAO9B,OAAO,CAAC,IAAI;IANxB,OAAO,CAAC,KAAK,CAAqB;IAIlC,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAI;gBAEhB,IAAI,EAAE,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC;IAIvC,IACI,OAAO,IAAI,OAAO,CAErB;IAED,IACI,KAAK,IAAI,OAAO,CAEnB;IAED,IACI,KAAK,IAAI,CAAC,GAAG,SAAS,CAEzB;IAGK,IAAI,CAAC,GAAG,IAAI,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;CAmBnC"}
|
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
2
|
-
var useValue = arguments.length > 2;
|
|
3
|
-
for (var i = 0; i < initializers.length; i++) {
|
|
4
|
-
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
5
|
-
}
|
|
6
|
-
return useValue ? value : void 0;
|
|
7
|
-
};
|
|
8
|
-
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
9
|
-
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
10
|
-
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
11
|
-
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
12
|
-
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
13
|
-
var _, done = false;
|
|
14
|
-
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
15
|
-
var context = {};
|
|
16
|
-
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
17
|
-
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
18
|
-
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
19
|
-
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
20
|
-
if (kind === "accessor") {
|
|
21
|
-
if (result === void 0) continue;
|
|
22
|
-
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
23
|
-
if (_ = accept(result.get)) descriptor.get = _;
|
|
24
|
-
if (_ = accept(result.set)) descriptor.set = _;
|
|
25
|
-
if (_ = accept(result.init)) initializers.unshift(_);
|
|
26
|
-
}
|
|
27
|
-
else if (_ = accept(result)) {
|
|
28
|
-
if (kind === "field") initializers.unshift(_);
|
|
29
|
-
else descriptor[key] = _;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
33
|
-
done = true;
|
|
34
|
-
};
|
|
35
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
36
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
37
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
38
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
39
|
-
};
|
|
40
|
-
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
41
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
42
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
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
|
-
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
45
|
-
};
|
|
46
|
-
import { action, computed, observable } from 'mobx';
|
|
47
|
-
import { catchIt } from '@taicode/common-base';
|
|
48
|
-
import { SideCache } from '../side-cache';
|
|
49
|
-
let CacheApi = (() => {
|
|
50
|
-
var _a, _CacheApi_pendingRequests_accessor_storage;
|
|
51
|
-
var _b;
|
|
52
|
-
let _instanceExtraInitializers = [];
|
|
53
|
-
let _pendingRequests_decorators;
|
|
54
|
-
let _pendingRequests_initializers = [];
|
|
55
|
-
let _pendingRequests_extraInitializers = [];
|
|
56
|
-
let _get_loading_decorators;
|
|
57
|
-
let _get_empty_decorators;
|
|
58
|
-
let _get_value_decorators;
|
|
59
|
-
let _send_decorators;
|
|
60
|
-
return _a = class CacheApi {
|
|
61
|
-
// 记录当前正在进行的请求数量
|
|
62
|
-
get pendingRequests() { return __classPrivateFieldGet(this, _CacheApi_pendingRequests_accessor_storage, "f"); }
|
|
63
|
-
set pendingRequests(value) { __classPrivateFieldSet(this, _CacheApi_pendingRequests_accessor_storage, value, "f"); }
|
|
64
|
-
constructor(func) {
|
|
65
|
-
this.func = (__runInitializers(this, _instanceExtraInitializers), func);
|
|
66
|
-
this.cache = new SideCache();
|
|
67
|
-
_CacheApi_pendingRequests_accessor_storage.set(this, __runInitializers(this, _pendingRequests_initializers, 0));
|
|
68
|
-
__runInitializers(this, _pendingRequests_extraInitializers);
|
|
69
|
-
this.func = func;
|
|
70
|
-
this.send = this.send.bind(this);
|
|
71
|
-
}
|
|
72
|
-
get loading() {
|
|
73
|
-
return this.pendingRequests > 0;
|
|
74
|
-
}
|
|
75
|
-
get empty() {
|
|
76
|
-
return this.cache.empty;
|
|
77
|
-
}
|
|
78
|
-
get value() {
|
|
79
|
-
return this.cache.value;
|
|
80
|
-
}
|
|
81
|
-
async send(...args) {
|
|
82
|
-
// 增加待处理请求计数
|
|
83
|
-
this.pendingRequests++;
|
|
84
|
-
const result = await catchIt(async () => {
|
|
85
|
-
return await this.cache.handle(args, async () => {
|
|
86
|
-
return await this.func(...args);
|
|
87
|
-
});
|
|
88
|
-
});
|
|
89
|
-
// 减少待处理请求计数
|
|
90
|
-
this.pendingRequests--;
|
|
91
|
-
if (result.isError()) {
|
|
92
|
-
throw result.error;
|
|
93
|
-
}
|
|
94
|
-
return result.value;
|
|
95
|
-
}
|
|
96
|
-
},
|
|
97
|
-
_CacheApi_pendingRequests_accessor_storage = new WeakMap(),
|
|
98
|
-
(() => {
|
|
99
|
-
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
|
|
100
|
-
_pendingRequests_decorators = [observable];
|
|
101
|
-
_get_loading_decorators = [computed];
|
|
102
|
-
_get_empty_decorators = [computed];
|
|
103
|
-
_get_value_decorators = [computed];
|
|
104
|
-
_send_decorators = [(_b = action).bound.bind(_b)];
|
|
105
|
-
__esDecorate(_a, null, _pendingRequests_decorators, { kind: "accessor", name: "pendingRequests", static: false, private: false, access: { has: obj => "pendingRequests" in obj, get: obj => obj.pendingRequests, set: (obj, value) => { obj.pendingRequests = value; } }, metadata: _metadata }, _pendingRequests_initializers, _pendingRequests_extraInitializers);
|
|
106
|
-
__esDecorate(_a, null, _get_loading_decorators, { kind: "getter", name: "loading", static: false, private: false, access: { has: obj => "loading" in obj, get: obj => obj.loading }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
107
|
-
__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);
|
|
108
|
-
__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);
|
|
109
|
-
__esDecorate(_a, null, _send_decorators, { kind: "method", name: "send", static: false, private: false, access: { has: obj => "send" in obj, get: obj => obj.send }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
110
|
-
if (_metadata) Object.defineProperty(_a, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
111
|
-
})(),
|
|
112
|
-
_a;
|
|
113
|
-
})();
|
|
114
|
-
export { CacheApi };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cache-api.test.d.ts","sourceRoot":"","sources":["../../../source/helpers/cache-api/cache-api.test.ts"],"names":[],"mappings":""}
|