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,233 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public types and pure helpers for `PhotoGrid` and `PhotoViewer`.
|
|
3
|
+
*
|
|
4
|
+
* Everything a gesture means is worked out here, on numbers: where a pinch
|
|
5
|
+
* leaves the photo, how far it may be panned, whether a swipe turns the page.
|
|
6
|
+
* The components only feed pointers in and apply the result, so the
|
|
7
|
+
* arithmetic can be tested without a browser.
|
|
8
|
+
*/
|
|
9
|
+
import type { Component } from "svelte";
|
|
10
|
+
export type PhotoKey = string | number;
|
|
11
|
+
/** One photo. `PhotoGrid` and `PhotoViewer` take the same array. */
|
|
12
|
+
export interface Photo {
|
|
13
|
+
/** Stable identity, when the same `src` may appear twice or may change. Without it, `src` is the identity. */
|
|
14
|
+
id?: PhotoKey;
|
|
15
|
+
/** The full image, shown in the viewer. */
|
|
16
|
+
src: string;
|
|
17
|
+
/** A small version for the grid, and for the viewer while the full image loads. Without it, `src`. */
|
|
18
|
+
thumbSrc?: string;
|
|
19
|
+
/** What the photo shows, for those who cannot see it. */
|
|
20
|
+
alt: string;
|
|
21
|
+
/** Width of the full image in px. With `height` it reserves the photo's box before it has loaded. */
|
|
22
|
+
width: number;
|
|
23
|
+
/** Height of the full image in px. */
|
|
24
|
+
height: number;
|
|
25
|
+
/** Shown under the photo in the viewer. */
|
|
26
|
+
caption?: string;
|
|
27
|
+
/**
|
|
28
|
+
* A second, quieter line under the caption in the viewer: who took the
|
|
29
|
+
* photo, when. It is never folded away with a long caption.
|
|
30
|
+
*/
|
|
31
|
+
credit?: string;
|
|
32
|
+
/**
|
|
33
|
+
* Where a photo that is being added stands, drawn on its tile in the grid:
|
|
34
|
+
* `uploading` (on its way) or `error` (it did not arrive). Left out: saved.
|
|
35
|
+
*/
|
|
36
|
+
status?: PhotoStatus;
|
|
37
|
+
/** How far an `uploading` photo has come, from 0 to 1. Without it the tile shows a spinner. */
|
|
38
|
+
progress?: number;
|
|
39
|
+
}
|
|
40
|
+
export type PhotoStatus = "uploading" | "error";
|
|
41
|
+
export declare function photoKey(photo: Photo): PhotoKey;
|
|
42
|
+
/** Payload of PhotoGrid's `onselect`. */
|
|
43
|
+
export interface PhotoGridSelectDetail {
|
|
44
|
+
photo: Photo;
|
|
45
|
+
index: number;
|
|
46
|
+
/** False when the press cleared the photo's selection (only in `multiple`). */
|
|
47
|
+
selected: boolean;
|
|
48
|
+
/** Every selected key after the change: one or none in `single`. */
|
|
49
|
+
keys: PhotoKey[];
|
|
50
|
+
}
|
|
51
|
+
/** Every built-in string of PhotoGrid. Pass a partial object to `strings` to translate. */
|
|
52
|
+
export interface PhotoGridStrings {
|
|
53
|
+
/** Visible label and name of the tile that adds a photo. */
|
|
54
|
+
addPhoto: string;
|
|
55
|
+
/** Name of a photo that has no `alt`. */
|
|
56
|
+
photoName: (position: number, total: number) => string;
|
|
57
|
+
/** Name of the last tile when it stands for the photos not shown. */
|
|
58
|
+
morePhotos: (count: number) => string;
|
|
59
|
+
/** Name of the button that opens a photo, in a grid where a press selects. */
|
|
60
|
+
openPhoto: (name: string) => string;
|
|
61
|
+
/** How to get around by keyboard. Read once when focus enters the grid, and shown while it has keyboard focus. */
|
|
62
|
+
keyboardHint: string;
|
|
63
|
+
/** Added to the name of a photo whose `status` is `uploading`. */
|
|
64
|
+
uploading: string;
|
|
65
|
+
/** Added to the name of a photo whose `status` is `error`. */
|
|
66
|
+
uploadFailed: string;
|
|
67
|
+
/** Name of the button on a failed photo that tries again. */
|
|
68
|
+
retryUpload: (name: string) => string;
|
|
69
|
+
}
|
|
70
|
+
export declare const PHOTO_GRID_STRINGS: PhotoGridStrings;
|
|
71
|
+
/** What the user did to close the viewer. `swipe` is a swipe down on the photo. */
|
|
72
|
+
export type PhotoViewerCloseReason = "escape" | "close-button" | "swipe";
|
|
73
|
+
/** Something to do with the photo that is showing: share it, delete it. */
|
|
74
|
+
export interface PhotoViewerAction {
|
|
75
|
+
id: string;
|
|
76
|
+
label: string;
|
|
77
|
+
/** An icon component, as `@lucide/svelte` icons are. */
|
|
78
|
+
icon?: Component<{
|
|
79
|
+
size?: number;
|
|
80
|
+
class?: string;
|
|
81
|
+
}>;
|
|
82
|
+
/** `danger` for a destructive action such as Delete. */
|
|
83
|
+
tone?: "danger";
|
|
84
|
+
disabled?: boolean;
|
|
85
|
+
onclick: (photo: Photo, index: number) => void;
|
|
86
|
+
}
|
|
87
|
+
/** Every built-in string of PhotoViewer. Pass a partial object to `strings` to translate. */
|
|
88
|
+
export interface PhotoViewerStrings {
|
|
89
|
+
close: string;
|
|
90
|
+
previous: string;
|
|
91
|
+
next: string;
|
|
92
|
+
/** The counter that is shown: "3 / 12". */
|
|
93
|
+
counter: (position: number, total: number) => string;
|
|
94
|
+
/** The same for a screen reader, read out after the photo's `alt`: "3 of 12". */
|
|
95
|
+
position: (position: number, total: number) => string;
|
|
96
|
+
/** Announced, with a spinner, when a photo takes a while to load. */
|
|
97
|
+
loading: string;
|
|
98
|
+
/** Shown when a photo cannot be loaded. */
|
|
99
|
+
loadError: string;
|
|
100
|
+
retry: string;
|
|
101
|
+
/** Name of the menu that holds the actions that do not fit in the bar. */
|
|
102
|
+
moreActions: string;
|
|
103
|
+
/** The button that shows all of a long caption, and the one that folds it again. */
|
|
104
|
+
showMore: string;
|
|
105
|
+
showLess: string;
|
|
106
|
+
/** Name of a photo that has no `alt`. */
|
|
107
|
+
photoName: (position: number, total: number) => string;
|
|
108
|
+
}
|
|
109
|
+
export declare const PHOTO_VIEWER_STRINGS: PhotoViewerStrings;
|
|
110
|
+
/** How many actions the viewer's bar shows before the rest go into a menu. */
|
|
111
|
+
export declare const MAX_BAR_ACTIONS = 3;
|
|
112
|
+
/** The actions shown in the bar, and those that go into the menu. */
|
|
113
|
+
export declare function splitActions<T>(actions: readonly T[], max?: number): {
|
|
114
|
+
bar: T[];
|
|
115
|
+
menu: T[];
|
|
116
|
+
};
|
|
117
|
+
/** An index held inside a list of `count` photos; -1 for an empty list. */
|
|
118
|
+
export declare function clampIndex(index: number, count: number): number;
|
|
119
|
+
/** What the grid shows of `total` photos under `max`, and how many the last tile stands for. */
|
|
120
|
+
export declare function visibleCount(total: number, max: number | undefined): {
|
|
121
|
+
shown: number;
|
|
122
|
+
hidden: number;
|
|
123
|
+
};
|
|
124
|
+
export interface Size {
|
|
125
|
+
width: number;
|
|
126
|
+
height: number;
|
|
127
|
+
}
|
|
128
|
+
export interface Point {
|
|
129
|
+
x: number;
|
|
130
|
+
y: number;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Where the photo is. `scale` 1 is the photo fitted to the screen. `x` and
|
|
134
|
+
* `y` are how far its centre is from the centre of the screen, in px.
|
|
135
|
+
*/
|
|
136
|
+
export interface PhotoTransform {
|
|
137
|
+
scale: number;
|
|
138
|
+
x: number;
|
|
139
|
+
y: number;
|
|
140
|
+
}
|
|
141
|
+
export declare const REST: PhotoTransform;
|
|
142
|
+
export declare const MIN_SCALE = 1;
|
|
143
|
+
export declare const MAX_SCALE = 4;
|
|
144
|
+
/** What a double tap zooms to. */
|
|
145
|
+
export declare const DOUBLE_TAP_SCALE = 2.5;
|
|
146
|
+
export declare const isZoomed: (transform: PhotoTransform) => boolean;
|
|
147
|
+
/** The largest size a photo of `photo` px takes inside `view` without being cropped. */
|
|
148
|
+
export declare function fitSize(photo: Size, view: Size): Size;
|
|
149
|
+
/**
|
|
150
|
+
* The transform with its pan held to the photo's edges: an edge of the photo
|
|
151
|
+
* never comes further in than the edge of the screen, and a side that is
|
|
152
|
+
* narrower than the screen stays centred. `fit` is the photo's size at scale 1.
|
|
153
|
+
*/
|
|
154
|
+
export declare function clampPan(transform: PhotoTransform, fit: Size, view: Size): PhotoTransform;
|
|
155
|
+
/**
|
|
156
|
+
* Zooms to `scale` so that the point of the photo under `point` stays under
|
|
157
|
+
* it. `point` is measured from the centre of the screen.
|
|
158
|
+
*/
|
|
159
|
+
export declare function zoomAbout(transform: PhotoTransform, scale: number, point: Point, fit: Size, view: Size): PhotoTransform;
|
|
160
|
+
/** Two fingers on the glass: the point between them, and how far apart they are. */
|
|
161
|
+
export interface PinchSample {
|
|
162
|
+
centre: Point;
|
|
163
|
+
distance: number;
|
|
164
|
+
}
|
|
165
|
+
export declare function pinchSample(first: Point, second: Point): PinchSample;
|
|
166
|
+
/**
|
|
167
|
+
* Where a pinch has taken the photo: scaled by how much the fingers have
|
|
168
|
+
* spread, about the point that was between them when it began, and moved with
|
|
169
|
+
* that point. Points are measured from the centre of the screen.
|
|
170
|
+
*/
|
|
171
|
+
export declare function pinchTransform(start: PhotoTransform, from: PinchSample, now: PinchSample, fit: Size, view: Size): PhotoTransform;
|
|
172
|
+
/** A pinch let go a hair above the fitted size is the fitted size. */
|
|
173
|
+
export declare function settleZoom(transform: PhotoTransform, fit: Size, view: Size): PhotoTransform;
|
|
174
|
+
/** A double tap: in to 2.5 times about the tap from the fitted photo, and back to fitted from any zoom. */
|
|
175
|
+
export declare function doubleTapTransform(transform: PhotoTransform, point: Point, fit: Size, view: Size): PhotoTransform;
|
|
176
|
+
/** The photo moved by `delta` px, held to its edges. */
|
|
177
|
+
export declare function panBy(transform: PhotoTransform, delta: Point, fit: Size, view: Size): PhotoTransform;
|
|
178
|
+
/** One step of the keyboard or the wheel: in or out by half again, about the centre. */
|
|
179
|
+
export declare const ZOOM_STEP = 1.5;
|
|
180
|
+
/** Movement under this many px is a press, not a drag. */
|
|
181
|
+
export declare const TAP_SLOP = 8;
|
|
182
|
+
/** A press shorter than this is a tap, and two taps closer together than this are a double tap. */
|
|
183
|
+
export declare const TAP_MS = 300;
|
|
184
|
+
/** Two taps further apart than this are two taps. */
|
|
185
|
+
export declare const DOUBLE_TAP_RADIUS = 32;
|
|
186
|
+
export declare function isDoubleTap(previous: {
|
|
187
|
+
time: number;
|
|
188
|
+
point: Point;
|
|
189
|
+
} | null, now: {
|
|
190
|
+
time: number;
|
|
191
|
+
point: Point;
|
|
192
|
+
}): boolean;
|
|
193
|
+
/**
|
|
194
|
+
* Which way a drag on the fitted photo is going, once it has gone far enough
|
|
195
|
+
* to tell: `x` turns the page, `down` closes, and null is not yet known. A
|
|
196
|
+
* drag upwards is neither, and stays null.
|
|
197
|
+
*/
|
|
198
|
+
export declare function dragAxis(delta: Point, slop?: number): "x" | "down" | null;
|
|
199
|
+
/** Part of the screen's width a slow swipe has to cross to turn the page. */
|
|
200
|
+
export declare const TURN_DISTANCE = 0.25;
|
|
201
|
+
/** Part of the screen's height a slow swipe down has to cross to close. */
|
|
202
|
+
export declare const CLOSE_DISTANCE = 0.2;
|
|
203
|
+
/**
|
|
204
|
+
* What a horizontal swipe does when the finger lifts. A flick decides by its
|
|
205
|
+
* direction; a slow one by how far it went. Swiping left shows the next
|
|
206
|
+
* photo, and the previous one in a right-to-left layout. At either end there
|
|
207
|
+
* is nothing to turn to.
|
|
208
|
+
*/
|
|
209
|
+
export declare function swipeTurn(options: {
|
|
210
|
+
/** px moved; negative is to the left. */
|
|
211
|
+
distance: number;
|
|
212
|
+
/** px per ms at release; negative is to the left. */
|
|
213
|
+
velocity: number;
|
|
214
|
+
width: number;
|
|
215
|
+
index: number;
|
|
216
|
+
count: number;
|
|
217
|
+
rtl?: boolean;
|
|
218
|
+
flick: number;
|
|
219
|
+
}): -1 | 0 | 1;
|
|
220
|
+
/** Whether a swipe down closes the viewer when the finger lifts. */
|
|
221
|
+
export declare function swipeCloses(options: {
|
|
222
|
+
/** px moved down. */
|
|
223
|
+
distance: number;
|
|
224
|
+
/** px per ms at release; positive is down. */
|
|
225
|
+
velocity: number;
|
|
226
|
+
height: number;
|
|
227
|
+
flick: number;
|
|
228
|
+
}): boolean;
|
|
229
|
+
/**
|
|
230
|
+
* How far a drag past the first or last photo moves it: a third of the
|
|
231
|
+
* finger's travel, so it gives but does not come away.
|
|
232
|
+
*/
|
|
233
|
+
export declare function resist(distance: number): number;
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public types and pure helpers for `PhotoGrid` and `PhotoViewer`.
|
|
3
|
+
*
|
|
4
|
+
* Everything a gesture means is worked out here, on numbers: where a pinch
|
|
5
|
+
* leaves the photo, how far it may be panned, whether a swipe turns the page.
|
|
6
|
+
* The components only feed pointers in and apply the result, so the
|
|
7
|
+
* arithmetic can be tested without a browser.
|
|
8
|
+
*/
|
|
9
|
+
export function photoKey(photo) {
|
|
10
|
+
return photo.id ?? photo.src;
|
|
11
|
+
}
|
|
12
|
+
export const PHOTO_GRID_STRINGS = {
|
|
13
|
+
addPhoto: "Add photo",
|
|
14
|
+
photoName: (position, total) => `Photo ${position} of ${total}`,
|
|
15
|
+
morePhotos: (count) => `${count} more ${count === 1 ? "photo" : "photos"}`,
|
|
16
|
+
openPhoto: (name) => `Open ${name}`,
|
|
17
|
+
keyboardHint: "Use the arrow keys to move between photos.",
|
|
18
|
+
uploading: "Uploading",
|
|
19
|
+
uploadFailed: "Not uploaded",
|
|
20
|
+
retryUpload: (name) => `Try again: ${name}`,
|
|
21
|
+
};
|
|
22
|
+
export const PHOTO_VIEWER_STRINGS = {
|
|
23
|
+
close: "Close",
|
|
24
|
+
previous: "Previous photo",
|
|
25
|
+
next: "Next photo",
|
|
26
|
+
counter: (position, total) => `${position} / ${total}`,
|
|
27
|
+
position: (position, total) => `${position} of ${total}`,
|
|
28
|
+
loading: "Loading photo",
|
|
29
|
+
loadError: "The photo could not be loaded.",
|
|
30
|
+
retry: "Try again",
|
|
31
|
+
moreActions: "More actions",
|
|
32
|
+
showMore: "More",
|
|
33
|
+
showLess: "Less",
|
|
34
|
+
photoName: (position, total) => `Photo ${position} of ${total}`,
|
|
35
|
+
};
|
|
36
|
+
/** How many actions the viewer's bar shows before the rest go into a menu. */
|
|
37
|
+
export const MAX_BAR_ACTIONS = 3;
|
|
38
|
+
/** The actions shown in the bar, and those that go into the menu. */
|
|
39
|
+
export function splitActions(actions, max = MAX_BAR_ACTIONS) {
|
|
40
|
+
if (actions.length <= max)
|
|
41
|
+
return { bar: [...actions], menu: [] };
|
|
42
|
+
// One place in the bar goes to the menu's own button.
|
|
43
|
+
return { bar: actions.slice(0, max - 1), menu: actions.slice(max - 1) };
|
|
44
|
+
}
|
|
45
|
+
/** An index held inside a list of `count` photos; -1 for an empty list. */
|
|
46
|
+
export function clampIndex(index, count) {
|
|
47
|
+
if (count <= 0)
|
|
48
|
+
return -1;
|
|
49
|
+
if (!Number.isFinite(index))
|
|
50
|
+
return 0;
|
|
51
|
+
return Math.min(Math.max(Math.trunc(index), 0), count - 1);
|
|
52
|
+
}
|
|
53
|
+
/** What the grid shows of `total` photos under `max`, and how many the last tile stands for. */
|
|
54
|
+
export function visibleCount(total, max) {
|
|
55
|
+
if (max === undefined || !Number.isFinite(max) || max < 1 || total <= max) {
|
|
56
|
+
return { shown: total, hidden: 0 };
|
|
57
|
+
}
|
|
58
|
+
const shown = Math.floor(max);
|
|
59
|
+
return { shown, hidden: total - shown };
|
|
60
|
+
}
|
|
61
|
+
export const REST = { scale: 1, x: 0, y: 0 };
|
|
62
|
+
export const MIN_SCALE = 1;
|
|
63
|
+
export const MAX_SCALE = 4;
|
|
64
|
+
/** What a double tap zooms to. */
|
|
65
|
+
export const DOUBLE_TAP_SCALE = 2.5;
|
|
66
|
+
/** Under this a released pinch goes back to the fitted photo. */
|
|
67
|
+
const SNAP_TO_FIT = 1.02;
|
|
68
|
+
export const isZoomed = (transform) => transform.scale > 1.001;
|
|
69
|
+
/** The largest size a photo of `photo` px takes inside `view` without being cropped. */
|
|
70
|
+
export function fitSize(photo, view) {
|
|
71
|
+
if (photo.width <= 0 || photo.height <= 0 || view.width <= 0 || view.height <= 0) {
|
|
72
|
+
return { width: 0, height: 0 };
|
|
73
|
+
}
|
|
74
|
+
const ratio = Math.min(view.width / photo.width, view.height / photo.height);
|
|
75
|
+
return { width: photo.width * ratio, height: photo.height * ratio };
|
|
76
|
+
}
|
|
77
|
+
const clamp = (value, min, max) => Math.min(Math.max(value, min), max);
|
|
78
|
+
/**
|
|
79
|
+
* The transform with its pan held to the photo's edges: an edge of the photo
|
|
80
|
+
* never comes further in than the edge of the screen, and a side that is
|
|
81
|
+
* narrower than the screen stays centred. `fit` is the photo's size at scale 1.
|
|
82
|
+
*/
|
|
83
|
+
export function clampPan(transform, fit, view) {
|
|
84
|
+
const scale = clamp(transform.scale, MIN_SCALE, MAX_SCALE);
|
|
85
|
+
const maxX = Math.max(0, (fit.width * scale - view.width) / 2);
|
|
86
|
+
const maxY = Math.max(0, (fit.height * scale - view.height) / 2);
|
|
87
|
+
// `|| 0`: a clamp to a limit of zero can leave -0, which is not what "centred" should print as.
|
|
88
|
+
return {
|
|
89
|
+
scale,
|
|
90
|
+
x: clamp(transform.x, -maxX, maxX) || 0,
|
|
91
|
+
y: clamp(transform.y, -maxY, maxY) || 0,
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Zooms to `scale` so that the point of the photo under `point` stays under
|
|
96
|
+
* it. `point` is measured from the centre of the screen.
|
|
97
|
+
*/
|
|
98
|
+
export function zoomAbout(transform, scale, point, fit, view) {
|
|
99
|
+
const next = clamp(scale, MIN_SCALE, MAX_SCALE);
|
|
100
|
+
const ratio = next / transform.scale;
|
|
101
|
+
return clampPan({
|
|
102
|
+
scale: next,
|
|
103
|
+
x: point.x - (point.x - transform.x) * ratio,
|
|
104
|
+
y: point.y - (point.y - transform.y) * ratio,
|
|
105
|
+
}, fit, view);
|
|
106
|
+
}
|
|
107
|
+
export function pinchSample(first, second) {
|
|
108
|
+
return {
|
|
109
|
+
centre: { x: (first.x + second.x) / 2, y: (first.y + second.y) / 2 },
|
|
110
|
+
distance: Math.hypot(second.x - first.x, second.y - first.y),
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Where a pinch has taken the photo: scaled by how much the fingers have
|
|
115
|
+
* spread, about the point that was between them when it began, and moved with
|
|
116
|
+
* that point. Points are measured from the centre of the screen.
|
|
117
|
+
*/
|
|
118
|
+
export function pinchTransform(start, from, now, fit, view) {
|
|
119
|
+
if (from.distance <= 0)
|
|
120
|
+
return clampPan(start, fit, view);
|
|
121
|
+
const zoomed = zoomAbout(start, start.scale * (now.distance / from.distance), from.centre, fit, view);
|
|
122
|
+
return clampPan({
|
|
123
|
+
scale: zoomed.scale,
|
|
124
|
+
x: zoomed.x + (now.centre.x - from.centre.x),
|
|
125
|
+
y: zoomed.y + (now.centre.y - from.centre.y),
|
|
126
|
+
}, fit, view);
|
|
127
|
+
}
|
|
128
|
+
/** A pinch let go a hair above the fitted size is the fitted size. */
|
|
129
|
+
export function settleZoom(transform, fit, view) {
|
|
130
|
+
return transform.scale < SNAP_TO_FIT ? REST : clampPan(transform, fit, view);
|
|
131
|
+
}
|
|
132
|
+
/** A double tap: in to 2.5 times about the tap from the fitted photo, and back to fitted from any zoom. */
|
|
133
|
+
export function doubleTapTransform(transform, point, fit, view) {
|
|
134
|
+
return isZoomed(transform) ? REST : zoomAbout(transform, DOUBLE_TAP_SCALE, point, fit, view);
|
|
135
|
+
}
|
|
136
|
+
/** The photo moved by `delta` px, held to its edges. */
|
|
137
|
+
export function panBy(transform, delta, fit, view) {
|
|
138
|
+
return clampPan({ scale: transform.scale, x: transform.x + delta.x, y: transform.y + delta.y }, fit, view);
|
|
139
|
+
}
|
|
140
|
+
/** One step of the keyboard or the wheel: in or out by half again, about the centre. */
|
|
141
|
+
export const ZOOM_STEP = 1.5;
|
|
142
|
+
// ---------------------------------------------------------------------------
|
|
143
|
+
// Taps and swipes
|
|
144
|
+
// ---------------------------------------------------------------------------
|
|
145
|
+
/** Movement under this many px is a press, not a drag. */
|
|
146
|
+
export const TAP_SLOP = 8;
|
|
147
|
+
/** A press shorter than this is a tap, and two taps closer together than this are a double tap. */
|
|
148
|
+
export const TAP_MS = 300;
|
|
149
|
+
/** Two taps further apart than this are two taps. */
|
|
150
|
+
export const DOUBLE_TAP_RADIUS = 32;
|
|
151
|
+
export function isDoubleTap(previous, now) {
|
|
152
|
+
if (!previous)
|
|
153
|
+
return false;
|
|
154
|
+
return (now.time - previous.time <= TAP_MS &&
|
|
155
|
+
Math.hypot(now.point.x - previous.point.x, now.point.y - previous.point.y) <= DOUBLE_TAP_RADIUS);
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Which way a drag on the fitted photo is going, once it has gone far enough
|
|
159
|
+
* to tell: `x` turns the page, `down` closes, and null is not yet known. A
|
|
160
|
+
* drag upwards is neither, and stays null.
|
|
161
|
+
*/
|
|
162
|
+
export function dragAxis(delta, slop = TAP_SLOP) {
|
|
163
|
+
const horizontal = Math.abs(delta.x);
|
|
164
|
+
const vertical = Math.abs(delta.y);
|
|
165
|
+
if (Math.max(horizontal, vertical) < slop)
|
|
166
|
+
return null;
|
|
167
|
+
if (horizontal >= vertical)
|
|
168
|
+
return "x";
|
|
169
|
+
return delta.y > 0 ? "down" : null;
|
|
170
|
+
}
|
|
171
|
+
/** Part of the screen's width a slow swipe has to cross to turn the page. */
|
|
172
|
+
export const TURN_DISTANCE = 0.25;
|
|
173
|
+
/** Part of the screen's height a slow swipe down has to cross to close. */
|
|
174
|
+
export const CLOSE_DISTANCE = 0.2;
|
|
175
|
+
/**
|
|
176
|
+
* What a horizontal swipe does when the finger lifts. A flick decides by its
|
|
177
|
+
* direction; a slow one by how far it went. Swiping left shows the next
|
|
178
|
+
* photo, and the previous one in a right-to-left layout. At either end there
|
|
179
|
+
* is nothing to turn to.
|
|
180
|
+
*/
|
|
181
|
+
export function swipeTurn(options) {
|
|
182
|
+
const { distance, velocity, width, index, count, rtl = false, flick } = options;
|
|
183
|
+
let direction = 0;
|
|
184
|
+
if (Math.abs(velocity) >= flick)
|
|
185
|
+
direction = velocity < 0 ? 1 : -1;
|
|
186
|
+
else if (Math.abs(distance) >= width * TURN_DISTANCE)
|
|
187
|
+
direction = distance < 0 ? 1 : -1;
|
|
188
|
+
// A flick against the way the photo was dragged is a change of mind.
|
|
189
|
+
if (direction !== 0 && distance !== 0 && Math.sign(distance) === direction)
|
|
190
|
+
direction = 0;
|
|
191
|
+
if (rtl && direction !== 0)
|
|
192
|
+
direction = direction === 1 ? -1 : 1;
|
|
193
|
+
const target = index + direction;
|
|
194
|
+
return target < 0 || target >= count ? 0 : direction;
|
|
195
|
+
}
|
|
196
|
+
/** Whether a swipe down closes the viewer when the finger lifts. */
|
|
197
|
+
export function swipeCloses(options) {
|
|
198
|
+
const { distance, velocity, height, flick } = options;
|
|
199
|
+
if (distance <= 0)
|
|
200
|
+
return false;
|
|
201
|
+
return velocity >= flick || (distance >= height * CLOSE_DISTANCE && velocity > -flick);
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* How far a drag past the first or last photo moves it: a third of the
|
|
205
|
+
* finger's travel, so it gives but does not come away.
|
|
206
|
+
*/
|
|
207
|
+
export function resist(distance) {
|
|
208
|
+
return distance / 3;
|
|
209
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Action } from "svelte/action";
|
|
2
|
+
/**
|
|
3
|
+
* Where to render the node: `true` for `document.body`, an element, or a
|
|
4
|
+
* selector. `false` leaves the node where the template put it.
|
|
5
|
+
*/
|
|
6
|
+
export type PortalTarget = boolean | HTMLElement | string;
|
|
7
|
+
/**
|
|
8
|
+
* Moves an overlay out of its ancestors so none of them can trap it: a
|
|
9
|
+
* `transform`, `filter` or `contain` ancestor becomes the containing block of a
|
|
10
|
+
* `position: fixed` child, and an `overflow: hidden` one then clips it.
|
|
11
|
+
*
|
|
12
|
+
* SSR-safe by construction: actions never run on the server, so the markup is
|
|
13
|
+
* rendered in place and moved on mount. The node is removed on destroy, and
|
|
14
|
+
* Svelte's own teardown of a node that has already gone is a no-op.
|
|
15
|
+
*
|
|
16
|
+
* Put it on the single root element of an `{#if}` block. The theme is a `.dark`
|
|
17
|
+
* class on an ancestor, so a node portalled to `body` keeps it only when the
|
|
18
|
+
* class sits on `<html>` or `<body>`.
|
|
19
|
+
*
|
|
20
|
+
* Usage: `<div use:portal>` or `<div use:portal={enabled}>`.
|
|
21
|
+
*/
|
|
22
|
+
export declare const portal: Action<HTMLElement, PortalTarget | undefined>;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
function resolveTarget(target) {
|
|
2
|
+
if (target === false)
|
|
3
|
+
return null;
|
|
4
|
+
if (target === true)
|
|
5
|
+
return document.body;
|
|
6
|
+
if (typeof target === "string") {
|
|
7
|
+
return document.querySelector(target);
|
|
8
|
+
}
|
|
9
|
+
return target;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Moves an overlay out of its ancestors so none of them can trap it: a
|
|
13
|
+
* `transform`, `filter` or `contain` ancestor becomes the containing block of a
|
|
14
|
+
* `position: fixed` child, and an `overflow: hidden` one then clips it.
|
|
15
|
+
*
|
|
16
|
+
* SSR-safe by construction: actions never run on the server, so the markup is
|
|
17
|
+
* rendered in place and moved on mount. The node is removed on destroy, and
|
|
18
|
+
* Svelte's own teardown of a node that has already gone is a no-op.
|
|
19
|
+
*
|
|
20
|
+
* Put it on the single root element of an `{#if}` block. The theme is a `.dark`
|
|
21
|
+
* class on an ancestor, so a node portalled to `body` keeps it only when the
|
|
22
|
+
* class sits on `<html>` or `<body>`.
|
|
23
|
+
*
|
|
24
|
+
* Usage: `<div use:portal>` or `<div use:portal={enabled}>`.
|
|
25
|
+
*/
|
|
26
|
+
export const portal = (node, target = true) => {
|
|
27
|
+
const home = node.parentNode;
|
|
28
|
+
const homeNext = node.nextSibling;
|
|
29
|
+
function place(next) {
|
|
30
|
+
const destination = resolveTarget(next);
|
|
31
|
+
if (destination) {
|
|
32
|
+
if (node.parentNode !== destination)
|
|
33
|
+
destination.appendChild(node);
|
|
34
|
+
}
|
|
35
|
+
else if (next === false && home && node.parentNode !== home) {
|
|
36
|
+
// Back to where the template put it, if that place still exists.
|
|
37
|
+
home.insertBefore(node, homeNext?.parentNode === home ? homeNext : null);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
place(target);
|
|
41
|
+
return {
|
|
42
|
+
update(next = true) {
|
|
43
|
+
place(next);
|
|
44
|
+
},
|
|
45
|
+
destroy() {
|
|
46
|
+
if (node.parentNode !== home)
|
|
47
|
+
node.remove();
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** Types and pure helpers for `Progress`. Kept out of the component so they can be tested without a DOM. */
|
|
2
|
+
/** Every built-in string. Pass a partial object to `strings` to translate. */
|
|
3
|
+
export interface ProgressStrings {
|
|
4
|
+
/**
|
|
5
|
+
* The count of a segmented bar, as its accessible value and as the
|
|
6
|
+
* read-out beside the label: "4 of 19". `value` is the number of filled
|
|
7
|
+
* segments.
|
|
8
|
+
*/
|
|
9
|
+
valueText: (value: number, max: number) => string;
|
|
10
|
+
}
|
|
11
|
+
export declare const PROGRESS_STRINGS: ProgressStrings;
|
|
12
|
+
/** The fewest and the most segments a segmented bar is drawn with. */
|
|
13
|
+
export declare const SEGMENTS_MIN = 2;
|
|
14
|
+
export declare const SEGMENTS_MAX = 24;
|
|
15
|
+
/** Whether `max` can be drawn as separate segments: a whole number from 2 to 24. */
|
|
16
|
+
export declare function canSegment(max: number): boolean;
|
|
17
|
+
/** Filled segments: `value` rounded down, held within 0..max; 0 for something that is not a number. */
|
|
18
|
+
export declare function filledSegments(value: number, max: number): number;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** Types and pure helpers for `Progress`. Kept out of the component so they can be tested without a DOM. */
|
|
2
|
+
export const PROGRESS_STRINGS = {
|
|
3
|
+
valueText: (value, max) => `${value} of ${max}`,
|
|
4
|
+
};
|
|
5
|
+
/** The fewest and the most segments a segmented bar is drawn with. */
|
|
6
|
+
export const SEGMENTS_MIN = 2;
|
|
7
|
+
export const SEGMENTS_MAX = 24;
|
|
8
|
+
/** Whether `max` can be drawn as separate segments: a whole number from 2 to 24. */
|
|
9
|
+
export function canSegment(max) {
|
|
10
|
+
return Number.isInteger(max) && max >= SEGMENTS_MIN && max <= SEGMENTS_MAX;
|
|
11
|
+
}
|
|
12
|
+
/** Filled segments: `value` rounded down, held within 0..max; 0 for something that is not a number. */
|
|
13
|
+
export function filledSegments(value, max) {
|
|
14
|
+
if (!Number.isFinite(value))
|
|
15
|
+
return 0;
|
|
16
|
+
return Math.max(0, Math.min(max, Math.floor(value)));
|
|
17
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/** Public types and pure helpers for `PullToRefresh`. */
|
|
2
|
+
/** The words a `PullToRefresh` says by itself. */
|
|
3
|
+
export interface PullToRefreshStrings {
|
|
4
|
+
/** Shown while the list is being pulled, short of the threshold. */
|
|
5
|
+
pull: string;
|
|
6
|
+
/** Shown once letting go would refresh. */
|
|
7
|
+
release: string;
|
|
8
|
+
/** Shown, and announced, while the refresh runs. */
|
|
9
|
+
refreshing: string;
|
|
10
|
+
/** Announced when it has finished. */
|
|
11
|
+
done: string;
|
|
12
|
+
/** The button that refreshes without the gesture. */
|
|
13
|
+
refresh: string;
|
|
14
|
+
}
|
|
15
|
+
export declare const DEFAULT_PULL_TO_REFRESH_STRINGS: PullToRefreshStrings;
|
|
16
|
+
/**
|
|
17
|
+
* How far the indicator has come out for a finger that has travelled
|
|
18
|
+
* `distance` px: half as far, so the list feels held, and never more than one
|
|
19
|
+
* and a half times the threshold.
|
|
20
|
+
*/
|
|
21
|
+
export declare function pullDistance(distance: number, threshold: number): number;
|
|
22
|
+
/**
|
|
23
|
+
* What scrolls the element: its nearest ancestor that scrolls on the block
|
|
24
|
+
* axis, or the page.
|
|
25
|
+
*/
|
|
26
|
+
export declare function scrollContainerOf(element: HTMLElement): HTMLElement;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/** Public types and pure helpers for `PullToRefresh`. */
|
|
2
|
+
export const DEFAULT_PULL_TO_REFRESH_STRINGS = {
|
|
3
|
+
pull: "Pull to refresh",
|
|
4
|
+
release: "Release to refresh",
|
|
5
|
+
refreshing: "Refreshing",
|
|
6
|
+
done: "Updated",
|
|
7
|
+
refresh: "Refresh",
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* How far the indicator has come out for a finger that has travelled
|
|
11
|
+
* `distance` px: half as far, so the list feels held, and never more than one
|
|
12
|
+
* and a half times the threshold.
|
|
13
|
+
*/
|
|
14
|
+
export function pullDistance(distance, threshold) {
|
|
15
|
+
return Math.max(0, Math.min(distance / 2, threshold * 1.5));
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* What scrolls the element: its nearest ancestor that scrolls on the block
|
|
19
|
+
* axis, or the page.
|
|
20
|
+
*/
|
|
21
|
+
export function scrollContainerOf(element) {
|
|
22
|
+
for (let parent = element.parentElement; parent; parent = parent.parentElement) {
|
|
23
|
+
if (parent === document.body || parent === document.documentElement)
|
|
24
|
+
break;
|
|
25
|
+
const overflow = getComputedStyle(parent).overflowY;
|
|
26
|
+
if (overflow === "auto" || overflow === "scroll" || overflow === "overlay")
|
|
27
|
+
return parent;
|
|
28
|
+
}
|
|
29
|
+
return document.scrollingElement ?? document.documentElement;
|
|
30
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where a key moves the selection in a radio group laid out in a row, as
|
|
3
|
+
* Rating and SegmentedControl are. Kept out of the components so it can be
|
|
4
|
+
* tested without a DOM.
|
|
5
|
+
*
|
|
6
|
+
* It is the native radio contract: Right and Down go to the next option, Left
|
|
7
|
+
* and Up to the previous one, both wrap, and Left and Right swap in a
|
|
8
|
+
* right-to-left layout.
|
|
9
|
+
*
|
|
10
|
+
* `current` is the option that has focus, which is not always the selected
|
|
11
|
+
* one: a screen reader's cursor can put focus on any radio, and the keys then
|
|
12
|
+
* move from where the user is. It is -1 when focus is on none of them: the
|
|
13
|
+
* next option is then the first, and the previous one the last.
|
|
14
|
+
*
|
|
15
|
+
* `hasSelection` is false while the group is empty. A forward key then selects
|
|
16
|
+
* the focused option itself instead of stepping over it, so Right on an empty
|
|
17
|
+
* rating gives one star, not two.
|
|
18
|
+
*
|
|
19
|
+
* Returns -1 for a key that is not a navigation key, or when there is nothing
|
|
20
|
+
* to move to.
|
|
21
|
+
*/
|
|
22
|
+
export declare function radioKeyIndex(key: string, current: number, count: number, rtl?: boolean, hasSelection?: boolean): number;
|
|
23
|
+
/** Whether `node` is laid out right to left. */
|
|
24
|
+
export declare function isRtl(node: Element): boolean;
|