@lanfermann/ui 0.5.0 → 0.7.0
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/dist/components/accordion/accordion.d.ts +11 -3
- package/dist/components/accordion/accordion.js +15 -10
- package/dist/components/action-bar/action-bar.d.ts +60 -0
- package/dist/components/action-bar/action-bar.js +117 -0
- package/dist/components/alert/alert.d.ts +1 -1
- package/dist/components/alert/alert.js +3 -17
- package/dist/components/alert-dialog/alert-dialog.d.ts +1 -1
- package/dist/components/app-shell/app-shell.d.ts +33 -0
- package/dist/components/app-shell/app-shell.js +93 -0
- package/dist/components/attachment/attachment.d.ts +51 -0
- package/dist/components/attachment/attachment.js +255 -0
- package/dist/components/attachment/kinds.d.ts +7 -0
- package/dist/components/attachment/kinds.js +142 -0
- package/dist/components/avatar/avatar.d.ts +14 -4
- package/dist/components/avatar/avatar.js +57 -13
- package/dist/components/avatar-group/avatar-group.d.ts +33 -0
- package/dist/components/avatar-group/avatar-group.js +110 -0
- package/dist/components/avatar-group/people.d.ts +12 -0
- package/dist/components/avatar-group/people.js +24 -0
- package/dist/components/badge/badge.d.ts +9 -3
- package/dist/components/badge/badge.js +21 -6
- package/dist/components/banner/banner.d.ts +39 -0
- package/dist/components/banner/banner.js +149 -0
- package/dist/components/button-group/button-group-variants.d.ts +4 -3
- package/dist/components/button-group/button-group-variants.js +13 -12
- package/dist/components/button-group/button-group.d.ts +3 -3
- package/dist/components/button-group/button-group.js +3 -3
- package/dist/components/card/card.d.ts +20 -4
- package/dist/components/card/card.js +32 -6
- package/dist/components/checkbox-card/checkbox-card.d.ts +21 -0
- package/dist/components/checkbox-card/checkbox-card.js +50 -0
- package/dist/components/chip/chip-group.d.ts +15 -0
- package/dist/components/chip/chip-group.js +44 -0
- package/dist/components/chip/chip-variants.d.ts +6 -0
- package/dist/components/chip/chip-variants.js +28 -0
- package/dist/components/chip/chip.d.ts +39 -0
- package/dist/components/chip/chip.js +71 -0
- package/dist/components/code-block/code-copy.d.ts +3 -11
- package/dist/components/code-block/code-copy.js +15 -62
- package/dist/components/code-block/code-keys.js +10 -22
- package/dist/components/collapsible/collapsible.js +7 -3
- package/dist/components/combobox/combobox.d.ts +53 -3
- package/dist/components/combobox/combobox.js +204 -20
- package/dist/components/command/command.d.ts +131 -0
- package/dist/components/command/command.js +335 -0
- package/dist/components/consent/consent-card.js +365 -0
- package/dist/components/consent/consent-embed.d.ts +21 -0
- package/dist/components/consent/consent-embed.js +111 -0
- package/dist/components/consent/consent-labels.d.ts +70 -0
- package/dist/components/consent/consent-labels.js +61 -0
- package/dist/components/consent/consent-record.d.ts +95 -0
- package/dist/components/consent/consent-record.js +112 -0
- package/dist/components/consent/consent-store.d.ts +26 -0
- package/dist/components/consent/consent-store.js +240 -0
- package/dist/components/consent/consent.d.ts +86 -0
- package/dist/components/consent/consent.js +306 -0
- package/dist/components/container/container.d.ts +1 -1
- package/dist/components/context-menu/context-menu.d.ts +23 -0
- package/dist/components/context-menu/context-menu.js +50 -0
- package/dist/components/conversation/conversation.d.ts +45 -0
- package/dist/components/conversation/conversation.js +295 -0
- package/dist/components/conversation/stick.js +23 -0
- package/dist/components/copy-button/copy-button.d.ts +50 -0
- package/dist/components/copy-button/copy-button.js +65 -0
- package/dist/components/copy-page/copy-page.d.ts +4 -4
- package/dist/components/copy-page/copy-page.js +16 -36
- package/dist/components/copy-pill/copy-pill.js +1 -1
- package/dist/components/description-list/description-list.d.ts +32 -0
- package/dist/components/description-list/description-list.js +51 -0
- package/dist/components/empty/empty.d.ts +38 -0
- package/dist/components/empty/empty.js +57 -0
- package/dist/components/field/field.js +1 -1
- package/dist/components/file-upload/file-upload.d.ts +96 -0
- package/dist/components/file-upload/file-upload.js +347 -0
- package/dist/components/file-upload/files.d.ts +39 -0
- package/dist/components/file-upload/files.js +74 -0
- package/dist/components/grow/grow.d.ts +15 -3
- package/dist/components/grow/grow.js +24 -9
- package/dist/components/heading/heading.d.ts +1 -1
- package/dist/components/icon/icon.d.ts +1 -1
- package/dist/components/input/input.js +1 -1
- package/dist/components/menu/menu.d.ts +20 -8
- package/dist/components/menu/menu.js +51 -29
- package/dist/components/message/message.d.ts +81 -0
- package/dist/components/message/message.js +208 -0
- package/dist/components/navigation-menu/navigation-menu.d.ts +7 -1
- package/dist/components/navigation-menu/navigation-menu.js +11 -4
- package/dist/components/otp-field/otp-field.d.ts +37 -0
- package/dist/components/otp-field/otp-field.js +161 -0
- package/dist/components/pagination/pagination.d.ts +50 -0
- package/dist/components/pagination/pagination.js +188 -0
- package/dist/components/prompt-input/keys.js +15 -0
- package/dist/components/prompt-input/prompt-input.d.ts +89 -0
- package/dist/components/prompt-input/prompt-input.js +331 -0
- package/dist/components/radio-card/radio-card.d.ts +23 -0
- package/dist/components/radio-card/radio-card.js +49 -0
- package/dist/components/rolling-number/rolling-number.d.ts +30 -0
- package/dist/components/rolling-number/rolling-number.js +149 -0
- package/dist/components/seam/seam.d.ts +1 -1
- package/dist/components/secret-field/secret-field.d.ts +53 -0
- package/dist/components/secret-field/secret-field.js +121 -0
- package/dist/components/section/section.d.ts +1 -1
- package/dist/components/segmented-control/segmented-control.js +29 -16
- package/dist/components/select/select.d.ts +5 -4
- package/dist/components/select/select.js +16 -11
- package/dist/components/shortcut/shortcut.d.ts +46 -0
- package/dist/components/shortcut/shortcut.js +87 -0
- package/dist/components/sidebar/sidebar-context.js +16 -0
- package/dist/components/sidebar/sidebar.d.ts +161 -0
- package/dist/components/sidebar/sidebar.js +588 -0
- package/dist/components/site-header/site-header.js +1 -1
- package/dist/components/skeleton/loaded.d.ts +21 -0
- package/dist/components/skeleton/loaded.js +57 -0
- package/dist/components/skeleton/skeleton.d.ts +43 -0
- package/dist/components/skeleton/skeleton.js +48 -0
- package/dist/components/sources/source-list.d.ts +17 -0
- package/dist/components/sources/source-list.js +26 -0
- package/dist/components/sources/sources.d.ts +45 -0
- package/dist/components/sources/sources.js +167 -0
- package/dist/components/stat/stat.d.ts +59 -0
- package/dist/components/stat/stat.js +112 -0
- package/dist/components/steps/steps.d.ts +57 -0
- package/dist/components/steps/steps.js +134 -0
- package/dist/components/table/table.d.ts +18 -9
- package/dist/components/table/table.js +21 -13
- package/dist/components/text/text.d.ts +1 -1
- package/dist/components/theme-switch/theme-switch.js +1 -1
- package/dist/components/time-field/time-field.js +7 -6
- package/dist/components/timeline/timeline.d.ts +45 -0
- package/dist/components/timeline/timeline.js +86 -0
- package/dist/components/toast/toast.js +10 -26
- package/dist/components/toggle/toggle.d.ts +27 -0
- package/dist/components/toggle/toggle.js +61 -0
- package/dist/components/toggle-group/toggle-group.d.ts +27 -0
- package/dist/components/toggle-group/toggle-group.js +38 -0
- package/dist/components/toolbar/toolbar-context.js +12 -0
- package/dist/components/toolbar/toolbar.d.ts +52 -0
- package/dist/components/toolbar/toolbar.js +105 -0
- package/dist/components/trace/trace.d.ts +2 -1
- package/dist/components/trace/trace.js +15 -27
- package/dist/index.d.ts +46 -3
- package/dist/index.js +44 -3
- package/dist/internal/arriving-pieces.js +56 -0
- package/dist/internal/arriving.js +171 -0
- package/dist/internal/avatar-cut.d.ts +15 -0
- package/dist/internal/avatar-cut.js +83 -0
- package/dist/internal/choice-card.d.ts +15 -0
- package/dist/internal/choice-card.js +81 -0
- package/dist/internal/clipboard.js +37 -0
- package/dist/internal/copy.js +58 -0
- package/dist/internal/disclosure.js +15 -3
- package/dist/internal/field.js +24 -4
- package/dist/internal/glyphs.js +26 -1
- package/dist/internal/key-tip.js +18 -0
- package/dist/internal/list-mark.js +39 -0
- package/dist/internal/live-list.js +41 -0
- package/dist/internal/number-places.js +157 -0
- package/dist/internal/picker-sheet.js +1 -1
- package/dist/internal/presence-dot.js +24 -0
- package/dist/internal/presence.js +104 -0
- package/dist/internal/rail-mark.d.ts +3 -0
- package/dist/internal/rail-mark.js +33 -0
- package/dist/internal/rule.js +2 -1
- package/dist/internal/status-icon.js +22 -0
- package/dist/internal/tile.js +23 -0
- package/dist/internal/travelling-mark.js +204 -0
- package/dist/lib/cn.js +10 -0
- package/dist/lib/shortcut.d.ts +11 -0
- package/dist/lib/shortcut.js +165 -0
- package/package.json +1 -1
- package/src/styles/accordion.css +176 -0
- package/src/styles/action-bar.css +28 -0
- package/src/styles/assistant.css +83 -0
- package/src/styles/avatar.css +24 -0
- package/src/styles/consent.css +65 -0
- package/src/styles/copy.css +12 -11
- package/src/styles/depth.css +120 -4
- package/src/styles/marks.css +20 -2
- package/src/styles/motion.css +3 -0
- package/src/styles/rail.css +49 -0
- package/src/styles/rolling-number.css +94 -0
- package/src/styles/segmented.css +14 -7
- package/src/styles/steps.css +98 -0
- package/src/styles/timeline.css +48 -0
- package/src/styles/travel.css +36 -0
- package/src/styles.css +10 -0
package/dist/index.js
CHANGED
|
@@ -1,37 +1,59 @@
|
|
|
1
1
|
import { Accordion, AccordionItem, AccordionPanel, AccordionTrigger } from "./components/accordion/accordion.js";
|
|
2
|
+
import { ActionBar, ActionBarButton } from "./components/action-bar/action-bar.js";
|
|
2
3
|
import { Alert, AlertDescription, AlertTitle } from "./components/alert/alert.js";
|
|
3
4
|
import { AlertDialog, AlertDialogClose, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, AlertDialogTrigger } from "./components/alert-dialog/alert-dialog.js";
|
|
4
5
|
import { AnchorHeading } from "./components/anchor-heading/anchor-heading.js";
|
|
6
|
+
import { AppShell, AppShellBar, AppShellMain, AppShellPage } from "./components/app-shell/app-shell.js";
|
|
7
|
+
import { Attachment, MessageAttachments } from "./components/attachment/attachment.js";
|
|
8
|
+
import { kindOf } from "./components/attachment/kinds.js";
|
|
5
9
|
import { Avatar, AvatarFallback, AvatarImage } from "./components/avatar/avatar.js";
|
|
10
|
+
import { AvatarGroup } from "./components/avatar-group/avatar-group.js";
|
|
6
11
|
import { Badge } from "./components/badge/badge.js";
|
|
12
|
+
import { Banner } from "./components/banner/banner.js";
|
|
7
13
|
import { BreadcrumbItem, BreadcrumbLink, BreadcrumbPage, Breadcrumbs } from "./components/breadcrumbs/breadcrumbs.js";
|
|
8
14
|
import { Button } from "./components/button/button.js";
|
|
9
15
|
import { buttonVariants } from "./components/button/button-variants.js";
|
|
10
16
|
import { ButtonGroup } from "./components/button-group/button-group.js";
|
|
11
17
|
import { Calendar } from "./components/calendar/calendar.js";
|
|
12
18
|
import { Callout } from "./components/callout/callout.js";
|
|
13
|
-
import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from "./components/card/card.js";
|
|
19
|
+
import { Card, CardBar, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from "./components/card/card.js";
|
|
14
20
|
import { Checkbox } from "./components/checkbox/checkbox.js";
|
|
21
|
+
import { CheckboxCard } from "./components/checkbox-card/checkbox-card.js";
|
|
15
22
|
import { CheckboxGroup, CheckboxGroupItems } from "./components/checkbox-group/checkbox-group.js";
|
|
23
|
+
import { Chip } from "./components/chip/chip.js";
|
|
24
|
+
import { ChipGroup } from "./components/chip/chip-group.js";
|
|
16
25
|
import { Code } from "./components/code/code.js";
|
|
17
26
|
import { CodeBlock } from "./components/code-block/code-block.js";
|
|
18
27
|
import { CodeBlockLive } from "./components/code-block/code-block-live.js";
|
|
19
28
|
import { CodeTabs } from "./components/code-block/code-tabs.js";
|
|
20
29
|
import { Collapsible, CollapsiblePanel, CollapsibleTrigger } from "./components/collapsible/collapsible.js";
|
|
21
|
-
import { Combobox, ComboboxCollection, ComboboxContent, ComboboxGroup, ComboboxGroupLabel, ComboboxInput, ComboboxItem, ComboboxSeparator } from "./components/combobox/combobox.js";
|
|
30
|
+
import { Combobox, ComboboxChips, ComboboxCollection, ComboboxContent, ComboboxGroup, ComboboxGroupLabel, ComboboxInput, ComboboxItem, ComboboxSeparator } from "./components/combobox/combobox.js";
|
|
31
|
+
import { Command, CommandContent, CommandFooter, CommandInput, CommandList, CommandTrigger } from "./components/command/command.js";
|
|
32
|
+
import { ConsentGate, ConsentProvider, ConsentSettingsTrigger, useConsent } from "./components/consent/consent.js";
|
|
33
|
+
import { ConsentEmbed } from "./components/consent/consent-embed.js";
|
|
34
|
+
import { consentLabels } from "./components/consent/consent-labels.js";
|
|
35
|
+
import { consentAllows, parseConsent } from "./components/consent/consent-record.js";
|
|
36
|
+
import { createMemoryJar } from "./components/consent/consent-store.js";
|
|
22
37
|
import { Container, containerVariants } from "./components/container/container.js";
|
|
38
|
+
import { ContextMenu, ContextMenuContent, ContextMenuTrigger } from "./components/context-menu/context-menu.js";
|
|
39
|
+
import { Conversation, ConversationContent, ConversationLatest, useConversation } from "./components/conversation/conversation.js";
|
|
40
|
+
import { CopyButton } from "./components/copy-button/copy-button.js";
|
|
23
41
|
import { CopyPage } from "./components/copy-page/copy-page.js";
|
|
24
42
|
import { CopyPill, CopyPillMark } from "./components/copy-pill/copy-pill.js";
|
|
25
43
|
import { Cta, CtaAction, CtaActions, CtaMessage, CtaText, CtaTitle } from "./components/cta/cta.js";
|
|
26
44
|
import { DateField } from "./components/date-field/date-field.js";
|
|
27
45
|
import { DateRangeField } from "./components/date-range-field/date-range-field.js";
|
|
46
|
+
import { DescriptionDetails, DescriptionList, DescriptionTerm } from "./components/description-list/description-list.js";
|
|
28
47
|
import { Dialog, DialogBody, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger } from "./components/dialog/dialog.js";
|
|
29
48
|
import { DocsLayout, DocsLayoutAside, DocsLayoutMain, DocsLayoutNav } from "./components/docs-layout/docs-layout.js";
|
|
30
49
|
import { docsPageState, docsPages, findDocsPage, sameDocsPage } from "./components/docs-layout/docs-nav.js";
|
|
31
50
|
import { Drawer, DrawerBody, DrawerClose, DrawerContent, DrawerDescription, DrawerFooter, DrawerHeader, DrawerTitle, DrawerTrigger } from "./components/drawer/drawer.js";
|
|
51
|
+
import { Empty, EmptyActions, EmptyMedia, EmptyText, EmptyTitle } from "./components/empty/empty.js";
|
|
32
52
|
import { Field, FieldDescription, FieldError, FieldLabel } from "./components/field/field.js";
|
|
33
53
|
import { Fieldset, FieldsetLegend } from "./components/fieldset/fieldset.js";
|
|
34
54
|
import { Figure, FigureCaption, FigureFrame } from "./components/figure/figure.js";
|
|
55
|
+
import { FileUpload, FileUploadItem, FileUploadList, FileUploadZone } from "./components/file-upload/file-upload.js";
|
|
56
|
+
import { acceptsFile, formatFileProgress, formatFileSize, sortFiles } from "./components/file-upload/files.js";
|
|
35
57
|
import { Form } from "./components/form/form.js";
|
|
36
58
|
import { Ground, useGround } from "./components/ground/ground.js";
|
|
37
59
|
import { Grow } from "./components/grow/grow.js";
|
|
@@ -46,31 +68,46 @@ import { linkVariants } from "./components/link/link-variants.js";
|
|
|
46
68
|
import { Logomark } from "./components/logo/logomark.js";
|
|
47
69
|
import { Wordmark } from "./components/logo/wordmark.js";
|
|
48
70
|
import { Menu, MenuCheckboxItem, MenuContent, MenuGroup, MenuGroupLabel, MenuItem, MenuLinkItem, MenuRadioGroup, MenuRadioItem, MenuSeparator, MenuSub, MenuSubContent, MenuSubTrigger, MenuTrigger } from "./components/menu/menu.js";
|
|
71
|
+
import { Message, MessageAction, MessageActions, MessageContent, MessageError, MessageFeedback } from "./components/message/message.js";
|
|
49
72
|
import { Meter, MeterLabel, MeterTrack, MeterValue } from "./components/meter/meter.js";
|
|
50
73
|
import { NavigationMenu, NavigationMenuContent, NavigationMenuItem, NavigationMenuLink, NavigationMenuLinkDescription, NavigationMenuLinkTitle, NavigationMenuList, NavigationMenuTrigger } from "./components/navigation-menu/navigation-menu.js";
|
|
51
74
|
import { navigationMenuEntryVariants } from "./components/navigation-menu/navigation-menu-variants.js";
|
|
52
75
|
import { NumberField, NumberFieldDecrement, NumberFieldIncrement, NumberFieldInput } from "./components/number-field/number-field.js";
|
|
76
|
+
import { OtpField } from "./components/otp-field/otp-field.js";
|
|
53
77
|
import { Pager, PagerLink } from "./components/pager/pager.js";
|
|
78
|
+
import { Pagination } from "./components/pagination/pagination.js";
|
|
54
79
|
import { Parameter, ParameterList } from "./components/parameter-list/parameter-list.js";
|
|
55
80
|
import { Popover, PopoverClose, PopoverContent, PopoverDescription, PopoverTitle, PopoverTrigger } from "./components/popover/popover.js";
|
|
56
81
|
import { Progress, ProgressLabel, ProgressTrack, ProgressValue } from "./components/progress/progress.js";
|
|
82
|
+
import { PromptInput, PromptInputActions, PromptInputAttach, PromptInputAttachments, PromptInputSubmit, PromptInputTextarea } from "./components/prompt-input/prompt-input.js";
|
|
57
83
|
import { Prose } from "./components/prose/prose.js";
|
|
58
84
|
import { Quote } from "./components/quote/quote.js";
|
|
59
85
|
import { Radio, RadioGroup } from "./components/radio/radio.js";
|
|
86
|
+
import { RadioCard } from "./components/radio-card/radio-card.js";
|
|
60
87
|
import { ReferenceEntry, ReferenceEntryBody, ReferenceEntryHeader, ReferenceEntryMeta, ReferenceEntryName, ReferenceEntryTitle } from "./components/reference-entry/reference-entry.js";
|
|
88
|
+
import { RollingNumber } from "./components/rolling-number/rolling-number.js";
|
|
61
89
|
import { ScrollFade } from "./components/scroll-fade/scroll-fade.js";
|
|
62
90
|
import { useScrollEdges } from "./components/scroll-fade/use-scroll-edges.js";
|
|
63
91
|
import { Seam } from "./components/seam/seam.js";
|
|
92
|
+
import { SecretField } from "./components/secret-field/secret-field.js";
|
|
64
93
|
import { Section } from "./components/section/section.js";
|
|
65
94
|
import { Segment, SegmentedControl } from "./components/segmented-control/segmented-control.js";
|
|
66
95
|
import { Select, SelectContent, SelectGroup, SelectGroupLabel, SelectItem, SelectSeparator, SelectTrigger } from "./components/select/select.js";
|
|
67
96
|
import { Separator } from "./components/separator/separator.js";
|
|
68
97
|
import { Shimmer } from "./components/shimmer/shimmer.js";
|
|
98
|
+
import { Shortcut, ShortcutProvider, usePlatform, useShortcut } from "./components/shortcut/shortcut.js";
|
|
69
99
|
import { SideNav, SideNavGroup, SideNavLink, SideNavSubLink } from "./components/side-nav/side-nav.js";
|
|
100
|
+
import { Sidebar, SidebarButton, SidebarContent, SidebarFooter, SidebarGroup, SidebarHeader, SidebarItem, SidebarMenu, SidebarSubItem, SidebarTrigger } from "./components/sidebar/sidebar.js";
|
|
70
101
|
import { SiteFooter, SiteFooterBrand, SiteFooterGroup, SiteFooterLegal, SiteFooterLink, SiteFooterMain, SiteFooterNav, siteFooterLinkClass } from "./components/site-footer/site-footer.js";
|
|
71
102
|
import { SiteHeader, SiteHeaderActions, SiteHeaderBrand, SiteHeaderMenu, SiteHeaderMenuGroup, SiteHeaderMenuLink } from "./components/site-header/site-header.js";
|
|
103
|
+
import { Loaded } from "./components/skeleton/loaded.js";
|
|
104
|
+
import { Skeleton, SkeletonGroup } from "./components/skeleton/skeleton.js";
|
|
72
105
|
import { Slider, SliderControl, SliderLabel, SliderThumb, SliderValue } from "./components/slider/slider.js";
|
|
106
|
+
import { siteOf } from "./components/sources/source-list.js";
|
|
107
|
+
import { SourceList, SourceReference, Sources } from "./components/sources/sources.js";
|
|
73
108
|
import { Spinner } from "./components/spinner/spinner.js";
|
|
109
|
+
import { Stat, StatChange, StatGroup, StatLabel, StatValue } from "./components/stat/stat.js";
|
|
110
|
+
import { Step, Steps } from "./components/steps/steps.js";
|
|
74
111
|
import { Switch } from "./components/switch/switch.js";
|
|
75
112
|
import { Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow, TableSortButton } from "./components/table/table.js";
|
|
76
113
|
import { TableOfContents } from "./components/table-of-contents/table-of-contents.js";
|
|
@@ -79,9 +116,13 @@ import { Text } from "./components/text/text.js";
|
|
|
79
116
|
import { Textarea } from "./components/textarea/textarea.js";
|
|
80
117
|
import { ThemeSwitch } from "./components/theme-switch/theme-switch.js";
|
|
81
118
|
import { TimeField } from "./components/time-field/time-field.js";
|
|
119
|
+
import { Timeline, TimelineGroup, TimelineItem } from "./components/timeline/timeline.js";
|
|
82
120
|
import { Toaster, toast, toastManager } from "./components/toast/toast.js";
|
|
121
|
+
import { Toggle } from "./components/toggle/toggle.js";
|
|
122
|
+
import { ToggleGroup } from "./components/toggle-group/toggle-group.js";
|
|
123
|
+
import { Toolbar, ToolbarButton, ToolbarGroup, ToolbarInput, ToolbarLink, ToolbarSeparator } from "./components/toolbar/toolbar.js";
|
|
83
124
|
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "./components/tooltip/tooltip.js";
|
|
84
125
|
import { Trace, TraceStep, TraceSummary } from "./components/trace/trace.js";
|
|
85
126
|
import { cn, mergeClassName } from "./lib/cn.js";
|
|
86
127
|
import { springs, transitions } from "./motion/springs.js";
|
|
87
|
-
export { Accordion, AccordionItem, AccordionPanel, AccordionTrigger, Alert, AlertDescription, AlertDialog, AlertDialogClose, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, AlertDialogTrigger, AlertTitle, AnchorHeading, Avatar, AvatarFallback, AvatarImage, Badge, BreadcrumbItem, BreadcrumbLink, BreadcrumbPage, Breadcrumbs, Button, ButtonGroup, Calendar, Callout, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Checkbox, CheckboxGroup, CheckboxGroupItems, Code, CodeBlock, CodeBlockLive, CodeTabs, Collapsible, CollapsiblePanel, CollapsibleTrigger, Combobox, ComboboxCollection, ComboboxContent, ComboboxGroup, ComboboxGroupLabel, ComboboxInput, ComboboxItem, ComboboxSeparator, Container, CopyPage, CopyPill, CopyPillMark, Cta, CtaAction, CtaActions, CtaMessage, CtaText, CtaTitle, DateField, DateRangeField, Dialog, DialogBody, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger, DocsLayout, DocsLayoutAside, DocsLayoutMain, DocsLayoutNav, Drawer, DrawerBody, DrawerClose, DrawerContent, DrawerDescription, DrawerFooter, DrawerHeader, DrawerTitle, DrawerTrigger, Field, FieldDescription, FieldError, FieldLabel, Fieldset, FieldsetLegend, Figure, FigureCaption, FigureFrame, Form, Ground, Grow, Heading, HoverCard, HoverCardContent, HoverCardTrigger, Icon, Input, InputGroup, InputGroupAddon, InputGroupButton, Kbd, Link, Logomark, Menu, MenuCheckboxItem, MenuContent, MenuGroup, MenuGroupLabel, MenuItem, MenuLinkItem, MenuRadioGroup, MenuRadioItem, MenuSeparator, MenuSub, MenuSubContent, MenuSubTrigger, MenuTrigger, Meter, MeterLabel, MeterTrack, MeterValue, NavigationMenu, NavigationMenuContent, NavigationMenuItem, NavigationMenuLink, NavigationMenuLinkDescription, NavigationMenuLinkTitle, NavigationMenuList, NavigationMenuTrigger, NumberField, NumberFieldDecrement, NumberFieldIncrement, NumberFieldInput, Pager, PagerLink, Parameter, ParameterList, Popover, PopoverClose, PopoverContent, PopoverDescription, PopoverTitle, PopoverTrigger, Progress, ProgressLabel, ProgressTrack, ProgressValue, Prose, Quote, Radio, RadioGroup, ReferenceEntry, ReferenceEntryBody, ReferenceEntryHeader, ReferenceEntryMeta, ReferenceEntryName, ReferenceEntryTitle, ScrollFade, Seam, Section, Segment, SegmentedControl, Select, SelectContent, SelectGroup, SelectGroupLabel, SelectItem, SelectSeparator, SelectTrigger, Separator, Shimmer, SideNav, SideNavGroup, SideNavLink, SideNavSubLink, SiteFooter, SiteFooterBrand, SiteFooterGroup, SiteFooterLegal, SiteFooterLink, SiteFooterMain, SiteFooterNav, SiteHeader, SiteHeaderActions, SiteHeaderBrand, SiteHeaderMenu, SiteHeaderMenuGroup, SiteHeaderMenuLink, Slider, SliderControl, SliderLabel, SliderThumb, SliderValue, Spinner, Switch, Tab, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableOfContents, TableRow, TableSortButton, Tabs, TabsList, TabsPanel, TabsPanels, Text, Textarea, ThemeSwitch, TimeField, Toaster, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, Trace, TraceStep, TraceSummary, Wordmark, buttonVariants, cn, containerVariants, docsPageState, docsPages, findDocsPage, linkVariants, mergeClassName, navigationMenuEntryVariants, sameDocsPage, siteFooterLinkClass, springs, toast, toastManager, transitions, useGround, useScrollEdges };
|
|
128
|
+
export { Accordion, AccordionItem, AccordionPanel, AccordionTrigger, ActionBar, ActionBarButton, Alert, AlertDescription, AlertDialog, AlertDialogClose, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, AlertDialogTrigger, AlertTitle, AnchorHeading, AppShell, AppShellBar, AppShellMain, AppShellPage, Attachment, Avatar, AvatarFallback, AvatarGroup, AvatarImage, Badge, Banner, BreadcrumbItem, BreadcrumbLink, BreadcrumbPage, Breadcrumbs, Button, ButtonGroup, Calendar, Callout, Card, CardBar, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Checkbox, CheckboxCard, CheckboxGroup, CheckboxGroupItems, Chip, ChipGroup, Code, CodeBlock, CodeBlockLive, CodeTabs, Collapsible, CollapsiblePanel, CollapsibleTrigger, Combobox, ComboboxChips, ComboboxCollection, ComboboxContent, ComboboxGroup, ComboboxGroupLabel, ComboboxInput, ComboboxItem, ComboboxSeparator, Command, CommandContent, CommandFooter, CommandInput, CommandList, CommandTrigger, ConsentEmbed, ConsentGate, ConsentProvider, ConsentSettingsTrigger, Container, ContextMenu, ContextMenuContent, ContextMenuTrigger, Conversation, ConversationContent, ConversationLatest, CopyButton, CopyPage, CopyPill, CopyPillMark, Cta, CtaAction, CtaActions, CtaMessage, CtaText, CtaTitle, DateField, DateRangeField, DescriptionDetails, DescriptionList, DescriptionTerm, Dialog, DialogBody, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger, DocsLayout, DocsLayoutAside, DocsLayoutMain, DocsLayoutNav, Drawer, DrawerBody, DrawerClose, DrawerContent, DrawerDescription, DrawerFooter, DrawerHeader, DrawerTitle, DrawerTrigger, Empty, EmptyActions, EmptyMedia, EmptyText, EmptyTitle, Field, FieldDescription, FieldError, FieldLabel, Fieldset, FieldsetLegend, Figure, FigureCaption, FigureFrame, FileUpload, FileUploadItem, FileUploadList, FileUploadZone, Form, Ground, Grow, Heading, HoverCard, HoverCardContent, HoverCardTrigger, Icon, Input, InputGroup, InputGroupAddon, InputGroupButton, Kbd, Link, Loaded, Logomark, Menu, MenuCheckboxItem, MenuContent, MenuGroup, MenuGroupLabel, MenuItem, MenuLinkItem, MenuRadioGroup, MenuRadioItem, MenuSeparator, MenuSub, MenuSubContent, MenuSubTrigger, MenuTrigger, Message, MessageAction, MessageActions, MessageAttachments, MessageContent, MessageError, MessageFeedback, Meter, MeterLabel, MeterTrack, MeterValue, NavigationMenu, NavigationMenuContent, NavigationMenuItem, NavigationMenuLink, NavigationMenuLinkDescription, NavigationMenuLinkTitle, NavigationMenuList, NavigationMenuTrigger, NumberField, NumberFieldDecrement, NumberFieldIncrement, NumberFieldInput, OtpField, Pager, PagerLink, Pagination, Parameter, ParameterList, Popover, PopoverClose, PopoverContent, PopoverDescription, PopoverTitle, PopoverTrigger, Progress, ProgressLabel, ProgressTrack, ProgressValue, PromptInput, PromptInputActions, PromptInputAttach, PromptInputAttachments, PromptInputSubmit, PromptInputTextarea, Prose, Quote, Radio, RadioCard, RadioGroup, ReferenceEntry, ReferenceEntryBody, ReferenceEntryHeader, ReferenceEntryMeta, ReferenceEntryName, ReferenceEntryTitle, RollingNumber, ScrollFade, Seam, SecretField, Section, Segment, SegmentedControl, Select, SelectContent, SelectGroup, SelectGroupLabel, SelectItem, SelectSeparator, SelectTrigger, Separator, Shimmer, Shortcut, ShortcutProvider, SideNav, SideNavGroup, SideNavLink, SideNavSubLink, Sidebar, SidebarButton, SidebarContent, SidebarFooter, SidebarGroup, SidebarHeader, SidebarItem, SidebarMenu, SidebarSubItem, SidebarTrigger, SiteFooter, SiteFooterBrand, SiteFooterGroup, SiteFooterLegal, SiteFooterLink, SiteFooterMain, SiteFooterNav, SiteHeader, SiteHeaderActions, SiteHeaderBrand, SiteHeaderMenu, SiteHeaderMenuGroup, SiteHeaderMenuLink, Skeleton, SkeletonGroup, Slider, SliderControl, SliderLabel, SliderThumb, SliderValue, SourceList, SourceReference, Sources, Spinner, Stat, StatChange, StatGroup, StatLabel, StatValue, Step, Steps, Switch, Tab, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableOfContents, TableRow, TableSortButton, Tabs, TabsList, TabsPanel, TabsPanels, Text, Textarea, ThemeSwitch, TimeField, Timeline, TimelineGroup, TimelineItem, Toaster, Toggle, ToggleGroup, Toolbar, ToolbarButton, ToolbarGroup, ToolbarInput, ToolbarLink, ToolbarSeparator, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, Trace, TraceStep, TraceSummary, Wordmark, acceptsFile, buttonVariants, cn, consentAllows, consentLabels, containerVariants, createMemoryJar, docsPageState, docsPages, findDocsPage, formatFileProgress, formatFileSize, kindOf, linkVariants, mergeClassName, navigationMenuEntryVariants, parseConsent, sameDocsPage, siteFooterLinkClass, siteOf, sortFiles, springs, toast, toastManager, transitions, useConsent, useConversation, useGround, usePlatform, useScrollEdges, useShortcut };
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
const segmenter = typeof Intl !== "undefined" && "Segmenter" in Intl ? new Intl.Segmenter("de", { granularity: "word" }) : null;
|
|
2
|
+
/** Where the words of `text` between `from` and `to` begin. Punctuation is not a word. */
|
|
3
|
+
function wordStarts(text, from, to) {
|
|
4
|
+
const stretch = text.slice(from, to);
|
|
5
|
+
const starts = [];
|
|
6
|
+
if (segmenter) {
|
|
7
|
+
for (const segment of segmenter.segment(stretch)) if (segment.isWordLike) starts.push(from + segment.index);
|
|
8
|
+
} else for (const word of stretch.matchAll(/\S+/g)) starts.push(from + word.index);
|
|
9
|
+
return starts;
|
|
10
|
+
}
|
|
11
|
+
/** Just after the last white space at or after `from`: how far the finished words reach. */
|
|
12
|
+
function finishedUpTo(text, from) {
|
|
13
|
+
for (let index = text.length - 1; index >= from; index -= 1) if (/\s/.test(text.charAt(index))) return index + 1;
|
|
14
|
+
return from;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* The pieces of `text` now, given the pieces it was shown in before. `complete` says that no
|
|
18
|
+
* more will be added to this text, so its last word is shown even without a space after it.
|
|
19
|
+
*
|
|
20
|
+
* A text that has become shorter (a renderer that took back what it had drawn, a retry that
|
|
21
|
+
* starts again) keeps what still stands as shown and fades in only what is added after that.
|
|
22
|
+
*/
|
|
23
|
+
function advancePieces(before, text, { complete, wordsPerPiece = 3 }) {
|
|
24
|
+
let ends = before;
|
|
25
|
+
let shown = ends.at(-1) ?? 0;
|
|
26
|
+
if (text.length < shown) {
|
|
27
|
+
ends = [...ends.filter((end) => end < text.length), text.length].filter((end) => end > 0);
|
|
28
|
+
shown = text.length;
|
|
29
|
+
}
|
|
30
|
+
const fresh = ends.length;
|
|
31
|
+
const reach = complete ? text.length : finishedUpTo(text, shown);
|
|
32
|
+
if (reach <= shown) return {
|
|
33
|
+
ends,
|
|
34
|
+
fresh
|
|
35
|
+
};
|
|
36
|
+
const cuts = wordStarts(text, shown, reach).filter((start, index) => index > 0 && index % wordsPerPiece === 0 && start > shown);
|
|
37
|
+
return {
|
|
38
|
+
ends: [
|
|
39
|
+
...ends,
|
|
40
|
+
...cuts,
|
|
41
|
+
reach
|
|
42
|
+
],
|
|
43
|
+
fresh
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* The delays of pieces that fade in together, in ms: one after the other, `step` apart, but
|
|
48
|
+
* never longer than `span` for the lot. A burst of text is pressed together instead of queuing,
|
|
49
|
+
* so a fast stream never falls behind what has arrived.
|
|
50
|
+
*/
|
|
51
|
+
function staggerDelays(count, step, span) {
|
|
52
|
+
if (count <= 0) return [];
|
|
53
|
+
const gap = count > 1 ? Math.min(step, span / (count - 1)) : 0;
|
|
54
|
+
return Array.from({ length: count }, (_, index) => Math.round(index * gap));
|
|
55
|
+
}
|
|
56
|
+
export { advancePieces, staggerDelays };
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { advancePieces, staggerDelays } from "./arriving-pieces.js";
|
|
3
|
+
import { useReducedMotion } from "./reduced-motion.js";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
import { Fragment as Fragment$1, cloneElement, isValidElement, useEffect, useLayoutEffect, useRef, useState } from "react";
|
|
6
|
+
// src/internal/arriving.tsx
|
|
7
|
+
/**
|
|
8
|
+
* Pieces of one look fade in this far apart at most, and all within this span (ms). Fading in
|
|
9
|
+
* by words was chosen over a line at a time, once it is full (Justin, 2026-11-19).
|
|
10
|
+
*/
|
|
11
|
+
const WORD_STEP = 40;
|
|
12
|
+
const SPAN = 240;
|
|
13
|
+
/** Elements whose text arrives whole: code, pictures, formulas, form controls. */
|
|
14
|
+
const whole = /* @__PURE__ */ new Set([
|
|
15
|
+
"pre",
|
|
16
|
+
"svg",
|
|
17
|
+
"math",
|
|
18
|
+
"script",
|
|
19
|
+
"style",
|
|
20
|
+
"textarea",
|
|
21
|
+
"select"
|
|
22
|
+
]);
|
|
23
|
+
/**
|
|
24
|
+
* The look of a piece. `data-arriving` is never rendered: the engine sets it on a new piece
|
|
25
|
+
* before it is painted and takes it away when its fade begins.
|
|
26
|
+
*/
|
|
27
|
+
const pieceLook = "transition-opacity spring-settle data-arriving:opacity-0";
|
|
28
|
+
/** The caller's tree with each string handed to `visit`; everything else as it was. */
|
|
29
|
+
function walk(node, path, visit) {
|
|
30
|
+
if (typeof node === "string") return visit(node, path);
|
|
31
|
+
if (typeof node === "number" || typeof node === "bigint") return visit(String(node), path);
|
|
32
|
+
if (Array.isArray(node)) return node.map((child, index) => walk(child, `${path}.${index}`, visit));
|
|
33
|
+
if (!isValidElement(node)) return node;
|
|
34
|
+
const element = node;
|
|
35
|
+
const { type } = element;
|
|
36
|
+
const children = element.props.children;
|
|
37
|
+
if (children === void 0 || children === null || typeof children === "boolean") return node;
|
|
38
|
+
if (typeof children === "function") return node;
|
|
39
|
+
if (typeof type === "string") {
|
|
40
|
+
if (whole.has(type)) return node;
|
|
41
|
+
} else if (type !== Fragment$1 && typeof children === "string") {
|
|
42
|
+
if (!type.carriesText) return node;
|
|
43
|
+
}
|
|
44
|
+
if (Array.isArray(children)) {
|
|
45
|
+
const walked = children.map((child, index) => walk(child, `${path}.${index}`, visit));
|
|
46
|
+
return cloneElement(element, void 0, ...walked);
|
|
47
|
+
}
|
|
48
|
+
return cloneElement(element, void 0, walk(children, `${path}.0`, visit));
|
|
49
|
+
}
|
|
50
|
+
/** Every string of a tree by its place in it, in reading order. */
|
|
51
|
+
function textsOf(children) {
|
|
52
|
+
const texts = /* @__PURE__ */ new Map();
|
|
53
|
+
walk(children, "t", (text, path) => {
|
|
54
|
+
texts.set(path, text);
|
|
55
|
+
return null;
|
|
56
|
+
});
|
|
57
|
+
return texts;
|
|
58
|
+
}
|
|
59
|
+
/** The first look: everything there is shown at once. */
|
|
60
|
+
function firstLook(children, streaming) {
|
|
61
|
+
const texts = /* @__PURE__ */ new Map();
|
|
62
|
+
for (const [path, text] of textsOf(children)) texts.set(path, text.length > 0 ? {
|
|
63
|
+
ends: [text.length],
|
|
64
|
+
born: [0]
|
|
65
|
+
} : {
|
|
66
|
+
ends: [],
|
|
67
|
+
born: []
|
|
68
|
+
});
|
|
69
|
+
return {
|
|
70
|
+
source: children,
|
|
71
|
+
streaming,
|
|
72
|
+
generation: 0,
|
|
73
|
+
texts
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
/** The next look: what is new since the last one becomes pieces of this one. */
|
|
77
|
+
function nextLook(before, children, streaming) {
|
|
78
|
+
const generation = before.generation + 1;
|
|
79
|
+
const strings = textsOf(children);
|
|
80
|
+
const last = [...strings.keys()].at(-1);
|
|
81
|
+
const texts = /* @__PURE__ */ new Map();
|
|
82
|
+
for (const [path, text] of strings) {
|
|
83
|
+
const old = before.texts.get(path) ?? {
|
|
84
|
+
ends: [],
|
|
85
|
+
born: []
|
|
86
|
+
};
|
|
87
|
+
const { ends, fresh } = advancePieces(old.ends, text, { complete: !streaming || path !== last });
|
|
88
|
+
const born = [...old.born.slice(0, fresh), ...ends.slice(fresh).map(() => generation)];
|
|
89
|
+
texts.set(path, {
|
|
90
|
+
ends,
|
|
91
|
+
born
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
return {
|
|
95
|
+
source: children,
|
|
96
|
+
streaming,
|
|
97
|
+
generation,
|
|
98
|
+
texts
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
/** The caller's tree with its strings cut into the pieces of a look. */
|
|
102
|
+
function draw(children, look) {
|
|
103
|
+
return walk(children, "t", (text, path) => {
|
|
104
|
+
const shown = look.texts.get(path);
|
|
105
|
+
if (!shown) return text;
|
|
106
|
+
let start = 0;
|
|
107
|
+
return /* @__PURE__ */ jsx(Fragment$1, { children: shown.ends.map((end, index) => {
|
|
108
|
+
const piece = /* @__PURE__ */ jsx("span", {
|
|
109
|
+
"data-slot": "message-piece",
|
|
110
|
+
"data-born": shown.born[index],
|
|
111
|
+
className: pieceLook,
|
|
112
|
+
children: text.slice(start, end)
|
|
113
|
+
}, index);
|
|
114
|
+
start = end;
|
|
115
|
+
return piece;
|
|
116
|
+
}) }, path);
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Text that is still being written, faded in piece by piece. It takes the tree the caller has
|
|
121
|
+
* rendered (paragraphs, lists, links, from Markdown or not) and cuts each string in it into
|
|
122
|
+
* pieces of a few words; a piece that is new since the last render fades in on `settle`, a few
|
|
123
|
+
* pieces 40ms apart and a burst pressed into 240ms. Nothing travels: the words are being read.
|
|
124
|
+
*
|
|
125
|
+
* What a component draws from its props, or as HTML, arrives whole; so does code. Hand over
|
|
126
|
+
* the rendered elements, not a component that renders the Markdown itself: from the outside
|
|
127
|
+
* its text cannot be seen.
|
|
128
|
+
*
|
|
129
|
+
* What the text holds when it mounts is there at once. Once `streaming` is over and the last
|
|
130
|
+
* piece has faded in, the pieces go and the caller's tree is rendered as it is. Under reduced
|
|
131
|
+
* motion there are no pieces at all.
|
|
132
|
+
*/
|
|
133
|
+
function useArrivingText(children, { streaming, box }) {
|
|
134
|
+
const reduced = useReducedMotion();
|
|
135
|
+
const [plain, setPlain] = useState(!streaming);
|
|
136
|
+
const [look, setLook] = useState(() => firstLook(children, streaming));
|
|
137
|
+
if (streaming && plain) {
|
|
138
|
+
setPlain(false);
|
|
139
|
+
setLook(firstLook(children, streaming));
|
|
140
|
+
} else if (!plain && (look.source !== children || look.streaming !== streaming)) setLook(nextLook(look, children, streaming));
|
|
141
|
+
const active = !plain && !reduced;
|
|
142
|
+
/** The last look whose new pieces were set off. */
|
|
143
|
+
const handled = useRef(0);
|
|
144
|
+
useLayoutEffect(() => {
|
|
145
|
+
const root = box.current;
|
|
146
|
+
if (look.generation < handled.current) handled.current = look.generation;
|
|
147
|
+
if (!active || !root || handled.current >= look.generation) return;
|
|
148
|
+
const since = handled.current;
|
|
149
|
+
handled.current = look.generation;
|
|
150
|
+
const fresh = [...root.querySelectorAll("[data-born]")].filter((piece) => Number(piece.dataset.born) > since);
|
|
151
|
+
if (fresh.length === 0) return;
|
|
152
|
+
for (const piece of fresh) piece.setAttribute("data-arriving", "");
|
|
153
|
+
root.offsetHeight;
|
|
154
|
+
const delays = staggerDelays(fresh.length, WORD_STEP, SPAN);
|
|
155
|
+
fresh.forEach((piece, index) => {
|
|
156
|
+
piece.style.transitionDelay = `${delays[index] ?? 0}ms`;
|
|
157
|
+
piece.removeAttribute("data-arriving");
|
|
158
|
+
});
|
|
159
|
+
}, [
|
|
160
|
+
active,
|
|
161
|
+
look,
|
|
162
|
+
box
|
|
163
|
+
]);
|
|
164
|
+
useEffect(() => {
|
|
165
|
+
if (streaming || plain) return;
|
|
166
|
+
const timer = window.setTimeout(() => setPlain(true), 840);
|
|
167
|
+
return () => window.clearTimeout(timer);
|
|
168
|
+
}, [streaming, plain]);
|
|
169
|
+
return active ? draw(children, look) : children;
|
|
170
|
+
}
|
|
171
|
+
export { useArrivingText };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The cut-out that parts two avatars: the gap between them is not a ring in the colour of the
|
|
3
|
+
* ground, it is cut out of the avatar underneath, so it is right on every ground, on a washed
|
|
4
|
+
* table row and over a picture. Avatars are round, and the outline of a circle grown by the gap
|
|
5
|
+
* is a circle the gap larger: the cut follows the avatar in front at a constant distance, and
|
|
6
|
+
* what is seen of the one underneath is a clean crescent.
|
|
7
|
+
*
|
|
8
|
+
* A presence dot stands on the edge of its avatar, half outside it, and is cut out of the avatar
|
|
9
|
+
* the same way, in a circle the gap larger than the dot; the avatar underneath has a hole for
|
|
10
|
+
* the dot of the one in front as well, so the dot never touches it.
|
|
11
|
+
*
|
|
12
|
+
* Each cut is one SVG for the avatar's own box, used as its mask: it moves and scales with the
|
|
13
|
+
* avatar and is drawn in whole pixels. Server-safe; the numbers are pixels at a 16px root.
|
|
14
|
+
*/
|
|
15
|
+
export type AvatarSize = "sm" | "md" | "lg" | "xl";
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
// src/internal/avatar-cut.ts
|
|
2
|
+
/** The avatar of each size: its diameter and the diameter of its presence dot. */
|
|
3
|
+
const avatarGeometry = {
|
|
4
|
+
sm: {
|
|
5
|
+
size: 24,
|
|
6
|
+
dot: 6
|
|
7
|
+
},
|
|
8
|
+
md: {
|
|
9
|
+
size: 28,
|
|
10
|
+
dot: 8
|
|
11
|
+
},
|
|
12
|
+
lg: {
|
|
13
|
+
size: 36,
|
|
14
|
+
dot: 10
|
|
15
|
+
},
|
|
16
|
+
xl: {
|
|
17
|
+
size: 48,
|
|
18
|
+
dot: 12
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* How far one avatar lies over the next, in pixels: a quarter of it, so a face stays a face
|
|
23
|
+
* (Justin, 2026-11-19, over a third).
|
|
24
|
+
*/
|
|
25
|
+
const avatarOverlap = {
|
|
26
|
+
sm: 6,
|
|
27
|
+
md: 7,
|
|
28
|
+
lg: 9,
|
|
29
|
+
xl: 12
|
|
30
|
+
};
|
|
31
|
+
/** Where a presence dot stands in an avatar's box: on its edge, in the bottom end corner. */
|
|
32
|
+
function dotCentre(size, dot) {
|
|
33
|
+
return size - dot / 2;
|
|
34
|
+
}
|
|
35
|
+
/** The circles cut out of an avatar, in its own pixels. */
|
|
36
|
+
function cutShapes({ size, gap, step, dot, frontDot, rtl }) {
|
|
37
|
+
const circles = [];
|
|
38
|
+
if (step !== void 0) {
|
|
39
|
+
circles.push({
|
|
40
|
+
cx: size / 2 - step,
|
|
41
|
+
cy: size / 2,
|
|
42
|
+
r: size / 2 + gap
|
|
43
|
+
});
|
|
44
|
+
if (frontDot !== void 0) {
|
|
45
|
+
const at = dotCentre(size, frontDot);
|
|
46
|
+
circles.push({
|
|
47
|
+
cx: at - step,
|
|
48
|
+
cy: at,
|
|
49
|
+
r: frontDot / 2 + gap
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
if (dot !== void 0) {
|
|
54
|
+
const at = dotCentre(size, dot);
|
|
55
|
+
circles.push({
|
|
56
|
+
cx: at,
|
|
57
|
+
cy: at,
|
|
58
|
+
r: dot / 2 + gap
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
return rtl ? circles.map((circle) => ({
|
|
62
|
+
...circle,
|
|
63
|
+
cx: size - circle.cx
|
|
64
|
+
})) : circles;
|
|
65
|
+
}
|
|
66
|
+
const masks = /* @__PURE__ */ new Map();
|
|
67
|
+
/**
|
|
68
|
+
* The mask of one avatar as a CSS `url()`, or `undefined` when nothing is cut out of it. Black
|
|
69
|
+
* circles in an SVG `<mask>` rather than holes in one path, so two cuts that overlap stay cut.
|
|
70
|
+
*/
|
|
71
|
+
function cutMask(options) {
|
|
72
|
+
const key = JSON.stringify(options);
|
|
73
|
+
const cached = masks.get(key);
|
|
74
|
+
if (cached) return cached;
|
|
75
|
+
const circles = cutShapes(options);
|
|
76
|
+
if (circles.length === 0) return void 0;
|
|
77
|
+
const { size } = options;
|
|
78
|
+
const svg = `<svg xmlns="http://www.w3.org/2000/svg" width="${size}" height="${size}" viewBox="0 0 ${size} ${size}"><mask id="m"><rect width="${size}" height="${size}" fill="#fff"/><g fill="#000">${circles.map((circle) => `<circle cx="${circle.cx}" cy="${circle.cy}" r="${circle.r}"/>`).join("")}</g></mask><rect width="${size}" height="${size}" mask="url(#m)"/></svg>`;
|
|
79
|
+
const mask = `url("data:image/svg+xml,${encodeURIComponent(svg)}")`;
|
|
80
|
+
masks.set(key, mask);
|
|
81
|
+
return mask;
|
|
82
|
+
}
|
|
83
|
+
export { avatarGeometry, avatarOverlap, cutMask, cutShapes, dotCentre };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { IconSvgElement } from "../components/icon/icon.js";
|
|
2
|
+
import { ReactNode } from "react";
|
|
3
|
+
/** What a card that is a choice says about itself. */
|
|
4
|
+
export type ChoiceCardText = {
|
|
5
|
+
/** The choice, in a word or two: "Team", "Rechnungen schreiben". It names the control. */
|
|
6
|
+
title: ReactNode;
|
|
7
|
+
/** One sentence on what choosing it means. It describes the control. */
|
|
8
|
+
description?: ReactNode;
|
|
9
|
+
/** A second fact at the end of the first line, in tabular digits: a price, a number. */
|
|
10
|
+
detail?: ReactNode;
|
|
11
|
+
/** A 16px symbol before the title. Give every card of a group one or none. */
|
|
12
|
+
icon?: IconSvgElement;
|
|
13
|
+
/** More that belongs to the choice, under its sentence: a short list, a `Badge`. */
|
|
14
|
+
children?: ReactNode;
|
|
15
|
+
};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { Icon } from "../components/icon/icon.js";
|
|
2
|
+
import { cn } from "../lib/cn.js";
|
|
3
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
+
// src/internal/choice-card.tsx
|
|
5
|
+
/**
|
|
6
|
+
* The card around a radio or a checkbox: a bevelled card (`depth-bevel`) that is the control's
|
|
7
|
+
* label, so the whole of it is the target. It keeps its size and place. Under the pointer a soft
|
|
8
|
+
* light follows the pointer across its face (`followPointer`); edge and shadow stay. Under a
|
|
9
|
+
* press its shadow goes down to the page while its mark dips as a plain `Radio` or `Checkbox`
|
|
10
|
+
* does. (The whole card going down to the press scale was too heavy: Justin, 2026-11-19. A wide
|
|
11
|
+
* shadow rising under the pointer was "odd"; the light was chosen over a firmer edge and over a
|
|
12
|
+
* 1px lift: Justin, 2026-11-20.) It takes the accent outline when the keyboard is on its
|
|
13
|
+
* control, and lies flat when the control is disabled. State is read from the control inside,
|
|
14
|
+
* which carries `data-slot="choice-control"`.
|
|
15
|
+
*/
|
|
16
|
+
const choiceCard = [
|
|
17
|
+
"group/card relative isolate flex cursor-pointer items-start gap-3 rounded-xl bg-surface p-4 text-left depth-bevel select-none",
|
|
18
|
+
"transition-[box-shadow] spring-leave not-active:has-[[data-slot=choice-control][data-checked]]:spring-settle active:spring-snap",
|
|
19
|
+
"not-has-[[data-slot=choice-control][data-disabled]]:active:shadow-bevel-pressed",
|
|
20
|
+
"before:pointer-events-none before:absolute before:inset-0 before:-z-1 before:rounded-[inherit] before:opacity-0",
|
|
21
|
+
"before:bg-[radial-gradient(240px_circle_at_var(--light-x,50%)_var(--light-y,50%),var(--depth-bevel-light),transparent_70%)]",
|
|
22
|
+
"before:transition-opacity before:spring-settle not-has-[[data-slot=choice-control][data-disabled]]:hover:before:opacity-100",
|
|
23
|
+
"has-[[data-slot=choice-control]:focus-visible]:outline-2 has-[[data-slot=choice-control]:focus-visible]:outline-offset-2 has-[[data-slot=choice-control]:focus-visible]:outline-accent",
|
|
24
|
+
"has-[[data-slot=choice-control][data-disabled]]:cursor-default has-[[data-slot=choice-control][data-disabled]]:bg-disabled has-[[data-slot=choice-control][data-disabled]]:depth-flat"
|
|
25
|
+
].join(" ");
|
|
26
|
+
/**
|
|
27
|
+
* Where the pointer is on the card, for its light: written straight onto the card as two custom
|
|
28
|
+
* properties, so a move never renders. Put it on the card as `onPointerMove`.
|
|
29
|
+
*/
|
|
30
|
+
function followPointer(event) {
|
|
31
|
+
if (event.pointerType !== "mouse" && event.pointerType !== "pen") return;
|
|
32
|
+
const card = event.currentTarget;
|
|
33
|
+
const box = card.getBoundingClientRect();
|
|
34
|
+
card.style.setProperty("--light-x", `${event.clientX - box.left}px`);
|
|
35
|
+
card.style.setProperty("--light-y", `${event.clientY - box.top}px`);
|
|
36
|
+
}
|
|
37
|
+
/** The chosen card wears the accent as its edge; it eases in on the card's own transition. */
|
|
38
|
+
const choiceCardEdge = "has-[[data-slot=choice-control][data-checked]]:depth-bevel-chosen";
|
|
39
|
+
/**
|
|
40
|
+
* The control inside the card: a box of the check size on the title's first line. The card
|
|
41
|
+
* around it takes the presses and shows the focus, so the control gives both up; it dips
|
|
42
|
+
* while the card is pressed, by as much as a plain `Radio` does under its own press.
|
|
43
|
+
*/
|
|
44
|
+
const choiceControl = [
|
|
45
|
+
"group/control pointer-events-none mt-0.5 flex size-(--check-size) shrink-0 items-center justify-center outline-hidden",
|
|
46
|
+
"transition-[scale] spring-seat group-active/card:scale-[0.92] group-active/card:spring-snap",
|
|
47
|
+
"data-disabled:scale-100"
|
|
48
|
+
].join(" ");
|
|
49
|
+
/** The words of the card, beside its control. */
|
|
50
|
+
function ChoiceCardBody({ slot, titleId, descriptionId, title, description, detail, icon, children }) {
|
|
51
|
+
return /* @__PURE__ */ jsxs("span", {
|
|
52
|
+
className: "flex min-w-0 flex-1 flex-col gap-0.5",
|
|
53
|
+
children: [
|
|
54
|
+
/* @__PURE__ */ jsxs("span", {
|
|
55
|
+
className: "flex items-baseline gap-3",
|
|
56
|
+
children: [/* @__PURE__ */ jsxs("span", {
|
|
57
|
+
id: titleId,
|
|
58
|
+
"data-slot": `${slot}-title`,
|
|
59
|
+
className: cn("flex min-w-0 items-center gap-2 text-control font-medium text-fg", "group-has-[[data-disabled]]/card:text-on-disabled"),
|
|
60
|
+
children: [icon && /* @__PURE__ */ jsx(Icon, {
|
|
61
|
+
icon,
|
|
62
|
+
size: 16,
|
|
63
|
+
className: "shrink-0 text-fg-muted"
|
|
64
|
+
}), title]
|
|
65
|
+
}), detail !== void 0 && /* @__PURE__ */ jsx("span", {
|
|
66
|
+
"data-slot": `${slot}-detail`,
|
|
67
|
+
className: "ml-auto shrink-0 text-control whitespace-nowrap text-fg-body tabular-nums group-has-[[data-disabled]]/card:text-on-disabled",
|
|
68
|
+
children: detail
|
|
69
|
+
})]
|
|
70
|
+
}),
|
|
71
|
+
description !== void 0 && /* @__PURE__ */ jsx("span", {
|
|
72
|
+
id: descriptionId,
|
|
73
|
+
"data-slot": `${slot}-description`,
|
|
74
|
+
className: "text-sm text-pretty text-fg-muted group-has-[[data-disabled]]/card:text-on-disabled",
|
|
75
|
+
children: description
|
|
76
|
+
}),
|
|
77
|
+
children
|
|
78
|
+
]
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
export { ChoiceCardBody, choiceCard, choiceCardEdge, choiceControl, followPointer };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// src/internal/clipboard.ts
|
|
2
|
+
/**
|
|
3
|
+
* Puts text on the clipboard, or rejects when the browser refuses.
|
|
4
|
+
*
|
|
5
|
+
* The text may still be on its way (a page being fetched). A browser only lets a press write to
|
|
6
|
+
* the clipboard, and a write that waits for the text first has left the press by the time it
|
|
7
|
+
* comes. Where the browser takes a promise for the clipboard (Safari, Chrome), the promise is
|
|
8
|
+
* handed over inside the press and the text follows; elsewhere the write waits for it.
|
|
9
|
+
*/
|
|
10
|
+
async function writeClipboard(text) {
|
|
11
|
+
if (typeof text === "string") {
|
|
12
|
+
await navigator.clipboard.writeText(text);
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
try {
|
|
16
|
+
if (typeof ClipboardItem !== "undefined" && typeof navigator.clipboard.write === "function") {
|
|
17
|
+
const blob = text.then((body) => new Blob([body], { type: "text/plain" }));
|
|
18
|
+
await navigator.clipboard.write([new ClipboardItem({ "text/plain": blob })]);
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
} catch {}
|
|
22
|
+
await navigator.clipboard.writeText(await text);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Selects what an element shows, so ⌘C still copies it after the clipboard was refused: the
|
|
26
|
+
* text of a field, or everything inside any other element.
|
|
27
|
+
*/
|
|
28
|
+
function selectContents(element) {
|
|
29
|
+
if (!element) return;
|
|
30
|
+
if (element instanceof HTMLInputElement || element instanceof HTMLTextAreaElement) {
|
|
31
|
+
element.focus();
|
|
32
|
+
element.select();
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
window.getSelection()?.selectAllChildren(element);
|
|
36
|
+
}
|
|
37
|
+
export { selectContents, writeClipboard };
|