@passui/react 0.1.45 → 0.1.46

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.
Files changed (140) hide show
  1. package/README.md +57 -46
  2. package/dist/types/src/components/accordion/accordion.d.ts +1 -1
  3. package/dist/types/src/components/breadcrumb/breadcrumb.d.ts +1 -1
  4. package/dist/types/src/components/inline-disclosure/inline-disclosure.d.ts +1 -1
  5. package/dist/types/src/components/popover/anchored-surface.d.ts +5 -1
  6. package/dist/types/src/components/popover/index.d.ts +41 -0
  7. package/dist/types/src/components/popover/popover-content.d.ts +32 -0
  8. package/dist/types/src/components/popover/popover-root.d.ts +22 -0
  9. package/dist/types/src/components/popover/popover-trigger.d.ts +23 -0
  10. package/dist/types/src/components/stepper/rolling-digit.d.ts +1 -1
  11. package/dist/types/src/components/table/table.d.ts +1 -1
  12. package/dist/types/src/components/view-controller/view-controller.d.ts +2 -2
  13. package/dist/types/src/index.d.ts +1 -1
  14. package/dist/types/src/machines/popover.machine.d.ts +30 -0
  15. package/package.json +307 -307
  16. package/src/appearance/index.ts +2 -2
  17. package/src/appearance/platform.tsx +76 -60
  18. package/src/appearance/theme.tsx +409 -377
  19. package/src/components/accordion/accordion.tsx +58 -49
  20. package/src/components/ambient/ambient.tsx +25 -25
  21. package/src/components/ambient/index.ts +1 -1
  22. package/src/components/aspect-ratio/aspect-ratio.tsx +21 -16
  23. package/src/components/breadcrumb/breadcrumb.tsx +63 -57
  24. package/src/components/button/button-styles.ts +39 -32
  25. package/src/components/button/button.tsx +91 -84
  26. package/src/components/button/icon-button.tsx +27 -25
  27. package/src/components/button/pending-spinner.tsx +8 -8
  28. package/src/components/button/use-pending-indicator.ts +11 -11
  29. package/src/components/chip/chip.tsx +35 -30
  30. package/src/components/code-block/code-block.tsx +40 -39
  31. package/src/components/combo-box/combo-box.tsx +5 -5
  32. package/src/components/command/command.tsx +124 -94
  33. package/src/components/compact-date-picker/calendar-month.ts +75 -53
  34. package/src/components/compact-date-picker/compact-date-picker.tsx +308 -289
  35. package/src/components/compact-time-picker/compact-time-picker.tsx +288 -281
  36. package/src/components/compact-time-picker/time-value.ts +32 -29
  37. package/src/components/content-unavailable-view/content-unavailable-view.tsx +64 -48
  38. package/src/components/content-view/content-view.tsx +168 -159
  39. package/src/components/content-view/index.ts +1 -1
  40. package/src/components/context-menu/conceal-menu-source.ts +25 -25
  41. package/src/components/context-menu/context-menu-host.tsx +439 -402
  42. package/src/components/context-menu/context-menu-store.ts +125 -123
  43. package/src/components/context-menu/menu-navigation.ts +25 -18
  44. package/src/components/context-menu/menu-position.ts +33 -29
  45. package/src/components/context-menu/menu-reveal.ts +32 -32
  46. package/src/components/context-menu/use-context-menu.ts +63 -56
  47. package/src/components/conversation/conversation.tsx +265 -263
  48. package/src/components/conversation/index.ts +1 -1
  49. package/src/components/date-picker/date-picker.tsx +95 -94
  50. package/src/components/date-picker/date-value.ts +20 -10
  51. package/src/components/dialog/dialog-host.tsx +105 -103
  52. package/src/components/dialog/dialog-store.ts +37 -36
  53. package/src/components/dialog/dialog.tsx +192 -179
  54. package/src/components/dialog/index.ts +1 -1
  55. package/src/components/disclosure-group/disclosure-group.tsx +93 -86
  56. package/src/components/divider/divider.tsx +24 -22
  57. package/src/components/inline-disclosure/inline-disclosure.tsx +40 -36
  58. package/src/components/keyboard-shortcut/keyboard-shortcut.tsx +23 -19
  59. package/src/components/labeled-content/labeled-content.tsx +68 -68
  60. package/src/components/locale-switcher/index.ts +1 -1
  61. package/src/components/locale-switcher/locale-switcher.tsx +279 -251
  62. package/src/components/menu/menu.tsx +75 -58
  63. package/src/components/morph/index.ts +2 -2
  64. package/src/components/morph/morph.tsx +227 -201
  65. package/src/components/morph/use-morph-disclosure.ts +19 -19
  66. package/src/components/one-time-code/one-time-code.tsx +216 -200
  67. package/src/components/picker/picker-trigger.ts +16 -13
  68. package/src/components/picker/picker.tsx +371 -345
  69. package/src/components/popover/anchored-surface.tsx +253 -229
  70. package/src/components/popover/index.ts +50 -0
  71. package/src/components/popover/popover-content.tsx +334 -0
  72. package/src/components/popover/popover-fit.ts +58 -53
  73. package/src/components/popover/popover-root.tsx +97 -0
  74. package/src/components/popover/popover-trigger.tsx +71 -0
  75. package/src/components/profile-image/profile-image.tsx +80 -64
  76. package/src/components/progress-view/progress-view.tsx +61 -59
  77. package/src/components/progress-view/use-liquid-progress.ts +38 -38
  78. package/src/components/radio-group/radio-group.tsx +71 -68
  79. package/src/components/search-field/expanding-search-field.tsx +191 -177
  80. package/src/components/search-field/search-field.tsx +59 -50
  81. package/src/components/search-list/search-list.tsx +246 -236
  82. package/src/components/section/section.tsx +58 -58
  83. package/src/components/secure-field/secure-field.tsx +3 -3
  84. package/src/components/segmented-control/segmented-control.tsx +136 -136
  85. package/src/components/sheet/modal-environment.ts +71 -64
  86. package/src/components/sheet/sheet-portal.tsx +58 -53
  87. package/src/components/sheet/sheet.tsx +146 -141
  88. package/src/components/sheet/use-sheet-focus.ts +97 -82
  89. package/src/components/sidebar/sidebar.tsx +78 -78
  90. package/src/components/skeleton/skeleton.tsx +30 -21
  91. package/src/components/slider/slider.tsx +113 -104
  92. package/src/components/slosh-slider/liquid-step.ts +32 -31
  93. package/src/components/slosh-slider/slosh-slider.tsx +265 -228
  94. package/src/components/stat-tile/index.ts +1 -1
  95. package/src/components/stat-tile/stat-tile.tsx +79 -68
  96. package/src/components/status-indicator/status-indicator.tsx +40 -37
  97. package/src/components/stepper/rolling-digit.tsx +82 -68
  98. package/src/components/stepper/stepper.tsx +122 -113
  99. package/src/components/swatch-picker/swatch-picker.tsx +120 -120
  100. package/src/components/tab-bar/tab-bar.tsx +149 -148
  101. package/src/components/tab-view/tab-view.tsx +140 -137
  102. package/src/components/table/table.tsx +117 -98
  103. package/src/components/text-editor/text-editor.tsx +34 -29
  104. package/src/components/text-field/text-field.tsx +182 -180
  105. package/src/components/toast/toast-store.ts +127 -115
  106. package/src/components/toast/toaster.tsx +361 -347
  107. package/src/components/toggle/toggle.tsx +297 -282
  108. package/src/components/tooltip/tooltip-host.tsx +157 -150
  109. package/src/components/view-controller/index.ts +1 -1
  110. package/src/components/view-controller/view-controller.tsx +64 -53
  111. package/src/components/wake-slider/wake-slider.tsx +220 -205
  112. package/src/hooks/scroll/minimize-decision.ts +11 -7
  113. package/src/hooks/use-anchored-disclosure.ts +19 -19
  114. package/src/hooks/use-anchored-placement.ts +29 -25
  115. package/src/hooks/use-dismiss.ts +33 -29
  116. package/src/hooks/use-floating-dismiss.ts +24 -22
  117. package/src/hooks/use-media-query.ts +67 -60
  118. package/src/hooks/use-minimize-on-scroll.ts +69 -60
  119. package/src/hooks/use-visual-viewport.ts +63 -63
  120. package/src/hooks/viewport/types.ts +16 -16
  121. package/src/hooks/viewport/viewport-metrics.ts +16 -10
  122. package/src/icons/icons.tsx +440 -328
  123. package/src/index.ts +91 -91
  124. package/src/lib/anchored-placement.ts +70 -65
  125. package/src/lib/class-names.ts +14 -13
  126. package/src/lib/clipboard.ts +8 -7
  127. package/src/lib/date.ts +61 -60
  128. package/src/lib/floating-layers.ts +39 -24
  129. package/src/lib/haptics.ts +10 -10
  130. package/src/lib/language.ts +9 -9
  131. package/src/lib/range-value.ts +27 -21
  132. package/src/lib/screen-edges.ts +33 -30
  133. package/src/lib/shapes.ts +38 -34
  134. package/src/machines/popover.machine.ts +51 -0
  135. package/src/motion/transitions.ts +46 -43
  136. package/src/styles/code-block.css +69 -43
  137. package/src/styles/motion-controls.css +393 -191
  138. package/src/tokens.ts +1 -1
  139. package/dist/types/src/components/popover/popover.d.ts +0 -21
  140. package/src/components/popover/popover.tsx +0 -334
@@ -1,55 +1,58 @@
1
1
  /** A time of day on a 24 hour clock. */
2
2
  export interface TimeOfDay {
3
- hour: number
4
- minute: number
3
+ hour: number;
4
+ minute: number;
5
5
  }
6
6
 
7
7
  /** Reads `HH:MM` (24 hour); null for anything else. */
8
8
  export function parseTime(value: string): TimeOfDay | null {
9
- const match = /^(\d{2}):(\d{2})$/.exec(value)
10
- if (!match) return null
11
- const hour = Number(match[1])
12
- const minute = Number(match[2])
13
- return hour < 24 && minute < 60 ? { hour, minute } : null
9
+ const match = /^(\d{2}):(\d{2})$/.exec(value);
10
+ if (!match) return null;
11
+ const hour = Number(match[1]);
12
+ const minute = Number(match[2]);
13
+ return hour < 24 && minute < 60 ? { hour, minute } : null;
14
14
  }
15
15
 
16
16
  export function formatTime({ hour, minute }: TimeOfDay): string {
17
- return `${String(hour).padStart(2, "0")}:${String(minute).padStart(2, "0")}`
17
+ return `${String(hour).padStart(2, "0")}:${String(minute).padStart(2, "0")}`;
18
18
  }
19
19
 
20
20
  /** Whether people where `locale` is used read time on a 12 hour clock. */
21
21
  export function usesTwelveHours(locale: string): boolean {
22
- try {
23
- const cycle = new Intl.DateTimeFormat(locale, {
24
- hour: "numeric",
25
- }).resolvedOptions().hourCycle
26
- return cycle === "h11" || cycle === "h12"
27
- } catch {
28
- return false
29
- }
22
+ try {
23
+ const cycle = new Intl.DateTimeFormat(locale, {
24
+ hour: "numeric",
25
+ }).resolvedOptions().hourCycle;
26
+ return cycle === "h11" || cycle === "h12";
27
+ } catch {
28
+ return false;
29
+ }
30
30
  }
31
31
 
32
32
  /** The hour as shown on a 12 hour clock (12, 1 to 11) and whether it's after noon. */
33
33
  export function toTwelveHours(hour: number): {
34
- hour: number
35
- pm: boolean
34
+ hour: number;
35
+ pm: boolean;
36
36
  } {
37
- return {
38
- hour: hour % 12 === 0 ? 12 : hour % 12,
39
- pm: hour >= 12,
40
- }
37
+ return {
38
+ hour: hour % 12 === 0 ? 12 : hour % 12,
39
+ pm: hour >= 12,
40
+ };
41
41
  }
42
42
 
43
43
  export function fromTwelveHours(hour: number, pm: boolean): number {
44
- return (hour % 12) + (pm ? 12 : 0)
44
+ return (hour % 12) + (pm ? 12 : 0);
45
45
  }
46
46
 
47
47
  /** Minutes offered in steps of `step`, keeping `current` when it falls between them. */
48
48
  export function minuteChoices(step: number, current?: number): number[] {
49
- const choices = Array.from({ length: Math.ceil(60 / step) }, (_, index) => index * step)
50
- if (current !== undefined && !choices.includes(current)) {
51
- choices.push(current)
52
- choices.sort((a, b) => a - b)
53
- }
54
- return choices
49
+ const choices = Array.from(
50
+ { length: Math.ceil(60 / step) },
51
+ (_, index) => index * step,
52
+ );
53
+ if (current !== undefined && !choices.includes(current)) {
54
+ choices.push(current);
55
+ choices.sort((a, b) => a - b);
56
+ }
57
+ return choices;
55
58
  }
@@ -1,62 +1,78 @@
1
- import type { ReactNode, ComponentProps } from "react"
2
- import { cn } from "../../lib/class-names"
1
+ import type { ReactNode, ComponentProps } from "react";
2
+ import { cn } from "../../lib/class-names";
3
3
 
4
- export type ContentUnavailableViewSize = "sm" | "md" | "lg"
4
+ export type ContentUnavailableViewSize = "sm" | "md" | "lg";
5
5
 
6
6
  const titleSizes: Record<ContentUnavailableViewSize, string> = {
7
- sm: "text-subheadline",
8
- md: "text-headline",
9
- lg: "text-title3",
10
- }
7
+ sm: "text-subheadline",
8
+ md: "text-headline",
9
+ lg: "text-title3",
10
+ };
11
11
 
12
12
  const descriptionSizes: Record<ContentUnavailableViewSize, string> = {
13
- sm: "text-caption",
14
- md: "text-footnote",
15
- lg: "text-subheadline",
16
- }
13
+ sm: "text-caption",
14
+ md: "text-footnote",
15
+ lg: "text-subheadline",
16
+ };
17
17
 
18
18
  const spacings: Record<ContentUnavailableViewSize, string> = {
19
- sm: "gap-2 px-6 py-6",
20
- md: "gap-3 px-6 py-10",
21
- lg: "gap-4 px-6 py-14",
22
- }
19
+ sm: "gap-2 px-6 py-6",
20
+ md: "gap-3 px-6 py-10",
21
+ lg: "gap-4 px-6 py-14",
22
+ };
23
23
 
24
- export interface ContentUnavailableViewProps extends Omit<ComponentProps<"div">, "title"> {
25
- title: string
26
- description?: string
27
- icon?: ReactNode
28
- actions?: ReactNode
29
- /** Title, description and vertical rhythm. @default "md" */
30
- size?: ContentUnavailableViewSize
24
+ export interface ContentUnavailableViewProps
25
+ extends Omit<ComponentProps<"div">, "title"> {
26
+ title: string;
27
+ description?: string;
28
+ icon?: ReactNode;
29
+ actions?: ReactNode;
30
+ /** Title, description and vertical rhythm. @default "md" */
31
+ size?: ContentUnavailableViewSize;
31
32
  }
32
33
 
33
34
  /** A focused empty or unavailable state with an optional next action. */
34
35
  export function ContentUnavailableView({
35
- title,
36
- description,
37
- icon,
38
- actions,
39
- size = "md",
40
- className,
41
- ...props
36
+ title,
37
+ description,
38
+ icon,
39
+ actions,
40
+ size = "md",
41
+ className,
42
+ ...props
42
43
  }: ContentUnavailableViewProps) {
43
- return (
44
- <div
45
- {...props}
46
- className={cn("flex flex-col items-center text-center", spacings[size], className)}
47
- >
48
- {icon && (
49
- <span aria-hidden="true" className="text-label-tertiary">
50
- {icon}
51
- </span>
52
- )}
53
- <p className={cn(titleSizes[size], "font-semibold text-label")}>{title}</p>
54
- {description && (
55
- <p className={cn(descriptionSizes[size], "max-w-sm text-label-secondary")}>
56
- {description}
57
- </p>
58
- )}
59
- {actions && <div className="mt-1 flex flex-wrap justify-center gap-2">{actions}</div>}
60
- </div>
61
- )
44
+ return (
45
+ <div
46
+ {...props}
47
+ className={cn(
48
+ "flex flex-col items-center text-center",
49
+ spacings[size],
50
+ className,
51
+ )}
52
+ >
53
+ {icon && (
54
+ <span aria-hidden="true" className="text-label-tertiary">
55
+ {icon}
56
+ </span>
57
+ )}
58
+ <p className={cn(titleSizes[size], "text-label font-semibold")}>
59
+ {title}
60
+ </p>
61
+ {description && (
62
+ <p
63
+ className={cn(
64
+ descriptionSizes[size],
65
+ "text-label-secondary max-w-sm",
66
+ )}
67
+ >
68
+ {description}
69
+ </p>
70
+ )}
71
+ {actions && (
72
+ <div className="mt-1 flex flex-wrap justify-center gap-2">
73
+ {actions}
74
+ </div>
75
+ )}
76
+ </div>
77
+ );
62
78
  }
@@ -1,206 +1,215 @@
1
1
  import {
2
- createContext,
3
- useContext,
4
- type ComponentPropsWithoutRef,
5
- type PropsWithChildren,
6
- type ReactNode,
7
- } from "react"
8
- import { cn } from "../../lib/class-names"
9
-
10
- export type ContentViewVariant = keyof typeof variants
11
- export type ContentViewHeadingLevel = "h1" | "h2" | "h3"
12
- export type ContentViewSize = "sm" | "md" | "lg"
2
+ createContext,
3
+ useContext,
4
+ type ComponentPropsWithoutRef,
5
+ type PropsWithChildren,
6
+ type ReactNode,
7
+ } from "react";
8
+ import { cn } from "../../lib/class-names";
9
+
10
+ export type ContentViewVariant = keyof typeof variants;
11
+ export type ContentViewHeadingLevel = "h1" | "h2" | "h3";
12
+ export type ContentViewSize = "sm" | "md" | "lg";
13
13
 
14
14
  const containerRadius: Record<ContentViewSize, string> = {
15
- sm: "rounded-xl",
16
- md: "rounded-2xl",
17
- lg: "rounded-3xl",
18
- }
15
+ sm: "rounded-xl",
16
+ md: "rounded-2xl",
17
+ lg: "rounded-3xl",
18
+ };
19
19
  const sectionGaps: Record<ContentViewSize, string> = {
20
- sm: "gap-2",
21
- md: "gap-3",
22
- lg: "gap-4",
23
- }
20
+ sm: "gap-2",
21
+ md: "gap-3",
22
+ lg: "gap-4",
23
+ };
24
24
  const spanText: Record<ContentViewSize, string> = {
25
- sm: "text-footnote tracking-tighter font-light",
26
- md: "text-callout tracking-tighter font-light",
27
- lg: "text-subheadline tracking-tighter font-light",
28
- }
25
+ sm: "text-footnote tracking-tighter font-light",
26
+ md: "text-callout tracking-tighter font-light",
27
+ lg: "text-subheadline tracking-tighter font-light",
28
+ };
29
29
  const subText: Record<ContentViewSize, string> = {
30
- sm: "text-footnote text-label",
31
- md: "text-subheadline text-label",
32
- lg: "text-body text-label",
33
- }
30
+ sm: "text-footnote text-label",
31
+ md: "text-subheadline text-label",
32
+ lg: "text-body text-label",
33
+ };
34
34
  const headerActionGaps: Record<ContentViewSize, string> = {
35
- sm: "gap-2",
36
- md: "gap-3",
37
- lg: "gap-4",
38
- }
35
+ sm: "gap-2",
36
+ md: "gap-3",
37
+ lg: "gap-4",
38
+ };
39
39
 
40
- const ContentViewSizeContext = createContext<ContentViewSize>("md")
41
- const useContentViewSize = () => useContext(ContentViewSizeContext)
40
+ const ContentViewSizeContext = createContext<ContentViewSize>("md");
41
+ const useContentViewSize = () => useContext(ContentViewSizeContext);
42
42
 
43
43
  type ContentViewProps = ComponentPropsWithoutRef<"section"> & {
44
- variant?: ContentViewVariant
45
- /** Container radius, section gap and text scale. @default "md" */
46
- size?: ContentViewSize
47
- }
44
+ variant?: ContentViewVariant;
45
+ /** Container radius, section gap and text scale. @default "md" */
46
+ size?: ContentViewSize;
47
+ };
48
48
 
49
- type RowProps = ComponentPropsWithoutRef<"div">
49
+ type RowProps = ComponentPropsWithoutRef<"div">;
50
50
 
51
- type SectionProps = ComponentPropsWithoutRef<"section">
51
+ type SectionProps = ComponentPropsWithoutRef<"section">;
52
52
 
53
53
  type HeaderProps = PropsWithChildren<{
54
- heading: string
55
- p?: string
56
- pClassName?: string
57
- icon?: ReactNode
58
- action?: ReactNode
59
- actionClassName?: string
60
- as?: ContentViewHeadingLevel
61
- className?: string
62
- }>
63
-
64
- type H1Props = ComponentPropsWithoutRef<"h1">
65
- type H2Props = ComponentPropsWithoutRef<"h2">
66
- type PProps = ComponentPropsWithoutRef<"p">
67
- type SpanProps = ComponentPropsWithoutRef<"span">
68
- type SubProps = ComponentPropsWithoutRef<"sub">
54
+ heading: string;
55
+ p?: string;
56
+ pClassName?: string;
57
+ icon?: ReactNode;
58
+ action?: ReactNode;
59
+ actionClassName?: string;
60
+ as?: ContentViewHeadingLevel;
61
+ className?: string;
62
+ }>;
63
+
64
+ type H1Props = ComponentPropsWithoutRef<"h1">;
65
+ type H2Props = ComponentPropsWithoutRef<"h2">;
66
+ type PProps = ComponentPropsWithoutRef<"p">;
67
+ type SpanProps = ComponentPropsWithoutRef<"span">;
68
+ type SubProps = ComponentPropsWithoutRef<"sub">;
69
69
 
70
70
  const variants = {
71
- elevated: cn(
72
- "rounded-2xl bg-elevated border border-separator/35",
73
- "shadow hover:shadow-md cursor-pointer group"
74
- ),
75
- } as const
71
+ elevated: cn(
72
+ "bg-elevated border-separator/35 rounded-2xl border",
73
+ "group cursor-pointer shadow hover:shadow-md",
74
+ ),
75
+ } as const;
76
76
 
77
77
  export function ContentView({
78
- variant = "elevated",
79
- size = "md",
80
- className,
81
- children,
82
- ...props
78
+ variant = "elevated",
79
+ size = "md",
80
+ className,
81
+ children,
82
+ ...props
83
83
  }: ContentViewProps) {
84
- return (
85
- <ContentViewSizeContext value={size}>
86
- <section
87
- className={cn(
88
- variants[variant],
89
- variant === "elevated" && containerRadius[size],
90
- className
91
- )}
92
- {...props}
93
- >
94
- {children}
95
- </section>
96
- </ContentViewSizeContext>
97
- )
84
+ return (
85
+ <ContentViewSizeContext value={size}>
86
+ <section
87
+ className={cn(
88
+ variants[variant],
89
+ variant === "elevated" && containerRadius[size],
90
+ className,
91
+ )}
92
+ {...props}
93
+ >
94
+ {children}
95
+ </section>
96
+ </ContentViewSizeContext>
97
+ );
98
98
  }
99
99
 
100
100
  function Row({ className, children, ...props }: RowProps) {
101
- return (
102
- <div className={cn("flex items-center", className)} {...props}>
103
- {children}
104
- </div>
105
- )
101
+ return (
102
+ <div className={cn("flex items-center", className)} {...props}>
103
+ {children}
104
+ </div>
105
+ );
106
106
  }
107
107
 
108
108
  function Section({ className, children, ...props }: SectionProps) {
109
- const size = useContentViewSize()
110
- return (
111
- <section className={cn("flex flex-col", sectionGaps[size], className)} {...props}>
112
- {children}
113
- </section>
114
- )
109
+ const size = useContentViewSize();
110
+ return (
111
+ <section
112
+ className={cn("flex flex-col", sectionGaps[size], className)}
113
+ {...props}
114
+ >
115
+ {children}
116
+ </section>
117
+ );
115
118
  }
116
119
 
117
120
  function Header({
118
- heading,
119
- p,
120
- pClassName,
121
- icon,
122
- action,
123
- actionClassName,
124
- as: Tag = "h3",
125
- className,
126
- children,
121
+ heading,
122
+ p,
123
+ pClassName,
124
+ icon,
125
+ action,
126
+ actionClassName,
127
+ as: Tag = "h3",
128
+ className,
129
+ children,
127
130
  }: HeaderProps) {
128
- const title = (
129
- <Tag className={cn(icon && "flex items-center gap-2")}>
130
- {icon}
131
- {heading}
132
- </Tag>
133
- )
134
-
135
- const size = useContentViewSize()
136
- return (
137
- <div className={className}>
138
- {action ? (
139
- <div className={cn("flex items-center", headerActionGaps[size], actionClassName)}>
140
- {title}
141
- {action}
142
- </div>
143
- ) : (
144
- title
145
- )}
146
- {p && <p className={pClassName}>{p}</p>}
147
- {children}
148
- </div>
149
- )
131
+ const title = (
132
+ <Tag className={cn(icon && "flex items-center gap-2")}>
133
+ {icon}
134
+ {heading}
135
+ </Tag>
136
+ );
137
+
138
+ const size = useContentViewSize();
139
+ return (
140
+ <div className={className}>
141
+ {action ? (
142
+ <div
143
+ className={cn(
144
+ "flex items-center",
145
+ headerActionGaps[size],
146
+ actionClassName,
147
+ )}
148
+ >
149
+ {title}
150
+ {action}
151
+ </div>
152
+ ) : (
153
+ title
154
+ )}
155
+ {p && <p className={pClassName}>{p}</p>}
156
+ {children}
157
+ </div>
158
+ );
150
159
  }
151
160
 
152
161
  function Divider() {
153
- return <span className="h-16 w-px bg-separator" />
162
+ return <span className="bg-separator h-16 w-px" />;
154
163
  }
155
164
 
156
165
  function H1({ className, children, ...props }: H1Props) {
157
- return (
158
- <h1 className={className} {...props}>
159
- {children}
160
- </h1>
161
- )
166
+ return (
167
+ <h1 className={className} {...props}>
168
+ {children}
169
+ </h1>
170
+ );
162
171
  }
163
172
 
164
173
  function H2({ className, children, ...props }: H2Props) {
165
- return (
166
- <h2 className={className} {...props}>
167
- {children}
168
- </h2>
169
- )
174
+ return (
175
+ <h2 className={className} {...props}>
176
+ {children}
177
+ </h2>
178
+ );
170
179
  }
171
180
 
172
181
  function P({ className, children, ...props }: PProps) {
173
- return (
174
- <p className={cn("leading-tight font-medium", className)} {...props}>
175
- {children}
176
- </p>
177
- )
182
+ return (
183
+ <p className={cn("leading-tight font-medium", className)} {...props}>
184
+ {children}
185
+ </p>
186
+ );
178
187
  }
179
188
 
180
189
  function Span({ className, children, ...props }: SpanProps) {
181
- const size = useContentViewSize()
182
- return (
183
- <span className={cn(spanText[size], className)} {...props}>
184
- {children}
185
- </span>
186
- )
190
+ const size = useContentViewSize();
191
+ return (
192
+ <span className={cn(spanText[size], className)} {...props}>
193
+ {children}
194
+ </span>
195
+ );
187
196
  }
188
197
 
189
198
  function Sub({ className, children, ...props }: SubProps) {
190
- const size = useContentViewSize()
191
- return (
192
- <sub className={cn(subText[size], className)} {...props}>
193
- {children}
194
- </sub>
195
- )
196
- }
197
-
198
- ContentView.Row = Row
199
- ContentView.Section = Section
200
- ContentView.Header = Header
201
- ContentView.Divider = Divider
202
- ContentView.H1 = H1
203
- ContentView.H2 = H2
204
- ContentView.P = P
205
- ContentView.Span = Span
206
- ContentView.Sub = Sub
199
+ const size = useContentViewSize();
200
+ return (
201
+ <sub className={cn(subText[size], className)} {...props}>
202
+ {children}
203
+ </sub>
204
+ );
205
+ }
206
+
207
+ ContentView.Row = Row;
208
+ ContentView.Section = Section;
209
+ ContentView.Header = Header;
210
+ ContentView.Divider = Divider;
211
+ ContentView.H1 = H1;
212
+ ContentView.H2 = H2;
213
+ ContentView.P = P;
214
+ ContentView.Span = Span;
215
+ ContentView.Sub = Sub;
@@ -1 +1 @@
1
- export * from "./content-view"
1
+ export * from "./content-view";
@@ -1,30 +1,30 @@
1
1
  type ConcealedSource = {
2
- count: number
3
- opacity: string
4
- inert: boolean
5
- }
6
- const sources = new WeakMap<HTMLElement, ConcealedSource>()
2
+ count: number;
3
+ opacity: string;
4
+ inert: boolean;
5
+ };
6
+ const sources = new WeakMap<HTMLElement, ConcealedSource>();
7
7
 
8
8
  /** Follow-up menus share ownership until the last surface finishes closing. */
9
9
  export function concealMenuSource(element: HTMLElement, inert: boolean) {
10
- const state = sources.get(element) ?? {
11
- count: 0,
12
- opacity: element.style.opacity,
13
- inert: element.inert,
14
- }
15
- state.count += 1
16
- sources.set(element, state)
17
- element.style.opacity = "0"
18
- if (inert) element.inert = true
19
- let active = true
20
- return () => {
21
- if (!active) return false
22
- active = false
23
- state.count -= 1
24
- if (state.count) return false
25
- element.style.opacity = state.opacity
26
- element.inert = state.inert
27
- sources.delete(element)
28
- return true
29
- }
10
+ const state = sources.get(element) ?? {
11
+ count: 0,
12
+ opacity: element.style.opacity,
13
+ inert: element.inert,
14
+ };
15
+ state.count += 1;
16
+ sources.set(element, state);
17
+ element.style.opacity = "0";
18
+ if (inert) element.inert = true;
19
+ let active = true;
20
+ return () => {
21
+ if (!active) return false;
22
+ active = false;
23
+ state.count -= 1;
24
+ if (state.count) return false;
25
+ element.style.opacity = state.opacity;
26
+ element.inert = state.inert;
27
+ sources.delete(element);
28
+ return true;
29
+ };
30
30
  }