@startsimpli/ui 0.4.93 → 0.4.94

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,6 +1,8 @@
1
1
  import * as React from "react"
2
2
 
3
3
  import { cn } from "../../lib/utils"
4
+ import { Caveat } from "../states/Caveat"
5
+ import { Footnote } from "../states/Footnote"
4
6
 
5
7
  const Card = React.forwardRef<
6
8
  HTMLDivElement,
@@ -17,12 +19,41 @@ const Card = React.forwardRef<
17
19
  ))
18
20
  Card.displayName = "Card"
19
21
 
20
- const CardHeader = React.forwardRef<
21
- HTMLDivElement,
22
- React.HTMLAttributes<HTMLDivElement>
23
- >(({ className, ...props }, ref) => (
24
- <div ref={ref} className={cn("flex flex-col space-y-1.5 p-6", className)} {...props} />
25
- ))
22
+ export interface CardHeaderProps extends React.HTMLAttributes<HTMLDivElement> {
23
+ /**
24
+ * A qualification of what this card shows. Collapses to a marker at the end
25
+ * of the header and expands on demand — the card's canonical caveat slot, so
26
+ * apps stop putting the caveat in the body at the weight of the data.
27
+ */
28
+ caveat?: React.ReactNode
29
+ /**
30
+ * A caveat that belongs to the whole section. Inside a `FootnoteScope` it is
31
+ * printed once beneath the section rather than once per card.
32
+ */
33
+ note?: string
34
+ }
35
+
36
+ const CardHeader = React.forwardRef<HTMLDivElement, CardHeaderProps>(
37
+ ({ className, caveat, note, children, ...props }, ref) => {
38
+ const hasCaveat = Boolean(caveat || note)
39
+
40
+ return (
41
+ <div ref={ref} className={cn("flex flex-col space-y-1.5 p-6", className)} {...props}>
42
+ {hasCaveat ? (
43
+ <div className="flex items-start justify-between gap-2">
44
+ <div className="flex min-w-0 flex-col space-y-1.5">{children}</div>
45
+ <span className="flex shrink-0 items-center">
46
+ {caveat ? <Caveat>{caveat}</Caveat> : null}
47
+ {note ? <Footnote note={note} /> : null}
48
+ </span>
49
+ </div>
50
+ ) : (
51
+ children
52
+ )}
53
+ </div>
54
+ )
55
+ }
56
+ )
26
57
  CardHeader.displayName = "CardHeader"
27
58
 
28
59
  const CardTitle = React.forwardRef<