@hilum/ui 3.6.0 → 3.6.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hilum/ui",
3
- "version": "3.6.0",
3
+ "version": "3.6.2",
4
4
  "private": false,
5
5
  "description": "Hilum UI — design system primitives (Button, Input, Dialog, Combobox, …) + tokens + fonts + icons",
6
6
  "license": "MIT",
@@ -17,6 +17,11 @@ import { spring } from "../lib/springs";
17
17
  import { useShape } from "../lib/shape-context";
18
18
  import { SurfaceProvider, useSurface } from "../lib/surface-context";
19
19
  import { surfaceClasses } from "../lib/surface-classes";
20
+ import {
21
+ desktopDialogContentClassName,
22
+ dialogSheetMotionClassName,
23
+ mobileDialogSheetContentClassName,
24
+ } from "../lib/mobile-popper-sheet";
20
25
  import { Button } from "./button";
21
26
 
22
27
  const DIALOG_OFFSET = 4;
@@ -75,6 +80,15 @@ const DialogContent = forwardRef<HTMLDivElement, DialogContentProps>(
75
80
 
76
81
  if (!mounted) return null;
77
82
 
83
+ const sizeClassName =
84
+ size === "sm"
85
+ ? container
86
+ ? "max-w-[400px]"
87
+ : "sm:max-w-[400px]"
88
+ : container
89
+ ? "max-w-[540px]"
90
+ : "sm:max-w-[540px]";
91
+
78
92
  return (
79
93
  <DialogPrimitive.Portal forceMount container={container ?? undefined}>
80
94
  <DialogPrimitive.Overlay asChild forceMount>
@@ -91,24 +105,31 @@ const DialogContent = forwardRef<HTMLDivElement, DialogContentProps>(
91
105
  <DialogPrimitive.Content ref={ref} asChild forceMount {...props}>
92
106
  <motion.div
93
107
  className={cn(
94
- container ? "absolute" : "fixed",
95
- "left-1/2 top-1/2 z-50 w-[calc(100%-2rem)]",
108
+ container
109
+ ? "absolute left-1/2 top-1/2 z-50 w-[calc(100%-2rem)]"
110
+ : [
111
+ mobileDialogSheetContentClassName,
112
+ desktopDialogContentClassName,
113
+ dialogSheetMotionClassName,
114
+ ],
96
115
  surfaceClasses(dialogLevel),
97
116
  "p-6 focus:outline-none",
98
- "rounded-t-2xl max-sm:pb-[calc(1.5rem+env(safe-area-inset-bottom))] data-[state=open]:slide-in-from-bottom sm:data-[state=open]:zoom-in-95",
99
- size === "sm" && "max-w-[400px]",
100
- size === "lg" && "max-w-[540px]",
117
+ sizeClassName,
101
118
  shape.container,
102
119
  "rounded-t-2xl",
103
120
  className,
104
121
  )}
105
- initial={{ opacity: 0, scale: 0.97, x: "-50%", y: "-50%" }}
106
- animate={{
107
- opacity: open ? 1 : 0,
108
- scale: open ? 1 : 0.97,
109
- x: "-50%",
110
- y: "-50%",
111
- }}
122
+ initial={container ? { opacity: 0, scale: 0.97, x: "-50%", y: "-50%" } : { opacity: 0 }}
123
+ animate={
124
+ container
125
+ ? {
126
+ opacity: open ? 1 : 0,
127
+ scale: open ? 1 : 0.97,
128
+ x: "-50%",
129
+ y: "-50%",
130
+ }
131
+ : { opacity: open ? 1 : 0 }
132
+ }
112
133
  transition={open ? spring.slow : spring.slow.exit}
113
134
  onAnimationComplete={handleExitComplete}
114
135
  >
@@ -0,0 +1,56 @@
1
+ import * as React from "react";
2
+ import { cn } from "../lib/utils";
3
+
4
+ interface SummaryTileGridProps extends React.HTMLAttributes<HTMLDivElement> {
5
+ columns?: 2 | 3 | 4;
6
+ }
7
+
8
+ interface SummaryTileProps extends React.HTMLAttributes<HTMLDivElement> {
9
+ title: string;
10
+ value: React.ReactNode;
11
+ description?: React.ReactNode;
12
+ }
13
+
14
+ const columnClassName: Record<NonNullable<SummaryTileGridProps["columns"]>, string> = {
15
+ 2: "md:grid-cols-2",
16
+ 3: "md:grid-cols-2 xl:grid-cols-3",
17
+ 4: "md:grid-cols-2 xl:grid-cols-4",
18
+ };
19
+
20
+ function SummaryTileGrid({ columns = 3, className, ...props }: SummaryTileGridProps) {
21
+ return (
22
+ <div
23
+ data-slot="summary-tile-grid"
24
+ className={cn(
25
+ "divide-y divide-border md:grid md:gap-3 md:divide-y-0",
26
+ columnClassName[columns],
27
+ className,
28
+ )}
29
+ {...props}
30
+ />
31
+ );
32
+ }
33
+
34
+ function SummaryTile({ title, value, description, className, ...props }: SummaryTileProps) {
35
+ return (
36
+ <div
37
+ data-slot="summary-tile"
38
+ className={cn(
39
+ "min-w-0 py-4 md:rounded-lg md:border md:border-border md:bg-card md:p-4",
40
+ className,
41
+ )}
42
+ {...props}
43
+ >
44
+ <p className="text-xs font-semibold uppercase tracking-wide text-muted-foreground">{title}</p>
45
+ <p className="mt-2 text-xl font-semibold text-foreground">{value}</p>
46
+ {description ? (
47
+ <p className="mt-1 text-sm leading-5 text-muted-foreground">{description}</p>
48
+ ) : null}
49
+ </div>
50
+ );
51
+ }
52
+
53
+ SummaryTileGrid.displayName = "SummaryTileGrid";
54
+ SummaryTile.displayName = "SummaryTile";
55
+
56
+ export { SummaryTile, SummaryTileGrid, type SummaryTileProps, type SummaryTileGridProps };
@@ -2,13 +2,7 @@
2
2
 
3
3
  import * as React from "react";
4
4
  import { cn } from "../lib/utils";
5
- import {
6
- Card,
7
- CardContent,
8
- CardDescription,
9
- CardHeader,
10
- CardTitle,
11
- } from "./card";
5
+ import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "./card";
12
6
  import { CardHeading } from "./card-heading";
13
7
 
14
8
  interface TitledCardProps {
@@ -17,6 +11,7 @@ interface TitledCardProps {
17
11
  children?: React.ReactNode;
18
12
  actionButtons?: React.ReactNode;
19
13
  icon?: React.ComponentType<{ className?: string }>;
14
+ contentPadding?: "default" | "flush-mobile" | "flush";
20
15
  className?: string;
21
16
  contentClassName?: string;
22
17
  containerClassName?: string;
@@ -29,6 +24,7 @@ function TitledCard({
29
24
  children,
30
25
  actionButtons,
31
26
  icon: Icon,
27
+ contentPadding = "default",
32
28
  className,
33
29
  contentClassName,
34
30
  containerClassName,
@@ -36,6 +32,14 @@ function TitledCard({
36
32
  }: TitledCardProps) {
37
33
  const hasHeader = Boolean(title || subtitle || actionButtons);
38
34
  const canUseCardHeading = Boolean(title) && !actionButtons && !titleClassName;
35
+ const contentPaddingClassName =
36
+ contentPadding === "flush"
37
+ ? "p-0"
38
+ : contentPadding === "flush-mobile"
39
+ ? "p-0 sm:p-5"
40
+ : hasHeader
41
+ ? "p-4 sm:p-5"
42
+ : "p-0 sm:p-5";
39
43
 
40
44
  return (
41
45
  <Card
@@ -84,11 +88,7 @@ function TitledCard({
84
88
  ) : null}
85
89
  {children && (
86
90
  <CardContent
87
- className={cn(
88
- hasHeader ? "p-4 sm:p-5" : "p-0 sm:p-5",
89
- "min-w-0 max-sm:px-0",
90
- contentClassName,
91
- )}
91
+ className={cn(contentPaddingClassName, "min-w-0 max-sm:px-0", contentClassName)}
92
92
  >
93
93
  {children}
94
94
  </CardContent>
package/src/index.ts CHANGED
@@ -99,6 +99,7 @@ export * from "./components/stacked-list";
99
99
  export * from "./components/stat-card";
100
100
  export * from "./components/status-badge";
101
101
  export * from "./components/steps";
102
+ export * from "./components/summary-tile";
102
103
  export * from "./components/switch";
103
104
  export * from "./components/table";
104
105
  export * from "./components/tabs";