@thomasfosterau/components 0.0.0 → 0.2.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/LICENSE +21 -0
- package/README.md +241 -56
- package/dist/canvas/VectorCanvas.svelte +320 -0
- package/dist/canvas/VectorCanvas.svelte.d.ts +105 -0
- package/dist/canvas/history.d.ts +105 -0
- package/dist/canvas/history.js +147 -0
- package/dist/canvas/index.d.ts +15 -0
- package/dist/canvas/index.js +14 -0
- package/dist/canvas/types.d.ts +91 -0
- package/dist/canvas/types.js +13 -0
- package/dist/canvas/utils.d.ts +66 -0
- package/dist/canvas/utils.js +114 -0
- package/dist/charts/Chart.svelte +300 -0
- package/dist/charts/Chart.svelte.d.ts +50 -0
- package/dist/charts/index.d.ts +11 -0
- package/dist/charts/index.js +10 -0
- package/dist/charts/types.d.ts +28 -0
- package/dist/charts/types.js +6 -0
- package/dist/citations/BookCitation.svelte +53 -0
- package/dist/citations/BookCitation.svelte.d.ts +41 -0
- package/dist/citations/ChapterCitation.svelte +38 -0
- package/dist/citations/ChapterCitation.svelte.d.ts +50 -0
- package/dist/citations/Citation.svelte +47 -0
- package/dist/citations/Citation.svelte.d.ts +24 -0
- package/dist/citations/CreditList.svelte +69 -0
- package/dist/citations/CreditList.svelte.d.ts +47 -0
- package/dist/citations/DOILink.svelte +28 -0
- package/dist/citations/DOILink.svelte.d.ts +19 -0
- package/dist/citations/Footnote.svelte +39 -0
- package/dist/citations/Footnote.svelte.d.ts +17 -0
- package/dist/citations/FootnoteList.svelte +36 -0
- package/dist/citations/FootnoteList.svelte.d.ts +21 -0
- package/dist/citations/ISBNLink.svelte +29 -0
- package/dist/citations/ISBNLink.svelte.d.ts +19 -0
- package/dist/citations/ISSNLink.svelte +29 -0
- package/dist/citations/ISSNLink.svelte.d.ts +19 -0
- package/dist/citations/Publisher.svelte +34 -0
- package/dist/citations/Publisher.svelte.d.ts +14 -0
- package/dist/citations/ReferenceList.svelte +53 -0
- package/dist/citations/ReferenceList.svelte.d.ts +21 -0
- package/dist/citations/ReportCitation.svelte +41 -0
- package/dist/citations/ReportCitation.svelte.d.ts +36 -0
- package/dist/citations/ScholarlyArticleCitation.svelte +64 -0
- package/dist/citations/ScholarlyArticleCitation.svelte.d.ts +41 -0
- package/dist/citations/ThesisCitation.svelte +35 -0
- package/dist/citations/ThesisCitation.svelte.d.ts +29 -0
- package/dist/citations/bibliography.svelte.d.ts +55 -0
- package/dist/citations/bibliography.svelte.js +78 -0
- package/dist/citations/citation.d.ts +71 -0
- package/dist/citations/citation.js +121 -0
- package/dist/citations/csl.d.ts +102 -0
- package/dist/citations/csl.js +20 -0
- package/dist/citations/index.d.ts +31 -0
- package/dist/citations/index.js +36 -0
- package/dist/citations/list-format.d.ts +34 -0
- package/dist/citations/list-format.js +40 -0
- package/dist/context.svelte.d.ts +46 -0
- package/dist/context.svelte.js +51 -0
- package/dist/data/ChatBubble.svelte +48 -0
- package/dist/data/ChatBubble.svelte.d.ts +33 -0
- package/dist/data/DataGrid.svelte +150 -0
- package/dist/data/DataGrid.svelte.d.ts +118 -0
- package/dist/data/DescriptionList.svelte +53 -0
- package/dist/data/DescriptionList.svelte.d.ts +26 -0
- package/dist/data/DescriptionRow.svelte +56 -0
- package/dist/data/DescriptionRow.svelte.d.ts +21 -0
- package/dist/data/DiffText.svelte +29 -0
- package/dist/data/DiffText.svelte.d.ts +19 -0
- package/dist/data/ItemList.svelte +80 -0
- package/dist/data/ItemList.svelte.d.ts +52 -0
- package/dist/data/LinkListItem.svelte +46 -0
- package/dist/data/LinkListItem.svelte.d.ts +21 -0
- package/dist/data/MessageThread.svelte +29 -0
- package/dist/data/MessageThread.svelte.d.ts +17 -0
- package/dist/data/Pagination.svelte +136 -0
- package/dist/data/Pagination.svelte.d.ts +79 -0
- package/dist/data/PaginationFooter.svelte +42 -0
- package/dist/data/PaginationFooter.svelte.d.ts +61 -0
- package/dist/data/ResultCount.svelte +27 -0
- package/dist/data/ResultCount.svelte.d.ts +18 -0
- package/dist/data/Table.svelte +151 -0
- package/dist/data/Table.svelte.d.ts +75 -0
- package/dist/data/TreeList.svelte +41 -0
- package/dist/data/TreeList.svelte.d.ts +17 -0
- package/dist/data/TreeListItem.svelte +29 -0
- package/dist/data/TreeListItem.svelte.d.ts +10 -0
- package/dist/data/description-context.d.ts +39 -0
- package/dist/data/description-context.js +36 -0
- package/dist/data/diff.d.ts +14 -0
- package/dist/data/diff.js +10 -0
- package/dist/data/index.d.ts +37 -0
- package/dist/data/index.js +37 -0
- package/dist/data/list-item.d.ts +30 -0
- package/dist/data/list-item.js +19 -0
- package/dist/data/pagination.d.ts +81 -0
- package/dist/data/pagination.js +79 -0
- package/dist/data/table-types.d.ts +71 -0
- package/dist/data/table-types.js +35 -0
- package/dist/feedback/ConfirmDialog.svelte +79 -0
- package/dist/feedback/ConfirmDialog.svelte.d.ts +82 -0
- package/dist/feedback/Dialog.svelte +47 -0
- package/dist/feedback/Dialog.svelte.d.ts +36 -0
- package/dist/feedback/DialogFrame.svelte +64 -0
- package/dist/feedback/DialogFrame.svelte.d.ts +23 -0
- package/dist/feedback/Drawer.svelte +43 -0
- package/dist/feedback/Drawer.svelte.d.ts +43 -0
- package/dist/feedback/LoadingBoundary.svelte +61 -0
- package/dist/feedback/LoadingBoundary.svelte.d.ts +34 -0
- package/dist/feedback/ProgressBar.svelte +46 -0
- package/dist/feedback/ProgressBar.svelte.d.ts +28 -0
- package/dist/feedback/SegmentBar.svelte +83 -0
- package/dist/feedback/SegmentBar.svelte.d.ts +37 -0
- package/dist/feedback/StatTile.svelte +77 -0
- package/dist/feedback/StatTile.svelte.d.ts +50 -0
- package/dist/feedback/Stats.svelte +18 -0
- package/dist/feedback/Stats.svelte.d.ts +16 -0
- package/dist/feedback/Steps.svelte +72 -0
- package/dist/feedback/Steps.svelte.d.ts +61 -0
- package/dist/feedback/Timeline.svelte +86 -0
- package/dist/feedback/Timeline.svelte.d.ts +55 -0
- package/dist/feedback/Toaster.svelte +78 -0
- package/dist/feedback/Toaster.svelte.d.ts +32 -0
- package/dist/feedback/index.d.ts +34 -0
- package/dist/feedback/index.js +29 -0
- package/dist/feedback/sizes.d.ts +41 -0
- package/dist/feedback/sizes.js +69 -0
- package/dist/feedback/toaster.d.ts +48 -0
- package/dist/feedback/toaster.js +29 -0
- package/dist/fields/Calendar.svelte +60 -0
- package/dist/fields/Calendar.svelte.d.ts +11 -0
- package/dist/fields/CalendarMonths.svelte +86 -0
- package/dist/fields/CalendarMonths.svelte.d.ts +30 -0
- package/dist/fields/Checkbox.svelte +33 -0
- package/dist/fields/Checkbox.svelte.d.ts +30 -0
- package/dist/fields/CheckboxGroup.svelte +41 -0
- package/dist/fields/CheckboxGroup.svelte.d.ts +40 -0
- package/dist/fields/Combobox.svelte +229 -0
- package/dist/fields/Combobox.svelte.d.ts +133 -0
- package/dist/fields/DateField.svelte +37 -0
- package/dist/fields/DateField.svelte.d.ts +20 -0
- package/dist/fields/DateInput.svelte +31 -0
- package/dist/fields/DateInput.svelte.d.ts +35 -0
- package/dist/fields/DatePicker.svelte +47 -0
- package/dist/fields/DatePicker.svelte.d.ts +25 -0
- package/dist/fields/DateRangePicker.svelte +70 -0
- package/dist/fields/DateRangePicker.svelte.d.ts +43 -0
- package/dist/fields/Dropzone.svelte +232 -0
- package/dist/fields/Dropzone.svelte.d.ts +103 -0
- package/dist/fields/FieldErrors.svelte +30 -0
- package/dist/fields/FieldErrors.svelte.d.ts +11 -0
- package/dist/fields/Fieldset.svelte +53 -0
- package/dist/fields/Fieldset.svelte.d.ts +27 -0
- package/dist/fields/FileInput.svelte +68 -0
- package/dist/fields/FileInput.svelte.d.ts +39 -0
- package/dist/fields/FormField.svelte +78 -0
- package/dist/fields/FormField.svelte.d.ts +29 -0
- package/dist/fields/ImageInput.svelte +87 -0
- package/dist/fields/ImageInput.svelte.d.ts +45 -0
- package/dist/fields/MultiSelect.svelte +112 -0
- package/dist/fields/MultiSelect.svelte.d.ts +75 -0
- package/dist/fields/NumberField.svelte +190 -0
- package/dist/fields/NumberField.svelte.d.ts +76 -0
- package/dist/fields/PasswordInput.svelte +95 -0
- package/dist/fields/PasswordInput.svelte.d.ts +58 -0
- package/dist/fields/PickerPopover.svelte +47 -0
- package/dist/fields/PickerPopover.svelte.d.ts +16 -0
- package/dist/fields/PinInput.svelte +83 -0
- package/dist/fields/PinInput.svelte.d.ts +66 -0
- package/dist/fields/PushToggle.svelte +93 -0
- package/dist/fields/PushToggle.svelte.d.ts +55 -0
- package/dist/fields/RadioGroup.svelte +88 -0
- package/dist/fields/RadioGroup.svelte.d.ts +41 -0
- package/dist/fields/RangeCalendar.svelte +51 -0
- package/dist/fields/RangeCalendar.svelte.d.ts +23 -0
- package/dist/fields/Rating.svelte +127 -0
- package/dist/fields/Rating.svelte.d.ts +86 -0
- package/dist/fields/SearchInput.svelte +58 -0
- package/dist/fields/SearchInput.svelte.d.ts +33 -0
- package/dist/fields/SegmentGroup.svelte +91 -0
- package/dist/fields/SegmentGroup.svelte.d.ts +20 -0
- package/dist/fields/Select.svelte +36 -0
- package/dist/fields/Select.svelte.d.ts +35 -0
- package/dist/fields/Slider.svelte +194 -0
- package/dist/fields/Slider.svelte.d.ts +100 -0
- package/dist/fields/TagsInput.svelte +256 -0
- package/dist/fields/TagsInput.svelte.d.ts +102 -0
- package/dist/fields/TextInput.svelte +26 -0
- package/dist/fields/TextInput.svelte.d.ts +36 -0
- package/dist/fields/Textarea.svelte +22 -0
- package/dist/fields/Textarea.svelte.d.ts +31 -0
- package/dist/fields/TimeField.svelte +30 -0
- package/dist/fields/TimeField.svelte.d.ts +19 -0
- package/dist/fields/Toggle.svelte +72 -0
- package/dist/fields/Toggle.svelte.d.ts +38 -0
- package/dist/fields/VideoInput.svelte +35 -0
- package/dist/fields/VideoInput.svelte.d.ts +46 -0
- package/dist/fields/calendar-props.d.ts +119 -0
- package/dist/fields/calendar-props.js +51 -0
- package/dist/fields/dates.d.ts +28 -0
- package/dist/fields/dates.js +26 -0
- package/dist/fields/field-types.d.ts +80 -0
- package/dist/fields/field-types.js +92 -0
- package/dist/fields/file-validation.d.ts +30 -0
- package/dist/fields/file-validation.js +51 -0
- package/dist/fields/index.d.ts +43 -0
- package/dist/fields/index.js +42 -0
- package/dist/fields/latest-search.svelte.d.ts +38 -0
- package/dist/fields/latest-search.svelte.js +85 -0
- package/dist/fields/number-format.d.ts +52 -0
- package/dist/fields/number-format.js +89 -0
- package/dist/fields/segmented-field.d.ts +128 -0
- package/dist/fields/segmented-field.js +52 -0
- package/dist/fields/slider-keys.d.ts +21 -0
- package/dist/fields/slider-keys.js +37 -0
- package/dist/formatting/Countdown.svelte +110 -0
- package/dist/formatting/Countdown.svelte.d.ts +35 -0
- package/dist/formatting/DateTime.svelte +35 -0
- package/dist/formatting/DateTime.svelte.d.ts +26 -0
- package/dist/formatting/Duration.svelte +18 -0
- package/dist/formatting/Duration.svelte.d.ts +20 -0
- package/dist/formatting/FormatList.svelte +31 -0
- package/dist/formatting/FormatList.svelte.d.ts +46 -0
- package/dist/formatting/Highlight.svelte +51 -0
- package/dist/formatting/Highlight.svelte.d.ts +19 -0
- package/dist/formatting/Number.svelte +35 -0
- package/dist/formatting/Number.svelte.d.ts +43 -0
- package/dist/formatting/RelativeTime.svelte +69 -0
- package/dist/formatting/RelativeTime.svelte.d.ts +26 -0
- package/dist/formatting/Year.svelte +39 -0
- package/dist/formatting/Year.svelte.d.ts +21 -0
- package/dist/formatting/duration.d.ts +44 -0
- package/dist/formatting/duration.js +125 -0
- package/dist/formatting/index.d.ts +15 -0
- package/dist/formatting/index.js +17 -0
- package/dist/forms/EntityForm.svelte +185 -0
- package/dist/forms/EntityForm.svelte.d.ts +66 -0
- package/dist/forms/FormActions.svelte +29 -0
- package/dist/forms/FormActions.svelte.d.ts +37 -0
- package/dist/forms/FormErrors.svelte +21 -0
- package/dist/forms/FormErrors.svelte.d.ts +16 -0
- package/dist/forms/HiddenField.svelte +22 -0
- package/dist/forms/HiddenField.svelte.d.ts +11 -0
- package/dist/forms/SearchForm.svelte +43 -0
- package/dist/forms/SearchForm.svelte.d.ts +36 -0
- package/dist/forms/entity-form.d.ts +12 -0
- package/dist/forms/entity-form.js +12 -0
- package/dist/forms/index.d.ts +14 -0
- package/dist/forms/index.js +14 -0
- package/dist/hotkeys/HotkeyBadge.svelte +39 -0
- package/dist/hotkeys/HotkeyBadge.svelte.d.ts +25 -0
- package/dist/hotkeys/HotkeyHelpDialog.svelte +68 -0
- package/dist/hotkeys/HotkeyHelpDialog.svelte.d.ts +35 -0
- package/dist/hotkeys/HotkeyProvider.svelte +92 -0
- package/dist/hotkeys/HotkeyProvider.svelte.d.ts +4 -0
- package/dist/hotkeys/context.svelte.d.ts +47 -0
- package/dist/hotkeys/context.svelte.js +72 -0
- package/dist/hotkeys/index.d.ts +28 -0
- package/dist/hotkeys/index.js +27 -0
- package/dist/hotkeys/match.d.ts +65 -0
- package/dist/hotkeys/match.js +135 -0
- package/dist/hotkeys/registry.svelte.d.ts +55 -0
- package/dist/hotkeys/registry.svelte.js +110 -0
- package/dist/hotkeys/types.d.ts +74 -0
- package/dist/hotkeys/types.js +18 -0
- package/dist/index.d.ts +37 -0
- package/dist/index.js +37 -0
- package/dist/infobox/Infobox.svelte +79 -0
- package/dist/infobox/Infobox.svelte.d.ts +33 -0
- package/dist/infobox/InfoboxHeader.svelte +35 -0
- package/dist/infobox/InfoboxHeader.svelte.d.ts +18 -0
- package/dist/infobox/InfoboxImage.svelte +38 -0
- package/dist/infobox/InfoboxImage.svelte.d.ts +21 -0
- package/dist/infobox/InfoboxRow.svelte +50 -0
- package/dist/infobox/InfoboxRow.svelte.d.ts +25 -0
- package/dist/infobox/InfoboxSection.svelte +24 -0
- package/dist/infobox/InfoboxSection.svelte.d.ts +12 -0
- package/dist/infobox/index.d.ts +21 -0
- package/dist/infobox/index.js +20 -0
- package/dist/infobox/types.d.ts +86 -0
- package/dist/infobox/types.js +27 -0
- package/dist/layout/AppShell.svelte +50 -0
- package/dist/layout/AppShell.svelte.d.ts +28 -0
- package/dist/layout/Breadcrumbs.svelte +52 -0
- package/dist/layout/Breadcrumbs.svelte.d.ts +18 -0
- package/dist/layout/Cluster.svelte +28 -0
- package/dist/layout/Cluster.svelte.d.ts +27 -0
- package/dist/layout/DetailLayout.svelte +50 -0
- package/dist/layout/DetailLayout.svelte.d.ts +19 -0
- package/dist/layout/FilterBar.svelte +40 -0
- package/dist/layout/FilterBar.svelte.d.ts +12 -0
- package/dist/layout/Fits.svelte +27 -0
- package/dist/layout/Fits.svelte.d.ts +13 -0
- package/dist/layout/Flow.svelte +46 -0
- package/dist/layout/Flow.svelte.d.ts +16 -0
- package/dist/layout/Footer.svelte +32 -0
- package/dist/layout/Footer.svelte.d.ts +12 -0
- package/dist/layout/Grid.svelte +23 -0
- package/dist/layout/Grid.svelte.d.ts +26 -0
- package/dist/layout/HStack.svelte +12 -0
- package/dist/layout/HStack.svelte.d.ts +34 -0
- package/dist/layout/Hero.svelte +76 -0
- package/dist/layout/Hero.svelte.d.ts +36 -0
- package/dist/layout/Main.svelte +30 -0
- package/dist/layout/Main.svelte.d.ts +15 -0
- package/dist/layout/Navbar.svelte +68 -0
- package/dist/layout/Navbar.svelte.d.ts +31 -0
- package/dist/layout/PageHeader.svelte +77 -0
- package/dist/layout/PageHeader.svelte.d.ts +33 -0
- package/dist/layout/Section.svelte +72 -0
- package/dist/layout/Section.svelte.d.ts +40 -0
- package/dist/layout/Sidebar.svelte +54 -0
- package/dist/layout/Sidebar.svelte.d.ts +27 -0
- package/dist/layout/Spacer.svelte +12 -0
- package/dist/layout/Spacer.svelte.d.ts +6 -0
- package/dist/layout/Tabs.svelte +85 -0
- package/dist/layout/Tabs.svelte.d.ts +42 -0
- package/dist/layout/VStack.svelte +12 -0
- package/dist/layout/VStack.svelte.d.ts +29 -0
- package/dist/layout/index.d.ts +38 -0
- package/dist/layout/index.js +38 -0
- package/dist/layout/space.d.ts +44 -0
- package/dist/layout/space.js +76 -0
- package/dist/layout/types.d.ts +52 -0
- package/dist/layout/types.js +27 -0
- package/dist/links/ContextLinks.svelte +28 -0
- package/dist/links/ContextLinks.svelte.d.ts +20 -0
- package/dist/links/EmailLink.svelte +26 -0
- package/dist/links/EmailLink.svelte.d.ts +20 -0
- package/dist/links/index.d.ts +7 -0
- package/dist/links/index.js +7 -0
- package/dist/media/Figure.svelte +26 -0
- package/dist/media/Figure.svelte.d.ts +12 -0
- package/dist/media/Image.svelte +76 -0
- package/dist/media/Image.svelte.d.ts +41 -0
- package/dist/media/Video.svelte +65 -0
- package/dist/media/Video.svelte.d.ts +29 -0
- package/dist/media/image-dimensions.d.ts +28 -0
- package/dist/media/image-dimensions.js +34 -0
- package/dist/media/index.d.ts +10 -0
- package/dist/media/index.js +10 -0
- package/dist/search/CommandPalette.svelte +257 -0
- package/dist/search/CommandPalette.svelte.d.ts +59 -0
- package/dist/search/index.d.ts +13 -0
- package/dist/search/index.js +13 -0
- package/dist/search/types.d.ts +40 -0
- package/dist/search/types.js +20 -0
- package/dist/seo/Head.svelte +190 -0
- package/dist/seo/Head.svelte.d.ts +86 -0
- package/dist/seo/JsonLd.svelte +30 -0
- package/dist/seo/JsonLd.svelte.d.ts +20 -0
- package/dist/seo/index.d.ts +18 -0
- package/dist/seo/index.js +17 -0
- package/dist/seo/json-ld.d.ts +33 -0
- package/dist/seo/json-ld.js +29 -0
- package/dist/seo/og-image.d.ts +72 -0
- package/dist/seo/og-image.js +82 -0
- package/dist/seo/types.d.ts +43 -0
- package/dist/seo/types.js +6 -0
- package/dist/theme.css +161 -0
- package/dist/tips/PopoverTip.svelte +80 -0
- package/dist/tips/PopoverTip.svelte.d.ts +33 -0
- package/dist/tips/Tip.svelte +91 -0
- package/dist/tips/Tip.svelte.d.ts +25 -0
- package/dist/tips/index.d.ts +15 -0
- package/dist/tips/index.js +14 -0
- package/dist/tips/tip-stack.d.ts +26 -0
- package/dist/tips/tip-stack.js +37 -0
- package/dist/tips/tip-store.svelte.d.ts +75 -0
- package/dist/tips/tip-store.svelte.js +158 -0
- package/dist/tips/types.d.ts +46 -0
- package/dist/tips/types.js +6 -0
- package/dist/ui/Accordion.svelte +75 -0
- package/dist/ui/Accordion.svelte.d.ts +50 -0
- package/dist/ui/AccordionItem.svelte +73 -0
- package/dist/ui/AccordionItem.svelte.d.ts +18 -0
- package/dist/ui/Alert.svelte +61 -0
- package/dist/ui/Alert.svelte.d.ts +37 -0
- package/dist/ui/Badge.svelte +39 -0
- package/dist/ui/Badge.svelte.d.ts +32 -0
- package/dist/ui/Button.svelte +44 -0
- package/dist/ui/Button.svelte.d.ts +29 -0
- package/dist/ui/ButtonGroup.svelte +24 -0
- package/dist/ui/ButtonGroup.svelte.d.ts +17 -0
- package/dist/ui/Card.svelte +49 -0
- package/dist/ui/Card.svelte.d.ts +44 -0
- package/dist/ui/Chip.svelte +58 -0
- package/dist/ui/Chip.svelte.d.ts +21 -0
- package/dist/ui/ConfirmButton.svelte +75 -0
- package/dist/ui/ConfirmButton.svelte.d.ts +48 -0
- package/dist/ui/ContextMenu.svelte +75 -0
- package/dist/ui/ContextMenu.svelte.d.ts +25 -0
- package/dist/ui/Disclosure.svelte +46 -0
- package/dist/ui/Disclosure.svelte.d.ts +22 -0
- package/dist/ui/Divider.svelte +47 -0
- package/dist/ui/Divider.svelte.d.ts +28 -0
- package/dist/ui/DropdownMenu.svelte +44 -0
- package/dist/ui/DropdownMenu.svelte.d.ts +30 -0
- package/dist/ui/EmptyState.svelte +37 -0
- package/dist/ui/EmptyState.svelte.d.ts +22 -0
- package/dist/ui/ExternalLink.svelte +38 -0
- package/dist/ui/ExternalLink.svelte.d.ts +34 -0
- package/dist/ui/Heading.svelte +58 -0
- package/dist/ui/Heading.svelte.d.ts +22 -0
- package/dist/ui/Link.svelte +34 -0
- package/dist/ui/Link.svelte.d.ts +20 -0
- package/dist/ui/LinkButton.svelte +51 -0
- package/dist/ui/LinkButton.svelte.d.ts +33 -0
- package/dist/ui/Menu.svelte +24 -0
- package/dist/ui/Menu.svelte.d.ts +13 -0
- package/dist/ui/MenuCheckboxItem.svelte +33 -0
- package/dist/ui/MenuCheckboxItem.svelte.d.ts +20 -0
- package/dist/ui/MenuItem.svelte +73 -0
- package/dist/ui/MenuItem.svelte.d.ts +21 -0
- package/dist/ui/MenuRadioGroup.svelte +25 -0
- package/dist/ui/MenuRadioGroup.svelte.d.ts +20 -0
- package/dist/ui/MenuRadioItem.svelte +20 -0
- package/dist/ui/MenuRadioItem.svelte.d.ts +15 -0
- package/dist/ui/MenuSeparator.svelte +27 -0
- package/dist/ui/MenuSeparator.svelte.d.ts +8 -0
- package/dist/ui/MenuSub.svelte +24 -0
- package/dist/ui/MenuSub.svelte.d.ts +15 -0
- package/dist/ui/Popover.svelte +63 -0
- package/dist/ui/Popover.svelte.d.ts +40 -0
- package/dist/ui/ShareButton.svelte +64 -0
- package/dist/ui/ShareButton.svelte.d.ts +39 -0
- package/dist/ui/Skeleton.svelte +43 -0
- package/dist/ui/Skeleton.svelte.d.ts +22 -0
- package/dist/ui/Spinner.svelte +41 -0
- package/dist/ui/Spinner.svelte.d.ts +35 -0
- package/dist/ui/Stack.svelte +36 -0
- package/dist/ui/Stack.svelte.d.ts +48 -0
- package/dist/ui/ThemeToggle.svelte +65 -0
- package/dist/ui/ThemeToggle.svelte.d.ts +24 -0
- package/dist/ui/ToggleButton.svelte +58 -0
- package/dist/ui/ToggleButton.svelte.d.ts +45 -0
- package/dist/ui/ToggleGroup.svelte +142 -0
- package/dist/ui/ToggleGroup.svelte.d.ts +86 -0
- package/dist/ui/Toolbar.svelte +40 -0
- package/dist/ui/Toolbar.svelte.d.ts +20 -0
- package/dist/ui/ToolbarButton.svelte +29 -0
- package/dist/ui/ToolbarButton.svelte.d.ts +21 -0
- package/dist/ui/ToolbarLink.svelte +21 -0
- package/dist/ui/ToolbarLink.svelte.d.ts +12 -0
- package/dist/ui/ToolbarSeparator.svelte +22 -0
- package/dist/ui/ToolbarSeparator.svelte.d.ts +12 -0
- package/dist/ui/ToolbarToggleGroup.svelte +66 -0
- package/dist/ui/ToolbarToggleGroup.svelte.d.ts +52 -0
- package/dist/ui/Tooltip.svelte +54 -0
- package/dist/ui/Tooltip.svelte.d.ts +35 -0
- package/dist/ui/VisuallyHidden.svelte +23 -0
- package/dist/ui/VisuallyHidden.svelte.d.ts +10 -0
- package/dist/ui/accordion-context.d.ts +26 -0
- package/dist/ui/accordion-context.js +23 -0
- package/dist/ui/colour-token.d.ts +41 -0
- package/dist/ui/colour-token.js +49 -0
- package/dist/ui/context-menu.d.ts +13 -0
- package/dist/ui/context-menu.js +13 -0
- package/dist/ui/index.d.ts +63 -0
- package/dist/ui/index.js +62 -0
- package/dist/ui/menu-context.d.ts +20 -0
- package/dist/ui/menu-context.js +22 -0
- package/dist/ui/menu-parts/CheckboxItemPart.svelte +26 -0
- package/dist/ui/menu-parts/CheckboxItemPart.svelte.d.ts +5 -0
- package/dist/ui/menu-parts/ItemPart.svelte +29 -0
- package/dist/ui/menu-parts/ItemPart.svelte.d.ts +5 -0
- package/dist/ui/menu-parts/RadioGroupPart.svelte +24 -0
- package/dist/ui/menu-parts/RadioGroupPart.svelte.d.ts +5 -0
- package/dist/ui/menu-parts/RadioItemPart.svelte +22 -0
- package/dist/ui/menu-parts/RadioItemPart.svelte.d.ts +5 -0
- package/dist/ui/menu-parts/SeparatorPart.svelte +16 -0
- package/dist/ui/menu-parts/SeparatorPart.svelte.d.ts +5 -0
- package/dist/ui/menu-parts/SubPart.svelte +28 -0
- package/dist/ui/menu-parts/SubPart.svelte.d.ts +5 -0
- package/dist/ui/menu-parts/menu-parts.d.ts +104 -0
- package/dist/ui/menu-parts/menu-parts.js +31 -0
- package/dist/ui/menu-parts/parts.d.ts +12 -0
- package/dist/ui/menu-parts/parts.js +27 -0
- package/dist/ui/slug.d.ts +19 -0
- package/dist/ui/slug.js +25 -0
- package/dist/ui/toggle-classes.d.ts +39 -0
- package/dist/ui/toggle-classes.js +36 -0
- package/dist/ui/tones.d.ts +103 -0
- package/dist/ui/tones.js +240 -0
- package/package.json +41 -25
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What `DateField` and `TimeField` share when handing their props to bits-ui:
|
|
3
|
+
* the props themselves, and the split between the bits-ui root and the
|
|
4
|
+
* segment group `SegmentGroup` renders.
|
|
5
|
+
*
|
|
6
|
+
* @module
|
|
7
|
+
*/
|
|
8
|
+
import type { CalendarDateTime, DateValue, Time, ZonedDateTime } from '@internationalized/date';
|
|
9
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
10
|
+
import type { FieldSize } from './field-types.ts';
|
|
11
|
+
/** A time of day, alone or on a date: what a `TimeField` holds. */
|
|
12
|
+
export type TimeValue = Time | CalendarDateTime | ZonedDateTime;
|
|
13
|
+
/** The props `DateField` and `TimeField` share: everything but the value, its bounds and the granularity. */
|
|
14
|
+
export interface SegmentedFieldProps extends Omit<HTMLAttributes<HTMLDivElement>, 'placeholder' | 'children' | 'id'> {
|
|
15
|
+
/** Force a 12- or 24-hour clock; omitted, the locale's. */
|
|
16
|
+
hourCycle?: 12 | 24 | undefined;
|
|
17
|
+
/** Form field name: bits-ui renders a hidden input with the ISO value. */
|
|
18
|
+
name?: string | undefined;
|
|
19
|
+
/** BCP 47 locale(s); the first is used. Falls back to the context's `locale()`. */
|
|
20
|
+
locales?: string | readonly string[] | undefined;
|
|
21
|
+
/**
|
|
22
|
+
* No interaction at all.
|
|
23
|
+
* @defaultValue `false`
|
|
24
|
+
*/
|
|
25
|
+
disabled?: boolean | undefined;
|
|
26
|
+
/**
|
|
27
|
+
* Focusable and read out, but the value cannot change.
|
|
28
|
+
* @defaultValue `false`
|
|
29
|
+
*/
|
|
30
|
+
readonly?: boolean | undefined;
|
|
31
|
+
/** @defaultValue `'md'` */
|
|
32
|
+
size?: FieldSize | undefined;
|
|
33
|
+
/** `FieldControl`: the segment group's `id`. */
|
|
34
|
+
id?: string | undefined;
|
|
35
|
+
/** `FieldControl`: the visible label's id; the group and each segment are `aria-labelledby` it. */
|
|
36
|
+
labelId?: string | undefined;
|
|
37
|
+
/**
|
|
38
|
+
* `FieldControl`: space-separated ids for the group's `aria-describedby`.
|
|
39
|
+
* @defaultValue `''`
|
|
40
|
+
*/
|
|
41
|
+
describedBy?: string | undefined;
|
|
42
|
+
/**
|
|
43
|
+
* `FieldControl`: the field is in error — `aria-invalid` and the error border.
|
|
44
|
+
* @defaultValue `false`
|
|
45
|
+
*/
|
|
46
|
+
invalid?: boolean | undefined;
|
|
47
|
+
/**
|
|
48
|
+
* `FieldControl`: a value is required for the form to submit.
|
|
49
|
+
* @defaultValue `false`
|
|
50
|
+
*/
|
|
51
|
+
required?: boolean | undefined;
|
|
52
|
+
}
|
|
53
|
+
/** What `SegmentGroup` renders the group with. */
|
|
54
|
+
export interface SegmentGroupOptions {
|
|
55
|
+
readonly id: string | undefined;
|
|
56
|
+
readonly name: string | undefined;
|
|
57
|
+
readonly labelId: string | undefined;
|
|
58
|
+
readonly describedBy: string;
|
|
59
|
+
readonly invalid: boolean;
|
|
60
|
+
readonly disabled: boolean;
|
|
61
|
+
readonly size: FieldSize;
|
|
62
|
+
/** The caller's remaining attributes, spread onto the group. */
|
|
63
|
+
readonly attributes: Record<string, unknown>;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Split the shared props into the bits-ui root's options (defaults applied,
|
|
67
|
+
* unset options dropped) and the segment group's. One function, so
|
|
68
|
+
* `DateField` and `TimeField` cannot disagree about a default.
|
|
69
|
+
*/
|
|
70
|
+
export declare function segmentedField(props: SegmentedFieldProps, contextLocale: string | readonly string[] | undefined): {
|
|
71
|
+
readonly root: Record<string, unknown>;
|
|
72
|
+
readonly group: SegmentGroupOptions;
|
|
73
|
+
};
|
|
74
|
+
/** The props `DatePicker` and `DateRangePicker` add to the segmented field: the calendar popover's. */
|
|
75
|
+
export interface PickerProps {
|
|
76
|
+
/** Whether the calendar popover is open. Bindable. */
|
|
77
|
+
open?: boolean | undefined;
|
|
78
|
+
/** Days that cannot be chosen at all; rendered disabled. */
|
|
79
|
+
isDateDisabled?: ((date: DateValue) => boolean) | undefined;
|
|
80
|
+
/** Days shown but marked unavailable: booked, frost, closed. */
|
|
81
|
+
isDateUnavailable?: ((date: DateValue) => boolean) | undefined;
|
|
82
|
+
/** 0 = Sunday … 6 = Saturday; omitted, the locale's own week start. */
|
|
83
|
+
weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6 | undefined;
|
|
84
|
+
/**
|
|
85
|
+
* Months shown side by side in the popover.
|
|
86
|
+
* @defaultValue `1`
|
|
87
|
+
*/
|
|
88
|
+
numberOfMonths?: number | undefined;
|
|
89
|
+
/**
|
|
90
|
+
* Accessible name of the calendar trigger button.
|
|
91
|
+
* @defaultValue `'Choose date'`
|
|
92
|
+
*/
|
|
93
|
+
triggerLabel?: string | undefined;
|
|
94
|
+
/**
|
|
95
|
+
* Accessible name of the popover's calendar.
|
|
96
|
+
* @defaultValue `'Calendar'`
|
|
97
|
+
*/
|
|
98
|
+
calendarLabel?: string | undefined;
|
|
99
|
+
/**
|
|
100
|
+
* Accessible name of the previous-month button.
|
|
101
|
+
* @defaultValue `'Previous month'`
|
|
102
|
+
*/
|
|
103
|
+
previousLabel?: string | undefined;
|
|
104
|
+
/**
|
|
105
|
+
* Accessible name of the next-month button.
|
|
106
|
+
* @defaultValue `'Next month'`
|
|
107
|
+
*/
|
|
108
|
+
nextLabel?: string | undefined;
|
|
109
|
+
}
|
|
110
|
+
/** What `pickerField` hands a picker: the bits-ui root's options, the segment group's, and the popover's labels. */
|
|
111
|
+
export interface PickerField {
|
|
112
|
+
readonly root: Record<string, unknown>;
|
|
113
|
+
readonly group: SegmentGroupOptions;
|
|
114
|
+
readonly triggerLabel: string;
|
|
115
|
+
readonly calendarLabel: string;
|
|
116
|
+
readonly months: {
|
|
117
|
+
readonly locale: string;
|
|
118
|
+
readonly previousLabel: string;
|
|
119
|
+
readonly nextLabel: string;
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Split a picker's props (the segmented field's plus the popover's) into
|
|
124
|
+
* what the bits-ui root, `SegmentGroup` and `PickerPopover` take, defaults
|
|
125
|
+
* applied. One function, so `DatePicker` and `DateRangePicker` cannot
|
|
126
|
+
* disagree about a default.
|
|
127
|
+
*/
|
|
128
|
+
export declare function pickerField(props: SegmentedFieldProps & Omit<PickerProps, 'open'>, contextLocale: string | readonly string[] | undefined): PickerField;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What `DateField` and `TimeField` share when handing their props to bits-ui:
|
|
3
|
+
* the props themselves, and the split between the bits-ui root and the
|
|
4
|
+
* segment group `SegmentGroup` renders.
|
|
5
|
+
*
|
|
6
|
+
* @module
|
|
7
|
+
*/
|
|
8
|
+
import { definedProps, firstLocale } from "./calendar-props.js";
|
|
9
|
+
/**
|
|
10
|
+
* Split the shared props into the bits-ui root's options (defaults applied,
|
|
11
|
+
* unset options dropped) and the segment group's. One function, so
|
|
12
|
+
* `DateField` and `TimeField` cannot disagree about a default.
|
|
13
|
+
*/
|
|
14
|
+
export function segmentedField(props, contextLocale) {
|
|
15
|
+
const { hourCycle, name, locales = contextLocale, disabled = false, readonly = false, size = 'md', id, labelId, describedBy = '', invalid = false, required = false, ...attributes } = props;
|
|
16
|
+
return {
|
|
17
|
+
root: {
|
|
18
|
+
...definedProps({ hourCycle, locale: firstLocale(locales) }),
|
|
19
|
+
disabled,
|
|
20
|
+
readonly,
|
|
21
|
+
required,
|
|
22
|
+
},
|
|
23
|
+
group: { id, name, labelId, describedBy, invalid, disabled, size, attributes },
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Split a picker's props (the segmented field's plus the popover's) into
|
|
28
|
+
* what the bits-ui root, `SegmentGroup` and `PickerPopover` take, defaults
|
|
29
|
+
* applied. One function, so `DatePicker` and `DateRangePicker` cannot
|
|
30
|
+
* disagree about a default.
|
|
31
|
+
*/
|
|
32
|
+
export function pickerField(props, contextLocale) {
|
|
33
|
+
const { isDateDisabled, isDateUnavailable, weekStartsOn, numberOfMonths = 1, triggerLabel = 'Choose date', calendarLabel = 'Calendar', previousLabel = 'Previous month', nextLabel = 'Next month', ...fieldProps } = props;
|
|
34
|
+
const field = segmentedField(fieldProps, contextLocale);
|
|
35
|
+
return {
|
|
36
|
+
root: {
|
|
37
|
+
...field.root,
|
|
38
|
+
...definedProps({ isDateDisabled, isDateUnavailable, weekStartsOn }),
|
|
39
|
+
numberOfMonths,
|
|
40
|
+
calendarLabel,
|
|
41
|
+
weekdayFormat: 'short',
|
|
42
|
+
},
|
|
43
|
+
group: field.group,
|
|
44
|
+
triggerLabel,
|
|
45
|
+
calendarLabel,
|
|
46
|
+
months: {
|
|
47
|
+
locale: firstLocale(fieldProps.locales ?? contextLocale) ?? 'en',
|
|
48
|
+
previousLabel,
|
|
49
|
+
nextLabel,
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Page Up / Page Down arithmetic behind `Slider`, which bits-ui 2.20's
|
|
3
|
+
* thumb keyboard handler does not cover. Pure, so the component's key handler
|
|
4
|
+
* stays a dispatch and the arithmetic is testable on its own.
|
|
5
|
+
*
|
|
6
|
+
* @module
|
|
7
|
+
*/
|
|
8
|
+
/** The scale a slider moves over: its bounds and its step (a number, or explicit snap points). */
|
|
9
|
+
export interface SliderScale {
|
|
10
|
+
readonly min: number;
|
|
11
|
+
readonly max: number;
|
|
12
|
+
readonly step: number | readonly number[];
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* The value one page away from `current` in `direction` (`1` up, `-1` down):
|
|
16
|
+
* a tenth of the scale, rounded to whole steps and never less than one. For
|
|
17
|
+
* snap points, a tenth of the points, never less than one.
|
|
18
|
+
*/
|
|
19
|
+
export declare function pageStep(current: number, direction: 1 | -1, scale: SliderScale): number;
|
|
20
|
+
/** Clamp `next` for thumb `index` between its neighbours (or the scale's ends), so thumbs never cross. */
|
|
21
|
+
export declare function clampToNeighbours(values: readonly number[], index: number, next: number, scale: SliderScale): number;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Page Up / Page Down arithmetic behind `Slider`, which bits-ui 2.20's
|
|
3
|
+
* thumb keyboard handler does not cover. Pure, so the component's key handler
|
|
4
|
+
* stays a dispatch and the arithmetic is testable on its own.
|
|
5
|
+
*
|
|
6
|
+
* @module
|
|
7
|
+
*/
|
|
8
|
+
/** Index of the snap point nearest `value`. */
|
|
9
|
+
function nearestIndex(points, value) {
|
|
10
|
+
let best = 0;
|
|
11
|
+
points.forEach((point, index) => {
|
|
12
|
+
if (Math.abs(point - value) < Math.abs((points[best] ?? point) - value))
|
|
13
|
+
best = index;
|
|
14
|
+
});
|
|
15
|
+
return best;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* The value one page away from `current` in `direction` (`1` up, `-1` down):
|
|
19
|
+
* a tenth of the scale, rounded to whole steps and never less than one. For
|
|
20
|
+
* snap points, a tenth of the points, never less than one.
|
|
21
|
+
*/
|
|
22
|
+
export function pageStep(current, direction, scale) {
|
|
23
|
+
const { min, max, step } = scale;
|
|
24
|
+
if (typeof step === 'number') {
|
|
25
|
+
return current + direction * step * Math.max(1, Math.round((max - min) / 10 / step));
|
|
26
|
+
}
|
|
27
|
+
const points = [...step].sort((a, b) => a - b);
|
|
28
|
+
const jump = Math.max(1, Math.round(points.length / 10));
|
|
29
|
+
const target = Math.min(points.length - 1, Math.max(0, nearestIndex(points, current) + direction * jump));
|
|
30
|
+
return points[target] ?? current;
|
|
31
|
+
}
|
|
32
|
+
/** Clamp `next` for thumb `index` between its neighbours (or the scale's ends), so thumbs never cross. */
|
|
33
|
+
export function clampToNeighbours(values, index, next, scale) {
|
|
34
|
+
const lower = values[index - 1] ?? scale.min;
|
|
35
|
+
const upper = values[index + 1] ?? scale.max;
|
|
36
|
+
return Math.min(upper, Math.max(lower, next));
|
|
37
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
<!-- @component
|
|
2
|
+
The time left until an instant, ticking every second in daisyUI's `countdown` digits, read out coarsely and announced once at zero.
|
|
3
|
+
-->
|
|
4
|
+
<!--
|
|
5
|
+
Countdown — a seed-swap opening, an auction close, a watering timer.
|
|
6
|
+
|
|
7
|
+
ARIA contract (the part that matters): a `role="timer"` named by `label`.
|
|
8
|
+
A second-by-second announcement is unusable, so the ticking digits are
|
|
9
|
+
`aria-hidden`, and what assistive technology reads is a separate
|
|
10
|
+
visually hidden text at a coarse granularity that changes far less often:
|
|
11
|
+
whole minutes under an hour ("4 minutes"), whole hours above it ("2
|
|
12
|
+
days, 4 hours"). The granularity is fixed, not a prop. `role="timer"` is
|
|
13
|
+
implicitly `aria-live="off"`, so even that is read on demand, not pushed.
|
|
14
|
+
At zero a polite `role="status"` announces `completeLabel` once. With
|
|
15
|
+
`prefers-reduced-motion: reduce` the digit roll does not animate
|
|
16
|
+
(WCAG 2.2.2).
|
|
17
|
+
|
|
18
|
+
The clock starts in an `$effect`, never at module load (`sideEffects:
|
|
19
|
+
false`), and stops on destroy or at zero. The first render uses the
|
|
20
|
+
current time, and the client re-syncs after mount. An `until` already in
|
|
21
|
+
the past renders the complete state without calling `onComplete`: that
|
|
22
|
+
only fires when the countdown is seen reaching zero.
|
|
23
|
+
-->
|
|
24
|
+
<script lang="ts">import { getComponentsContext } from "../context.svelte.js";
|
|
25
|
+
import { formatDuration } from "./duration.js";
|
|
26
|
+
let { until, label, largestUnit = "days", display = "digits", completeLabel = "Time is up", onComplete, locales = getComponentsContext().locale(), class: className, ...rest } = $props();
|
|
27
|
+
const SECOND = 1e3;
|
|
28
|
+
const MINUTE = 60 * SECOND;
|
|
29
|
+
const HOUR = 60 * MINUTE;
|
|
30
|
+
const DAY = 24 * HOUR;
|
|
31
|
+
const SIZES = {
|
|
32
|
+
days: DAY,
|
|
33
|
+
hours: HOUR,
|
|
34
|
+
minutes: MINUTE,
|
|
35
|
+
seconds: SECOND
|
|
36
|
+
};
|
|
37
|
+
const ORDER = [
|
|
38
|
+
"days",
|
|
39
|
+
"hours",
|
|
40
|
+
"minutes",
|
|
41
|
+
"seconds"
|
|
42
|
+
];
|
|
43
|
+
let now = $state(Date.now());
|
|
44
|
+
const target = $derived(new Date(until).getTime());
|
|
45
|
+
const remaining = $derived(Math.max(0, target - now));
|
|
46
|
+
const complete = $derived(remaining === 0);
|
|
47
|
+
/** The units shown, from `largestUnit` down to seconds, each with its count. */
|
|
48
|
+
const parts = $derived.by(() => {
|
|
49
|
+
let rest = Math.ceil(remaining / SECOND) * SECOND;
|
|
50
|
+
return ORDER.slice(ORDER.indexOf(largestUnit)).map((unit) => {
|
|
51
|
+
const count = Math.floor(rest / SIZES[unit]);
|
|
52
|
+
rest -= count * SIZES[unit];
|
|
53
|
+
return {
|
|
54
|
+
unit,
|
|
55
|
+
count
|
|
56
|
+
};
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
/** The spoken, coarse rendering: minutes under an hour, hours above. */
|
|
60
|
+
const spoken = $derived.by(() => {
|
|
61
|
+
if (remaining >= HOUR) {
|
|
62
|
+
const days = Math.floor(remaining / DAY);
|
|
63
|
+
const hours = Math.floor(remaining % DAY / HOUR);
|
|
64
|
+
const value = days > 0 ? {
|
|
65
|
+
days,
|
|
66
|
+
hours
|
|
67
|
+
} : { hours };
|
|
68
|
+
return formatDuration(value, locales, "long");
|
|
69
|
+
}
|
|
70
|
+
return formatDuration({ minutes: Math.ceil(remaining / MINUTE) }, locales, "long");
|
|
71
|
+
});
|
|
72
|
+
const text = $derived(formatDuration(Object.fromEntries(parts.map(({ unit, count }) => [unit, count])), locales, "short"));
|
|
73
|
+
/** The narrow unit label after each digit group ("d", "h", "m", "s" in English). */
|
|
74
|
+
const unitLabel = (unit, count) => new Intl.NumberFormat(locales, {
|
|
75
|
+
style: "unit",
|
|
76
|
+
unit: unit.slice(0, -1),
|
|
77
|
+
unitDisplay: "narrow"
|
|
78
|
+
}).formatToParts(count).filter((part) => part.type === "unit").map((part) => part.value).join("");
|
|
79
|
+
$effect(() => {
|
|
80
|
+
now = Date.now();
|
|
81
|
+
if (target <= now) return;
|
|
82
|
+
let done = false;
|
|
83
|
+
const timer = setInterval(() => {
|
|
84
|
+
now = Date.now();
|
|
85
|
+
if (!done && now >= target) {
|
|
86
|
+
done = true;
|
|
87
|
+
clearInterval(timer);
|
|
88
|
+
onComplete?.();
|
|
89
|
+
}
|
|
90
|
+
}, SECOND);
|
|
91
|
+
return () => clearInterval(timer);
|
|
92
|
+
});
|
|
93
|
+
</script>
|
|
94
|
+
|
|
95
|
+
<span {...rest} role="timer" aria-label={label} class={['inline-flex flex-wrap items-baseline gap-2', className]}>
|
|
96
|
+
<span aria-hidden="true">{label}</span>
|
|
97
|
+
<span aria-hidden="true" class="inline-flex items-baseline gap-1 font-mono tabular-nums">
|
|
98
|
+
{#if display === 'digits'}
|
|
99
|
+
{#each parts as { unit, count } (unit)}
|
|
100
|
+
<span class="countdown motion-reduce:*:before:transition-none"
|
|
101
|
+
><span style:--value={count} style:--digits={unit === largestUnit ? undefined : 2}>{count}</span></span
|
|
102
|
+
>{unitLabel(unit, count)}
|
|
103
|
+
{/each}
|
|
104
|
+
{:else}
|
|
105
|
+
{text}
|
|
106
|
+
{/if}
|
|
107
|
+
</span>
|
|
108
|
+
<span class="sr-only">{complete ? '' : spoken}</span>
|
|
109
|
+
<span role="status" class="sr-only">{complete ? completeLabel : ''}</span>
|
|
110
|
+
</span>
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
2
|
+
/** The largest unit a `Countdown` shows. */
|
|
3
|
+
type CountdownUnit = 'days' | 'hours' | 'minutes';
|
|
4
|
+
interface Props extends Omit<HTMLAttributes<HTMLSpanElement>, 'children'> {
|
|
5
|
+
/** The instant counted down to: a `Date`, epoch milliseconds or an ISO string. */
|
|
6
|
+
until: Date | number | string;
|
|
7
|
+
/** Accessible name and visible lead-in, e.g. `'Seed swap opens in'`. */
|
|
8
|
+
label: string;
|
|
9
|
+
/**
|
|
10
|
+
* Largest unit shown; larger amounts fold into it (50 hours with `'hours'`).
|
|
11
|
+
* @defaultValue `'days'`
|
|
12
|
+
*/
|
|
13
|
+
largestUnit?: CountdownUnit | undefined;
|
|
14
|
+
/**
|
|
15
|
+
* daisyUI digit roll, or formatted text.
|
|
16
|
+
* @defaultValue `'digits'`
|
|
17
|
+
*/
|
|
18
|
+
display?: 'digits' | 'text' | undefined;
|
|
19
|
+
/**
|
|
20
|
+
* Announced once at zero.
|
|
21
|
+
* @defaultValue `'Time is up'`
|
|
22
|
+
*/
|
|
23
|
+
completeLabel?: string | undefined;
|
|
24
|
+
/** Called once when the countdown is seen reaching zero. */
|
|
25
|
+
onComplete?: (() => void) | undefined;
|
|
26
|
+
/**
|
|
27
|
+
* Locale(s) for the unit words.
|
|
28
|
+
* @defaultValue the components context's `locale()`
|
|
29
|
+
*/
|
|
30
|
+
locales?: string | readonly string[] | undefined;
|
|
31
|
+
}
|
|
32
|
+
/** The time left until an instant, ticking every second in daisyUI's `countdown` digits, read out coarsely and announced once at zero. */
|
|
33
|
+
declare const Countdown: import("svelte").Component<Props, {}, "">;
|
|
34
|
+
type Countdown = ReturnType<typeof Countdown>;
|
|
35
|
+
export default Countdown;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
<!-- @component
|
|
2
|
+
A `<time>` element with the ISO instant in `datetime` and the `Intl.DateTimeFormat` rendering as its text.
|
|
3
|
+
-->
|
|
4
|
+
<!--
|
|
5
|
+
DateTime — a `<time>` element carrying the ISO instant in `datetime` and
|
|
6
|
+
`Intl.DateTimeFormat`'s locale rendering as its text.
|
|
7
|
+
|
|
8
|
+
ARIA contract: none beyond the native `<time>` semantics — the `datetime`
|
|
9
|
+
attribute is what makes the value machine-readable; a screen reader still
|
|
10
|
+
announces the formatted text content (or the `children` snippet, when
|
|
11
|
+
given), never the ISO string.
|
|
12
|
+
|
|
13
|
+
`options` (raw `Intl.DateTimeFormatOptions`) wins over `dateStyle`/
|
|
14
|
+
`timeStyle` when both are supplied, so a caller that needs a field-level
|
|
15
|
+
combination (`{ year: 'numeric', month: 'long' }`) isn't stuck with the
|
|
16
|
+
coarse style presets.
|
|
17
|
+
-->
|
|
18
|
+
<script lang="ts">import { getComponentsContext } from "../context.svelte.js";
|
|
19
|
+
let { value, locales = getComponentsContext().locale(), dateStyle = "medium", timeStyle, options, children, ...rest } = $props();
|
|
20
|
+
const instant = $derived(new Date(value));
|
|
21
|
+
// The formatter and the formatted string are separate `$derived` values so
|
|
22
|
+
// constructing the (relatively expensive) `Intl.DateTimeFormat` is skipped
|
|
23
|
+
// when only `value` changes, not when locale/options change. See
|
|
24
|
+
// PERF-CPU-003 in docs/specs/performance-invariants.md.
|
|
25
|
+
const format = $derived(new Intl.DateTimeFormat(locales, options ?? {
|
|
26
|
+
dateStyle,
|
|
27
|
+
timeStyle
|
|
28
|
+
}));
|
|
29
|
+
const formatted = $derived(format.format(instant));
|
|
30
|
+
const iso = $derived(instant.toISOString());
|
|
31
|
+
</script>
|
|
32
|
+
|
|
33
|
+
<time {...rest} datetime={iso}>
|
|
34
|
+
{#if children}{@render children()}{:else}{formatted}{/if}
|
|
35
|
+
</time>
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
import type { HTMLTimeAttributes } from 'svelte/elements';
|
|
3
|
+
interface Props extends Omit<HTMLTimeAttributes, 'children'> {
|
|
4
|
+
/** The instant: a `Date`, epoch milliseconds or an ISO string. */
|
|
5
|
+
value: Date | number | string;
|
|
6
|
+
/**
|
|
7
|
+
* Locale(s) for `Intl` formatting.
|
|
8
|
+
* @defaultValue the components context's `locale()`
|
|
9
|
+
*/
|
|
10
|
+
locales?: string | readonly string[] | undefined;
|
|
11
|
+
/**
|
|
12
|
+
* `Intl.DateTimeFormat` `dateStyle`.
|
|
13
|
+
* @defaultValue `'medium'`
|
|
14
|
+
*/
|
|
15
|
+
dateStyle?: Intl.DateTimeFormatOptions['dateStyle'] | undefined;
|
|
16
|
+
/** `Intl.DateTimeFormat` `timeStyle`; omitted, no time is shown. */
|
|
17
|
+
timeStyle?: Intl.DateTimeFormatOptions['timeStyle'] | undefined;
|
|
18
|
+
/** Raw `Intl.DateTimeFormatOptions`; wins over `dateStyle`/`timeStyle` when given. */
|
|
19
|
+
options?: Intl.DateTimeFormatOptions | undefined;
|
|
20
|
+
/** Replaces the formatted text; the `datetime` attribute stays machine-readable. */
|
|
21
|
+
children?: Snippet<[]> | undefined;
|
|
22
|
+
}
|
|
23
|
+
/** A `<time>` element with the ISO instant in `datetime` and the `Intl.DateTimeFormat` rendering as its text. */
|
|
24
|
+
declare const DateTime: import("svelte").Component<Props, {}, "">;
|
|
25
|
+
type DateTime = ReturnType<typeof DateTime>;
|
|
26
|
+
export default DateTime;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<!-- @component
|
|
2
|
+
A length of time ("2 hr, 30 min") in a `<time>` element whose `datetime` is the ISO 8601 duration.
|
|
3
|
+
-->
|
|
4
|
+
<!--
|
|
5
|
+
Duration — the length-of-time counterpart of `DateTime` (an instant) and
|
|
6
|
+
`RelativeTime` (an instant relative to now), formatted by
|
|
7
|
+
`formatDuration` (see `duration.ts`).
|
|
8
|
+
|
|
9
|
+
ARIA contract: none beyond the native `<time>`. Its `datetime` holds the
|
|
10
|
+
HTML duration string (`PT2H30M`), the content the localised text.
|
|
11
|
+
-->
|
|
12
|
+
<script lang="ts">import { getComponentsContext } from "../context.svelte.js";
|
|
13
|
+
import { durationFromMilliseconds, formatDuration, toIsoDuration } from "./duration.js";
|
|
14
|
+
let { value, style = "short", locales = getComponentsContext().locale(), ...rest } = $props();
|
|
15
|
+
const duration = $derived(typeof value === "number" ? durationFromMilliseconds(value) : value);
|
|
16
|
+
</script>
|
|
17
|
+
|
|
18
|
+
<time {...rest} datetime={toIsoDuration(duration)}>{formatDuration(duration, locales, style)}</time>
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { HTMLTimeAttributes } from 'svelte/elements';
|
|
2
|
+
import { type DurationStyle, type DurationValue } from './duration.ts';
|
|
3
|
+
interface Props extends Omit<HTMLTimeAttributes, 'children'> {
|
|
4
|
+
/** A `DurationValue`, or milliseconds. */
|
|
5
|
+
value: DurationValue | number;
|
|
6
|
+
/**
|
|
7
|
+
* How it is spelled.
|
|
8
|
+
* @defaultValue `'short'`
|
|
9
|
+
*/
|
|
10
|
+
style?: DurationStyle | undefined;
|
|
11
|
+
/**
|
|
12
|
+
* Locale(s) for `Intl` formatting.
|
|
13
|
+
* @defaultValue the components context's `locale()`
|
|
14
|
+
*/
|
|
15
|
+
locales?: string | readonly string[] | undefined;
|
|
16
|
+
}
|
|
17
|
+
/** A length of time ("2 hr, 30 min") in a `<time>` element whose `datetime` is the ISO 8601 duration. */
|
|
18
|
+
declare const Duration: import("svelte").Component<Props, {}, "">;
|
|
19
|
+
type Duration = ReturnType<typeof Duration>;
|
|
20
|
+
export default Duration;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
<!-- @component
|
|
2
|
+
Renders `items` through `Intl.ListFormat`, with each item drawn by the `children` snippet and the joining words from the locale.
|
|
3
|
+
-->
|
|
4
|
+
<!--
|
|
5
|
+
FormatList<T> — renders `items` through `Intl.ListFormat`, letting the
|
|
6
|
+
`children` snippet render each element while literal text ("and", ", ")
|
|
7
|
+
comes from the locale's own conjunction/disjunction rules.
|
|
8
|
+
|
|
9
|
+
No wrapping element of its own — it emits `children(item)` and text nodes
|
|
10
|
+
in sequence, so the caller controls the surrounding markup entirely.
|
|
11
|
+
-->
|
|
12
|
+
<script lang="ts" generics="T">import { getComponentsContext } from "../context.svelte.js";
|
|
13
|
+
let { items, style = "long", type = "conjunction", locales = getComponentsContext().locale(), children } = $props();
|
|
14
|
+
const format = $derived(new Intl.ListFormat(locales, {
|
|
15
|
+
style,
|
|
16
|
+
type
|
|
17
|
+
}));
|
|
18
|
+
// `Intl.ListFormat` only formats strings, so format the items' *indices*
|
|
19
|
+
// and map each "element" part back to the real item by index — that way
|
|
20
|
+
// the snippet gets the original `T`, not its stringified form.
|
|
21
|
+
const indices = $derived(items.map((_, index) => index.toString()));
|
|
22
|
+
const parts = $derived(format.formatToParts(indices));
|
|
23
|
+
</script>
|
|
24
|
+
|
|
25
|
+
{#each parts as part, i (i)}
|
|
26
|
+
{#if part.type === 'element'}
|
|
27
|
+
{@render children(items[Number.parseInt(part.value, 10)] as T)}
|
|
28
|
+
{:else}
|
|
29
|
+
{part.value}
|
|
30
|
+
{/if}
|
|
31
|
+
{/each}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
declare function $$render<T>(): {
|
|
3
|
+
props: {
|
|
4
|
+
/** The items to join, each rendered by `children`. */
|
|
5
|
+
items: readonly T[];
|
|
6
|
+
/**
|
|
7
|
+
* `Intl.ListFormat` style.
|
|
8
|
+
* @defaultValue `'long'`
|
|
9
|
+
*/
|
|
10
|
+
style?: Intl.ListFormatOptions["style"] | undefined;
|
|
11
|
+
/**
|
|
12
|
+
* `Intl.ListFormat` type.
|
|
13
|
+
* @defaultValue `'conjunction'`
|
|
14
|
+
*/
|
|
15
|
+
type?: Intl.ListFormatOptions["type"] | undefined;
|
|
16
|
+
/**
|
|
17
|
+
* Locale(s) for `Intl` formatting.
|
|
18
|
+
* @defaultValue the components context's `locale()`
|
|
19
|
+
*/
|
|
20
|
+
locales?: string | readonly string[] | undefined;
|
|
21
|
+
/** Renders one item. */
|
|
22
|
+
children: Snippet<[T]>;
|
|
23
|
+
};
|
|
24
|
+
exports: {};
|
|
25
|
+
bindings: "";
|
|
26
|
+
slots: {};
|
|
27
|
+
events: {};
|
|
28
|
+
};
|
|
29
|
+
declare class __sveltets_Render<T> {
|
|
30
|
+
props(): ReturnType<typeof $$render<T>>['props'];
|
|
31
|
+
events(): ReturnType<typeof $$render<T>>['events'];
|
|
32
|
+
slots(): ReturnType<typeof $$render<T>>['slots'];
|
|
33
|
+
bindings(): "";
|
|
34
|
+
exports(): {};
|
|
35
|
+
}
|
|
36
|
+
interface $$IsomorphicComponent {
|
|
37
|
+
new <T>(options: import('svelte').ComponentConstructorOptions<ReturnType<__sveltets_Render<T>['props']>>): import('svelte').SvelteComponent<ReturnType<__sveltets_Render<T>['props']>, ReturnType<__sveltets_Render<T>['events']>, ReturnType<__sveltets_Render<T>['slots']>> & {
|
|
38
|
+
$$bindings?: ReturnType<__sveltets_Render<T>['bindings']>;
|
|
39
|
+
} & ReturnType<__sveltets_Render<T>['exports']>;
|
|
40
|
+
<T>(internal: unknown, props: ReturnType<__sveltets_Render<T>['props']> & {}): ReturnType<__sveltets_Render<T>['exports']>;
|
|
41
|
+
z_$$bindings?: ReturnType<__sveltets_Render<any>['bindings']>;
|
|
42
|
+
}
|
|
43
|
+
/** Renders `items` through `Intl.ListFormat`, with each item drawn by the `children` snippet and the joining words from the locale. */
|
|
44
|
+
declare const FormatList: $$IsomorphicComponent;
|
|
45
|
+
type FormatList<T> = InstanceType<typeof FormatList<T>>;
|
|
46
|
+
export default FormatList;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
<!-- @component
|
|
2
|
+
Best-effort client-side highlighting of query tokens in a search result.
|
|
3
|
+
-->
|
|
4
|
+
<!--
|
|
5
|
+
Highlight — best-effort client-side token highlight for search results.
|
|
6
|
+
|
|
7
|
+
Splits `query` on whitespace, escapes regex metacharacters, and wraps
|
|
8
|
+
case-insensitive matches in `<mark>`. Intentionally naive: no stemming, no
|
|
9
|
+
FTS-aware tokenisation, no diacritic folding — the authoritative match is
|
|
10
|
+
whatever server-side search produced; this is a UX nicety, and its highlights should not be read as
|
|
11
|
+
"this is exactly what full-text search matched".
|
|
12
|
+
-->
|
|
13
|
+
<script lang="ts" module>function escapeRegex(value) {
|
|
14
|
+
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Split `text` into segments, each flagged `match` when it is a case-insensitive hit for one of `query`'s whitespace-separated tokens.
|
|
18
|
+
* A blank `query` or `text` returns the whole text as one unmatched segment.
|
|
19
|
+
*/
|
|
20
|
+
export function tokenise(text, query) {
|
|
21
|
+
const tokens = query.trim().split(/\s+/).filter((token) => token.length > 0).map(escapeRegex);
|
|
22
|
+
if (tokens.length === 0 || text.length === 0) {
|
|
23
|
+
return [{
|
|
24
|
+
text,
|
|
25
|
+
match: false
|
|
26
|
+
}];
|
|
27
|
+
}
|
|
28
|
+
// `String.prototype.split` with a single capturing group interleaves the
|
|
29
|
+
// captured matches into the result at odd indices: [before, match,
|
|
30
|
+
// between, match, …]. Read `match` from that index parity rather than
|
|
31
|
+
// re-testing each segment — testing each part against a *global* regex
|
|
32
|
+
// would leave `lastIndex` advanced on non-matching segments, which can
|
|
33
|
+
// misclassify later segments and drop highlights. Map first (parity is
|
|
34
|
+
// meaningful on the raw split array), then filter empties.
|
|
35
|
+
const pattern = new RegExp(`(${tokens.join("|")})`, "gi");
|
|
36
|
+
return text.split(pattern).map((part, index) => ({
|
|
37
|
+
text: part,
|
|
38
|
+
match: index % 2 === 1
|
|
39
|
+
})).filter((segment) => segment.text.length > 0);
|
|
40
|
+
}
|
|
41
|
+
</script>
|
|
42
|
+
|
|
43
|
+
<script lang="ts">const { text, query } = $props();
|
|
44
|
+
const segments = $derived(tokenise(text, query));
|
|
45
|
+
</script>
|
|
46
|
+
|
|
47
|
+
{#each segments as segment, i (i)}
|
|
48
|
+
{#if segment.match}
|
|
49
|
+
<mark class="bg-warning/30 text-base-content rounded-sm px-0.5">{segment.text}</mark>
|
|
50
|
+
{:else}{segment.text}{/if}
|
|
51
|
+
{/each}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
interface Segment {
|
|
2
|
+
text: string;
|
|
3
|
+
match: boolean;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Split `text` into segments, each flagged `match` when it is a case-insensitive hit for one of `query`'s whitespace-separated tokens.
|
|
7
|
+
* A blank `query` or `text` returns the whole text as one unmatched segment.
|
|
8
|
+
*/
|
|
9
|
+
export declare function tokenise(text: string, query: string): Segment[];
|
|
10
|
+
interface Props {
|
|
11
|
+
/** The full text to render. */
|
|
12
|
+
text: string;
|
|
13
|
+
/** The user's search query. Tokens are highlighted within `text`. */
|
|
14
|
+
query: string;
|
|
15
|
+
}
|
|
16
|
+
/** Best-effort client-side highlighting of query tokens in a search result. */
|
|
17
|
+
declare const Highlight: import("svelte").Component<Props, {}, "">;
|
|
18
|
+
type Highlight = ReturnType<typeof Highlight>;
|
|
19
|
+
export default Highlight;
|