@zayne-labs/ui-react 0.10.8 → 0.10.10
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/dist/esm/{cn-s-D7vHW1.js → cn-DdD3uYxA.js} +1 -1
- package/dist/esm/{cn-s-D7vHW1.js.map → cn-DdD3uYxA.js.map} +1 -1
- package/dist/esm/common/await/index.d.ts +46 -4
- package/dist/esm/common/await/index.js +86 -4
- package/dist/esm/common/await/index.js.map +1 -0
- package/dist/esm/common/error-boundary/index.d.ts +1 -1
- package/dist/esm/common/for/index.d.ts +23 -2
- package/dist/esm/common/for/index.js +1 -1
- package/dist/esm/common/presence/index.js +1 -1
- package/dist/esm/common/show/index.d.ts +32 -2
- package/dist/esm/common/slot/index.d.ts +16 -2
- package/dist/esm/common/suspense-with-boundary/index.d.ts +2 -2
- package/dist/esm/common/suspense-with-boundary/index.js +20 -3
- package/dist/esm/common/suspense-with-boundary/index.js.map +1 -0
- package/dist/esm/common/switch/index.d.ts +28 -2
- package/dist/esm/common/switch/index.js +37 -2
- package/dist/esm/common/switch/index.js.map +1 -0
- package/dist/esm/common/teleport/index.d.ts +14 -2
- package/dist/esm/common/teleport/index.js +31 -2
- package/dist/esm/common/teleport/index.js.map +1 -0
- package/dist/esm/{for-DK5rEY_m.js → for-BYsFEk3R.js} +1 -1
- package/dist/esm/{for-DK5rEY_m.js.map → for-BYsFEk3R.js.map} +1 -1
- package/dist/esm/{index-C8_O0zCb.d.ts → index-BwhRxsrZ.d.ts} +3 -3
- package/dist/esm/{index-B4K9g2v-.d.ts → index-C_2Onnhl.d.ts} +4 -4
- package/dist/esm/{presence-CL5_GHQH.js → presence-CAQElNtY.js} +1 -1
- package/dist/esm/{presence-CL5_GHQH.js.map → presence-CAQElNtY.js.map} +1 -1
- package/dist/esm/ui/card/index.d.ts +20 -2
- package/dist/esm/ui/card/index.js +94 -4
- package/dist/esm/ui/card/index.js.map +1 -0
- package/dist/esm/ui/carousel/index.d.ts +95 -2
- package/dist/esm/ui/carousel/index.js +285 -13
- package/dist/esm/ui/carousel/index.js.map +1 -0
- package/dist/esm/ui/drag-scroll/index.d.ts +23 -2
- package/dist/esm/ui/drag-scroll/index.js +114 -3
- package/dist/esm/ui/drag-scroll/index.js.map +1 -0
- package/dist/esm/ui/drop-zone/index.d.ts +346 -2
- package/dist/esm/ui/drop-zone/index.js +1026 -14
- package/dist/esm/ui/drop-zone/index.js.map +1 -0
- package/dist/esm/ui/form/index.d.ts +227 -2
- package/dist/esm/ui/form/index.js +573 -5
- package/dist/esm/ui/form/index.js.map +1 -0
- package/package.json +6 -8
- package/dist/esm/await-DDgVzpvI.js +0 -87
- package/dist/esm/await-DDgVzpvI.js.map +0 -1
- package/dist/esm/card-DDLJVCwL.js +0 -95
- package/dist/esm/card-DDLJVCwL.js.map +0 -1
- package/dist/esm/carousel-B051PAAX.js +0 -285
- package/dist/esm/carousel-B051PAAX.js.map +0 -1
- package/dist/esm/common/index.d.ts +0 -9
- package/dist/esm/common/index.js +0 -11
- package/dist/esm/common-PS3X58Pj.js +0 -0
- package/dist/esm/drag-scroll-Bb1SG4On.js +0 -115
- package/dist/esm/drag-scroll-Bb1SG4On.js.map +0 -1
- package/dist/esm/drop-zone-C9VpKJAD.js +0 -1013
- package/dist/esm/drop-zone-C9VpKJAD.js.map +0 -1
- package/dist/esm/form-DyGy9LnA.js +0 -574
- package/dist/esm/form-DyGy9LnA.js.map +0 -1
- package/dist/esm/index-BoZe50e8.d.ts +0 -340
- package/dist/esm/index-BsGxDKlt.d.ts +0 -32
- package/dist/esm/index-Bx2BzRRJ.d.ts +0 -16
- package/dist/esm/index-C1GPFYKG.d.ts +0 -23
- package/dist/esm/index-CZjeBSoQ.d.ts +0 -14
- package/dist/esm/index-CffEFE66.d.ts +0 -28
- package/dist/esm/index-DWl-QZ3Q.d.ts +0 -46
- package/dist/esm/index-DZxgPnK1.d.ts +0 -95
- package/dist/esm/index-DbiE_few.d.ts +0 -227
- package/dist/esm/index-Df39YVRj.d.ts +0 -23
- package/dist/esm/index-SX3cnKP6.d.ts +0 -20
- package/dist/esm/suspense-with-boundary-D-1NYDV4.js +0 -21
- package/dist/esm/suspense-with-boundary-D-1NYDV4.js.map +0 -1
- package/dist/esm/switch-Ch22z21e.js +0 -38
- package/dist/esm/switch-Ch22z21e.js.map +0 -1
- package/dist/esm/teleport-C8TzRm4M.js +0 -32
- package/dist/esm/teleport-C8TzRm4M.js.map +0 -1
- package/dist/esm/ui/index.d.ts +0 -6
- package/dist/esm/ui/index.js +0 -18
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"carousel-B051PAAX.js","names":["useCarouselStore: typeof useCarouselStoreContext","Show.Root","Show.Content","Show.Fallback"],"sources":["../../src/components/ui/carousel/carousel-store-context.ts","../../src/components/ui/carousel/icons.tsx","../../src/components/ui/carousel/useCarouselOptions.ts","../../src/components/ui/carousel/carousel.tsx","../../src/components/ui/carousel/carousel-parts.ts"],"sourcesContent":["import { createStore } from \"@zayne-labs/toolkit-core\";\nimport { useCallbackRef, useStore } from \"@zayne-labs/toolkit-react\";\nimport { createZustandContext } from \"@zayne-labs/toolkit-react/zustand\";\nimport type { PrettyOmit } from \"@zayne-labs/toolkit-type-helpers\";\nimport { useMemo } from \"react\";\nimport type { CarouselRootProps, CarouselStore, ImagesType } from \"./types\";\n\nconst [CarouselStoreContextProvider, useCarouselStoreContext] = createZustandContext<CarouselStore>({\n\thookName: \"useCarouselStore\",\n\tname: \"CarouselStoreContext\",\n\tproviderName: \"CarouselRoot\",\n});\n\n// CarouselStore Creation\nconst createCarouselStore = <TImages extends ImagesType>(\n\tstoreValues: PrettyOmit<CarouselRootProps<TImages>, \"children\">\n) => {\n\tconst { images, onSlideBtnClick } = storeValues;\n\n\tconst carouselStore = createStore<CarouselStore<TImages>>((set, get) => ({\n\t\tcurrentSlide: 0,\n\t\timages,\n\t\tmaxSlide: images.length - 1,\n\n\t\t/* eslint-disable perfectionist/sort-objects -- actions should be last */\n\t\tactions: {\n\t\t\t/* eslint-enable perfectionist/sort-objects -- actions should be last */\n\n\t\t\tgoToNextSlide: () => {\n\t\t\t\tconst { currentSlide, maxSlide } = get();\n\t\t\t\tconst { goToSlide } = get().actions;\n\n\t\t\t\tif (currentSlide === maxSlide) {\n\t\t\t\t\tgoToSlide(0);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tgoToSlide(currentSlide + 1);\n\t\t\t},\n\n\t\t\tgoToPreviousSlide: () => {\n\t\t\t\tconst { currentSlide, maxSlide } = get();\n\t\t\t\tconst { goToSlide } = get().actions;\n\n\t\t\t\tif (currentSlide === 0) {\n\t\t\t\t\tgoToSlide(maxSlide);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tgoToSlide(currentSlide - 1);\n\t\t\t},\n\n\t\t\tgoToSlide: (newValue) => {\n\t\t\t\tonSlideBtnClick?.();\n\n\t\t\t\tset({ currentSlide: newValue });\n\t\t\t},\n\t\t},\n\t}));\n\n\treturn carouselStore;\n};\n\nconst useCarousel = <TImages extends ImagesType>(props: Omit<CarouselRootProps<TImages>, \"children\">) => {\n\tconst { images, onSlideBtnClick } = props;\n\n\tconst savedOnSlideBtnClick = useCallbackRef(onSlideBtnClick);\n\n\tconst carouselStore = useMemo(\n\t\t() => createCarouselStore({ images, onSlideBtnClick: savedOnSlideBtnClick }),\n\t\t[images, savedOnSlideBtnClick]\n\t);\n\n\tconst useCarouselStore: typeof useCarouselStoreContext = (selector) => {\n\t\treturn useStore(carouselStore, selector);\n\t};\n\n\tconst savedUseCarouselStore = useCallbackRef(useCarouselStore);\n\n\treturn useMemo(\n\t\t() => ({ carouselStore, useCarouselStore: savedUseCarouselStore }),\n\t\t[carouselStore, savedUseCarouselStore]\n\t);\n};\n\nexport { CarouselStoreContextProvider, useCarousel, useCarouselStoreContext };\n","import * as React from \"react\";\n\nexport const ChevronLeftIcon = (props: React.SVGProps<SVGSVGElement>) => (\n\t<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"1em\" height=\"1em\" viewBox=\"0 0 24 24\" {...props}>\n\t\t<g fill=\"none\" stroke=\"currentColor\" strokeLinecap=\"round\" strokeLinejoin=\"round\" strokeWidth=\"2\">\n\t\t\t<circle cx=\"12\" cy=\"12\" r=\"10\" />\n\t\t\t<path d=\"m14 16l-4-4l4-4\" />\n\t\t</g>\n\t</svg>\n);\n","import { useAnimationInterval, useCallbackRef } from \"@zayne-labs/toolkit-react\";\nimport { useState } from \"react\";\nimport type { CarouselStore } from \"./types\";\n\ntype CarouselOptions = {\n\tactions: CarouselStore[\"actions\"];\n\tautoSlideInterval?: number;\n\thasAutoSlide?: boolean;\n\tshouldPauseOnHover?: boolean;\n};\n\nconst useCarouselOptions = (options: CarouselOptions) => {\n\tconst { actions, autoSlideInterval = 5000, hasAutoSlide = false, shouldPauseOnHover = false } = options;\n\n\tconst [isPaused, setIsPaused] = useState(false);\n\n\tconst shouldAutoSlide = hasAutoSlide && !isPaused;\n\n\tuseAnimationInterval({\n\t\tintervalDuration: shouldAutoSlide ? autoSlideInterval : null,\n\t\tonAnimation: actions.goToNextSlide,\n\t});\n\n\tconst pauseAutoSlide = useCallbackRef(() => shouldPauseOnHover && setIsPaused(true));\n\n\tconst resumeAutoSlide = useCallbackRef(() => shouldPauseOnHover && setIsPaused(false));\n\n\treturn { pauseAutoSlide, resumeAutoSlide };\n};\n\nexport { useCarouselOptions };\n","\"use client\";\n\nimport type { CssWithCustomProperties, PolymorphicPropsStrict } from \"@zayne-labs/toolkit-react/utils\";\nimport { isFunction } from \"@zayne-labs/toolkit-type-helpers\";\nimport * as React from \"react\";\nimport { Show } from \"@/components/common\";\nimport { For } from \"@/components/common/for\";\nimport { cnMerge } from \"@/lib/utils/cn\";\nimport {\n\tCarouselStoreContextProvider,\n\tuseCarousel,\n\tuseCarouselStoreContext,\n} from \"./carousel-store-context\";\nimport { ChevronLeftIcon } from \"./icons\";\nimport type {\n\tCarouselButtonsProps,\n\tCarouselControlProps,\n\tCarouselIndicatorProps,\n\tCarouselRootProps,\n\tCarouselWrapperProps,\n\tImagesType,\n\tOtherCarouselProps,\n} from \"./types\";\nimport { useCarouselOptions } from \"./useCarouselOptions\";\n\n// TODO - Add dragging and swiping support\nexport function CarouselRoot<TImages extends ImagesType, TElement extends React.ElementType = \"div\">(\n\tprops: PolymorphicPropsStrict<TElement, CarouselRootProps<TImages>>\n) {\n\tconst {\n\t\tas: Element = \"div\",\n\t\tautoSlideInterval,\n\t\tchildren,\n\t\tclassNames,\n\t\thasAutoSlide,\n\t\timages,\n\t\tonSlideBtnClick,\n\t\tshouldPauseOnHover,\n\t} = props;\n\n\tconst { carouselStore } = useCarousel({ images, onSlideBtnClick });\n\n\tconst actions = carouselStore.getState().actions;\n\n\tconst { pauseAutoSlide, resumeAutoSlide } = useCarouselOptions({\n\t\tactions,\n\t\tautoSlideInterval,\n\t\thasAutoSlide,\n\t\tshouldPauseOnHover,\n\t});\n\n\treturn (\n\t\t<CarouselStoreContextProvider store={carouselStore}>\n\t\t\t<Element\n\t\t\t\tdata-scope=\"carousel\"\n\t\t\t\tdata-part=\"content\"\n\t\t\t\tdata-slot=\"carousel-content\"\n\t\t\t\tclassName={cnMerge(\"relative select-none\", classNames?.base)}\n\t\t\t\tonMouseEnter={pauseAutoSlide}\n\t\t\t\tonMouseLeave={resumeAutoSlide}\n\t\t\t>\n\t\t\t\t<div\n\t\t\t\t\tclassName={cnMerge(\n\t\t\t\t\t\t\"flex size-full overflow-x-scroll [scrollbar-width:none] [&::-webkit-scrollbar]:hidden\",\n\t\t\t\t\t\tclassNames?.scrollContainer\n\t\t\t\t\t)}\n\t\t\t\t>\n\t\t\t\t\t{children}\n\t\t\t\t</div>\n\t\t\t</Element>\n\t\t</CarouselStoreContextProvider>\n\t);\n}\n\nexport function CarouselButton(props: CarouselButtonsProps) {\n\tconst { classNames, icon, variant } = props;\n\n\tconst { goToNextSlide, goToPreviousSlide } = useCarouselStoreContext((state) => state.actions);\n\n\treturn (\n\t\t<button\n\t\t\tdata-scope=\"carousel\"\n\t\t\tdata-part=\"button\"\n\t\t\tdata-slot=\"carousel-button\"\n\t\t\ttype=\"button\"\n\t\t\tclassName={cnMerge(\n\t\t\t\t\"z-30 flex h-full w-fit items-center\",\n\t\t\t\tvariant === \"prev\" ? \"justify-start\" : \"justify-end\",\n\t\t\t\tclassNames?.base\n\t\t\t)}\n\t\t\tonClick={variant === \"prev\" ? goToPreviousSlide : goToNextSlide}\n\t\t>\n\t\t\t<span className={cnMerge(\"transition-transform active:scale-[1.06]\", classNames?.iconContainer)}>\n\t\t\t\t{icon ?? (\n\t\t\t\t\t<ChevronLeftIcon\n\t\t\t\t\t\tclassName={cnMerge(variant === \"next\" && \"rotate-180\", classNames?.defaultIcon)}\n\t\t\t\t\t/>\n\t\t\t\t)}\n\t\t\t</span>\n\t\t</button>\n\t);\n}\n\nexport function CarouselControls(props: CarouselControlProps) {\n\tconst { classNames, icon } = props;\n\n\treturn (\n\t\t<div\n\t\t\tdata-scope=\"carousel\"\n\t\t\tdata-part=\"controls\"\n\t\t\tdata-slot=\"carousel-controls\"\n\t\t\tclassName={cnMerge(\"absolute inset-0 flex justify-between\", classNames?.base)}\n\t\t>\n\t\t\t<Show.Root when={icon?.iconType}>\n\t\t\t\t<Show.Content>\n\t\t\t\t\t<CarouselButton\n\t\t\t\t\t\tvariant=\"prev\"\n\t\t\t\t\t\tclassNames={{\n\t\t\t\t\t\t\tdefaultIcon: classNames?.defaultIcon,\n\t\t\t\t\t\t\ticonContainer: cnMerge(\n\t\t\t\t\t\t\t\ticon?.iconType === \"nextIcon\" && \"rotate-180\",\n\t\t\t\t\t\t\t\tclassNames?.iconContainer\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t}}\n\t\t\t\t\t\ticon={icon?.icon}\n\t\t\t\t\t/>\n\n\t\t\t\t\t<CarouselButton\n\t\t\t\t\t\tvariant=\"next\"\n\t\t\t\t\t\tclassNames={{\n\t\t\t\t\t\t\tdefaultIcon: classNames?.defaultIcon,\n\t\t\t\t\t\t\ticonContainer: cnMerge(\n\t\t\t\t\t\t\t\ticon?.iconType === \"prevIcon\" && \"rotate-180\",\n\t\t\t\t\t\t\t\tclassNames?.iconContainer\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t}}\n\t\t\t\t\t\ticon={icon?.icon}\n\t\t\t\t\t/>\n\t\t\t\t</Show.Content>\n\n\t\t\t\t<Show.Fallback>\n\t\t\t\t\t<CarouselButton\n\t\t\t\t\t\tvariant=\"prev\"\n\t\t\t\t\t\tclassNames={{\n\t\t\t\t\t\t\tdefaultIcon: classNames?.defaultIcon,\n\t\t\t\t\t\t\ticonContainer: classNames?.iconContainer,\n\t\t\t\t\t\t}}\n\t\t\t\t\t\ticon={icon?.prev}\n\t\t\t\t\t/>\n\n\t\t\t\t\t<CarouselButton\n\t\t\t\t\t\tvariant=\"next\"\n\t\t\t\t\t\tclassNames={{\n\t\t\t\t\t\t\tdefaultIcon: classNames?.defaultIcon,\n\t\t\t\t\t\t\ticonContainer: classNames?.iconContainer,\n\t\t\t\t\t\t}}\n\t\t\t\t\t\ticon={icon?.next}\n\t\t\t\t\t/>\n\t\t\t\t</Show.Fallback>\n\t\t\t</Show.Root>\n\t\t</div>\n\t);\n}\n\nexport function CarouselItemList<TArrayItem>(props: CarouselWrapperProps<TArrayItem>) {\n\tconst { children, className, each } = props;\n\n\tconst currentSlide = useCarouselStoreContext((state) => state.currentSlide);\n\tconst images = useCarouselStoreContext((state) => each ?? (state.images as TArrayItem[]));\n\n\treturn (\n\t\t<ul\n\t\t\tdata-scope=\"carousel\"\n\t\t\tdata-part=\"item-list\"\n\t\t\tdata-slot=\"carousel-item-list\"\n\t\t\tclassName={cnMerge(\n\t\t\t\t`flex w-full shrink-0 transform-[translate3d(var(--translate-distance),0,0)] snap-center\n\t\t\t\ttransition-transform duration-800`,\n\t\t\t\tclassName\n\t\t\t)}\n\t\t\tstyle={\n\t\t\t\t{\n\t\t\t\t\t\"--translate-distance\": `-${currentSlide * 100}%`,\n\t\t\t\t} satisfies CssWithCustomProperties as CssWithCustomProperties\n\t\t\t}\n\t\t>\n\t\t\t{isFunction(children) ?\n\t\t\t\t<For each={images} renderItem={(image, index, array) => children({ array, image, index })} />\n\t\t\t:\tchildren}\n\t\t</ul>\n\t);\n}\n\nexport function CarouselItem(props: OtherCarouselProps) {\n\tconst { children, className, ...restOfProps } = props;\n\n\treturn (\n\t\t<li\n\t\t\tdata-scope=\"carousel\"\n\t\t\tdata-part=\"item\"\n\t\t\tdata-slot=\"carousel-item\"\n\t\t\tclassName={cnMerge(\"flex w-full shrink-0 snap-center justify-center\", className)}\n\t\t\t{...restOfProps}\n\t\t>\n\t\t\t{children}\n\t\t</li>\n\t);\n}\n\nexport function CarouselCaption<TElement extends React.ElementType = \"div\">(\n\tprops: PolymorphicPropsStrict<TElement, OtherCarouselProps>\n) {\n\tconst { as: HtmlElement = \"div\", children, className } = props;\n\n\treturn (\n\t\t<HtmlElement\n\t\t\tdata-scope=\"carousel\"\n\t\t\tdata-part=\"caption\"\n\t\t\tdata-slot=\"carousel-caption\"\n\t\t\tclassName={cnMerge(\"absolute z-10\", className)}\n\t\t>\n\t\t\t{children}\n\t\t</HtmlElement>\n\t);\n}\n\nexport function CarouselIndicatorList<TArrayItem>(props: CarouselWrapperProps<TArrayItem>) {\n\tconst { children, className, each } = props;\n\n\tconst images = useCarouselStoreContext((state) => each ?? (state.images as TArrayItem[]));\n\n\treturn (\n\t\t<ul\n\t\t\tdata-scope=\"carousel\"\n\t\t\tdata-part=\"indicator-list\"\n\t\t\tdata-slot=\"carousel-indicator-list\"\n\t\t\tclassName={cnMerge(\n\t\t\t\t\"absolute bottom-[25px] z-[2] flex w-full items-center justify-center gap-[15px]\",\n\t\t\t\tclassName\n\t\t\t)}\n\t\t>\n\t\t\t{isFunction(children) ?\n\t\t\t\t<For each={images} renderItem={(image, index, array) => children({ array, image, index })} />\n\t\t\t:\tchildren}\n\t\t</ul>\n\t);\n}\n\nexport function CarouselIndicator(props: CarouselIndicatorProps) {\n\tconst { classNames, currentIndex } = props;\n\n\tconst {\n\t\tactions: { goToSlide },\n\t\tcurrentSlide,\n\t} = useCarouselStoreContext((state) => state);\n\n\treturn (\n\t\t<li\n\t\t\tdata-scope=\"carousel\"\n\t\t\tdata-part=\"indicator\"\n\t\t\tdata-slot=\"carousel-indicator\"\n\t\t\tclassName={cnMerge(\"inline-flex\", classNames?.base)}\n\t\t>\n\t\t\t<button\n\t\t\t\ttype=\"button\"\n\t\t\t\tonClick={() => goToSlide(currentIndex)}\n\t\t\t\tclassName={cnMerge(\n\t\t\t\t\t\"size-[6px] rounded-[50%]\",\n\t\t\t\t\tclassNames?.base,\n\t\t\t\t\tcurrentIndex === currentSlide && [\"w-[35px] rounded-[5px]\", classNames?.isActive]\n\t\t\t\t)}\n\t\t\t/>\n\t\t</li>\n\t);\n}\n","export {\n\tCarouselButton as Button,\n\tCarouselCaption as Caption,\n\tCarouselControls as Controls,\n\tCarouselIndicator as Indicator,\n\tCarouselIndicatorList as IndicatorGroup,\n\tCarouselItem as Item,\n\tCarouselItemList as ItemGroup,\n\tCarouselRoot as Root,\n} from \"./carousel\";\n"],"mappings":";;;;;;;;;;;;AAOA,MAAM,CAAC,8BAA8B,2BAA2B,qBAAoC;CACnG,UAAU;CACV,MAAM;CACN,cAAc;CACd,CAAC;AAGF,MAAM,uBACL,gBACI;CACJ,MAAM,EAAE,QAAQ,oBAAoB;AA2CpC,QAzCsB,aAAqC,KAAK,SAAS;EACxE,cAAc;EACd;EACA,UAAU,OAAO,SAAS;EAG1B,SAAS;GAGR,qBAAqB;IACpB,MAAM,EAAE,cAAc,aAAa,KAAK;IACxC,MAAM,EAAE,cAAc,KAAK,CAAC;AAE5B,QAAI,iBAAiB,UAAU;AAC9B,eAAU,EAAE;AACZ;;AAGD,cAAU,eAAe,EAAE;;GAG5B,yBAAyB;IACxB,MAAM,EAAE,cAAc,aAAa,KAAK;IACxC,MAAM,EAAE,cAAc,KAAK,C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EzF,QACC,oBAAC;EACA,cAAW;EACX,aAAU;EACV,aAAU;EACV,WAAW,QACV,mFACA,UACA;YAEA,WAAW,SAAS,GACpB,oBAAC;GAAI,MAAM;GAAQ,aAAa,OAAO,OAAO,UAAU,SAAS;IAAE;IAAO;IAAO;IAAO,CAAC;IAAI,GAC5F;GACE;;AAIP,SAAgB,kBAAkB,OAA+B;CAChE,MAAM,EAAE,YAAY,iBAAiB;CAErC,MAAM,EACL,SAAS,EAAE,aACX,iBACG,yBAAyB,UAAU,MAAM;AAE7C,QACC,oBAAC;EACA,cAAW;EACX,aAAU;EACV,aAAU;EACV,WAAW,QAAQ,eAAe,YAAY,KAAK;YAEnD,oBAAC;GACA,MAAK;GACL,eAAe,UAAU,aAAa;GACtC,WAAW,QACV,4BACA,YAAY,MACZ,iBAAiB,gBAAgB,CAAC,0BAA0B,YAAY,SAAS,CACjF;IACA;GACE"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { ErrorBoundary } from "../index-C8_O0zCb.js";
|
|
2
|
-
import { SuspenseWithBoundary } from "../index-B4K9g2v-.js";
|
|
3
|
-
import { await_parts_d_exports } from "../index-DWl-QZ3Q.js";
|
|
4
|
-
import { For, ForWithWrapper } from "../index-Df39YVRj.js";
|
|
5
|
-
import { show_parts_d_exports } from "../index-BsGxDKlt.js";
|
|
6
|
-
import { slot_parts_d_exports } from "../index-Bx2BzRRJ.js";
|
|
7
|
-
import { switch_parts_d_exports } from "../index-CffEFE66.js";
|
|
8
|
-
import { Teleport } from "../index-CZjeBSoQ.js";
|
|
9
|
-
export { await_parts_d_exports as Await, ErrorBoundary, For, ForWithWrapper, show_parts_d_exports as Show, slot_parts_d_exports as Slot, SuspenseWithBoundary, switch_parts_d_exports as Switch, Teleport };
|
package/dist/esm/common/index.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { ErrorBoundary } from "../error-boundary-y9Samt_s.js";
|
|
2
|
-
import { slot_parts_exports } from "../slot-WVWfOlr3.js";
|
|
3
|
-
import { await_parts_exports } from "../await-DDgVzpvI.js";
|
|
4
|
-
import { For, ForWithWrapper } from "../for-DK5rEY_m.js";
|
|
5
|
-
import { show_parts_exports } from "../show-N1ZXBhoA.js";
|
|
6
|
-
import { SuspenseWithBoundary } from "../suspense-with-boundary-D-1NYDV4.js";
|
|
7
|
-
import { switch_parts_exports } from "../switch-Ch22z21e.js";
|
|
8
|
-
import { Teleport } from "../teleport-C8TzRm4M.js";
|
|
9
|
-
import "../common-PS3X58Pj.js";
|
|
10
|
-
|
|
11
|
-
export { await_parts_exports as Await, ErrorBoundary, For, ForWithWrapper, show_parts_exports as Show, slot_parts_exports as Slot, SuspenseWithBoundary, switch_parts_exports as Switch, Teleport };
|
|
File without changes
|
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
import { cnMerge } from "./cn-s-D7vHW1.js";
|
|
2
|
-
import { composeRefs, mergeTwoProps } from "@zayne-labs/toolkit-react/utils";
|
|
3
|
-
import { useCallback, useMemo, useRef } from "react";
|
|
4
|
-
import { useCallbackRef } from "@zayne-labs/toolkit-react";
|
|
5
|
-
import { checkIsDeviceMobile, off, on } from "@zayne-labs/toolkit-core";
|
|
6
|
-
|
|
7
|
-
//#region src/components/ui/drag-scroll/utils.ts
|
|
8
|
-
const updateCursor = (element) => {
|
|
9
|
-
element.style.cursor = "grabbing";
|
|
10
|
-
element.style.userSelect = "none";
|
|
11
|
-
};
|
|
12
|
-
const onScrollSnap = (action, element) => {
|
|
13
|
-
if (action === "remove") {
|
|
14
|
-
element.style.scrollSnapType = "none";
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
17
|
-
element.style.scrollSnapType = "";
|
|
18
|
-
};
|
|
19
|
-
const resetCursor = (element) => {
|
|
20
|
-
element.style.cursor = "";
|
|
21
|
-
element.style.userSelect = "";
|
|
22
|
-
};
|
|
23
|
-
const handleScrollSnap = (dragContainer) => {
|
|
24
|
-
if (!checkIsDeviceMobile()) onScrollSnap("remove", dragContainer);
|
|
25
|
-
else onScrollSnap("reset", dragContainer);
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
//#endregion
|
|
29
|
-
//#region src/components/ui/drag-scroll/use-drag-scroll.ts
|
|
30
|
-
const useDragScroll = (props) => {
|
|
31
|
-
const { classNames, extraItemProps, extraRootProps, orientation = "horizontal", usage = "allScreens" } = props ?? {};
|
|
32
|
-
const dragContainerRef = useRef(null);
|
|
33
|
-
const positionRef = useRef({
|
|
34
|
-
left: 0,
|
|
35
|
-
top: 0,
|
|
36
|
-
x: 0,
|
|
37
|
-
y: 0
|
|
38
|
-
});
|
|
39
|
-
const handleMouseMove = useCallbackRef((event) => {
|
|
40
|
-
if (!dragContainerRef.current) return;
|
|
41
|
-
if (orientation === "horizontal" || orientation === "both") {
|
|
42
|
-
const dx = event.clientX - positionRef.current.x;
|
|
43
|
-
dragContainerRef.current.scrollLeft = positionRef.current.left - dx;
|
|
44
|
-
}
|
|
45
|
-
if (orientation === "vertical" || orientation === "both") {
|
|
46
|
-
const dy = event.clientY - positionRef.current.y;
|
|
47
|
-
dragContainerRef.current.scrollTop = positionRef.current.top - dy;
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
const handleMouseUpOrLeave = useCallbackRef(() => {
|
|
51
|
-
if (!dragContainerRef.current) return;
|
|
52
|
-
off("mousemove", dragContainerRef.current, handleMouseMove);
|
|
53
|
-
off("mouseup", dragContainerRef.current, handleMouseUpOrLeave);
|
|
54
|
-
off("mouseleave", dragContainerRef.current, handleMouseUpOrLeave);
|
|
55
|
-
resetCursor(dragContainerRef.current);
|
|
56
|
-
});
|
|
57
|
-
const handleMouseDown = useCallbackRef((event) => {
|
|
58
|
-
if (usage === "mobileAndTabletOnly" && window.innerWidth >= 768) return;
|
|
59
|
-
if (usage === "desktopOnly" && window.innerWidth < 768) return;
|
|
60
|
-
if (!dragContainerRef.current) return;
|
|
61
|
-
if (orientation === "horizontal" || orientation === "both") {
|
|
62
|
-
positionRef.current.x = event.clientX;
|
|
63
|
-
positionRef.current.left = dragContainerRef.current.scrollLeft;
|
|
64
|
-
}
|
|
65
|
-
if (orientation === "vertical" || orientation === "both") {
|
|
66
|
-
positionRef.current.y = event.clientY;
|
|
67
|
-
positionRef.current.top = dragContainerRef.current.scrollTop;
|
|
68
|
-
}
|
|
69
|
-
updateCursor(dragContainerRef.current);
|
|
70
|
-
on("mousemove", dragContainerRef.current, handleMouseMove);
|
|
71
|
-
on("mouseup", dragContainerRef.current, handleMouseUpOrLeave);
|
|
72
|
-
on("mouseleave", dragContainerRef.current, handleMouseUpOrLeave);
|
|
73
|
-
});
|
|
74
|
-
const refCallBack = useCallbackRef((node) => {
|
|
75
|
-
dragContainerRef.current = node;
|
|
76
|
-
node && handleScrollSnap(node);
|
|
77
|
-
return on("mousedown", dragContainerRef.current, handleMouseDown);
|
|
78
|
-
});
|
|
79
|
-
const getRootProps = useCallback((rootProps) => {
|
|
80
|
-
const mergedRootProps = mergeTwoProps(extraRootProps, rootProps);
|
|
81
|
-
return {
|
|
82
|
-
...mergedRootProps,
|
|
83
|
-
className: cnMerge(`scrollbar-hidden flex w-full cursor-grab snap-x snap-mandatory overflow-x-scroll
|
|
84
|
-
overflow-y-hidden`, orientation === "horizontal" && "flex-row", orientation === "vertical" && "flex-col", usage === "mobileAndTabletOnly" && "md:cursor-default md:flex-col", usage === "desktopOnly" && "max-md:cursor-default max-md:flex-col", classNames?.base, mergedRootProps.className),
|
|
85
|
-
"data-part": "root",
|
|
86
|
-
"data-scope": "drag-scroll",
|
|
87
|
-
"data-slot": "drag-scroll-root",
|
|
88
|
-
ref: composeRefs(refCallBack, mergedRootProps?.ref)
|
|
89
|
-
};
|
|
90
|
-
}, [
|
|
91
|
-
extraRootProps,
|
|
92
|
-
classNames?.base,
|
|
93
|
-
orientation,
|
|
94
|
-
refCallBack,
|
|
95
|
-
usage
|
|
96
|
-
]);
|
|
97
|
-
const getItemProps = useCallback((itemProps) => {
|
|
98
|
-
const mergedItemProps = mergeTwoProps(extraItemProps, itemProps);
|
|
99
|
-
return {
|
|
100
|
-
...mergedItemProps,
|
|
101
|
-
className: cnMerge("snap-center snap-always", classNames?.item, mergedItemProps.className),
|
|
102
|
-
"data-part": "item",
|
|
103
|
-
"data-scope": "drag-scroll",
|
|
104
|
-
"data-slot": "drag-scroll-item"
|
|
105
|
-
};
|
|
106
|
-
}, [extraItemProps, classNames?.item]);
|
|
107
|
-
return useMemo(() => ({
|
|
108
|
-
getItemProps,
|
|
109
|
-
getRootProps
|
|
110
|
-
}), [getItemProps, getRootProps]);
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
//#endregion
|
|
114
|
-
export { useDragScroll };
|
|
115
|
-
//# sourceMappingURL=drag-scroll-Bb1SG4On.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"drag-scroll-Bb1SG4On.js","names":["refCallBack: RefCallback<TElement>","getRootProps: DragScrollResult<TElement, TItemElement>[\"getRootProps\"]","getItemProps: DragScrollResult<TElement, TItemElement>[\"getItemProps\"]"],"sources":["../../src/components/ui/drag-scroll/utils.ts","../../src/components/ui/drag-scroll/use-drag-scroll.ts"],"sourcesContent":["import { checkIsDeviceMobile } from \"@zayne-labs/toolkit-core\";\n\n/* eslint-disable no-param-reassign -- Mutation is needed here since it's an element */\nexport const updateCursor = <TElement extends HTMLElement>(element: TElement) => {\n\telement.style.cursor = \"grabbing\";\n\telement.style.userSelect = \"none\";\n};\n\nexport const onScrollSnap = <TElement extends HTMLElement>(\n\taction: \"remove\" | \"reset\",\n\telement: TElement\n) => {\n\tif (action === \"remove\") {\n\t\telement.style.scrollSnapType = \"none\";\n\t\treturn;\n\t}\n\n\telement.style.scrollSnapType = \"\";\n};\n\nexport const resetCursor = <TElement extends HTMLElement>(element: TElement) => {\n\telement.style.cursor = \"\";\n\telement.style.userSelect = \"\";\n};\n/* eslint-enable no-param-reassign -- Mutation is needed here since it's an element */\n\nexport const handleScrollSnap = (dragContainer: HTMLElement) => {\n\tconst isMobile = checkIsDeviceMobile();\n\n\tif (!isMobile) {\n\t\tonScrollSnap(\"remove\", dragContainer);\n\t} else {\n\t\tonScrollSnap(\"reset\", dragContainer);\n\t}\n};\n","import { off, on } from \"@zayne-labs/toolkit-core\";\nimport { useCallbackRef } from \"@zayne-labs/toolkit-react\";\nimport { composeRefs, type InferProps, mergeTwoProps } from \"@zayne-labs/toolkit-react/utils\";\nimport { type RefCallback, useCallback, useMemo, useRef } from \"react\";\nimport { cnMerge } from \"@/lib/utils/cn\";\nimport { handleScrollSnap, resetCursor, updateCursor } from \"./utils\";\n\ntype ItemProps<TItemElement extends HTMLElement> = Omit<InferProps<TItemElement>, \"children\">;\n\ntype RootProps<TElement extends HTMLElement> = Omit<InferProps<TElement>, \"children\">;\n\ntype DragScrollProps<TElement extends HTMLElement, TItemElement extends HTMLElement> = {\n\tclassNames?: { base?: string; item?: string };\n\textraItemProps?: ItemProps<TItemElement>;\n\textraRootProps?: InferProps<TElement>;\n\torientation?: \"both\" | \"horizontal\" | \"vertical\";\n\tusage?: \"allScreens\" | \"desktopOnly\" | \"mobileAndTabletOnly\";\n};\n\ntype DragScrollResult<TElement extends HTMLElement, TItemElement extends HTMLElement> = {\n\tgetItemProps: (itemProps?: ItemProps<TItemElement>) => ItemProps<TItemElement>;\n\tgetRootProps: (rootProps?: RootProps<TElement>) => RootProps<TElement>;\n};\n\nconst useDragScroll = <TElement extends HTMLElement, TItemElement extends HTMLElement = HTMLElement>(\n\tprops?: DragScrollProps<TElement, TItemElement>\n): DragScrollResult<TElement, TItemElement> => {\n\tconst {\n\t\tclassNames,\n\t\textraItemProps,\n\t\textraRootProps,\n\t\torientation = \"horizontal\",\n\t\tusage = \"allScreens\",\n\t} = props ?? {};\n\n\tconst dragContainerRef = useRef<TElement>(null);\n\n\tconst positionRef = useRef({ left: 0, top: 0, x: 0, y: 0 });\n\n\tconst handleMouseMove = useCallbackRef((event: MouseEvent) => {\n\t\tif (!dragContainerRef.current) return;\n\n\t\tif (orientation === \"horizontal\" || orientation === \"both\") {\n\t\t\t// == calculate the current change in the horizontal scroll position based on the difference between the previous mouse position and the new mouse position\n\t\t\tconst dx = event.clientX - positionRef.current.x;\n\n\t\t\t// == Assign the scrollLeft of the container to the difference between its previous horizontal scroll position and the change in the mouse position\n\t\t\tdragContainerRef.current.scrollLeft = positionRef.current.left - dx;\n\t\t}\n\n\t\tif (orientation === \"vertical\" || orientation === \"both\") {\n\t\t\t// == calculate the current change in the vertical scroll position based on the difference between the previous mouse position and the new mouse position\n\t\t\tconst dy = event.clientY - positionRef.current.y;\n\n\t\t\t// == Assign the scrollTop of the container to the difference between its previous vertical scroll position and the change in the mouse position\n\t\t\tdragContainerRef.current.scrollTop = positionRef.current.top - dy;\n\t\t}\n\t});\n\n\tconst handleMouseUpOrLeave = useCallbackRef(() => {\n\t\tif (!dragContainerRef.current) return;\n\n\t\toff(\"mousemove\", dragContainerRef.current, handleMouseMove);\n\t\toff(\"mouseup\", dragContainerRef.current, handleMouseUpOrLeave);\n\t\toff(\"mouseleave\", dragContainerRef.current, handleMouseUpOrLeave);\n\n\t\tresetCursor(dragContainerRef.current);\n\t});\n\n\tconst handleMouseDown = useCallbackRef((event: MouseEvent) => {\n\t\tif (usage === \"mobileAndTabletOnly\" && window.innerWidth >= 768) return;\n\t\tif (usage === \"desktopOnly\" && window.innerWidth < 768) return;\n\n\t\tif (!dragContainerRef.current) return;\n\n\t\t// == Update all initial position properties stored in the positionRef\n\t\tif (orientation === \"horizontal\" || orientation === \"both\") {\n\t\t\tpositionRef.current.x = event.clientX;\n\t\t\tpositionRef.current.left = dragContainerRef.current.scrollLeft;\n\t\t}\n\n\t\tif (orientation === \"vertical\" || orientation === \"both\") {\n\t\t\tpositionRef.current.y = event.clientY;\n\t\t\tpositionRef.current.top = dragContainerRef.current.scrollTop;\n\t\t}\n\n\t\tupdateCursor(dragContainerRef.current);\n\n\t\ton(\"mousemove\", dragContainerRef.current, handleMouseMove);\n\t\ton(\"mouseup\", dragContainerRef.current, handleMouseUpOrLeave);\n\t\ton(\"mouseleave\", dragContainerRef.current, handleMouseUpOrLeave);\n\t});\n\n\tconst refCallBack: RefCallback<TElement> = useCallbackRef((node) => {\n\t\tdragContainerRef.current = node;\n\n\t\tnode && handleScrollSnap(node);\n\n\t\tconst cleanup = on(\"mousedown\", dragContainerRef.current, handleMouseDown);\n\n\t\treturn cleanup;\n\t});\n\n\tconst getRootProps: DragScrollResult<TElement, TItemElement>[\"getRootProps\"] = useCallback(\n\t\t(rootProps) => {\n\t\t\tconst mergedRootProps = mergeTwoProps(extraRootProps, rootProps);\n\n\t\t\treturn {\n\t\t\t\t...mergedRootProps,\n\t\t\t\tclassName: cnMerge(\n\t\t\t\t\t`scrollbar-hidden flex w-full cursor-grab snap-x snap-mandatory overflow-x-scroll\n\t\t\t\t\toverflow-y-hidden`,\n\t\t\t\t\torientation === \"horizontal\" && \"flex-row\",\n\t\t\t\t\torientation === \"vertical\" && \"flex-col\",\n\t\t\t\t\tusage === \"mobileAndTabletOnly\" && \"md:cursor-default md:flex-col\",\n\t\t\t\t\tusage === \"desktopOnly\" && \"max-md:cursor-default max-md:flex-col\",\n\t\t\t\t\tclassNames?.base,\n\t\t\t\t\tmergedRootProps.className\n\t\t\t\t),\n\t\t\t\t\"data-part\": \"root\",\n\t\t\t\t\"data-scope\": \"drag-scroll\",\n\t\t\t\t\"data-slot\": \"drag-scroll-root\",\n\t\t\t\tref: composeRefs(\n\t\t\t\t\trefCallBack,\n\t\t\t\t\t(mergedRootProps as { ref?: React.Ref<TElement> } | undefined)?.ref\n\t\t\t\t),\n\t\t\t};\n\t\t},\n\t\t[extraRootProps, classNames?.base, orientation, refCallBack, usage]\n\t);\n\n\tconst getItemProps: DragScrollResult<TElement, TItemElement>[\"getItemProps\"] = useCallback(\n\t\t(itemProps) => {\n\t\t\tconst mergedItemProps = mergeTwoProps(extraItemProps, itemProps);\n\n\t\t\treturn {\n\t\t\t\t...mergedItemProps,\n\t\t\t\tclassName: cnMerge(\"snap-center snap-always\", classNames?.item, mergedItemProps.className),\n\t\t\t\t\"data-part\": \"item\",\n\t\t\t\t\"data-scope\": \"drag-scroll\",\n\t\t\t\t\"data-slot\": \"drag-scroll-item\",\n\t\t\t};\n\t\t},\n\t\t[extraItemProps, classNames?.item]\n\t);\n\n\tconst result = useMemo(() => ({ getItemProps, getRootProps }), [getItemProps, getRootProps]);\n\n\treturn result;\n};\n\nexport { useDragScroll };\n"],"mappings":";;;;;;;AAGA,MAAa,gBAA8C,YAAsB;AAChF,SAAQ,MAAM,SAAS;AACvB,SAAQ,MAAM,aAAa;;AAG5B,MAAa,gBACZ,QACA,YACI;AACJ,KAAI,WAAW,UAAU;AACxB,UAAQ,MAAM,iBAAiB;AAC/B;;AAGD,SAAQ,MAAM,iBAAiB;;AAGhC,MAAa,eAA6C,YAAsB;AAC/E,SAAQ,MAAM,SAAS;AACvB,SAAQ,MAAM,aAAa;;AAI5B,MAAa,oBAAoB,kBAA+B;AAG/D,KAAI,CAFa,qBAAqB,CAGrC,cAAa,UAAU,cAAc;KAErC,cAAa,SAAS,cAAc;;;;;ACRtC,MAAM,iBACL,UAC8C;CAC9C,MAAM,EACL,YACA,gBACA,gBACA,cAAc,cACd,QAAQ,iBACL,SAAS,EAAE;CAEf,MAAM,mBAAmB,OAAiB,KAAK;CAE/C,MAAM,cAAc,OAAO;EAAE,MAAM;EAAG,KAAK;EAAG,GAAG;EAAG,GAAG;EAAG,CAAC;CAE3D,MAAM,kBAAkB,gBAAgB,UAAsB;AAC7D,MAAI,CAAC,iBAAiB,QAAS;AAE/B,MAAI,gBAAgB,gBAAgB,gBAAgB,QAAQ;GAE3D,MAAM,KAAK,MAAM,UAAU,YAAY,QAAQ;AAG/C,oBAAiB,QAAQ,aAAa,YAAY,QAAQ,OAAO;;AAGlE,MAAI,gBAAgB,cAAc,gBAAgB,QAAQ;GAEzD,MAAM,KAAK,MAAM,UAAU,YAAY,QAAQ;AAG/C,oBAAiB,QAAQ,YAAY,YAAY,QAAQ,MA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