@marwes-ui/svelte 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +42 -0
- package/LICENSE +21 -0
- package/README.md +518 -0
- package/dist/components/accordion/Accordion.svelte +56 -0
- package/dist/components/accordion/Accordion.svelte.d.ts +4 -0
- package/dist/components/accordion/AccordionField.svelte +90 -0
- package/dist/components/accordion/AccordionField.svelte.d.ts +4 -0
- package/dist/components/accordion/FAQAccordion.svelte +21 -0
- package/dist/components/accordion/FAQAccordion.svelte.d.ts +20 -0
- package/dist/components/accordion/README.md +19 -0
- package/dist/components/accordion/SectionsAccordion.svelte +22 -0
- package/dist/components/accordion/SectionsAccordion.svelte.d.ts +21 -0
- package/dist/components/accordion/SettingsAccordion.svelte +21 -0
- package/dist/components/accordion/SettingsAccordion.svelte.d.ts +20 -0
- package/dist/components/accordion/index.d.ts +2 -0
- package/dist/components/accordion/index.js +1 -0
- package/dist/components/accordion/types.d.ts +28 -0
- package/dist/components/accordion/types.js +1 -0
- package/dist/components/avatar/Avatar.svelte +45 -0
- package/dist/components/avatar/Avatar.svelte.d.ts +4 -0
- package/dist/components/avatar/AvatarBadge.svelte +47 -0
- package/dist/components/avatar/AvatarBadge.svelte.d.ts +7 -0
- package/dist/components/avatar/AvatarGroup.svelte +50 -0
- package/dist/components/avatar/AvatarGroup.svelte.d.ts +15 -0
- package/dist/components/avatar/PresenceAvatar.svelte +12 -0
- package/dist/components/avatar/PresenceAvatar.svelte.d.ts +7 -0
- package/dist/components/avatar/ProfileAvatar.svelte +7 -0
- package/dist/components/avatar/ProfileAvatar.svelte.d.ts +4 -0
- package/dist/components/avatar/README.md +19 -0
- package/dist/components/avatar/TeamAvatarGroup.svelte +21 -0
- package/dist/components/avatar/TeamAvatarGroup.svelte.d.ts +15 -0
- package/dist/components/avatar/index.d.ts +2 -0
- package/dist/components/avatar/index.js +1 -0
- package/dist/components/avatar/types.d.ts +6 -0
- package/dist/components/avatar/types.js +1 -0
- package/dist/components/badge/Badge.svelte +26 -0
- package/dist/components/badge/Badge.svelte.d.ts +4 -0
- package/dist/components/badge/BadgeGroup.svelte +25 -0
- package/dist/components/badge/BadgeGroup.svelte.d.ts +4 -0
- package/dist/components/badge/NotificationBadge.svelte +7 -0
- package/dist/components/badge/NotificationBadge.svelte.d.ts +4 -0
- package/dist/components/badge/PriorityBadge.svelte +7 -0
- package/dist/components/badge/PriorityBadge.svelte.d.ts +4 -0
- package/dist/components/badge/README.md +16 -0
- package/dist/components/badge/StatusBadge.svelte +7 -0
- package/dist/components/badge/StatusBadge.svelte.d.ts +4 -0
- package/dist/components/badge/index.d.ts +3 -0
- package/dist/components/badge/index.js +2 -0
- package/dist/components/badge/types.d.ts +15 -0
- package/dist/components/badge/types.js +1 -0
- package/dist/components/button/Button.svelte +92 -0
- package/dist/components/button/Button.svelte.d.ts +4 -0
- package/dist/components/button/CancelButton.svelte +8 -0
- package/dist/components/button/CancelButton.svelte.d.ts +5 -0
- package/dist/components/button/CloseButton.svelte +8 -0
- package/dist/components/button/CloseButton.svelte.d.ts +5 -0
- package/dist/components/button/ConfirmButton.svelte +8 -0
- package/dist/components/button/ConfirmButton.svelte.d.ts +5 -0
- package/dist/components/button/CopyButton.svelte +8 -0
- package/dist/components/button/CopyButton.svelte.d.ts +5 -0
- package/dist/components/button/CreateButton.svelte +7 -0
- package/dist/components/button/CreateButton.svelte.d.ts +5 -0
- package/dist/components/button/DestructiveButton.svelte +8 -0
- package/dist/components/button/DestructiveButton.svelte.d.ts +5 -0
- package/dist/components/button/DownloadButton.svelte +8 -0
- package/dist/components/button/DownloadButton.svelte.d.ts +5 -0
- package/dist/components/button/DropdownButton.svelte +8 -0
- package/dist/components/button/DropdownButton.svelte.d.ts +5 -0
- package/dist/components/button/EditButton.svelte +8 -0
- package/dist/components/button/EditButton.svelte.d.ts +5 -0
- package/dist/components/button/FilterButton.svelte +8 -0
- package/dist/components/button/FilterButton.svelte.d.ts +5 -0
- package/dist/components/button/LinkButton.svelte +8 -0
- package/dist/components/button/LinkButton.svelte.d.ts +5 -0
- package/dist/components/button/PrimaryButton.svelte +7 -0
- package/dist/components/button/PrimaryButton.svelte.d.ts +5 -0
- package/dist/components/button/README.md +21 -0
- package/dist/components/button/RefreshButton.svelte +8 -0
- package/dist/components/button/RefreshButton.svelte.d.ts +5 -0
- package/dist/components/button/SaveButton.svelte +8 -0
- package/dist/components/button/SaveButton.svelte.d.ts +5 -0
- package/dist/components/button/SearchButton.svelte +8 -0
- package/dist/components/button/SearchButton.svelte.d.ts +5 -0
- package/dist/components/button/SecondaryButton.svelte +7 -0
- package/dist/components/button/SecondaryButton.svelte.d.ts +5 -0
- package/dist/components/button/SortButton.svelte +8 -0
- package/dist/components/button/SortButton.svelte.d.ts +5 -0
- package/dist/components/button/SubmitButton.svelte +7 -0
- package/dist/components/button/SubmitButton.svelte.d.ts +5 -0
- package/dist/components/button/SuccessButton.svelte +7 -0
- package/dist/components/button/SuccessButton.svelte.d.ts +5 -0
- package/dist/components/button/TextButton.svelte +7 -0
- package/dist/components/button/TextButton.svelte.d.ts +5 -0
- package/dist/components/button/UploadButton.svelte +8 -0
- package/dist/components/button/UploadButton.svelte.d.ts +5 -0
- package/dist/components/button/VerifyButton.svelte +8 -0
- package/dist/components/button/VerifyButton.svelte.d.ts +5 -0
- package/dist/components/button/index.d.ts +2 -0
- package/dist/components/button/index.js +1 -0
- package/dist/components/button/types.d.ts +8 -0
- package/dist/components/button/types.js +1 -0
- package/dist/components/card/Card.svelte +33 -0
- package/dist/components/card/Card.svelte.d.ts +4 -0
- package/dist/components/card/ProductCard.svelte +6 -0
- package/dist/components/card/ProductCard.svelte.d.ts +4 -0
- package/dist/components/card/ProfileCard.svelte +6 -0
- package/dist/components/card/ProfileCard.svelte.d.ts +4 -0
- package/dist/components/card/README.md +15 -0
- package/dist/components/card/StatCard.svelte +6 -0
- package/dist/components/card/StatCard.svelte.d.ts +4 -0
- package/dist/components/card/index.d.ts +2 -0
- package/dist/components/card/index.js +1 -0
- package/dist/components/card/types.d.ts +10 -0
- package/dist/components/card/types.js +1 -0
- package/dist/components/checkbox/Checkbox.svelte +54 -0
- package/dist/components/checkbox/Checkbox.svelte.d.ts +4 -0
- package/dist/components/checkbox/CheckboxField.svelte +74 -0
- package/dist/components/checkbox/CheckboxField.svelte.d.ts +4 -0
- package/dist/components/checkbox/CheckboxGroupField.svelte +50 -0
- package/dist/components/checkbox/CheckboxGroupField.svelte.d.ts +4 -0
- package/dist/components/checkbox/README.md +17 -0
- package/dist/components/checkbox/index.d.ts +3 -0
- package/dist/components/checkbox/index.js +2 -0
- package/dist/components/checkbox/types.d.ts +30 -0
- package/dist/components/checkbox/types.js +1 -0
- package/dist/components/date-picker/DatePicker.svelte +108 -0
- package/dist/components/date-picker/DatePicker.svelte.d.ts +4 -0
- package/dist/components/date-picker/README.md +17 -0
- package/dist/components/date-picker/index.d.ts +2 -0
- package/dist/components/date-picker/index.js +1 -0
- package/dist/components/date-picker/types.d.ts +13 -0
- package/dist/components/date-picker/types.js +1 -0
- package/dist/components/dialog/ConfirmDialog.svelte +28 -0
- package/dist/components/dialog/ConfirmDialog.svelte.d.ts +4 -0
- package/dist/components/dialog/DestructiveDialog.svelte +28 -0
- package/dist/components/dialog/DestructiveDialog.svelte.d.ts +4 -0
- package/dist/components/dialog/Dialog.svelte +114 -0
- package/dist/components/dialog/Dialog.svelte.d.ts +4 -0
- package/dist/components/dialog/DialogModal.svelte +120 -0
- package/dist/components/dialog/DialogModal.svelte.d.ts +4 -0
- package/dist/components/dialog/InfoDialog.svelte +24 -0
- package/dist/components/dialog/InfoDialog.svelte.d.ts +4 -0
- package/dist/components/dialog/README.md +23 -0
- package/dist/components/dialog/index.d.ts +6 -0
- package/dist/components/dialog/index.js +5 -0
- package/dist/components/dialog/types.d.ts +42 -0
- package/dist/components/dialog/types.js +1 -0
- package/dist/components/divider/Divider.svelte +25 -0
- package/dist/components/divider/Divider.svelte.d.ts +4 -0
- package/dist/components/divider/README.md +15 -0
- package/dist/components/divider/index.d.ts +2 -0
- package/dist/components/divider/index.js +1 -0
- package/dist/components/divider/types.d.ts +5 -0
- package/dist/components/divider/types.js +1 -0
- package/dist/components/heading/H1.svelte +23 -0
- package/dist/components/heading/H1.svelte.d.ts +4 -0
- package/dist/components/heading/H2.svelte +23 -0
- package/dist/components/heading/H2.svelte.d.ts +4 -0
- package/dist/components/heading/H3.svelte +23 -0
- package/dist/components/heading/H3.svelte.d.ts +4 -0
- package/dist/components/heading/README.md +13 -0
- package/dist/components/heading/index.d.ts +4 -0
- package/dist/components/heading/index.js +3 -0
- package/dist/components/heading/types.d.ts +26 -0
- package/dist/components/heading/types.js +1 -0
- package/dist/components/icon/Icon.svelte +65 -0
- package/dist/components/icon/Icon.svelte.d.ts +4 -0
- package/dist/components/icon/README.md +18 -0
- package/dist/components/icon/index.d.ts +2 -0
- package/dist/components/icon/index.js +1 -0
- package/dist/components/icon/types.d.ts +12 -0
- package/dist/components/icon/types.js +1 -0
- package/dist/components/input/CurrencyField.svelte +12 -0
- package/dist/components/input/CurrencyField.svelte.d.ts +7 -0
- package/dist/components/input/DateOfBirthField.svelte +21 -0
- package/dist/components/input/DateOfBirthField.svelte.d.ts +14 -0
- package/dist/components/input/DropdownField.svelte +29 -0
- package/dist/components/input/DropdownField.svelte.d.ts +14 -0
- package/dist/components/input/EmailField.svelte +9 -0
- package/dist/components/input/EmailField.svelte.d.ts +7 -0
- package/dist/components/input/Input.svelte +49 -0
- package/dist/components/input/Input.svelte.d.ts +4 -0
- package/dist/components/input/InputField.svelte +139 -0
- package/dist/components/input/InputField.svelte.d.ts +4 -0
- package/dist/components/input/InputOtp.svelte +140 -0
- package/dist/components/input/InputOtp.svelte.d.ts +4 -0
- package/dist/components/input/PasswordField.svelte +9 -0
- package/dist/components/input/PasswordField.svelte.d.ts +7 -0
- package/dist/components/input/PhoneField.svelte +9 -0
- package/dist/components/input/PhoneField.svelte.d.ts +7 -0
- package/dist/components/input/README.md +24 -0
- package/dist/components/input/RichText.svelte +177 -0
- package/dist/components/input/RichText.svelte.d.ts +4 -0
- package/dist/components/input/RichTextField.svelte +84 -0
- package/dist/components/input/RichTextField.svelte.d.ts +4 -0
- package/dist/components/input/SearchField.svelte +9 -0
- package/dist/components/input/SearchField.svelte.d.ts +7 -0
- package/dist/components/input/Select.svelte +88 -0
- package/dist/components/input/Select.svelte.d.ts +4 -0
- package/dist/components/input/SelectField.svelte +395 -0
- package/dist/components/input/SelectField.svelte.d.ts +4 -0
- package/dist/components/input/Textarea.svelte +50 -0
- package/dist/components/input/Textarea.svelte.d.ts +4 -0
- package/dist/components/input/TextareaField.svelte +57 -0
- package/dist/components/input/TextareaField.svelte.d.ts +4 -0
- package/dist/components/input/URLField.svelte +9 -0
- package/dist/components/input/URLField.svelte.d.ts +7 -0
- package/dist/components/input/ZipCodeField.svelte +21 -0
- package/dist/components/input/ZipCodeField.svelte.d.ts +14 -0
- package/dist/components/input/index.d.ts +7 -0
- package/dist/components/input/index.js +6 -0
- package/dist/components/input/types.d.ts +104 -0
- package/dist/components/input/types.js +1 -0
- package/dist/components/paragraph/Paragraph.svelte +23 -0
- package/dist/components/paragraph/Paragraph.svelte.d.ts +4 -0
- package/dist/components/paragraph/README.md +13 -0
- package/dist/components/paragraph/index.d.ts +2 -0
- package/dist/components/paragraph/index.js +1 -0
- package/dist/components/paragraph/types.d.ts +9 -0
- package/dist/components/paragraph/types.js +1 -0
- package/dist/components/radio/OptionRadioGroup.svelte +52 -0
- package/dist/components/radio/OptionRadioGroup.svelte.d.ts +21 -0
- package/dist/components/radio/README.md +16 -0
- package/dist/components/radio/Radio.svelte +38 -0
- package/dist/components/radio/Radio.svelte.d.ts +4 -0
- package/dist/components/radio/RadioGroupField.svelte +75 -0
- package/dist/components/radio/RadioGroupField.svelte.d.ts +4 -0
- package/dist/components/radio/RatingRadioGroup.svelte +51 -0
- package/dist/components/radio/RatingRadioGroup.svelte.d.ts +17 -0
- package/dist/components/radio/YesNoRadioGroup.svelte +48 -0
- package/dist/components/radio/YesNoRadioGroup.svelte.d.ts +16 -0
- package/dist/components/radio/index.d.ts +3 -0
- package/dist/components/radio/index.js +2 -0
- package/dist/components/radio/types.d.ts +22 -0
- package/dist/components/radio/types.js +1 -0
- package/dist/components/skeleton/README.md +16 -0
- package/dist/components/skeleton/Skeleton.svelte +29 -0
- package/dist/components/skeleton/Skeleton.svelte.d.ts +4 -0
- package/dist/components/skeleton/index.d.ts +2 -0
- package/dist/components/skeleton/index.js +1 -0
- package/dist/components/skeleton/types.d.ts +6 -0
- package/dist/components/skeleton/types.js +1 -0
- package/dist/components/slider/BrightnessSlider.svelte +31 -0
- package/dist/components/slider/BrightnessSlider.svelte.d.ts +11 -0
- package/dist/components/slider/README.md +20 -0
- package/dist/components/slider/RadiusSlider.svelte +31 -0
- package/dist/components/slider/RadiusSlider.svelte.d.ts +11 -0
- package/dist/components/slider/Slider.svelte +67 -0
- package/dist/components/slider/Slider.svelte.d.ts +4 -0
- package/dist/components/slider/SliderField.svelte +115 -0
- package/dist/components/slider/SliderField.svelte.d.ts +4 -0
- package/dist/components/slider/VolumeSlider.svelte +31 -0
- package/dist/components/slider/VolumeSlider.svelte.d.ts +11 -0
- package/dist/components/slider/index.d.ts +2 -0
- package/dist/components/slider/index.js +1 -0
- package/dist/components/slider/types.d.ts +28 -0
- package/dist/components/slider/types.js +1 -0
- package/dist/components/spacing/README.md +15 -0
- package/dist/components/spacing/Spacer.svelte +8 -0
- package/dist/components/spacing/Spacer.svelte.d.ts +3 -0
- package/dist/components/spacing/Spacing.svelte +23 -0
- package/dist/components/spacing/Spacing.svelte.d.ts +4 -0
- package/dist/components/spacing/index.d.ts +3 -0
- package/dist/components/spacing/index.js +2 -0
- package/dist/components/spacing/types.d.ts +7 -0
- package/dist/components/spacing/types.js +1 -0
- package/dist/components/spinner/ButtonSpinner.svelte +35 -0
- package/dist/components/spinner/ButtonSpinner.svelte.d.ts +4 -0
- package/dist/components/spinner/EmptyStateSpinner.svelte +20 -0
- package/dist/components/spinner/EmptyStateSpinner.svelte.d.ts +4 -0
- package/dist/components/spinner/README.md +19 -0
- package/dist/components/spinner/Spinner.svelte +60 -0
- package/dist/components/spinner/Spinner.svelte.d.ts +4 -0
- package/dist/components/spinner/index.d.ts +3 -0
- package/dist/components/spinner/index.js +2 -0
- package/dist/components/spinner/types.d.ts +9 -0
- package/dist/components/spinner/types.js +1 -0
- package/dist/components/stat-tile/README.md +15 -0
- package/dist/components/stat-tile/StatTile.svelte +44 -0
- package/dist/components/stat-tile/StatTile.svelte.d.ts +4 -0
- package/dist/components/stat-tile/index.d.ts +2 -0
- package/dist/components/stat-tile/index.js +1 -0
- package/dist/components/stat-tile/types.d.ts +14 -0
- package/dist/components/stat-tile/types.js +1 -0
- package/dist/components/switch/FeatureToggle.svelte +19 -0
- package/dist/components/switch/FeatureToggle.svelte.d.ts +13 -0
- package/dist/components/switch/PermissionSwitch.svelte +19 -0
- package/dist/components/switch/PermissionSwitch.svelte.d.ts +13 -0
- package/dist/components/switch/PreferenceSwitch.svelte +19 -0
- package/dist/components/switch/PreferenceSwitch.svelte.d.ts +13 -0
- package/dist/components/switch/README.md +17 -0
- package/dist/components/switch/Switch.svelte +52 -0
- package/dist/components/switch/Switch.svelte.d.ts +4 -0
- package/dist/components/switch/SwitchField.svelte +71 -0
- package/dist/components/switch/SwitchField.svelte.d.ts +4 -0
- package/dist/components/switch/index.d.ts +3 -0
- package/dist/components/switch/index.js +2 -0
- package/dist/components/switch/types.d.ts +20 -0
- package/dist/components/switch/types.js +1 -0
- package/dist/components/tab/ContentTabs.svelte +11 -0
- package/dist/components/tab/ContentTabs.svelte.d.ts +3 -0
- package/dist/components/tab/NavigationTabs.svelte +11 -0
- package/dist/components/tab/NavigationTabs.svelte.d.ts +3 -0
- package/dist/components/tab/README.md +26 -0
- package/dist/components/tab/SettingsTabs.svelte +11 -0
- package/dist/components/tab/SettingsTabs.svelte.d.ts +3 -0
- package/dist/components/tab/Tab.svelte +32 -0
- package/dist/components/tab/Tab.svelte.d.ts +4 -0
- package/dist/components/tab/TabGroup.svelte +132 -0
- package/dist/components/tab/TabGroup.svelte.d.ts +4 -0
- package/dist/components/tab/TabPanel.svelte +25 -0
- package/dist/components/tab/TabPanel.svelte.d.ts +4 -0
- package/dist/components/tab/index.d.ts +7 -0
- package/dist/components/tab/index.js +6 -0
- package/dist/components/tab/types.d.ts +36 -0
- package/dist/components/tab/types.js +1 -0
- package/dist/components/toast/ErrorToast.svelte +24 -0
- package/dist/components/toast/ErrorToast.svelte.d.ts +4 -0
- package/dist/components/toast/InfoToast.svelte +24 -0
- package/dist/components/toast/InfoToast.svelte.d.ts +4 -0
- package/dist/components/toast/README.md +35 -0
- package/dist/components/toast/SuccessToast.svelte +25 -0
- package/dist/components/toast/SuccessToast.svelte.d.ts +4 -0
- package/dist/components/toast/Toast.svelte +53 -0
- package/dist/components/toast/Toast.svelte.d.ts +4 -0
- package/dist/components/toast/ToastContainer.svelte +212 -0
- package/dist/components/toast/ToastContainer.svelte.d.ts +4 -0
- package/dist/components/toast/ToastProvider.svelte +71 -0
- package/dist/components/toast/ToastProvider.svelte.d.ts +7 -0
- package/dist/components/toast/WarningToast.svelte +24 -0
- package/dist/components/toast/WarningToast.svelte.d.ts +4 -0
- package/dist/components/toast/index.d.ts +9 -0
- package/dist/components/toast/index.js +8 -0
- package/dist/components/toast/types.d.ts +48 -0
- package/dist/components/toast/types.js +1 -0
- package/dist/components/tooltip/README.md +22 -0
- package/dist/components/tooltip/Tooltip.svelte +29 -0
- package/dist/components/tooltip/Tooltip.svelte.d.ts +4 -0
- package/dist/components/tooltip/TooltipGroup.svelte +100 -0
- package/dist/components/tooltip/TooltipGroup.svelte.d.ts +4 -0
- package/dist/components/tooltip/index.d.ts +3 -0
- package/dist/components/tooltip/index.js +2 -0
- package/dist/components/tooltip/types.d.ts +22 -0
- package/dist/components/tooltip/types.js +1 -0
- package/dist/index.d.ts +149 -0
- package/dist/index.js +149 -0
- package/dist/internal/attrs.d.ts +2 -0
- package/dist/internal/attrs.js +5 -0
- package/dist/internal/css-vars.d.ts +5 -0
- package/dist/internal/css-vars.js +20 -0
- package/dist/internal/merge-class.d.ts +1 -0
- package/dist/internal/merge-class.js +4 -0
- package/dist/internal/svg-attrs.d.ts +9 -0
- package/dist/internal/svg-attrs.js +16 -0
- package/dist/provider/MarwesProvider.svelte +186 -0
- package/dist/provider/MarwesProvider.svelte.d.ts +4 -0
- package/dist/provider/context.d.ts +3 -0
- package/dist/provider/context.js +12 -0
- package/dist/provider/runtime-theme.d.ts +5 -0
- package/dist/provider/runtime-theme.js +63 -0
- package/dist/provider/theme-mode-runtime.d.ts +15 -0
- package/dist/provider/theme-mode-runtime.js +84 -0
- package/dist/provider/types.d.ts +32 -0
- package/dist/provider/types.js +1 -0
- package/dist/provider/use-theme-mode.d.ts +24 -0
- package/dist/provider/use-theme-mode.js +38 -0
- package/dist/provider/use-theme.d.ts +15 -0
- package/dist/provider/use-theme.js +19 -0
- package/dist/ssr.d.ts +2 -0
- package/dist/ssr.js +1 -0
- package/package.json +59 -0
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { createStatTileRecipe } from "@marwes-ui/core";
|
|
3
|
+
import { mergeClass } from "../../internal/merge-class.js";
|
|
4
|
+
import type { StatTileProps } from "./types.js";
|
|
5
|
+
|
|
6
|
+
let {
|
|
7
|
+
label,
|
|
8
|
+
value,
|
|
9
|
+
subtitle,
|
|
10
|
+
trendValue,
|
|
11
|
+
dataAttributes,
|
|
12
|
+
class: className,
|
|
13
|
+
...options
|
|
14
|
+
}: StatTileProps = $props();
|
|
15
|
+
|
|
16
|
+
const kit = $derived(createStatTileRecipe({
|
|
17
|
+
...options,
|
|
18
|
+
...(trendValue ? { trendValue } : {}),
|
|
19
|
+
...(dataAttributes ? { dataAttributes } : {}),
|
|
20
|
+
}));
|
|
21
|
+
const mergedClass = $derived(mergeClass(kit.className, className));
|
|
22
|
+
</script>
|
|
23
|
+
|
|
24
|
+
<article class={mergedClass} {...kit.dataAttributes}>
|
|
25
|
+
<div class={kit.slots.headerClassName}>
|
|
26
|
+
<span class={kit.slots.labelClassName}>{label}</span>
|
|
27
|
+
{#if trendValue}
|
|
28
|
+
<span
|
|
29
|
+
class={kit.slots.trendClassName}
|
|
30
|
+
aria-label={kit.a11y.trendAriaLabel}
|
|
31
|
+
{...kit.trendDataAttributes}
|
|
32
|
+
>
|
|
33
|
+
{#if kit.trendIcon}
|
|
34
|
+
<span class={kit.slots.trendIconClassName} aria-hidden="true">{kit.trendIcon}</span>
|
|
35
|
+
{/if}
|
|
36
|
+
<span class={kit.slots.trendValueClassName}>{trendValue}</span>
|
|
37
|
+
</span>
|
|
38
|
+
{/if}
|
|
39
|
+
</div>
|
|
40
|
+
<div class={kit.slots.valueClassName}>{value}</div>
|
|
41
|
+
{#if subtitle}
|
|
42
|
+
<div class={kit.slots.subtitleClassName}>{subtitle}</div>
|
|
43
|
+
{/if}
|
|
44
|
+
</article>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as StatTile } from "./StatTile.svelte";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { StatTileOptions } from "@marwes-ui/core";
|
|
2
|
+
export interface StatTileProps extends StatTileOptions {
|
|
3
|
+
/** The main label (e.g. "Revenue") */
|
|
4
|
+
label: string;
|
|
5
|
+
/** The primary value (e.g. "$12,345") */
|
|
6
|
+
value: string;
|
|
7
|
+
/** Optional subtitle below value */
|
|
8
|
+
subtitle?: string;
|
|
9
|
+
/** Optional trend value (e.g. "+12%") */
|
|
10
|
+
trendValue?: string;
|
|
11
|
+
/** Data attributes for AI-friendly metadata */
|
|
12
|
+
dataAttributes?: Record<string, string>;
|
|
13
|
+
class?: string;
|
|
14
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import SwitchField from "./SwitchField.svelte";
|
|
3
|
+
import type { SwitchProps } from "./types.js";
|
|
4
|
+
|
|
5
|
+
interface SwitchFieldPurposeProps {
|
|
6
|
+
id?: string;
|
|
7
|
+
label: string;
|
|
8
|
+
description?: string;
|
|
9
|
+
error?: string;
|
|
10
|
+
switch?: Omit<SwitchProps, "children">;
|
|
11
|
+
ariaDescribedBy?: string;
|
|
12
|
+
class?: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
let props: SwitchFieldPurposeProps = $props();
|
|
16
|
+
</script>
|
|
17
|
+
<div data-purpose="feature-toggle">
|
|
18
|
+
<SwitchField {...props} />
|
|
19
|
+
</div>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { SwitchProps } from "./types.js";
|
|
2
|
+
interface SwitchFieldPurposeProps {
|
|
3
|
+
id?: string;
|
|
4
|
+
label: string;
|
|
5
|
+
description?: string;
|
|
6
|
+
error?: string;
|
|
7
|
+
switch?: Omit<SwitchProps, "children">;
|
|
8
|
+
ariaDescribedBy?: string;
|
|
9
|
+
class?: string;
|
|
10
|
+
}
|
|
11
|
+
declare const FeatureToggle: import("svelte").Component<SwitchFieldPurposeProps, {}, "">;
|
|
12
|
+
type FeatureToggle = ReturnType<typeof FeatureToggle>;
|
|
13
|
+
export default FeatureToggle;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import SwitchField from "./SwitchField.svelte";
|
|
3
|
+
import type { SwitchProps } from "./types.js";
|
|
4
|
+
|
|
5
|
+
interface SwitchFieldPurposeProps {
|
|
6
|
+
id?: string;
|
|
7
|
+
label: string;
|
|
8
|
+
description?: string;
|
|
9
|
+
error?: string;
|
|
10
|
+
switch?: Omit<SwitchProps, "children">;
|
|
11
|
+
ariaDescribedBy?: string;
|
|
12
|
+
class?: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
let props: SwitchFieldPurposeProps = $props();
|
|
16
|
+
</script>
|
|
17
|
+
<div data-purpose="permission">
|
|
18
|
+
<SwitchField {...props} />
|
|
19
|
+
</div>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { SwitchProps } from "./types.js";
|
|
2
|
+
interface SwitchFieldPurposeProps {
|
|
3
|
+
id?: string;
|
|
4
|
+
label: string;
|
|
5
|
+
description?: string;
|
|
6
|
+
error?: string;
|
|
7
|
+
switch?: Omit<SwitchProps, "children">;
|
|
8
|
+
ariaDescribedBy?: string;
|
|
9
|
+
class?: string;
|
|
10
|
+
}
|
|
11
|
+
declare const PermissionSwitch: import("svelte").Component<SwitchFieldPurposeProps, {}, "">;
|
|
12
|
+
type PermissionSwitch = ReturnType<typeof PermissionSwitch>;
|
|
13
|
+
export default PermissionSwitch;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import SwitchField from "./SwitchField.svelte";
|
|
3
|
+
import type { SwitchProps } from "./types.js";
|
|
4
|
+
|
|
5
|
+
interface SwitchFieldPurposeProps {
|
|
6
|
+
id?: string;
|
|
7
|
+
label: string;
|
|
8
|
+
description?: string;
|
|
9
|
+
error?: string;
|
|
10
|
+
switch?: Omit<SwitchProps, "children">;
|
|
11
|
+
ariaDescribedBy?: string;
|
|
12
|
+
class?: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
let props: SwitchFieldPurposeProps = $props();
|
|
16
|
+
</script>
|
|
17
|
+
<div data-purpose="preference">
|
|
18
|
+
<SwitchField {...props} />
|
|
19
|
+
</div>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { SwitchProps } from "./types.js";
|
|
2
|
+
interface SwitchFieldPurposeProps {
|
|
3
|
+
id?: string;
|
|
4
|
+
label: string;
|
|
5
|
+
description?: string;
|
|
6
|
+
error?: string;
|
|
7
|
+
switch?: Omit<SwitchProps, "children">;
|
|
8
|
+
ariaDescribedBy?: string;
|
|
9
|
+
class?: string;
|
|
10
|
+
}
|
|
11
|
+
declare const PreferenceSwitch: import("svelte").Component<SwitchFieldPurposeProps, {}, "">;
|
|
12
|
+
type PreferenceSwitch = ReturnType<typeof PreferenceSwitch>;
|
|
13
|
+
export default PreferenceSwitch;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Switch — Parity Findings
|
|
2
|
+
|
|
3
|
+
## Svelte vs React/Vue
|
|
4
|
+
|
|
5
|
+
### Aligned ✅
|
|
6
|
+
- `Switch` atom with `createSwitchRecipe`
|
|
7
|
+
- `oncheckedchange` callback
|
|
8
|
+
- role="switch", aria-checked, aria-disabled
|
|
9
|
+
- Track/thumb DOM structure (mw-switch__track > mw-switch__thumb)
|
|
10
|
+
- `SwitchField` molecule with label, description, error, `buildSwitchFieldA11yIds`
|
|
11
|
+
- All sizes: compact, wide, rich
|
|
12
|
+
|
|
13
|
+
### Missing ❌
|
|
14
|
+
- **Purpose variant wrappers**: React/Vue have some switch variants (not critical)
|
|
15
|
+
|
|
16
|
+
### Notes
|
|
17
|
+
- Full functional parity. Switch variants in React/Vue are minor visual presets — not blocking.
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { createSwitchRecipe } from "@marwes-ui/core";
|
|
3
|
+
import { cssVarsToStyle, mergeStyle } from "../../internal/css-vars.js";
|
|
4
|
+
import { mergeClass } from "../../internal/merge-class.js";
|
|
5
|
+
import type { SwitchProps } from "./types.js";
|
|
6
|
+
|
|
7
|
+
let {
|
|
8
|
+
children,
|
|
9
|
+
class: className,
|
|
10
|
+
id,
|
|
11
|
+
oncheckedchange,
|
|
12
|
+
onclick,
|
|
13
|
+
ariaDescribedBy,
|
|
14
|
+
ariaLabel,
|
|
15
|
+
...coreProps
|
|
16
|
+
}: SwitchProps = $props();
|
|
17
|
+
|
|
18
|
+
const kit = $derived(createSwitchRecipe({
|
|
19
|
+
...coreProps,
|
|
20
|
+
...(ariaDescribedBy ? { ariaDescribedBy } : {}),
|
|
21
|
+
...(ariaLabel ? { ariaLabel } : {}),
|
|
22
|
+
}));
|
|
23
|
+
const mergedClass = $derived(mergeClass(kit.className, className));
|
|
24
|
+
const mergedStyle = $derived(cssVarsToStyle(kit.vars));
|
|
25
|
+
const isDisabled = $derived(kit.a11y.ariaDisabled === true);
|
|
26
|
+
|
|
27
|
+
function handleClick(e: MouseEvent): void {
|
|
28
|
+
onclick?.(e);
|
|
29
|
+
if (isDisabled || e.defaultPrevented) return;
|
|
30
|
+
oncheckedchange?.(!kit.a11y.ariaChecked);
|
|
31
|
+
}
|
|
32
|
+
</script>
|
|
33
|
+
|
|
34
|
+
<button
|
|
35
|
+
{id}
|
|
36
|
+
type="button"
|
|
37
|
+
role={kit.a11y.role}
|
|
38
|
+
disabled={isDisabled}
|
|
39
|
+
aria-checked={kit.a11y.ariaChecked}
|
|
40
|
+
aria-disabled={kit.a11y.ariaDisabled}
|
|
41
|
+
aria-label={kit.a11y.ariaLabel}
|
|
42
|
+
aria-labelledby={kit.a11y.ariaLabelledby}
|
|
43
|
+
aria-describedby={kit.a11y.ariaDescribedBy}
|
|
44
|
+
class={mergedClass}
|
|
45
|
+
style={mergedStyle}
|
|
46
|
+
onclick={handleClick}
|
|
47
|
+
>
|
|
48
|
+
<span class="mw-switch__track">
|
|
49
|
+
<span class="mw-switch__thumb"></span>
|
|
50
|
+
</span>
|
|
51
|
+
{@render children?.()}
|
|
52
|
+
</button>
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { buildSwitchFieldA11yIds } from "@marwes-ui/core";
|
|
3
|
+
import { mergeClass } from "../../internal/merge-class.js";
|
|
4
|
+
import Switch from "./Switch.svelte";
|
|
5
|
+
import type { SwitchFieldProps, SwitchProps } from "./types.js";
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
let {
|
|
9
|
+
id: userProvidedId,
|
|
10
|
+
label,
|
|
11
|
+
description,
|
|
12
|
+
error,
|
|
13
|
+
switch: switchProps = {},
|
|
14
|
+
ariaDescribedBy,
|
|
15
|
+
class: className,
|
|
16
|
+
}: SwitchFieldProps = $props();
|
|
17
|
+
|
|
18
|
+
const uniqueId = $props.id();
|
|
19
|
+
const fieldId = $derived(userProvidedId ?? `mw-switch-${uniqueId}`);
|
|
20
|
+
|
|
21
|
+
function hasTextContent(text: string | undefined): boolean {
|
|
22
|
+
return text !== undefined && text.trim().length > 0;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const hasDescription = $derived(hasTextContent(description));
|
|
26
|
+
const hasError = $derived(hasTextContent(error));
|
|
27
|
+
const disabled = $derived(switchProps.disabled || false);
|
|
28
|
+
|
|
29
|
+
const a11yIds = $derived(
|
|
30
|
+
buildSwitchFieldA11yIds({
|
|
31
|
+
id: fieldId,
|
|
32
|
+
hasDescription,
|
|
33
|
+
hasError,
|
|
34
|
+
externalDescribedBy: ariaDescribedBy,
|
|
35
|
+
})
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
const wrapperClass = $derived(
|
|
39
|
+
mergeClass(
|
|
40
|
+
"mw-switch-field",
|
|
41
|
+
disabled && "mw-switch-field--disabled",
|
|
42
|
+
className
|
|
43
|
+
)
|
|
44
|
+
);
|
|
45
|
+
</script>
|
|
46
|
+
|
|
47
|
+
<div class={wrapperClass}>
|
|
48
|
+
<div class="mw-switch-field__row">
|
|
49
|
+
<Switch
|
|
50
|
+
{...switchProps}
|
|
51
|
+
id={fieldId}
|
|
52
|
+
ariaDescribedBy={a11yIds.describedBy}
|
|
53
|
+
ariaLabelledby={a11yIds.labelId}
|
|
54
|
+
/>
|
|
55
|
+
<label class="mw-switch-field__label" id={a11yIds.labelId} for={fieldId}>
|
|
56
|
+
<p class="mw-p mw-p--md">{label}</p>
|
|
57
|
+
</label>
|
|
58
|
+
</div>
|
|
59
|
+
|
|
60
|
+
{#if hasDescription}
|
|
61
|
+
<div class="mw-switch-field__description" id={a11yIds.descriptionId}>
|
|
62
|
+
<p class="mw-p mw-p--sm">{description}</p>
|
|
63
|
+
</div>
|
|
64
|
+
{/if}
|
|
65
|
+
|
|
66
|
+
{#if hasError}
|
|
67
|
+
<div class="mw-switch-field__error" id={a11yIds.errorId} aria-live="polite">
|
|
68
|
+
<p class="mw-p mw-p--sm">{error}</p>
|
|
69
|
+
</div>
|
|
70
|
+
{/if}
|
|
71
|
+
</div>
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { SwitchOptions } from "@marwes-ui/core";
|
|
2
|
+
import type { Snippet } from "svelte";
|
|
3
|
+
export interface SwitchProps extends Omit<SwitchOptions, "ariaDescribedBy" | "ariaLabel"> {
|
|
4
|
+
children?: Snippet;
|
|
5
|
+
class?: string;
|
|
6
|
+
id?: string;
|
|
7
|
+
oncheckedchange?: (checked: boolean) => void;
|
|
8
|
+
onclick?: (e: MouseEvent) => void;
|
|
9
|
+
ariaDescribedBy?: string | undefined;
|
|
10
|
+
ariaLabel?: string | undefined;
|
|
11
|
+
}
|
|
12
|
+
export interface SwitchFieldProps {
|
|
13
|
+
id?: string;
|
|
14
|
+
label: string;
|
|
15
|
+
description?: string;
|
|
16
|
+
error?: string;
|
|
17
|
+
switch?: Omit<SwitchProps, "children">;
|
|
18
|
+
ariaDescribedBy?: string;
|
|
19
|
+
class?: string;
|
|
20
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import TabGroup from "./TabGroup.svelte";
|
|
3
|
+
import type { ContentTabsProps } from "./types.js";
|
|
4
|
+
let { ariaLabel = "Content tabs", dataAttributes, ...props }: ContentTabsProps = $props();
|
|
5
|
+
</script>
|
|
6
|
+
|
|
7
|
+
<TabGroup
|
|
8
|
+
{...props}
|
|
9
|
+
{ariaLabel}
|
|
10
|
+
dataAttributes={{ ...dataAttributes, "data-purpose": "content-tabs" }}
|
|
11
|
+
/>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import TabGroup from "./TabGroup.svelte";
|
|
3
|
+
import type { NavigationTabsProps } from "./types.js";
|
|
4
|
+
let { ariaLabel = "Navigation tabs", dataAttributes, ...props }: NavigationTabsProps = $props();
|
|
5
|
+
</script>
|
|
6
|
+
|
|
7
|
+
<TabGroup
|
|
8
|
+
{...props}
|
|
9
|
+
{ariaLabel}
|
|
10
|
+
dataAttributes={{ ...dataAttributes, "data-purpose": "navigation-tabs" }}
|
|
11
|
+
/>
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Tab
|
|
2
|
+
|
|
3
|
+
Svelte tab components are aligned with the React and Vue tab family.
|
|
4
|
+
|
|
5
|
+
## Public Components
|
|
6
|
+
|
|
7
|
+
- `Tab` — atom for custom tablist layouts.
|
|
8
|
+
- `TabPanel` — atom-level panel primitive.
|
|
9
|
+
- `TabGroup` — coordinated tablist and panel molecule.
|
|
10
|
+
- `NavigationTabs` — purpose wrapper for navigation-style tab groups.
|
|
11
|
+
- `ContentTabs` — purpose wrapper for content-section tab groups.
|
|
12
|
+
- `SettingsTabs` — purpose wrapper for settings/admin tab groups.
|
|
13
|
+
|
|
14
|
+
## Shared Contract
|
|
15
|
+
|
|
16
|
+
- Uses `createTabRecipe`, `buildTabGroupA11yIds`, `moveTabSelection`, and `resolveTabValue` from `@marwes-ui/core`.
|
|
17
|
+
- Supports controlled and uncontrolled active tab state.
|
|
18
|
+
- Supports disabled tabs.
|
|
19
|
+
- Supports ArrowLeft, ArrowRight, Home, and End keyboard navigation.
|
|
20
|
+
- Wires `role="tablist"`, `role="tab"`, `role="tabpanel"`, `aria-selected`, `aria-controls`, and `aria-labelledby`.
|
|
21
|
+
- Renders string panel content or Svelte snippets.
|
|
22
|
+
- Applies purpose metadata to the `.mw-tab-group` root through `dataAttributes`, matching React and Vue.
|
|
23
|
+
|
|
24
|
+
## Svelte Notes
|
|
25
|
+
|
|
26
|
+
Svelte keeps the same declarative `tabs` array API as React and Vue. Event naming follows Svelte conventions with `onactivetabchange`.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import TabGroup from "./TabGroup.svelte";
|
|
3
|
+
import type { SettingsTabsProps } from "./types.js";
|
|
4
|
+
let { ariaLabel = "Settings tabs", dataAttributes, ...props }: SettingsTabsProps = $props();
|
|
5
|
+
</script>
|
|
6
|
+
|
|
7
|
+
<TabGroup
|
|
8
|
+
{...props}
|
|
9
|
+
{ariaLabel}
|
|
10
|
+
dataAttributes={{ ...dataAttributes, "data-purpose": "settings-tabs" }}
|
|
11
|
+
/>
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { createTabRecipe } from "@marwes-ui/core";
|
|
3
|
+
import { mergeClass } from "../../internal/merge-class.js";
|
|
4
|
+
import type { TabProps } from "./types.js";
|
|
5
|
+
|
|
6
|
+
let {
|
|
7
|
+
children,
|
|
8
|
+
class: className,
|
|
9
|
+
id,
|
|
10
|
+
onclick,
|
|
11
|
+
...coreProps
|
|
12
|
+
}: TabProps = $props();
|
|
13
|
+
|
|
14
|
+
const kit = $derived(createTabRecipe(coreProps));
|
|
15
|
+
const mergedClass = $derived(mergeClass(kit.className, className));
|
|
16
|
+
</script>
|
|
17
|
+
|
|
18
|
+
<button
|
|
19
|
+
{id}
|
|
20
|
+
type="button"
|
|
21
|
+
class={mergedClass}
|
|
22
|
+
role={kit.a11y.role}
|
|
23
|
+
aria-selected={kit.a11y.ariaSelected}
|
|
24
|
+
aria-disabled={kit.a11y.ariaDisabled}
|
|
25
|
+
aria-label={kit.a11y.ariaLabel}
|
|
26
|
+
aria-controls={kit.a11y.ariaControls}
|
|
27
|
+
tabindex={kit.a11y.tabIndex}
|
|
28
|
+
disabled={coreProps.disabled}
|
|
29
|
+
{onclick}
|
|
30
|
+
>
|
|
31
|
+
{@render children?.()}
|
|
32
|
+
</button>
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import {
|
|
3
|
+
buildTabGroupA11yIds,
|
|
4
|
+
createTabRecipe,
|
|
5
|
+
moveTabSelection,
|
|
6
|
+
resolveTabValue,
|
|
7
|
+
} from "@marwes-ui/core";
|
|
8
|
+
import type { TabGroupItemState } from "@marwes-ui/core";
|
|
9
|
+
import { mergeClass } from "../../internal/merge-class.js";
|
|
10
|
+
import type { TabGroupProps } from "./types.js";
|
|
11
|
+
|
|
12
|
+
let {
|
|
13
|
+
id: idProp,
|
|
14
|
+
label,
|
|
15
|
+
ariaLabel,
|
|
16
|
+
tabs,
|
|
17
|
+
activeTab: controlledActive,
|
|
18
|
+
defaultActiveTab,
|
|
19
|
+
onactivetabchange,
|
|
20
|
+
dataAttributes,
|
|
21
|
+
class: className,
|
|
22
|
+
}: TabGroupProps = $props();
|
|
23
|
+
|
|
24
|
+
const uniqueId = $props.id();
|
|
25
|
+
const groupId = $derived(idProp ?? `mw-tab-group-${uniqueId}`);
|
|
26
|
+
|
|
27
|
+
const itemStates: TabGroupItemState[] = $derived(
|
|
28
|
+
tabs.map((t) => ({ value: t.value, ...(t.disabled ? { disabled: true } : {}) }))
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
const itemValues = $derived(tabs.map((t) => t.value));
|
|
32
|
+
const hasLabel = $derived(!!label);
|
|
33
|
+
|
|
34
|
+
const a11yIds = $derived(buildTabGroupA11yIds({ id: groupId, itemValues, hasLabel }));
|
|
35
|
+
|
|
36
|
+
let internalActive = $state<string | undefined>(undefined);
|
|
37
|
+
|
|
38
|
+
// Initialize internal state
|
|
39
|
+
$effect(() => {
|
|
40
|
+
if (internalActive === undefined) {
|
|
41
|
+
internalActive = resolveTabValue(itemStates, defaultActiveTab);
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
const activeValue = $derived(
|
|
46
|
+
controlledActive !== undefined ? resolveTabValue(itemStates, controlledActive) : internalActive
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
function selectTab(value: string): void {
|
|
50
|
+
if (controlledActive === undefined) {
|
|
51
|
+
internalActive = value;
|
|
52
|
+
}
|
|
53
|
+
onactivetabchange?.(value);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function handleKeydown(e: KeyboardEvent): void {
|
|
57
|
+
let direction: "next" | "previous" | "start" | "end" | undefined;
|
|
58
|
+
if (e.key === "ArrowRight") direction = "next";
|
|
59
|
+
else if (e.key === "ArrowLeft") direction = "previous";
|
|
60
|
+
else if (e.key === "Home") direction = "start";
|
|
61
|
+
else if (e.key === "End") direction = "end";
|
|
62
|
+
|
|
63
|
+
if (!direction) return;
|
|
64
|
+
e.preventDefault();
|
|
65
|
+
|
|
66
|
+
const next = moveTabSelection(itemStates, activeValue, direction);
|
|
67
|
+
if (next) {
|
|
68
|
+
selectTab(next);
|
|
69
|
+
const tabEl = document.getElementById(a11yIds.tabIds[next] ?? "");
|
|
70
|
+
if (tabEl instanceof HTMLButtonElement) tabEl.focus();
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const mergedClass = $derived(mergeClass("mw-tab-group", className));
|
|
75
|
+
</script>
|
|
76
|
+
|
|
77
|
+
<div class={mergedClass} {...dataAttributes}>
|
|
78
|
+
{#if label}
|
|
79
|
+
<div class="mw-tab-group__label" id={a11yIds.labelId}>
|
|
80
|
+
<p class="mw-p mw-p--sm">{label}</p>
|
|
81
|
+
</div>
|
|
82
|
+
{/if}
|
|
83
|
+
|
|
84
|
+
<div
|
|
85
|
+
class="mw-tab-group__tablist"
|
|
86
|
+
role="tablist"
|
|
87
|
+
id={a11yIds.tabListId}
|
|
88
|
+
aria-labelledby={a11yIds.labelId}
|
|
89
|
+
aria-label={!label ? ariaLabel : undefined}
|
|
90
|
+
onkeydown={handleKeydown}
|
|
91
|
+
>
|
|
92
|
+
{#each tabs as tab}
|
|
93
|
+
{@const isSelected = tab.value === activeValue}
|
|
94
|
+
{@const kit = createTabRecipe({ selected: isSelected, ...(tab.disabled ? { disabled: tab.disabled } : {}), ...(tab.ariaLabel ? { ariaLabel: tab.ariaLabel } : {}), ...(a11yIds.panelIds[tab.value] ? { ariaControls: a11yIds.panelIds[tab.value] } : {}) })}
|
|
95
|
+
<button
|
|
96
|
+
id={a11yIds.tabIds[tab.value]}
|
|
97
|
+
type="button"
|
|
98
|
+
role={kit.a11y.role}
|
|
99
|
+
class={kit.className}
|
|
100
|
+
aria-selected={kit.a11y.ariaSelected}
|
|
101
|
+
aria-disabled={kit.a11y.ariaDisabled}
|
|
102
|
+
aria-controls={kit.a11y.ariaControls}
|
|
103
|
+
aria-label={kit.a11y.ariaLabel}
|
|
104
|
+
tabindex={kit.a11y.tabIndex}
|
|
105
|
+
disabled={tab.disabled}
|
|
106
|
+
onclick={() => !tab.disabled && selectTab(tab.value)}
|
|
107
|
+
>
|
|
108
|
+
{tab.label}
|
|
109
|
+
</button>
|
|
110
|
+
{/each}
|
|
111
|
+
</div>
|
|
112
|
+
|
|
113
|
+
{#each tabs as tab}
|
|
114
|
+
{@const isActive = tab.value === activeValue}
|
|
115
|
+
<div
|
|
116
|
+
id={a11yIds.panelIds[tab.value]}
|
|
117
|
+
role="tabpanel"
|
|
118
|
+
aria-labelledby={a11yIds.tabIds[tab.value]}
|
|
119
|
+
class="mw-tab-group__panel"
|
|
120
|
+
tabindex={isActive ? 0 : undefined}
|
|
121
|
+
hidden={!isActive}
|
|
122
|
+
>
|
|
123
|
+
{#if isActive}
|
|
124
|
+
{#if typeof tab.panel === "string"}
|
|
125
|
+
<p class="mw-p mw-p--md">{tab.panel}</p>
|
|
126
|
+
{:else}
|
|
127
|
+
{@render tab.panel()}
|
|
128
|
+
{/if}
|
|
129
|
+
{/if}
|
|
130
|
+
</div>
|
|
131
|
+
{/each}
|
|
132
|
+
</div>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { mergeClass } from "../../internal/merge-class.js";
|
|
3
|
+
import type { TabPanelProps } from "./types.js";
|
|
4
|
+
|
|
5
|
+
let {
|
|
6
|
+
id,
|
|
7
|
+
tabId,
|
|
8
|
+
hidden = false,
|
|
9
|
+
children,
|
|
10
|
+
class: className,
|
|
11
|
+
}: TabPanelProps = $props();
|
|
12
|
+
|
|
13
|
+
const mergedClass = $derived(mergeClass("mw-tab-group__panel", className));
|
|
14
|
+
</script>
|
|
15
|
+
|
|
16
|
+
<div
|
|
17
|
+
{id}
|
|
18
|
+
role="tabpanel"
|
|
19
|
+
aria-labelledby={tabId}
|
|
20
|
+
class={mergedClass}
|
|
21
|
+
hidden={hidden || undefined}
|
|
22
|
+
tabindex={hidden ? undefined : 0}
|
|
23
|
+
>
|
|
24
|
+
{@render children?.()}
|
|
25
|
+
</div>
|