@yimingliao/cms 0.0.82 → 0.0.84

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.
@@ -1,4 +1,4 @@
1
- import { R as Result, S as SuccessResult, d as ErrorResult, g as AdminFull } from '../types-BGsFazJr.js';
1
+ import { R as Result, S as SuccessResult, d as ErrorResult, g as AdminFull, D as DeviceInfo } from '../types-BGsFazJr.js';
2
2
  import { Logger } from 'logry';
3
3
  import * as _tanstack_react_query from '@tanstack/react-query';
4
4
  import { QueryClient, UseMutationOptions, UseQueryOptions } from '@tanstack/react-query';
@@ -346,13 +346,19 @@ type ShadcnButtonProps = React$1.ComponentProps<"button"> & VariantProps<typeof
346
346
  asChild?: boolean;
347
347
  };
348
348
 
349
- interface ButtonProps extends Omit<ShadcnButtonProps, "className">, UIStates {
349
+ interface ButtonProps extends ShadcnButtonProps, UIStates {
350
350
  icon?: LucideIcon;
351
351
  href?: string;
352
352
  openNewTab?: boolean;
353
353
  }
354
354
  declare function Button({ icon, href, openNewTab, isDisabled, isLoading, children, ...props }: ButtonProps): react_jsx_runtime.JSX.Element;
355
355
 
356
+ declare function AuthForm({ title, children, className, ...props }: ComponentProps<"form"> & {
357
+ title: string;
358
+ }): react_jsx_runtime.JSX.Element;
359
+
356
360
  declare const cn: (...inputs: ClassValue[]) => string;
357
361
 
358
- export { AdminProvider, Button, type ButtonProps, Form, type ShowToastOption, cn, createAdminInitializer, createRequestInterceptor, createResponseInterceptor, createSmartFetch, createUseCommand, createUseQuery, handleToast, useAdmin };
362
+ declare function useDeviceInfo(): DeviceInfo | null;
363
+
364
+ export { AdminProvider, AuthForm, Button, type ButtonProps, Form, type ShowToastOption, cn, createAdminInitializer, createRequestInterceptor, createResponseInterceptor, createSmartFetch, createUseCommand, createUseQuery, handleToast, useAdmin, useDeviceInfo };
@@ -6,6 +6,7 @@ import * as React2 from 'react';
6
6
  import { createContext, useState, useContext, useEffect } from 'react';
7
7
  import { clsx } from 'clsx';
8
8
  import { twMerge } from 'tailwind-merge';
9
+ import { UAParser } from 'ua-parser-js';
9
10
  import { useRouter } from 'next/navigation';
10
11
  import { Slot } from '@radix-ui/react-slot';
11
12
  import { cva } from 'class-variance-authority';
@@ -244,6 +245,27 @@ function createAdminInitializer({
244
245
  var cn = (...inputs) => {
245
246
  return twMerge(clsx(inputs));
246
247
  };
248
+ function useDeviceInfo() {
249
+ const [deviceInfo, setDeviceInfo] = useState(null);
250
+ useEffect(() => {
251
+ const parser = new UAParser(navigator.userAgent);
252
+ const result = parser.getResult();
253
+ setDeviceInfo({
254
+ deviceType: result.device.type || "desktop",
255
+ platform: result.os.name || "Unknown",
256
+ timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
257
+ language: navigator.language,
258
+ screenResolution: {
259
+ width: window.screen.width,
260
+ height: window.screen.height
261
+ },
262
+ browser: result.browser.name || "Unknown",
263
+ browserVersion: result.browser.version || "",
264
+ userAgent: navigator.userAgent
265
+ });
266
+ }, []);
267
+ return deviceInfo;
268
+ }
247
269
  function Form({
248
270
  onSubmit,
249
271
  className,
@@ -325,7 +347,6 @@ function Button({
325
347
  children,
326
348
  ...props
327
349
  }) {
328
- isDisabled = isDisabled || isLoading;
329
350
  const router = useRouter();
330
351
  const handleClick = () => {
331
352
  if (!href) return;
@@ -339,7 +360,7 @@ function Button({
339
360
  ShadCnButton,
340
361
  {
341
362
  type: props.type ?? "button",
342
- disabled: isDisabled,
363
+ disabled: isDisabled || isLoading,
343
364
  onClick: props.onClick ?? handleClick,
344
365
  ...props,
345
366
  children: isLoading ? /* @__PURE__ */ jsx(Spinner, {}) : /* @__PURE__ */ jsxs(Fragment, { children: [
@@ -349,5 +370,62 @@ function Button({
349
370
  }
350
371
  );
351
372
  }
373
+ function Card({ className, ...props }) {
374
+ return /* @__PURE__ */ jsx(
375
+ "div",
376
+ {
377
+ "data-slot": "card",
378
+ className: cn(
379
+ "bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6 shadow-sm",
380
+ className
381
+ ),
382
+ ...props
383
+ }
384
+ );
385
+ }
386
+ function CardHeader({ className, ...props }) {
387
+ return /* @__PURE__ */ jsx(
388
+ "div",
389
+ {
390
+ "data-slot": "card-header",
391
+ className: cn(
392
+ "@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-2 px-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6",
393
+ className
394
+ ),
395
+ ...props
396
+ }
397
+ );
398
+ }
399
+ function CardTitle({ className, ...props }) {
400
+ return /* @__PURE__ */ jsx(
401
+ "div",
402
+ {
403
+ "data-slot": "card-title",
404
+ className: cn("leading-none font-semibold", className),
405
+ ...props
406
+ }
407
+ );
408
+ }
409
+ function CardContent({ className, ...props }) {
410
+ return /* @__PURE__ */ jsx(
411
+ "div",
412
+ {
413
+ "data-slot": "card-content",
414
+ className: cn("px-6", className),
415
+ ...props
416
+ }
417
+ );
418
+ }
419
+ function AuthForm({
420
+ title,
421
+ children,
422
+ className,
423
+ ...props
424
+ }) {
425
+ return /* @__PURE__ */ jsx(Form, { className: cn("mx-auto mt-14 w-96", className), ...props, children: /* @__PURE__ */ jsxs(Card, { children: [
426
+ /* @__PURE__ */ jsx(CardHeader, { children: /* @__PURE__ */ jsx(CardTitle, { className: "mx-auto", children: title }) }),
427
+ /* @__PURE__ */ jsx(CardContent, { children: /* @__PURE__ */ jsx("div", { className: "relative flex flex-col gap-6", children }) })
428
+ ] }) });
429
+ }
352
430
 
353
- export { AdminProvider, Button, Form, cn, createAdminInitializer, createRequestInterceptor, createResponseInterceptor, createSmartFetch, createUseCommand, createUseQuery, handleToast, useAdmin };
431
+ export { AdminProvider, AuthForm, Button, Form, cn, createAdminInitializer, createRequestInterceptor, createResponseInterceptor, createSmartFetch, createUseCommand, createUseQuery, handleToast, useAdmin, useDeviceInfo };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yimingliao/cms",
3
- "version": "0.0.82",
3
+ "version": "0.0.84",
4
4
  "author": "Yiming Liao",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -47,7 +47,6 @@
47
47
  "@radix-ui/react-slot": "^1.2.4",
48
48
  "argon2": "^0.44.0",
49
49
  "class-variance-authority": "^0.7.1",
50
- "clsx": "^2.1.1",
51
50
  "jsonwebtoken": "^9.0.3",
52
51
  "keyv": "^5.6.0",
53
52
  "logry": "^2.1.6",
@@ -55,7 +54,7 @@
55
54
  "mime-types": "^3.0.2",
56
55
  "nodemailer": "^8.0.1",
57
56
  "sonner": "^2.0.7",
58
- "tailwind-merge": "^3.5.0",
57
+ "ua-parser-js": "^2.0.9",
59
58
  "ulid": "^3.0.2"
60
59
  },
61
60
  "devDependencies": {
@@ -68,6 +67,7 @@
68
67
  "@types/nodemailer": "^7.0.11",
69
68
  "@types/react": "^19.2.14",
70
69
  "@types/ssh2-sftp-client": "^9.0.6",
70
+ "clsx": "^2.1.1",
71
71
  "eslint": "^9",
72
72
  "eslint-import-resolver-typescript": "^4.4.4",
73
73
  "eslint-plugin-import": "^2.32.0",
@@ -82,6 +82,7 @@
82
82
  "next": "^16.1.6",
83
83
  "prisma": "6.5.0",
84
84
  "react": "^19.2.4",
85
+ "tailwind-merge": "^3.5.0",
85
86
  "tsup": "^8.5.1",
86
87
  "typescript": "^5.9.3",
87
88
  "typescript-eslint": "^8.56.1",