@passui/react 0.1.44 → 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.
- package/README.md +57 -46
- package/dist/types/src/components/accordion/accordion.d.ts +1 -1
- package/dist/types/src/components/breadcrumb/breadcrumb.d.ts +1 -1
- package/dist/types/src/components/inline-disclosure/inline-disclosure.d.ts +1 -1
- package/dist/types/src/components/popover/anchored-surface.d.ts +5 -1
- package/dist/types/src/components/popover/index.d.ts +41 -0
- package/dist/types/src/components/popover/popover-content.d.ts +32 -0
- package/dist/types/src/components/popover/popover-root.d.ts +22 -0
- package/dist/types/src/components/popover/popover-trigger.d.ts +23 -0
- package/dist/types/src/components/stepper/rolling-digit.d.ts +1 -1
- package/dist/types/src/components/table/table.d.ts +1 -1
- package/dist/types/src/components/view-controller/view-controller.d.ts +2 -2
- package/dist/types/src/index.d.ts +1 -1
- package/dist/types/src/machines/popover.machine.d.ts +30 -0
- package/package.json +307 -307
- package/src/appearance/index.ts +2 -2
- package/src/appearance/platform.tsx +76 -60
- package/src/appearance/theme.tsx +409 -377
- package/src/components/accordion/accordion.tsx +58 -49
- package/src/components/ambient/ambient.tsx +25 -25
- package/src/components/ambient/index.ts +1 -1
- package/src/components/aspect-ratio/aspect-ratio.tsx +21 -16
- package/src/components/breadcrumb/breadcrumb.tsx +63 -57
- package/src/components/button/button-styles.ts +39 -32
- package/src/components/button/button.tsx +91 -84
- package/src/components/button/icon-button.tsx +27 -25
- package/src/components/button/pending-spinner.tsx +8 -8
- package/src/components/button/use-pending-indicator.ts +11 -11
- package/src/components/chip/chip.tsx +35 -30
- package/src/components/code-block/code-block.tsx +40 -39
- package/src/components/combo-box/combo-box.tsx +5 -5
- package/src/components/command/command.tsx +124 -94
- package/src/components/compact-date-picker/calendar-month.ts +75 -53
- package/src/components/compact-date-picker/compact-date-picker.tsx +308 -289
- package/src/components/compact-time-picker/compact-time-picker.tsx +288 -281
- package/src/components/compact-time-picker/time-value.ts +32 -29
- package/src/components/content-unavailable-view/content-unavailable-view.tsx +64 -48
- package/src/components/content-view/content-view.tsx +168 -159
- package/src/components/content-view/index.ts +1 -1
- package/src/components/context-menu/conceal-menu-source.ts +25 -25
- package/src/components/context-menu/context-menu-host.tsx +439 -398
- package/src/components/context-menu/context-menu-store.ts +125 -123
- package/src/components/context-menu/menu-navigation.ts +25 -18
- package/src/components/context-menu/menu-position.ts +33 -29
- package/src/components/context-menu/menu-reveal.ts +32 -32
- package/src/components/context-menu/use-context-menu.ts +63 -56
- package/src/components/conversation/conversation.tsx +265 -263
- package/src/components/conversation/index.ts +1 -1
- package/src/components/date-picker/date-picker.tsx +95 -94
- package/src/components/date-picker/date-value.ts +20 -10
- package/src/components/dialog/dialog-host.tsx +105 -103
- package/src/components/dialog/dialog-store.ts +37 -36
- package/src/components/dialog/dialog.tsx +192 -179
- package/src/components/dialog/index.ts +1 -1
- package/src/components/disclosure-group/disclosure-group.tsx +93 -86
- package/src/components/divider/divider.tsx +24 -22
- package/src/components/inline-disclosure/inline-disclosure.tsx +40 -36
- package/src/components/keyboard-shortcut/keyboard-shortcut.tsx +23 -19
- package/src/components/labeled-content/labeled-content.tsx +68 -68
- package/src/components/locale-switcher/index.ts +1 -1
- package/src/components/locale-switcher/locale-switcher.tsx +279 -251
- package/src/components/menu/menu.tsx +75 -58
- package/src/components/morph/index.ts +2 -2
- package/src/components/morph/morph.tsx +227 -201
- package/src/components/morph/use-morph-disclosure.ts +19 -19
- package/src/components/one-time-code/one-time-code.tsx +216 -200
- package/src/components/picker/picker-trigger.ts +16 -13
- package/src/components/picker/picker.tsx +371 -345
- package/src/components/popover/anchored-surface.tsx +253 -229
- package/src/components/popover/index.ts +50 -0
- package/src/components/popover/popover-content.tsx +334 -0
- package/src/components/popover/popover-fit.ts +58 -53
- package/src/components/popover/popover-root.tsx +97 -0
- package/src/components/popover/popover-trigger.tsx +71 -0
- package/src/components/profile-image/profile-image.tsx +80 -64
- package/src/components/progress-view/progress-view.tsx +61 -59
- package/src/components/progress-view/use-liquid-progress.ts +38 -38
- package/src/components/radio-group/radio-group.tsx +71 -68
- package/src/components/search-field/expanding-search-field.tsx +191 -177
- package/src/components/search-field/search-field.tsx +59 -50
- package/src/components/search-list/search-list.tsx +246 -236
- package/src/components/section/section.tsx +58 -58
- package/src/components/secure-field/secure-field.tsx +3 -3
- package/src/components/segmented-control/segmented-control.tsx +136 -136
- package/src/components/sheet/modal-environment.ts +71 -64
- package/src/components/sheet/sheet-portal.tsx +58 -53
- package/src/components/sheet/sheet.tsx +146 -141
- package/src/components/sheet/use-sheet-focus.ts +97 -82
- package/src/components/sidebar/sidebar.tsx +78 -78
- package/src/components/skeleton/skeleton.tsx +30 -21
- package/src/components/slider/slider.tsx +113 -104
- package/src/components/slosh-slider/liquid-step.ts +32 -31
- package/src/components/slosh-slider/slosh-slider.tsx +265 -228
- package/src/components/stat-tile/index.ts +1 -1
- package/src/components/stat-tile/stat-tile.tsx +79 -68
- package/src/components/status-indicator/status-indicator.tsx +40 -37
- package/src/components/stepper/rolling-digit.tsx +82 -68
- package/src/components/stepper/stepper.tsx +122 -113
- package/src/components/swatch-picker/swatch-picker.tsx +120 -120
- package/src/components/tab-bar/tab-bar.tsx +149 -148
- package/src/components/tab-view/tab-view.tsx +140 -137
- package/src/components/table/table.tsx +117 -98
- package/src/components/text-editor/text-editor.tsx +34 -29
- package/src/components/text-field/text-field.tsx +182 -180
- package/src/components/toast/toast-store.ts +127 -115
- package/src/components/toast/toaster.tsx +361 -347
- package/src/components/toggle/toggle.tsx +297 -282
- package/src/components/tooltip/tooltip-host.tsx +157 -150
- package/src/components/view-controller/index.ts +1 -1
- package/src/components/view-controller/view-controller.tsx +64 -53
- package/src/components/wake-slider/wake-slider.tsx +220 -205
- package/src/hooks/scroll/minimize-decision.ts +11 -7
- package/src/hooks/use-anchored-disclosure.ts +19 -19
- package/src/hooks/use-anchored-placement.ts +29 -25
- package/src/hooks/use-dismiss.ts +33 -29
- package/src/hooks/use-floating-dismiss.ts +24 -22
- package/src/hooks/use-media-query.ts +67 -60
- package/src/hooks/use-minimize-on-scroll.ts +69 -60
- package/src/hooks/use-visual-viewport.ts +63 -63
- package/src/hooks/viewport/types.ts +16 -16
- package/src/hooks/viewport/viewport-metrics.ts +16 -10
- package/src/icons/icons.tsx +440 -328
- package/src/index.ts +91 -91
- package/src/lib/anchored-placement.ts +70 -65
- package/src/lib/class-names.ts +14 -13
- package/src/lib/clipboard.ts +8 -7
- package/src/lib/date.ts +61 -60
- package/src/lib/floating-layers.ts +39 -24
- package/src/lib/haptics.ts +10 -10
- package/src/lib/language.ts +9 -9
- package/src/lib/range-value.ts +27 -21
- package/src/lib/screen-edges.ts +33 -30
- package/src/lib/shapes.ts +38 -34
- package/src/machines/popover.machine.ts +51 -0
- package/src/motion/transitions.ts +46 -43
- package/src/styles/code-block.css +69 -43
- package/src/styles/motion-controls.css +393 -191
- package/src/tokens.ts +1 -1
- package/dist/types/src/components/popover/popover.d.ts +0 -21
- package/src/components/popover/popover.tsx +0 -322
|
@@ -1,55 +1,58 @@
|
|
|
1
1
|
/** A time of day on a 24 hour clock. */
|
|
2
2
|
export interface TimeOfDay {
|
|
3
|
-
|
|
4
|
-
|
|
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
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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
|
-
|
|
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
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
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
|
-
|
|
35
|
-
|
|
34
|
+
hour: number;
|
|
35
|
+
pm: boolean;
|
|
36
36
|
} {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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
|
-
|
|
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
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
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
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}
|
|
7
|
+
sm: "text-subheadline",
|
|
8
|
+
md: "text-headline",
|
|
9
|
+
lg: "text-title3",
|
|
10
|
+
};
|
|
11
11
|
|
|
12
12
|
const descriptionSizes: Record<ContentUnavailableViewSize, string> = {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
13
|
+
sm: "text-caption",
|
|
14
|
+
md: "text-footnote",
|
|
15
|
+
lg: "text-subheadline",
|
|
16
|
+
};
|
|
17
17
|
|
|
18
18
|
const spacings: Record<ContentUnavailableViewSize, string> = {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
36
|
+
title,
|
|
37
|
+
description,
|
|
38
|
+
icon,
|
|
39
|
+
actions,
|
|
40
|
+
size = "md",
|
|
41
|
+
className,
|
|
42
|
+
...props
|
|
42
43
|
}: ContentUnavailableViewProps) {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
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
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
15
|
+
sm: "rounded-xl",
|
|
16
|
+
md: "rounded-2xl",
|
|
17
|
+
lg: "rounded-3xl",
|
|
18
|
+
};
|
|
19
19
|
const sectionGaps: Record<ContentViewSize, string> = {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
20
|
+
sm: "gap-2",
|
|
21
|
+
md: "gap-3",
|
|
22
|
+
lg: "gap-4",
|
|
23
|
+
};
|
|
24
24
|
const spanText: Record<ContentViewSize, string> = {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
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
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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
|
-
|
|
36
|
-
|
|
37
|
-
|
|
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
|
-
|
|
45
|
-
|
|
46
|
-
|
|
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
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
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
|
-
|
|
72
|
-
|
|
73
|
-
|
|
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
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
78
|
+
variant = "elevated",
|
|
79
|
+
size = "md",
|
|
80
|
+
className,
|
|
81
|
+
children,
|
|
82
|
+
...props
|
|
83
83
|
}: ContentViewProps) {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
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
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
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
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
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
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
121
|
+
heading,
|
|
122
|
+
p,
|
|
123
|
+
pClassName,
|
|
124
|
+
icon,
|
|
125
|
+
action,
|
|
126
|
+
actionClassName,
|
|
127
|
+
as: Tag = "h3",
|
|
128
|
+
className,
|
|
129
|
+
children,
|
|
127
130
|
}: HeaderProps) {
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
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
|
-
|
|
162
|
+
return <span className="bg-separator h-16 w-px" />;
|
|
154
163
|
}
|
|
155
164
|
|
|
156
165
|
function H1({ className, children, ...props }: H1Props) {
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
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
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
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
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
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
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
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
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
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
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
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
|
}
|