zabi-components 7.0.2 → 8.1.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/CHANGELOG.md +1924 -0
- package/README.md +287 -11
- package/THEME.md +149 -332
- package/THEMING.md +1329 -163
- package/dist/atoms/ActionPanel.svelte +24 -9
- package/dist/atoms/ActionPanel.svelte.d.ts +2 -0
- package/dist/atoms/Avatar.svelte +104 -0
- package/dist/atoms/Avatar.svelte.d.ts +34 -0
- package/dist/atoms/Badge.svelte +124 -58
- package/dist/atoms/Badge.svelte.d.ts +17 -5
- package/dist/atoms/Button.svelte +212 -62
- package/dist/atoms/Button.svelte.d.ts +33 -2
- package/dist/atoms/Card.svelte +31 -28
- package/dist/atoms/Card.svelte.d.ts +5 -2
- package/dist/atoms/CardContent.svelte +10 -2
- package/dist/atoms/CardContent.svelte.d.ts +2 -0
- package/dist/atoms/CardFooter.svelte +10 -2
- package/dist/atoms/CardFooter.svelte.d.ts +2 -0
- package/dist/atoms/CardHeader.svelte +26 -6
- package/dist/atoms/CardHeader.svelte.d.ts +2 -0
- package/dist/atoms/Checkbox.svelte +52 -21
- package/dist/atoms/Checkbox.svelte.d.ts +6 -2
- package/dist/atoms/CodeBlock.svelte +35 -9
- package/dist/atoms/CodeBlock.svelte.d.ts +13 -3
- package/dist/atoms/ColorPicker.svelte +272 -52
- package/dist/atoms/ColorPicker.svelte.d.ts +6 -1
- package/dist/atoms/Container.svelte +17 -10
- package/dist/atoms/DateField.svelte +107 -0
- package/dist/atoms/DateField.svelte.d.ts +53 -0
- package/dist/atoms/Divider.svelte +4 -4
- package/dist/atoms/FeatureCard.svelte +4 -3
- package/dist/atoms/FieldMessages.svelte +69 -0
- package/dist/atoms/FieldMessages.svelte.d.ts +23 -0
- package/dist/atoms/FloatingActionButton.svelte +174 -0
- package/dist/atoms/FloatingActionButton.svelte.d.ts +51 -0
- package/dist/atoms/Heading.svelte +93 -32
- package/dist/atoms/Heading.svelte.d.ts +24 -4
- package/dist/atoms/IconButton.svelte +242 -53
- package/dist/atoms/IconButton.svelte.d.ts +49 -4
- package/dist/atoms/Input.svelte +267 -74
- package/dist/atoms/Input.svelte.d.ts +32 -2
- package/dist/atoms/List.svelte +13 -2
- package/dist/atoms/List.svelte.d.ts +2 -0
- package/dist/atoms/ListItem.svelte +44 -11
- package/dist/atoms/ListItem.svelte.d.ts +5 -0
- package/dist/atoms/ListItemLeading.svelte +4 -2
- package/dist/atoms/ListItemLeading.svelte.d.ts +1 -1
- package/dist/atoms/OptimizedImage.svelte +11 -2
- package/dist/atoms/OptimizedImage.svelte.d.ts +2 -0
- package/dist/atoms/Progress.svelte +31 -9
- package/dist/atoms/Progress.svelte.d.ts +6 -0
- package/dist/atoms/Radio.svelte +23 -3
- package/dist/atoms/Radio.svelte.d.ts +6 -2
- package/dist/atoms/Rating.svelte +494 -0
- package/dist/atoms/Rating.svelte.d.ts +56 -0
- package/dist/atoms/Select.svelte +475 -135
- package/dist/atoms/Select.svelte.d.ts +52 -2
- package/dist/atoms/SelectionControl.svelte +99 -18
- package/dist/atoms/SelectionControl.svelte.d.ts +6 -3
- package/dist/atoms/Skeleton.svelte +5 -3
- package/dist/atoms/Slider.svelte +309 -0
- package/dist/atoms/Slider.svelte.d.ts +40 -0
- package/dist/atoms/Spinner.svelte +57 -0
- package/dist/atoms/Spinner.svelte.d.ts +19 -0
- package/dist/atoms/Table.svelte +152 -6
- package/dist/atoms/Table.svelte.d.ts +15 -3
- package/dist/atoms/TemporalField.svelte +140 -0
- package/dist/atoms/TemporalField.svelte.d.ts +32 -0
- package/dist/atoms/Text.svelte +56 -15
- package/dist/atoms/Text.svelte.d.ts +13 -4
- package/dist/atoms/Textarea.svelte +57 -45
- package/dist/atoms/Textarea.svelte.d.ts +14 -2
- package/dist/atoms/ThemeToggle.svelte +238 -56
- package/dist/atoms/ThemeToggle.svelte.d.ts +28 -3
- package/dist/atoms/TimeField.svelte +108 -0
- package/dist/atoms/TimeField.svelte.d.ts +54 -0
- package/dist/atoms/Toast.svelte +25 -10
- package/dist/atoms/Toast.svelte.d.ts +2 -0
- package/dist/atoms/Toggle.svelte +60 -19
- package/dist/atoms/Toggle.svelte.d.ts +18 -2
- package/dist/atoms/Tooltip.svelte +583 -40
- package/dist/atoms/Tooltip.svelte.d.ts +26 -0
- package/dist/atoms/ZabiStringsProvider.svelte +45 -0
- package/dist/atoms/ZabiStringsProvider.svelte.d.ts +27 -0
- package/dist/atoms/index.d.ts +17 -0
- package/dist/atoms/index.js +12 -0
- package/dist/atoms/selection-control.styles.d.ts +36 -5
- package/dist/atoms/selection-control.styles.js +40 -9
- package/dist/components/atoms/index.d.ts +17 -0
- package/dist/components/atoms/index.d.ts.map +1 -1
- package/dist/components/atoms/selection-control.styles.d.ts +36 -5
- package/dist/components/atoms/selection-control.styles.d.ts.map +1 -1
- package/dist/components/index.d.ts +83 -3
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/molecules/index.d.ts +46 -0
- package/dist/components/molecules/index.d.ts.map +1 -1
- package/dist/components/molecules/toast-store.d.ts +53 -7
- package/dist/components/molecules/toast-store.d.ts.map +1 -1
- package/dist/components/organisms/index.d.ts +6 -0
- package/dist/components/organisms/index.d.ts.map +1 -1
- package/dist/components/types/variants.d.ts +15 -1
- package/dist/components/types/variants.d.ts.map +1 -1
- package/dist/components/util/app-shell.d.ts +28 -0
- package/dist/components/util/app-shell.d.ts.map +1 -0
- package/dist/components/util/avatar.d.ts +36 -0
- package/dist/components/util/avatar.d.ts.map +1 -0
- package/dist/components/util/bottom-sheet.d.ts +30 -0
- package/dist/components/util/bottom-sheet.d.ts.map +1 -0
- package/dist/components/util/bottom-tab-bar.d.ts +35 -0
- package/dist/components/util/bottom-tab-bar.d.ts.map +1 -0
- package/dist/components/util/calendar.d.ts +56 -0
- package/dist/components/util/calendar.d.ts.map +1 -0
- package/dist/components/util/cn.d.ts +8 -0
- package/dist/components/util/cn.d.ts.map +1 -0
- package/dist/components/util/collapsible.d.ts +58 -0
- package/dist/components/util/collapsible.d.ts.map +1 -0
- package/dist/components/util/confirm-dialog.d.ts +12 -0
- package/dist/components/util/confirm-dialog.d.ts.map +1 -0
- package/dist/components/util/date.d.ts +96 -0
- package/dist/components/util/date.d.ts.map +1 -0
- package/dist/components/util/drawer.d.ts +13 -0
- package/dist/components/util/drawer.d.ts.map +1 -0
- package/dist/components/util/dropdown.d.ts +47 -0
- package/dist/components/util/dropdown.d.ts.map +1 -0
- package/dist/components/util/field.d.ts +39 -0
- package/dist/components/util/field.d.ts.map +1 -0
- package/dist/components/util/fit-in-viewport.d.ts +201 -0
- package/dist/components/util/fit-in-viewport.d.ts.map +1 -0
- package/dist/components/util/focus-utils.d.ts +75 -2
- package/dist/components/util/focus-utils.d.ts.map +1 -1
- package/dist/components/util/hydration.d.ts +45 -0
- package/dist/components/util/hydration.d.ts.map +1 -0
- package/dist/components/util/keyboard-inset.d.ts +18 -0
- package/dist/components/util/keyboard-inset.d.ts.map +1 -0
- package/dist/components/util/media-grid.d.ts +51 -0
- package/dist/components/util/media-grid.d.ts.map +1 -0
- package/dist/components/util/media.d.ts +6 -0
- package/dist/components/util/media.d.ts.map +1 -0
- package/dist/components/util/overlay-chrome.d.ts +53 -0
- package/dist/components/util/overlay-chrome.d.ts.map +1 -0
- package/dist/components/util/overlay.d.ts +72 -0
- package/dist/components/util/overlay.d.ts.map +1 -0
- package/dist/components/util/photo.d.ts +215 -0
- package/dist/components/util/photo.d.ts.map +1 -0
- package/dist/components/util/portal.d.ts +23 -0
- package/dist/components/util/portal.d.ts.map +1 -0
- package/dist/components/util/pull-to-refresh.d.ts +27 -0
- package/dist/components/util/pull-to-refresh.d.ts.map +1 -0
- package/dist/components/util/radio-keys.d.ts +25 -0
- package/dist/components/util/radio-keys.d.ts.map +1 -0
- package/dist/components/util/rating.d.ts +23 -0
- package/dist/components/util/rating.d.ts.map +1 -0
- package/dist/components/util/ready-made-strings.d.ts +77 -0
- package/dist/components/util/ready-made-strings.d.ts.map +1 -0
- package/dist/components/util/scroll-padding.d.ts +20 -0
- package/dist/components/util/scroll-padding.d.ts.map +1 -0
- package/dist/components/util/segmented-control.d.ts +16 -0
- package/dist/components/util/segmented-control.d.ts.map +1 -0
- package/dist/components/util/select.d.ts +41 -0
- package/dist/components/util/select.d.ts.map +1 -0
- package/dist/components/util/sheet-drag.d.ts +60 -0
- package/dist/components/util/sheet-drag.d.ts.map +1 -0
- package/dist/components/util/sidebar.d.ts +63 -0
- package/dist/components/util/sidebar.d.ts.map +1 -0
- package/dist/components/util/sortable-list.d.ts +65 -0
- package/dist/components/util/sortable-list.d.ts.map +1 -0
- package/dist/components/util/ssr-safe.d.ts +4 -4
- package/dist/components/util/ssr-safe.d.ts.map +1 -1
- package/dist/components/util/stepper.d.ts +40 -0
- package/dist/components/util/stepper.d.ts.map +1 -0
- package/dist/components/util/swipeable-list-item.d.ts +36 -0
- package/dist/components/util/swipeable-list-item.d.ts.map +1 -0
- package/dist/components/util/theme-mode.d.ts +80 -0
- package/dist/components/util/theme-mode.d.ts.map +1 -0
- package/dist/components/util/toaster.d.ts +93 -0
- package/dist/components/util/toaster.d.ts.map +1 -0
- package/dist/components/util/tooltip.d.ts +10 -0
- package/dist/components/util/tooltip.d.ts.map +1 -0
- package/dist/components/util/top-navbar.d.ts +11 -0
- package/dist/components/util/top-navbar.d.ts.map +1 -0
- package/dist/components/util/touch-target.d.ts +31 -0
- package/dist/components/util/touch-target.d.ts.map +1 -0
- package/dist/components/util/zabi-strings.d.ts +133 -0
- package/dist/components/util/zabi-strings.d.ts.map +1 -0
- package/dist/create-theme/cli.js +169 -0
- package/dist/create-theme/index.d.ts +176 -0
- package/dist/create-theme/index.js +817 -0
- package/dist/create-theme/lib/ramp-math.js +128 -0
- package/dist/create-theme/lib/resolve.js +141 -0
- package/dist/create-theme/theme-data.js +1116 -0
- package/dist/index.d.ts +83 -3
- package/dist/index.js +60 -8
- package/dist/molecules/Alert.svelte +73 -66
- package/dist/molecules/Alert.svelte.d.ts +9 -1
- package/dist/molecules/AppBar.svelte +415 -0
- package/dist/molecules/AppBar.svelte.d.ts +69 -0
- package/dist/molecules/AvatarGroup.svelte +116 -0
- package/dist/molecules/AvatarGroup.svelte.d.ts +40 -0
- package/dist/molecules/BottomSheet.svelte +540 -0
- package/dist/molecules/BottomSheet.svelte.d.ts +93 -0
- package/dist/molecules/BottomTabBar.svelte +297 -0
- package/dist/molecules/BottomTabBar.svelte.d.ts +64 -0
- package/dist/molecules/Calendar.svelte +597 -0
- package/dist/molecules/Calendar.svelte.d.ts +72 -0
- package/dist/molecules/Collapsible.svelte +243 -0
- package/dist/molecules/Collapsible.svelte.d.ts +44 -0
- package/dist/molecules/CollapsibleGroup.svelte +126 -0
- package/dist/molecules/CollapsibleGroup.svelte.d.ts +14 -0
- package/dist/molecules/ComponentDemo.svelte +25 -5
- package/dist/molecules/ComponentDemo.svelte.d.ts +5 -0
- package/dist/molecules/ConfirmDialog.svelte +253 -0
- package/dist/molecules/ConfirmDialog.svelte.d.ts +55 -0
- package/dist/molecules/ContactForm.svelte +46 -19
- package/dist/molecules/ContactForm.svelte.d.ts +10 -0
- package/dist/molecules/Drawer.svelte +394 -0
- package/dist/molecules/Drawer.svelte.d.ts +55 -0
- package/dist/molecules/Dropdown.svelte +540 -50
- package/dist/molecules/Dropdown.svelte.d.ts +49 -6
- package/dist/molecules/DropdownItem.svelte +122 -0
- package/dist/molecules/DropdownItem.svelte.d.ts +28 -0
- package/dist/molecules/EmptyState.svelte +56 -10
- package/dist/molecules/EmptyState.svelte.d.ts +8 -0
- package/dist/molecules/Form.svelte +25 -14
- package/dist/molecules/Form.svelte.d.ts +13 -5
- package/dist/molecules/FormField.svelte +11 -2
- package/dist/molecules/FormField.svelte.d.ts +2 -0
- package/dist/molecules/Header.svelte +13 -3
- package/dist/molecules/Header.svelte.d.ts +2 -0
- package/dist/molecules/ImageUpload.svelte +422 -70
- package/dist/molecules/ImageUpload.svelte.d.ts +61 -5
- package/dist/molecules/MediaGrid.svelte +527 -0
- package/dist/molecules/MediaGrid.svelte.d.ts +77 -0
- package/dist/molecules/Modal.svelte +340 -45
- package/dist/molecules/Modal.svelte.d.ts +59 -7
- package/dist/molecules/NavigationMenu.svelte +15 -3
- package/dist/molecules/NavigationMenu.svelte.d.ts +4 -0
- package/dist/molecules/NavigationMenuContent.svelte +91 -36
- package/dist/molecules/NavigationMenuContent.svelte.d.ts +2 -0
- package/dist/molecules/NavigationMenuItem.svelte +10 -3
- package/dist/molecules/NavigationMenuItem.svelte.d.ts +2 -0
- package/dist/molecules/NavigationMenuLink.svelte +10 -2
- package/dist/molecules/NavigationMenuLink.svelte.d.ts +2 -0
- package/dist/molecules/NavigationMenuList.svelte +19 -4
- package/dist/molecules/NavigationMenuList.svelte.d.ts +2 -0
- package/dist/molecules/NavigationMenuTrigger.svelte +16 -3
- package/dist/molecules/NavigationMenuTrigger.svelte.d.ts +2 -0
- package/dist/molecules/Page.svelte +38 -2
- package/dist/molecules/Page.svelte.d.ts +13 -0
- package/dist/molecules/PhotoGrid.svelte +433 -0
- package/dist/molecules/PhotoGrid.svelte.d.ts +62 -0
- package/dist/molecules/PhotoViewer.svelte +1116 -0
- package/dist/molecules/PhotoViewer.svelte.d.ts +56 -0
- package/dist/molecules/PropsTable.svelte +26 -11
- package/dist/molecules/PropsTable.svelte.d.ts +5 -0
- package/dist/molecules/PullToRefresh.svelte +263 -0
- package/dist/molecules/PullToRefresh.svelte.d.ts +52 -0
- package/dist/molecules/RadioGroup.svelte +57 -15
- package/dist/molecules/RadioGroup.svelte.d.ts +16 -3
- package/dist/molecules/Section.svelte +13 -5
- package/dist/molecules/Section.svelte.d.ts +3 -1
- package/dist/molecules/SegmentedControl.svelte +323 -0
- package/dist/molecules/SegmentedControl.svelte.d.ts +34 -0
- package/dist/molecules/SidebarBrandHeader.svelte +24 -5
- package/dist/molecules/SidebarBrandHeader.svelte.d.ts +5 -0
- package/dist/molecules/SidebarFooter.svelte +39 -8
- package/dist/molecules/SidebarFooter.svelte.d.ts +5 -0
- package/dist/molecules/SidebarNavSection.svelte +12 -4
- package/dist/molecules/SidebarNavSection.svelte.d.ts +2 -0
- package/dist/molecules/SlideUp.svelte +253 -30
- package/dist/molecules/SlideUp.svelte.d.ts +31 -4
- package/dist/molecules/SortableList.svelte +632 -0
- package/dist/molecules/SortableList.svelte.d.ts +69 -0
- package/dist/molecules/Stepper.svelte +548 -0
- package/dist/molecules/Stepper.svelte.d.ts +39 -0
- package/dist/molecules/StickyActionBar.svelte +191 -0
- package/dist/molecules/StickyActionBar.svelte.d.ts +65 -0
- package/dist/molecules/SwipeableListItem.svelte +334 -0
- package/dist/molecules/SwipeableListItem.svelte.d.ts +54 -0
- package/dist/molecules/Tabs.svelte +254 -24
- package/dist/molecules/Tabs.svelte.d.ts +15 -4
- package/dist/molecules/Toaster.svelte +352 -6
- package/dist/molecules/Toaster.svelte.d.ts +95 -2
- package/dist/molecules/ToasterToast.svelte +279 -62
- package/dist/molecules/ToasterToast.svelte.d.ts +11 -0
- package/dist/molecules/UnsavedChangesBar.svelte +212 -0
- package/dist/molecules/UnsavedChangesBar.svelte.d.ts +43 -0
- package/dist/molecules/index.d.ts +46 -0
- package/dist/molecules/index.js +27 -0
- package/dist/molecules/toast-store.d.ts +53 -7
- package/dist/molecules/toast-store.js +21 -0
- package/dist/organisms/AppShell.svelte +196 -0
- package/dist/organisms/AppShell.svelte.d.ts +61 -0
- package/dist/organisms/SidebarAccountPanel.svelte +111 -12
- package/dist/organisms/SidebarAccountPanel.svelte.d.ts +21 -0
- package/dist/organisms/SidebarNavigation.svelte +193 -69
- package/dist/organisms/SidebarNavigation.svelte.d.ts +31 -1
- package/dist/organisms/SidebarPanel.svelte +45 -16
- package/dist/organisms/SidebarPanel.svelte.d.ts +2 -0
- package/dist/organisms/SidebarShell.svelte +263 -0
- package/dist/organisms/SidebarShell.svelte.d.ts +106 -0
- package/dist/organisms/TopNavbar.svelte +329 -33
- package/dist/organisms/TopNavbar.svelte.d.ts +28 -0
- package/dist/organisms/index.d.ts +6 -0
- package/dist/organisms/index.js +4 -0
- package/dist/routes/lib/variant-utils.d.ts +26 -0
- package/dist/routes/lib/{variant-utils.ts → variant-utils.js} +15 -46
- package/dist/types/components.d.ts +4 -0
- package/dist/types/components.d.ts.map +1 -1
- package/dist/types/events.js +1 -0
- package/dist/types/index.d.ts +605 -25
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +3 -0
- package/dist/types/variants.ts +17 -1
- package/dist/util/app-shell.d.ts +27 -0
- package/dist/util/app-shell.js +72 -0
- package/dist/util/avatar.d.ts +35 -0
- package/dist/util/avatar.js +52 -0
- package/dist/util/bottom-sheet.d.ts +29 -0
- package/dist/util/bottom-sheet.js +43 -0
- package/dist/util/bottom-tab-bar.d.ts +34 -0
- package/dist/util/bottom-tab-bar.js +54 -0
- package/dist/util/calendar.d.ts +55 -0
- package/dist/util/calendar.js +74 -0
- package/dist/util/cn.d.ts +7 -0
- package/dist/util/cn.js +48 -0
- package/dist/util/collapsible.d.ts +57 -0
- package/dist/util/collapsible.js +23 -0
- package/dist/util/confirm-dialog.d.ts +11 -0
- package/dist/util/confirm-dialog.js +2 -0
- package/dist/util/date.d.ts +95 -0
- package/dist/util/date.js +237 -0
- package/dist/util/drawer.d.ts +12 -0
- package/dist/util/drawer.js +7 -0
- package/dist/util/dropdown.d.ts +46 -0
- package/dist/util/dropdown.js +21 -0
- package/dist/util/field.d.ts +38 -0
- package/dist/util/field.js +38 -0
- package/dist/util/fit-in-viewport.d.ts +200 -0
- package/dist/util/fit-in-viewport.js +399 -0
- package/dist/util/focus-utils.d.ts +75 -2
- package/dist/util/focus-utils.js +182 -9
- package/dist/util/hydration.d.ts +44 -0
- package/dist/util/hydration.js +58 -0
- package/dist/util/keyboard-inset.d.ts +17 -0
- package/dist/util/keyboard-inset.js +53 -0
- package/dist/util/media-grid.d.ts +50 -0
- package/dist/util/media-grid.js +81 -0
- package/dist/util/media.d.ts +5 -0
- package/dist/util/media.js +10 -0
- package/dist/util/overlay-chrome.d.ts +52 -0
- package/dist/util/overlay-chrome.js +56 -0
- package/dist/util/overlay.d.ts +71 -0
- package/dist/util/overlay.js +240 -0
- package/dist/util/photo.d.ts +214 -0
- package/dist/util/photo.js +206 -0
- package/dist/util/portal.d.ts +22 -0
- package/dist/util/portal.js +50 -0
- package/dist/util/pull-to-refresh.d.ts +26 -0
- package/dist/util/pull-to-refresh.js +30 -0
- package/dist/util/radio-keys.d.ts +24 -0
- package/dist/util/radio-keys.js +49 -0
- package/dist/util/rating.d.ts +22 -0
- package/dist/util/rating.js +26 -0
- package/dist/util/ready-made-strings.d.ts +76 -0
- package/dist/util/ready-made-strings.js +67 -0
- package/dist/util/scroll-padding.d.ts +19 -0
- package/dist/util/scroll-padding.js +44 -0
- package/dist/util/segmented-control.d.ts +15 -0
- package/dist/util/segmented-control.js +1 -0
- package/dist/util/select.d.ts +40 -0
- package/dist/util/select.js +63 -0
- package/dist/util/sheet-drag.d.ts +59 -0
- package/dist/util/sheet-drag.js +241 -0
- package/dist/util/sidebar.d.ts +62 -0
- package/dist/util/sidebar.js +38 -0
- package/dist/util/sortable-list.d.ts +64 -0
- package/dist/util/sortable-list.js +53 -0
- package/dist/util/ssr-safe.d.ts +4 -4
- package/dist/util/stepper.d.ts +39 -0
- package/dist/util/stepper.js +38 -0
- package/dist/util/swipeable-list-item.d.ts +35 -0
- package/dist/util/swipeable-list-item.js +32 -0
- package/dist/util/theme-mode.d.ts +79 -0
- package/dist/util/theme-mode.js +121 -0
- package/dist/util/toaster.d.ts +92 -0
- package/dist/util/toaster.js +75 -0
- package/dist/util/tooltip.d.ts +9 -0
- package/dist/util/tooltip.js +18 -0
- package/dist/util/top-navbar.d.ts +10 -0
- package/dist/util/top-navbar.js +5 -0
- package/dist/util/touch-target.d.ts +30 -0
- package/dist/util/touch-target.js +30 -0
- package/dist/util/zabi-strings.d.ts +132 -0
- package/dist/util/zabi-strings.js +105 -0
- package/dist/zabi-components-colors.css +5 -2
- package/dist/zabi-components-theme-dark-only.css +574 -225
- package/dist/zabi-components-theme-dark.css +574 -225
- package/dist/zabi-components-theme-only.css +1680 -317
- package/dist/zabi-components-theme.css +1680 -317
- package/dist/zabi-components.css +4473 -1158
- package/docs/lucide-icons.md +41 -16
- package/docs/theme-imports.md +81 -11
- package/package.json +51 -29
- package/dist/lib/layout-width-tokens.d.ts +0 -17
- package/dist/lib/layout-width-tokens.d.ts.map +0 -1
- package/dist/lib/showcase/component-docs/Button.d.ts +0 -3
- package/dist/lib/showcase/component-docs/Button.d.ts.map +0 -1
- package/dist/lib/showcase/component-docs/Input.d.ts +0 -3
- package/dist/lib/showcase/component-docs/Input.d.ts.map +0 -1
- package/dist/lib/showcase/component-docs/List.d.ts +0 -3
- package/dist/lib/showcase/component-docs/List.d.ts.map +0 -1
- package/dist/lib/showcase/component-docs/Modal.d.ts +0 -3
- package/dist/lib/showcase/component-docs/Modal.d.ts.map +0 -1
- package/dist/lib/showcase/component-docs/Radio.d.ts +0 -3
- package/dist/lib/showcase/component-docs/Radio.d.ts.map +0 -1
- package/dist/lib/showcase/component-docs/SidebarNavigation.d.ts +0 -3
- package/dist/lib/showcase/component-docs/SidebarNavigation.d.ts.map +0 -1
- package/dist/lib/showcase/component-docs/Skeleton.d.ts +0 -3
- package/dist/lib/showcase/component-docs/Skeleton.d.ts.map +0 -1
- package/dist/lib/showcase/component-docs/_shared.d.ts +0 -12
- package/dist/lib/showcase/component-docs/_shared.d.ts.map +0 -1
- package/dist/lib/showcase/component-docs/index.d.ts +0 -4
- package/dist/lib/showcase/component-docs/index.d.ts.map +0 -1
- package/dist/lib/showcase/components-catalog.d.ts +0 -3
- package/dist/lib/showcase/components-catalog.d.ts.map +0 -1
- package/dist/lib/showcase/components-showcase-constants.d.ts +0 -89
- package/dist/lib/showcase/components-showcase-constants.d.ts.map +0 -1
- package/dist/lib/showcase/docs-sidebar-helpers.d.ts +0 -15
- package/dist/lib/showcase/docs-sidebar-helpers.d.ts.map +0 -1
- package/dist/routes/lib/focus-utils.d.ts +0 -12
- package/dist/routes/lib/focus-utils.ts +0 -110
- package/dist/routes/lib/ssr-safe.ts +0 -58
- package/scripts/fix-lucide-svelte-icon-dts.js +0 -35
|
@@ -1,21 +1,367 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
+
import { mergeStrings } from "../util/ready-made-strings.js";
|
|
3
|
+
import { zabiStringsFor } from "../util/zabi-strings.js";
|
|
2
4
|
import ToasterToast from './ToasterToast.svelte';
|
|
3
5
|
import { toastStore } from './toast-store.js';
|
|
6
|
+
import { cn } from "../util/cn.js";
|
|
7
|
+
import { readKeyboardInset } from "../util/keyboard-inset.js";
|
|
8
|
+
import { topOverlayFooter, topOverlayHeader, watchOverlayFooters } from "../util/overlay.js";
|
|
9
|
+
import {
|
|
10
|
+
DEFAULT_TOASTER_STRINGS,
|
|
11
|
+
type ToastDuration,
|
|
12
|
+
type ToasterStrings,
|
|
13
|
+
type ToastPauseChange,
|
|
14
|
+
} from "../util/toaster.js";
|
|
15
|
+
import type { HTMLAttributes } from "svelte/elements";
|
|
4
16
|
|
|
5
|
-
|
|
17
|
+
/**
|
|
18
|
+
* The stack of toasts, fixed to the bottom of the screen: in the corner
|
|
19
|
+
* from 640px up, across the width with 16px on each side below that.
|
|
20
|
+
*
|
|
21
|
+
* It keeps clear of what is at the bottom of a phone screen. The home
|
|
22
|
+
* indicator and a notch at the side are read from the safe-area insets
|
|
23
|
+
* (the page has to ask for them with `viewport-fit=cover`). Inside an
|
|
24
|
+
* `AppShell` the stack sits above the shell's tab bar, which the shell
|
|
25
|
+
* reports in `--app-shell-bottom-inset`. For anything else fixed to the
|
|
26
|
+
* bottom (a `BottomTabBar` on its own, a `StickyActionBar`, a
|
|
27
|
+
* `FloatingActionButton`), say how tall it is with
|
|
28
|
+
* `--toaster-bottom-offset` on the Toaster or any ancestor:
|
|
29
|
+
*
|
|
30
|
+
* ```svelte
|
|
31
|
+
* <Toaster style="--toaster-bottom-offset: 65px" />
|
|
32
|
+
* ```
|
|
33
|
+
*
|
|
34
|
+
* A `FloatingActionButton` is 56px with 16px under it: `72px` puts the
|
|
35
|
+
* stack above it.
|
|
36
|
+
*
|
|
37
|
+
* That offset is for what is on the page. Over a modal overlay (Modal,
|
|
38
|
+
* BottomSheet, SlideUp, Drawer) the stack minds the overlay instead: it
|
|
39
|
+
* never lies on the header, which holds the close button, nor on a
|
|
40
|
+
* footer pinned to the bottom, and the offset is not added on top. It
|
|
41
|
+
* sits above the panel when there is more room there, and otherwise
|
|
42
|
+
* between the header and the footer. Where the on-screen keyboard covers
|
|
43
|
+
* the page, the stack sits above the keyboard. It is never taller than
|
|
44
|
+
* the room it has: with more toasts than fit, it scrolls. With an
|
|
45
|
+
* overlay open, Tab goes from its last control into the toasts and back,
|
|
46
|
+
* and Escape in a toast returns focus to where it came from.
|
|
47
|
+
*
|
|
48
|
+
* A toast shows what it was pushed with: its `title`, its `message`
|
|
49
|
+
* under it, or the message alone.
|
|
50
|
+
*
|
|
51
|
+
* How long it stays is said in words, per toast (`pushToast({ duration:
|
|
52
|
+
* "short" })`) or for all of them here (`defaultDuration`): `"short"` is
|
|
53
|
+
* 3 seconds, for a few words that need no reading time ("Saved");
|
|
54
|
+
* anything a person has to read is `"medium"` (7 seconds) or `"long"`
|
|
55
|
+
* (14); what they have to act on, and an error, should stay:
|
|
56
|
+
* `"persistent"`. A number is milliseconds. A toast given no duration
|
|
57
|
+
* gets medium up to 120 characters of text, long up to 240, and stays
|
|
58
|
+
* beyond that; an error and a toast with an action stay until they are
|
|
59
|
+
* dismissed.
|
|
60
|
+
*
|
|
61
|
+
* Its timer stops while a mouse is over it, a finger is on it or focus
|
|
62
|
+
* is inside it, which is what lets a timed toast be read in the reader's
|
|
63
|
+
* own time (WCAG 2.2.1). A finger that lifts leaves it at least three
|
|
64
|
+
* seconds, so holding a short toast starts it again.
|
|
65
|
+
* `data-paused` on the toast says so, and `onpausechange` is called.
|
|
66
|
+
* Every word the toaster says by itself is in `strings`:
|
|
67
|
+
*
|
|
68
|
+
* ```svelte
|
|
69
|
+
* <Toaster
|
|
70
|
+
* strings={{
|
|
71
|
+
* regionLabel: "Aviseringar",
|
|
72
|
+
* dismiss: "Stäng aviseringen",
|
|
73
|
+
* closesIn: (seconds) => `Stängs om ${seconds} sekunder.`,
|
|
74
|
+
* }}
|
|
75
|
+
* />
|
|
76
|
+
* ```
|
|
77
|
+
*/
|
|
78
|
+
type Props = Omit<HTMLAttributes<HTMLDivElement>, "class" | "role" | "aria-label"> & {
|
|
79
|
+
/**
|
|
80
|
+
* The words the toaster says by itself, for an app in another
|
|
81
|
+
* language: the region's name, the buttons' names, the sentence about
|
|
82
|
+
* the time left. What is left out keeps its English default.
|
|
83
|
+
*/
|
|
84
|
+
strings?: Partial<ToasterStrings>;
|
|
85
|
+
/** Accessible name of the region. Wins over `strings.regionLabel`. */
|
|
86
|
+
"aria-label"?: string;
|
|
87
|
+
/**
|
|
88
|
+
* Shows the time a toast has left as a sentence under it, with a
|
|
89
|
+
* button that stops the timer. Without it the bar along the bottom of
|
|
90
|
+
* the toast shows the time, and the sentence is there for a screen
|
|
91
|
+
* reader only.
|
|
92
|
+
*/
|
|
93
|
+
showCountdown?: boolean;
|
|
94
|
+
/**
|
|
95
|
+
* How long a toast stays when it was pushed without a `duration`, in
|
|
96
|
+
* place of `"medium"`: `"short"`, `"medium"`, `"long"`,
|
|
97
|
+
* `"persistent"` or milliseconds. An error and a toast with an action
|
|
98
|
+
* still stay until dismissed, a text of 121 to 240 characters still
|
|
99
|
+
* gets at least `"long"`, and a longer one still stays. A `duration`
|
|
100
|
+
* on the toast wins.
|
|
101
|
+
*/
|
|
102
|
+
defaultDuration?: ToastDuration;
|
|
103
|
+
/**
|
|
104
|
+
* Called when a pointer, a finger or focus starts or stops holding a
|
|
105
|
+
* toast's timer, with the toast's id. The same state is `data-paused`
|
|
106
|
+
* on the toast.
|
|
107
|
+
*/
|
|
108
|
+
onpausechange?: (detail: ToastPauseChange) => void;
|
|
6
109
|
class?: string;
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
let {
|
|
113
|
+
strings,
|
|
114
|
+
"aria-label": ariaLabel,
|
|
115
|
+
showCountdown = false,
|
|
116
|
+
defaultDuration,
|
|
117
|
+
onpausechange,
|
|
118
|
+
class: className = '',
|
|
119
|
+
...restProps
|
|
120
|
+
}: Props = $props();
|
|
121
|
+
|
|
122
|
+
/** The app-wide words for the toaster, from the `ZabiStringsProvider` it is mounted under, if there is one. */
|
|
123
|
+
const provided = zabiStringsFor("toaster");
|
|
124
|
+
const words = $derived<ToasterStrings>(mergeStrings(DEFAULT_TOASTER_STRINGS, provided(), strings));
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* One utility per property, so a class from the caller still replaces it
|
|
128
|
+
* at every width; what differs below 640px is carried by the three
|
|
129
|
+
* variables. From 640px up this is what it always was: 1rem from the
|
|
130
|
+
* bottom and the right, 24rem wide, 1rem of padding.
|
|
131
|
+
*/
|
|
132
|
+
const placement = [
|
|
133
|
+
"[--toaster-edge:0px] sm:[--toaster-edge:1rem]",
|
|
134
|
+
"[--toaster-width:100vw] sm:[--toaster-width:24rem]",
|
|
135
|
+
// In px below 640px: a gutter that grew with the text would take the room the text needs.
|
|
136
|
+
"[--toaster-padding:16px] sm:[--toaster-padding:1rem]",
|
|
137
|
+
// `--toaster-overlay-inset` is set below, while a footer of an open overlay is under the stack.
|
|
138
|
+
"bottom-[calc(max(max(var(--app-shell-bottom-inset,0px),env(safe-area-inset-bottom,0px))_+_var(--toaster-bottom-offset,0px),var(--toaster-overlay-inset,0px))_+_var(--toaster-edge))]",
|
|
139
|
+
"right-[calc(env(safe-area-inset-right,0px)_+_var(--toaster-edge))]",
|
|
140
|
+
"w-[min(var(--toaster-width),calc(100vw_-_env(safe-area-inset-left,0px)_-_env(safe-area-inset-right,0px)_-_2_*_var(--toaster-edge)))]",
|
|
141
|
+
"p-(--toaster-padding)",
|
|
142
|
+
].join(" ");
|
|
143
|
+
|
|
144
|
+
let region = $state<HTMLDivElement>();
|
|
145
|
+
|
|
146
|
+
/** The highest the stack may reach: below the status bar or an AppShell's top bar. */
|
|
147
|
+
const TOP = "calc(max(var(--app-shell-top-inset, 0px), env(safe-area-inset-top, 0px)) + var(--toaster-edge))";
|
|
148
|
+
/**
|
|
149
|
+
* Places the stack for what is on screen now. At rest it is where the
|
|
150
|
+
* classes put it, raised above the on-screen keyboard where that covers
|
|
151
|
+
* the page. The header (with its close button) and the pinned footer of
|
|
152
|
+
* the overlay on top are never covered: when the stack would lie on
|
|
153
|
+
* either, it takes the larger of the two free stretches, above the panel
|
|
154
|
+
* or between its header and its footer. Where it would be taller than
|
|
155
|
+
* the room it has, it gets that height and scrolls, with the newest toast
|
|
156
|
+
* in view.
|
|
157
|
+
* Written straight to the element: it is measured between the steps, in
|
|
158
|
+
* one go, before anything is painted.
|
|
159
|
+
*/
|
|
160
|
+
function layout(): void {
|
|
161
|
+
const stack = region;
|
|
162
|
+
if (!stack) return;
|
|
163
|
+
// Taking the height off puts a stack that scrolls back at its start.
|
|
164
|
+
const scrolledTo = stack.style.overflowY === "auto" ? stack.scrollTop : null;
|
|
165
|
+
stack.style.removeProperty("--toaster-overlay-inset");
|
|
166
|
+
stack.style.top = "";
|
|
167
|
+
stack.style.bottom = "";
|
|
168
|
+
stack.style.maxHeight = "";
|
|
169
|
+
stack.style.overflowY = "";
|
|
170
|
+
stack.style.paddingBlock = "";
|
|
171
|
+
if (stack.childElementCount === 0) return;
|
|
172
|
+
|
|
173
|
+
const viewportHeight = document.documentElement.clientHeight;
|
|
174
|
+
// Nothing where the page shrinks by itself: the classes already end above the keyboard there.
|
|
175
|
+
const keyboard = readKeyboardInset();
|
|
176
|
+
const raise = (px: number) => stack.style.setProperty("--toaster-overlay-inset", `${px}px`);
|
|
177
|
+
if (keyboard > 0) raise(keyboard);
|
|
178
|
+
const rest = stack.getBoundingClientRect();
|
|
179
|
+
// No layout (a test DOM): nothing to place.
|
|
180
|
+
if (rest.width === 0 && rest.height === 0) return;
|
|
181
|
+
|
|
182
|
+
stack.style.top = TOP;
|
|
183
|
+
stack.style.bottom = "auto";
|
|
184
|
+
const topLimit = stack.getBoundingClientRect().top;
|
|
185
|
+
stack.style.top = "";
|
|
186
|
+
stack.style.bottom = "";
|
|
187
|
+
|
|
188
|
+
// Only what is in the same columns as the stack can be under it.
|
|
189
|
+
const beside = (part: HTMLElement | null) => {
|
|
190
|
+
const box = part?.getBoundingClientRect();
|
|
191
|
+
return box && box.height > 0 && box.left < rest.right && box.right > rest.left ? box : null;
|
|
192
|
+
};
|
|
193
|
+
const header = beside(topOverlayHeader());
|
|
194
|
+
const footer = beside(topOverlayFooter());
|
|
195
|
+
const under = (box: DOMRect | null) => !!box && box.top < rest.bottom && box.bottom > rest.top;
|
|
196
|
+
|
|
197
|
+
let ceiling = topLimit;
|
|
198
|
+
let bottomEdge = rest.bottom;
|
|
199
|
+
if (under(header) || under(footer)) {
|
|
200
|
+
// Between the header and the footer (or the stack's own resting edge)...
|
|
201
|
+
const insideTop = header ? Math.max(topLimit, header.bottom) : topLimit;
|
|
202
|
+
const insideBottom = footer && footer.top > insideTop ? footer.top : rest.bottom;
|
|
203
|
+
// ...or above the panel, over the backdrop.
|
|
204
|
+
const aboveBottom = header ? header.top : topLimit;
|
|
205
|
+
const above = aboveBottom - topLimit > insideBottom - insideTop;
|
|
206
|
+
ceiling = above ? topLimit : insideTop;
|
|
207
|
+
const floor = above ? aboveBottom : insideBottom;
|
|
208
|
+
if (floor < rest.bottom) raise(Math.max(keyboard, Math.ceil(viewportHeight - floor)));
|
|
209
|
+
bottomEdge = stack.getBoundingClientRect().bottom;
|
|
210
|
+
} else if (header && header.bottom <= rest.top) {
|
|
211
|
+
// Clear of it now; it does not grow over it either.
|
|
212
|
+
ceiling = Math.max(topLimit, header.bottom);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
const room = Math.max(0, Math.floor(bottomEdge - ceiling));
|
|
216
|
+
if (stack.scrollHeight > room + 1) {
|
|
217
|
+
stack.style.maxHeight = `${room}px`;
|
|
218
|
+
stack.style.overflowY = "auto";
|
|
219
|
+
// A box is never shorter than its own padding. In a slit between
|
|
220
|
+
// a header and a footer (a small dialog over a keyboard, on a
|
|
221
|
+
// phone held sideways) the padding goes, or the stack would reach
|
|
222
|
+
// over the header after all.
|
|
223
|
+
const padding = parseFloat(getComputedStyle(stack).paddingTop) || 0;
|
|
224
|
+
if (room < 2 * padding + 44) stack.style.paddingBlock = "0px";
|
|
225
|
+
// Where it was, or at its end when it has only now begun to scroll:
|
|
226
|
+
// the newest toast is the last one.
|
|
227
|
+
stack.scrollTop = scrolledTo ?? stack.scrollHeight;
|
|
228
|
+
}
|
|
7
229
|
}
|
|
8
230
|
|
|
9
|
-
|
|
231
|
+
/** How many toasts were shown at the last layout: a new one is scrolled to. */
|
|
232
|
+
let shownCount = 0;
|
|
233
|
+
|
|
234
|
+
$effect(() => {
|
|
235
|
+
const count = $toastStore.length;
|
|
236
|
+
layout();
|
|
237
|
+
const stack = region;
|
|
238
|
+
// The newest is at the end: in a stack that scrolls, that is what to show.
|
|
239
|
+
if (stack && count > shownCount && stack.style.overflowY === "auto") {
|
|
240
|
+
stack.scrollTop = stack.scrollHeight;
|
|
241
|
+
}
|
|
242
|
+
shownCount = count;
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
$effect(() => {
|
|
246
|
+
const stack = region;
|
|
247
|
+
if (!stack) return;
|
|
248
|
+
const again = () => layout();
|
|
249
|
+
const stopFooters = watchOverlayFooters(again);
|
|
250
|
+
const observer = typeof ResizeObserver === "function" ? new ResizeObserver(again) : undefined;
|
|
251
|
+
observer?.observe(stack);
|
|
252
|
+
// Its children too: a toast that opens its details makes the stack taller inside a fixed height.
|
|
253
|
+
const children = new MutationObserver(() => {
|
|
254
|
+
observer?.disconnect();
|
|
255
|
+
observer?.observe(stack);
|
|
256
|
+
for (const child of stack.children) observer?.observe(child);
|
|
257
|
+
});
|
|
258
|
+
children.observe(stack, { childList: true });
|
|
259
|
+
window.addEventListener("resize", again);
|
|
260
|
+
window.visualViewport?.addEventListener("resize", again);
|
|
261
|
+
window.visualViewport?.addEventListener("scroll", again);
|
|
262
|
+
return () => {
|
|
263
|
+
window.visualViewport?.removeEventListener("scroll", again);
|
|
264
|
+
stopFooters();
|
|
265
|
+
observer?.disconnect();
|
|
266
|
+
children.disconnect();
|
|
267
|
+
window.removeEventListener("resize", again);
|
|
268
|
+
window.visualViewport?.removeEventListener("resize", again);
|
|
269
|
+
};
|
|
270
|
+
});
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* Escape in a toast gives focus back to where it came from (a control in
|
|
274
|
+
* the page, or in the modal that is open), and nothing else: the toast
|
|
275
|
+
* stays, and the modal under it does not take the key as its own.
|
|
276
|
+
*/
|
|
277
|
+
function handleKeydown(event: KeyboardEvent) {
|
|
278
|
+
if (event.key !== "Escape" || event.defaultPrevented) return;
|
|
279
|
+
const back = returnTarget();
|
|
280
|
+
if (!back) return;
|
|
281
|
+
event.preventDefault();
|
|
282
|
+
back.focus();
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
/** What had focus before it entered the region; where it goes back to. */
|
|
286
|
+
let cameFrom: HTMLElement | null = null;
|
|
287
|
+
|
|
288
|
+
/**
|
|
289
|
+
* Where focus goes back to, if that is still a place for it. A control of
|
|
290
|
+
* the page that focus came from before a modal overlay opened is behind
|
|
291
|
+
* that overlay now: focus is not sent there, out of the overlay's trap.
|
|
292
|
+
*/
|
|
293
|
+
function returnTarget(): HTMLElement | null {
|
|
294
|
+
if (!cameFrom?.isConnected) return null;
|
|
295
|
+
const modal = '[aria-modal="true"]';
|
|
296
|
+
if (document.querySelector(modal) && !cameFrom.closest(modal)) return null;
|
|
297
|
+
return cameFrom;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
function handleFocusIn(event: FocusEvent) {
|
|
301
|
+
const from = event.relatedTarget;
|
|
302
|
+
if (from instanceof HTMLElement && !region?.contains(from)) cameFrom = from;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
/**
|
|
306
|
+
* Dismissing the toast that holds focus (its action, or Dismiss) removes
|
|
307
|
+
* the focused control, and the browser would drop focus on `<body>`. It
|
|
308
|
+
* goes to the neighbouring toast instead, or back to where it came from.
|
|
309
|
+
* Which toast held focus has to be read before the list is re-rendered.
|
|
310
|
+
*/
|
|
311
|
+
let shownIds: string[] = [];
|
|
312
|
+
let focusAfterDismiss: { neighbours: string[] } | null = null;
|
|
313
|
+
|
|
314
|
+
$effect.pre(() => {
|
|
315
|
+
const ids = $toastStore.map((toast) => toast.id);
|
|
316
|
+
const holder = region
|
|
317
|
+
? (document.activeElement?.closest<HTMLElement>('[data-toast-id]') ?? null)
|
|
318
|
+
: null;
|
|
319
|
+
const held = holder && region?.contains(holder) ? holder.dataset.toastId : undefined;
|
|
320
|
+
if (held !== undefined && !ids.includes(held)) {
|
|
321
|
+
const at = shownIds.indexOf(held);
|
|
322
|
+
// The next toast first, then the ones before it, nearest first.
|
|
323
|
+
focusAfterDismiss = {
|
|
324
|
+
neighbours: [...shownIds.slice(at + 1), ...shownIds.slice(0, at).reverse()],
|
|
325
|
+
};
|
|
326
|
+
}
|
|
327
|
+
shownIds = ids;
|
|
328
|
+
});
|
|
329
|
+
|
|
330
|
+
$effect(() => {
|
|
331
|
+
void $toastStore;
|
|
332
|
+
const pending = focusAfterDismiss;
|
|
333
|
+
focusAfterDismiss = null;
|
|
334
|
+
if (!pending || !region) return;
|
|
335
|
+
// Something else took focus in the meantime (the action opened a dialog): leave it.
|
|
336
|
+
const active = document.activeElement;
|
|
337
|
+
if (active && active !== document.body && !region.contains(active)) return;
|
|
338
|
+
|
|
339
|
+
const toasts = [...region.querySelectorAll<HTMLElement>('[data-toast-id]')];
|
|
340
|
+
for (const id of pending.neighbours) {
|
|
341
|
+
const next = toasts
|
|
342
|
+
.find((toast) => toast.dataset.toastId === id)
|
|
343
|
+
?.querySelector<HTMLElement>('button');
|
|
344
|
+
if (next) {
|
|
345
|
+
next.focus();
|
|
346
|
+
return;
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
returnTarget()?.focus();
|
|
350
|
+
});
|
|
10
351
|
</script>
|
|
11
352
|
|
|
12
353
|
<div
|
|
13
|
-
|
|
354
|
+
{...restProps}
|
|
355
|
+
class={cn("pointer-events-none fixed z-toast flex min-w-0 flex-col gap-2 overscroll-contain", placement, className)}
|
|
14
356
|
role="region"
|
|
15
|
-
aria-label=
|
|
16
|
-
|
|
357
|
+
aria-label={ariaLabel ?? words.regionLabel}
|
|
358
|
+
data-zabi-toaster
|
|
359
|
+
bind:this={region}
|
|
360
|
+
onfocusin={handleFocusIn}
|
|
361
|
+
onkeydown={handleKeydown}
|
|
17
362
|
>
|
|
363
|
+
<!-- Each toast owns its role="status"/"alert"; a region-level aria-live would announce twice. -->
|
|
18
364
|
{#each $toastStore as toast (toast.id)}
|
|
19
|
-
<ToasterToast {toast} />
|
|
365
|
+
<ToasterToast {toast} strings={words} {showCountdown} {defaultDuration} {onpausechange} />
|
|
20
366
|
{/each}
|
|
21
367
|
</div>
|
|
@@ -1,6 +1,99 @@
|
|
|
1
|
-
|
|
1
|
+
import { type ToastDuration, type ToasterStrings, type ToastPauseChange } from "../util/toaster.js";
|
|
2
|
+
import type { HTMLAttributes } from "svelte/elements";
|
|
3
|
+
/**
|
|
4
|
+
* The stack of toasts, fixed to the bottom of the screen: in the corner
|
|
5
|
+
* from 640px up, across the width with 16px on each side below that.
|
|
6
|
+
*
|
|
7
|
+
* It keeps clear of what is at the bottom of a phone screen. The home
|
|
8
|
+
* indicator and a notch at the side are read from the safe-area insets
|
|
9
|
+
* (the page has to ask for them with `viewport-fit=cover`). Inside an
|
|
10
|
+
* `AppShell` the stack sits above the shell's tab bar, which the shell
|
|
11
|
+
* reports in `--app-shell-bottom-inset`. For anything else fixed to the
|
|
12
|
+
* bottom (a `BottomTabBar` on its own, a `StickyActionBar`, a
|
|
13
|
+
* `FloatingActionButton`), say how tall it is with
|
|
14
|
+
* `--toaster-bottom-offset` on the Toaster or any ancestor:
|
|
15
|
+
*
|
|
16
|
+
* ```svelte
|
|
17
|
+
* <Toaster style="--toaster-bottom-offset: 65px" />
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* A `FloatingActionButton` is 56px with 16px under it: `72px` puts the
|
|
21
|
+
* stack above it.
|
|
22
|
+
*
|
|
23
|
+
* That offset is for what is on the page. Over a modal overlay (Modal,
|
|
24
|
+
* BottomSheet, SlideUp, Drawer) the stack minds the overlay instead: it
|
|
25
|
+
* never lies on the header, which holds the close button, nor on a
|
|
26
|
+
* footer pinned to the bottom, and the offset is not added on top. It
|
|
27
|
+
* sits above the panel when there is more room there, and otherwise
|
|
28
|
+
* between the header and the footer. Where the on-screen keyboard covers
|
|
29
|
+
* the page, the stack sits above the keyboard. It is never taller than
|
|
30
|
+
* the room it has: with more toasts than fit, it scrolls. With an
|
|
31
|
+
* overlay open, Tab goes from its last control into the toasts and back,
|
|
32
|
+
* and Escape in a toast returns focus to where it came from.
|
|
33
|
+
*
|
|
34
|
+
* A toast shows what it was pushed with: its `title`, its `message`
|
|
35
|
+
* under it, or the message alone.
|
|
36
|
+
*
|
|
37
|
+
* How long it stays is said in words, per toast (`pushToast({ duration:
|
|
38
|
+
* "short" })`) or for all of them here (`defaultDuration`): `"short"` is
|
|
39
|
+
* 3 seconds, for a few words that need no reading time ("Saved");
|
|
40
|
+
* anything a person has to read is `"medium"` (7 seconds) or `"long"`
|
|
41
|
+
* (14); what they have to act on, and an error, should stay:
|
|
42
|
+
* `"persistent"`. A number is milliseconds. A toast given no duration
|
|
43
|
+
* gets medium up to 120 characters of text, long up to 240, and stays
|
|
44
|
+
* beyond that; an error and a toast with an action stay until they are
|
|
45
|
+
* dismissed.
|
|
46
|
+
*
|
|
47
|
+
* Its timer stops while a mouse is over it, a finger is on it or focus
|
|
48
|
+
* is inside it, which is what lets a timed toast be read in the reader's
|
|
49
|
+
* own time (WCAG 2.2.1). A finger that lifts leaves it at least three
|
|
50
|
+
* seconds, so holding a short toast starts it again.
|
|
51
|
+
* `data-paused` on the toast says so, and `onpausechange` is called.
|
|
52
|
+
* Every word the toaster says by itself is in `strings`:
|
|
53
|
+
*
|
|
54
|
+
* ```svelte
|
|
55
|
+
* <Toaster
|
|
56
|
+
* strings={{
|
|
57
|
+
* regionLabel: "Aviseringar",
|
|
58
|
+
* dismiss: "Stäng aviseringen",
|
|
59
|
+
* closesIn: (seconds) => `Stängs om ${seconds} sekunder.`,
|
|
60
|
+
* }}
|
|
61
|
+
* />
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
64
|
+
type Props = Omit<HTMLAttributes<HTMLDivElement>, "class" | "role" | "aria-label"> & {
|
|
65
|
+
/**
|
|
66
|
+
* The words the toaster says by itself, for an app in another
|
|
67
|
+
* language: the region's name, the buttons' names, the sentence about
|
|
68
|
+
* the time left. What is left out keeps its English default.
|
|
69
|
+
*/
|
|
70
|
+
strings?: Partial<ToasterStrings>;
|
|
71
|
+
/** Accessible name of the region. Wins over `strings.regionLabel`. */
|
|
72
|
+
"aria-label"?: string;
|
|
73
|
+
/**
|
|
74
|
+
* Shows the time a toast has left as a sentence under it, with a
|
|
75
|
+
* button that stops the timer. Without it the bar along the bottom of
|
|
76
|
+
* the toast shows the time, and the sentence is there for a screen
|
|
77
|
+
* reader only.
|
|
78
|
+
*/
|
|
79
|
+
showCountdown?: boolean;
|
|
80
|
+
/**
|
|
81
|
+
* How long a toast stays when it was pushed without a `duration`, in
|
|
82
|
+
* place of `"medium"`: `"short"`, `"medium"`, `"long"`,
|
|
83
|
+
* `"persistent"` or milliseconds. An error and a toast with an action
|
|
84
|
+
* still stay until dismissed, a text of 121 to 240 characters still
|
|
85
|
+
* gets at least `"long"`, and a longer one still stays. A `duration`
|
|
86
|
+
* on the toast wins.
|
|
87
|
+
*/
|
|
88
|
+
defaultDuration?: ToastDuration;
|
|
89
|
+
/**
|
|
90
|
+
* Called when a pointer, a finger or focus starts or stops holding a
|
|
91
|
+
* toast's timer, with the toast's id. The same state is `data-paused`
|
|
92
|
+
* on the toast.
|
|
93
|
+
*/
|
|
94
|
+
onpausechange?: (detail: ToastPauseChange) => void;
|
|
2
95
|
class?: string;
|
|
3
|
-
}
|
|
96
|
+
};
|
|
4
97
|
declare const Toaster: import("svelte").Component<Props, {}, "">;
|
|
5
98
|
type Toaster = ReturnType<typeof Toaster>;
|
|
6
99
|
export default Toaster;
|