zabi-components 8.0.0 → 9.0.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 +2935 -0
- package/README.md +243 -10
- package/THEME.md +162 -332
- package/THEMING.md +1419 -259
- package/dist/atoms/ActionPanel.svelte +15 -5
- package/dist/atoms/Avatar.svelte +120 -0
- package/dist/atoms/Avatar.svelte.d.ts +46 -0
- package/dist/atoms/Badge.svelte +71 -13
- package/dist/atoms/Badge.svelte.d.ts +8 -2
- package/dist/atoms/Block.svelte +74 -0
- package/dist/atoms/Block.svelte.d.ts +29 -0
- package/dist/atoms/Button.svelte +217 -30
- package/dist/atoms/Button.svelte.d.ts +33 -4
- package/dist/atoms/Card.svelte +182 -26
- package/dist/atoms/Card.svelte.d.ts +55 -3
- package/dist/atoms/CardHeader.svelte +16 -4
- package/dist/atoms/Checkbox.svelte +81 -21
- package/dist/atoms/Checkbox.svelte.d.ts +31 -2
- package/dist/atoms/Chip.svelte +351 -0
- package/dist/atoms/Chip.svelte.d.ts +57 -0
- package/dist/atoms/CodeBlock.svelte +20 -2
- package/dist/atoms/CodeBlock.svelte.d.ts +4 -0
- package/dist/atoms/CodeField.svelte +385 -0
- package/dist/atoms/CodeField.svelte.d.ts +61 -0
- package/dist/atoms/ColorPicker.svelte +260 -49
- package/dist/atoms/ColorPicker.svelte.d.ts +3 -0
- package/dist/atoms/Container.svelte +16 -8
- package/dist/atoms/DateField.svelte +145 -0
- package/dist/atoms/DateField.svelte.d.ts +81 -0
- package/dist/atoms/FieldMessages.svelte +69 -0
- package/dist/atoms/FieldMessages.svelte.d.ts +23 -0
- package/dist/atoms/FloatingActionButton.svelte +176 -0
- package/dist/atoms/FloatingActionButton.svelte.d.ts +51 -0
- package/dist/atoms/Heading.svelte +63 -5
- package/dist/atoms/Heading.svelte.d.ts +14 -0
- package/dist/atoms/IconButton.svelte +294 -26
- package/dist/atoms/IconButton.svelte.d.ts +62 -4
- package/dist/atoms/Input.svelte +259 -53
- package/dist/atoms/Input.svelte.d.ts +33 -2
- package/dist/atoms/List.svelte +5 -1
- package/dist/atoms/ListItem.svelte +70 -13
- package/dist/atoms/ListItem.svelte.d.ts +11 -0
- package/dist/atoms/PickerField.svelte +239 -0
- package/dist/atoms/PickerField.svelte.d.ts +67 -0
- package/dist/atoms/Progress.svelte +99 -19
- package/dist/atoms/Progress.svelte.d.ts +15 -1
- package/dist/atoms/Radio.svelte +51 -3
- package/dist/atoms/Radio.svelte.d.ts +30 -2
- package/dist/atoms/Rating.svelte +620 -0
- package/dist/atoms/Rating.svelte.d.ts +77 -0
- package/dist/atoms/Select.svelte +438 -98
- package/dist/atoms/Select.svelte.d.ts +61 -3
- package/dist/atoms/SelectionControl.svelte +193 -23
- package/dist/atoms/SelectionControl.svelte.d.ts +29 -3
- package/dist/atoms/Skeleton.svelte +114 -18
- package/dist/atoms/Skeleton.svelte.d.ts +30 -3
- package/dist/atoms/SkeletonGroup.svelte +43 -0
- package/dist/atoms/SkeletonGroup.svelte.d.ts +20 -0
- package/dist/atoms/Slider.svelte +344 -0
- package/dist/atoms/Slider.svelte.d.ts +40 -0
- package/dist/atoms/Sparkline.svelte +109 -0
- package/dist/atoms/Sparkline.svelte.d.ts +27 -0
- package/dist/atoms/SpeechBubble.svelte +187 -0
- package/dist/atoms/SpeechBubble.svelte.d.ts +33 -0
- package/dist/atoms/Spinner.svelte +57 -0
- package/dist/atoms/Spinner.svelte.d.ts +19 -0
- package/dist/atoms/Stat.svelte +72 -0
- package/dist/atoms/Stat.svelte.d.ts +19 -0
- package/dist/atoms/Table.svelte +151 -6
- package/dist/atoms/Table.svelte.d.ts +15 -3
- package/dist/atoms/TemporalField.svelte +472 -0
- package/dist/atoms/TemporalField.svelte.d.ts +48 -0
- package/dist/atoms/Text.svelte +23 -11
- package/dist/atoms/Text.svelte.d.ts +6 -3
- package/dist/atoms/Textarea.svelte +150 -44
- package/dist/atoms/Textarea.svelte.d.ts +35 -2
- package/dist/atoms/ThemeToggle.svelte +223 -44
- package/dist/atoms/ThemeToggle.svelte.d.ts +26 -3
- package/dist/atoms/TimeColumn.svelte +150 -0
- package/dist/atoms/TimeColumn.svelte.d.ts +25 -0
- package/dist/atoms/TimeField.svelte +151 -0
- package/dist/atoms/TimeField.svelte.d.ts +85 -0
- package/dist/atoms/Toast.svelte +22 -8
- package/dist/atoms/Toast.svelte.d.ts +2 -0
- package/dist/atoms/Toggle.svelte +98 -14
- package/dist/atoms/Toggle.svelte.d.ts +26 -2
- package/dist/atoms/Tooltip.svelte +528 -24
- package/dist/atoms/Tooltip.svelte.d.ts +18 -0
- package/dist/atoms/ZabiStringsProvider.svelte +45 -0
- package/dist/atoms/ZabiStringsProvider.svelte.d.ts +27 -0
- package/dist/atoms/index.d.ts +38 -0
- package/dist/atoms/index.js +29 -0
- package/dist/atoms/selection-control.styles.d.ts +47 -5
- package/dist/atoms/selection-control.styles.js +52 -10
- package/dist/components/atoms/index.d.ts +38 -0
- package/dist/components/atoms/index.d.ts.map +1 -1
- package/dist/components/atoms/selection-control.styles.d.ts +47 -5
- package/dist/components/atoms/selection-control.styles.d.ts.map +1 -1
- package/dist/components/index.d.ts +104 -2
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/map.d.ts +11 -0
- package/dist/components/map.d.ts.map +1 -0
- package/dist/components/molecules/index.d.ts +51 -0
- package/dist/components/molecules/index.d.ts.map +1 -1
- package/dist/components/molecules/toast-store.d.ts +83 -7
- package/dist/components/molecules/toast-store.d.ts.map +1 -1
- package/dist/components/organisms/index.d.ts +10 -0
- package/dist/components/organisms/index.d.ts.map +1 -1
- package/dist/components/types/variants.d.ts +24 -1
- package/dist/components/types/variants.d.ts.map +1 -1
- package/dist/components/util/app-shell.d.ts +79 -0
- package/dist/components/util/app-shell.d.ts.map +1 -0
- package/dist/components/util/avatar.d.ts +39 -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 +41 -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/chart.d.ts +140 -0
- package/dist/components/util/chart.d.ts.map +1 -0
- package/dist/components/util/chip.d.ts +66 -0
- package/dist/components/util/chip.d.ts.map +1 -0
- package/dist/components/util/cn.d.ts.map +1 -1
- package/dist/components/util/code-field.d.ts +63 -0
- package/dist/components/util/code-field.d.ts.map +1 -0
- package/dist/components/util/collapsible.d.ts +64 -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/display-voice.d.ts +10 -0
- package/dist/components/util/display-voice.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-control.d.ts +30 -0
- package/dist/components/util/field-control.d.ts.map +1 -0
- package/dist/components/util/field.d.ts +45 -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 +77 -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/map-view.d.ts +144 -0
- package/dist/components/util/map-view.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 +234 -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/progress.d.ts +19 -0
- package/dist/components/util/progress.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-edge.d.ts +33 -0
- package/dist/components/util/scroll-edge.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 +84 -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/skeleton.d.ts +15 -0
- package/dist/components/util/skeleton.d.ts.map +1 -0
- package/dist/components/util/sliding-indicator.d.ts +25 -0
- package/dist/components/util/sliding-indicator.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/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/temporal-field.d.ts +89 -0
- package/dist/components/util/temporal-field.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 +133 -0
- package/dist/components/util/toaster.d.ts.map +1 -0
- package/dist/components/util/tone-surface.d.ts +34 -0
- package/dist/components/util/tone-surface.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 +35 -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 +142 -0
- package/dist/components/util/zabi-strings.d.ts.map +1 -0
- package/dist/create-theme/cli.js +173 -0
- package/dist/create-theme/index.d.ts +190 -0
- package/dist/create-theme/index.js +1034 -0
- package/dist/create-theme/lib/ramp-math.js +128 -0
- package/dist/create-theme/lib/resolve.js +238 -0
- package/dist/create-theme/theme-data.js +2644 -0
- package/dist/index.d.ts +104 -2
- package/dist/index.js +75 -2
- package/dist/map.d.ts +10 -0
- package/dist/map.js +9 -0
- package/dist/molecules/Alert.svelte +63 -16
- package/dist/molecules/Alert.svelte.d.ts +14 -1
- package/dist/molecules/AppBar.svelte +674 -0
- package/dist/molecules/AppBar.svelte.d.ts +131 -0
- package/dist/molecules/AvatarGroup.svelte +116 -0
- package/dist/molecules/AvatarGroup.svelte.d.ts +40 -0
- package/dist/molecules/BarChart.svelte +381 -0
- package/dist/molecules/BarChart.svelte.d.ts +45 -0
- package/dist/molecules/BottomSheet.svelte +608 -0
- package/dist/molecules/BottomSheet.svelte.d.ts +109 -0
- package/dist/molecules/BottomTabBar.svelte +403 -0
- package/dist/molecules/BottomTabBar.svelte.d.ts +98 -0
- package/dist/molecules/Calendar.svelte +597 -0
- package/dist/molecules/Calendar.svelte.d.ts +72 -0
- package/dist/molecules/ChipGroup.svelte +325 -0
- package/dist/molecules/ChipGroup.svelte.d.ts +41 -0
- package/dist/molecules/Collapsible.svelte +347 -0
- package/dist/molecules/Collapsible.svelte.d.ts +61 -0
- package/dist/molecules/CollapsibleGroup.svelte +136 -0
- package/dist/molecules/CollapsibleGroup.svelte.d.ts +14 -0
- package/dist/molecules/ComponentDemo.svelte +16 -4
- package/dist/molecules/ComponentDemo.svelte.d.ts +3 -0
- package/dist/molecules/ConfirmDialog.svelte +257 -0
- package/dist/molecules/ConfirmDialog.svelte.d.ts +58 -0
- package/dist/molecules/ContactForm.svelte +34 -17
- package/dist/molecules/ContactForm.svelte.d.ts +8 -0
- package/dist/molecules/Drawer.svelte +415 -0
- package/dist/molecules/Drawer.svelte.d.ts +55 -0
- package/dist/molecules/Dropdown.svelte +517 -48
- package/dist/molecules/Dropdown.svelte.d.ts +47 -6
- package/dist/molecules/DropdownItem.svelte +122 -0
- package/dist/molecules/DropdownItem.svelte.d.ts +28 -0
- package/dist/molecules/EmptyState.svelte +55 -10
- package/dist/molecules/EmptyState.svelte.d.ts +8 -0
- package/dist/molecules/FormField.svelte +9 -1
- package/dist/molecules/FormField.svelte.d.ts +2 -0
- package/dist/molecules/Header.svelte +1 -1
- package/dist/molecules/ImageUpload.svelte +492 -69
- package/dist/molecules/ImageUpload.svelte.d.ts +82 -2
- package/dist/molecules/LineChart.svelte +459 -0
- package/dist/molecules/LineChart.svelte.d.ts +53 -0
- package/dist/molecules/MapView.svelte +565 -0
- package/dist/molecules/MapView.svelte.d.ts +88 -0
- package/dist/molecules/MediaGrid.svelte +527 -0
- package/dist/molecules/MediaGrid.svelte.d.ts +77 -0
- package/dist/molecules/Modal.svelte +293 -72
- package/dist/molecules/Modal.svelte.d.ts +51 -2
- package/dist/molecules/NavigationMenuContent.svelte +58 -1
- package/dist/molecules/NavigationMenuItem.svelte +0 -1
- package/dist/molecules/NavigationMenuLink.svelte +1 -1
- package/dist/molecules/NavigationMenuList.svelte +10 -3
- package/dist/molecules/NavigationMenuTrigger.svelte +2 -2
- package/dist/molecules/Page.svelte +32 -2
- package/dist/molecules/Page.svelte.d.ts +11 -0
- package/dist/molecules/PhotoGrid.svelte +523 -0
- package/dist/molecules/PhotoGrid.svelte.d.ts +73 -0
- package/dist/molecules/PhotoViewer.svelte +1213 -0
- package/dist/molecules/PhotoViewer.svelte.d.ts +74 -0
- package/dist/molecules/PieChart.svelte +421 -0
- package/dist/molecules/PieChart.svelte.d.ts +51 -0
- package/dist/molecules/PropsTable.svelte +22 -10
- package/dist/molecules/PropsTable.svelte.d.ts +3 -0
- package/dist/molecules/PullToRefresh.svelte +263 -0
- package/dist/molecules/PullToRefresh.svelte.d.ts +52 -0
- package/dist/molecules/RadioGroup.svelte +72 -18
- package/dist/molecules/RadioGroup.svelte.d.ts +19 -3
- package/dist/molecules/Section.svelte +1 -1
- package/dist/molecules/SegmentedControl.svelte +456 -0
- package/dist/molecules/SegmentedControl.svelte.d.ts +40 -0
- package/dist/molecules/SidebarBrandHeader.svelte +11 -1
- package/dist/molecules/SidebarBrandHeader.svelte.d.ts +3 -0
- package/dist/molecules/SidebarFooter.svelte +30 -7
- package/dist/molecules/SidebarFooter.svelte.d.ts +3 -0
- package/dist/molecules/SidebarNavSection.svelte +1 -1
- package/dist/molecules/SlideUp.svelte +220 -61
- package/dist/molecules/SlideUp.svelte.d.ts +26 -0
- package/dist/molecules/SortableList.svelte +633 -0
- package/dist/molecules/SortableList.svelte.d.ts +69 -0
- package/dist/molecules/Stepper.svelte +562 -0
- package/dist/molecules/Stepper.svelte.d.ts +39 -0
- package/dist/molecules/StickyActionBar.svelte +250 -0
- package/dist/molecules/StickyActionBar.svelte.d.ts +78 -0
- package/dist/molecules/SwipeableListItem.svelte +334 -0
- package/dist/molecules/SwipeableListItem.svelte.d.ts +54 -0
- package/dist/molecules/Tabs.svelte +310 -9
- package/dist/molecules/Tabs.svelte.d.ts +7 -0
- package/dist/molecules/Toaster.svelte +514 -5
- package/dist/molecules/Toaster.svelte.d.ts +153 -2
- package/dist/molecules/ToasterToast.svelte +495 -77
- package/dist/molecules/ToasterToast.svelte.d.ts +15 -0
- package/dist/molecules/UnsavedChangesBar.svelte +223 -0
- package/dist/molecules/UnsavedChangesBar.svelte.d.ts +43 -0
- package/dist/molecules/index.d.ts +51 -0
- package/dist/molecules/index.js +31 -0
- package/dist/molecules/toast-store.d.ts +83 -7
- package/dist/molecules/toast-store.js +25 -1
- package/dist/organisms/AppNavigation.svelte +440 -0
- package/dist/organisms/AppNavigation.svelte.d.ts +72 -0
- package/dist/organisms/AppShell.svelte +696 -0
- package/dist/organisms/AppShell.svelte.d.ts +157 -0
- package/dist/organisms/AppShellHeaderPart.svelte +163 -0
- package/dist/organisms/AppShellHeaderPart.svelte.d.ts +57 -0
- package/dist/organisms/SidebarAccountPanel.svelte +107 -12
- package/dist/organisms/SidebarAccountPanel.svelte.d.ts +19 -0
- package/dist/organisms/SidebarNavigation.svelte +111 -43
- package/dist/organisms/SidebarNavigation.svelte.d.ts +29 -1
- package/dist/organisms/SidebarPanel.svelte +34 -17
- package/dist/organisms/SidebarPanel.svelte.d.ts +1 -0
- package/dist/organisms/SidebarShell.svelte +164 -14
- package/dist/organisms/SidebarShell.svelte.d.ts +56 -2
- package/dist/organisms/TopNavbar.svelte +353 -39
- package/dist/organisms/TopNavbar.svelte.d.ts +47 -0
- package/dist/organisms/TopNavbarSheetContent.svelte +145 -0
- package/dist/organisms/TopNavbarSheetContent.svelte.d.ts +24 -0
- package/dist/organisms/index.d.ts +10 -0
- package/dist/organisms/index.js +7 -0
- package/dist/types/components.d.ts +21 -1
- package/dist/types/components.d.ts.map +1 -1
- package/dist/types/index.d.ts +1093 -26
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/variants.ts +28 -1
- package/dist/util/app-shell.d.ts +78 -0
- package/dist/util/app-shell.js +97 -0
- package/dist/util/avatar.d.ts +38 -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 +40 -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/chart.d.ts +139 -0
- package/dist/util/chart.js +305 -0
- package/dist/util/chip.d.ts +65 -0
- package/dist/util/chip.js +58 -0
- package/dist/util/cn.js +28 -2
- package/dist/util/code-field.d.ts +62 -0
- package/dist/util/code-field.js +112 -0
- package/dist/util/collapsible.d.ts +63 -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/display-voice.d.ts +9 -0
- package/dist/util/display-voice.js +9 -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-control.d.ts +29 -0
- package/dist/util/field-control.js +32 -0
- package/dist/util/field.d.ts +44 -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 +77 -2
- package/dist/util/focus-utils.js +186 -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/map-view.d.ts +143 -0
- package/dist/util/map-view.js +121 -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 +233 -0
- package/dist/util/photo.js +209 -0
- package/dist/util/portal.d.ts +22 -0
- package/dist/util/portal.js +50 -0
- package/dist/util/progress.d.ts +18 -0
- package/dist/util/progress.js +17 -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-edge.d.ts +32 -0
- package/dist/util/scroll-edge.js +87 -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 +83 -0
- package/dist/util/sheet-drag.js +311 -0
- package/dist/util/sidebar.d.ts +62 -0
- package/dist/util/sidebar.js +38 -0
- package/dist/util/skeleton.d.ts +14 -0
- package/dist/util/skeleton.js +22 -0
- package/dist/util/sliding-indicator.d.ts +24 -0
- package/dist/util/sliding-indicator.js +44 -0
- package/dist/util/sortable-list.d.ts +64 -0
- package/dist/util/sortable-list.js +53 -0
- 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/temporal-field.d.ts +88 -0
- package/dist/util/temporal-field.js +136 -0
- package/dist/util/theme-mode.d.ts +79 -0
- package/dist/util/theme-mode.js +121 -0
- package/dist/util/toaster.d.ts +132 -0
- package/dist/util/toaster.js +130 -0
- package/dist/util/tone-surface.d.ts +33 -0
- package/dist/util/tone-surface.js +35 -0
- package/dist/util/tooltip.d.ts +9 -0
- package/dist/util/tooltip.js +18 -0
- package/dist/util/top-navbar.d.ts +34 -0
- package/dist/util/top-navbar.js +28 -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 +141 -0
- package/dist/util/zabi-strings.js +105 -0
- package/dist/zabi-components-colors.css +11 -2
- package/dist/zabi-components-theme-dark-only.css +870 -258
- package/dist/zabi-components-theme-dark.css +870 -258
- package/dist/zabi-components-theme-only.css +2419 -368
- package/dist/zabi-components-theme.css +2419 -368
- package/dist/zabi-components.css +6032 -711
- package/docs/lucide-icons.md +40 -17
- package/docs/theme-imports.md +81 -11
- package/package.json +45 -8
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dragging a bottom sheet with a finger or a pointer. Shared by `BottomSheet`
|
|
3
|
+
* and `SlideUp`, so the two cannot disagree on what a swipe is.
|
|
4
|
+
*
|
|
5
|
+
* It only reports the gesture: how far the pointer has travelled since the
|
|
6
|
+
* drag began and how fast it was going at the end. What that means (move the
|
|
7
|
+
* panel, snap, close) is the caller's.
|
|
8
|
+
*/
|
|
9
|
+
/** Movement under this many px is a press, not a drag. */
|
|
10
|
+
export const DRAG_SLOP = 6;
|
|
11
|
+
/**
|
|
12
|
+
* Movement, on either axis, after which a touch in the content has an axis:
|
|
13
|
+
* more across than down is sideways (a carousel, a row that scrolls, a
|
|
14
|
+
* swipeable item), and stays so until the finger lifts.
|
|
15
|
+
*/
|
|
16
|
+
export const AXIS_SLOP = 8;
|
|
17
|
+
/** Controls in the handle zone that keep their own press, except the grip itself. */
|
|
18
|
+
const INTERACTIVE = "button, a[href], input, select, textarea, [data-sheet-no-drag]";
|
|
19
|
+
const GRIP = "[data-sheet-grip]";
|
|
20
|
+
/**
|
|
21
|
+
* Content that is dragged by a finger on its own and so is never the sheet's:
|
|
22
|
+
* anything carrying `data-sheet-no-drag`, and a range input. Read on a touch
|
|
23
|
+
* that starts in the content.
|
|
24
|
+
*/
|
|
25
|
+
const OWN_DRAG = "[data-sheet-no-drag], input[type='range']";
|
|
26
|
+
/**
|
|
27
|
+
* Whether a computed `touch-action` hands vertical gestures to the element's
|
|
28
|
+
* own code: `none`, or panning on the x axis only. `auto`, `manipulation`,
|
|
29
|
+
* `pan-y` and the like let the browser pan vertically, which is the sheet's
|
|
30
|
+
* to take.
|
|
31
|
+
*/
|
|
32
|
+
function ownsVerticalGesture(touchAction) {
|
|
33
|
+
const tokens = touchAction.trim().split(/\s+/);
|
|
34
|
+
if (tokens.includes("none"))
|
|
35
|
+
return true;
|
|
36
|
+
const sideways = tokens.some((token) => token === "pan-x" || token === "pan-left" || token === "pan-right");
|
|
37
|
+
const vertical = tokens.some((token) => token === "pan-y" || token === "pan-up" || token === "pan-down");
|
|
38
|
+
return sideways && !vertical;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Whether a touch that begins on `target` belongs to the content and not to the
|
|
42
|
+
* sheet: it started on something that is dragged itself (`OWN_DRAG`), or it
|
|
43
|
+
* has, between it and the sheet's `scroller`, a box that scrolls on the y axis
|
|
44
|
+
* or one whose `touch-action` leaves vertical panning to the page's own code
|
|
45
|
+
* (`ownsVerticalGesture`: a map, a canvas, a drawing pad, a slider).
|
|
46
|
+
* A box that can scroll keeps the gesture whether it is at its top or not: a
|
|
47
|
+
* drag that sometimes scrolls a list and sometimes closes the sheet cannot be
|
|
48
|
+
* predicted, and the list does not hand over what it cannot use
|
|
49
|
+
* (`overscroll-contain`). The scroller itself is not asked here; it is the
|
|
50
|
+
* sheet's own content, and hands a pull down at its top to the sheet.
|
|
51
|
+
*/
|
|
52
|
+
export function contentTakesTouch(target, scroller) {
|
|
53
|
+
if (!(target instanceof Element))
|
|
54
|
+
return false;
|
|
55
|
+
if (target.closest(OWN_DRAG))
|
|
56
|
+
return true;
|
|
57
|
+
for (let node = target; node && node !== scroller; node = node.parentElement) {
|
|
58
|
+
const style = getComputedStyle(node);
|
|
59
|
+
if (ownsVerticalGesture(style.getPropertyValue("touch-action")))
|
|
60
|
+
return true;
|
|
61
|
+
const overflow = style.overflowY;
|
|
62
|
+
if ((overflow === "auto" || overflow === "scroll") && node.scrollHeight > node.clientHeight) {
|
|
63
|
+
return true;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
/** The clock of this page, for when an event's own time cannot be used. */
|
|
69
|
+
const now = () => (typeof performance !== "undefined" ? performance.now() : Date.now());
|
|
70
|
+
/**
|
|
71
|
+
* When a pointer or touch event happened: its own `timeStamp`, which is when
|
|
72
|
+
* the finger moved. The time the handler runs is later by however busy the
|
|
73
|
+
* page is, and unevenly so, which made a flick on a janky frame (or a loaded
|
|
74
|
+
* machine) measure slower than it was and spring back. An event without a
|
|
75
|
+
* usable stamp gets the clock.
|
|
76
|
+
*/
|
|
77
|
+
export function timeOf(event) {
|
|
78
|
+
const stamp = event.timeStamp;
|
|
79
|
+
return typeof stamp === "number" && stamp > 0 ? stamp : now();
|
|
80
|
+
}
|
|
81
|
+
/** How far back the velocity looks, in ms. */
|
|
82
|
+
const VELOCITY_WINDOW = 100;
|
|
83
|
+
/**
|
|
84
|
+
* How fast a pointer was moving over the last moments of a gesture, on one
|
|
85
|
+
* axis. Also used by `PhotoViewer`, for both axes.
|
|
86
|
+
*/
|
|
87
|
+
export function createVelocityTracker() {
|
|
88
|
+
/** `time` is the event's; `clock` is when it was handled. */
|
|
89
|
+
let samples = [];
|
|
90
|
+
return {
|
|
91
|
+
reset(y, time) {
|
|
92
|
+
samples = [{ time, clock: now(), y }];
|
|
93
|
+
},
|
|
94
|
+
add(y, time) {
|
|
95
|
+
samples.push({ time, clock: now(), y });
|
|
96
|
+
while (samples.length > 2 && time - samples[0].time > VELOCITY_WINDOW)
|
|
97
|
+
samples.shift();
|
|
98
|
+
},
|
|
99
|
+
velocity() {
|
|
100
|
+
if (samples.length < 2)
|
|
101
|
+
return 0;
|
|
102
|
+
const first = samples[0];
|
|
103
|
+
const last = samples[samples.length - 1];
|
|
104
|
+
// Some browsers hand every event of one frame the same stamp:
|
|
105
|
+
// such a flick has no duration by the events, and is timed by
|
|
106
|
+
// the clock instead.
|
|
107
|
+
const byEvents = last.time - first.time;
|
|
108
|
+
const elapsed = byEvents > 0 ? byEvents : last.clock - first.clock;
|
|
109
|
+
return elapsed > 0 ? (last.y - first.y) / elapsed : 0;
|
|
110
|
+
},
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Listens for drags on a sheet. Call it when the sheet is open, in the
|
|
115
|
+
* browser, and call the returned function when it closes.
|
|
116
|
+
*/
|
|
117
|
+
export function attachSheetDrag({ handleZone, scroller }, callbacks) {
|
|
118
|
+
const tracker = createVelocityTracker();
|
|
119
|
+
const allowed = () => callbacks.canStart?.() ?? true;
|
|
120
|
+
// --- The handle zone: pointer events, so a mouse and a pen drag it too.
|
|
121
|
+
let pointerId = null;
|
|
122
|
+
let pointerStart = 0;
|
|
123
|
+
let pointerDragging = false;
|
|
124
|
+
function swallowClick(event) {
|
|
125
|
+
// The click that ends a drag on the grip is not a press of the grip.
|
|
126
|
+
event.preventDefault();
|
|
127
|
+
event.stopPropagation();
|
|
128
|
+
}
|
|
129
|
+
function onPointerDown(event) {
|
|
130
|
+
if (pointerId !== null || touchDragging)
|
|
131
|
+
return;
|
|
132
|
+
if (event.pointerType === "mouse" && event.button !== 0)
|
|
133
|
+
return;
|
|
134
|
+
const target = event.target;
|
|
135
|
+
if (target?.closest(INTERACTIVE) && !target.closest(GRIP))
|
|
136
|
+
return;
|
|
137
|
+
if (!allowed())
|
|
138
|
+
return;
|
|
139
|
+
pointerId = event.pointerId;
|
|
140
|
+
pointerStart = event.clientY;
|
|
141
|
+
pointerDragging = false;
|
|
142
|
+
tracker.reset(event.clientY, timeOf(event));
|
|
143
|
+
// Not captured yet. A captured pointer delivers its `pointerup` and
|
|
144
|
+
// the click that follows to the handle zone, not to what was
|
|
145
|
+
// pressed: a mouse click on the grip then never reached the grip's
|
|
146
|
+
// button. It is captured once the press has become a drag. A mouse
|
|
147
|
+
// can leave the zone before that, so its moves are followed on the
|
|
148
|
+
// window meanwhile; a finger stays with the element it went down on.
|
|
149
|
+
window.addEventListener("pointermove", onPointerMove);
|
|
150
|
+
window.addEventListener("pointerup", onPointerUp);
|
|
151
|
+
window.addEventListener("pointercancel", onPointerCancel);
|
|
152
|
+
}
|
|
153
|
+
function stopFollowing() {
|
|
154
|
+
window.removeEventListener("pointermove", onPointerMove);
|
|
155
|
+
window.removeEventListener("pointerup", onPointerUp);
|
|
156
|
+
window.removeEventListener("pointercancel", onPointerCancel);
|
|
157
|
+
}
|
|
158
|
+
function onPointerMove(event) {
|
|
159
|
+
if (event.pointerId !== pointerId)
|
|
160
|
+
return;
|
|
161
|
+
const distance = event.clientY - pointerStart;
|
|
162
|
+
if (!pointerDragging) {
|
|
163
|
+
if (Math.abs(distance) < DRAG_SLOP)
|
|
164
|
+
return;
|
|
165
|
+
pointerDragging = true;
|
|
166
|
+
try {
|
|
167
|
+
handleZone.setPointerCapture(event.pointerId);
|
|
168
|
+
}
|
|
169
|
+
catch {
|
|
170
|
+
/* a test DOM, or a pointer that is already gone */
|
|
171
|
+
}
|
|
172
|
+
// Measured from where the drag was recognised, so the sheet does
|
|
173
|
+
// not jump by the slop.
|
|
174
|
+
pointerStart = event.clientY;
|
|
175
|
+
tracker.reset(event.clientY, timeOf(event));
|
|
176
|
+
callbacks.onStart?.();
|
|
177
|
+
callbacks.onMove(0);
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
tracker.add(event.clientY, timeOf(event));
|
|
181
|
+
callbacks.onMove(distance);
|
|
182
|
+
}
|
|
183
|
+
function finishPointer(event, cancelled) {
|
|
184
|
+
if (event.pointerId !== pointerId)
|
|
185
|
+
return;
|
|
186
|
+
const wasDragging = pointerDragging;
|
|
187
|
+
const distance = event.clientY - pointerStart;
|
|
188
|
+
pointerId = null;
|
|
189
|
+
pointerDragging = false;
|
|
190
|
+
stopFollowing();
|
|
191
|
+
try {
|
|
192
|
+
handleZone.releasePointerCapture(event.pointerId);
|
|
193
|
+
}
|
|
194
|
+
catch {
|
|
195
|
+
/* never captured */
|
|
196
|
+
}
|
|
197
|
+
if (!wasDragging)
|
|
198
|
+
return;
|
|
199
|
+
if (cancelled) {
|
|
200
|
+
callbacks.onCancel?.();
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
tracker.add(event.clientY, timeOf(event));
|
|
204
|
+
handleZone.addEventListener("click", swallowClick, { capture: true, once: true });
|
|
205
|
+
// No click follows a drag that ends off the element it began on.
|
|
206
|
+
setTimeout(() => handleZone.removeEventListener("click", swallowClick, true), 0);
|
|
207
|
+
callbacks.onEnd(distance, tracker.velocity(), event);
|
|
208
|
+
}
|
|
209
|
+
const onPointerUp = (event) => finishPointer(event, false);
|
|
210
|
+
const onPointerCancel = (event) => finishPointer(event, true);
|
|
211
|
+
// --- The content: touch events, because here the browser owns the
|
|
212
|
+
// gesture (it scrolls) until we take it, and only a touch listener that
|
|
213
|
+
// is not passive can take it.
|
|
214
|
+
let touchId = null;
|
|
215
|
+
let touchStart = 0;
|
|
216
|
+
let touchStartX = 0;
|
|
217
|
+
/** Decided once per gesture, after `AXIS_SLOP`: null until then. */
|
|
218
|
+
let touchAxis = null;
|
|
219
|
+
let touchDragging = false;
|
|
220
|
+
let startedAtTop = false;
|
|
221
|
+
/** The touch began on something inside the content that keeps it. */
|
|
222
|
+
let contentOwns = false;
|
|
223
|
+
const touchOf = (event, list) => Array.from(list).find((touch) => touch.identifier === touchId);
|
|
224
|
+
function onTouchStart(event) {
|
|
225
|
+
if (touchId !== null || pointerId !== null || event.touches.length !== 1)
|
|
226
|
+
return;
|
|
227
|
+
const touch = event.touches[0];
|
|
228
|
+
touchId = touch.identifier;
|
|
229
|
+
touchStart = touch.clientY;
|
|
230
|
+
touchStartX = touch.clientX;
|
|
231
|
+
touchAxis = null;
|
|
232
|
+
touchDragging = false;
|
|
233
|
+
startedAtTop = (scroller?.scrollTop ?? 0) <= 0;
|
|
234
|
+
contentOwns = !!scroller && contentTakesTouch(event.target, scroller);
|
|
235
|
+
}
|
|
236
|
+
function onTouchMove(event) {
|
|
237
|
+
const touch = touchOf(event, event.touches);
|
|
238
|
+
if (!touch)
|
|
239
|
+
return;
|
|
240
|
+
const distance = touch.clientY - touchStart;
|
|
241
|
+
if (!touchDragging) {
|
|
242
|
+
// Content that has scrolled, or a swipe upwards: the content's.
|
|
243
|
+
if (contentOwns || touchAxis === "x" || !startedAtTop || (scroller?.scrollTop ?? 0) > 0)
|
|
244
|
+
return;
|
|
245
|
+
if (touchAxis === null) {
|
|
246
|
+
const across = Math.abs(touch.clientX - touchStartX);
|
|
247
|
+
if (Math.max(across, Math.abs(distance)) < AXIS_SLOP)
|
|
248
|
+
return;
|
|
249
|
+
touchAxis = across > Math.abs(distance) ? "x" : "y";
|
|
250
|
+
if (touchAxis === "x")
|
|
251
|
+
return;
|
|
252
|
+
}
|
|
253
|
+
if (distance < DRAG_SLOP || !allowed())
|
|
254
|
+
return;
|
|
255
|
+
touchDragging = true;
|
|
256
|
+
touchStart = touch.clientY;
|
|
257
|
+
tracker.reset(touch.clientY, timeOf(event));
|
|
258
|
+
callbacks.onStart?.();
|
|
259
|
+
if (event.cancelable)
|
|
260
|
+
event.preventDefault();
|
|
261
|
+
callbacks.onMove(0);
|
|
262
|
+
return;
|
|
263
|
+
}
|
|
264
|
+
// Ours now: no scrolling, no pull-to-refresh.
|
|
265
|
+
if (event.cancelable)
|
|
266
|
+
event.preventDefault();
|
|
267
|
+
tracker.add(touch.clientY, timeOf(event));
|
|
268
|
+
callbacks.onMove(distance);
|
|
269
|
+
}
|
|
270
|
+
function finishTouch(event, cancelled) {
|
|
271
|
+
const touch = touchOf(event, event.changedTouches);
|
|
272
|
+
if (!touch)
|
|
273
|
+
return;
|
|
274
|
+
const wasDragging = touchDragging;
|
|
275
|
+
const distance = touch.clientY - touchStart;
|
|
276
|
+
touchId = null;
|
|
277
|
+
touchDragging = false;
|
|
278
|
+
if (!wasDragging)
|
|
279
|
+
return;
|
|
280
|
+
if (cancelled) {
|
|
281
|
+
callbacks.onCancel?.();
|
|
282
|
+
return;
|
|
283
|
+
}
|
|
284
|
+
tracker.add(touch.clientY, timeOf(event));
|
|
285
|
+
callbacks.onEnd(distance, tracker.velocity(), event);
|
|
286
|
+
}
|
|
287
|
+
const onTouchEnd = (event) => finishTouch(event, false);
|
|
288
|
+
const onTouchCancel = (event) => finishTouch(event, true);
|
|
289
|
+
handleZone.addEventListener("pointerdown", onPointerDown);
|
|
290
|
+
scroller?.addEventListener("touchstart", onTouchStart, { passive: true });
|
|
291
|
+
scroller?.addEventListener("touchmove", onTouchMove, { passive: false });
|
|
292
|
+
scroller?.addEventListener("touchend", onTouchEnd);
|
|
293
|
+
scroller?.addEventListener("touchcancel", onTouchCancel);
|
|
294
|
+
return () => {
|
|
295
|
+
handleZone.removeEventListener("pointerdown", onPointerDown);
|
|
296
|
+
stopFollowing();
|
|
297
|
+
handleZone.removeEventListener("click", swallowClick, true);
|
|
298
|
+
scroller?.removeEventListener("touchstart", onTouchStart);
|
|
299
|
+
scroller?.removeEventListener("touchmove", onTouchMove);
|
|
300
|
+
scroller?.removeEventListener("touchend", onTouchEnd);
|
|
301
|
+
scroller?.removeEventListener("touchcancel", onTouchCancel);
|
|
302
|
+
};
|
|
303
|
+
}
|
|
304
|
+
/** A flick: faster than this, in px per ms, and the direction decides, not the distance. */
|
|
305
|
+
export const FLICK_VELOCITY = 0.5;
|
|
306
|
+
/** True where the user has asked for less motion, or where that cannot be asked. */
|
|
307
|
+
export function prefersReducedMotion() {
|
|
308
|
+
return (typeof window === "undefined" ||
|
|
309
|
+
typeof window.matchMedia !== "function" ||
|
|
310
|
+
window.matchMedia("(prefers-reduced-motion: reduce)").matches);
|
|
311
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The words the sidebar components say by themselves. Each takes its own as
|
|
3
|
+
* `strings`; `SidebarNavigation` takes them all and hands the footer and the
|
|
4
|
+
* brand header theirs.
|
|
5
|
+
*/
|
|
6
|
+
/** `SidebarBrandHeader`. */
|
|
7
|
+
export interface SidebarBrandHeaderStrings {
|
|
8
|
+
/** The logo's alt text when neither `logoAlt` nor `brandName` is given. */
|
|
9
|
+
brandAlt: string;
|
|
10
|
+
}
|
|
11
|
+
export declare const DEFAULT_SIDEBAR_BRAND_HEADER_STRINGS: SidebarBrandHeaderStrings;
|
|
12
|
+
/** `SidebarFooter`. */
|
|
13
|
+
export interface SidebarFooterStrings {
|
|
14
|
+
/** Accessible name of the footer. */
|
|
15
|
+
accountAndSettings: string;
|
|
16
|
+
/** Accessible name of the profile button in a collapsed rail. */
|
|
17
|
+
openAccountPanel: string;
|
|
18
|
+
/** The same button in an expanded sidebar, with the profile's name. */
|
|
19
|
+
openAccountPanelFor: (name: string) => string;
|
|
20
|
+
}
|
|
21
|
+
export declare const DEFAULT_SIDEBAR_FOOTER_STRINGS: SidebarFooterStrings;
|
|
22
|
+
/** `SidebarAccountPanel`. */
|
|
23
|
+
export interface SidebarAccountPanelStrings {
|
|
24
|
+
/** Accessible name of the panel. */
|
|
25
|
+
panelLabel: string;
|
|
26
|
+
/** The panel's heading. */
|
|
27
|
+
title: string;
|
|
28
|
+
/** Accessible name of the close button. */
|
|
29
|
+
closeLabel: string;
|
|
30
|
+
/** Accessible name of the list of rows. */
|
|
31
|
+
listLabel: string;
|
|
32
|
+
/** The first row, above the profile's name. */
|
|
33
|
+
account: string;
|
|
34
|
+
/** The row that switches the theme. */
|
|
35
|
+
theme: string;
|
|
36
|
+
/** That row's second line, in each mode. */
|
|
37
|
+
lightMode: string;
|
|
38
|
+
darkMode: string;
|
|
39
|
+
/** With `themeModes="three"`: the mode that follows the system. */
|
|
40
|
+
systemMode: string;
|
|
41
|
+
/** The badge on that row, in each mode. */
|
|
42
|
+
light: string;
|
|
43
|
+
dark: string;
|
|
44
|
+
system: string;
|
|
45
|
+
/** The second line of the log-out row. Its first line is `logoutLabel`. */
|
|
46
|
+
signOut: string;
|
|
47
|
+
}
|
|
48
|
+
export declare const DEFAULT_SIDEBAR_ACCOUNT_PANEL_STRINGS: SidebarAccountPanelStrings;
|
|
49
|
+
/** `SidebarNavigation`: its own words, and those of the footer and the brand header in it. */
|
|
50
|
+
export interface SidebarNavigationStrings extends SidebarFooterStrings, SidebarBrandHeaderStrings {
|
|
51
|
+
/** Accessible name of the main list of links, when it has no section heading. */
|
|
52
|
+
primaryNavigation: string;
|
|
53
|
+
/** Accessible name of the second list of links. */
|
|
54
|
+
secondaryNavigation: string;
|
|
55
|
+
/** Accessible name of a list under a section heading, from the heading. */
|
|
56
|
+
sectionNavigation: (section: string) => string;
|
|
57
|
+
/** Shown when a search matches no link: the heading. */
|
|
58
|
+
noMatchesTitle: string;
|
|
59
|
+
/** And the line under it, with what was searched for. */
|
|
60
|
+
noMatchesDescription: (term: string) => string;
|
|
61
|
+
}
|
|
62
|
+
export declare const DEFAULT_SIDEBAR_NAVIGATION_STRINGS: SidebarNavigationStrings;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The words the sidebar components say by themselves. Each takes its own as
|
|
3
|
+
* `strings`; `SidebarNavigation` takes them all and hands the footer and the
|
|
4
|
+
* brand header theirs.
|
|
5
|
+
*/
|
|
6
|
+
export const DEFAULT_SIDEBAR_BRAND_HEADER_STRINGS = {
|
|
7
|
+
brandAlt: "Brand",
|
|
8
|
+
};
|
|
9
|
+
export const DEFAULT_SIDEBAR_FOOTER_STRINGS = {
|
|
10
|
+
accountAndSettings: "Account and settings",
|
|
11
|
+
openAccountPanel: "Open account panel",
|
|
12
|
+
openAccountPanelFor: (name) => `Open account panel for ${name}`,
|
|
13
|
+
};
|
|
14
|
+
export const DEFAULT_SIDEBAR_ACCOUNT_PANEL_STRINGS = {
|
|
15
|
+
panelLabel: "Account panel",
|
|
16
|
+
title: "Account",
|
|
17
|
+
closeLabel: "Close account panel",
|
|
18
|
+
listLabel: "Select item",
|
|
19
|
+
account: "Account",
|
|
20
|
+
theme: "Theme",
|
|
21
|
+
lightMode: "Light mode",
|
|
22
|
+
darkMode: "Dark mode",
|
|
23
|
+
// Not "System": the badge beside it says that, and the row read "Theme System System".
|
|
24
|
+
systemMode: "Follows the system",
|
|
25
|
+
light: "Light",
|
|
26
|
+
dark: "Dark",
|
|
27
|
+
system: "System",
|
|
28
|
+
signOut: "Sign out of this account",
|
|
29
|
+
};
|
|
30
|
+
export const DEFAULT_SIDEBAR_NAVIGATION_STRINGS = {
|
|
31
|
+
...DEFAULT_SIDEBAR_FOOTER_STRINGS,
|
|
32
|
+
...DEFAULT_SIDEBAR_BRAND_HEADER_STRINGS,
|
|
33
|
+
primaryNavigation: "Primary navigation",
|
|
34
|
+
secondaryNavigation: "Secondary navigation",
|
|
35
|
+
sectionNavigation: (section) => `${section} navigation`,
|
|
36
|
+
noMatchesTitle: "No matching navigation items",
|
|
37
|
+
noMatchesDescription: (term) => `No results found for "${term}". Try another keyword.`,
|
|
38
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/** Every built-in string. Pass a partial object to `strings` to translate. */
|
|
2
|
+
export interface SkeletonStrings {
|
|
3
|
+
/** The name of the loading status, for a lone `Skeleton` and for a `SkeletonGroup`. */
|
|
4
|
+
label: string;
|
|
5
|
+
}
|
|
6
|
+
export declare const DEFAULT_SKELETON_STRINGS: SkeletonStrings;
|
|
7
|
+
/** The fewest and the most lines a text `Skeleton` draws with `lines`. */
|
|
8
|
+
export declare const SKELETON_LINES_MAX = 20;
|
|
9
|
+
/** `lines` as a whole number from 1 to 20, or 0 for "not a paragraph" (unset, below 1, not a number). */
|
|
10
|
+
export declare function skeletonLineCount(lines: number | undefined): number;
|
|
11
|
+
/** For `SkeletonGroup`: marks everything below it as pieces of one status. Call while the component initialises. */
|
|
12
|
+
export declare function provideSkeletonGroup(): void;
|
|
13
|
+
/** For `Skeleton`: whether it sits under a `SkeletonGroup`. Call while the component initialises. */
|
|
14
|
+
export declare function inSkeletonGroup(): boolean;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/** Types and helpers shared by `Skeleton` and `SkeletonGroup`. Kept out of the components so they can be tested without a DOM. */
|
|
2
|
+
import { getContext, setContext } from "svelte";
|
|
3
|
+
export const DEFAULT_SKELETON_STRINGS = {
|
|
4
|
+
label: "Loading…",
|
|
5
|
+
};
|
|
6
|
+
/** The fewest and the most lines a text `Skeleton` draws with `lines`. */
|
|
7
|
+
export const SKELETON_LINES_MAX = 20;
|
|
8
|
+
/** `lines` as a whole number from 1 to 20, or 0 for "not a paragraph" (unset, below 1, not a number). */
|
|
9
|
+
export function skeletonLineCount(lines) {
|
|
10
|
+
if (lines === undefined || !Number.isFinite(lines) || lines < 1)
|
|
11
|
+
return 0;
|
|
12
|
+
return Math.min(SKELETON_LINES_MAX, Math.floor(lines));
|
|
13
|
+
}
|
|
14
|
+
const GROUP_KEY = Symbol("zabi-skeleton-group");
|
|
15
|
+
/** For `SkeletonGroup`: marks everything below it as pieces of one status. Call while the component initialises. */
|
|
16
|
+
export function provideSkeletonGroup() {
|
|
17
|
+
setContext(GROUP_KEY, true);
|
|
18
|
+
}
|
|
19
|
+
/** For `Skeleton`: whether it sits under a `SkeletonGroup`. Call while the component initialises. */
|
|
20
|
+
export function inSkeletonGroup() {
|
|
21
|
+
return getContext(GROUP_KEY) === true;
|
|
22
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Measuring for the sliding indicator of Tabs and SegmentedControl. The
|
|
3
|
+
* component paints its selected item itself until a box has been measured, so
|
|
4
|
+
* a server render, a page that has not hydrated and an engine that cannot
|
|
5
|
+
* measure all keep the static look.
|
|
6
|
+
*/
|
|
7
|
+
export interface IndicatorBox {
|
|
8
|
+
x: number;
|
|
9
|
+
y: number;
|
|
10
|
+
width: number;
|
|
11
|
+
height: number;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* The `item`'s box in the coordinates an absolutely positioned child of
|
|
15
|
+
* `container` uses: from the container's padding box, plus what the container
|
|
16
|
+
* has scrolled (so an indicator inside a scrolling list stays on its item).
|
|
17
|
+
* Measured as physical boxes, so a right-to-left layout needs nothing extra.
|
|
18
|
+
* Null where nothing can be measured (no layout, or the item is not shown).
|
|
19
|
+
*/
|
|
20
|
+
export declare function measureIndicator(container: HTMLElement, item: HTMLElement): IndicatorBox | null;
|
|
21
|
+
/** Calls `onChange` when any of the `targets` changes size; a no-op without ResizeObserver. */
|
|
22
|
+
export declare function observeSizes(targets: Array<Element | null | undefined>, onChange: () => void): () => void;
|
|
23
|
+
/** Runs `callback` after the next frame; the timer stands in where there are no frames. */
|
|
24
|
+
export declare function afterFrame(callback: () => void): () => void;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Measuring for the sliding indicator of Tabs and SegmentedControl. The
|
|
3
|
+
* component paints its selected item itself until a box has been measured, so
|
|
4
|
+
* a server render, a page that has not hydrated and an engine that cannot
|
|
5
|
+
* measure all keep the static look.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* The `item`'s box in the coordinates an absolutely positioned child of
|
|
9
|
+
* `container` uses: from the container's padding box, plus what the container
|
|
10
|
+
* has scrolled (so an indicator inside a scrolling list stays on its item).
|
|
11
|
+
* Measured as physical boxes, so a right-to-left layout needs nothing extra.
|
|
12
|
+
* Null where nothing can be measured (no layout, or the item is not shown).
|
|
13
|
+
*/
|
|
14
|
+
export function measureIndicator(container, item) {
|
|
15
|
+
const outer = container.getBoundingClientRect();
|
|
16
|
+
const inner = item.getBoundingClientRect();
|
|
17
|
+
if (inner.width === 0 && inner.height === 0)
|
|
18
|
+
return null;
|
|
19
|
+
return {
|
|
20
|
+
x: inner.left - outer.left - container.clientLeft + container.scrollLeft,
|
|
21
|
+
y: inner.top - outer.top - container.clientTop + container.scrollTop,
|
|
22
|
+
width: inner.width,
|
|
23
|
+
height: inner.height,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
/** Calls `onChange` when any of the `targets` changes size; a no-op without ResizeObserver. */
|
|
27
|
+
export function observeSizes(targets, onChange) {
|
|
28
|
+
if (typeof ResizeObserver === "undefined")
|
|
29
|
+
return () => { };
|
|
30
|
+
const observer = new ResizeObserver(onChange);
|
|
31
|
+
for (const target of targets)
|
|
32
|
+
if (target)
|
|
33
|
+
observer.observe(target);
|
|
34
|
+
return () => observer.disconnect();
|
|
35
|
+
}
|
|
36
|
+
/** Runs `callback` after the next frame; the timer stands in where there are no frames. */
|
|
37
|
+
export function afterFrame(callback) {
|
|
38
|
+
if (typeof requestAnimationFrame === "function") {
|
|
39
|
+
const id = requestAnimationFrame(callback);
|
|
40
|
+
return () => cancelAnimationFrame(id);
|
|
41
|
+
}
|
|
42
|
+
const id = setTimeout(callback, 16);
|
|
43
|
+
return () => clearTimeout(id);
|
|
44
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/** Types and pure helpers for `SortableList`. Kept out of the component so they can be tested without a DOM. */
|
|
2
|
+
import type { Snippet } from "svelte";
|
|
3
|
+
/** Payload of `onreorder`: which item moved, and between which zero-based indexes. */
|
|
4
|
+
export interface SortableListReorderDetail<T> {
|
|
5
|
+
item: T;
|
|
6
|
+
from: number;
|
|
7
|
+
to: number;
|
|
8
|
+
/** The list in its new order (the same array `bind:items` receives). */
|
|
9
|
+
items: T[];
|
|
10
|
+
}
|
|
11
|
+
/** What a live-region message is built from. `position` is one-based. */
|
|
12
|
+
export interface SortableListAnnouncement {
|
|
13
|
+
label: string;
|
|
14
|
+
position: number;
|
|
15
|
+
total: number;
|
|
16
|
+
}
|
|
17
|
+
/** Second argument of the `item` snippet. */
|
|
18
|
+
export interface SortableListRow {
|
|
19
|
+
/** Zero-based index in the current order. */
|
|
20
|
+
index: number;
|
|
21
|
+
/** True while this row is being dragged with a pointer. */
|
|
22
|
+
dragging: boolean;
|
|
23
|
+
/** True when the list or this item is disabled. */
|
|
24
|
+
disabled: boolean;
|
|
25
|
+
/** The drag handle. Render it yourself when `controls="manual"`. */
|
|
26
|
+
handle: Snippet;
|
|
27
|
+
/** The move up / move down buttons. Render them yourself when `controls="manual"`. */
|
|
28
|
+
moveButtons: Snippet;
|
|
29
|
+
}
|
|
30
|
+
/** Every built-in string. Pass a partial object to `strings` to translate. */
|
|
31
|
+
export interface SortableListStrings {
|
|
32
|
+
/** Accessible name of the drag handle. */
|
|
33
|
+
handleLabel: (label: string) => string;
|
|
34
|
+
/** How to use the handle; referenced by every handle through `aria-describedby`. */
|
|
35
|
+
handleDescription: string;
|
|
36
|
+
moveUp: (label: string) => string;
|
|
37
|
+
moveDown: (label: string) => string;
|
|
38
|
+
/** Announced after every move. */
|
|
39
|
+
moved: (detail: SortableListAnnouncement) => string;
|
|
40
|
+
/** Announced when Escape (or a cancelled pointer) abandons a drag. */
|
|
41
|
+
cancelled: (detail: SortableListAnnouncement) => string;
|
|
42
|
+
/** Announced when Arrow Up or Home is pressed on the first item. */
|
|
43
|
+
atStart: (detail: SortableListAnnouncement) => string;
|
|
44
|
+
/** Announced when Arrow Down or End is pressed on the last item. */
|
|
45
|
+
atEnd: (detail: SortableListAnnouncement) => string;
|
|
46
|
+
}
|
|
47
|
+
export declare const SORTABLE_LIST_STRINGS: SortableListStrings;
|
|
48
|
+
/** A copy of `items` with the entry at `from` moved to `to`. Out-of-range indexes are clamped. */
|
|
49
|
+
export declare function moveItem<T>(items: readonly T[], from: number, to: number): T[];
|
|
50
|
+
/** Top edge and height of a row, measured once when a drag starts. */
|
|
51
|
+
export interface SortableSlot {
|
|
52
|
+
top: number;
|
|
53
|
+
height: number;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Index the dragged row would land on, given how far it has travelled.
|
|
57
|
+
*
|
|
58
|
+
* A row below counts as passed once the dragged row's bottom edge crosses its
|
|
59
|
+
* centre, and a row above once the top edge does. Both are read from the
|
|
60
|
+
* positions measured at drag start, so the answer depends on the pointer
|
|
61
|
+
* alone: rows sliding out of the way cannot feed back into it and make the
|
|
62
|
+
* target flicker, which is what happens when the live positions are compared.
|
|
63
|
+
*/
|
|
64
|
+
export declare function dropIndex(slots: readonly SortableSlot[], from: number, offset: number): number;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/** Types and pure helpers for `SortableList`. Kept out of the component so they can be tested without a DOM. */
|
|
2
|
+
export const SORTABLE_LIST_STRINGS = {
|
|
3
|
+
handleLabel: (label) => `Reorder ${label}`,
|
|
4
|
+
// Kept short: a screen reader reads it after the name each time the
|
|
5
|
+
// handle takes focus, and a move down can hand focus back to the handle.
|
|
6
|
+
handleDescription: "Arrow keys move this item. Home and End move it to the start or the end.",
|
|
7
|
+
moveUp: (label) => `Move ${label} up`,
|
|
8
|
+
moveDown: (label) => `Move ${label} down`,
|
|
9
|
+
moved: ({ label, position, total }) => `${label}, moved to position ${position} of ${total}`,
|
|
10
|
+
cancelled: ({ label, position, total }) => `${label}, move cancelled, still at position ${position} of ${total}`,
|
|
11
|
+
atStart: ({ label }) => `${label}, already first`,
|
|
12
|
+
atEnd: ({ label }) => `${label}, already last`,
|
|
13
|
+
};
|
|
14
|
+
/** A copy of `items` with the entry at `from` moved to `to`. Out-of-range indexes are clamped. */
|
|
15
|
+
export function moveItem(items, from, to) {
|
|
16
|
+
const next = [...items];
|
|
17
|
+
if (from < 0 || from >= next.length)
|
|
18
|
+
return next;
|
|
19
|
+
const target = Math.max(0, Math.min(next.length - 1, to));
|
|
20
|
+
const [moved] = next.splice(from, 1);
|
|
21
|
+
next.splice(target, 0, moved);
|
|
22
|
+
return next;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Index the dragged row would land on, given how far it has travelled.
|
|
26
|
+
*
|
|
27
|
+
* A row below counts as passed once the dragged row's bottom edge crosses its
|
|
28
|
+
* centre, and a row above once the top edge does. Both are read from the
|
|
29
|
+
* positions measured at drag start, so the answer depends on the pointer
|
|
30
|
+
* alone: rows sliding out of the way cannot feed back into it and make the
|
|
31
|
+
* target flicker, which is what happens when the live positions are compared.
|
|
32
|
+
*/
|
|
33
|
+
export function dropIndex(slots, from, offset) {
|
|
34
|
+
const dragged = slots[from];
|
|
35
|
+
if (!dragged)
|
|
36
|
+
return from;
|
|
37
|
+
const top = dragged.top + offset;
|
|
38
|
+
const bottom = top + dragged.height;
|
|
39
|
+
let to = from;
|
|
40
|
+
for (let i = from + 1; i < slots.length; i += 1) {
|
|
41
|
+
if (bottom > slots[i].top + slots[i].height / 2)
|
|
42
|
+
to = i;
|
|
43
|
+
else
|
|
44
|
+
break;
|
|
45
|
+
}
|
|
46
|
+
for (let i = from - 1; i >= 0; i -= 1) {
|
|
47
|
+
if (top < slots[i].top + slots[i].height / 2)
|
|
48
|
+
to = i;
|
|
49
|
+
else
|
|
50
|
+
break;
|
|
51
|
+
}
|
|
52
|
+
return to;
|
|
53
|
+
}
|