negodesign 0.0.77 → 0.0.79
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/README.md +133 -133
- package/dist/components/NegoDesign.svelte +21 -21
- package/dist/components/pages/admin/01/ui/AdminContent.svelte +14 -14
- package/dist/components/pages/admin/01/ui/AdminPanel.svelte +46 -46
- package/dist/components/pages/product-details/shared/ProductDetailFilesVertical.svelte +103 -103
- package/dist/components/pages/profile-user/shared/ProfileUserAddress.svelte +83 -83
- package/dist/components/pages/profile-user/shared/ProfileUserTabs.svelte +80 -80
- package/dist/components/pages/security/auth/PageAuth01.svelte +21 -24
- package/dist/components/pages/security/auth/PageAuth02.svelte +11 -16
- package/dist/components/pages/security/auth/PageAuth03.svelte +11 -16
- package/dist/components/pages/security/login/01/ui/FormLogin.svelte +7 -5
- package/dist/components/pages/security/login/01/ui/FormLogin.svelte.d.ts +2 -0
- package/dist/components/pages/security/login/01/ui/FormLoginEmailPassword.svelte +4 -2
- package/dist/components/pages/security/login/01/ui/FormLoginEmailPassword.svelte.d.ts +2 -0
- package/dist/components/pages/security/login/01/ui/FormLoginPhonePassword.svelte +4 -2
- package/dist/components/pages/security/login/01/ui/FormLoginPhonePassword.svelte.d.ts +2 -0
- package/dist/components/pages/security/login/01/ui/FormLoginUsernamePassword.svelte +4 -2
- package/dist/components/pages/security/login/01/ui/FormLoginUsernamePassword.svelte.d.ts +2 -0
- package/dist/components/pages/security/login/01/ui/{LoginCard.svelte → LoginCard01.svelte} +132 -109
- package/dist/components/pages/security/login/01/ui/{LoginCard.svelte.d.ts → LoginCard01.svelte.d.ts} +3 -3
- package/dist/components/pages/security/login/01/ui/PageLogin01.svelte +2 -2
- package/dist/components/pages/security/login/02/ui/FormLogin02.svelte +7 -5
- package/dist/components/pages/security/login/02/ui/FormLogin02.svelte.d.ts +2 -0
- package/dist/components/pages/security/login/02/ui/FormLoginEmailPassword02.svelte +4 -2
- package/dist/components/pages/security/login/02/ui/FormLoginEmailPassword02.svelte.d.ts +2 -0
- package/dist/components/pages/security/login/02/ui/FormLoginPhonePassword02.svelte +4 -2
- package/dist/components/pages/security/login/02/ui/FormLoginPhonePassword02.svelte.d.ts +2 -0
- package/dist/components/pages/security/login/02/ui/FormLoginUsernamePassword02.svelte +4 -2
- package/dist/components/pages/security/login/02/ui/FormLoginUsernamePassword02.svelte.d.ts +2 -0
- package/dist/components/pages/security/login/03/ui/FormLogin03.svelte +8 -4
- package/dist/components/pages/security/login/03/ui/FormLogin03.svelte.d.ts +2 -0
- package/dist/components/pages/security/login/03/ui/FormLoginEmailPassword03.svelte +4 -2
- package/dist/components/pages/security/login/03/ui/FormLoginEmailPassword03.svelte.d.ts +2 -0
- package/dist/components/pages/security/login/03/ui/FormLoginPhonePassword03.svelte +4 -2
- package/dist/components/pages/security/login/03/ui/FormLoginPhonePassword03.svelte.d.ts +2 -0
- package/dist/components/pages/security/login/03/ui/FormLoginUsernamePassword03.svelte +4 -2
- package/dist/components/pages/security/login/03/ui/FormLoginUsernamePassword03.svelte.d.ts +2 -0
- package/dist/components/pages/security/login/PageLogin.svelte +30 -30
- package/dist/components/pages/security/register/01/ui/PageRegister01.svelte +21 -9
- package/dist/components/pages/security/register/01/ui/PageRegister01.svelte.d.ts +1 -0
- package/dist/components/pages/security/register/01/ui/{RegisterCard.svelte → RegisterCard01.svelte} +26 -22
- package/dist/components/pages/security/register/01/ui/{RegisterCard.svelte.d.ts → RegisterCard01.svelte.d.ts} +3 -3
- package/dist/components/pages/security/register/FormRegister.svelte +40 -14
- package/dist/components/pages/security/register/FormRegister.svelte.d.ts +3 -0
- package/dist/components/ui/avatar/avatar-fallback.svelte +29 -29
- package/dist/components/ui/avatar/avatar-image.svelte +38 -38
- package/dist/components/ui/avatar/avatar.svelte +39 -39
- package/dist/components/ui/badge/badge.svelte +46 -46
- package/dist/components/ui/banner/AdCardBanner.svelte +74 -74
- package/dist/components/ui/banner/CtaCardBanner.svelte +118 -118
- package/dist/components/ui/banner/CtaCardImageBanner.svelte +94 -94
- package/dist/components/ui/breadcrumb/core/breadcrumb-list.svelte +31 -31
- package/dist/components/ui/button/ButtonBack.svelte +18 -18
- package/dist/components/ui/button/ButtonLogin.svelte +15 -15
- package/dist/components/ui/button/ButtonLoginWith.svelte +57 -57
- package/dist/components/ui/button/ButtonSend.svelte +15 -15
- package/dist/components/ui/button/button.svelte +85 -85
- package/dist/components/ui/card/core/highlight/01/CardHighlight01.svelte +103 -103
- package/dist/components/ui/card/core/highlight/02/CardHighlight02.svelte +99 -99
- package/dist/components/ui/card/core/highlight/CardHighlight.svelte +22 -22
- package/dist/components/ui/card/core/media/01/CardMedia01.svelte +133 -133
- package/dist/components/ui/card/core/media/02/CardMedia02.svelte +127 -127
- package/dist/components/ui/card/core/media/CardMedia.svelte +18 -18
- package/dist/components/ui/card/core/product/01/CardProduct01.svelte +136 -136
- package/dist/components/ui/card/core/product/02/CardProduct02.svelte +124 -124
- package/dist/components/ui/card/core/product/CardProduct.svelte +22 -22
- package/dist/components/ui/card/core/profile/01/CardProfile01.svelte +134 -134
- package/dist/components/ui/card/core/profile/02/CardProfile02.svelte +132 -132
- package/dist/components/ui/card/core/profile/CardProfile.svelte +18 -18
- package/dist/components/ui/card/core/promotion/CardPromotion.svelte +139 -139
- package/dist/components/ui/card/core/promotion/CardPromotionPrice.svelte +32 -32
- package/dist/components/ui/card/core/shared/CardButton.svelte +42 -42
- package/dist/components/ui/card/core/shared/CardCart.svelte +36 -36
- package/dist/components/ui/card/core/shared/CardDescription.svelte +41 -41
- package/dist/components/ui/card/core/shared/CardFavorite.svelte +33 -33
- package/dist/components/ui/card/core/shared/CardLogo.svelte +19 -19
- package/dist/components/ui/card/core/shared/CardPhoneOrWhatsapp.svelte +45 -45
- package/dist/components/ui/card/core/shared/CardStarRating.svelte +24 -24
- package/dist/components/ui/card/core/shared/CardTags.svelte +95 -95
- package/dist/components/ui/card/core/shared/CardThumbnailVideo.svelte +232 -232
- package/dist/components/ui/card/core/shared/CardTitlePrice.svelte +24 -24
- package/dist/components/ui/card/core/shared/TruncatableText.svelte +49 -49
- package/dist/components/ui/carousel/carousel-content.svelte +56 -56
- package/dist/components/ui/carousel/carousel-item.svelte +29 -29
- package/dist/components/ui/carousel/carousel-next.svelte +40 -40
- package/dist/components/ui/carousel/carousel-previous.svelte +40 -40
- package/dist/components/ui/carousel/carousel.svelte +225 -225
- package/dist/components/ui/carousel/core/badge/ui/CarouselBadge.svelte +108 -108
- package/dist/components/ui/carousel/core/grid/shared/ui/CarouselGridSlot.svelte +38 -38
- package/dist/components/ui/carousel/core/hero/ui/CarouselHero.svelte +181 -181
- package/dist/components/ui/carousel/core/highlights/ui/CarouselHighlights.svelte +67 -67
- package/dist/components/ui/carousel/core/product/ui/CarouselProduct.svelte +57 -57
- package/dist/components/ui/carousel/core/promotion/ui/CarouselPromotion.svelte +67 -67
- package/dist/components/ui/carousel/core/shared/ui/CarouselHeader.svelte +59 -59
- package/dist/components/ui/checkbox/checkbox.svelte +96 -96
- package/dist/components/ui/collapsible/collapsible-content.svelte +30 -30
- package/dist/components/ui/collapsible/collapsible-trigger.svelte +51 -51
- package/dist/components/ui/collapsible/collapsible.svelte +66 -66
- package/dist/components/ui/data-table/flex-render.svelte +40 -40
- package/dist/components/ui/datatable/ui/DataTableActions.svelte +28 -28
- package/dist/components/ui/datatable/ui/DataTableCheckbox.svelte +22 -22
- package/dist/components/ui/datatable/ui/DataTableContent.svelte +59 -59
- package/dist/components/ui/datatable/ui/DataTableCore.svelte +148 -148
- package/dist/components/ui/datatable/ui/DataTableDragHandle.svelte +8 -8
- package/dist/components/ui/datatable/ui/DataTableListFilter.svelte +60 -60
- package/dist/components/ui/datatable/ui/DataTableListPagination.svelte +35 -35
- package/dist/components/ui/drawer/drawer-close.svelte +41 -41
- package/dist/components/ui/drawer/drawer-content.svelte +81 -81
- package/dist/components/ui/drawer/drawer-description.svelte +19 -19
- package/dist/components/ui/drawer/drawer-footer.svelte +20 -20
- package/dist/components/ui/drawer/drawer-header.svelte +20 -20
- package/dist/components/ui/drawer/drawer-nested.svelte +34 -34
- package/dist/components/ui/drawer/drawer-overlay.svelte +25 -25
- package/dist/components/ui/drawer/drawer-portal.svelte +19 -19
- package/dist/components/ui/drawer/drawer-title.svelte +19 -19
- package/dist/components/ui/drawer/drawer-trigger.svelte +42 -42
- package/dist/components/ui/drawer/drawer.svelte +74 -74
- package/dist/components/ui/dropdown-menu/dropdown-menu-checkbox-group.svelte +25 -25
- package/dist/components/ui/dropdown-menu/dropdown-menu-checkbox-item.svelte +69 -69
- package/dist/components/ui/dropdown-menu/dropdown-menu-content.svelte +106 -106
- package/dist/components/ui/dropdown-menu/dropdown-menu-group-heading.svelte +27 -27
- package/dist/components/ui/dropdown-menu/dropdown-menu-group.svelte +21 -21
- package/dist/components/ui/dropdown-menu/dropdown-menu-item.svelte +60 -60
- package/dist/components/ui/dropdown-menu/dropdown-menu-label.svelte +27 -27
- package/dist/components/ui/dropdown-menu/dropdown-menu-portal.svelte +6 -6
- package/dist/components/ui/dropdown-menu/dropdown-menu-radio-group.svelte +43 -43
- package/dist/components/ui/dropdown-menu/dropdown-menu-radio-item.svelte +70 -70
- package/dist/components/ui/dropdown-menu/dropdown-menu-separator.svelte +20 -20
- package/dist/components/ui/dropdown-menu/dropdown-menu-sub-content.svelte +33 -33
- package/dist/components/ui/dropdown-menu/dropdown-menu-sub-trigger.svelte +57 -57
- package/dist/components/ui/dropdown-menu/dropdown-menu-sub.svelte +76 -76
- package/dist/components/ui/dropdown-menu/dropdown-menu-trigger.svelte +68 -68
- package/dist/components/ui/dropdown-menu/dropdown-menu.svelte +53 -53
- package/dist/components/ui/empty/empty-content.svelte +19 -19
- package/dist/components/ui/empty/empty-description.svelte +19 -19
- package/dist/components/ui/empty/empty-header.svelte +19 -19
- package/dist/components/ui/empty/empty-media.svelte +41 -41
- package/dist/components/ui/empty/empty-title.svelte +19 -19
- package/dist/components/ui/empty/empty.svelte +19 -19
- package/dist/components/ui/footer/ui/Footer.svelte +18 -18
- package/dist/components/ui/form/data/InputIconDefault.svelte.js +2 -1
- package/dist/components/ui/form/data/InputLabel.svelte.d.ts +3 -0
- package/dist/components/ui/form/ui/calendar/Calendar.svelte +194 -0
- package/dist/components/ui/form/ui/calendar/Calendar.svelte.d.ts +15 -0
- package/dist/components/ui/form/ui/calendar/CalendarCard.svelte +90 -0
- package/dist/components/ui/form/ui/calendar/CalendarCard.svelte.d.ts +20 -0
- package/dist/components/ui/form/ui/calendar/DaysGrid.svelte +76 -0
- package/dist/components/ui/form/ui/calendar/DaysGrid.svelte.d.ts +17 -0
- package/dist/components/ui/form/ui/calendar/MonthSelect.svelte +50 -0
- package/dist/components/ui/form/ui/calendar/MonthSelect.svelte.d.ts +10 -0
- package/dist/components/ui/form/ui/calendar/YearSelect.svelte +117 -0
- package/dist/components/ui/form/ui/calendar/YearSelect.svelte.d.ts +15 -0
- package/dist/components/ui/form/ui/calendar/index.d.ts +5 -0
- package/dist/components/ui/form/ui/calendar/index.js +5 -0
- package/dist/components/ui/form/ui/calendar/utils.d.ts +26 -0
- package/dist/components/ui/form/ui/calendar/utils.js +89 -0
- package/dist/components/ui/form/ui/input-base.svelte +83 -81
- package/dist/components/ui/form/ui/input-calendar-interval.svelte +179 -0
- package/dist/components/ui/form/ui/input-calendar-interval.svelte.d.ts +14 -0
- package/dist/components/ui/form/ui/input-calendar.svelte +110 -0
- package/dist/components/ui/form/ui/input-calendar.svelte.d.ts +9 -0
- package/dist/components/ui/form/ui/input-email-or-phone.svelte +23 -23
- package/dist/components/ui/form/ui/input-email.svelte +23 -23
- package/dist/components/ui/form/ui/input-password-confirm.svelte +23 -23
- package/dist/components/ui/form/ui/input-password.svelte +23 -23
- package/dist/components/ui/form/ui/input-phone.svelte +37 -33
- package/dist/components/ui/form/ui/input-select.svelte +210 -158
- package/dist/components/ui/form/ui/input-select.svelte.d.ts +5 -9
- package/dist/components/ui/form/ui/input-username.svelte +22 -22
- package/dist/components/ui/grid/core/ui/01/Grid01.svelte +30 -30
- package/dist/components/ui/grid/core/ui/02/Grid02.svelte +30 -30
- package/dist/components/ui/grid/core/ui/ItemsPanel.svelte +26 -26
- package/dist/components/ui/grid/core/ui/ItemsPanelCarousel.svelte +37 -37
- package/dist/components/ui/grid/core/ui/ItemsPanelGrid.svelte +43 -43
- package/dist/components/ui/grid/core/ui/ItemsSimpleGrid.svelte +45 -45
- package/dist/components/ui/grid/core/ui/shared/DescriptionGrid.svelte +23 -23
- package/dist/components/ui/grid/core/ui/shared/IconRenderGrid.svelte +23 -23
- package/dist/components/ui/grid/core/ui/shared/TitleGrid.svelte +19 -19
- package/dist/components/ui/hero/SimpleHero.svelte +65 -65
- package/dist/components/ui/input-otp/input-otp-group.svelte +22 -22
- package/dist/components/ui/input-otp/input-otp-separator.svelte +27 -27
- package/dist/components/ui/input-otp/input-otp-slot.svelte +63 -63
- package/dist/components/ui/input-otp/input-otp.svelte +181 -181
- package/dist/components/ui/label/core/LabelOr.svelte +25 -25
- package/dist/components/ui/label/label.svelte +19 -19
- package/dist/components/ui/language-switcher/language-switcher.svelte +48 -48
- package/dist/components/ui/light-switch/light-switch.svelte +48 -48
- package/dist/components/ui/link/link-forget-password.svelte +12 -12
- package/dist/components/ui/link/link-privacy-polity.svelte +12 -12
- package/dist/components/ui/link/link-terms-of-service.svelte +12 -12
- package/dist/components/ui/modal/core/index.d.ts +1 -1
- package/dist/components/ui/modal/core/types.d.ts +2 -1
- package/dist/components/ui/modal/core/ui/ModalCore.svelte +132 -132
- package/dist/components/ui/modal/grid/types.d.ts +6 -5
- package/dist/components/ui/modal/grid/ui/02/ModalGridSelection02.svelte +146 -146
- package/dist/components/ui/modal/share/ui/ModalShareSelection.svelte +156 -156
- package/dist/components/ui/nav/ui/ComplexMenu.svelte +51 -51
- package/dist/components/ui/nav/ui/Menu.svelte +72 -72
- package/dist/components/ui/nav/ui/SimpleMenu.svelte +14 -14
- package/dist/components/ui/nav/ui/mobile/ComplexMenuMobile.svelte +125 -125
- package/dist/components/ui/nav/ui/mobile/MenuMobile.svelte +54 -54
- package/dist/components/ui/nav/ui/shared/MenuButton.svelte +51 -51
- package/dist/components/ui/nav/ui/shared/MenuLinks.svelte +40 -40
- package/dist/components/ui/nav/ui/shared/MenuListItem.svelte +44 -44
- package/dist/components/ui/nav/ui/shared/MenuLogo.svelte +13 -13
- package/dist/components/ui/nav/ui/shared/dropdown/DropdownNavigationMenuItemGrid.svelte +30 -30
- package/dist/components/ui/nav/ui/shared/navigation/NavDropdown.svelte +87 -87
- package/dist/components/ui/nav/ui/shared/navigation/NavigationMenuItem.svelte +17 -17
- package/dist/components/ui/nav/ui/shared/navigation/NavigationMenuItemCard.svelte +53 -53
- package/dist/components/ui/nav/ui/shared/navigation/NavigationMenuItemGrid.svelte +36 -36
- package/dist/components/ui/nav/ui/shared/navigation/NavigationMenuItemList.svelte +24 -24
- package/dist/components/ui/nav/ui/shared/navigation/NavigationMenuItems.svelte +21 -21
- package/dist/components/ui/panel/CarouselSlot.svelte +57 -57
- package/dist/components/ui/panel/LeftHero.svelte +114 -114
- package/dist/components/ui/panel/NotFoundEmpty.svelte +66 -66
- package/dist/components/ui/phone-input/country-selector.svelte +87 -87
- package/dist/components/ui/phone-input/country-selector.svelte.d.ts +2 -2
- package/dist/components/ui/phone-input/flag.svelte +11 -11
- package/dist/components/ui/phone-input/phone-input.svelte +163 -148
- package/dist/components/ui/phone-input/phone-input.svelte.d.ts +2 -2
- package/dist/components/ui/popover/popover-close.svelte +25 -25
- package/dist/components/ui/popover/popover-content.svelte +92 -92
- package/dist/components/ui/popover/popover-portal.svelte +6 -6
- package/dist/components/ui/popover/popover-trigger.svelte +68 -68
- package/dist/components/ui/popover/popover.svelte +53 -53
- package/dist/components/ui/search/SearchInput.svelte +32 -32
- package/dist/components/ui/search/shared/SearchInputCore.svelte +66 -66
- package/dist/components/ui/separator/separator.svelte +28 -28
- package/dist/components/ui/sidebar/core/MenuBarSidebar.svelte +70 -70
- package/dist/components/ui/sidebar/core/ui/navbar/NavMenuBarSidebar.svelte +97 -97
- package/dist/components/ui/sidebar/core/ui/navbar/NavMenuBottomSidebar.svelte +33 -33
- package/dist/components/ui/sidebar/core/ui/navbar/NavMenuTopBarSidebar.svelte +101 -101
- package/dist/components/ui/sidebar/core/ui/navbar/nav-menu-header-sidebar.svelte +77 -77
- package/dist/components/ui/sidebar/sidebar-content.svelte +24 -24
- package/dist/components/ui/sidebar/sidebar-footer.svelte +21 -21
- package/dist/components/ui/sidebar/sidebar-group-content.svelte +21 -21
- package/dist/components/ui/sidebar/sidebar-menu-action.svelte +38 -38
- package/dist/components/ui/sidebar/sidebar-menu-button.svelte +70 -70
- package/dist/components/ui/sidebar/sidebar-menu-sub-button.svelte +39 -39
- package/dist/components/ui/sidebar/sidebar-provider.svelte +62 -62
- package/dist/components/ui/sidebar/sidebar-rail.svelte +36 -36
- package/dist/components/ui/sidebar/sidebar-separator.svelte +21 -21
- package/dist/components/ui/sidebar/sidebar-trigger.svelte +36 -36
- package/dist/components/ui/sidebar/sidebar.svelte +118 -118
- package/dist/components/ui/skeleton/skeleton.svelte +19 -19
- package/dist/components/ui/star-rating/star-rating-star.svelte +66 -66
- package/dist/components/ui/star-rating/star-rating.svelte +149 -149
- package/dist/components/ui/table/table-body.svelte +15 -15
- package/dist/components/ui/table/table-caption.svelte +20 -20
- package/dist/components/ui/table/table-cell.svelte +15 -15
- package/dist/components/ui/table/table-footer.svelte +20 -20
- package/dist/components/ui/table/table-head.svelte +15 -15
- package/dist/components/ui/table/table-header.svelte +20 -20
- package/dist/components/ui/table/table-row.svelte +15 -15
- package/dist/components/ui/table/table.svelte +17 -17
- package/dist/components/ui/tabs/ui/tab-underline.svelte +43 -43
- package/dist/components/ui/underline-tabs/underline-tabs-content.svelte +33 -33
- package/dist/components/ui/underline-tabs/underline-tabs-list.svelte +40 -40
- package/dist/components/ui/underline-tabs/underline-tabs-trigger.svelte +91 -91
- package/dist/components/ui/underline-tabs/underline-tabs.svelte +61 -61
- package/dist/docs/ApiTable.svelte +42 -42
- package/dist/docs/CodeBlock.svelte +26 -26
- package/dist/docs/DocsHeader.svelte +25 -25
- package/dist/docs/DocsSidebar.svelte +108 -156
- package/dist/docs/components.js +638 -563
- package/dist/globals.css +68 -10
- package/dist/i18n/langs/en.d.ts +7 -0
- package/dist/i18n/langs/en.js +7 -0
- package/dist/i18n/langs/pt.d.ts +7 -0
- package/dist/i18n/langs/pt.js +7 -0
- package/dist/i18n/translations.d.ts +14 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.js +23 -0
- package/dist/styles/globals.css +283 -283
- package/dist/types/index.d.ts +3 -1
- package/package.json +81 -81
- package/dist/components/pages/security/login/01/ui/FormRegister.svelte +0 -28
- package/dist/components/pages/security/login/01/ui/FormRegister.svelte.d.ts +0 -3
|
@@ -1,226 +1,226 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import { cn, type WithElementRef } from "../../../utils.js";
|
|
3
|
-
import {
|
|
4
|
-
type CarouselAPI,
|
|
5
|
-
type CarouselProps,
|
|
6
|
-
type EmblaContext,
|
|
7
|
-
setEmblaContext,
|
|
8
|
-
} from "./context.js";
|
|
9
|
-
|
|
10
|
-
let {
|
|
11
|
-
ref = $bindable(null),
|
|
12
|
-
opts = {},
|
|
13
|
-
plugins = [],
|
|
14
|
-
setApi = () => {},
|
|
15
|
-
orientation = "horizontal",
|
|
16
|
-
class: className,
|
|
17
|
-
children,
|
|
18
|
-
...restProps
|
|
19
|
-
}: WithElementRef<CarouselProps> = $props();
|
|
20
|
-
|
|
21
|
-
let isVertical = $derived(orientation === "vertical");
|
|
22
|
-
let available = $state(false);
|
|
23
|
-
|
|
24
|
-
// svelte-ignore state_referenced_locally
|
|
25
|
-
let ctx = $state<EmblaContext>({
|
|
26
|
-
orientation,
|
|
27
|
-
containerEl: undefined,
|
|
28
|
-
canScrollNext: false,
|
|
29
|
-
canScrollPrev: false,
|
|
30
|
-
selectedIndex: 0,
|
|
31
|
-
scrollSnaps: [],
|
|
32
|
-
scrollPrev,
|
|
33
|
-
scrollNext,
|
|
34
|
-
scrollTo,
|
|
35
|
-
onScroll,
|
|
36
|
-
handleKeyDown,
|
|
37
|
-
plugins,
|
|
38
|
-
setContainer,
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
setEmblaContext(ctx);
|
|
42
|
-
|
|
43
|
-
function setContainer(el: HTMLDivElement | null | undefined) {
|
|
44
|
-
ctx.containerEl = el ?? undefined;
|
|
45
|
-
available = el != null;
|
|
46
|
-
updateScrollSnaps();
|
|
47
|
-
onScroll();
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
function getSlides(): HTMLElement[] {
|
|
51
|
-
const container = ctx.containerEl;
|
|
52
|
-
if (!container) return [];
|
|
53
|
-
return Array.from(
|
|
54
|
-
container.querySelectorAll<HTMLElement>("[data-slot='carousel-item']")
|
|
55
|
-
);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
function snapsEqual(a: number[], b: number[]): boolean {
|
|
59
|
-
if (a.length !== b.length) return false;
|
|
60
|
-
for (let i = 0; i < a.length; i++) if (a[i] !== b[i]) return false;
|
|
61
|
-
return true;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
function updateScrollSnaps() {
|
|
65
|
-
const container = ctx.containerEl;
|
|
66
|
-
if (!container) {
|
|
67
|
-
if (ctx.scrollSnaps.length > 0) ctx.scrollSnaps = [];
|
|
68
|
-
return;
|
|
69
|
-
}
|
|
70
|
-
const scrollPos = isVertical ? container.scrollTop : container.scrollLeft;
|
|
71
|
-
const origin = isVertical
|
|
72
|
-
? container.getBoundingClientRect().top
|
|
73
|
-
: container.getBoundingClientRect().left;
|
|
74
|
-
const next = getSlides().map((slide) => {
|
|
75
|
-
const slidePos = isVertical
|
|
76
|
-
? slide.getBoundingClientRect().top
|
|
77
|
-
: slide.getBoundingClientRect().left;
|
|
78
|
-
return slidePos - origin + scrollPos;
|
|
79
|
-
});
|
|
80
|
-
if (!snapsEqual(ctx.scrollSnaps, next)) ctx.scrollSnaps = next;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
function onScroll() {
|
|
84
|
-
const container = ctx.containerEl;
|
|
85
|
-
if (!container) return;
|
|
86
|
-
const pos = isVertical ? container.scrollTop : container.scrollLeft;
|
|
87
|
-
const size = isVertical ? container.clientHeight : container.clientWidth;
|
|
88
|
-
const scrollSize = isVertical
|
|
89
|
-
? container.scrollHeight
|
|
90
|
-
: container.scrollWidth;
|
|
91
|
-
const max = Math.max(0, scrollSize - size);
|
|
92
|
-
ctx.canScrollPrev = pos > 1;
|
|
93
|
-
ctx.canScrollNext = pos < max - 1;
|
|
94
|
-
const snaps = ctx.scrollSnaps;
|
|
95
|
-
let closest = 0;
|
|
96
|
-
let minDistance = Infinity;
|
|
97
|
-
for (let i = 0; i < snaps.length; i++) {
|
|
98
|
-
const distance = Math.abs(snaps[i] - pos);
|
|
99
|
-
if (distance < minDistance) {
|
|
100
|
-
minDistance = distance;
|
|
101
|
-
closest = i;
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
ctx.selectedIndex = minDistance === Infinity ? 0 : closest;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
function scrollTo(index: number, jump?: boolean) {
|
|
108
|
-
const container = ctx.containerEl;
|
|
109
|
-
const snaps = ctx.scrollSnaps;
|
|
110
|
-
if (!container || snaps.length === 0) return;
|
|
111
|
-
const target = Math.min(Math.max(index, 0), snaps.length - 1);
|
|
112
|
-
const snap = snaps[target];
|
|
113
|
-
container.scrollTo({
|
|
114
|
-
left: isVertical ? 0 : snap,
|
|
115
|
-
top: isVertical ? snap : 0,
|
|
116
|
-
behavior: jump ? "instant" : "smooth",
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
function scrollPrev() {
|
|
121
|
-
scrollTo(ctx.selectedIndex - 1);
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
function scrollNext() {
|
|
125
|
-
scrollTo(ctx.selectedIndex + 1);
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
function buildApi(): CarouselAPI {
|
|
129
|
-
return {
|
|
130
|
-
scrollPrev,
|
|
131
|
-
scrollNext,
|
|
132
|
-
canScrollPrev: ctx.canScrollPrev,
|
|
133
|
-
canScrollNext: ctx.canScrollNext,
|
|
134
|
-
selectedIndex: ctx.selectedIndex,
|
|
135
|
-
scrollTo,
|
|
136
|
-
scrollSnapList: () => ctx.scrollSnaps.slice(),
|
|
137
|
-
};
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
$effect(() => {
|
|
141
|
-
setApi(buildApi());
|
|
142
|
-
});
|
|
143
|
-
|
|
144
|
-
function handleKeyDown(e: KeyboardEvent) {
|
|
145
|
-
if (e.key === "ArrowLeft") {
|
|
146
|
-
e.preventDefault();
|
|
147
|
-
scrollPrev();
|
|
148
|
-
} else if (e.key === "ArrowRight") {
|
|
149
|
-
e.preventDefault();
|
|
150
|
-
scrollNext();
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
$effect(() => {
|
|
155
|
-
if (!available) return;
|
|
156
|
-
const container = ctx.containerEl;
|
|
157
|
-
if (!container) return;
|
|
158
|
-
const plugin = plugins[0];
|
|
159
|
-
if (!plugin?.delay) return;
|
|
160
|
-
|
|
161
|
-
let stopped = false;
|
|
162
|
-
let timer: number | undefined;
|
|
163
|
-
let lastIndex = ctx.selectedIndex;
|
|
164
|
-
|
|
165
|
-
const clearTimer = () => {
|
|
166
|
-
if (timer !== undefined) window.clearTimeout(timer);
|
|
167
|
-
};
|
|
168
|
-
|
|
169
|
-
const cleanup = () => {
|
|
170
|
-
stopped = true;
|
|
171
|
-
clearTimer();
|
|
172
|
-
};
|
|
173
|
-
|
|
174
|
-
const schedule = () => {
|
|
175
|
-
if (stopped) return;
|
|
176
|
-
timer = window.setTimeout(() => {
|
|
177
|
-
if (stopped) return;
|
|
178
|
-
if (ctx.canScrollNext) {
|
|
179
|
-
scrollNext();
|
|
180
|
-
} else if (plugin.loop) {
|
|
181
|
-
scrollTo(0, true);
|
|
182
|
-
}
|
|
183
|
-
lastIndex = ctx.selectedIndex;
|
|
184
|
-
schedule();
|
|
185
|
-
}, plugin.delay);
|
|
186
|
-
};
|
|
187
|
-
|
|
188
|
-
const onPointer = () => {
|
|
189
|
-
if (stopped) return;
|
|
190
|
-
if (plugin.stopOnInteraction) cleanup();
|
|
191
|
-
};
|
|
192
|
-
|
|
193
|
-
const onScrollReset = () => {
|
|
194
|
-
if (stopped || plugin.stopOnInteraction) return;
|
|
195
|
-
if (ctx.selectedIndex !== lastIndex) {
|
|
196
|
-
clearTimer();
|
|
197
|
-
lastIndex = ctx.selectedIndex;
|
|
198
|
-
schedule();
|
|
199
|
-
}
|
|
200
|
-
};
|
|
201
|
-
|
|
202
|
-
container.addEventListener("pointerdown", onPointer);
|
|
203
|
-
container.addEventListener("touchstart", onPointer);
|
|
204
|
-
container.addEventListener("scroll", onScrollReset, { passive: true });
|
|
205
|
-
|
|
206
|
-
schedule();
|
|
207
|
-
|
|
208
|
-
return () => {
|
|
209
|
-
cleanup();
|
|
210
|
-
container.removeEventListener("pointerdown", onPointer);
|
|
211
|
-
container.removeEventListener("touchstart", onPointer);
|
|
212
|
-
container.removeEventListener("scroll", onScrollReset);
|
|
213
|
-
};
|
|
214
|
-
});
|
|
215
|
-
</script>
|
|
216
|
-
|
|
217
|
-
<div
|
|
218
|
-
bind:this={ref}
|
|
219
|
-
data-slot="carousel"
|
|
220
|
-
class={cn("relative", className)}
|
|
221
|
-
role="region"
|
|
222
|
-
aria-roledescription="carousel"
|
|
223
|
-
{...restProps}
|
|
224
|
-
>
|
|
225
|
-
{@render children?.()}
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { cn, type WithElementRef } from "../../../utils.js";
|
|
3
|
+
import {
|
|
4
|
+
type CarouselAPI,
|
|
5
|
+
type CarouselProps,
|
|
6
|
+
type EmblaContext,
|
|
7
|
+
setEmblaContext,
|
|
8
|
+
} from "./context.js";
|
|
9
|
+
|
|
10
|
+
let {
|
|
11
|
+
ref = $bindable(null),
|
|
12
|
+
opts = {},
|
|
13
|
+
plugins = [],
|
|
14
|
+
setApi = () => {},
|
|
15
|
+
orientation = "horizontal",
|
|
16
|
+
class: className,
|
|
17
|
+
children,
|
|
18
|
+
...restProps
|
|
19
|
+
}: WithElementRef<CarouselProps> = $props();
|
|
20
|
+
|
|
21
|
+
let isVertical = $derived(orientation === "vertical");
|
|
22
|
+
let available = $state(false);
|
|
23
|
+
|
|
24
|
+
// svelte-ignore state_referenced_locally
|
|
25
|
+
let ctx = $state<EmblaContext>({
|
|
26
|
+
orientation,
|
|
27
|
+
containerEl: undefined,
|
|
28
|
+
canScrollNext: false,
|
|
29
|
+
canScrollPrev: false,
|
|
30
|
+
selectedIndex: 0,
|
|
31
|
+
scrollSnaps: [],
|
|
32
|
+
scrollPrev,
|
|
33
|
+
scrollNext,
|
|
34
|
+
scrollTo,
|
|
35
|
+
onScroll,
|
|
36
|
+
handleKeyDown,
|
|
37
|
+
plugins,
|
|
38
|
+
setContainer,
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
setEmblaContext(ctx);
|
|
42
|
+
|
|
43
|
+
function setContainer(el: HTMLDivElement | null | undefined) {
|
|
44
|
+
ctx.containerEl = el ?? undefined;
|
|
45
|
+
available = el != null;
|
|
46
|
+
updateScrollSnaps();
|
|
47
|
+
onScroll();
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function getSlides(): HTMLElement[] {
|
|
51
|
+
const container = ctx.containerEl;
|
|
52
|
+
if (!container) return [];
|
|
53
|
+
return Array.from(
|
|
54
|
+
container.querySelectorAll<HTMLElement>("[data-slot='carousel-item']")
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function snapsEqual(a: number[], b: number[]): boolean {
|
|
59
|
+
if (a.length !== b.length) return false;
|
|
60
|
+
for (let i = 0; i < a.length; i++) if (a[i] !== b[i]) return false;
|
|
61
|
+
return true;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function updateScrollSnaps() {
|
|
65
|
+
const container = ctx.containerEl;
|
|
66
|
+
if (!container) {
|
|
67
|
+
if (ctx.scrollSnaps.length > 0) ctx.scrollSnaps = [];
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
const scrollPos = isVertical ? container.scrollTop : container.scrollLeft;
|
|
71
|
+
const origin = isVertical
|
|
72
|
+
? container.getBoundingClientRect().top
|
|
73
|
+
: container.getBoundingClientRect().left;
|
|
74
|
+
const next = getSlides().map((slide) => {
|
|
75
|
+
const slidePos = isVertical
|
|
76
|
+
? slide.getBoundingClientRect().top
|
|
77
|
+
: slide.getBoundingClientRect().left;
|
|
78
|
+
return slidePos - origin + scrollPos;
|
|
79
|
+
});
|
|
80
|
+
if (!snapsEqual(ctx.scrollSnaps, next)) ctx.scrollSnaps = next;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function onScroll() {
|
|
84
|
+
const container = ctx.containerEl;
|
|
85
|
+
if (!container) return;
|
|
86
|
+
const pos = isVertical ? container.scrollTop : container.scrollLeft;
|
|
87
|
+
const size = isVertical ? container.clientHeight : container.clientWidth;
|
|
88
|
+
const scrollSize = isVertical
|
|
89
|
+
? container.scrollHeight
|
|
90
|
+
: container.scrollWidth;
|
|
91
|
+
const max = Math.max(0, scrollSize - size);
|
|
92
|
+
ctx.canScrollPrev = pos > 1;
|
|
93
|
+
ctx.canScrollNext = pos < max - 1;
|
|
94
|
+
const snaps = ctx.scrollSnaps;
|
|
95
|
+
let closest = 0;
|
|
96
|
+
let minDistance = Infinity;
|
|
97
|
+
for (let i = 0; i < snaps.length; i++) {
|
|
98
|
+
const distance = Math.abs(snaps[i] - pos);
|
|
99
|
+
if (distance < minDistance) {
|
|
100
|
+
minDistance = distance;
|
|
101
|
+
closest = i;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
ctx.selectedIndex = minDistance === Infinity ? 0 : closest;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function scrollTo(index: number, jump?: boolean) {
|
|
108
|
+
const container = ctx.containerEl;
|
|
109
|
+
const snaps = ctx.scrollSnaps;
|
|
110
|
+
if (!container || snaps.length === 0) return;
|
|
111
|
+
const target = Math.min(Math.max(index, 0), snaps.length - 1);
|
|
112
|
+
const snap = snaps[target];
|
|
113
|
+
container.scrollTo({
|
|
114
|
+
left: isVertical ? 0 : snap,
|
|
115
|
+
top: isVertical ? snap : 0,
|
|
116
|
+
behavior: jump ? "instant" : "smooth",
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function scrollPrev() {
|
|
121
|
+
scrollTo(ctx.selectedIndex - 1);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
function scrollNext() {
|
|
125
|
+
scrollTo(ctx.selectedIndex + 1);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function buildApi(): CarouselAPI {
|
|
129
|
+
return {
|
|
130
|
+
scrollPrev,
|
|
131
|
+
scrollNext,
|
|
132
|
+
canScrollPrev: ctx.canScrollPrev,
|
|
133
|
+
canScrollNext: ctx.canScrollNext,
|
|
134
|
+
selectedIndex: ctx.selectedIndex,
|
|
135
|
+
scrollTo,
|
|
136
|
+
scrollSnapList: () => ctx.scrollSnaps.slice(),
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
$effect(() => {
|
|
141
|
+
setApi(buildApi());
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
function handleKeyDown(e: KeyboardEvent) {
|
|
145
|
+
if (e.key === "ArrowLeft") {
|
|
146
|
+
e.preventDefault();
|
|
147
|
+
scrollPrev();
|
|
148
|
+
} else if (e.key === "ArrowRight") {
|
|
149
|
+
e.preventDefault();
|
|
150
|
+
scrollNext();
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
$effect(() => {
|
|
155
|
+
if (!available) return;
|
|
156
|
+
const container = ctx.containerEl;
|
|
157
|
+
if (!container) return;
|
|
158
|
+
const plugin = plugins[0];
|
|
159
|
+
if (!plugin?.delay) return;
|
|
160
|
+
|
|
161
|
+
let stopped = false;
|
|
162
|
+
let timer: number | undefined;
|
|
163
|
+
let lastIndex = ctx.selectedIndex;
|
|
164
|
+
|
|
165
|
+
const clearTimer = () => {
|
|
166
|
+
if (timer !== undefined) window.clearTimeout(timer);
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
const cleanup = () => {
|
|
170
|
+
stopped = true;
|
|
171
|
+
clearTimer();
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
const schedule = () => {
|
|
175
|
+
if (stopped) return;
|
|
176
|
+
timer = window.setTimeout(() => {
|
|
177
|
+
if (stopped) return;
|
|
178
|
+
if (ctx.canScrollNext) {
|
|
179
|
+
scrollNext();
|
|
180
|
+
} else if (plugin.loop) {
|
|
181
|
+
scrollTo(0, true);
|
|
182
|
+
}
|
|
183
|
+
lastIndex = ctx.selectedIndex;
|
|
184
|
+
schedule();
|
|
185
|
+
}, plugin.delay);
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
const onPointer = () => {
|
|
189
|
+
if (stopped) return;
|
|
190
|
+
if (plugin.stopOnInteraction) cleanup();
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
const onScrollReset = () => {
|
|
194
|
+
if (stopped || plugin.stopOnInteraction) return;
|
|
195
|
+
if (ctx.selectedIndex !== lastIndex) {
|
|
196
|
+
clearTimer();
|
|
197
|
+
lastIndex = ctx.selectedIndex;
|
|
198
|
+
schedule();
|
|
199
|
+
}
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
container.addEventListener("pointerdown", onPointer);
|
|
203
|
+
container.addEventListener("touchstart", onPointer);
|
|
204
|
+
container.addEventListener("scroll", onScrollReset, { passive: true });
|
|
205
|
+
|
|
206
|
+
schedule();
|
|
207
|
+
|
|
208
|
+
return () => {
|
|
209
|
+
cleanup();
|
|
210
|
+
container.removeEventListener("pointerdown", onPointer);
|
|
211
|
+
container.removeEventListener("touchstart", onPointer);
|
|
212
|
+
container.removeEventListener("scroll", onScrollReset);
|
|
213
|
+
};
|
|
214
|
+
});
|
|
215
|
+
</script>
|
|
216
|
+
|
|
217
|
+
<div
|
|
218
|
+
bind:this={ref}
|
|
219
|
+
data-slot="carousel"
|
|
220
|
+
class={cn("relative", className)}
|
|
221
|
+
role="region"
|
|
222
|
+
aria-roledescription="carousel"
|
|
223
|
+
{...restProps}
|
|
224
|
+
>
|
|
225
|
+
{@render children?.()}
|
|
226
226
|
</div>
|
|
@@ -1,108 +1,108 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import * as Carousel from "../../../index.js";
|
|
3
|
-
import type { CarouselBadgeProps } from "../../types.js";
|
|
4
|
-
import { HugeiconsIcon } from "@hugeicons/svelte";
|
|
5
|
-
import Skeleton from "../../../../skeleton/skeleton.svelte";
|
|
6
|
-
import { useDevice } from "../../../../../../hooks/responsive.svelte";
|
|
7
|
-
|
|
8
|
-
const {
|
|
9
|
-
items = [],
|
|
10
|
-
imageClass,
|
|
11
|
-
iconClass,
|
|
12
|
-
labelClass,
|
|
13
|
-
activeClass = "bg-gradient text-white rounded-full px-3",
|
|
14
|
-
orientation = "horizontal",
|
|
15
|
-
itemStyle = "DEFAULT",
|
|
16
|
-
isBorderInline = false,
|
|
17
|
-
showButton = true,
|
|
18
|
-
isLoading = false,
|
|
19
|
-
btnNavClass,
|
|
20
|
-
itemClass,
|
|
21
|
-
menuKey,
|
|
22
|
-
onClick,
|
|
23
|
-
}: CarouselBadgeProps = $props();
|
|
24
|
-
|
|
25
|
-
const TOP_NAV = $derived(isBorderInline ? "top-5.5" : "top-7.5");
|
|
26
|
-
const borderB = $derived(
|
|
27
|
-
isBorderInline ? `border-b-2 ${itemStyle == "BORDER" ? "pb-2" : ""}` : "",
|
|
28
|
-
);
|
|
29
|
-
const isInlineBorder = $derived(isBorderInline && itemStyle == "INLINE");
|
|
30
|
-
const DEFAULT_IMG_OR_ICON_CLASS = "size-3 md:size-6";
|
|
31
|
-
|
|
32
|
-
const responsive = useDevice();
|
|
33
|
-
const skeletonCount = $derived(responsive.isMobile ? 2 : 8);
|
|
34
|
-
|
|
35
|
-
// svelte-ignore state_referenced_locally
|
|
36
|
-
let selectedValue = $state<string | undefined>(menuKey ?? "");
|
|
37
|
-
|
|
38
|
-
function isSelected(item: (typeof items)[number]) {
|
|
39
|
-
return item.value !== undefined && item.value === selectedValue;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
function selectItem(item: (typeof items)[number]) {
|
|
43
|
-
selectedValue = item.value;
|
|
44
|
-
item.onClick?.(item.value);
|
|
45
|
-
onClick?.(item.value);
|
|
46
|
-
}
|
|
47
|
-
</script>
|
|
48
|
-
|
|
49
|
-
{#snippet itemVisual(item: (typeof items)[number])}
|
|
50
|
-
{#if item.image}
|
|
51
|
-
<img
|
|
52
|
-
src={item.image}
|
|
53
|
-
alt={item.label}
|
|
54
|
-
class={imageClass || DEFAULT_IMG_OR_ICON_CLASS}
|
|
55
|
-
/>
|
|
56
|
-
{:else if typeof item.icon === "string"}
|
|
57
|
-
<i class={`${item.icon} ${iconClass || DEFAULT_IMG_OR_ICON_CLASS}`}></i>
|
|
58
|
-
{:else if item.icon}
|
|
59
|
-
<HugeiconsIcon
|
|
60
|
-
icon={item.icon}
|
|
61
|
-
class={iconClass || DEFAULT_IMG_OR_ICON_CLASS}
|
|
62
|
-
/>
|
|
63
|
-
{/if}
|
|
64
|
-
{/snippet}
|
|
65
|
-
|
|
66
|
-
{#if items.length > 0}
|
|
67
|
-
<Carousel.Root>
|
|
68
|
-
<Carousel.Content class={borderB}>
|
|
69
|
-
{#if isLoading}
|
|
70
|
-
<div class="flex items-center justify-between w-full gap-1 md:gap-2">
|
|
71
|
-
{#each Array.from( { length: skeletonCount }, ) as _, i (`skeleton-${i}`)}
|
|
72
|
-
<Skeleton class="h-4 w-25 bg-gray-50/90" />
|
|
73
|
-
{/each}
|
|
74
|
-
</div>
|
|
75
|
-
{:else}
|
|
76
|
-
{#each items as item, i (`badge-${i}-${item.value ?? item.label ?? i}`)}
|
|
77
|
-
<Carousel.Item onclick={() => selectItem(item)}>
|
|
78
|
-
<div
|
|
79
|
-
class="flex gap-1 mx-2 p-1 justify-center w-min items-center cursor-pointer relative hover:text-lg hover:font-bold
|
|
80
|
-
{isSelected(item)
|
|
81
|
-
? isInlineBorder
|
|
82
|
-
? 'text-gradient font-bold'
|
|
83
|
-
: activeClass
|
|
84
|
-
: ''}
|
|
85
|
-
{itemStyle == 'BORDER' ? 'border-2 rounded-full min-w-25 px-1' : ''}
|
|
86
|
-
{orientation === 'horizontal' ? 'flex-row' : 'flex-col'}
|
|
87
|
-
{isInlineBorder ? 'pb-3' : ''}
|
|
88
|
-
{itemClass}
|
|
89
|
-
"
|
|
90
|
-
>
|
|
91
|
-
{@render itemVisual(item)}
|
|
92
|
-
<div class={labelClass}>{item.label}</div>
|
|
93
|
-
</div>
|
|
94
|
-
{#if isSelected(item) && isInlineBorder}
|
|
95
|
-
<div class="absolute pt-5 w-full h-2 bg-gradient"></div>
|
|
96
|
-
{/if}
|
|
97
|
-
</Carousel.Item>
|
|
98
|
-
{/each}
|
|
99
|
-
{/if}
|
|
100
|
-
</Carousel.Content>
|
|
101
|
-
{#if showButton}
|
|
102
|
-
{@const navClass =
|
|
103
|
-
"absolute -translate-y-1/2 z-50 bg-blue-700! text-white! cursor-pointer"}
|
|
104
|
-
<Carousel.Previous class="-left-8 {navClass} {TOP_NAV} {btnNavClass}" />
|
|
105
|
-
<Carousel.Next class="-right-8 {navClass} {TOP_NAV} {btnNavClass}" />
|
|
106
|
-
{/if}
|
|
107
|
-
</Carousel.Root>
|
|
108
|
-
{/if}
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import * as Carousel from "../../../index.js";
|
|
3
|
+
import type { CarouselBadgeProps } from "../../types.js";
|
|
4
|
+
import { HugeiconsIcon } from "@hugeicons/svelte";
|
|
5
|
+
import Skeleton from "../../../../skeleton/skeleton.svelte";
|
|
6
|
+
import { useDevice } from "../../../../../../hooks/responsive.svelte";
|
|
7
|
+
|
|
8
|
+
const {
|
|
9
|
+
items = [],
|
|
10
|
+
imageClass,
|
|
11
|
+
iconClass,
|
|
12
|
+
labelClass,
|
|
13
|
+
activeClass = "bg-gradient text-white rounded-full px-3",
|
|
14
|
+
orientation = "horizontal",
|
|
15
|
+
itemStyle = "DEFAULT",
|
|
16
|
+
isBorderInline = false,
|
|
17
|
+
showButton = true,
|
|
18
|
+
isLoading = false,
|
|
19
|
+
btnNavClass,
|
|
20
|
+
itemClass,
|
|
21
|
+
menuKey,
|
|
22
|
+
onClick,
|
|
23
|
+
}: CarouselBadgeProps = $props();
|
|
24
|
+
|
|
25
|
+
const TOP_NAV = $derived(isBorderInline ? "top-5.5" : "top-7.5");
|
|
26
|
+
const borderB = $derived(
|
|
27
|
+
isBorderInline ? `border-b-2 ${itemStyle == "BORDER" ? "pb-2" : ""}` : "",
|
|
28
|
+
);
|
|
29
|
+
const isInlineBorder = $derived(isBorderInline && itemStyle == "INLINE");
|
|
30
|
+
const DEFAULT_IMG_OR_ICON_CLASS = "size-3 md:size-6";
|
|
31
|
+
|
|
32
|
+
const responsive = useDevice();
|
|
33
|
+
const skeletonCount = $derived(responsive.isMobile ? 2 : 8);
|
|
34
|
+
|
|
35
|
+
// svelte-ignore state_referenced_locally
|
|
36
|
+
let selectedValue = $state<string | undefined>(menuKey ?? "");
|
|
37
|
+
|
|
38
|
+
function isSelected(item: (typeof items)[number]) {
|
|
39
|
+
return item.value !== undefined && item.value === selectedValue;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function selectItem(item: (typeof items)[number]) {
|
|
43
|
+
selectedValue = item.value;
|
|
44
|
+
item.onClick?.(item.value);
|
|
45
|
+
onClick?.(item.value);
|
|
46
|
+
}
|
|
47
|
+
</script>
|
|
48
|
+
|
|
49
|
+
{#snippet itemVisual(item: (typeof items)[number])}
|
|
50
|
+
{#if item.image}
|
|
51
|
+
<img
|
|
52
|
+
src={item.image}
|
|
53
|
+
alt={item.label}
|
|
54
|
+
class={imageClass || DEFAULT_IMG_OR_ICON_CLASS}
|
|
55
|
+
/>
|
|
56
|
+
{:else if typeof item.icon === "string"}
|
|
57
|
+
<i class={`${item.icon} ${iconClass || DEFAULT_IMG_OR_ICON_CLASS}`}></i>
|
|
58
|
+
{:else if item.icon}
|
|
59
|
+
<HugeiconsIcon
|
|
60
|
+
icon={item.icon}
|
|
61
|
+
class={iconClass || DEFAULT_IMG_OR_ICON_CLASS}
|
|
62
|
+
/>
|
|
63
|
+
{/if}
|
|
64
|
+
{/snippet}
|
|
65
|
+
|
|
66
|
+
{#if items.length > 0}
|
|
67
|
+
<Carousel.Root>
|
|
68
|
+
<Carousel.Content class={borderB}>
|
|
69
|
+
{#if isLoading}
|
|
70
|
+
<div class="flex items-center justify-between w-full gap-1 md:gap-2">
|
|
71
|
+
{#each Array.from( { length: skeletonCount }, ) as _, i (`skeleton-${i}`)}
|
|
72
|
+
<Skeleton class="h-4 w-25 bg-gray-50/90" />
|
|
73
|
+
{/each}
|
|
74
|
+
</div>
|
|
75
|
+
{:else}
|
|
76
|
+
{#each items as item, i (`badge-${i}-${item.value ?? item.label ?? i}`)}
|
|
77
|
+
<Carousel.Item onclick={() => selectItem(item)}>
|
|
78
|
+
<div
|
|
79
|
+
class="flex gap-1 mx-2 p-1 justify-center w-min items-center cursor-pointer relative hover:text-lg hover:font-bold
|
|
80
|
+
{isSelected(item)
|
|
81
|
+
? isInlineBorder
|
|
82
|
+
? 'text-gradient font-bold'
|
|
83
|
+
: activeClass
|
|
84
|
+
: ''}
|
|
85
|
+
{itemStyle == 'BORDER' ? 'border-2 rounded-full min-w-25 px-1' : ''}
|
|
86
|
+
{orientation === 'horizontal' ? 'flex-row' : 'flex-col'}
|
|
87
|
+
{isInlineBorder ? 'pb-3' : ''}
|
|
88
|
+
{itemClass}
|
|
89
|
+
"
|
|
90
|
+
>
|
|
91
|
+
{@render itemVisual(item)}
|
|
92
|
+
<div class={labelClass}>{item.label}</div>
|
|
93
|
+
</div>
|
|
94
|
+
{#if isSelected(item) && isInlineBorder}
|
|
95
|
+
<div class="absolute pt-5 w-full h-2 bg-gradient"></div>
|
|
96
|
+
{/if}
|
|
97
|
+
</Carousel.Item>
|
|
98
|
+
{/each}
|
|
99
|
+
{/if}
|
|
100
|
+
</Carousel.Content>
|
|
101
|
+
{#if showButton}
|
|
102
|
+
{@const navClass =
|
|
103
|
+
"absolute -translate-y-1/2 z-50 bg-blue-700! text-white! cursor-pointer"}
|
|
104
|
+
<Carousel.Previous class="-left-8 {navClass} {TOP_NAV} {btnNavClass}" />
|
|
105
|
+
<Carousel.Next class="-right-8 {navClass} {TOP_NAV} {btnNavClass}" />
|
|
106
|
+
{/if}
|
|
107
|
+
</Carousel.Root>
|
|
108
|
+
{/if}
|