@hilum/ui 3.2.2 → 3.2.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.
@@ -0,0 +1,85 @@
1
+ import * as React from "react";
2
+ import { ArrowRight } from "lucide-react";
3
+ import { Callout } from "./callout";
4
+ import { Switch } from "./switch";
5
+ import { cn } from "../lib/utils";
6
+
7
+ function normalizeUrlHandle(value: string): string {
8
+ return String(value || "")
9
+ .trim()
10
+ .replace(/^\/+|\/+$/g, "");
11
+ }
12
+
13
+ function urlResourcePath(prefix: string, handle: string): string {
14
+ const cleanPrefix = normalizeUrlHandle(prefix);
15
+ const cleanHandle = normalizeUrlHandle(handle);
16
+ if (!cleanPrefix || !cleanHandle) return "";
17
+ return `/${cleanPrefix}/${cleanHandle}`;
18
+ }
19
+
20
+ function hasUrlHandleChanged(originalHandle?: string, nextHandle?: string): boolean {
21
+ const original = normalizeUrlHandle(originalHandle || "");
22
+ const next = normalizeUrlHandle(nextHandle || "");
23
+ return Boolean(original && next && original !== next);
24
+ }
25
+
26
+ interface UrlRedirectPromptProps {
27
+ originalHandle?: string;
28
+ nextHandle?: string;
29
+ pathPrefix: string;
30
+ checked: boolean;
31
+ onCheckedChange: (checked: boolean) => void;
32
+ title?: React.ReactNode;
33
+ description?: React.ReactNode;
34
+ switchLabel?: string;
35
+ className?: string;
36
+ }
37
+
38
+ function UrlRedirectPrompt({
39
+ originalHandle,
40
+ nextHandle,
41
+ pathPrefix,
42
+ checked,
43
+ onCheckedChange,
44
+ title = "Create URL redirect",
45
+ description,
46
+ switchLabel = "Create URL redirect",
47
+ className,
48
+ }: UrlRedirectPromptProps) {
49
+ if (!hasUrlHandleChanged(originalHandle, nextHandle)) return null;
50
+
51
+ const fromPath = urlResourcePath(pathPrefix, originalHandle || "");
52
+ const toPath = urlResourcePath(pathPrefix, nextHandle || "");
53
+ const calloutProps = className ? { className } : {};
54
+
55
+ return (
56
+ <Callout
57
+ tone="warning"
58
+ compact
59
+ icon={<ArrowRight aria-hidden="true" />}
60
+ title={title}
61
+ actions={
62
+ <Switch checked={checked} onCheckedChange={onCheckedChange} aria-label={switchLabel} />
63
+ }
64
+ {...calloutProps}
65
+ >
66
+ {description || (
67
+ <p className="body-sm text-pretty text-muted-foreground">
68
+ Preserve search rankings and old links by redirecting{" "}
69
+ <span className="font-mono text-foreground">{fromPath}</span> to{" "}
70
+ <span className="font-mono text-foreground">{toPath}</span>.
71
+ </p>
72
+ )}
73
+ </Callout>
74
+ );
75
+ }
76
+
77
+ UrlRedirectPrompt.displayName = "UrlRedirectPrompt";
78
+
79
+ export {
80
+ UrlRedirectPrompt,
81
+ hasUrlHandleChanged,
82
+ normalizeUrlHandle,
83
+ urlResourcePath,
84
+ };
85
+ export type { UrlRedirectPromptProps };
package/src/index.ts CHANGED
@@ -23,6 +23,7 @@ export * from "./components/breadcrumb";
23
23
  export * from "./components/button-group";
24
24
  export * from "./components/button";
25
25
  export * from "./components/calendar";
26
+ export * from "./components/callout";
26
27
  export * from "./components/card-heading";
27
28
  export * from "./components/card";
28
29
  export * from "./components/carousel";
@@ -36,6 +37,7 @@ export * from "./components/command-palette";
36
37
  export * from "./components/command";
37
38
  export * from "./components/context-menu";
38
39
  export * from "./components/data-table";
40
+ export * from "./components/data-transfer-controls";
39
41
  export * from "./components/date-picker";
40
42
  export * from "./components/description-list";
41
43
  export * from "./components/dialog";
@@ -43,7 +45,9 @@ export * from "./components/drawer";
43
45
  export * from "./components/dropdown-menu";
44
46
  export * from "./components/empty-state";
45
47
  export * from "./components/field";
48
+ export * from "./components/file-dropzone";
46
49
  export * from "./components/grid-list";
50
+ export * from "./components/help-tooltip";
47
51
  export * from "./components/hover-card";
48
52
  export * from "./components/input-group";
49
53
  export * from "./components/input-number";
@@ -51,6 +55,7 @@ export * from "./components/input-otp";
51
55
  export * from "./components/input";
52
56
  export * from "./components/kbd";
53
57
  export * from "./components/label";
58
+ export * from "./components/media-asset-card";
54
59
  export * from "./components/media-object";
55
60
  export * from "./components/menubar";
56
61
  export * from "./components/native-select";
@@ -64,8 +69,10 @@ export * from "./components/property-row";
64
69
  export * from "./components/radio-card";
65
70
  export * from "./components/radio-group";
66
71
  export * from "./components/resizable";
72
+ export * from "./components/rich-text-editor";
67
73
  export * from "./components/scroll-area";
68
74
  export * from "./components/section-heading";
75
+ export * from "./components/searchable-table";
69
76
  export * from "./components/select";
70
77
  export * from "./components/separator";
71
78
  export * from "./components/sheet";
@@ -76,11 +83,14 @@ export * from "./components/sonner";
76
83
  export * from "./components/spinner";
77
84
  export * from "./components/stacked-list";
78
85
  export * from "./components/stat-card";
86
+ export * from "./components/status-badge";
79
87
  export * from "./components/steps";
80
88
  export * from "./components/switch";
81
89
  export * from "./components/table";
82
90
  export * from "./components/tabs";
83
91
  export * from "./components/textarea";
92
+ export * from "./components/titled-card";
84
93
  export * from "./components/toggle-group";
85
94
  export * from "./components/toggle";
86
95
  export * from "./components/tooltip";
96
+ export * from "./components/url-redirect-prompt";
@@ -0,0 +1,78 @@
1
+ export const mobileDialogSheetContentClassName = [
2
+ "fixed inset-x-0 bottom-0 z-50 max-h-[calc(100dvh-1rem)] w-full overflow-y-auto",
3
+ "rounded-t-2xl border border-border bg-card p-6 shadow-elevated",
4
+ "max-sm:pb-[calc(1.5rem+env(safe-area-inset-bottom))] max-sm:pt-8",
5
+ "max-sm:before:absolute max-sm:before:left-1/2 max-sm:before:top-3 max-sm:before:h-1 max-sm:before:w-9",
6
+ "max-sm:before:-translate-x-1/2 max-sm:before:rounded-full max-sm:before:bg-muted-foreground/35",
7
+ ].join(" ");
8
+
9
+ export const desktopDialogContentClassName =
10
+ "sm:bottom-auto sm:left-1/2 sm:top-1/2 sm:max-h-[calc(100dvh-2rem)] sm:-translate-x-1/2 sm:-translate-y-1/2 sm:rounded-2xl";
11
+
12
+ export const dialogSheetMotionClassName = [
13
+ "data-[state=open]:animate-in data-[state=closed]:animate-out",
14
+ "data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
15
+ "data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",
16
+ "sm:data-[state=closed]:zoom-out-95 sm:data-[state=open]:zoom-in-95",
17
+ ].join(" ");
18
+
19
+ export const mobilePopperSheetPositionClassName = [
20
+ "max-sm:!fixed max-sm:!inset-x-3 max-sm:!bottom-3 max-sm:!top-auto max-sm:!left-3 max-sm:!right-3",
21
+ "max-sm:!w-auto max-sm:!min-w-0 max-sm:!max-w-none max-sm:!transform-none",
22
+ ].join(" ");
23
+
24
+ export const mobilePopperSheetSurfaceClassName =
25
+ "max-sm:max-h-[min(70dvh,28rem)] max-sm:rounded-2xl max-sm:border max-sm:border-border max-sm:shadow-elevated";
26
+
27
+ export const mobilePopperSheetMotionClassName = [
28
+ "max-sm:data-[state=closed]:slide-out-to-bottom max-sm:data-[state=open]:slide-in-from-bottom",
29
+ ].join(" ");
30
+
31
+ export const mobilePopperSheetStyle = `
32
+ @media (max-width: 639px) {
33
+ [data-radix-popper-content-wrapper]:has([data-hilum-mobile-sheet="true"]) {
34
+ position: fixed !important;
35
+ inset: 0 !important;
36
+ min-width: 0 !important;
37
+ transform: none !important;
38
+ pointer-events: none;
39
+ z-index: 50 !important;
40
+ }
41
+
42
+ [data-radix-popper-content-wrapper]:has([data-hilum-mobile-sheet="true"][data-state="open"])::before {
43
+ content: "";
44
+ position: fixed;
45
+ inset: 0;
46
+ background: rgb(0 0 0 / 0.3);
47
+ backdrop-filter: blur(4px);
48
+ pointer-events: auto;
49
+ }
50
+
51
+ [data-hilum-mobile-sheet="true"] {
52
+ position: fixed !important;
53
+ left: 0.75rem !important;
54
+ right: 0.75rem !important;
55
+ bottom: max(0.75rem, env(safe-area-inset-bottom)) !important;
56
+ top: auto !important;
57
+ width: calc(100dvw - 1.5rem) !important;
58
+ min-width: 0 !important;
59
+ max-width: none !important;
60
+ transform: none !important;
61
+ pointer-events: auto;
62
+ transform-origin: bottom center !important;
63
+ overscroll-behavior: contain;
64
+ }
65
+
66
+ [data-hilum-mobile-sheet="true"]::before {
67
+ content: "";
68
+ position: absolute;
69
+ top: 0.5rem;
70
+ left: 50%;
71
+ width: 2.25rem;
72
+ height: 0.25rem;
73
+ border-radius: 999px;
74
+ background: hsl(var(--muted-foreground) / 0.35);
75
+ transform: translateX(-50%);
76
+ }
77
+ }
78
+ `;