@skeletonlabs/skeleton 0.92.1 → 0.92.2
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/actions/Clipboard/clipboard.d.ts +4 -0
- package/actions/Clipboard/clipboard.js +37 -0
- package/actions/Filters/filter.d.ts +3 -0
- package/actions/Filters/filter.js +23 -0
- package/{src/lib/actions → actions}/Filters/svg-filters/Apollo.svelte +0 -0
- package/actions/Filters/svg-filters/Apollo.svelte.d.ts +23 -0
- package/{src/lib/actions → actions}/Filters/svg-filters/BlueNight.svelte +0 -0
- package/actions/Filters/svg-filters/BlueNight.svelte.d.ts +23 -0
- package/{src/lib/actions → actions}/Filters/svg-filters/Emerald.svelte +0 -0
- package/actions/Filters/svg-filters/Emerald.svelte.d.ts +23 -0
- package/{src/lib/actions → actions}/Filters/svg-filters/GreenFall.svelte +0 -0
- package/actions/Filters/svg-filters/GreenFall.svelte.d.ts +23 -0
- package/{src/lib/actions → actions}/Filters/svg-filters/Noir.svelte +0 -0
- package/actions/Filters/svg-filters/Noir.svelte.d.ts +23 -0
- package/{src/lib/actions → actions}/Filters/svg-filters/NoirLight.svelte +0 -0
- package/actions/Filters/svg-filters/NoirLight.svelte.d.ts +23 -0
- package/{src/lib/actions → actions}/Filters/svg-filters/Rustic.svelte +0 -0
- package/actions/Filters/svg-filters/Rustic.svelte.d.ts +23 -0
- package/{src/lib/actions → actions}/Filters/svg-filters/Summer84.svelte +0 -0
- package/actions/Filters/svg-filters/Summer84.svelte.d.ts +23 -0
- package/{src/lib/actions → actions}/Filters/svg-filters/XPro.svelte +0 -0
- package/actions/Filters/svg-filters/XPro.svelte.d.ts +23 -0
- package/actions/FocusTrap/focusTrap.d.ts +4 -0
- package/actions/FocusTrap/focusTrap.js +53 -0
- package/components/Accordion/AccordionGroup.svelte +46 -0
- package/components/Accordion/AccordionGroup.svelte.d.ts +24 -0
- package/components/Accordion/AccordionItem.svelte +73 -0
- package/components/Accordion/AccordionItem.svelte.d.ts +36 -0
- package/components/Alert/Alert.svelte +65 -0
- package/components/Alert/Alert.svelte.d.ts +30 -0
- package/components/AppBar/AppBar.svelte +54 -0
- package/components/AppBar/AppBar.svelte.d.ts +30 -0
- package/components/AppRail/AppRail.svelte +51 -0
- package/components/AppRail/AppRail.svelte.d.ts +32 -0
- package/components/AppRail/AppRailTile.svelte +57 -0
- package/components/AppRail/AppRailTile.svelte.d.ts +33 -0
- package/components/AppShell/AppShell.svelte +80 -0
- package/components/AppShell/AppShell.svelte.d.ts +31 -0
- package/components/Avatar/Avatar.svelte +46 -0
- package/components/Avatar/Avatar.svelte.d.ts +32 -0
- package/components/Breadcrumb/Breadcrumb.svelte +24 -0
- package/components/Breadcrumb/Breadcrumb.svelte.d.ts +21 -0
- package/{src/lib/components → components}/Breadcrumb/Crumb.svelte +16 -23
- package/components/Breadcrumb/Crumb.svelte.d.ts +26 -0
- package/components/ConicGradient/ConicGradient.svelte +80 -0
- package/components/ConicGradient/ConicGradient.svelte.d.ts +29 -0
- package/components/ConicGradient/settings.d.ts +13 -0
- package/components/ConicGradient/settings.js +335 -0
- package/components/ConicGradient/types.d.ts +10 -0
- package/components/ConicGradient/types.js +2 -0
- package/components/Divider/Divider.svelte +21 -0
- package/components/Divider/Divider.svelte.d.ts +22 -0
- package/components/FileButton/FileButton.svelte +25 -0
- package/components/FileButton/FileButton.svelte.d.ts +25 -0
- package/components/FileDropzone/FileDropzone.svelte +95 -0
- package/components/FileDropzone/FileDropzone.svelte.d.ts +32 -0
- package/components/GradientHeading/GradientHeading.svelte +21 -0
- package/components/GradientHeading/GradientHeading.svelte.d.ts +22 -0
- package/components/InputChip/InputChip.svelte +107 -0
- package/components/InputChip/InputChip.svelte.d.ts +29 -0
- package/components/ListBox/ListBox.svelte +57 -0
- package/components/ListBox/ListBox.svelte.d.ts +30 -0
- package/components/ListBox/ListBoxItem.svelte +88 -0
- package/components/ListBox/ListBoxItem.svelte.d.ts +32 -0
- package/components/Paginator/Paginator.svelte +74 -0
- package/components/Paginator/Paginator.svelte.d.ts +29 -0
- package/components/Paginator/types.d.ts +10 -0
- package/components/Paginator/types.js +2 -0
- package/components/ProgressBar/ProgressBar.svelte +67 -0
- package/components/ProgressBar/ProgressBar.svelte.d.ts +24 -0
- package/components/ProgressRadial/ProgressRadial.svelte +89 -0
- package/components/ProgressRadial/ProgressRadial.svelte.d.ts +25 -0
- package/components/Radio/RadioGroup.svelte +48 -0
- package/components/Radio/RadioGroup.svelte.d.ts +31 -0
- package/components/Radio/RadioItem.svelte +61 -0
- package/components/Radio/RadioItem.svelte.d.ts +33 -0
- package/components/RangeSlider/RangeSlider.svelte +101 -0
- package/components/RangeSlider/RangeSlider.svelte.d.ts +32 -0
- package/components/SlideToggle/SlideToggle.svelte +100 -0
- package/components/SlideToggle/SlideToggle.svelte.d.ts +34 -0
- package/components/Stepper/Step.svelte +133 -0
- package/components/Stepper/Step.svelte.d.ts +39 -0
- package/components/Stepper/Stepper.svelte +64 -0
- package/components/Stepper/Stepper.svelte.d.ts +32 -0
- package/components/SvgIcon/SvgIcon.svelte +45 -0
- package/components/SvgIcon/SvgIcon.svelte.d.ts +26 -0
- package/components/SvgIcon/icons.d.ts +1 -0
- package/components/SvgIcon/icons.js +25 -0
- package/components/Tab/Tab.svelte +69 -0
- package/components/Tab/Tab.svelte.d.ts +37 -0
- package/components/Tab/TabGroup.svelte +69 -0
- package/components/Tab/TabGroup.svelte.d.ts +30 -0
- package/components/Table/Table.svelte +99 -0
- package/components/Table/Table.svelte.d.ts +27 -0
- package/components/Table/types.d.ts +10 -0
- package/components/Table/types.js +1 -0
- package/components/Table/utils.d.ts +7 -0
- package/{src/lib/components/Table/utils.ts → components/Table/utils.js} +10 -16
- package/components/TableOfContents/TableOfContents.svelte +132 -0
- package/components/TableOfContents/TableOfContents.svelte.d.ts +32 -0
- package/{src/lib/index.ts → index.d.ts} +1 -31
- package/index.js +71 -0
- package/package.json +158 -61
- package/{src/lib/styles → styles}/all.css +0 -0
- package/{src/lib/styles → styles}/core.css +0 -0
- package/{src/lib/styles → styles}/elements/alerts.css +0 -0
- package/{src/lib/styles → styles}/elements/badges.css +0 -0
- package/{src/lib/styles → styles}/elements/breadcrumbs.css +0 -0
- package/{src/lib/styles → styles}/elements/buttons.css +0 -0
- package/{src/lib/styles → styles}/elements/cards.css +0 -0
- package/{src/lib/styles → styles}/elements/chips.css +0 -0
- package/{src/lib/styles → styles}/elements/lists.css +0 -0
- package/{src/lib/styles → styles}/elements/logo-clouds.css +0 -0
- package/{src/lib/styles → styles}/elements/menus.css +0 -0
- package/{src/lib/styles → styles}/elements/placeholders.css +0 -0
- package/{src/lib/styles → styles}/elements/tables.css +0 -0
- package/{src/lib/styles → styles}/elements/tooltips.css +0 -0
- package/{src/lib/styles → styles}/elements.css +0 -0
- package/{src/lib/styles → styles}/forms.css +0 -0
- package/{src/lib/styles → styles}/highlight-js.css +0 -0
- package/{src/lib/styles → styles}/tailwind.css +0 -0
- package/{src/lib/styles → styles}/typography.css +0 -0
- package/tailwind/generated/allComponents.cjs +1 -0
- package/tailwind/generated/allComponents.d.cts +2156 -0
- package/{src/lib/tailwind → tailwind}/settings.cjs +0 -0
- package/tailwind/settings.d.cts +6 -0
- package/{src/lib/tailwind → tailwind}/skeleton.cjs +0 -0
- package/tailwind/skeleton.d.cts +5 -0
- package/{src/lib/tailwind → tailwind}/theme/colors.cjs +0 -0
- package/tailwind/theme/colors.d.cts +2 -0
- package/{src/lib/tailwind → tailwind}/tokens/backgrounds.cjs +0 -0
- package/tailwind/tokens/backgrounds.d.cts +2 -0
- package/{src/lib/tailwind → tailwind}/tokens/border-radius.cjs +0 -0
- package/tailwind/tokens/border-radius.d.cts +33 -0
- package/{src/lib/tailwind → tailwind}/tokens/borders.cjs +0 -0
- package/tailwind/tokens/borders.d.cts +6 -0
- package/{src/lib/tailwind → tailwind}/tokens/fills.cjs +0 -0
- package/tailwind/tokens/fills.d.cts +15 -0
- package/{src/lib/tailwind → tailwind}/tokens/rings.cjs +0 -0
- package/tailwind/tokens/rings.d.cts +17 -0
- package/{src/lib/tailwind → tailwind}/tokens/text.cjs +0 -0
- package/tailwind/tokens/text.d.cts +21 -0
- package/{src/lib/themes → themes}/theme-crimson.css +0 -0
- package/{src/lib/themes → themes}/theme-gold-nouveau.css +0 -0
- package/{src/lib/themes → themes}/theme-hamlindigo.css +0 -0
- package/{src/lib/themes → themes}/theme-modern.css +0 -0
- package/{src/lib/themes → themes}/theme-rocket.css +0 -0
- package/{src/lib/themes → themes}/theme-sahara.css +0 -0
- package/{src/lib/themes → themes}/theme-seafoam.css +0 -0
- package/{src/lib/themes → themes}/theme-seasonal.css +0 -0
- package/{src/lib/themes → themes}/theme-skeleton.css +0 -0
- package/{src/lib/themes → themes}/theme-vintage.css +0 -0
- package/utilities/CodeBlock/CodeBlock.svelte +68 -0
- package/utilities/CodeBlock/CodeBlock.svelte.d.ts +25 -0
- package/utilities/CodeBlock/stores.d.ts +2 -0
- package/utilities/CodeBlock/stores.js +3 -0
- package/utilities/DataTable/DataTable.d.ts +18 -0
- package/utilities/DataTable/DataTable.js +137 -0
- package/utilities/DataTable/actions.d.ts +8 -0
- package/utilities/DataTable/actions.js +114 -0
- package/utilities/DataTable/types.d.ts +33 -0
- package/utilities/DataTable/types.js +2 -0
- package/utilities/Drawer/Drawer.svelte +157 -0
- package/utilities/Drawer/Drawer.svelte.d.ts +33 -0
- package/utilities/Drawer/stores.d.ts +10 -0
- package/utilities/Drawer/stores.js +21 -0
- package/utilities/Drawer/types.d.ts +33 -0
- package/utilities/Drawer/types.js +2 -0
- package/utilities/LightSwitch/LightSwitch.svelte +98 -0
- package/utilities/LightSwitch/LightSwitch.svelte.d.ts +21 -0
- package/utilities/LightSwitch/stores.d.ts +2 -0
- package/utilities/LightSwitch/stores.js +5 -0
- package/utilities/LocalStorageStore/LocalStorageStore.d.ts +12 -0
- package/utilities/LocalStorageStore/LocalStorageStore.js +49 -0
- package/utilities/Menu/menu.d.ts +18 -0
- package/utilities/Menu/menu.js +151 -0
- package/utilities/Modal/Modal.svelte +195 -0
- package/utilities/Modal/Modal.svelte.d.ts +35 -0
- package/{src/lib/utilities → utilities}/Modal/examples/ModalExampleEmbed.svelte +5 -7
- package/utilities/Modal/examples/ModalExampleEmbed.svelte.d.ts +17 -0
- package/{src/lib/utilities → utilities}/Modal/examples/ModalExampleForm.svelte +20 -24
- package/utilities/Modal/examples/ModalExampleForm.svelte.d.ts +17 -0
- package/{src/lib/utilities → utilities}/Modal/examples/ModalExampleList.svelte +13 -18
- package/utilities/Modal/examples/ModalExampleList.svelte.d.ts +17 -0
- package/utilities/Modal/stores.d.ts +12 -0
- package/utilities/Modal/stores.js +24 -0
- package/utilities/Modal/types.d.ts +36 -0
- package/utilities/Modal/types.js +2 -0
- package/utilities/Toast/Toast.svelte +117 -0
- package/utilities/Toast/Toast.svelte.d.ts +28 -0
- package/utilities/Toast/stores.d.ts +10 -0
- package/utilities/Toast/stores.js +60 -0
- package/utilities/Toast/types.d.ts +26 -0
- package/utilities/Toast/types.js +2 -0
- package/utilities/Tooltip/tooltip.d.ts +35 -0
- package/utilities/Tooltip/tooltip.js +94 -0
- package/.eslintrc.cjs +0 -20
- package/.github/FUNDING.yml +0 -13
- package/.github/ISSUE_TEMPLATE/bug_report.yml +0 -30
- package/.github/ISSUE_TEMPLATE/config.yml +0 -8
- package/.github/ISSUE_TEMPLATE/docs_issue.yml +0 -23
- package/.github/ISSUE_TEMPLATE/feature_request.yml +0 -22
- package/.github/pull_request_template.md +0 -14
- package/.prettierignore +0 -12
- package/.prettierrc +0 -6
- package/postcss.config.cjs +0 -14
- package/scripts/compile-css-to-js.cjs +0 -50
- package/scripts/generate-jss.js +0 -67
- package/scripts/post-build.js +0 -17
- package/scripts/pre-build.js +0 -14
- package/src/app.d.ts +0 -13
- package/src/app.html +0 -43
- package/src/app.postcss +0 -10
- package/src/docs/DocsAppBar/DocsAppBar.svelte +0 -213
- package/src/docs/DocsFooter/DocsFooter.svelte +0 -78
- package/src/docs/DocsLogo/DocsLogoAnim.svelte +0 -44
- package/src/docs/DocsLogo/DocsLogoFull.svelte +0 -11
- package/src/docs/DocsLogo/DocsLogoIcon.svelte +0 -6
- package/src/docs/DocsNavigation/DocsDrawer.svelte +0 -23
- package/src/docs/DocsNavigation/DocsSidebar.svelte +0 -103
- package/src/docs/DocsNavigation/links.ts +0 -148
- package/src/docs/DocsSearch/DocsSearch.svelte +0 -78
- package/src/docs/DocsShell/DocsShell.svelte +0 -377
- package/src/docs/DocsShell/sveldMapper.ts +0 -143
- package/src/docs/DocsShell/types.ts +0 -96
- package/src/docs/DocsStyles/blog.css +0 -192
- package/src/docs/DocsThemer/DocsThemer.svelte +0 -254
- package/src/docs/DocsThemer/Swatch.svelte +0 -28
- package/src/docs/DocsThemer/colors.ts +0 -122
- package/src/docs/DocsThemer/settings.ts +0 -129
- package/src/docs/DocsThemer/stores.ts +0 -5
- package/src/docs/DocsThemer/types.ts +0 -20
- package/src/docs/README.md +0 -3
- package/src/docs/stores.ts +0 -15
- package/src/lib/actions/Clipboard/clipboard.ts +0 -39
- package/src/lib/actions/Filters/filter.test.ts +0 -40
- package/src/lib/actions/Filters/filter.ts +0 -23
- package/src/lib/actions/FocusTrap/focusTrap.ts +0 -56
- package/src/lib/components/Accordion/AccordionGroup.svelte +0 -53
- package/src/lib/components/Accordion/AccordionGroup.test.ts +0 -22
- package/src/lib/components/Accordion/AccordionItem.svelte +0 -80
- package/src/lib/components/Accordion/AccordionItem.test.ts +0 -28
- package/src/lib/components/Alert/Alert.svelte +0 -71
- package/src/lib/components/Alert/Alert.test.ts +0 -30
- package/src/lib/components/AppBar/AppBar.svelte +0 -60
- package/src/lib/components/AppBar/AppBar.test.ts +0 -31
- package/src/lib/components/AppRail/AppRail.svelte +0 -58
- package/src/lib/components/AppRail/AppRailTile.svelte +0 -66
- package/src/lib/components/AppShell/AppShell.svelte +0 -84
- package/src/lib/components/AppShell/AppShell.test.ts +0 -26
- package/src/lib/components/Avatar/Avatar.svelte +0 -51
- package/src/lib/components/Avatar/Avatar.test.ts +0 -41
- package/src/lib/components/Breadcrumb/Breadcrumb.svelte +0 -30
- package/src/lib/components/Breadcrumb/Breadcrumb.test.ts +0 -20
- package/src/lib/components/Breadcrumb/Crumb.test.ts +0 -48
- package/src/lib/components/ConicGradient/ConicGradient.svelte +0 -88
- package/src/lib/components/ConicGradient/ConicGradient.test.ts +0 -26
- package/src/lib/components/ConicGradient/settings.ts +0 -345
- package/src/lib/components/ConicGradient/types.ts +0 -12
- package/src/lib/components/Divider/Divider.svelte +0 -26
- package/src/lib/components/Divider/Divider.test.ts +0 -32
- package/src/lib/components/FileButton/FileButton.svelte +0 -29
- package/src/lib/components/FileButton/FileButton.test.ts +0 -32
- package/src/lib/components/FileDropzone/FileDropzone.svelte +0 -108
- package/src/lib/components/FileDropzone/FileDropzone.test.ts +0 -32
- package/src/lib/components/GradientHeading/GradientHeading.svelte +0 -24
- package/src/lib/components/GradientHeading/GradientHeading.test.ts +0 -30
- package/src/lib/components/InputChip/InputChip.svelte +0 -118
- package/src/lib/components/ListBox/ListBox.svelte +0 -65
- package/src/lib/components/ListBox/ListBox.test.ts +0 -48
- package/src/lib/components/ListBox/ListBoxItem.svelte +0 -99
- package/src/lib/components/ListBox/ListBoxItem.test.ts +0 -22
- package/src/lib/components/Paginator/Paginator.svelte +0 -84
- package/src/lib/components/Paginator/Paginator.test.ts +0 -29
- package/src/lib/components/Paginator/types.ts +0 -12
- package/src/lib/components/ProgressBar/ProgressBar.svelte +0 -73
- package/src/lib/components/ProgressBar/ProgressBar.test.ts +0 -27
- package/src/lib/components/ProgressRadial/ProgressRadial.svelte +0 -98
- package/src/lib/components/ProgressRadial/ProgressRadial.test.ts +0 -26
- package/src/lib/components/Radio/RadioGroup.svelte +0 -54
- package/src/lib/components/Radio/RadioGroup.test.ts +0 -35
- package/src/lib/components/Radio/RadioItem.svelte +0 -71
- package/src/lib/components/Radio/RadioItem.test.ts +0 -32
- package/src/lib/components/RangeSlider/RangeSlider.svelte +0 -110
- package/src/lib/components/RangeSlider/RangeSlider.test.ts +0 -44
- package/src/lib/components/SlideToggle/SlideToggle.svelte +0 -106
- package/src/lib/components/SlideToggle/SlideToggle.test.ts +0 -23
- package/src/lib/components/Stepper/Step.svelte +0 -140
- package/src/lib/components/Stepper/Step.test.ts +0 -21
- package/src/lib/components/Stepper/Stepper.svelte +0 -71
- package/src/lib/components/Stepper/Stepper.test.ts +0 -31
- package/src/lib/components/SvgIcon/SvgIcon.svelte +0 -50
- package/src/lib/components/SvgIcon/SvgIcon.test.ts +0 -28
- package/src/lib/components/SvgIcon/icons.ts +0 -29
- package/src/lib/components/Tab/Tab.svelte +0 -79
- package/src/lib/components/Tab/Tab.test.ts +0 -26
- package/src/lib/components/Tab/TabGroup.svelte +0 -78
- package/src/lib/components/Tab/TabGroup.test.ts +0 -30
- package/src/lib/components/Table/Table.svelte +0 -106
- package/src/lib/components/Table/types.ts +0 -10
- package/src/lib/components/TableOfContents/TableOfContents.svelte +0 -139
- package/src/lib/themes/theme-test.css +0 -96
- package/src/lib/utilities/CodeBlock/CodeBlock.svelte +0 -78
- package/src/lib/utilities/CodeBlock/CodeBlock.test.ts +0 -27
- package/src/lib/utilities/CodeBlock/stores.ts +0 -5
- package/src/lib/utilities/DataTable/DataTable.ts +0 -151
- package/src/lib/utilities/DataTable/actions.ts +0 -100
- package/src/lib/utilities/DataTable/types.ts +0 -33
- package/src/lib/utilities/Drawer/Drawer.svelte +0 -173
- package/src/lib/utilities/Drawer/Drawer.test.ts +0 -15
- package/src/lib/utilities/Drawer/stores.ts +0 -27
- package/src/lib/utilities/Drawer/types.ts +0 -47
- package/src/lib/utilities/LightSwitch/LightSwitch.svelte +0 -116
- package/src/lib/utilities/LightSwitch/LightSwitch.test.ts +0 -19
- package/src/lib/utilities/LightSwitch/stores.ts +0 -7
- package/src/lib/utilities/LocalStorageStore/LocalStorageStore.test.ts +0 -220
- package/src/lib/utilities/LocalStorageStore/LocalStorageStore.ts +0 -77
- package/src/lib/utilities/Menu/menu.test.ts +0 -22
- package/src/lib/utilities/Menu/menu.ts +0 -172
- package/src/lib/utilities/Modal/Modal.svelte +0 -206
- package/src/lib/utilities/Modal/Modal.test.ts +0 -50
- package/src/lib/utilities/Modal/stores.ts +0 -29
- package/src/lib/utilities/Modal/types.ts +0 -39
- package/src/lib/utilities/Toast/Toast.svelte +0 -95
- package/src/lib/utilities/Toast/Toats.test.ts +0 -25
- package/src/lib/utilities/Toast/stores.ts +0 -63
- package/src/lib/utilities/Toast/types.ts +0 -29
- package/src/lib/utilities/Tooltip/tooltip.ts +0 -137
- package/src/routes/(inner)/+layout.svelte +0 -3
- package/src/routes/(inner)/actions/clipboard/+page.svelte +0 -87
- package/src/routes/(inner)/actions/filters/+page.svelte +0 -151
- package/src/routes/(inner)/actions/focus-trap/+page.svelte +0 -59
- package/src/routes/(inner)/components/accordions/+page.svelte +0 -127
- package/src/routes/(inner)/components/alerts/+page.svelte +0 -130
- package/src/routes/(inner)/components/app-bar/+page.svelte +0 -52
- package/src/routes/(inner)/components/app-rail/+page.svelte +0 -105
- package/src/routes/(inner)/components/app-shell/+page.svelte +0 -159
- package/src/routes/(inner)/components/avatars/+page.svelte +0 -193
- package/src/routes/(inner)/components/breadcrumbs/+page.svelte +0 -121
- package/src/routes/(inner)/components/conic-gradients/+page.svelte +0 -161
- package/src/routes/(inner)/components/dividers/+page.svelte +0 -146
- package/src/routes/(inner)/components/file-buttons/+page.svelte +0 -46
- package/src/routes/(inner)/components/file-dropzone/+page.svelte +0 -71
- package/src/routes/(inner)/components/gradient-headings/+page.svelte +0 -138
- package/src/routes/(inner)/components/input-chips/+page.svelte +0 -128
- package/src/routes/(inner)/components/listboxes/+page.svelte +0 -92
- package/src/routes/(inner)/components/paginators/+page.svelte +0 -118
- package/src/routes/(inner)/components/progress-bars/+page.svelte +0 -157
- package/src/routes/(inner)/components/progress-radials/+page.svelte +0 -64
- package/src/routes/(inner)/components/radio-groups/+page.svelte +0 -91
- package/src/routes/(inner)/components/range-sliders/+page.svelte +0 -134
- package/src/routes/(inner)/components/slide-toggles/+page.svelte +0 -63
- package/src/routes/(inner)/components/steppers/+page.svelte +0 -168
- package/src/routes/(inner)/components/svg-icons/+page.svelte +0 -60
- package/src/routes/(inner)/components/table-of-contents/+page.svelte +0 -110
- package/src/routes/(inner)/components/tables/+page.svelte +0 -216
- package/src/routes/(inner)/components/tabs/+page.svelte +0 -146
- package/src/routes/(inner)/docs/comparisons/+page.svelte +0 -130
- package/src/routes/(inner)/docs/contributions/+page.svelte +0 -78
- package/src/routes/(inner)/docs/contributions/documentation/+page.svelte +0 -217
- package/src/routes/(inner)/docs/contributions/requirements/+page.svelte +0 -173
- package/src/routes/(inner)/docs/contributions/style-guide/+page.svelte +0 -164
- package/src/routes/(inner)/docs/faqs/+page.svelte +0 -80
- package/src/routes/(inner)/docs/features/+page.svelte +0 -121
- package/src/routes/(inner)/docs/recommended/+page.svelte +0 -162
- package/src/routes/(inner)/docs/why/+page.svelte +0 -104
- package/src/routes/(inner)/elements/alerts/+page.svelte +0 -142
- package/src/routes/(inner)/elements/badges/+page.svelte +0 -155
- package/src/routes/(inner)/elements/breadcrumbs/+page.svelte +0 -132
- package/src/routes/(inner)/elements/buttons/+page.svelte +0 -304
- package/src/routes/(inner)/elements/cards/+page.svelte +0 -117
- package/src/routes/(inner)/elements/chips/+page.svelte +0 -130
- package/src/routes/(inner)/elements/core/+page.svelte +0 -98
- package/src/routes/(inner)/elements/forms/+page.svelte +0 -89
- package/src/routes/(inner)/elements/forms/preview/+page.svelte +0 -256
- package/src/routes/(inner)/elements/lists/+page.svelte +0 -197
- package/src/routes/(inner)/elements/logo-clouds/+page.svelte +0 -105
- package/src/routes/(inner)/elements/placeholders/+page.svelte +0 -70
- package/src/routes/(inner)/elements/tables/+page.svelte +0 -138
- package/src/routes/(inner)/elements/tokens/+page.svelte +0 -176
- package/src/routes/(inner)/elements/typography/+page.svelte +0 -100
- package/src/routes/(inner)/guides/install/+page.svelte +0 -84
- package/src/routes/(inner)/guides/quickstart/+page.svelte +0 -118
- package/src/routes/(inner)/guides/styling/+page.svelte +0 -361
- package/src/routes/(inner)/guides/tailwind/+page.svelte +0 -150
- package/src/routes/(inner)/guides/themes/+page.svelte +0 -144
- package/src/routes/(inner)/guides/themes/colors/+page.svelte +0 -87
- package/src/routes/(inner)/guides/themes/generator/+page.svelte +0 -58
- package/src/routes/(inner)/guides/themes/presets.ts +0 -69
- package/src/routes/(inner)/template/+page.svelte +0 -52
- package/src/routes/(inner)/utilities/codeblocks/+page.svelte +0 -77
- package/src/routes/(inner)/utilities/data-tables/+page.svelte +0 -399
- package/src/routes/(inner)/utilities/data-tables/+page.ts +0 -18
- package/src/routes/(inner)/utilities/drawers/+page.svelte +0 -193
- package/src/routes/(inner)/utilities/lightswitches/+page.svelte +0 -86
- package/src/routes/(inner)/utilities/local-storage-stores/+page.svelte +0 -67
- package/src/routes/(inner)/utilities/menus/+page.svelte +0 -186
- package/src/routes/(inner)/utilities/modals/+page.svelte +0 -391
- package/src/routes/(inner)/utilities/toasts/+page.svelte +0 -212
- package/src/routes/(inner)/utilities/tooltips/+page.svelte +0 -153
- package/src/routes/+error.svelte +0 -16
- package/src/routes/+layout.server.ts +0 -13
- package/src/routes/+layout.svelte +0 -100
- package/src/routes/+page.server.ts +0 -12
- package/src/routes/+page.svelte +0 -197
- package/src/routes/blog/+page.svelte +0 -78
- package/src/routes/blog/+page.ts +0 -6
- package/src/routes/blog/[slug]/+page.svelte +0 -112
- package/src/routes/blog/[slug]/+page.ts +0 -6
- package/src/routes/blog/blog-service.ts +0 -31
- package/src/routes/blog/rss/+server.ts +0 -16
- package/static/favicon.png +0 -0
- package/svelte.config.js +0 -30
- package/tailwind.config.cjs +0 -14
- package/tsconfig.json +0 -37
- package/vite.config.js +0 -25
|
@@ -1,220 +0,0 @@
|
|
|
1
|
-
// Source: https://github.com/joshnuss/svelte-local-storage-store
|
|
2
|
-
// https://github.com/joshnuss/svelte-local-storage-store/blob/master/it/localStorageStore.it.ts
|
|
3
|
-
// Represents version v0.3.2 (2022-12-04)
|
|
4
|
-
|
|
5
|
-
import { describe, it, expect, beforeEach } from 'vitest';
|
|
6
|
-
import { get } from 'svelte/store';
|
|
7
|
-
|
|
8
|
-
import { localStorageStore } from '$lib/utilities/LocalStorageStore/LocalStorageStore';
|
|
9
|
-
|
|
10
|
-
describe('localStorageStore()', () => {
|
|
11
|
-
beforeEach(() => localStorage.clear());
|
|
12
|
-
|
|
13
|
-
it('uses initial value if nothing in local storage', () => {
|
|
14
|
-
const store = localStorageStore('myKey', 123);
|
|
15
|
-
const value = get(store);
|
|
16
|
-
|
|
17
|
-
expect(value).toEqual(123);
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
it('uses existing value if data already in local storage', () => {
|
|
21
|
-
localStorage.setItem('myKey2', '"existing"');
|
|
22
|
-
|
|
23
|
-
const store = localStorageStore('myKey2', 'initial');
|
|
24
|
-
const value = get(store);
|
|
25
|
-
|
|
26
|
-
expect(value).toEqual('existing');
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
describe('set()', () => {
|
|
30
|
-
it('replaces old value', () => {
|
|
31
|
-
localStorage.setItem('myKey3', '"existing"');
|
|
32
|
-
|
|
33
|
-
const store = localStorageStore('myKey3', '');
|
|
34
|
-
store.set('new-value');
|
|
35
|
-
const value = get(store);
|
|
36
|
-
|
|
37
|
-
expect(localStorage.myKey3).toEqual('"new-value"');
|
|
38
|
-
expect(value).toEqual('new-value');
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
it('adds new value', () => {
|
|
42
|
-
const store = localStorageStore('myKey4', '');
|
|
43
|
-
store.set('new-value');
|
|
44
|
-
const value = get(store);
|
|
45
|
-
|
|
46
|
-
expect(localStorage.myKey4).toEqual('"new-value"');
|
|
47
|
-
expect(value).toEqual('new-value');
|
|
48
|
-
});
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
describe('update()', () => {
|
|
52
|
-
it('replaces old value', () => {
|
|
53
|
-
localStorage.setItem('myKey5', '123');
|
|
54
|
-
|
|
55
|
-
const store = localStorageStore('myKey5', 0);
|
|
56
|
-
store.update((n) => n + 1);
|
|
57
|
-
const value = get(store);
|
|
58
|
-
|
|
59
|
-
expect(localStorage.myKey5).toEqual('124');
|
|
60
|
-
expect(value).toEqual(124);
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
it('adds new value', () => {
|
|
64
|
-
const store = localStorageStore('myKey6', 123);
|
|
65
|
-
store.update((n) => n + 1);
|
|
66
|
-
const value = get(store);
|
|
67
|
-
|
|
68
|
-
expect(localStorage.myKey6).toEqual('124');
|
|
69
|
-
expect(value).toEqual(124);
|
|
70
|
-
});
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
describe('subscribe()', () => {
|
|
74
|
-
it('publishes updates', () => {
|
|
75
|
-
const store = localStorageStore('myKey7', 123);
|
|
76
|
-
const values: number[] = [];
|
|
77
|
-
const unsub = store.subscribe((value: number) => {
|
|
78
|
-
if (value !== undefined) values.push(value);
|
|
79
|
-
});
|
|
80
|
-
store.set(456);
|
|
81
|
-
store.set(999);
|
|
82
|
-
|
|
83
|
-
expect(values).toEqual([123, 456, 999]);
|
|
84
|
-
|
|
85
|
-
unsub();
|
|
86
|
-
});
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
it('handles duplicate stores with the same key', () => {
|
|
90
|
-
const store1 = localStorageStore('same-key', 1);
|
|
91
|
-
const values1: number[] = [];
|
|
92
|
-
|
|
93
|
-
const unsub1 = store1.subscribe((value) => {
|
|
94
|
-
values1.push(value);
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
store1.set(2);
|
|
98
|
-
|
|
99
|
-
const store2 = localStorageStore('same-key', 99);
|
|
100
|
-
const values2: number[] = [];
|
|
101
|
-
|
|
102
|
-
const unsub2 = store2.subscribe((value) => {
|
|
103
|
-
values2.push(value);
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
store1.set(3);
|
|
107
|
-
store2.set(4);
|
|
108
|
-
|
|
109
|
-
expect(values1).toEqual([1, 2, 3, 4]);
|
|
110
|
-
expect(values2).toEqual([2, 3, 4]);
|
|
111
|
-
expect(get(store1)).toEqual(get(store2));
|
|
112
|
-
|
|
113
|
-
expect(store1).toEqual(store2);
|
|
114
|
-
|
|
115
|
-
unsub1();
|
|
116
|
-
unsub2();
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
describe('handles window.storage event', () => {
|
|
120
|
-
type NumberDict = { [key: string]: number };
|
|
121
|
-
|
|
122
|
-
it('sets storage when key matches', () => {
|
|
123
|
-
const store = localStorageStore('myKey8', { a: 1 });
|
|
124
|
-
const values: NumberDict[] = [];
|
|
125
|
-
|
|
126
|
-
const unsub = store.subscribe((value: NumberDict) => {
|
|
127
|
-
values.push(value);
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
const event = new StorageEvent('storage', { key: 'myKey8', newValue: '{"a": 1, "b": 2}' });
|
|
131
|
-
window.dispatchEvent(event);
|
|
132
|
-
|
|
133
|
-
expect(values).toEqual([{ a: 1 }, { a: 1, b: 2 }]);
|
|
134
|
-
|
|
135
|
-
unsub();
|
|
136
|
-
});
|
|
137
|
-
|
|
138
|
-
it('sets store to null when value is null', () => {
|
|
139
|
-
const store = localStorageStore('myKey9', { a: 1 });
|
|
140
|
-
const values: NumberDict[] = [];
|
|
141
|
-
|
|
142
|
-
const unsub = store.subscribe((value: NumberDict) => {
|
|
143
|
-
values.push(value);
|
|
144
|
-
});
|
|
145
|
-
|
|
146
|
-
const event = new StorageEvent('storage', { key: 'myKey9', newValue: null });
|
|
147
|
-
window.dispatchEvent(event);
|
|
148
|
-
|
|
149
|
-
expect(values).toEqual([{ a: 1 }, null]);
|
|
150
|
-
|
|
151
|
-
unsub();
|
|
152
|
-
});
|
|
153
|
-
|
|
154
|
-
it("doesn't update store when key doesn't match", () => {
|
|
155
|
-
const store = localStorageStore('myKey10', 1);
|
|
156
|
-
const values: number[] = [];
|
|
157
|
-
|
|
158
|
-
const unsub = store.subscribe((value: number) => {
|
|
159
|
-
values.push(value);
|
|
160
|
-
});
|
|
161
|
-
|
|
162
|
-
const event = new StorageEvent('storage', { key: 'unknownKey', newValue: '2' });
|
|
163
|
-
window.dispatchEvent(event);
|
|
164
|
-
|
|
165
|
-
expect(values).toEqual([1]);
|
|
166
|
-
|
|
167
|
-
unsub();
|
|
168
|
-
});
|
|
169
|
-
|
|
170
|
-
it("doesn't update store when there are no subscribers", () => {
|
|
171
|
-
const store = localStorageStore('myKey', 1);
|
|
172
|
-
const values: number[] = [];
|
|
173
|
-
|
|
174
|
-
const event = new StorageEvent('storage', { key: 'myKey', newValue: '2' });
|
|
175
|
-
window.dispatchEvent(event);
|
|
176
|
-
localStorage.setItem('myKey', '2');
|
|
177
|
-
|
|
178
|
-
const unsub = store.subscribe((value: number) => {
|
|
179
|
-
values.push(value);
|
|
180
|
-
});
|
|
181
|
-
|
|
182
|
-
expect(values).toEqual([2]);
|
|
183
|
-
|
|
184
|
-
unsub();
|
|
185
|
-
});
|
|
186
|
-
});
|
|
187
|
-
|
|
188
|
-
it('allows custom serialize/deserialize functions', () => {
|
|
189
|
-
const serializer = {
|
|
190
|
-
stringify: (set: Set<number>) => JSON.stringify(Array.from(set)),
|
|
191
|
-
parse: (json: string) => new Set(JSON.parse(json))
|
|
192
|
-
};
|
|
193
|
-
|
|
194
|
-
const itSet = new Set([1, 2, 3]);
|
|
195
|
-
|
|
196
|
-
const store = localStorageStore('myKey11', itSet, { serializer });
|
|
197
|
-
const value = get(store);
|
|
198
|
-
|
|
199
|
-
store.update((d) => d.add(4));
|
|
200
|
-
|
|
201
|
-
expect(value).toEqual(itSet);
|
|
202
|
-
expect(localStorage.myKey11).toEqual(serializer.stringify(itSet));
|
|
203
|
-
});
|
|
204
|
-
|
|
205
|
-
// FIXME: need to replace the `jest` syntax here
|
|
206
|
-
// it('lets you switch storage type', () => {
|
|
207
|
-
// jest.spyOn(Object.getPrototypeOf(window.sessionStorage), 'setItem');
|
|
208
|
-
// Object.setPrototypeOf(window.sessionStorage.setItem, jest.fn());
|
|
209
|
-
|
|
210
|
-
// const value = 'foo';
|
|
211
|
-
|
|
212
|
-
// const store = localStorageStore('myKey12', value, {
|
|
213
|
-
// storage: 'session'
|
|
214
|
-
// });
|
|
215
|
-
|
|
216
|
-
// store.set('bar');
|
|
217
|
-
|
|
218
|
-
// expect(window.sessionStorage.setItem).toHaveBeenCalled();
|
|
219
|
-
// });
|
|
220
|
-
});
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
// Source: https://github.com/joshnuss/svelte-local-storage-store
|
|
2
|
-
// https://github.com/joshnuss/svelte-local-storage-store/blob/master/index.ts
|
|
3
|
-
// Represents version v0.3.1 (2022-08-21)
|
|
4
|
-
|
|
5
|
-
import { writable as internal, get, type Writable } from 'svelte/store';
|
|
6
|
-
|
|
7
|
-
declare type Updater<T> = (value: T) => T;
|
|
8
|
-
declare type StoreDict<T> = { [key: string]: Writable<T> };
|
|
9
|
-
|
|
10
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
11
|
-
const stores: StoreDict<any> = {};
|
|
12
|
-
|
|
13
|
-
interface Serializer<T> {
|
|
14
|
-
parse(text: string): T;
|
|
15
|
-
stringify(object: T): string;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
type StorageType = 'local' | 'session';
|
|
19
|
-
|
|
20
|
-
interface Options<T> {
|
|
21
|
-
serializer?: Serializer<T>;
|
|
22
|
-
storage?: StorageType;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function getStorage(type: StorageType) {
|
|
26
|
-
return type === 'local' ? localStorage : sessionStorage;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export function localStorageStore<T>(key: string, initialValue: T, options?: Options<T>): Writable<T> {
|
|
30
|
-
const serializer = options?.serializer ?? JSON;
|
|
31
|
-
const storageType = options?.storage ?? 'local';
|
|
32
|
-
const browser = typeof window !== 'undefined' && typeof document !== 'undefined';
|
|
33
|
-
|
|
34
|
-
function updateStorage(key: string, value: T) {
|
|
35
|
-
if (!browser) return;
|
|
36
|
-
|
|
37
|
-
getStorage(storageType).setItem(key, serializer.stringify(value));
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
if (!stores[key]) {
|
|
41
|
-
const store = internal(initialValue, (set) => {
|
|
42
|
-
const json = browser ? getStorage(storageType).getItem(key) : null;
|
|
43
|
-
|
|
44
|
-
if (json) {
|
|
45
|
-
set(<T>serializer.parse(json));
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
if (browser) {
|
|
49
|
-
const handleStorage = (event: StorageEvent) => {
|
|
50
|
-
if (event.key === key) set(event.newValue ? serializer.parse(event.newValue) : null);
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
window.addEventListener('storage', handleStorage);
|
|
54
|
-
|
|
55
|
-
return () => window.removeEventListener('storage', handleStorage);
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
const { subscribe, set } = store;
|
|
60
|
-
|
|
61
|
-
stores[key] = {
|
|
62
|
-
set(value: T) {
|
|
63
|
-
updateStorage(key, value);
|
|
64
|
-
set(value);
|
|
65
|
-
},
|
|
66
|
-
update(updater: Updater<T>) {
|
|
67
|
-
const value = updater(get(store));
|
|
68
|
-
|
|
69
|
-
updateStorage(key, value);
|
|
70
|
-
set(value);
|
|
71
|
-
},
|
|
72
|
-
subscribe
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
return stores[key];
|
|
77
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
// import { render } from '@testing-library/svelte';
|
|
2
|
-
import { describe, it, expect } from 'vitest';
|
|
3
|
-
|
|
4
|
-
// Action
|
|
5
|
-
import { menu } from '$lib/utilities/Menu/menu';
|
|
6
|
-
|
|
7
|
-
describe.skip('Action: Menu', () => {
|
|
8
|
-
// FIXME: TEST SKIPPED UNTIL FIXED
|
|
9
|
-
// Chris: Not sure why this isn't working, same pattern as filters.ts
|
|
10
|
-
it('Smoke Test', async () => {
|
|
11
|
-
// Element: Menu
|
|
12
|
-
const elemMenu: HTMLElement = document.createElement('div');
|
|
13
|
-
elemMenu.setAttribute('data-menu', 'test');
|
|
14
|
-
// Element: Button (trigger)
|
|
15
|
-
const elemButton: HTMLElement = document.createElement('button');
|
|
16
|
-
// Run Action
|
|
17
|
-
menu(elemButton, { menu: 'test' });
|
|
18
|
-
// Expect
|
|
19
|
-
// console.log(elemMenu.getAttribute('role')); // --> returns null???
|
|
20
|
-
expect(elemMenu.getAttribute('role')).to.eq('menu');
|
|
21
|
-
});
|
|
22
|
-
});
|
|
@@ -1,172 +0,0 @@
|
|
|
1
|
-
// Action: Menu
|
|
2
|
-
// https://svelte.dev/repl/0ace7a508bd843b798ae599940a91783?version=3.16.7
|
|
3
|
-
|
|
4
|
-
interface ArgsMenu {
|
|
5
|
-
/** The value of 'x' from data-menu-[x] */
|
|
6
|
-
menu: string;
|
|
7
|
-
/** Origin - TRUE: fixed | FALSE: auto */
|
|
8
|
-
fixed?: boolean;
|
|
9
|
-
/** Clicks inside body will not close window */
|
|
10
|
-
interactive?: boolean;
|
|
11
|
-
/** Provide an optional callback function to handle open/close state changes. */
|
|
12
|
-
state?: (e: { menu: string; state: boolean }) => void;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
// prettier-ignore
|
|
16
|
-
export function menu(node: HTMLElement, args: ArgsMenu) {
|
|
17
|
-
const elemMenu: HTMLElement | null = document.querySelector(`[data-menu="${args.menu}"]`);
|
|
18
|
-
if (!elemMenu) return;
|
|
19
|
-
|
|
20
|
-
const elemWhitelist: string = 'a[href], button, input, textarea, select, details, [tabindex]:not([tabindex="-1"])';
|
|
21
|
-
let activeFocusIdx: number;
|
|
22
|
-
let focusableElems: HTMLElement[];
|
|
23
|
-
|
|
24
|
-
const onInit = (): void => {
|
|
25
|
-
autoUpdateOrigin();
|
|
26
|
-
// Apply a11y attributes
|
|
27
|
-
elemMenu.setAttribute('role', 'menu');
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
// Menu States ---
|
|
31
|
-
|
|
32
|
-
const menuOpen = (openWithFocus: boolean = false): void => {
|
|
33
|
-
elemMenu.style.display = 'block';
|
|
34
|
-
stateEventHandler(true);
|
|
35
|
-
|
|
36
|
-
// Create array of all focusable elements, so that we can iterate through them
|
|
37
|
-
focusableElems = Array.from(elemMenu.querySelectorAll(elemWhitelist));
|
|
38
|
-
// reset the focus index
|
|
39
|
-
activeFocusIdx = -1;
|
|
40
|
-
|
|
41
|
-
if (openWithFocus) {
|
|
42
|
-
// Automatically focus the element if openWithFocus is true (for example if
|
|
43
|
-
// the menu was opened with Enter instead of with a click
|
|
44
|
-
activeFocusIdx = 0;
|
|
45
|
-
focusableElems[0]?.focus();
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
const menuClose = (): void => {
|
|
50
|
-
elemMenu.style.display = 'none';
|
|
51
|
-
stateEventHandler(false);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
const stateEventHandler = (state: boolean): void => {
|
|
55
|
-
if (args.state) args.state({menu: args.menu, state});
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
// Click Handlers ---
|
|
59
|
-
|
|
60
|
-
const toggleMenu = (): void => {
|
|
61
|
-
// When the node is clicked, open the menu if it is closed, otherwise close it
|
|
62
|
-
if (elemMenu.style.display != 'block') {
|
|
63
|
-
autoUpdateOrigin();
|
|
64
|
-
menuOpen();
|
|
65
|
-
} else {
|
|
66
|
-
menuClose();
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
const onWindowClick = (event: any): void => {
|
|
71
|
-
args.interactive === true ? interactiveClickHandler(event) : standardClickHandler(event);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
// Interactive FALSE - any click closes the menu
|
|
75
|
-
const standardClickHandler = (event: any): void => {
|
|
76
|
-
// Any click outside the node closes the menu, but a click inside the node toggles the menu.
|
|
77
|
-
const outsideNode = node && !node.contains(event.target);
|
|
78
|
-
if (outsideNode) { menuClose(); }
|
|
79
|
-
else { toggleMenu(); }
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
// Interactive TRUE - clicks outside close menu
|
|
83
|
-
const interactiveClickHandler = (event: any): void => {
|
|
84
|
-
const outsideNode = node && !node.contains(event.target);
|
|
85
|
-
const outsideMenu = elemMenu && !elemMenu.contains(event.target);
|
|
86
|
-
if (!outsideNode) { toggleMenu(); }
|
|
87
|
-
else if (outsideNode && outsideMenu) { menuClose(); }
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
// Menu - Set auto origin ---
|
|
91
|
-
|
|
92
|
-
const autoUpdateOrigin = (): void => {
|
|
93
|
-
if (!args.fixed && !elemMenu.classList.contains('hidden')) {
|
|
94
|
-
// Get the Menu's bounds
|
|
95
|
-
const elemTriggerBounds: DOMRect = node.getBoundingClientRect();
|
|
96
|
-
// Determine vertical and horizontal values
|
|
97
|
-
const vert: string = elemTriggerBounds.y < window.innerHeight / 2 ? 't' : 'b'; // top/bottom
|
|
98
|
-
const horz: string = elemTriggerBounds.x < window.innerWidth / 2 ? 'l' : 'r'; // left/right
|
|
99
|
-
// Strip and apply only the relevant class
|
|
100
|
-
elemMenu.classList.remove('menu-tl', 'menu-tr', 'menu-bl', 'menu-br');
|
|
101
|
-
elemMenu.classList.add(`menu-${vert}${horz}`);
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
// A11y Input Handlers ---
|
|
106
|
-
|
|
107
|
-
const onTriggerKeyDown = (event: KeyboardEvent): void => {
|
|
108
|
-
const key: string = event.key;
|
|
109
|
-
|
|
110
|
-
if (key === 'Enter' || key === 'Space') {
|
|
111
|
-
event.preventDefault();
|
|
112
|
-
|
|
113
|
-
// Toggle menu
|
|
114
|
-
toggleMenu();
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
const onWindowKeyDown = (event: KeyboardEvent): void => {
|
|
119
|
-
const key: string = event.key;
|
|
120
|
-
|
|
121
|
-
if (elemMenu.style.display === 'none') return;
|
|
122
|
-
|
|
123
|
-
if (key === 'Escape' || key === 'Tab') {
|
|
124
|
-
// Close the menu
|
|
125
|
-
event.preventDefault();
|
|
126
|
-
menuClose();
|
|
127
|
-
node.focus();
|
|
128
|
-
} else if (key === 'ArrowDown') {
|
|
129
|
-
event.preventDefault();
|
|
130
|
-
if (activeFocusIdx < focusableElems.length - 1) {
|
|
131
|
-
// Move down the menu
|
|
132
|
-
activeFocusIdx += 1;
|
|
133
|
-
focusableElems[activeFocusIdx]?.focus();
|
|
134
|
-
}
|
|
135
|
-
} else if (key === 'ArrowUp') {
|
|
136
|
-
event.preventDefault();
|
|
137
|
-
if (activeFocusIdx > 0) {
|
|
138
|
-
// Move up the menu
|
|
139
|
-
activeFocusIdx -= 1;
|
|
140
|
-
focusableElems[activeFocusIdx]?.focus();
|
|
141
|
-
} else if (focusableElems.length && activeFocusIdx === -1) {
|
|
142
|
-
// Start at the bottom of the menu if first key is arrow up key
|
|
143
|
-
event.preventDefault();
|
|
144
|
-
activeFocusIdx = focusableElems.length - 1;
|
|
145
|
-
focusableElems[activeFocusIdx]?.focus();
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
// On Action Init
|
|
151
|
-
onInit();
|
|
152
|
-
// Window Events
|
|
153
|
-
window.addEventListener('resize', autoUpdateOrigin, true)
|
|
154
|
-
window.addEventListener('click', onWindowClick, true);
|
|
155
|
-
window.addEventListener('keydown', onWindowKeyDown, true);
|
|
156
|
-
// Trigger Node Events
|
|
157
|
-
node.addEventListener('keydown', onTriggerKeyDown);
|
|
158
|
-
node.addEventListener('change', (e: any) => {
|
|
159
|
-
console.log(e);
|
|
160
|
-
})
|
|
161
|
-
|
|
162
|
-
// Lifecycle
|
|
163
|
-
return {
|
|
164
|
-
update: (newArgs: ArgsMenu) => { args = newArgs },
|
|
165
|
-
destroy: (): void => {
|
|
166
|
-
window.removeEventListener('resize', onWindowClick, true);
|
|
167
|
-
window.removeEventListener('click', onWindowClick, true);
|
|
168
|
-
window.removeEventListener('keydown', onWindowKeyDown, true);
|
|
169
|
-
node.removeEventListener('keydown', onTriggerKeyDown);
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
}
|
|
@@ -1,206 +0,0 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import { createEventDispatcher } from 'svelte';
|
|
3
|
-
import { fade, fly } from 'svelte/transition';
|
|
4
|
-
|
|
5
|
-
// Event Handler
|
|
6
|
-
const dispatch = createEventDispatcher();
|
|
7
|
-
|
|
8
|
-
import { focusTrap } from '$lib/actions/FocusTrap/focusTrap';
|
|
9
|
-
import { modalStore } from '$lib/utilities/Modal/stores';
|
|
10
|
-
import type { ModalSettings } from './types';
|
|
11
|
-
|
|
12
|
-
// Props
|
|
13
|
-
/** The open/close animation duration. Set '0' (zero) to disable. */
|
|
14
|
-
export let duration = 150;
|
|
15
|
-
|
|
16
|
-
// Props (modal)
|
|
17
|
-
/** Provide classes to style the modal background. */
|
|
18
|
-
export let background = 'bg-surface-100-800-token';
|
|
19
|
-
/** Provide classes to style the modal width. */
|
|
20
|
-
export let width = 'w-full max-w-[640px]';
|
|
21
|
-
/** Provide classes to style the modal. */
|
|
22
|
-
export let height = 'h-auto';
|
|
23
|
-
/** Provide classes to style the modal padding. */
|
|
24
|
-
export let padding = 'p-4';
|
|
25
|
-
/** Provide classes to style the modal spacing. */
|
|
26
|
-
export let spacing = 'space-y-4';
|
|
27
|
-
/** Provide classes to style the modal border radius. */
|
|
28
|
-
export let rounded = 'rounded-container-token';
|
|
29
|
-
/** Provide classes to style modal box shadow. */
|
|
30
|
-
export let shadow = 'shadow-xl';
|
|
31
|
-
|
|
32
|
-
// Props (buttons)
|
|
33
|
-
/** Provide classes for neutral buttons, such as Cancel. */
|
|
34
|
-
export let buttonNeutral = 'btn-ghost-surface';
|
|
35
|
-
/** Provide classes for positive actions, such as Confirm or Submit. */
|
|
36
|
-
export let buttonPositive = 'btn-filled-primary';
|
|
37
|
-
/** Override the text for the Cancel button. */
|
|
38
|
-
export let buttonTextCancel = 'Cancel';
|
|
39
|
-
/** Override the text for the Confirm button. */
|
|
40
|
-
export let buttonTextConfirm = 'Confirm';
|
|
41
|
-
/** Override the text for the Submit button. */
|
|
42
|
-
export let buttonTextSubmit = 'Submit';
|
|
43
|
-
|
|
44
|
-
// Props (regions)
|
|
45
|
-
/** Provide classes to style the backdrop. */
|
|
46
|
-
export let regionBackdrop = 'bg-surface-backdrop-token';
|
|
47
|
-
/** Provide arbitrary classes to modal header region. */
|
|
48
|
-
export let regionHeader = 'text-2xl font-bold';
|
|
49
|
-
/** Provide arbitrary classes to modal body region. */
|
|
50
|
-
export let regionBody = 'max-h-[200px] overflow-hidden';
|
|
51
|
-
/** Provide arbitrary classes to modal footer region. */
|
|
52
|
-
export let regionFooter = 'flex justify-end space-x-2';
|
|
53
|
-
|
|
54
|
-
// Base Styles
|
|
55
|
-
const cBackdrop = 'fixed top-0 left-0 right-0 bottom-0 z-[999] flex justify-center items-center p-4';
|
|
56
|
-
const cModal = 'max-h-full overflow-y-auto overflow-x-hidden';
|
|
57
|
-
const cModalImage = 'w-full h-auto';
|
|
58
|
-
|
|
59
|
-
// Local
|
|
60
|
-
let promptValue: any;
|
|
61
|
-
const buttonTextDefaults: Record<string, string> = {
|
|
62
|
-
buttonTextCancel,
|
|
63
|
-
buttonTextConfirm,
|
|
64
|
-
buttonTextSubmit
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
// Modal Store Subscription
|
|
68
|
-
modalStore.subscribe((dArr: ModalSettings[]) => {
|
|
69
|
-
if (!dArr.length) return;
|
|
70
|
-
// Set Prompt input value and type
|
|
71
|
-
promptValue = dArr[0].value;
|
|
72
|
-
// Override button text per instance, if available
|
|
73
|
-
buttonTextCancel = dArr[0].buttonTextCancel || buttonTextDefaults.buttonTextCancel;
|
|
74
|
-
buttonTextConfirm = dArr[0].buttonTextConfirm || buttonTextDefaults.buttonTextConfirm;
|
|
75
|
-
buttonTextSubmit = dArr[0].buttonTextSubmit || buttonTextDefaults.buttonTextSubmit;
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
// Event Handlers ---
|
|
79
|
-
|
|
80
|
-
function onBackdropInteraction(event: MouseEvent | TouchEvent): void {
|
|
81
|
-
if (!(event.target instanceof Element)) return;
|
|
82
|
-
if (event.target.classList.contains('modal-backdrop')) onClose();
|
|
83
|
-
/** @event {{ event }} backdrop - Fires on backdrop interaction. */
|
|
84
|
-
dispatch('backdrop', event);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
function onClose(): void {
|
|
88
|
-
if ($modalStore[0].response) $modalStore[0].response(false);
|
|
89
|
-
modalStore.close();
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
function onConfirm(): void {
|
|
93
|
-
if ($modalStore[0].response) $modalStore[0].response(true);
|
|
94
|
-
modalStore.close();
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
function onPromptSubmit(): void {
|
|
98
|
-
if ($modalStore[0].response) $modalStore[0].response(promptValue);
|
|
99
|
-
modalStore.close();
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
// A11y ---
|
|
103
|
-
|
|
104
|
-
function onKeyDown(event: KeyboardEvent): void {
|
|
105
|
-
if (!$modalStore.length) return;
|
|
106
|
-
if (event.code === 'Escape') onClose();
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
// Reactive
|
|
110
|
-
$: classesBackdrop = `${cBackdrop} ${regionBackdrop} ${$$props.class || ''}`;
|
|
111
|
-
$: classesModal = `${cModal} ${background} ${width} ${height} ${padding} ${spacing} ${rounded} ${shadow}`;
|
|
112
|
-
// IMPORTANT: add values to pass to the children templates.
|
|
113
|
-
// There is a way to self-reference component values, but it involes svelte-internal and is not yet stable.
|
|
114
|
-
// REPL: https://svelte.dev/repl/badd0f11aa99450ca69dca6690d4d5a4?version=3.52.0
|
|
115
|
-
// Source: https://discord.com/channels/457912077277855764/1037768846855118909
|
|
116
|
-
$: parent = {
|
|
117
|
-
background,
|
|
118
|
-
width,
|
|
119
|
-
height,
|
|
120
|
-
padding,
|
|
121
|
-
spacing,
|
|
122
|
-
rounded,
|
|
123
|
-
shadow,
|
|
124
|
-
// ---
|
|
125
|
-
buttonNeutral,
|
|
126
|
-
buttonPositive,
|
|
127
|
-
buttonTextCancel,
|
|
128
|
-
buttonTextConfirm,
|
|
129
|
-
buttonTextSubmit,
|
|
130
|
-
// ---
|
|
131
|
-
regionBackdrop,
|
|
132
|
-
regionHeader,
|
|
133
|
-
regionBody,
|
|
134
|
-
regionFooter,
|
|
135
|
-
// ---
|
|
136
|
-
onClose
|
|
137
|
-
};
|
|
138
|
-
</script>
|
|
139
|
-
|
|
140
|
-
<svelte:window on:keydown={onKeyDown} />
|
|
141
|
-
|
|
142
|
-
{#if $modalStore.length > 0}
|
|
143
|
-
{#key $modalStore}
|
|
144
|
-
<!-- Backdrop -->
|
|
145
|
-
<div
|
|
146
|
-
class="modal-backdrop {classesBackdrop} {$modalStore[0].backdropClasses}"
|
|
147
|
-
on:mousedown={onBackdropInteraction}
|
|
148
|
-
on:touchstart={onBackdropInteraction}
|
|
149
|
-
transition:fade={{ duration }}
|
|
150
|
-
data-testid="modal-backdrop"
|
|
151
|
-
>
|
|
152
|
-
<!-- Modal -->
|
|
153
|
-
<div
|
|
154
|
-
class="modal {classesModal} {$modalStore[0].modalClasses}"
|
|
155
|
-
transition:fly={{ duration, opacity: 0, y: 100 }}
|
|
156
|
-
use:focusTrap={true}
|
|
157
|
-
data-testid="modal"
|
|
158
|
-
role="dialog"
|
|
159
|
-
aria-modal="true"
|
|
160
|
-
aria-label={$modalStore[0].title}
|
|
161
|
-
>
|
|
162
|
-
<!-- Header -->
|
|
163
|
-
{#if $modalStore[0]?.title}
|
|
164
|
-
<header class="modal-header {regionHeader}">{@html $modalStore[0].title}</header>
|
|
165
|
-
{/if}
|
|
166
|
-
<!-- Body -->
|
|
167
|
-
{#if $modalStore[0]?.body}
|
|
168
|
-
<article class="modal-body {regionBody}">{@html $modalStore[0].body}</article>
|
|
169
|
-
{/if}
|
|
170
|
-
<!-- Image -->
|
|
171
|
-
{#if $modalStore[0]?.image && typeof $modalStore[0]?.image === 'string'}
|
|
172
|
-
<img class="modal-image {cModalImage}" src={$modalStore[0]?.image} alt="Modal" />
|
|
173
|
-
{/if}
|
|
174
|
-
<!-- Type -->
|
|
175
|
-
{#if $modalStore[0].type === 'alert'}
|
|
176
|
-
<!-- Template: Alert -->
|
|
177
|
-
<footer class="modal-footer {regionFooter}">
|
|
178
|
-
<!-- prettier-ignore -->
|
|
179
|
-
<button class="btn {buttonNeutral}" on:click={onClose}>{buttonTextCancel}</button>
|
|
180
|
-
</footer>
|
|
181
|
-
{:else if $modalStore[0].type === 'confirm'}
|
|
182
|
-
<!-- Template: Confirm -->
|
|
183
|
-
<!-- prettier-ignore -->
|
|
184
|
-
<footer class="modal-footer {regionFooter}">
|
|
185
|
-
<button class="btn {buttonNeutral}" on:click={onClose}>{buttonTextCancel}</button>
|
|
186
|
-
<button class="btn {buttonPositive}" on:click={onConfirm}>{buttonTextConfirm}</button>
|
|
187
|
-
</footer>
|
|
188
|
-
{:else if $modalStore[0].type === 'prompt'}
|
|
189
|
-
<!-- Template: Prompt -->
|
|
190
|
-
<input class="modal-prompt-input" type="text" bind:value={promptValue} />
|
|
191
|
-
<!-- prettier-ignore -->
|
|
192
|
-
<footer class="modal-footer {regionFooter}">
|
|
193
|
-
<button class="btn {buttonNeutral}" on:click={onClose}>{buttonTextCancel}</button>
|
|
194
|
-
<button class="btn {buttonPositive}" on:click={onPromptSubmit} disabled={!promptValue}>{buttonTextSubmit}</button>
|
|
195
|
-
</footer>
|
|
196
|
-
{:else if $modalStore[0].type === 'component'}
|
|
197
|
-
<!-- Template: Component -->
|
|
198
|
-
<!-- NOTE: users are repsonsible for handling all UI, including cancel/submit buttons -->
|
|
199
|
-
<svelte:component this={$modalStore[0].component?.ref} {...$modalStore[0].component?.props} {parent}>
|
|
200
|
-
{@html $modalStore[0].component?.slot}
|
|
201
|
-
</svelte:component>
|
|
202
|
-
{/if}
|
|
203
|
-
</div>
|
|
204
|
-
</div>
|
|
205
|
-
{/key}
|
|
206
|
-
{/if}
|