@xbg.solutions/create-frontend 1.1.1 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/xbg-frontend.cjs +32 -0
- package/package.json +17 -3
- package/src/commands/add.cjs +470 -0
- package/src/commands/generate.cjs +24 -0
- package/src/manifest.json +1578 -0
- package/src/registry/advanced/ChartWrapper.svelte +587 -0
- package/src/registry/advanced/DataTable.svelte +645 -0
- package/src/registry/advanced/FormWizard.svelte +546 -0
- package/src/registry/advanced/ImageUpload.svelte +663 -0
- package/src/registry/advanced/index.ts +33 -0
- package/src/registry/atoms/calendar/Calendar.svelte +181 -0
- package/src/registry/atoms/calendar/index.ts +1 -0
- package/src/registry/atoms/dialog/Dialog.svelte +179 -0
- package/src/registry/atoms/dialog/DialogDescription.svelte +16 -0
- package/src/registry/atoms/dialog/DialogFooter.svelte +16 -0
- package/src/registry/atoms/dialog/DialogHeader.svelte +16 -0
- package/src/registry/atoms/dialog/DialogTitle.svelte +16 -0
- package/src/registry/atoms/dialog/index.ts +10 -0
- package/src/registry/atoms/icon/BrandIcon.svelte +47 -0
- package/src/registry/atoms/icon/DynamicIcon.svelte +49 -0
- package/src/registry/atoms/icon/index.ts +2 -0
- package/src/registry/atoms/legend/Legend.svelte +32 -0
- package/src/registry/atoms/legend/index.ts +1 -0
- package/src/registry/atoms/menu/MenuItem.svelte +85 -0
- package/src/registry/atoms/menu/index.ts +1 -0
- package/src/registry/atoms/message/Message.svelte +62 -0
- package/src/registry/atoms/message/index.ts +1 -0
- package/src/registry/atoms/nav/NavItem.svelte +67 -0
- package/src/registry/atoms/nav/index.ts +1 -0
- package/src/registry/atoms/notification-badge/NotificationBadge.svelte +30 -0
- package/src/registry/atoms/notification-badge/index.ts +1 -0
- package/src/registry/atoms/otp-input/OtpInput.svelte +108 -0
- package/src/registry/atoms/otp-input/index.ts +1 -0
- package/src/registry/atoms/select/Select.svelte +216 -0
- package/src/registry/atoms/select/index.ts +6 -0
- package/src/registry/atoms/settings-card/SettingsCard.svelte +48 -0
- package/src/registry/atoms/settings-card/index.ts +1 -0
- package/src/registry/atoms/sidebar-item/SidebarItem.svelte +90 -0
- package/src/registry/atoms/sidebar-item/index.ts +1 -0
- package/src/registry/atoms/statistic-card/StatisticCard.svelte +53 -0
- package/src/registry/atoms/statistic-card/index.ts +1 -0
- package/src/registry/atoms/text-editor/TextEditor.svelte +77 -0
- package/src/registry/atoms/text-editor/index.ts +1 -0
- package/src/registry/atoms/uploader/Uploader.svelte +102 -0
- package/src/registry/atoms/uploader/index.ts +1 -0
- package/src/registry/atoms/user-item/UserItem.svelte +39 -0
- package/src/registry/atoms/user-item/index.ts +1 -0
- package/src/registry/blocks/account-section/AccountSection01.svelte +112 -0
- package/src/registry/blocks/account-section/AccountSection02.svelte +190 -0
- package/src/registry/blocks/account-section/AccountSection03.svelte +161 -0
- package/src/registry/blocks/account-section/AccountSection04.svelte +164 -0
- package/src/registry/blocks/account-section/AccountSection05.svelte +76 -0
- package/src/registry/blocks/account-section/index.ts +5 -0
- package/src/registry/blocks/app-shell/AppShell01.svelte +74 -0
- package/src/registry/blocks/app-shell/AppShell02.svelte +87 -0
- package/src/registry/blocks/app-shell/AppShell03.svelte +79 -0
- package/src/registry/blocks/app-shell/AppShell04.svelte +177 -0
- package/src/registry/blocks/app-shell/index.ts +4 -0
- package/src/registry/blocks/auth/AuthSplitScreen.svelte +132 -0
- package/src/registry/blocks/auth/LoginBlock01.svelte +94 -0
- package/src/registry/blocks/auth/LoginBlock02.svelte +103 -0
- package/src/registry/blocks/auth/LoginBlock03.svelte +53 -0
- package/src/registry/blocks/auth/LoginBlock04.svelte +99 -0
- package/src/registry/blocks/auth/LoginBlock05.svelte +101 -0
- package/src/registry/blocks/auth/OtpBlock01.svelte +115 -0
- package/src/registry/blocks/auth/OtpBlock02.svelte +113 -0
- package/src/registry/blocks/auth/OtpBlock03.svelte +143 -0
- package/src/registry/blocks/auth/OtpBlock04.svelte +122 -0
- package/src/registry/blocks/auth/OtpBlock05.svelte +81 -0
- package/src/registry/blocks/auth/SignupBlock01.svelte +103 -0
- package/src/registry/blocks/auth/SignupBlock02.svelte +94 -0
- package/src/registry/blocks/auth/SignupBlock03.svelte +120 -0
- package/src/registry/blocks/auth/SignupBlock04.svelte +112 -0
- package/src/registry/blocks/auth/SignupBlock05.svelte +77 -0
- package/src/registry/blocks/auth/index.ts +31 -0
- package/src/registry/blocks/banner/Banner01.svelte +67 -0
- package/src/registry/blocks/banner/Banner02.svelte +61 -0
- package/src/registry/blocks/banner/Banner03.svelte +54 -0
- package/src/registry/blocks/banner/Banner04.svelte +49 -0
- package/src/registry/blocks/banner/Banner05.svelte +47 -0
- package/src/registry/blocks/banner/index.ts +5 -0
- package/src/registry/blocks/bento-grid/BentoGrid01.svelte +92 -0
- package/src/registry/blocks/bento-grid/BentoGrid02.svelte +79 -0
- package/src/registry/blocks/bento-grid/BentoGrid03.svelte +79 -0
- package/src/registry/blocks/bento-grid/BentoGrid04.svelte +58 -0
- package/src/registry/blocks/bento-grid/BentoGrid05.svelte +92 -0
- package/src/registry/blocks/bento-grid/BentoGrid06.svelte +42 -0
- package/src/registry/blocks/bento-grid/index.ts +14 -0
- package/src/registry/blocks/blog-section/BlogSection01.svelte +100 -0
- package/src/registry/blocks/blog-section/BlogSection02.svelte +93 -0
- package/src/registry/blocks/blog-section/BlogSection03.svelte +92 -0
- package/src/registry/blocks/blog-section/BlogSection04.svelte +97 -0
- package/src/registry/blocks/blog-section/BlogSection05.svelte +120 -0
- package/src/registry/blocks/blog-section/index.ts +15 -0
- package/src/registry/blocks/buttons/ButtonBookmark.svelte +37 -0
- package/src/registry/blocks/buttons/ButtonLike.svelte +37 -0
- package/src/registry/blocks/buttons/ButtonMenu.svelte +37 -0
- package/src/registry/blocks/buttons/ButtonSplitDropdown.svelte +46 -0
- package/src/registry/blocks/buttons/ButtonStepper.svelte +55 -0
- package/src/registry/blocks/buttons/ButtonSteps.svelte +73 -0
- package/src/registry/blocks/buttons/ButtonToggleGroup.svelte +35 -0
- package/src/registry/blocks/buttons/ButtonsGroup.svelte +63 -0
- package/src/registry/blocks/buttons/SocialButtonsHorizontal.svelte +41 -0
- package/src/registry/blocks/buttons/SocialButtonsVertical.svelte +53 -0
- package/src/registry/blocks/buttons/index.ts +10 -0
- package/src/registry/blocks/calendar/CalendarBlock01.svelte +169 -0
- package/src/registry/blocks/calendar/CalendarBlock02.svelte +133 -0
- package/src/registry/blocks/calendar/CalendarBlock03.svelte +194 -0
- package/src/registry/blocks/calendar/CalendarBlock04.svelte +96 -0
- package/src/registry/blocks/calendar/CalendarBlock05.svelte +97 -0
- package/src/registry/blocks/calendar/CalendarBlock06.svelte +98 -0
- package/src/registry/blocks/calendar/CalendarBlock07.svelte +109 -0
- package/src/registry/blocks/calendar/CalendarBlock08.svelte +71 -0
- package/src/registry/blocks/calendar/CalendarBlock09.svelte +99 -0
- package/src/registry/blocks/calendar/CalendarBlock10.svelte +88 -0
- package/src/registry/blocks/calendar/CalendarBlock11.svelte +99 -0
- package/src/registry/blocks/calendar/CalendarBlock12.svelte +121 -0
- package/src/registry/blocks/calendar/CalendarBlock13.svelte +92 -0
- package/src/registry/blocks/calendar/CalendarBlock14.svelte +71 -0
- package/src/registry/blocks/calendar/CalendarBlock15.svelte +96 -0
- package/src/registry/blocks/calendar/CalendarBlock16.svelte +98 -0
- package/src/registry/blocks/calendar/CalendarBlock17.svelte +88 -0
- package/src/registry/blocks/calendar/CalendarBlock18.svelte +84 -0
- package/src/registry/blocks/calendar/CalendarBlock19.svelte +105 -0
- package/src/registry/blocks/calendar/CalendarBlock20.svelte +78 -0
- package/src/registry/blocks/calendar/CalendarBlock21.svelte +115 -0
- package/src/registry/blocks/calendar/CalendarBlock22.svelte +136 -0
- package/src/registry/blocks/calendar/CalendarBlock23.svelte +112 -0
- package/src/registry/blocks/calendar/CalendarBlock24.svelte +116 -0
- package/src/registry/blocks/calendar/CalendarBlock25.svelte +144 -0
- package/src/registry/blocks/calendar/CalendarBlock26.svelte +163 -0
- package/src/registry/blocks/calendar/CalendarBlock27.svelte +112 -0
- package/src/registry/blocks/calendar/CalendarBlock28.svelte +109 -0
- package/src/registry/blocks/calendar/CalendarBlock29.svelte +126 -0
- package/src/registry/blocks/calendar/CalendarBlock30.svelte +122 -0
- package/src/registry/blocks/calendar/CalendarBlock31.svelte +161 -0
- package/src/registry/blocks/calendar/CalendarBlock32.svelte +154 -0
- package/src/registry/blocks/calendar/index.ts +32 -0
- package/src/registry/blocks/card/Card01.svelte +69 -0
- package/src/registry/blocks/card/Card02.svelte +50 -0
- package/src/registry/blocks/card/Card03.svelte +60 -0
- package/src/registry/blocks/card/Card04.svelte +89 -0
- package/src/registry/blocks/card/Card05.svelte +51 -0
- package/src/registry/blocks/card/Card06.svelte +77 -0
- package/src/registry/blocks/card/Card07.svelte +35 -0
- package/src/registry/blocks/card/Card08.svelte +36 -0
- package/src/registry/blocks/card/index.ts +8 -0
- package/src/registry/blocks/cart/Cart01.svelte +183 -0
- package/src/registry/blocks/cart/Cart02.svelte +103 -0
- package/src/registry/blocks/cart/Cart03.svelte +38 -0
- package/src/registry/blocks/cart/Cart04.svelte +174 -0
- package/src/registry/blocks/cart/index.ts +4 -0
- package/src/registry/blocks/checkout/Checkout01.svelte +237 -0
- package/src/registry/blocks/checkout/Checkout02.svelte +205 -0
- package/src/registry/blocks/checkout/Checkout03.svelte +189 -0
- package/src/registry/blocks/checkout/Checkout04.svelte +109 -0
- package/src/registry/blocks/checkout/index.ts +4 -0
- package/src/registry/blocks/comparison-section/ComparisonSection01.svelte +116 -0
- package/src/registry/blocks/comparison-section/ComparisonSection02.svelte +98 -0
- package/src/registry/blocks/comparison-section/ComparisonSection03.svelte +93 -0
- package/src/registry/blocks/comparison-section/ComparisonSection04.svelte +98 -0
- package/src/registry/blocks/comparison-section/ComparisonSection05.svelte +119 -0
- package/src/registry/blocks/comparison-section/ComparisonSection06.svelte +154 -0
- package/src/registry/blocks/comparison-section/index.ts +6 -0
- package/src/registry/blocks/contact-section/ContactSection01.svelte +64 -0
- package/src/registry/blocks/contact-section/ContactSection02.svelte +108 -0
- package/src/registry/blocks/contact-section/ContactSection03.svelte +64 -0
- package/src/registry/blocks/contact-section/ContactSection04.svelte +30 -0
- package/src/registry/blocks/contact-section/ContactSection05.svelte +71 -0
- package/src/registry/blocks/contact-section/ContactSection06.svelte +88 -0
- package/src/registry/blocks/contact-section/index.ts +6 -0
- package/src/registry/blocks/cta/CTA01.svelte +44 -0
- package/src/registry/blocks/cta/CTA02.svelte +48 -0
- package/src/registry/blocks/cta/CTA03.svelte +53 -0
- package/src/registry/blocks/cta/CTA04.svelte +60 -0
- package/src/registry/blocks/cta/CTA05.svelte +53 -0
- package/src/registry/blocks/cta/CTA06.svelte +44 -0
- package/src/registry/blocks/cta/CTA07.svelte +39 -0
- package/src/registry/blocks/cta/index.ts +7 -0
- package/src/registry/blocks/dashboard/ChartsBlock01.svelte +275 -0
- package/src/registry/blocks/dashboard/DashboardBlock01.svelte +207 -0
- package/src/registry/blocks/dashboard/DashboardBlock02.svelte +259 -0
- package/src/registry/blocks/dashboard/DashboardBlock03.svelte +315 -0
- package/src/registry/blocks/dashboard/DashboardBlock04.svelte +220 -0
- package/src/registry/blocks/dashboard/DashboardBlock05.svelte +158 -0
- package/src/registry/blocks/dashboard/DashboardBlock06.svelte +173 -0
- package/src/registry/blocks/dashboard/DashboardBlock07.svelte +103 -0
- package/src/registry/blocks/dashboard/index.ts +16 -0
- package/src/registry/blocks/description-list/DescriptionList01.svelte +75 -0
- package/src/registry/blocks/description-list/DescriptionList02.svelte +50 -0
- package/src/registry/blocks/description-list/DescriptionList03.svelte +74 -0
- package/src/registry/blocks/description-list/DescriptionList04.svelte +88 -0
- package/src/registry/blocks/description-list/index.ts +4 -0
- package/src/registry/blocks/empty-lp/EmptyLP01.svelte +46 -0
- package/src/registry/blocks/empty-lp/EmptyLP02.svelte +49 -0
- package/src/registry/blocks/empty-lp/EmptyLP03.svelte +61 -0
- package/src/registry/blocks/empty-lp/EmptyLP04.svelte +37 -0
- package/src/registry/blocks/empty-lp/index.ts +4 -0
- package/src/registry/blocks/empty-section/EmptySection01.svelte +47 -0
- package/src/registry/blocks/empty-section/EmptySection02.svelte +93 -0
- package/src/registry/blocks/empty-section/EmptySection03.svelte +101 -0
- package/src/registry/blocks/empty-section/EmptySection04.svelte +76 -0
- package/src/registry/blocks/empty-section/index.ts +4 -0
- package/src/registry/blocks/faq-section/FaqSection01.svelte +114 -0
- package/src/registry/blocks/faq-section/FaqSection02.svelte +137 -0
- package/src/registry/blocks/faq-section/FaqSection03.svelte +107 -0
- package/src/registry/blocks/faq-section/FaqSection04.svelte +74 -0
- package/src/registry/blocks/faq-section/FaqSection05.svelte +69 -0
- package/src/registry/blocks/faq-section/index.ts +11 -0
- package/src/registry/blocks/feature-section/FeatureSection01.svelte +94 -0
- package/src/registry/blocks/feature-section/FeatureSection02.svelte +61 -0
- package/src/registry/blocks/feature-section/FeatureSection03.svelte +85 -0
- package/src/registry/blocks/feature-section/FeatureSection04.svelte +67 -0
- package/src/registry/blocks/feature-section/FeatureSection05.svelte +61 -0
- package/src/registry/blocks/feature-section/FeatureSection06.svelte +58 -0
- package/src/registry/blocks/feature-section/FeatureSection07.svelte +79 -0
- package/src/registry/blocks/feature-section/FeatureSection08.svelte +92 -0
- package/src/registry/blocks/feature-section/FeatureSection09.svelte +58 -0
- package/src/registry/blocks/feature-section/FeatureSection10.svelte +87 -0
- package/src/registry/blocks/feature-section/FeatureSection11.svelte +118 -0
- package/src/registry/blocks/feature-section/FeatureSection12.svelte +76 -0
- package/src/registry/blocks/feature-section/FeatureSection13.svelte +88 -0
- package/src/registry/blocks/feature-section/FeatureSection14.svelte +119 -0
- package/src/registry/blocks/feature-section/FeatureSection15.svelte +122 -0
- package/src/registry/blocks/feature-section/FeatureSection16.svelte +113 -0
- package/src/registry/blocks/feature-section/FeatureSection17.svelte +93 -0
- package/src/registry/blocks/feature-section/FeatureSection18.svelte +97 -0
- package/src/registry/blocks/feature-section/FeatureSection19.svelte +74 -0
- package/src/registry/blocks/feature-section/FeatureSection20.svelte +69 -0
- package/src/registry/blocks/feature-section/index.ts +20 -0
- package/src/registry/blocks/footer/Footer01.svelte +62 -0
- package/src/registry/blocks/footer/Footer02.svelte +67 -0
- package/src/registry/blocks/footer/Footer03.svelte +87 -0
- package/src/registry/blocks/footer/Footer04.svelte +67 -0
- package/src/registry/blocks/footer/Footer05.svelte +20 -0
- package/src/registry/blocks/footer/Footer06.svelte +107 -0
- package/src/registry/blocks/footer/Footer07.svelte +88 -0
- package/src/registry/blocks/footer/Footer08.svelte +84 -0
- package/src/registry/blocks/footer/Footer09.svelte +65 -0
- package/src/registry/blocks/footer/index.ts +19 -0
- package/src/registry/blocks/forms/SettingsBlock.svelte +329 -0
- package/src/registry/blocks/forms/index.ts +1 -0
- package/src/registry/blocks/gallery-section/GallerySection01.svelte +43 -0
- package/src/registry/blocks/gallery-section/GallerySection02.svelte +45 -0
- package/src/registry/blocks/gallery-section/GallerySection03.svelte +43 -0
- package/src/registry/blocks/gallery-section/GallerySection04.svelte +49 -0
- package/src/registry/blocks/gallery-section/GallerySection05.svelte +45 -0
- package/src/registry/blocks/gallery-section/GallerySection06.svelte +49 -0
- package/src/registry/blocks/gallery-section/GallerySection07.svelte +48 -0
- package/src/registry/blocks/gallery-section/GallerySection08.svelte +43 -0
- package/src/registry/blocks/gallery-section/GallerySection09.svelte +55 -0
- package/src/registry/blocks/gallery-section/GallerySection10.svelte +43 -0
- package/src/registry/blocks/gallery-section/GallerySection11.svelte +75 -0
- package/src/registry/blocks/gallery-section/GallerySection12.svelte +76 -0
- package/src/registry/blocks/gallery-section/index.ts +12 -0
- package/src/registry/blocks/header-section/HeaderSection01.svelte +53 -0
- package/src/registry/blocks/header-section/HeaderSection02.svelte +53 -0
- package/src/registry/blocks/header-section/HeaderSection03.svelte +61 -0
- package/src/registry/blocks/header-section/HeaderSection04.svelte +63 -0
- package/src/registry/blocks/header-section/HeaderSection05.svelte +53 -0
- package/src/registry/blocks/header-section/HeaderSection06.svelte +70 -0
- package/src/registry/blocks/header-section/HeaderSection07.svelte +97 -0
- package/src/registry/blocks/header-section/HeaderSection08.svelte +61 -0
- package/src/registry/blocks/header-section/HeaderSection09.svelte +53 -0
- package/src/registry/blocks/header-section/HeaderSection10.svelte +63 -0
- package/src/registry/blocks/header-section/HeaderSection11.svelte +68 -0
- package/src/registry/blocks/header-section/HeaderSection12.svelte +60 -0
- package/src/registry/blocks/header-section/HeaderSection13.svelte +92 -0
- package/src/registry/blocks/header-section/HeaderSection14.svelte +77 -0
- package/src/registry/blocks/header-section/HeaderSection15.svelte +49 -0
- package/src/registry/blocks/header-section/HeaderSection16.svelte +74 -0
- package/src/registry/blocks/header-section/HeaderSection17.svelte +58 -0
- package/src/registry/blocks/header-section/HeaderSection18.svelte +66 -0
- package/src/registry/blocks/header-section/HeaderSection19.svelte +47 -0
- package/src/registry/blocks/header-section/HeaderSection20.svelte +53 -0
- package/src/registry/blocks/header-section/index.ts +20 -0
- package/src/registry/blocks/hero-section/HeroSection01.svelte +69 -0
- package/src/registry/blocks/hero-section/HeroSection02.svelte +47 -0
- package/src/registry/blocks/hero-section/HeroSection03.svelte +56 -0
- package/src/registry/blocks/hero-section/HeroSection04.svelte +69 -0
- package/src/registry/blocks/hero-section/HeroSection05.svelte +73 -0
- package/src/registry/blocks/hero-section/HeroSection06.svelte +78 -0
- package/src/registry/blocks/hero-section/HeroSection07.svelte +48 -0
- package/src/registry/blocks/hero-section/HeroSection08.svelte +73 -0
- package/src/registry/blocks/hero-section/HeroSection09.svelte +51 -0
- package/src/registry/blocks/hero-section/HeroSection10.svelte +47 -0
- package/src/registry/blocks/hero-section/HeroSection11.svelte +60 -0
- package/src/registry/blocks/hero-section/HeroSection12.svelte +74 -0
- package/src/registry/blocks/hero-section/HeroSection13.svelte +86 -0
- package/src/registry/blocks/hero-section/HeroSection14.svelte +116 -0
- package/src/registry/blocks/hero-section/HeroSection15.svelte +75 -0
- package/src/registry/blocks/hero-section/HeroSection16.svelte +92 -0
- package/src/registry/blocks/hero-section/HeroSection17.svelte +78 -0
- package/src/registry/blocks/hero-section/HeroSection18.svelte +82 -0
- package/src/registry/blocks/hero-section/HeroSection19.svelte +72 -0
- package/src/registry/blocks/hero-section/HeroSection20.svelte +79 -0
- package/src/registry/blocks/hero-section/HeroSection21.svelte +75 -0
- package/src/registry/blocks/hero-section/HeroSection22.svelte +103 -0
- package/src/registry/blocks/hero-section/index.ts +22 -0
- package/src/registry/blocks/logo-section/LogoSection01.svelte +54 -0
- package/src/registry/blocks/logo-section/LogoSection02.svelte +56 -0
- package/src/registry/blocks/logo-section/LogoSection03.svelte +58 -0
- package/src/registry/blocks/logo-section/LogoSection04.svelte +58 -0
- package/src/registry/blocks/logo-section/LogoSection05.svelte +43 -0
- package/src/registry/blocks/logo-section/LogoSection06.svelte +43 -0
- package/src/registry/blocks/logo-section/LogoSection07.svelte +56 -0
- package/src/registry/blocks/logo-section/index.ts +7 -0
- package/src/registry/blocks/lp-navbar/LPNavbar01.svelte +94 -0
- package/src/registry/blocks/lp-navbar/LPNavbar02.svelte +96 -0
- package/src/registry/blocks/lp-navbar/LPNavbar03.svelte +97 -0
- package/src/registry/blocks/lp-navbar/LPNavbar04.svelte +103 -0
- package/src/registry/blocks/lp-navbar/LPNavbar05.svelte +173 -0
- package/src/registry/blocks/lp-navbar/LPNavbar06.svelte +200 -0
- package/src/registry/blocks/lp-navbar/LPNavbar07.svelte +202 -0
- package/src/registry/blocks/lp-navbar/index.ts +7 -0
- package/src/registry/blocks/mail/MailBlock.svelte +321 -0
- package/src/registry/blocks/mail/index.ts +2 -0
- package/src/registry/blocks/music/MusicBlock.svelte +239 -0
- package/src/registry/blocks/music/index.ts +1 -0
- package/src/registry/blocks/navbar/Navbar01.svelte +234 -0
- package/src/registry/blocks/navbar/Navbar02.svelte +111 -0
- package/src/registry/blocks/navbar/Navbar03.svelte +88 -0
- package/src/registry/blocks/navbar/index.ts +3 -0
- package/src/registry/blocks/not-found/NotFound01.svelte +29 -0
- package/src/registry/blocks/not-found/NotFound02.svelte +28 -0
- package/src/registry/blocks/not-found/NotFound03.svelte +25 -0
- package/src/registry/blocks/not-found/index.ts +3 -0
- package/src/registry/blocks/order-history/OrderHistory01.svelte +208 -0
- package/src/registry/blocks/order-history/OrderHistory02.svelte +131 -0
- package/src/registry/blocks/order-history/OrderHistory03.svelte +133 -0
- package/src/registry/blocks/order-history/index.ts +3 -0
- package/src/registry/blocks/page-header/PageHeader01.svelte +39 -0
- package/src/registry/blocks/page-header/PageHeader02.svelte +58 -0
- package/src/registry/blocks/page-header/PageHeader03.svelte +64 -0
- package/src/registry/blocks/page-header/PageHeader04.svelte +49 -0
- package/src/registry/blocks/page-header/PageHeader05.svelte +49 -0
- package/src/registry/blocks/page-header/PageHeader06.svelte +58 -0
- package/src/registry/blocks/page-header/PageHeader07.svelte +64 -0
- package/src/registry/blocks/page-header/PageHeader08.svelte +68 -0
- package/src/registry/blocks/page-header/index.ts +8 -0
- package/src/registry/blocks/playground/PlaygroundBlock01.svelte +162 -0
- package/src/registry/blocks/playground/PlaygroundBlock02.svelte +156 -0
- package/src/registry/blocks/playground/index.ts +2 -0
- package/src/registry/blocks/pricing-section/PricingSection01.svelte +109 -0
- package/src/registry/blocks/pricing-section/PricingSection02.svelte +145 -0
- package/src/registry/blocks/pricing-section/PricingSection03.svelte +94 -0
- package/src/registry/blocks/pricing-section/PricingSection04.svelte +103 -0
- package/src/registry/blocks/pricing-section/PricingSection05.svelte +128 -0
- package/src/registry/blocks/pricing-section/index.ts +20 -0
- package/src/registry/blocks/product-card/ProductCard01.svelte +74 -0
- package/src/registry/blocks/product-card/ProductCard02.svelte +108 -0
- package/src/registry/blocks/product-card/ProductCard03.svelte +80 -0
- package/src/registry/blocks/product-card/ProductCard04.svelte +50 -0
- package/src/registry/blocks/product-card/ProductCard05.svelte +107 -0
- package/src/registry/blocks/product-card/index.ts +5 -0
- package/src/registry/blocks/product-detail/ProductDetail01.svelte +174 -0
- package/src/registry/blocks/product-detail/ProductDetail02.svelte +170 -0
- package/src/registry/blocks/product-detail/ProductDetail03.svelte +159 -0
- package/src/registry/blocks/product-detail/ProductDetail04.svelte +106 -0
- package/src/registry/blocks/product-detail/ProductDetail05.svelte +181 -0
- package/src/registry/blocks/product-detail/index.ts +5 -0
- package/src/registry/blocks/product-listing/ProductListing01.svelte +194 -0
- package/src/registry/blocks/product-listing/ProductListing02.svelte +163 -0
- package/src/registry/blocks/product-listing/ProductListing03.svelte +173 -0
- package/src/registry/blocks/product-listing/ProductListing04.svelte +179 -0
- package/src/registry/blocks/product-listing/ProductListing05.svelte +126 -0
- package/src/registry/blocks/product-listing/index.ts +5 -0
- package/src/registry/blocks/product-reviews/ProductReviews01.svelte +156 -0
- package/src/registry/blocks/product-reviews/ProductReviews02.svelte +139 -0
- package/src/registry/blocks/product-reviews/ProductReviews03.svelte +137 -0
- package/src/registry/blocks/product-reviews/ProductReviews04.svelte +129 -0
- package/src/registry/blocks/product-reviews/index.ts +4 -0
- package/src/registry/blocks/promo-section/PromoSection01.svelte +72 -0
- package/src/registry/blocks/promo-section/PromoSection02.svelte +61 -0
- package/src/registry/blocks/promo-section/PromoSection03.svelte +110 -0
- package/src/registry/blocks/promo-section/PromoSection04.svelte +103 -0
- package/src/registry/blocks/promo-section/index.ts +4 -0
- package/src/registry/blocks/rich-text/RichText01.svelte +30 -0
- package/src/registry/blocks/rich-text/RichText02.svelte +72 -0
- package/src/registry/blocks/rich-text/RichText03.svelte +52 -0
- package/src/registry/blocks/rich-text/RichText04.svelte +44 -0
- package/src/registry/blocks/rich-text/RichText05.svelte +56 -0
- package/src/registry/blocks/rich-text/index.ts +5 -0
- package/src/registry/blocks/section/Section01.svelte +38 -0
- package/src/registry/blocks/section/Section02.svelte +90 -0
- package/src/registry/blocks/section/Section03.svelte +95 -0
- package/src/registry/blocks/section/Section04.svelte +117 -0
- package/src/registry/blocks/section/index.ts +4 -0
- package/src/registry/blocks/section-footer/SectionFooter01.svelte +39 -0
- package/src/registry/blocks/section-footer/SectionFooter02.svelte +33 -0
- package/src/registry/blocks/section-footer/SectionFooter03.svelte +33 -0
- package/src/registry/blocks/section-footer/SectionFooter04.svelte +34 -0
- package/src/registry/blocks/section-footer/SectionFooter05.svelte +69 -0
- package/src/registry/blocks/section-footer/index.ts +5 -0
- package/src/registry/blocks/section-header/SectionHeader01.svelte +39 -0
- package/src/registry/blocks/section-header/SectionHeader02.svelte +58 -0
- package/src/registry/blocks/section-header/SectionHeader03.svelte +88 -0
- package/src/registry/blocks/section-header/SectionHeader04.svelte +45 -0
- package/src/registry/blocks/section-header/SectionHeader05.svelte +64 -0
- package/src/registry/blocks/section-header/index.ts +5 -0
- package/src/registry/blocks/settings/Settings01.svelte +202 -0
- package/src/registry/blocks/settings/Settings02.svelte +201 -0
- package/src/registry/blocks/settings/Settings03.svelte +156 -0
- package/src/registry/blocks/settings/Settings04.svelte +175 -0
- package/src/registry/blocks/settings/Settings05.svelte +248 -0
- package/src/registry/blocks/settings/Settings06.svelte +120 -0
- package/src/registry/blocks/settings/Settings07.svelte +136 -0
- package/src/registry/blocks/settings/index.ts +7 -0
- package/src/registry/blocks/sidebar/SidebarLayout01.svelte +108 -0
- package/src/registry/blocks/sidebar/SidebarLayout02.svelte +75 -0
- package/src/registry/blocks/sidebar/SidebarLayout03.svelte +108 -0
- package/src/registry/blocks/sidebar/SidebarLayout04.svelte +111 -0
- package/src/registry/blocks/sidebar/SidebarLayout05.svelte +103 -0
- package/src/registry/blocks/sidebar/SidebarLayout06.svelte +122 -0
- package/src/registry/blocks/sidebar/SidebarLayout07.svelte +183 -0
- package/src/registry/blocks/sidebar/SidebarLayout08.svelte +162 -0
- package/src/registry/blocks/sidebar/SidebarLayout09.svelte +167 -0
- package/src/registry/blocks/sidebar/SidebarLayout10.svelte +159 -0
- package/src/registry/blocks/sidebar/SidebarLayout11.svelte +135 -0
- package/src/registry/blocks/sidebar/SidebarLayout12.svelte +159 -0
- package/src/registry/blocks/sidebar/SidebarLayout13.svelte +103 -0
- package/src/registry/blocks/sidebar/SidebarLayout14.svelte +87 -0
- package/src/registry/blocks/sidebar/SidebarLayout15.svelte +228 -0
- package/src/registry/blocks/sidebar/index.ts +15 -0
- package/src/registry/blocks/sign-in/SignIn01.svelte +140 -0
- package/src/registry/blocks/sign-in/SignIn02.svelte +155 -0
- package/src/registry/blocks/sign-in/SignIn03.svelte +214 -0
- package/src/registry/blocks/sign-in/SignIn04.svelte +163 -0
- package/src/registry/blocks/sign-in/SignIn05.svelte +209 -0
- package/src/registry/blocks/sign-in/SignIn06.svelte +233 -0
- package/src/registry/blocks/sign-in/SignIn07.svelte +268 -0
- package/src/registry/blocks/sign-in/SignIn08.svelte +125 -0
- package/src/registry/blocks/sign-in/SignIn09.svelte +93 -0
- package/src/registry/blocks/sign-in/SignIn10.svelte +74 -0
- package/src/registry/blocks/sign-in/index.ts +10 -0
- package/src/registry/blocks/sign-up/SignUp01.svelte +124 -0
- package/src/registry/blocks/sign-up/SignUp02.svelte +110 -0
- package/src/registry/blocks/sign-up/SignUp03.svelte +182 -0
- package/src/registry/blocks/sign-up/SignUp04.svelte +126 -0
- package/src/registry/blocks/sign-up/SignUp05.svelte +182 -0
- package/src/registry/blocks/sign-up/SignUp06.svelte +221 -0
- package/src/registry/blocks/sign-up/SignUp07.svelte +98 -0
- package/src/registry/blocks/sign-up/index.ts +7 -0
- package/src/registry/blocks/stats-section/StatsSection01.svelte +66 -0
- package/src/registry/blocks/stats-section/StatsSection02.svelte +60 -0
- package/src/registry/blocks/stats-section/StatsSection03.svelte +66 -0
- package/src/registry/blocks/stats-section/StatsSection04.svelte +66 -0
- package/src/registry/blocks/stats-section/StatsSection05.svelte +60 -0
- package/src/registry/blocks/stats-section/StatsSection06.svelte +48 -0
- package/src/registry/blocks/stats-section/StatsSection07.svelte +66 -0
- package/src/registry/blocks/stats-section/index.ts +7 -0
- package/src/registry/blocks/store-navbar/StoreNavbar01.svelte +101 -0
- package/src/registry/blocks/store-navbar/StoreNavbar02.svelte +65 -0
- package/src/registry/blocks/store-navbar/StoreNavbar03.svelte +83 -0
- package/src/registry/blocks/store-navbar/StoreNavbar04.svelte +110 -0
- package/src/registry/blocks/store-navbar/StoreNavbar05.svelte +80 -0
- package/src/registry/blocks/store-navbar/index.ts +5 -0
- package/src/registry/blocks/table-header/TableHeader01.svelte +96 -0
- package/src/registry/blocks/table-header/TableHeader02.svelte +86 -0
- package/src/registry/blocks/table-header/TableHeader03.svelte +99 -0
- package/src/registry/blocks/table-header/TableHeader04.svelte +107 -0
- package/src/registry/blocks/table-header/index.ts +4 -0
- package/src/registry/blocks/tasks/TasksBlock.svelte +286 -0
- package/src/registry/blocks/tasks/index.ts +1 -0
- package/src/registry/blocks/team-section/TeamSection01.svelte +80 -0
- package/src/registry/blocks/team-section/TeamSection02.svelte +102 -0
- package/src/registry/blocks/team-section/TeamSection03.svelte +76 -0
- package/src/registry/blocks/team-section/TeamSection04.svelte +106 -0
- package/src/registry/blocks/team-section/index.ts +13 -0
- package/src/registry/blocks/testimonials/Testimonial01.svelte +74 -0
- package/src/registry/blocks/testimonials/Testimonial02.svelte +74 -0
- package/src/registry/blocks/testimonials/Testimonial03.svelte +79 -0
- package/src/registry/blocks/testimonials/Testimonial04.svelte +113 -0
- package/src/registry/blocks/testimonials/Testimonial05.svelte +74 -0
- package/src/registry/blocks/testimonials/Testimonial06.svelte +114 -0
- package/src/registry/blocks/testimonials/Testimonial07.svelte +131 -0
- package/src/registry/blocks/testimonials/Testimonials01.svelte +60 -0
- package/src/registry/blocks/testimonials/Testimonials02.svelte +61 -0
- package/src/registry/blocks/testimonials/Testimonials03.svelte +79 -0
- package/src/registry/blocks/testimonials/Testimonials04.svelte +74 -0
- package/src/registry/blocks/testimonials/Testimonials05.svelte +68 -0
- package/src/registry/blocks/testimonials/Testimonials06.svelte +82 -0
- package/src/registry/blocks/testimonials/Testimonials07.svelte +98 -0
- package/src/registry/blocks/testimonials/index.ts +16 -0
- package/src/registry/templates/cn.ts +42 -0
- package/src/index.ts +0 -2
- package/tsconfig.json +0 -20
- /package/src/{generate-component.cjs → commands/generate-component.cjs} +0 -0
- /package/src/{generate-route.cjs → commands/generate-route.cjs} +0 -0
- /package/src/{generate-service.cjs → commands/generate-service.cjs} +0 -0
- /package/src/{manage-auth-users.cjs → commands/manage-auth-users.cjs} +0 -0
- /package/src/{setup.cjs → commands/setup.cjs} +0 -0
- /package/src/{validate-setup.cjs → commands/validate.cjs} +0 -0
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
CalendarBlock03.svelte
|
|
3
|
+
Date range picker with dual month view and range highlighting.
|
|
4
|
+
-->
|
|
5
|
+
<script lang="ts">
|
|
6
|
+
import { cn } from '$lib/utils/cn';
|
|
7
|
+
import { Button } from '$lib/components/ui';
|
|
8
|
+
|
|
9
|
+
let {
|
|
10
|
+
class: className = '',
|
|
11
|
+
startDate = null,
|
|
12
|
+
endDate = null
|
|
13
|
+
}: {
|
|
14
|
+
class?: string;
|
|
15
|
+
startDate?: Date | null;
|
|
16
|
+
endDate?: Date | null;
|
|
17
|
+
} = $props();
|
|
18
|
+
|
|
19
|
+
let viewYear = $state(startDate ? startDate.getFullYear() : new Date().getFullYear());
|
|
20
|
+
let viewMonth = $state(startDate ? startDate.getMonth() : new Date().getMonth());
|
|
21
|
+
|
|
22
|
+
/** Track whether next click sets start or end */
|
|
23
|
+
let selectingEnd = $state(false);
|
|
24
|
+
|
|
25
|
+
const DAYS = ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'];
|
|
26
|
+
const MONTHS = [
|
|
27
|
+
'January', 'February', 'March', 'April', 'May', 'June',
|
|
28
|
+
'July', 'August', 'September', 'October', 'November', 'December'
|
|
29
|
+
];
|
|
30
|
+
|
|
31
|
+
function getDaysInMonth(y: number, m: number): number {
|
|
32
|
+
return new Date(y, m + 1, 0).getDate();
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function getFirstDayOfMonth(y: number, m: number): number {
|
|
36
|
+
return new Date(y, m, 1).getDay();
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function getCalendarDays(y: number, m: number): Array<{ day: number; current: boolean }> {
|
|
40
|
+
const daysInMonth = getDaysInMonth(y, m);
|
|
41
|
+
const firstDay = getFirstDayOfMonth(y, m);
|
|
42
|
+
const daysInPrevMonth = getDaysInMonth(y, m - 1);
|
|
43
|
+
const days: Array<{ day: number; current: boolean }> = [];
|
|
44
|
+
|
|
45
|
+
for (let i = firstDay - 1; i >= 0; i--) {
|
|
46
|
+
days.push({ day: daysInPrevMonth - i, current: false });
|
|
47
|
+
}
|
|
48
|
+
for (let i = 1; i <= daysInMonth; i++) {
|
|
49
|
+
days.push({ day: i, current: true });
|
|
50
|
+
}
|
|
51
|
+
const remaining = 42 - days.length;
|
|
52
|
+
for (let i = 1; i <= remaining; i++) {
|
|
53
|
+
days.push({ day: i, current: false });
|
|
54
|
+
}
|
|
55
|
+
return days;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function dateEquals(a: Date | null, y: number, m: number, d: number): boolean {
|
|
59
|
+
if (!a) return false;
|
|
60
|
+
return a.getFullYear() === y && a.getMonth() === m && a.getDate() === d;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function isInRange(y: number, m: number, d: number): boolean {
|
|
64
|
+
if (!startDate || !endDate) return false;
|
|
65
|
+
const date = new Date(y, m, d);
|
|
66
|
+
return date > startDate && date < endDate;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function isRangeStart(y: number, m: number, d: number): boolean {
|
|
70
|
+
return dateEquals(startDate, y, m, d);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function isRangeEnd(y: number, m: number, d: number): boolean {
|
|
74
|
+
return dateEquals(endDate, y, m, d);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function selectDay(y: number, m: number, d: number) {
|
|
78
|
+
const date = new Date(y, m, d);
|
|
79
|
+
if (!selectingEnd) {
|
|
80
|
+
startDate = date;
|
|
81
|
+
endDate = null;
|
|
82
|
+
selectingEnd = true;
|
|
83
|
+
} else {
|
|
84
|
+
if (date < startDate!) {
|
|
85
|
+
startDate = date;
|
|
86
|
+
endDate = null;
|
|
87
|
+
} else {
|
|
88
|
+
endDate = date;
|
|
89
|
+
selectingEnd = false;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function prevMonth() {
|
|
95
|
+
if (viewMonth === 0) { viewMonth = 11; viewYear--; }
|
|
96
|
+
else { viewMonth--; }
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function nextMonth() {
|
|
100
|
+
if (viewMonth === 11) { viewMonth = 0; viewYear++; }
|
|
101
|
+
else { viewMonth++; }
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
let secondMonth = $derived(viewMonth === 11 ? 0 : viewMonth + 1);
|
|
105
|
+
let secondYear = $derived(viewMonth === 11 ? viewYear + 1 : viewYear);
|
|
106
|
+
let leftDays = $derived(getCalendarDays(viewYear, viewMonth));
|
|
107
|
+
let rightDays = $derived(getCalendarDays(secondYear, secondMonth));
|
|
108
|
+
</script>
|
|
109
|
+
|
|
110
|
+
<div class={cn('inline-flex flex-col', className)}>
|
|
111
|
+
<!-- Navigation -->
|
|
112
|
+
<div class="mb-4 flex items-center justify-between">
|
|
113
|
+
<Button variant="outline" size="sm" onclick={prevMonth}>
|
|
114
|
+
<
|
|
115
|
+
</Button>
|
|
116
|
+
<span class="text-sm font-medium">
|
|
117
|
+
{MONTHS[viewMonth]} {viewYear} - {MONTHS[secondMonth]} {secondYear}
|
|
118
|
+
</span>
|
|
119
|
+
<Button variant="outline" size="sm" onclick={nextMonth}>
|
|
120
|
+
>
|
|
121
|
+
</Button>
|
|
122
|
+
</div>
|
|
123
|
+
|
|
124
|
+
<!-- Range display -->
|
|
125
|
+
{#if startDate || endDate}
|
|
126
|
+
<div class="mb-3 flex items-center gap-2 text-sm text-muted-foreground">
|
|
127
|
+
<span>{startDate ? startDate.toLocaleDateString() : '...'}</span>
|
|
128
|
+
<span>-</span>
|
|
129
|
+
<span>{endDate ? endDate.toLocaleDateString() : '...'}</span>
|
|
130
|
+
</div>
|
|
131
|
+
{/if}
|
|
132
|
+
|
|
133
|
+
<div class="flex gap-8">
|
|
134
|
+
<!-- Left Month -->
|
|
135
|
+
<div>
|
|
136
|
+
<h3 class="mb-2 text-center text-sm font-medium">{MONTHS[viewMonth]} {viewYear}</h3>
|
|
137
|
+
<div class="grid grid-cols-7 gap-0">
|
|
138
|
+
{#each DAYS as day}
|
|
139
|
+
<div class="flex h-8 w-8 items-center justify-center text-xs font-medium text-muted-foreground">
|
|
140
|
+
{day}
|
|
141
|
+
</div>
|
|
142
|
+
{/each}
|
|
143
|
+
{#each leftDays as { day, current }}
|
|
144
|
+
<button
|
|
145
|
+
type="button"
|
|
146
|
+
class={cn(
|
|
147
|
+
'flex h-8 w-8 items-center justify-center text-sm transition-colors',
|
|
148
|
+
!current && 'text-muted-foreground/40',
|
|
149
|
+
current && 'hover:bg-muted',
|
|
150
|
+
current && isInRange(viewYear, viewMonth, day) && 'bg-accent',
|
|
151
|
+
current && isRangeStart(viewYear, viewMonth, day) && 'rounded-l-full bg-primary text-primary-foreground hover:bg-primary',
|
|
152
|
+
current && isRangeEnd(viewYear, viewMonth, day) && 'rounded-r-full bg-primary text-primary-foreground hover:bg-primary',
|
|
153
|
+
current && !isRangeStart(viewYear, viewMonth, day) && !isRangeEnd(viewYear, viewMonth, day) && !isInRange(viewYear, viewMonth, day) && 'rounded-full'
|
|
154
|
+
)}
|
|
155
|
+
onclick={() => current && selectDay(viewYear, viewMonth, day)}
|
|
156
|
+
disabled={!current}
|
|
157
|
+
>
|
|
158
|
+
{day}
|
|
159
|
+
</button>
|
|
160
|
+
{/each}
|
|
161
|
+
</div>
|
|
162
|
+
</div>
|
|
163
|
+
|
|
164
|
+
<!-- Right Month -->
|
|
165
|
+
<div>
|
|
166
|
+
<h3 class="mb-2 text-center text-sm font-medium">{MONTHS[secondMonth]} {secondYear}</h3>
|
|
167
|
+
<div class="grid grid-cols-7 gap-0">
|
|
168
|
+
{#each DAYS as day}
|
|
169
|
+
<div class="flex h-8 w-8 items-center justify-center text-xs font-medium text-muted-foreground">
|
|
170
|
+
{day}
|
|
171
|
+
</div>
|
|
172
|
+
{/each}
|
|
173
|
+
{#each rightDays as { day, current }}
|
|
174
|
+
<button
|
|
175
|
+
type="button"
|
|
176
|
+
class={cn(
|
|
177
|
+
'flex h-8 w-8 items-center justify-center text-sm transition-colors',
|
|
178
|
+
!current && 'text-muted-foreground/40',
|
|
179
|
+
current && 'hover:bg-muted',
|
|
180
|
+
current && isInRange(secondYear, secondMonth, day) && 'bg-accent',
|
|
181
|
+
current && isRangeStart(secondYear, secondMonth, day) && 'rounded-l-full bg-primary text-primary-foreground hover:bg-primary',
|
|
182
|
+
current && isRangeEnd(secondYear, secondMonth, day) && 'rounded-r-full bg-primary text-primary-foreground hover:bg-primary',
|
|
183
|
+
current && !isRangeStart(secondYear, secondMonth, day) && !isRangeEnd(secondYear, secondMonth, day) && !isInRange(secondYear, secondMonth, day) && 'rounded-full'
|
|
184
|
+
)}
|
|
185
|
+
onclick={() => current && selectDay(secondYear, secondMonth, day)}
|
|
186
|
+
disabled={!current}
|
|
187
|
+
>
|
|
188
|
+
{day}
|
|
189
|
+
</button>
|
|
190
|
+
{/each}
|
|
191
|
+
</div>
|
|
192
|
+
</div>
|
|
193
|
+
</div>
|
|
194
|
+
</div>
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
CalendarBlock04.svelte
|
|
3
|
+
Single month with continuous date-range row highlight (start–end dates).
|
|
4
|
+
-->
|
|
5
|
+
<script lang="ts">
|
|
6
|
+
import { cn } from '$lib/utils/cn';
|
|
7
|
+
import { Button } from '$lib/components/ui';
|
|
8
|
+
|
|
9
|
+
let {
|
|
10
|
+
class: className = '',
|
|
11
|
+
startDate = null,
|
|
12
|
+
endDate = null,
|
|
13
|
+
month = new Date().getMonth(),
|
|
14
|
+
year = new Date().getFullYear()
|
|
15
|
+
}: {
|
|
16
|
+
class?: string;
|
|
17
|
+
startDate?: Date | null;
|
|
18
|
+
endDate?: Date | null;
|
|
19
|
+
month?: number;
|
|
20
|
+
year?: number;
|
|
21
|
+
} = $props();
|
|
22
|
+
|
|
23
|
+
const DAYS = ['Su','Mo','Tu','We','Th','Fr','Sa'];
|
|
24
|
+
const MONTHS = ['January','February','March','April','May','June','July','August','September','October','November','December'];
|
|
25
|
+
|
|
26
|
+
function getDim(y: number, m: number) { return new Date(y, m + 1, 0).getDate(); }
|
|
27
|
+
function getCalDays(y: number, m: number) {
|
|
28
|
+
const dim = getDim(y, m), fd = new Date(y, m, 1).getDay(), prev = getDim(y, m - 1);
|
|
29
|
+
const days: Array<{ day: number; cur: boolean }> = [];
|
|
30
|
+
for (let i = fd - 1; i >= 0; i--) days.push({ day: prev - i, cur: false });
|
|
31
|
+
for (let i = 1; i <= dim; i++) days.push({ day: i, cur: true });
|
|
32
|
+
while (days.length < 42) days.push({ day: days.length - dim - fd + 2, cur: false });
|
|
33
|
+
return days;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function toNum(d: Date | null) { return d ? d.getFullYear() * 10000 + d.getMonth() * 100 + d.getDate() : null; }
|
|
37
|
+
function dayNum(d: number) { return year * 10000 + month * 100 + d; }
|
|
38
|
+
|
|
39
|
+
function inRange(d: number): boolean {
|
|
40
|
+
const n = dayNum(d), s = toNum(startDate), e = toNum(endDate);
|
|
41
|
+
if (!s || !e) return false;
|
|
42
|
+
const [lo, hi] = s <= e ? [s, e] : [e, s];
|
|
43
|
+
return n >= lo && n <= hi;
|
|
44
|
+
}
|
|
45
|
+
function isStart(d: number): boolean {
|
|
46
|
+
const n = dayNum(d), s = toNum(startDate), e = toNum(endDate);
|
|
47
|
+
if (!s) return false;
|
|
48
|
+
return n === (s <= (e ?? s) ? s : e!);
|
|
49
|
+
}
|
|
50
|
+
function isEnd(d: number): boolean {
|
|
51
|
+
const n = dayNum(d), s = toNum(startDate), e = toNum(endDate);
|
|
52
|
+
if (!e) return false;
|
|
53
|
+
return n === (s <= e ? e : s);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function handleClick(d: number) {
|
|
57
|
+
const clicked = new Date(year, month, d);
|
|
58
|
+
if (!startDate || (startDate && endDate)) {
|
|
59
|
+
startDate = clicked; endDate = null;
|
|
60
|
+
} else {
|
|
61
|
+
endDate = clicked;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function prev() { if (month === 0) { month = 11; year--; } else month--; }
|
|
66
|
+
function next() { if (month === 11) { month = 0; year++; } else month++; }
|
|
67
|
+
|
|
68
|
+
let calDays = $derived(getCalDays(year, month));
|
|
69
|
+
</script>
|
|
70
|
+
|
|
71
|
+
<div class={cn('inline-flex flex-col rounded-md border p-4', className)}>
|
|
72
|
+
<div class="mb-4 flex items-center justify-between">
|
|
73
|
+
<Button variant="ghost" size="sm" onclick={prev}><</Button>
|
|
74
|
+
<h3 class="text-sm font-medium">{MONTHS[month]} {year}</h3>
|
|
75
|
+
<Button variant="ghost" size="sm" onclick={next}>></Button>
|
|
76
|
+
</div>
|
|
77
|
+
<div class="grid grid-cols-7">
|
|
78
|
+
{#each DAYS as d}
|
|
79
|
+
<div class="flex h-8 w-8 items-center justify-center text-xs font-medium text-muted-foreground">{d}</div>
|
|
80
|
+
{/each}
|
|
81
|
+
{#each calDays as { day, cur }}
|
|
82
|
+
<button
|
|
83
|
+
type="button"
|
|
84
|
+
class={cn(
|
|
85
|
+
'flex h-8 w-8 items-center justify-center text-sm transition-colors',
|
|
86
|
+
!cur && 'text-muted-foreground/40 pointer-events-none',
|
|
87
|
+
cur && inRange(day) && 'bg-muted',
|
|
88
|
+
cur && (isStart(day) || isEnd(day)) && 'rounded-full bg-primary text-primary-foreground',
|
|
89
|
+
cur && !inRange(day) && 'rounded-full hover:bg-muted'
|
|
90
|
+
)}
|
|
91
|
+
onclick={() => cur && handleClick(day)}
|
|
92
|
+
disabled={!cur}
|
|
93
|
+
>{day}</button>
|
|
94
|
+
{/each}
|
|
95
|
+
</div>
|
|
96
|
+
</div>
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
CalendarBlock05.svelte
|
|
3
|
+
Dual-month range picker with full-row range background highlight.
|
|
4
|
+
-->
|
|
5
|
+
<script lang="ts">
|
|
6
|
+
import { cn } from '$lib/utils/cn';
|
|
7
|
+
import { Button } from '$lib/components/ui';
|
|
8
|
+
|
|
9
|
+
let {
|
|
10
|
+
class: className = '',
|
|
11
|
+
startDate = null,
|
|
12
|
+
endDate = null
|
|
13
|
+
}: {
|
|
14
|
+
class?: string;
|
|
15
|
+
startDate?: Date | null;
|
|
16
|
+
endDate?: Date | null;
|
|
17
|
+
} = $props();
|
|
18
|
+
|
|
19
|
+
const today = new Date();
|
|
20
|
+
let viewYear = $state(today.getFullYear());
|
|
21
|
+
let viewMonth = $state(today.getMonth());
|
|
22
|
+
|
|
23
|
+
const DAYS = ['Su','Mo','Tu','We','Th','Fr','Sa'];
|
|
24
|
+
const MONTHS = ['January','February','March','April','May','June','July','August','September','October','November','December'];
|
|
25
|
+
|
|
26
|
+
function getDim(y: number, m: number) { return new Date(y, m + 1, 0).getDate(); }
|
|
27
|
+
function getCalDays(y: number, m: number) {
|
|
28
|
+
const dim = getDim(y, m), fd = new Date(y, m, 1).getDay(), prev = getDim(y, m - 1);
|
|
29
|
+
const days: Array<{ day: number; cur: boolean }> = [];
|
|
30
|
+
for (let i = fd - 1; i >= 0; i--) days.push({ day: prev - i, cur: false });
|
|
31
|
+
for (let i = 1; i <= dim; i++) days.push({ day: i, cur: true });
|
|
32
|
+
while (days.length < 42) days.push({ day: days.length - dim - fd + 2, cur: false });
|
|
33
|
+
return days;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function toTs(d: Date | null) { return d ? d.getTime() : null; }
|
|
37
|
+
function makeDate(y: number, m: number, d: number) { return new Date(y, m, d).getTime(); }
|
|
38
|
+
|
|
39
|
+
function inRange(y: number, m: number, d: number): boolean {
|
|
40
|
+
const n = makeDate(y, m, d), s = toTs(startDate), e = toTs(endDate);
|
|
41
|
+
if (!s || !e) return false;
|
|
42
|
+
const [lo, hi] = s <= e ? [s, e] : [e, s];
|
|
43
|
+
return n >= lo && n <= hi;
|
|
44
|
+
}
|
|
45
|
+
function isEdge(y: number, m: number, d: number): boolean {
|
|
46
|
+
const n = makeDate(y, m, d), s = toTs(startDate), e = toTs(endDate);
|
|
47
|
+
return n === s || n === e;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function handleClick(y: number, m: number, d: number) {
|
|
51
|
+
const clicked = new Date(y, m, d);
|
|
52
|
+
if (!startDate || (startDate && endDate)) { startDate = clicked; endDate = null; }
|
|
53
|
+
else endDate = clicked;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function prev() { if (viewMonth === 0) { viewMonth = 11; viewYear--; } else viewMonth--; }
|
|
57
|
+
function next() { if (viewMonth === 11) { viewMonth = 0; viewYear++; } else viewMonth++; }
|
|
58
|
+
|
|
59
|
+
let m2 = $derived(viewMonth === 11 ? 0 : viewMonth + 1);
|
|
60
|
+
let y2 = $derived(viewMonth === 11 ? viewYear + 1 : viewYear);
|
|
61
|
+
let left = $derived(getCalDays(viewYear, viewMonth));
|
|
62
|
+
let right = $derived(getCalDays(y2, m2));
|
|
63
|
+
</script>
|
|
64
|
+
|
|
65
|
+
<div class={cn('inline-flex flex-col rounded-md border p-4', className)}>
|
|
66
|
+
<div class="mb-4 flex items-center justify-between">
|
|
67
|
+
<Button variant="ghost" size="sm" onclick={prev}><</Button>
|
|
68
|
+
<span class="text-sm font-medium">{MONTHS[viewMonth]} {viewYear} – {MONTHS[m2]} {y2}</span>
|
|
69
|
+
<Button variant="ghost" size="sm" onclick={next}>></Button>
|
|
70
|
+
</div>
|
|
71
|
+
<div class="flex gap-8">
|
|
72
|
+
{#each [[viewYear, viewMonth, left], [y2, m2, right]] as [y, m, days]}
|
|
73
|
+
<div>
|
|
74
|
+
<h3 class="mb-2 text-center text-sm font-medium">{MONTHS[m as number]} {y}</h3>
|
|
75
|
+
<div class="grid grid-cols-7">
|
|
76
|
+
{#each DAYS as d}
|
|
77
|
+
<div class="flex h-8 w-8 items-center justify-center text-xs font-medium text-muted-foreground">{d}</div>
|
|
78
|
+
{/each}
|
|
79
|
+
{#each (days as Array<{day:number;cur:boolean}>) as { day, cur }}
|
|
80
|
+
<button
|
|
81
|
+
type="button"
|
|
82
|
+
class={cn(
|
|
83
|
+
'flex h-8 w-8 items-center justify-center text-sm transition-colors',
|
|
84
|
+
!cur && 'text-muted-foreground/40 pointer-events-none',
|
|
85
|
+
cur && inRange(y as number, m as number, day) && !isEdge(y as number, m as number, day) && 'bg-muted',
|
|
86
|
+
cur && isEdge(y as number, m as number, day) && 'rounded-full bg-primary text-primary-foreground',
|
|
87
|
+
cur && !inRange(y as number, m as number, day) && 'rounded-full hover:bg-muted'
|
|
88
|
+
)}
|
|
89
|
+
onclick={() => cur && handleClick(y as number, m as number, day)}
|
|
90
|
+
disabled={!cur}
|
|
91
|
+
>{day}</button>
|
|
92
|
+
{/each}
|
|
93
|
+
</div>
|
|
94
|
+
</div>
|
|
95
|
+
{/each}
|
|
96
|
+
</div>
|
|
97
|
+
</div>
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
CalendarBlock06.svelte
|
|
3
|
+
Single-month range picker with minimum-days validation message.
|
|
4
|
+
-->
|
|
5
|
+
<script lang="ts">
|
|
6
|
+
import { cn } from '$lib/utils/cn';
|
|
7
|
+
import { Button } from '$lib/components/ui';
|
|
8
|
+
|
|
9
|
+
let {
|
|
10
|
+
class: className = '',
|
|
11
|
+
startDate = null,
|
|
12
|
+
endDate = null,
|
|
13
|
+
minDays = 5,
|
|
14
|
+
validationMessage = `A minimum of ${5} days is required`,
|
|
15
|
+
month = new Date().getMonth(),
|
|
16
|
+
year = new Date().getFullYear()
|
|
17
|
+
}: {
|
|
18
|
+
class?: string;
|
|
19
|
+
startDate?: Date | null;
|
|
20
|
+
endDate?: Date | null;
|
|
21
|
+
minDays?: number;
|
|
22
|
+
validationMessage?: string;
|
|
23
|
+
month?: number;
|
|
24
|
+
year?: number;
|
|
25
|
+
} = $props();
|
|
26
|
+
|
|
27
|
+
const DAYS = ['Su','Mo','Tu','We','Th','Fr','Sa'];
|
|
28
|
+
const MONTHS = ['January','February','March','April','May','June','July','August','September','October','November','December'];
|
|
29
|
+
|
|
30
|
+
function getDim(y: number, m: number) { return new Date(y, m + 1, 0).getDate(); }
|
|
31
|
+
function getCalDays(y: number, m: number) {
|
|
32
|
+
const dim = getDim(y, m), fd = new Date(y, m, 1).getDay(), prev = getDim(y, m - 1);
|
|
33
|
+
const days: Array<{ day: number; cur: boolean }> = [];
|
|
34
|
+
for (let i = fd - 1; i >= 0; i--) days.push({ day: prev - i, cur: false });
|
|
35
|
+
for (let i = 1; i <= dim; i++) days.push({ day: i, cur: true });
|
|
36
|
+
while (days.length < 42) days.push({ day: days.length - dim - fd + 2, cur: false });
|
|
37
|
+
return days;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function makeTs(y: number, m: number, d: number) { return new Date(y, m, d).getTime(); }
|
|
41
|
+
function inRange(d: number) {
|
|
42
|
+
const n = makeTs(year, month, d), s = startDate?.getTime(), e = endDate?.getTime();
|
|
43
|
+
if (!s || !e) return false;
|
|
44
|
+
const [lo, hi] = s <= e ? [s, e] : [e, s];
|
|
45
|
+
return n >= lo && n <= hi;
|
|
46
|
+
}
|
|
47
|
+
function isEdge(d: number) {
|
|
48
|
+
const n = makeTs(year, month, d);
|
|
49
|
+
return n === startDate?.getTime() || n === endDate?.getTime();
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function handleClick(d: number) {
|
|
53
|
+
const clicked = new Date(year, month, d);
|
|
54
|
+
if (!startDate || endDate) { startDate = clicked; endDate = null; }
|
|
55
|
+
else endDate = clicked;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
let rangedays = $derived(() => {
|
|
59
|
+
if (!startDate || !endDate) return 0;
|
|
60
|
+
return Math.round(Math.abs(endDate.getTime() - startDate.getTime()) / 86400000) + 1;
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
let showError = $derived(endDate !== null && rangedays() < minDays);
|
|
64
|
+
|
|
65
|
+
function prev() { if (month === 0) { month = 11; year--; } else month--; }
|
|
66
|
+
function next() { if (month === 11) { month = 0; year++; } else month++; }
|
|
67
|
+
let calDays = $derived(getCalDays(year, month));
|
|
68
|
+
</script>
|
|
69
|
+
|
|
70
|
+
<div class={cn('inline-flex flex-col rounded-md border p-4', className)}>
|
|
71
|
+
<div class="mb-4 flex items-center justify-between">
|
|
72
|
+
<Button variant="ghost" size="sm" onclick={prev}><</Button>
|
|
73
|
+
<h3 class="text-sm font-medium">{MONTHS[month]} {year}</h3>
|
|
74
|
+
<Button variant="ghost" size="sm" onclick={next}>></Button>
|
|
75
|
+
</div>
|
|
76
|
+
<div class="grid grid-cols-7">
|
|
77
|
+
{#each DAYS as d}
|
|
78
|
+
<div class="flex h-8 w-8 items-center justify-center text-xs font-medium text-muted-foreground">{d}</div>
|
|
79
|
+
{/each}
|
|
80
|
+
{#each calDays as { day, cur }}
|
|
81
|
+
<button
|
|
82
|
+
type="button"
|
|
83
|
+
class={cn(
|
|
84
|
+
'flex h-8 w-8 items-center justify-center text-sm transition-colors',
|
|
85
|
+
!cur && 'text-muted-foreground/40 pointer-events-none',
|
|
86
|
+
cur && inRange(day) && !isEdge(day) && 'bg-muted',
|
|
87
|
+
cur && isEdge(day) && 'rounded-full bg-primary text-primary-foreground',
|
|
88
|
+
cur && !inRange(day) && 'rounded-full hover:bg-muted'
|
|
89
|
+
)}
|
|
90
|
+
onclick={() => cur && handleClick(day)}
|
|
91
|
+
disabled={!cur}
|
|
92
|
+
>{day}</button>
|
|
93
|
+
{/each}
|
|
94
|
+
</div>
|
|
95
|
+
{#if showError}
|
|
96
|
+
<p class="mt-3 text-center text-xs text-muted-foreground">{validationMessage}</p>
|
|
97
|
+
{/if}
|
|
98
|
+
</div>
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
CalendarBlock07.svelte
|
|
3
|
+
Dual-month range picker with stay-length validation message.
|
|
4
|
+
-->
|
|
5
|
+
<script lang="ts">
|
|
6
|
+
import { cn } from '$lib/utils/cn';
|
|
7
|
+
import { Button } from '$lib/components/ui';
|
|
8
|
+
|
|
9
|
+
let {
|
|
10
|
+
class: className = '',
|
|
11
|
+
startDate = null,
|
|
12
|
+
endDate = null,
|
|
13
|
+
minNights = 2,
|
|
14
|
+
maxNights = 20,
|
|
15
|
+
validationMessage = `Your stay must be between ${2} and ${20} nights`
|
|
16
|
+
}: {
|
|
17
|
+
class?: string;
|
|
18
|
+
startDate?: Date | null;
|
|
19
|
+
endDate?: Date | null;
|
|
20
|
+
minNights?: number;
|
|
21
|
+
maxNights?: number;
|
|
22
|
+
validationMessage?: string;
|
|
23
|
+
} = $props();
|
|
24
|
+
|
|
25
|
+
const today = new Date();
|
|
26
|
+
let viewYear = $state(today.getFullYear());
|
|
27
|
+
let viewMonth = $state(today.getMonth());
|
|
28
|
+
|
|
29
|
+
const DAYS = ['Su','Mo','Tu','We','Th','Fr','Sa'];
|
|
30
|
+
const MONTHS = ['January','February','March','April','May','June','July','August','September','October','November','December'];
|
|
31
|
+
|
|
32
|
+
function getDim(y: number, m: number) { return new Date(y, m + 1, 0).getDate(); }
|
|
33
|
+
function getCalDays(y: number, m: number) {
|
|
34
|
+
const dim = getDim(y, m), fd = new Date(y, m, 1).getDay(), prev = getDim(y, m - 1);
|
|
35
|
+
const days: Array<{ day: number; cur: boolean }> = [];
|
|
36
|
+
for (let i = fd - 1; i >= 0; i--) days.push({ day: prev - i, cur: false });
|
|
37
|
+
for (let i = 1; i <= dim; i++) days.push({ day: i, cur: true });
|
|
38
|
+
while (days.length < 42) days.push({ day: days.length - dim - fd + 2, cur: false });
|
|
39
|
+
return days;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function inRange(y: number, m: number, d: number) {
|
|
43
|
+
const n = new Date(y, m, d).getTime(), s = startDate?.getTime(), e = endDate?.getTime();
|
|
44
|
+
if (!s || !e) return false;
|
|
45
|
+
const [lo, hi] = s <= e ? [s, e] : [e, s];
|
|
46
|
+
return n >= lo && n <= hi;
|
|
47
|
+
}
|
|
48
|
+
function isEdge(y: number, m: number, d: number) {
|
|
49
|
+
const n = new Date(y, m, d).getTime();
|
|
50
|
+
return n === startDate?.getTime() || n === endDate?.getTime();
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function handleClick(y: number, m: number, d: number) {
|
|
54
|
+
const clicked = new Date(y, m, d);
|
|
55
|
+
if (!startDate || endDate) { startDate = clicked; endDate = null; }
|
|
56
|
+
else endDate = clicked;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
let nights = $derived(() => {
|
|
60
|
+
if (!startDate || !endDate) return 0;
|
|
61
|
+
return Math.round(Math.abs(endDate.getTime() - startDate.getTime()) / 86400000);
|
|
62
|
+
});
|
|
63
|
+
let showError = $derived(endDate !== null && (nights() < minNights || nights() > maxNights));
|
|
64
|
+
|
|
65
|
+
function prev() { if (viewMonth === 0) { viewMonth = 11; viewYear--; } else viewMonth--; }
|
|
66
|
+
function next() { if (viewMonth === 11) { viewMonth = 0; viewYear++; } else viewMonth++; }
|
|
67
|
+
|
|
68
|
+
let m2 = $derived(viewMonth === 11 ? 0 : viewMonth + 1);
|
|
69
|
+
let y2 = $derived(viewMonth === 11 ? viewYear + 1 : viewYear);
|
|
70
|
+
let left = $derived(getCalDays(viewYear, viewMonth));
|
|
71
|
+
let right = $derived(getCalDays(y2, m2));
|
|
72
|
+
</script>
|
|
73
|
+
|
|
74
|
+
<div class={cn('inline-flex flex-col rounded-md border p-4', className)}>
|
|
75
|
+
<div class="mb-4 flex items-center justify-between">
|
|
76
|
+
<Button variant="ghost" size="sm" onclick={prev}><</Button>
|
|
77
|
+
<span class="text-sm font-medium">{MONTHS[viewMonth]} {viewYear} – {MONTHS[m2]} {y2}</span>
|
|
78
|
+
<Button variant="ghost" size="sm" onclick={next}>></Button>
|
|
79
|
+
</div>
|
|
80
|
+
<div class="flex gap-8">
|
|
81
|
+
{#each [[viewYear, viewMonth, left],[y2, m2, right]] as [y,m,days]}
|
|
82
|
+
<div>
|
|
83
|
+
<h3 class="mb-2 text-center text-sm font-medium">{MONTHS[m as number]} {y}</h3>
|
|
84
|
+
<div class="grid grid-cols-7">
|
|
85
|
+
{#each DAYS as d}
|
|
86
|
+
<div class="flex h-8 w-8 items-center justify-center text-xs font-medium text-muted-foreground">{d}</div>
|
|
87
|
+
{/each}
|
|
88
|
+
{#each (days as Array<{day:number;cur:boolean}>) as { day, cur }}
|
|
89
|
+
<button
|
|
90
|
+
type="button"
|
|
91
|
+
class={cn(
|
|
92
|
+
'flex h-8 w-8 items-center justify-center text-sm transition-colors',
|
|
93
|
+
!cur && 'text-muted-foreground/40 pointer-events-none',
|
|
94
|
+
cur && inRange(y as number,m as number,day) && !isEdge(y as number,m as number,day) && 'bg-muted',
|
|
95
|
+
cur && isEdge(y as number,m as number,day) && 'rounded-full bg-primary text-primary-foreground',
|
|
96
|
+
cur && !inRange(y as number,m as number,day) && 'rounded-full hover:bg-muted'
|
|
97
|
+
)}
|
|
98
|
+
onclick={() => cur && handleClick(y as number,m as number,day)}
|
|
99
|
+
disabled={!cur}
|
|
100
|
+
>{day}</button>
|
|
101
|
+
{/each}
|
|
102
|
+
</div>
|
|
103
|
+
</div>
|
|
104
|
+
{/each}
|
|
105
|
+
</div>
|
|
106
|
+
{#if showError}
|
|
107
|
+
<p class="mt-3 text-center text-xs text-muted-foreground">{validationMessage}</p>
|
|
108
|
+
{/if}
|
|
109
|
+
</div>
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
CalendarBlock08.svelte
|
|
3
|
+
Single month with weekends disabled (Mon–Fri only selectable).
|
|
4
|
+
-->
|
|
5
|
+
<script lang="ts">
|
|
6
|
+
import { cn } from '$lib/utils/cn';
|
|
7
|
+
import { Button } from '$lib/components/ui';
|
|
8
|
+
|
|
9
|
+
let {
|
|
10
|
+
class: className = '',
|
|
11
|
+
selectedDate = null,
|
|
12
|
+
month = new Date().getMonth(),
|
|
13
|
+
year = new Date().getFullYear()
|
|
14
|
+
}: {
|
|
15
|
+
class?: string;
|
|
16
|
+
selectedDate?: Date | null;
|
|
17
|
+
month?: number;
|
|
18
|
+
year?: number;
|
|
19
|
+
} = $props();
|
|
20
|
+
|
|
21
|
+
const DAYS = ['Su','Mo','Tu','We','Th','Fr','Sa'];
|
|
22
|
+
const MONTHS = ['January','February','March','April','May','June','July','August','September','October','November','December'];
|
|
23
|
+
|
|
24
|
+
function getDim(y: number, m: number) { return new Date(y, m + 1, 0).getDate(); }
|
|
25
|
+
function getCalDays(y: number, m: number) {
|
|
26
|
+
const dim = getDim(y, m), fd = new Date(y, m, 1).getDay(), prev = getDim(y, m - 1);
|
|
27
|
+
const days: Array<{ day: number; cur: boolean; dow: number }> = [];
|
|
28
|
+
for (let i = fd - 1; i >= 0; i--) days.push({ day: prev - i, cur: false, dow: (fd - 1 - i + (7 - fd + 1)) % 7 });
|
|
29
|
+
for (let i = 1; i <= dim; i++) days.push({ day: i, cur: true, dow: new Date(y, m, i).getDay() });
|
|
30
|
+
while (days.length < 42) {
|
|
31
|
+
const idx = days.length;
|
|
32
|
+
days.push({ day: idx - dim - fd + 2, cur: false, dow: idx % 7 });
|
|
33
|
+
}
|
|
34
|
+
return days;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function isSelected(d: number) {
|
|
38
|
+
return selectedDate?.getFullYear() === year && selectedDate?.getMonth() === month && selectedDate?.getDate() === d;
|
|
39
|
+
}
|
|
40
|
+
function isWeekend(dow: number) { return dow === 0 || dow === 6; }
|
|
41
|
+
|
|
42
|
+
function prev() { if (month === 0) { month = 11; year--; } else month--; }
|
|
43
|
+
function next() { if (month === 11) { month = 0; year++; } else month++; }
|
|
44
|
+
let calDays = $derived(getCalDays(year, month));
|
|
45
|
+
</script>
|
|
46
|
+
|
|
47
|
+
<div class={cn('inline-flex flex-col rounded-md border p-4', className)}>
|
|
48
|
+
<div class="mb-4 flex items-center justify-between">
|
|
49
|
+
<Button variant="ghost" size="sm" onclick={prev}><</Button>
|
|
50
|
+
<h3 class="text-sm font-medium">{MONTHS[month]} {year}</h3>
|
|
51
|
+
<Button variant="ghost" size="sm" onclick={next}>></Button>
|
|
52
|
+
</div>
|
|
53
|
+
<div class="grid grid-cols-7">
|
|
54
|
+
{#each DAYS as d}
|
|
55
|
+
<div class="flex h-8 w-8 items-center justify-center text-xs font-medium text-muted-foreground">{d}</div>
|
|
56
|
+
{/each}
|
|
57
|
+
{#each calDays as { day, cur, dow }}
|
|
58
|
+
<button
|
|
59
|
+
type="button"
|
|
60
|
+
class={cn(
|
|
61
|
+
'flex h-8 w-8 items-center justify-center rounded-full text-sm transition-colors',
|
|
62
|
+
(!cur || isWeekend(dow)) && 'text-muted-foreground/40 pointer-events-none',
|
|
63
|
+
cur && !isWeekend(dow) && 'hover:bg-muted',
|
|
64
|
+
cur && !isWeekend(dow) && isSelected(day) && 'bg-primary text-primary-foreground hover:bg-primary'
|
|
65
|
+
)}
|
|
66
|
+
onclick={() => cur && !isWeekend(dow) && (selectedDate = new Date(year, month, day))}
|
|
67
|
+
disabled={!cur || isWeekend(dow)}
|
|
68
|
+
>{day}</button>
|
|
69
|
+
{/each}
|
|
70
|
+
</div>
|
|
71
|
+
</div>
|