@yimingliao/cms 0.0.106 → 0.0.108

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,421 +0,0 @@
1
- import { clsx } from 'clsx';
2
- import { twMerge } from 'tailwind-merge';
3
- import { useState, useRef, useCallback, useEffect } from 'react';
4
- import { usePathname } from 'next/navigation';
5
- import { UAParser } from 'ua-parser-js';
6
- import { Slot } from '@radix-ui/react-slot';
7
- import { cva } from 'class-variance-authority';
8
- import { jsx } from 'react/jsx-runtime';
9
- import { Loader2Icon } from 'lucide-react';
10
- import * as LabelPrimitive from '@radix-ui/react-label';
11
- import * as SeparatorPrimitive from '@radix-ui/react-separator';
12
-
13
- // src/client/applications/ui/utils.ts
14
- var cn = (...inputs) => {
15
- return twMerge(clsx(inputs));
16
- };
17
- var useCountdown = (initialTime) => {
18
- const [timeLeft, setTimeLeft] = useState(initialTime);
19
- const [isCounting, setIsCounting] = useState(false);
20
- const intervalRef = useRef(null);
21
- const startCountdown = useCallback(() => {
22
- setTimeLeft(initialTime);
23
- setIsCounting(true);
24
- }, [initialTime]);
25
- useEffect(() => {
26
- if (!isCounting) return;
27
- intervalRef.current = setInterval(() => {
28
- setTimeLeft((prev) => {
29
- if (prev <= 1) {
30
- clearInterval(intervalRef.current);
31
- intervalRef.current = null;
32
- setIsCounting(false);
33
- return 0;
34
- }
35
- return prev - 1;
36
- });
37
- }, 1e3);
38
- return () => {
39
- if (intervalRef.current) {
40
- clearInterval(intervalRef.current);
41
- intervalRef.current = null;
42
- }
43
- };
44
- }, [isCounting]);
45
- return { timeLeft, isCounting, startCountdown };
46
- };
47
- var useParentPathname = () => {
48
- const pathname = usePathname();
49
- if (pathname === "/") return "/";
50
- const index = pathname.lastIndexOf("/");
51
- return index <= 0 ? "/" : pathname.slice(0, index);
52
- };
53
-
54
- // src/client/applications/ui/is-confirm.ts
55
- var isConfirm = (t, key = "ui.dialog.confirm.text") => {
56
- return confirm(t(key));
57
- };
58
- function useDeviceInfo() {
59
- const [deviceInfo, setDeviceInfo] = useState(null);
60
- useEffect(() => {
61
- const parser = new UAParser(navigator.userAgent);
62
- const result = parser.getResult();
63
- setDeviceInfo({
64
- deviceType: result.device.type || "desktop",
65
- platform: result.os.name || "Unknown",
66
- timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
67
- language: navigator.language,
68
- screenResolution: {
69
- width: window.screen.width,
70
- height: window.screen.height
71
- },
72
- browser: result.browser.name || "Unknown",
73
- browserVersion: result.browser.version || "",
74
- userAgent: navigator.userAgent
75
- });
76
- }, []);
77
- return deviceInfo;
78
- }
79
- var buttonVariants = cva(
80
- "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",
81
- {
82
- variants: {
83
- variant: {
84
- default: "bg-primary text-primary-foreground hover:bg-primary/90",
85
- destructive: "bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",
86
- 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",
87
- secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80",
88
- ghost: "hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",
89
- link: "text-primary underline-offset-4 hover:underline",
90
- success: "bg-success text-white hover:bg-success/90 focus-visible:ring-success/20 dark:focus-visible:ring-success/40 dark:bg-success/60",
91
- warning: "bg-warning text-white hover:bg-warning/90 focus-visible:ring-warning/20 dark:focus-visible:ring-warning/40 dark:bg-warning/60"
92
- },
93
- size: {
94
- default: "h-9 px-4 py-2 has-[>svg]:px-3",
95
- sm: "h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",
96
- lg: "h-10 rounded-md px-6 has-[>svg]:px-4",
97
- icon: "size-9",
98
- "icon-sm": "size-8",
99
- "icon-lg": "size-10",
100
- xs: "h-7 rounded-md px-2 text-xs has-[>svg]:px-2 gap-1"
101
- }
102
- },
103
- defaultVariants: {
104
- variant: "default",
105
- size: "default"
106
- }
107
- }
108
- );
109
- function Button({
110
- className,
111
- variant,
112
- size,
113
- asChild = false,
114
- ...props
115
- }) {
116
- const Comp = asChild ? Slot : "button";
117
- return /* @__PURE__ */ jsx(
118
- Comp,
119
- {
120
- "data-slot": "button",
121
- className: cn(buttonVariants({ variant, size, className })),
122
- ...props
123
- }
124
- );
125
- }
126
- function Card({ className, ...props }) {
127
- return /* @__PURE__ */ jsx(
128
- "div",
129
- {
130
- "data-slot": "card",
131
- className: cn(
132
- "bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6 shadow-sm",
133
- className
134
- ),
135
- ...props
136
- }
137
- );
138
- }
139
- function CardHeader({ className, ...props }) {
140
- return /* @__PURE__ */ jsx(
141
- "div",
142
- {
143
- "data-slot": "card-header",
144
- className: cn(
145
- "@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",
146
- className
147
- ),
148
- ...props
149
- }
150
- );
151
- }
152
- function CardTitle({ className, ...props }) {
153
- return /* @__PURE__ */ jsx(
154
- "div",
155
- {
156
- "data-slot": "card-title",
157
- className: cn("leading-none font-semibold", className),
158
- ...props
159
- }
160
- );
161
- }
162
- function CardDescription({ className, ...props }) {
163
- return /* @__PURE__ */ jsx(
164
- "div",
165
- {
166
- "data-slot": "card-description",
167
- className: cn("text-muted-foreground text-sm", className),
168
- ...props
169
- }
170
- );
171
- }
172
- function CardAction({ className, ...props }) {
173
- return /* @__PURE__ */ jsx(
174
- "div",
175
- {
176
- "data-slot": "card-action",
177
- className: cn(
178
- "col-start-2 row-span-2 row-start-1 self-start justify-self-end",
179
- className
180
- ),
181
- ...props
182
- }
183
- );
184
- }
185
- function CardContent({ className, ...props }) {
186
- return /* @__PURE__ */ jsx(
187
- "div",
188
- {
189
- "data-slot": "card-content",
190
- className: cn("px-6", className),
191
- ...props
192
- }
193
- );
194
- }
195
- function CardFooter({ className, ...props }) {
196
- return /* @__PURE__ */ jsx(
197
- "div",
198
- {
199
- "data-slot": "card-footer",
200
- className: cn("flex items-center px-6 [.border-t]:pt-6", className),
201
- ...props
202
- }
203
- );
204
- }
205
- function Input({ className, type, ...props }) {
206
- return /* @__PURE__ */ jsx(
207
- "input",
208
- {
209
- type,
210
- "data-slot": "input",
211
- className: cn(
212
- "file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input h-9 w-full min-w-0 rounded-md border bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",
213
- "focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]",
214
- "aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",
215
- className
216
- ),
217
- ...props
218
- }
219
- );
220
- }
221
- function Textarea({ className, ...props }) {
222
- return /* @__PURE__ */ jsx(
223
- "textarea",
224
- {
225
- "data-slot": "textarea",
226
- className: cn(
227
- // "min-h-16",
228
- // "field-sizing-content",
229
- "border-input placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 flex w-full rounded-md border bg-transparent px-3 py-2 text-base shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",
230
- className
231
- ),
232
- ...props
233
- }
234
- );
235
- }
236
- function InputGroup({ className, ...props }) {
237
- return /* @__PURE__ */ jsx(
238
- "div",
239
- {
240
- "data-slot": "input-group",
241
- role: "group",
242
- className: cn(
243
- "group/input-group border-input dark:bg-input/30 relative flex w-full items-center rounded-md border shadow-xs transition-[color,box-shadow] outline-none",
244
- "h-9 min-w-0 has-[>textarea]:h-auto",
245
- // Variants based on alignment.
246
- "has-[>[data-align=inline-start]]:[&>input]:pl-2",
247
- "has-[>[data-align=inline-end]]:[&>input]:pr-2",
248
- "has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>[data-align=block-start]]:[&>input]:pb-3",
249
- "has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-end]]:[&>input]:pt-3",
250
- // Focus state.
251
- "has-[[data-slot=input-group-control]:focus-visible]:border-ring has-[[data-slot=input-group-control]:focus-visible]:ring-ring/50 has-[[data-slot=input-group-control]:focus-visible]:ring-[3px]",
252
- // Error state.
253
- "has-[[data-slot][aria-invalid=true]]:ring-destructive/20 has-[[data-slot][aria-invalid=true]]:border-destructive dark:has-[[data-slot][aria-invalid=true]]:ring-destructive/40",
254
- className
255
- ),
256
- ...props
257
- }
258
- );
259
- }
260
- var inputGroupAddonVariants = cva(
261
- "text-muted-foreground flex h-auto cursor-text items-center justify-center gap-2 py-1.5 text-sm font-medium select-none [&>svg:not([class*='size-'])]:size-4 [&>kbd]:rounded-[calc(var(--radius)-5px)] group-data-[disabled=true]/input-group:opacity-50",
262
- {
263
- variants: {
264
- align: {
265
- "inline-start": "order-first pl-3 has-[>button]:ml-[-0.45rem] has-[>kbd]:ml-[-0.35rem]",
266
- "inline-end": "order-last pr-3 has-[>button]:mr-[-0.45rem] has-[>kbd]:mr-[-0.35rem]",
267
- "block-start": "order-first w-full justify-start px-3 pt-3 [.border-b]:pb-3 group-has-[>input]/input-group:pt-2.5",
268
- "block-end": "order-last w-full justify-start px-3 pb-3 [.border-t]:pt-3 group-has-[>input]/input-group:pb-2.5"
269
- }
270
- },
271
- defaultVariants: {
272
- align: "inline-start"
273
- }
274
- }
275
- );
276
- function InputGroupAddon({
277
- className,
278
- align = "inline-start",
279
- ...props
280
- }) {
281
- return /* @__PURE__ */ jsx(
282
- "div",
283
- {
284
- role: "group",
285
- "data-slot": "input-group-addon",
286
- "data-align": align,
287
- className: cn(inputGroupAddonVariants({ align }), className),
288
- onClick: (e) => {
289
- if (e.target.closest("button")) {
290
- return;
291
- }
292
- e.currentTarget.parentElement?.querySelector("input")?.focus();
293
- },
294
- ...props
295
- }
296
- );
297
- }
298
- var inputGroupButtonVariants = cva(
299
- "text-sm shadow-none flex gap-2 items-center",
300
- {
301
- variants: {
302
- size: {
303
- xs: "h-6 gap-1 px-2 rounded-[calc(var(--radius)-5px)] [&>svg:not([class*='size-'])]:size-3.5 has-[>svg]:px-2",
304
- sm: "h-8 px-2.5 gap-1.5 rounded-md has-[>svg]:px-2.5",
305
- "icon-xs": "size-6 rounded-[calc(var(--radius)-5px)] p-0 has-[>svg]:p-0",
306
- "icon-sm": "size-8 p-0 has-[>svg]:p-0"
307
- }
308
- },
309
- defaultVariants: {
310
- size: "xs"
311
- }
312
- }
313
- );
314
- function InputGroupButton({
315
- className,
316
- type = "button",
317
- variant = "ghost",
318
- size = "xs",
319
- ...props
320
- }) {
321
- return /* @__PURE__ */ jsx(
322
- Button,
323
- {
324
- type,
325
- "data-size": size,
326
- variant,
327
- className: cn(inputGroupButtonVariants({ size }), className),
328
- ...props
329
- }
330
- );
331
- }
332
- function InputGroupText({ className, ...props }) {
333
- return /* @__PURE__ */ jsx(
334
- "span",
335
- {
336
- className: cn(
337
- "text-muted-foreground flex items-center gap-2 text-sm [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4",
338
- className
339
- ),
340
- ...props
341
- }
342
- );
343
- }
344
- function InputGroupInput({
345
- className,
346
- ...props
347
- }) {
348
- return /* @__PURE__ */ jsx(
349
- Input,
350
- {
351
- "data-slot": "input-group-control",
352
- className: cn(
353
- "flex-1 rounded-none border-0 bg-transparent shadow-none focus-visible:ring-0 dark:bg-transparent",
354
- className
355
- ),
356
- ...props
357
- }
358
- );
359
- }
360
- function InputGroupTextarea({
361
- className,
362
- ...props
363
- }) {
364
- return /* @__PURE__ */ jsx(
365
- Textarea,
366
- {
367
- "data-slot": "input-group-control",
368
- className: cn(
369
- "flex-1 resize-none rounded-none border-0 bg-transparent py-3 shadow-none focus-visible:ring-0 dark:bg-transparent",
370
- className
371
- ),
372
- ...props
373
- }
374
- );
375
- }
376
- function Spinner({ className, ...props }) {
377
- return /* @__PURE__ */ jsx(
378
- Loader2Icon,
379
- {
380
- role: "status",
381
- "aria-label": "Loading",
382
- className: cn("size-4 animate-spin", className),
383
- ...props
384
- }
385
- );
386
- }
387
- function Label({ className, ...props }) {
388
- return /* @__PURE__ */ jsx(
389
- LabelPrimitive.Root,
390
- {
391
- "data-slot": "label",
392
- className: cn(
393
- "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",
394
- className
395
- ),
396
- ...props
397
- }
398
- );
399
- }
400
- function Separator({
401
- className,
402
- orientation = "horizontal",
403
- decorative = true,
404
- ...props
405
- }) {
406
- return /* @__PURE__ */ jsx(
407
- SeparatorPrimitive.Root,
408
- {
409
- "data-slot": "separator",
410
- decorative,
411
- orientation,
412
- className: cn(
413
- "bg-border shrink-0 data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-px",
414
- className
415
- ),
416
- ...props
417
- }
418
- );
419
- }
420
-
421
- export { Button, Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Input, InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput, InputGroupText, InputGroupTextarea, Label, Separator, Spinner, Textarea, cn, isConfirm, useCountdown, useDeviceInfo, useParentPathname };
@@ -1,19 +0,0 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import * as class_variance_authority_types from 'class-variance-authority/types';
3
- import { VariantProps } from 'class-variance-authority';
4
- import * as React from 'react';
5
- import * as LabelPrimitive from '@radix-ui/react-label';
6
-
7
- declare const buttonVariants: (props?: ({
8
- variant?: "link" | "default" | "success" | "destructive" | "outline" | "secondary" | "ghost" | "warning" | null | undefined;
9
- size?: "lg" | "sm" | "default" | "icon" | "icon-sm" | "icon-lg" | "xs" | null | undefined;
10
- } & class_variance_authority_types.ClassProp) | undefined) => string;
11
- type ButtonProps = React.ComponentProps<"button"> & VariantProps<typeof buttonVariants> & {
12
- asChild?: boolean;
13
- };
14
- declare function Button({ className, variant, size, asChild, ...props }: ButtonProps): react_jsx_runtime.JSX.Element;
15
-
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 };