@yimingliao/cms 0.0.87 → 0.0.88

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.
@@ -6,6 +6,7 @@ import { Slot } from '@radix-ui/react-slot';
6
6
  import { cva } from 'class-variance-authority';
7
7
  import { jsx } from 'react/jsx-runtime';
8
8
  import { Loader2Icon } from 'lucide-react';
9
+ import * as LabelPrimitive from '@radix-ui/react-label';
9
10
 
10
11
  // src/client/applications/ui/utils.ts
11
12
  var cn = (...inputs) => {
@@ -340,5 +341,18 @@ function Spinner({ className, ...props }) {
340
341
  }
341
342
  );
342
343
  }
344
+ function Label({ className, ...props }) {
345
+ return /* @__PURE__ */ jsx(
346
+ LabelPrimitive.Root,
347
+ {
348
+ "data-slot": "label",
349
+ className: cn(
350
+ "flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",
351
+ className
352
+ ),
353
+ ...props
354
+ }
355
+ );
356
+ }
343
357
 
344
- export { Button, Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Input, InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput, InputGroupText, InputGroupTextarea, Spinner, Textarea, cn, useDeviceInfo };
358
+ export { Button, Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Input, InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput, InputGroupText, InputGroupTextarea, Label, Spinner, Textarea, cn, useDeviceInfo };
@@ -6,9 +6,9 @@ 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
8
  import * as React$1 from 'react';
9
- import { ComponentProps } from 'react';
9
+ import { ComponentProps, ReactNode, HTMLAttributes } from 'react';
10
+ import { L as LabelProps, B as ButtonProps$1 } from '../label-BF4qxS03.js';
10
11
  import { LucideIcon } from 'lucide-react';
11
- import { B as ButtonProps$1 } from '../button-DsjdULEG.js';
12
12
  import { ClassValue } from 'clsx';
13
13
  import '../types-J25u1G6t.js';
14
14
  import '../types-0oS1A2K5.js';
@@ -23,6 +23,7 @@ import 'keyv';
23
23
  import 'zod/v4/core';
24
24
  import 'class-variance-authority/types';
25
25
  import 'class-variance-authority';
26
+ import '@radix-ui/react-label';
26
27
 
27
28
  interface UIStates {
28
29
  isLoading?: boolean;
@@ -350,6 +351,22 @@ declare function createAdminInitializer({ useAdmin, useQuery, verifyAction, }: {
350
351
 
351
352
  declare function Form({ onSubmit, className, ...props }: ComponentProps<"form">): react_jsx_runtime.JSX.Element;
352
353
 
354
+ interface FieldProps extends LabelProps {
355
+ label: ReactNode;
356
+ isRequired?: boolean;
357
+ hint?: ReactNode;
358
+ labelChildren?: ReactNode;
359
+ children: ReactNode;
360
+ }
361
+ declare function Field({ label, isRequired, hint, labelChildren, children, ...props }: FieldProps): react_jsx_runtime.JSX.Element;
362
+
363
+ interface FieldBodyProps extends HTMLAttributes<HTMLDivElement>, UIStates {
364
+ isEmpty?: boolean;
365
+ backgroundClassName?: string;
366
+ childrenClassName?: string;
367
+ }
368
+ declare function FieldBody({ isLoading, isDisabled, isEmpty, className, backgroundClassName, childrenClassName, children, ...props }: FieldBodyProps): react_jsx_runtime.JSX.Element;
369
+
353
370
  interface ButtonProps extends ButtonProps$1, UIStates {
354
371
  icon?: LucideIcon;
355
372
  href?: string;
@@ -361,8 +378,10 @@ interface InputProps<T = Record<string, unknown>> extends ComponentProps<"input"
361
378
  }
362
379
  declare function Input<T>({ fieldName, setFormData, isLoading, isDisabled, isError, children, ...props }: InputProps<T>): react_jsx_runtime.JSX.Element;
363
380
 
381
+ declare function PasswordInput<T>({ ...props }: InputProps<T>): react_jsx_runtime.JSX.Element;
382
+
364
383
  declare const cn: (...inputs: ClassValue[]) => string;
365
384
 
366
385
  declare function useDeviceInfo(): DeviceInfo | null;
367
386
 
368
- export { AdminProvider, Button, type ButtonProps, Form, Input, type InputProps, type ShowToastOption, cn, createAdminInitializer, createRequestInterceptor, createResponseInterceptor, createSmartFetch, createUseCommand, createUseQuery, handleToast, useAdmin, useDeviceInfo };
387
+ export { AdminProvider, Button, type ButtonProps, Field, FieldBody, Form, Input, type InputProps, PasswordInput, type ShowToastOption, cn, createAdminInitializer, createRequestInterceptor, createResponseInterceptor, createSmartFetch, createUseCommand, createUseQuery, handleToast, useAdmin, useDeviceInfo };
@@ -1,11 +1,13 @@
1
- import { cn, Button, Spinner, InputGroup, InputGroupAddon, InputGroupInput } from '../chunk-MYQZGULX.js';
2
- export { cn, useDeviceInfo } from '../chunk-MYQZGULX.js';
1
+ import { cn, Label, Spinner, Button, InputGroup, InputGroupAddon, InputGroupInput, InputGroupButton } from '../chunk-OQGJBZXQ.js';
2
+ export { cn, useDeviceInfo } from '../chunk-OQGJBZXQ.js';
3
3
  import { ensureArray } from '../chunk-OAENV763.js';
4
4
  import { toast } from 'sonner';
5
5
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
6
6
  import { useMutation, useQuery } from '@tanstack/react-query';
7
7
  import * as React from 'react';
8
8
  import { createContext, useState, useContext, useEffect } from 'react';
9
+ import { Asterisk, Eye, EyeOff } from 'lucide-react';
10
+ import { useTranslator } from 'intor/react';
9
11
  import { useRouter } from 'next/navigation';
10
12
 
11
13
  // src/client/infrastructure/fetch/smart-fetch.ts
@@ -250,6 +252,81 @@ function Form({
250
252
  };
251
253
  return /* @__PURE__ */ jsx("form", { className: cn(className), onSubmit: handleSubmit, ...props });
252
254
  }
255
+ function Field({
256
+ label,
257
+ isRequired = false,
258
+ hint,
259
+ labelChildren,
260
+ children,
261
+ ...props
262
+ }) {
263
+ return /* @__PURE__ */ jsxs("div", { className: "grid w-full items-center gap-3", children: [
264
+ /* @__PURE__ */ jsxs("span", { className: "flex gap-2", children: [
265
+ /* @__PURE__ */ jsxs(Label, { className: "flex gap-1 truncate", ...props, children: [
266
+ label,
267
+ isRequired && /* @__PURE__ */ jsx(Asterisk, { className: "text-destructive size-3" }),
268
+ hint && /* @__PURE__ */ jsx("span", { className: "ml-2 text-xs text-muted-foreground", children: hint })
269
+ ] }),
270
+ /* @__PURE__ */ jsx("span", { children: labelChildren })
271
+ ] }),
272
+ children
273
+ ] });
274
+ }
275
+ function FieldBody({
276
+ // ui states
277
+ isLoading = false,
278
+ isDisabled = false,
279
+ isEmpty = false,
280
+ // base
281
+ className,
282
+ backgroundClassName,
283
+ childrenClassName,
284
+ children,
285
+ ...props
286
+ }) {
287
+ const { t } = useTranslator();
288
+ return /* @__PURE__ */ jsxs(
289
+ "div",
290
+ {
291
+ className: cn(
292
+ className,
293
+ "relative",
294
+ "min-h-9 w-full min-w-0",
295
+ "flex items-center",
296
+ "text-sm"
297
+ ),
298
+ ...props,
299
+ children: [
300
+ /* @__PURE__ */ jsx(
301
+ "div",
302
+ {
303
+ className: cn(
304
+ "absolute size-full",
305
+ "dark:bg-input/30 bg-foreground/2 rounded-md",
306
+ backgroundClassName
307
+ )
308
+ }
309
+ ),
310
+ isLoading && /* @__PURE__ */ jsx("div", { className: "px-3", children: /* @__PURE__ */ jsx(Spinner, {}) }),
311
+ !isLoading && (!children || isEmpty) && /* @__PURE__ */ jsx("div", { className: "flex-center h-9 px-3 opacity-50", children: /* @__PURE__ */ jsx("p", { className: "opacity-50", children: t("ui.no-data.text") }) }),
312
+ !isLoading && children && !isEmpty && /* @__PURE__ */ jsx(
313
+ "div",
314
+ {
315
+ className: cn(
316
+ "relative size-full",
317
+ "flex items-center gap-3",
318
+ "px-3 py-2",
319
+ "break-all",
320
+ (isDisabled || isLoading) && "opacity-50",
321
+ childrenClassName
322
+ ),
323
+ children
324
+ }
325
+ )
326
+ ]
327
+ }
328
+ );
329
+ }
253
330
  function Button2({
254
331
  icon,
255
332
  href,
@@ -312,5 +389,18 @@ function Input({
312
389
  children
313
390
  ] });
314
391
  }
392
+ function PasswordInput({ ...props }) {
393
+ const [showPassword, setShowPassword] = useState(false);
394
+ return /* @__PURE__ */ jsx(Input, { type: showPassword ? "text" : "password", ...props, children: /* @__PURE__ */ jsx(InputGroupAddon, { align: "inline-end", children: /* @__PURE__ */ jsx(
395
+ InputGroupButton,
396
+ {
397
+ "aria-label": showPassword ? "Hide password" : "Show password",
398
+ title: showPassword ? "Hide password" : "Show password",
399
+ size: "icon-xs",
400
+ onClick: () => setShowPassword((prev) => !prev),
401
+ children: showPassword ? /* @__PURE__ */ jsx(Eye, {}) : /* @__PURE__ */ jsx(EyeOff, {})
402
+ }
403
+ ) }) });
404
+ }
315
405
 
316
- export { AdminProvider, Button2 as Button, Form, Input, createAdminInitializer, createRequestInterceptor, createResponseInterceptor, createSmartFetch, createUseCommand, createUseQuery, handleToast, useAdmin };
406
+ export { AdminProvider, Button2 as Button, Field, FieldBody, Form, Input, PasswordInput, createAdminInitializer, createRequestInterceptor, createResponseInterceptor, createSmartFetch, createUseCommand, createUseQuery, handleToast, useAdmin };
@@ -1,10 +1,11 @@
1
- import { a as Button } from '../../button-DsjdULEG.js';
2
- export { B as ButtonProps } from '../../button-DsjdULEG.js';
1
+ import { a as Button } from '../../label-BF4qxS03.js';
2
+ export { B as ButtonProps, b as Label, L as LabelProps } from '../../label-BF4qxS03.js';
3
3
  import * as react_jsx_runtime from 'react/jsx-runtime';
4
4
  import * as React from 'react';
5
5
  import { ComponentProps } from 'react';
6
6
  import * as class_variance_authority_types from 'class-variance-authority/types';
7
7
  import { VariantProps } from 'class-variance-authority';
8
+ import '@radix-ui/react-label';
8
9
 
9
10
  declare function Card({ className, ...props }: React.ComponentProps<"div">): react_jsx_runtime.JSX.Element;
10
11
  declare function CardHeader({ className, ...props }: React.ComponentProps<"div">): react_jsx_runtime.JSX.Element;
@@ -1 +1 @@
1
- export { Button, Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Input, InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput, InputGroupText, InputGroupTextarea, Spinner, Textarea } from '../../chunk-MYQZGULX.js';
1
+ export { Button, Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Input, InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput, InputGroupText, InputGroupTextarea, Label, Spinner, Textarea } from '../../chunk-OQGJBZXQ.js';
@@ -2,6 +2,7 @@ import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import * as class_variance_authority_types from 'class-variance-authority/types';
3
3
  import { VariantProps } from 'class-variance-authority';
4
4
  import * as React from 'react';
5
+ import * as LabelPrimitive from '@radix-ui/react-label';
5
6
 
6
7
  declare const buttonVariants: (props?: ({
7
8
  variant?: "link" | "default" | "success" | "destructive" | "outline" | "secondary" | "ghost" | "warning" | null | undefined;
@@ -12,4 +13,7 @@ type ButtonProps = React.ComponentProps<"button"> & VariantProps<typeof buttonVa
12
13
  };
13
14
  declare function Button({ className, variant, size, asChild, ...props }: ButtonProps): react_jsx_runtime.JSX.Element;
14
15
 
15
- export { type ButtonProps as B, Button as a };
16
+ type LabelProps = React.ComponentProps<typeof LabelPrimitive.Root>;
17
+ declare function Label({ className, ...props }: LabelProps): react_jsx_runtime.JSX.Element;
18
+
19
+ export { type ButtonProps as B, type LabelProps as L, Button as a, Label as b };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yimingliao/cms",
3
- "version": "0.0.87",
3
+ "version": "0.0.88",
4
4
  "author": "Yiming Liao",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -49,6 +49,7 @@
49
49
  },
50
50
  "dependencies": {
51
51
  "@keyv/redis": "^5.1.6",
52
+ "@radix-ui/react-label": "^2.1.8",
52
53
  "@radix-ui/react-slot": "^1.2.4",
53
54
  "argon2": "^0.44.0",
54
55
  "class-variance-authority": "^0.7.1",
@@ -85,6 +86,8 @@
85
86
  "intor": "^2.5.0",
86
87
  "knip": "^5.86.0",
87
88
  "next": "^16.1.6",
89
+ "prettier": "^3.8.1",
90
+ "prettier-plugin-tailwindcss": "^0.7.2",
88
91
  "prisma": "6.5.0",
89
92
  "react": "^19.2.4",
90
93
  "tailwind-merge": "^3.5.0",