@yimingliao/cms 0.0.80 → 0.0.82
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/dist/client/index.d.ts +32 -1
- package/dist/client/index.js +117 -2
- package/package.json +6 -1
package/dist/client/index.d.ts
CHANGED
|
@@ -5,6 +5,12 @@ import { QueryClient, UseMutationOptions, UseQueryOptions } from '@tanstack/reac
|
|
|
5
5
|
import * as _tanstack_query_core from '@tanstack/query-core';
|
|
6
6
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
7
7
|
import { c as createVerifyAction } from '../create-verify-action-DBwWOXPO.js';
|
|
8
|
+
import * as React$1 from 'react';
|
|
9
|
+
import { ComponentProps } from 'react';
|
|
10
|
+
import { LucideIcon } from 'lucide-react';
|
|
11
|
+
import * as class_variance_authority_types from 'class-variance-authority/types';
|
|
12
|
+
import { VariantProps } from 'class-variance-authority';
|
|
13
|
+
import { ClassValue } from 'clsx';
|
|
8
14
|
import '../types-J25u1G6t.js';
|
|
9
15
|
import '../types-0oS1A2K5.js';
|
|
10
16
|
import 'jsonwebtoken';
|
|
@@ -17,6 +23,12 @@ import 'intor';
|
|
|
17
23
|
import 'keyv';
|
|
18
24
|
import 'zod/v4/core';
|
|
19
25
|
|
|
26
|
+
interface UIStates {
|
|
27
|
+
isLoading?: boolean;
|
|
28
|
+
isDisabled?: boolean;
|
|
29
|
+
isError?: boolean;
|
|
30
|
+
}
|
|
31
|
+
|
|
20
32
|
interface FetchContext {
|
|
21
33
|
input: string;
|
|
22
34
|
init: RequestInit;
|
|
@@ -324,4 +336,23 @@ declare function createAdminInitializer({ useAdmin, useQuery, verifyAction, }: {
|
|
|
324
336
|
verifyAction: ReturnType<typeof createVerifyAction>;
|
|
325
337
|
}): () => null;
|
|
326
338
|
|
|
327
|
-
|
|
339
|
+
declare function Form({ onSubmit, className, ...props }: ComponentProps<"form">): react_jsx_runtime.JSX.Element;
|
|
340
|
+
|
|
341
|
+
declare const buttonVariants: (props?: ({
|
|
342
|
+
variant?: "link" | "default" | "success" | "destructive" | "outline" | "secondary" | "ghost" | "warning" | null | undefined;
|
|
343
|
+
size?: "lg" | "sm" | "default" | "icon" | "icon-sm" | "icon-lg" | "xs" | null | undefined;
|
|
344
|
+
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
345
|
+
type ShadcnButtonProps = React$1.ComponentProps<"button"> & VariantProps<typeof buttonVariants> & {
|
|
346
|
+
asChild?: boolean;
|
|
347
|
+
};
|
|
348
|
+
|
|
349
|
+
interface ButtonProps extends Omit<ShadcnButtonProps, "className">, UIStates {
|
|
350
|
+
icon?: LucideIcon;
|
|
351
|
+
href?: string;
|
|
352
|
+
openNewTab?: boolean;
|
|
353
|
+
}
|
|
354
|
+
declare function Button({ icon, href, openNewTab, isDisabled, isLoading, children, ...props }: ButtonProps): react_jsx_runtime.JSX.Element;
|
|
355
|
+
|
|
356
|
+
declare const cn: (...inputs: ClassValue[]) => string;
|
|
357
|
+
|
|
358
|
+
export { AdminProvider, Button, type ButtonProps, Form, type ShowToastOption, cn, createAdminInitializer, createRequestInterceptor, createResponseInterceptor, createSmartFetch, createUseCommand, createUseQuery, handleToast, useAdmin };
|
package/dist/client/index.js
CHANGED
|
@@ -1,8 +1,15 @@
|
|
|
1
1
|
import { ensureArray } from '../chunk-OAENV763.js';
|
|
2
2
|
import { toast } from 'sonner';
|
|
3
|
-
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
3
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
4
4
|
import { useMutation, useQuery } from '@tanstack/react-query';
|
|
5
|
+
import * as React2 from 'react';
|
|
5
6
|
import { createContext, useState, useContext, useEffect } from 'react';
|
|
7
|
+
import { clsx } from 'clsx';
|
|
8
|
+
import { twMerge } from 'tailwind-merge';
|
|
9
|
+
import { useRouter } from 'next/navigation';
|
|
10
|
+
import { Slot } from '@radix-ui/react-slot';
|
|
11
|
+
import { cva } from 'class-variance-authority';
|
|
12
|
+
import { Loader2Icon } from 'lucide-react';
|
|
6
13
|
|
|
7
14
|
// src/client/infrastructure/fetch/smart-fetch.ts
|
|
8
15
|
function createSmartFetch({
|
|
@@ -234,5 +241,113 @@ function createAdminInitializer({
|
|
|
234
241
|
return null;
|
|
235
242
|
};
|
|
236
243
|
}
|
|
244
|
+
var cn = (...inputs) => {
|
|
245
|
+
return twMerge(clsx(inputs));
|
|
246
|
+
};
|
|
247
|
+
function Form({
|
|
248
|
+
onSubmit,
|
|
249
|
+
className,
|
|
250
|
+
...props
|
|
251
|
+
}) {
|
|
252
|
+
const handleSubmit = (e) => {
|
|
253
|
+
if (!onSubmit) return;
|
|
254
|
+
e.preventDefault();
|
|
255
|
+
void onSubmit(e);
|
|
256
|
+
};
|
|
257
|
+
return /* @__PURE__ */ jsx("form", { className: cn(className), onSubmit: handleSubmit, ...props });
|
|
258
|
+
}
|
|
259
|
+
var buttonVariants = cva(
|
|
260
|
+
"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",
|
|
261
|
+
{
|
|
262
|
+
variants: {
|
|
263
|
+
variant: {
|
|
264
|
+
default: "bg-primary text-primary-foreground hover:bg-primary/90",
|
|
265
|
+
destructive: "bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",
|
|
266
|
+
outline: "border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",
|
|
267
|
+
secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80",
|
|
268
|
+
ghost: "hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",
|
|
269
|
+
link: "text-primary underline-offset-4 hover:underline",
|
|
270
|
+
success: "bg-success text-white hover:bg-success/90 focus-visible:ring-success/20 dark:focus-visible:ring-success/40 dark:bg-success/60",
|
|
271
|
+
warning: "bg-warning text-white hover:bg-warning/90 focus-visible:ring-warning/20 dark:focus-visible:ring-warning/40 dark:bg-warning/60"
|
|
272
|
+
},
|
|
273
|
+
size: {
|
|
274
|
+
default: "h-9 px-4 py-2 has-[>svg]:px-3",
|
|
275
|
+
sm: "h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",
|
|
276
|
+
lg: "h-10 rounded-md px-6 has-[>svg]:px-4",
|
|
277
|
+
icon: "size-9",
|
|
278
|
+
"icon-sm": "size-8",
|
|
279
|
+
"icon-lg": "size-10",
|
|
280
|
+
xs: "h-7 rounded-md px-2 text-xs has-[>svg]:px-2 gap-1"
|
|
281
|
+
}
|
|
282
|
+
},
|
|
283
|
+
defaultVariants: {
|
|
284
|
+
variant: "default",
|
|
285
|
+
size: "default"
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
);
|
|
289
|
+
function ShadCnButton({
|
|
290
|
+
className,
|
|
291
|
+
variant,
|
|
292
|
+
size,
|
|
293
|
+
asChild = false,
|
|
294
|
+
...props
|
|
295
|
+
}) {
|
|
296
|
+
const Comp = asChild ? Slot : "button";
|
|
297
|
+
return /* @__PURE__ */ jsx(
|
|
298
|
+
Comp,
|
|
299
|
+
{
|
|
300
|
+
"data-slot": "button",
|
|
301
|
+
className: cn(buttonVariants({ variant, size, className })),
|
|
302
|
+
...props
|
|
303
|
+
}
|
|
304
|
+
);
|
|
305
|
+
}
|
|
306
|
+
function Spinner({ className, ...props }) {
|
|
307
|
+
return /* @__PURE__ */ jsx(
|
|
308
|
+
Loader2Icon,
|
|
309
|
+
{
|
|
310
|
+
role: "status",
|
|
311
|
+
"aria-label": "Loading",
|
|
312
|
+
className: cn("size-4 animate-spin", className),
|
|
313
|
+
...props
|
|
314
|
+
}
|
|
315
|
+
);
|
|
316
|
+
}
|
|
317
|
+
function Button({
|
|
318
|
+
icon,
|
|
319
|
+
href,
|
|
320
|
+
openNewTab = false,
|
|
321
|
+
// processing states
|
|
322
|
+
isDisabled = false,
|
|
323
|
+
isLoading = false,
|
|
324
|
+
// base
|
|
325
|
+
children,
|
|
326
|
+
...props
|
|
327
|
+
}) {
|
|
328
|
+
isDisabled = isDisabled || isLoading;
|
|
329
|
+
const router = useRouter();
|
|
330
|
+
const handleClick = () => {
|
|
331
|
+
if (!href) return;
|
|
332
|
+
if (openNewTab) {
|
|
333
|
+
window.open(href, "_blank");
|
|
334
|
+
} else {
|
|
335
|
+
router.push(href);
|
|
336
|
+
}
|
|
337
|
+
};
|
|
338
|
+
return /* @__PURE__ */ jsx(
|
|
339
|
+
ShadCnButton,
|
|
340
|
+
{
|
|
341
|
+
type: props.type ?? "button",
|
|
342
|
+
disabled: isDisabled,
|
|
343
|
+
onClick: props.onClick ?? handleClick,
|
|
344
|
+
...props,
|
|
345
|
+
children: isLoading ? /* @__PURE__ */ jsx(Spinner, {}) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
346
|
+
icon && React2.createElement(icon),
|
|
347
|
+
children
|
|
348
|
+
] })
|
|
349
|
+
}
|
|
350
|
+
);
|
|
351
|
+
}
|
|
237
352
|
|
|
238
|
-
export { AdminProvider, createAdminInitializer, createRequestInterceptor, createResponseInterceptor, createSmartFetch, createUseCommand, createUseQuery, handleToast, useAdmin };
|
|
353
|
+
export { AdminProvider, Button, Form, cn, createAdminInitializer, createRequestInterceptor, createResponseInterceptor, createSmartFetch, createUseCommand, createUseQuery, handleToast, useAdmin };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yimingliao/cms",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.82",
|
|
4
4
|
"author": "Yiming Liao",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -44,13 +44,18 @@
|
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
46
|
"@keyv/redis": "^5.1.6",
|
|
47
|
+
"@radix-ui/react-slot": "^1.2.4",
|
|
47
48
|
"argon2": "^0.44.0",
|
|
49
|
+
"class-variance-authority": "^0.7.1",
|
|
50
|
+
"clsx": "^2.1.1",
|
|
48
51
|
"jsonwebtoken": "^9.0.3",
|
|
49
52
|
"keyv": "^5.6.0",
|
|
50
53
|
"logry": "^2.1.6",
|
|
54
|
+
"lucide-react": "^0.577.0",
|
|
51
55
|
"mime-types": "^3.0.2",
|
|
52
56
|
"nodemailer": "^8.0.1",
|
|
53
57
|
"sonner": "^2.0.7",
|
|
58
|
+
"tailwind-merge": "^3.5.0",
|
|
54
59
|
"ulid": "^3.0.2"
|
|
55
60
|
},
|
|
56
61
|
"devDependencies": {
|