@zayne-labs/ui-react 0.10.6 → 0.10.7
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/{card-gWNDcZV0.js → card-DDLJVCwL.js} +4 -3
- package/dist/esm/card-DDLJVCwL.js.map +1 -0
- package/dist/esm/{carousel-BY9RvR71.js → carousel-B051PAAX.js} +2 -2
- package/dist/esm/carousel-B051PAAX.js.map +1 -0
- package/dist/esm/common/await/index.d.ts +3 -3
- package/dist/esm/common/error-boundary/index.d.ts +1 -1
- package/dist/esm/common/for/index.d.ts +1 -1
- package/dist/esm/common/for/index.js +1 -1
- package/dist/esm/common/index.d.ts +5 -5
- package/dist/esm/common/index.js +1 -1
- package/dist/esm/common/presence/index.js +1 -1
- package/dist/esm/common/slot/index.d.ts +1 -1
- package/dist/esm/common/suspense-with-boundary/index.d.ts +2 -2
- package/dist/esm/{drop-zone-5dDyxv_f.js → drop-zone-C9VpKJAD.js} +41 -15
- package/dist/esm/drop-zone-C9VpKJAD.js.map +1 -0
- package/dist/esm/error-boundary-y9Samt_s.js.map +1 -1
- package/dist/esm/{for-Dfh7e9Z4.js → for-DK5rEY_m.js} +4 -5
- package/dist/esm/for-DK5rEY_m.js.map +1 -0
- package/dist/esm/{form-DDSlHq5t.js → form-DyGy9LnA.js} +2 -2
- package/dist/esm/form-DyGy9LnA.js.map +1 -0
- package/dist/esm/{index-D259PHNG.d.ts → index-ATxxr1XS.d.ts} +2 -2
- package/dist/esm/{index-RnqeaSJm.d.ts → index-B4YvRWlE.d.ts} +5 -5
- package/dist/esm/{index-CJLZEhIo.d.ts → index-BAywimP3.d.ts} +3 -3
- package/dist/esm/index-BT0UvcRp.d.ts +23 -0
- package/dist/esm/{index-BBHGVe_0.d.ts → index-BWD8WVO-.d.ts} +12 -8
- package/dist/esm/{index-CvjRPnhb.d.ts → index-C889t8UO.d.ts} +6 -6
- package/dist/esm/{index-B53RIFft.d.ts → index-CuJVxLEc.d.ts} +3 -3
- package/dist/esm/{index-GHA8HNcd.d.ts → index-DVBtz0VB.d.ts} +9 -9
- package/dist/esm/{index-DoRAzdDN.d.ts → index-Dpt8KDv1.d.ts} +11 -11
- package/dist/esm/{presence-CRZsP1Jk.js → presence-CL5_GHQH.js} +2 -2
- package/dist/esm/{presence-CRZsP1Jk.js.map → presence-CL5_GHQH.js.map} +1 -1
- package/dist/esm/ui/card/index.d.ts +1 -1
- package/dist/esm/ui/card/index.js +1 -1
- package/dist/esm/ui/carousel/index.d.ts +1 -1
- package/dist/esm/ui/carousel/index.js +2 -2
- package/dist/esm/ui/drop-zone/index.d.ts +1 -1
- package/dist/esm/ui/drop-zone/index.js +3 -3
- package/dist/esm/ui/form/index.d.ts +1 -1
- package/dist/esm/ui/form/index.js +2 -2
- package/dist/esm/ui/index.d.ts +4 -4
- package/dist/esm/ui/index.js +6 -6
- package/dist/style.css +30 -0
- package/package.json +4 -4
- package/dist/esm/card-gWNDcZV0.js.map +0 -1
- package/dist/esm/carousel-BY9RvR71.js.map +0 -1
- package/dist/esm/drop-zone-5dDyxv_f.js.map +0 -1
- package/dist/esm/for-Dfh7e9Z4.js.map +0 -1
- package/dist/esm/form-DDSlHq5t.js.map +0 -1
- package/dist/esm/index-Bra0UlL_.d.ts +0 -21
|
@@ -16,12 +16,13 @@ function CardRoot(props) {
|
|
|
16
16
|
});
|
|
17
17
|
}
|
|
18
18
|
function CardHeader(props) {
|
|
19
|
-
const { as: Element = "header",...restOfProps } = props;
|
|
19
|
+
const { as: Element = "header", className,...restOfProps } = props;
|
|
20
20
|
return /* @__PURE__ */ jsx(Element, {
|
|
21
21
|
"data-scope": "card",
|
|
22
22
|
"data-part": "header",
|
|
23
23
|
"data-slot": "card-header",
|
|
24
|
-
className:
|
|
24
|
+
className: cnMerge(`@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-1.5 px-6
|
|
25
|
+
has-data-[slot=card-action]:grid-cols-[1fr_auto]`, className),
|
|
25
26
|
...restOfProps
|
|
26
27
|
});
|
|
27
28
|
}
|
|
@@ -91,4 +92,4 @@ var card_parts_exports = __export({
|
|
|
91
92
|
|
|
92
93
|
//#endregion
|
|
93
94
|
export { CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardRoot, CardTitle, card_parts_exports };
|
|
94
|
-
//# sourceMappingURL=card-
|
|
95
|
+
//# sourceMappingURL=card-DDLJVCwL.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"card-DDLJVCwL.js","names":["Component","Slot.Root"],"sources":["../../src/components/ui/card/card.tsx","../../src/components/ui/card/card-parts.ts"],"sourcesContent":["import type { PolymorphicProps } from \"@zayne-labs/toolkit-react/utils\";\nimport * as React from \"react\";\nimport { Slot } from \"@/components/common/slot\";\nimport { cnMerge } from \"@/lib/utils/cn\";\n\nexport function CardRoot<TElement extends React.ElementType = \"article\">(\n\tprops: PolymorphicProps<TElement>\n) {\n\tconst { as: Element = \"article\", ...restOfProps } = props;\n\n\treturn (\n\t\t<Element\n\t\t\tdata-scope=\"card\"\n\t\t\tdata-part=\"root\"\n\t\t\tdata-slot=\"card-root\"\n\t\t\tclassName=\"flex flex-col gap-6 rounded-xl border py-6 shadow-sm\"\n\t\t\t{...restOfProps}\n\t\t/>\n\t);\n}\n\nexport function CardHeader<TElement extends React.ElementType = \"header\">(\n\tprops: PolymorphicProps<TElement>\n) {\n\tconst { as: Element = \"header\", className, ...restOfProps } = props;\n\n\treturn (\n\t\t<Element\n\t\t\tdata-scope=\"card\"\n\t\t\tdata-part=\"header\"\n\t\t\tdata-slot=\"card-header\"\n\t\t\tclassName={cnMerge(\n\t\t\t\t`@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-1.5 px-6\n\t\t\t\thas-data-[slot=card-action]:grid-cols-[1fr_auto]`,\n\t\t\t\tclassName\n\t\t\t)}\n\t\t\t{...restOfProps}\n\t\t/>\n\t);\n}\n\nexport function CardTitle<TElement extends React.ElementType = \"h3\">(props: PolymorphicProps<TElement>) {\n\tconst { as: Element = \"h3\", className, ...restOfProps } = props;\n\n\treturn (\n\t\t<Element\n\t\t\tdata-scope=\"card\"\n\t\t\tdata-part=\"title\"\n\t\t\tdata-slot=\"card-title\"\n\t\t\tclassName={cnMerge(\"leading-none font-semibold\", className)}\n\t\t\t{...restOfProps}\n\t\t/>\n\t);\n}\n\nexport function CardDescription<TElement extends React.ElementType = \"p\">(\n\tprops: PolymorphicProps<TElement>\n) {\n\tconst { as: Element = \"p\", className, ...restOfProps } = props;\n\n\treturn (\n\t\t<Element\n\t\t\tdata-scope=\"card\"\n\t\t\tdata-part=\"description\"\n\t\t\tdata-slot=\"card-description\"\n\t\t\tclassName={cnMerge(\"text-sm text-zu-muted-foreground\", className)}\n\t\t\t{...restOfProps}\n\t\t/>\n\t);\n}\n\nexport function CardContent<TElement extends React.ElementType = \"div\">(\n\tprops: PolymorphicProps<TElement>\n) {\n\tconst { as: Element = \"div\", className, ...restOfProps } = props;\n\n\treturn (\n\t\t<Element\n\t\t\tdata-scope=\"card\"\n\t\t\tdata-part=\"content\"\n\t\t\tdata-slot=\"card-content\"\n\t\t\tclassName={cnMerge(\"px-6\", className)}\n\t\t\t{...restOfProps}\n\t\t/>\n\t);\n}\n\nexport function CardAction<TElement extends React.ElementType = \"div\">(props: PolymorphicProps<TElement>) {\n\tconst { as: Element = \"div\", className, ...restOfProps } = props;\n\n\treturn (\n\t\t<Element\n\t\t\tdata-scope=\"card\"\n\t\t\tdata-part=\"action\"\n\t\t\tdata-slot=\"card-action\"\n\t\t\tclassName={cnMerge(\"col-start-2 row-span-2 row-start-1 self-start justify-self-end\", className)}\n\t\t\t{...restOfProps}\n\t\t/>\n\t);\n}\n\nexport function CardFooter<TElement extends React.ElementType = \"footer\">(\n\tprops: PolymorphicProps<TElement, { asChild?: boolean }>\n) {\n\tconst { as: Element = \"footer\", asChild, className, ...restOfProps } = props;\n\n\tconst Component = asChild ? Slot.Root : Element;\n\n\treturn (\n\t\t<Component\n\t\t\tdata-scope=\"card\"\n\t\t\tdata-part=\"footer\"\n\t\t\tdata-slot=\"card-footer\"\n\t\t\tclassName={cnMerge(\"px-6\", className)}\n\t\t\t{...restOfProps}\n\t\t/>\n\t);\n}\n","export {\n\tCardContent as Content,\n\tCardDescription as Description,\n\tCardFooter as Footer,\n\tCardHeader as Header,\n\tCardAction as Action,\n\tCardRoot as Root,\n\tCardTitle as Title,\n} from \"./card\";\n"],"mappings":";;;;;;;AAKA,SAAgB,SACf,OACC;CACD,MAAM,EAAE,IAAI,UAAU,UAAW,GAAG,gBAAgB;AAEpD,QACC,oBAAC;EACA,cAAW;EACX,aAAU;EACV,aAAU;EACV,WAAU;EACV,GAAI;GACH;;AAIJ,SAAgB,WACf,OACC;CACD,MAAM,EAAE,IAAI,UAAU,UAAU,UAAW,GAAG,gBAAgB;AAE9D,QACC,oBAAC;EACA,cAAW;EACX,aAAU;EACV,aAAU;EACV,WAAW,QACV;uDAEA,UACA;EACD,GAAI;GACH;;AAIJ,SAAgB,UAAqD,OAAmC;CACvG,MAAM,EAAE,IAAI,UAAU,MAAM,UAAW,GAAG,gBAAgB;AAE1D,QACC,oBAAC;EACA,cAAW;EACX,aAAU;EACV,aAAU;EACV,WAAW,QAAQ,8BAA8B,UAAU;EAC3D,GAAI;GACH;;AAIJ,SAAgB,gBACf,OACC;CACD,MAAM,EAAE,IAAI,UAAU,KAAK,UAAW,GAAG,gBAAgB;AAEzD,QACC,oBAAC;EACA,cAAW;EACX,aAAU;EACV,aAAU;EACV,WAAW,QAAQ,oCAAoC,UAAU;EACjE,GAAI;GACH;;AAIJ,SAAgB,YACf,OACC;CACD,MAAM,EAAE,IAAI,UAAU,OAAO,UAAW,GAAG,gBAAgB;AAE3D,QACC,oBAAC;EACA,cAAW;EACX,aAAU;EACV,aAAU;EACV,WAAW,QAAQ,QAAQ,UAAU;EACrC,GAAI;GACH;;AAIJ,SAAgB,WAAuD,OAAmC;CACzG,MAAM,EAAE,IAAI,UAAU,OAAO,UAAW,GAAG,gBAAgB;AAE3D,QACC,oBAAC;EACA,cAAW;EACX,aAAU;EACV,aAAU;EACV,WAAW,QAAQ,kEAAkE,UAAU;EAC/F,GAAI;GACH;;AAIJ,SAAgB,WACf,OACC;CACD,MAAM,EAAE,IAAI,UAAU,UAAU,SAAS,UAAW,GAAG,gBAAgB;CAEvE,MAAMA,cAAY,UAAUC,WAAY;AAExC,QACC,oBAACD;EACA,cAAW;EACX,aAAU;EACV,aAAU;EACV,WAAW,QAAQ,QAAQ,UAAU;EACrC,GAAI;GACH"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { __export } from "./chunk-CTAAG5j7.js";
|
|
2
|
-
import { For } from "./for-
|
|
2
|
+
import { For } from "./for-DK5rEY_m.js";
|
|
3
3
|
import { ShowContent, ShowFallback, ShowRoot } from "./show-N1ZXBhoA.js";
|
|
4
4
|
import { cnMerge } from "./cn-s-D7vHW1.js";
|
|
5
5
|
import { isFunction } from "@zayne-labs/toolkit-type-helpers";
|
|
@@ -282,4 +282,4 @@ var carousel_parts_exports = __export({
|
|
|
282
282
|
|
|
283
283
|
//#endregion
|
|
284
284
|
export { CarouselButton, CarouselCaption, CarouselControls, CarouselIndicator, CarouselIndicatorList, CarouselItem, CarouselItemList, CarouselRoot, carousel_parts_exports };
|
|
285
|
-
//# sourceMappingURL=carousel-
|
|
285
|
+
//# sourceMappingURL=carousel-B051PAAX.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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\tCarou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,UAAU,SAAS;IAAE;IAAO;IAAO;IAAO,CAAC;IAAI,GAC5F;GACE;;AAIP,SAAgB,aAAa,OAA2B;CACvD,MAAM,EAAE,UAAU,UAAW,GAAG,gBAAgB;AAEhD,QACC,oBAAC;EACA,cAAW;EACX,aAAU;EACV,aAAU;EACV,WAAW,QAAQ,mDAAmD,UAAU;EAChF,GAAI;EAEH;GACG;;AAIP,SAAgB,gBACf,OACC;CACD,MAAM,EAAE,IAAI,cAAc,OAAO,UAAU,cAAc;AAEzD,QACC,oBAAC;EACA,cAAW;EACX,aAAU;EACV,aAAU;EACV,WAAW,QAAQ,iBAAiB,UAAU;EAE7C;GACY;;AAIhB,SAAgB,sBAAkC,OAAyC;CAC1F,MAAM,EAAE,UAAU,WAAW,SAAS;CAEtC,MAAM,SAAS,yBAAyB,UAAU,QAAS,MAAM,OAAwB;AAEzF,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,4 +1,4 @@
|
|
|
1
|
-
import "../../index-
|
|
2
|
-
import "../../index-
|
|
3
|
-
import { AwaitError, AwaitPending, AwaitRoot, AwaitSuccess, await_parts_d_exports, useAwaitContext } from "../../index-
|
|
1
|
+
import "../../index-BAywimP3.js";
|
|
2
|
+
import "../../index-ATxxr1XS.js";
|
|
3
|
+
import { AwaitError, AwaitPending, AwaitRoot, AwaitSuccess, await_parts_d_exports, useAwaitContext } from "../../index-C889t8UO.js";
|
|
4
4
|
export { await_parts_d_exports as Await, AwaitError, AwaitPending, AwaitRoot, AwaitSuccess, useAwaitContext };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { ErrorBoundary, ErrorBoundaryContextType, ErrorBoundaryProps, FallbackProps, useErrorBoundary, useErrorBoundaryContext } from "../../index-
|
|
1
|
+
import { ErrorBoundary, ErrorBoundaryContextType, ErrorBoundaryProps, FallbackProps, useErrorBoundary, useErrorBoundaryContext } from "../../index-BAywimP3.js";
|
|
2
2
|
export { ErrorBoundary, ErrorBoundaryContextType, ErrorBoundaryProps, FallbackProps, useErrorBoundary, useErrorBoundaryContext };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { For, ForRenderProps, ForWithWrapper, getElementList } from "../../index-
|
|
1
|
+
import { For, ForRenderProps, ForWithWrapper, getElementList } from "../../index-BT0UvcRp.js";
|
|
2
2
|
export { For, ForRenderProps, ForWithWrapper, getElementList };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { ErrorBoundary } from "../index-
|
|
2
|
-
import { SuspenseWithBoundary } from "../index-
|
|
3
|
-
import { await_parts_d_exports } from "../index-
|
|
4
|
-
import { For, ForWithWrapper } from "../index-
|
|
1
|
+
import { ErrorBoundary } from "../index-BAywimP3.js";
|
|
2
|
+
import { SuspenseWithBoundary } from "../index-ATxxr1XS.js";
|
|
3
|
+
import { await_parts_d_exports } from "../index-C889t8UO.js";
|
|
4
|
+
import { For, ForWithWrapper } from "../index-BT0UvcRp.js";
|
|
5
5
|
import { show_parts_d_exports } from "../index-BsGxDKlt.js";
|
|
6
|
-
import { slot_parts_d_exports } from "../index-
|
|
6
|
+
import { slot_parts_d_exports } from "../index-CuJVxLEc.js";
|
|
7
7
|
import { switch_parts_d_exports } from "../index-CffEFE66.js";
|
|
8
8
|
import { Teleport } from "../index-CZjeBSoQ.js";
|
|
9
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
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ErrorBoundary } from "../error-boundary-y9Samt_s.js";
|
|
2
2
|
import { slot_parts_exports } from "../slot-WVWfOlr3.js";
|
|
3
3
|
import { await_parts_exports } from "../await-Da5w2vIc.js";
|
|
4
|
-
import { For, ForWithWrapper } from "../for-
|
|
4
|
+
import { For, ForWithWrapper } from "../for-DK5rEY_m.js";
|
|
5
5
|
import { show_parts_exports } from "../show-N1ZXBhoA.js";
|
|
6
6
|
import { SuspenseWithBoundary } from "../suspense-with-boundary-D-1NYDV4.js";
|
|
7
7
|
import { switch_parts_exports } from "../switch-Ch22z21e.js";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { SlotRoot, SlotSlottable, slot_parts_d_exports } from "../../index-
|
|
1
|
+
import { SlotRoot, SlotSlottable, slot_parts_d_exports } from "../../index-CuJVxLEc.js";
|
|
2
2
|
export { slot_parts_d_exports as Slot, SlotRoot, SlotSlottable };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import "../../index-
|
|
2
|
-
import { SuspenseWithBoundary, SuspenseWithBoundaryProps } from "../../index-
|
|
1
|
+
import "../../index-BAywimP3.js";
|
|
2
|
+
import { SuspenseWithBoundary, SuspenseWithBoundaryProps } from "../../index-ATxxr1XS.js";
|
|
3
3
|
export { SuspenseWithBoundary, SuspenseWithBoundaryProps };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { __export } from "./chunk-CTAAG5j7.js";
|
|
2
2
|
import { SlotRoot } from "./slot-WVWfOlr3.js";
|
|
3
|
-
import { For } from "./for-
|
|
3
|
+
import { For } from "./for-DK5rEY_m.js";
|
|
4
4
|
import { cnMerge } from "./cn-s-D7vHW1.js";
|
|
5
|
-
import { Presence } from "./presence-
|
|
5
|
+
import { Presence } from "./presence-CL5_GHQH.js";
|
|
6
6
|
import { composeRefs, composeTwoEventHandlers } from "@zayne-labs/toolkit-react/utils";
|
|
7
7
|
import { isFile, isFunction, isNumber, isObject, isString } from "@zayne-labs/toolkit-type-helpers";
|
|
8
8
|
import { useCallback, useMemo, useRef } from "react";
|
|
@@ -236,6 +236,11 @@ const createDropZoneStore = (initStoreValues) => {
|
|
|
236
236
|
status: "idle"
|
|
237
237
|
}));
|
|
238
238
|
const store = createStore((set, get) => ({
|
|
239
|
+
disabled: false,
|
|
240
|
+
errors: [],
|
|
241
|
+
fileStateArray: initFileStateArray,
|
|
242
|
+
isDraggingOver: false,
|
|
243
|
+
isInvalid: false,
|
|
239
244
|
actions: {
|
|
240
245
|
addFiles: async (files) => {
|
|
241
246
|
if (!files || files.length === 0) {
|
|
@@ -281,12 +286,19 @@ const createDropZoneStore = (initStoreValues) => {
|
|
|
281
286
|
await actions.handleFileUpload({ newFileStateArray });
|
|
282
287
|
},
|
|
283
288
|
clearErrors: () => {
|
|
284
|
-
set({
|
|
289
|
+
set({
|
|
290
|
+
errors: [],
|
|
291
|
+
isInvalid: false
|
|
292
|
+
});
|
|
285
293
|
},
|
|
286
294
|
clearFiles: () => {
|
|
287
295
|
const { actions } = get();
|
|
288
296
|
actions.clearObjectURLs();
|
|
289
|
-
set({
|
|
297
|
+
set({
|
|
298
|
+
errors: [],
|
|
299
|
+
fileStateArray: [],
|
|
300
|
+
isInvalid: false
|
|
301
|
+
});
|
|
290
302
|
},
|
|
291
303
|
clearObjectURLs: () => {
|
|
292
304
|
const { fileStateArray } = get();
|
|
@@ -418,13 +430,17 @@ const createDropZoneStore = (initStoreValues) => {
|
|
|
418
430
|
});
|
|
419
431
|
set({ fileStateArray: updatedFileStateArray });
|
|
420
432
|
}
|
|
421
|
-
}
|
|
422
|
-
disabled: false,
|
|
423
|
-
errors: [],
|
|
424
|
-
fileStateArray: initFileStateArray,
|
|
425
|
-
isDraggingOver: false
|
|
433
|
+
}
|
|
426
434
|
}));
|
|
427
435
|
store.subscribe.withSelector((state) => state.fileStateArray, (fileStateArray) => onFilesChange?.({ fileStateArray }));
|
|
436
|
+
store.subscribe.withSelector((state) => state.errors, (errors) => {
|
|
437
|
+
if (errors.length === 0) return;
|
|
438
|
+
store.setState({ isInvalid: true });
|
|
439
|
+
});
|
|
440
|
+
store.subscribe.withSelector((state) => state.isInvalid, (isInvalid) => {
|
|
441
|
+
if (!isInvalid) return;
|
|
442
|
+
setTimeout(() => store.setState({ isInvalid: !isInvalid }), 1500);
|
|
443
|
+
});
|
|
428
444
|
return store;
|
|
429
445
|
};
|
|
430
446
|
|
|
@@ -480,6 +496,7 @@ const useDropZone = (props) => {
|
|
|
480
496
|
};
|
|
481
497
|
const isDraggingOver = useDropZoneStore((state) => !disableInternalStateSubscription ? state.isDraggingOver : null);
|
|
482
498
|
const hasFiles = useDropZoneStore((state) => !disableInternalStateSubscription ? state.fileStateArray.length > 0 : null);
|
|
499
|
+
const isInvalid = useDropZoneStore((state) => !disableInternalStateSubscription ? state.isInvalid : null);
|
|
483
500
|
const getContainerProps = useCallback((innerProps) => {
|
|
484
501
|
const isDisabled = disabled;
|
|
485
502
|
const onFileDrop = !isDisabled ? actions.handleDrop : void 0;
|
|
@@ -490,12 +507,16 @@ const useDropZone = (props) => {
|
|
|
490
507
|
return {
|
|
491
508
|
...getScopeAttrs("container"),
|
|
492
509
|
role: "region",
|
|
493
|
-
...!disableInternalStateSubscription && {
|
|
510
|
+
...!disableInternalStateSubscription && {
|
|
511
|
+
"data-drag-over": dataAttr(isDraggingOver),
|
|
512
|
+
"data-invalid": dataAttr(isInvalid)
|
|
513
|
+
},
|
|
494
514
|
...innerProps,
|
|
495
515
|
className: cnMerge(`relative flex flex-col items-center justify-center gap-2 rounded-lg border-2 border-dashed
|
|
496
|
-
p-6 transition-colors outline-none select-none hover:bg-zu-accent/30
|
|
497
|
-
focus-visible:border-zu-ring/50 data-[disabled]:pointer-events-none
|
|
498
|
-
data-[drag-over]:
|
|
516
|
+
p-6 transition-colors duration-250 ease-out outline-none select-none hover:bg-zu-accent/30
|
|
517
|
+
focus-visible:border-zu-ring/50`, `data-[disabled]:pointer-events-none data-[drag-over]:border-zu-primary/30
|
|
518
|
+
data-[drag-over]:bg-zu-accent/30 data-[dragging]:bg-zu-accent/30
|
|
519
|
+
data-[invalid]:border-zu-destructive data-[invalid]:ring-zu-destructive/20`, innerProps.className),
|
|
499
520
|
"data-disabled": dataAttr(isDisabled),
|
|
500
521
|
onClick: composeTwoEventHandlers(onAreaClick, innerProps.onClick),
|
|
501
522
|
onDragEnter: composeTwoEventHandlers(actions.handleDragEnter, innerProps.onDragEnter),
|
|
@@ -517,6 +538,7 @@ const useDropZone = (props) => {
|
|
|
517
538
|
disableInternalStateSubscription,
|
|
518
539
|
disabled,
|
|
519
540
|
isDraggingOver,
|
|
541
|
+
isInvalid,
|
|
520
542
|
shouldOpenFilePickerOnAreaClick
|
|
521
543
|
]);
|
|
522
544
|
const getInputProps = useCallback((innerProps) => {
|
|
@@ -694,9 +716,13 @@ function DropZoneContainer(props) {
|
|
|
694
716
|
const { as: Element = "div", asChild,...restOfProps } = props;
|
|
695
717
|
const { disableInternalStateSubscription, propGetters } = useDropZoneRootContext();
|
|
696
718
|
const isDraggingOver = useDropZoneStoreContext((store) => disableInternalStateSubscription ? store.isDraggingOver : null);
|
|
719
|
+
const isInvalid = useDropZoneStoreContext((store) => disableInternalStateSubscription ? store.isInvalid : null);
|
|
697
720
|
const Component$1 = asChild ? SlotRoot : Element;
|
|
698
721
|
return /* @__PURE__ */ jsx(Component$1, { ...propGetters.getContainerProps({
|
|
699
|
-
...disableInternalStateSubscription && {
|
|
722
|
+
...disableInternalStateSubscription && {
|
|
723
|
+
"data-drag-over": dataAttr(isDraggingOver),
|
|
724
|
+
"data-invalid": dataAttr(isInvalid)
|
|
725
|
+
},
|
|
700
726
|
...restOfProps
|
|
701
727
|
}) });
|
|
702
728
|
}
|
|
@@ -984,4 +1010,4 @@ var drop_zone_parts_exports = __export({
|
|
|
984
1010
|
|
|
985
1011
|
//#endregion
|
|
986
1012
|
export { DropZoneArea, DropZoneContainer, DropZoneContext, DropZoneError, DropZoneFileClear, DropZoneFileItem, DropZoneFileItemDelete, DropZoneFileItemMetadata, DropZoneFileItemPreview, DropZoneFileItemProgress, DropZoneFileList, DropZoneInput, DropZoneRoot, DropZoneTrigger, drop_zone_parts_exports, useDropZone, useDropZoneStoreContext };
|
|
987
|
-
//# sourceMappingURL=drop-zone-
|
|
1013
|
+
//# sourceMappingURL=drop-zone-C9VpKJAD.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"drop-zone-C9VpKJAD.js","names":["generateFileID","generateFileIDPrimitive","initFileStateArray: DropZoneState[\"fileStateArray\"]","newFileStateArray: DropZoneState[\"fileStateArray\"]","generateFileID","updatedFileStateArray: DropZoneState[\"fileStateArray\"]","useDropZoneStore: UseDropZoneResult[\"useDropZoneStore\"]","getContainerProps: UseDropZoneResult[\"propGetters\"][\"getContainerProps\"]","getInputProps: UseDropZoneResult[\"propGetters\"][\"getInputProps\"]","getTriggerProps: UseDropZoneResult[\"propGetters\"][\"getTriggerProps\"]","getFileListProps: UseDropZoneResult[\"propGetters\"][\"getFileListProps\"]","getFileItemProps: UseDropZoneResult[\"propGetters\"][\"getFileItemProps\"]","getFileItemProgressProps: UseDropZoneResult[\"propGetters\"][\"getFileItemProgressProps\"]","getFileItemDeleteProps: UseDropZoneResult[\"propGetters\"][\"getFileItemDeleteProps\"]","getFileItemPreviewProps: UseDropZoneResult[\"propGetters\"][\"getFileItemPreviewProps\"]","getFileItemMetadataProps: UseDropZoneResult[\"propGetters\"][\"getFileItemMetadataProps\"]","getFileItemClearProps: UseDropZoneResult[\"propGetters\"][\"getFileItemClearProps\"]","Component","Slot.Root"],"sources":["../../src/components/ui/drop-zone/drop-zone-context.ts","../../src/components/ui/drop-zone/icons.tsx","../../src/components/ui/drop-zone/utils.ts","../../src/components/ui/drop-zone/drop-zone-store.ts","../../src/components/ui/drop-zone/use-drop-zone.ts","../../src/components/ui/drop-zone/drop-zone.tsx","../../src/components/ui/drop-zone/drop-zone-parts.ts"],"sourcesContent":["import { createCustomContext } from \"@zayne-labs/toolkit-react\";\nimport { createZustandContext } from \"@zayne-labs/toolkit-react/zustand\";\nimport type { DropZoneStore } from \"./drop-zone-store\";\nimport type { FileState, UseDropZoneResult } from \"./types\";\n\nconst [DropZoneStoreContextProvider, useDropZoneStoreContext] = createZustandContext<DropZoneStore>({\n\thookName: \"useDropZoneStoreContext\",\n\tname: \"DropZoneStoreContext\",\n\tproviderName: \"DropZoneRoot\",\n});\n\nexport type DropZoneRootContextType = Pick<\n\tUseDropZoneResult,\n\t\"disabled\" | \"disableInternalStateSubscription\" | \"inputRef\" | \"propGetters\"\n>;\n\nconst [DropZoneRootContextProvider, useDropZoneRootContext] = createCustomContext<DropZoneRootContextType>(\n\t{\n\t\thookName: \"useDropZoneRootContext\",\n\t\tname: \"DropZoneRootContext\",\n\t\tproviderName: \"DropZoneRoot\",\n\t}\n);\n\nexport type FileItemContextType = {\n\tfileState: FileState | undefined;\n};\n\nconst [FileItemContextProvider, useFileItemContext] = createCustomContext({\n\tdefaultValue: null as unknown as FileItemContextType,\n\thookName: \"useFileItemContext\",\n\tname: \"FileItemContext\",\n\tproviderName: \"FileItem\",\n\tstrict: false,\n});\n\nexport {\n\tDropZoneRootContextProvider,\n\tDropZoneStoreContextProvider,\n\tFileItemContextProvider,\n\tuseDropZoneRootContext,\n\tuseDropZoneStoreContext,\n\tuseFileItemContext,\n};\n","import * as React from \"react\";\n\nexport const FileVideoIcon = (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{/* Icon from Lucide by Lucide Contributors - https://github.com/lucide-icons/lucide/blob/main/LICENSE */}\n\t\t<g fill=\"none\" stroke=\"currentColor\" strokeLinecap=\"round\" strokeLinejoin=\"round\" strokeWidth=\"2\">\n\t\t\t<path d=\"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z\" />\n\t\t\t<path d=\"M14 2v4a2 2 0 0 0 2 2h4m-10 3l5 3l-5 3z\" />\n\t\t</g>\n\t</svg>\n);\n\nexport const FileAudioIcon = (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{/* Icon from Lucide by Lucide Contributors - https://github.com/lucide-icons/lucide/blob/main/LICENSE */}\n\t\t<g fill=\"none\" stroke=\"currentColor\" strokeLinecap=\"round\" strokeLinejoin=\"round\" strokeWidth=\"2\">\n\t\t\t<path d=\"M17.5 22h.5a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v3\" />\n\t\t\t<path d=\"M14 2v4a2 2 0 0 0 2 2h4M2 19a2 2 0 1 1 4 0v1a2 2 0 1 1-4 0v-4a6 6 0 0 1 12 0v4a2 2 0 1 1-4 0v-1a2 2 0 1 1 4 0\" />\n\t\t</g>\n\t</svg>\n);\n\nexport const FileTextIcon = (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{/* Icon from Lucide by Lucide Contributors - https://github.com/lucide-icons/lucide/blob/main/LICENSE */}\n\t\t<g fill=\"none\" stroke=\"currentColor\" strokeLinecap=\"round\" strokeLinejoin=\"round\" strokeWidth=\"2\">\n\t\t\t<path d=\"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z\" />\n\t\t\t<path d=\"M14 2v4a2 2 0 0 0 2 2h4M10 9H8m8 4H8m8 4H8\" />\n\t\t</g>\n\t</svg>\n);\n\nexport const FileCodeIcon = (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{/* Icon from Lucide by Lucide Contributors - https://github.com/lucide-icons/lucide/blob/main/LICENSE */}\n\t\t<g fill=\"none\" stroke=\"currentColor\" strokeLinecap=\"round\" strokeLinejoin=\"round\" strokeWidth=\"2\">\n\t\t\t<path d=\"M10 12.5L8 15l2 2.5m4-5l2 2.5l-2 2.5M14 2v4a2 2 0 0 0 2 2h4\" />\n\t\t\t<path d=\"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7z\" />\n\t\t</g>\n\t</svg>\n);\n\nexport const FileArchiveIcon = (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{/* Icon from Lucide by Lucide Contributors - https://github.com/lucide-icons/lucide/blob/main/LICENSE */}\n\t\t<g fill=\"none\" stroke=\"currentColor\" strokeLinecap=\"round\" strokeLinejoin=\"round\" strokeWidth=\"2\">\n\t\t\t<path d=\"M10 12v-1m0 7v-2m0-9V6m4-4v4a2 2 0 0 0 2 2h4\" />\n\t\t\t<path d=\"M15.5 22H18a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v16a2 2 0 0 0 .274 1.01\" />\n\t\t\t<circle cx=\"10\" cy=\"20\" r=\"2\" />\n\t\t</g>\n\t</svg>\n);\n\nexport const FileCogIcon = (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{/* Icon from Lucide by Lucide Contributors - https://github.com/lucide-icons/lucide/blob/main/LICENSE */}\n\t\t<g fill=\"none\" stroke=\"currentColor\" strokeLinecap=\"round\" strokeLinejoin=\"round\" strokeWidth=\"2\">\n\t\t\t<path d=\"M14 2v4a2 2 0 0 0 2 2h4M3.2 12.9l-.9-.4m.9 2.6l-.9.4\" />\n\t\t\t<path d=\"M4.677 21.5a2 2 0 0 0 1.313.5H18a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v2.5m.9 4.7l-.4-.9m.4 6.5l-.4.9m3-7.4l-.4.9m.4 6.5l-.4-.9m2.6-4.3l-.9.4m.9 2.6l-.9-.4\" />\n\t\t\t<circle cx=\"6\" cy=\"14\" r=\"3\" />\n\t\t</g>\n\t</svg>\n);\n\nexport const FileIcon = (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{/* Icon from Lucide by Lucide Contributors - https://github.com/lucide-icons/lucide/blob/main/LICENSE */}\n\t\t<g fill=\"none\" stroke=\"currentColor\" strokeLinecap=\"round\" strokeLinejoin=\"round\" strokeWidth=\"2\">\n\t\t\t<path d=\"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z\" />\n\t\t\t<path d=\"M14 2v4a2 2 0 0 0 2 2h4\" />\n\t\t</g>\n\t</svg>\n);\n","import {\n\tcreateFileUrl,\n\ttype FileOrFileMeta,\n\ttype FileValidationErrorContextEach,\n\tgenerateFileID as generateFileIDPrimitive,\n} from \"@zayne-labs/toolkit-core\";\nimport { isFile, isObject, isString } from \"@zayne-labs/toolkit-type-helpers\";\nimport type { FileState, FileStateOrIDProp, PartProps } from \"./types\";\n\nexport const generateFileID = generateFileIDPrimitive;\n\nexport const createObjectURL = (\n\tfile: FileOrFileMeta,\n\tdisallowPreviewForNonImageFiles: boolean | undefined\n) => {\n\tif (disallowPreviewForNonImageFiles && !file.type?.startsWith(\"image/\")) return;\n\n\treturn createFileUrl(file);\n};\n\nexport const clearObjectURL = (\n\tfileState: FileState | undefined,\n\tdisallowPreviewForNonImageFiles: boolean | undefined\n) => {\n\tif (!isFile(fileState?.file)) return;\n\n\tif (disallowPreviewForNonImageFiles && !fileState.file.type.startsWith(\"image/\")) return;\n\n\tif (!fileState.preview) return;\n\n\tURL.revokeObjectURL(fileState.preview);\n};\n\nexport const isMatchingFile = (\n\toptions: FileStateOrIDProp & {\n\t\tfileState: FileOrFileMeta | FileState;\n\t}\n) => {\n\tconst { fileState, fileStateOrID } = options;\n\n\tconst fileID = isFile(fileState) ? generateFileID(fileState) : fileState.id;\n\n\tif (isString(fileStateOrID)) {\n\t\treturn fileID === fileStateOrID;\n\t}\n\n\tif (isFile(fileStateOrID)) {\n\t\tconst generatedFileID = generateFileID(fileStateOrID);\n\t\treturn fileID === generatedFileID;\n\t}\n\n\treturn fileID === fileStateOrID.id;\n};\n\ntype FromCamelToKebabCase<TString extends string> =\n\tTString extends `${infer First}${infer Rest}` ?\n\t\tFirst extends Uppercase<First> ?\n\t\t\t`-${Lowercase<First>}${FromCamelToKebabCase<Rest>}`\n\t\t:\t`${First}${FromCamelToKebabCase<Rest>}`\n\t:\t\"\";\n\nexport const getScopeAttrs = (part: FromCamelToKebabCase<keyof PartProps>) => {\n\treturn {\n\t\t/* eslint-disable perfectionist/sort-objects -- I need this order to be maintained */\n\t\t\"data-slot\": `dropzone-${part}`,\n\t\t\"data-scope\": \"dropzone\",\n\t\t\"data-part\": part,\n\t\t/* eslint-enable perfectionist/sort-objects -- I need this order to be maintained */\n\t} as const;\n};\n\nconst dropZoneErrorSymbol = Symbol(\"DropZoneError\");\n\nexport class DropZoneError extends Error {\n\treadonly dropZoneErrorSymbol = dropZoneErrorSymbol;\n\tfile?: FileValidationErrorContextEach[\"file\"];\n\toverride name = \"DropZoneError\" as const;\n\n\tconstructor(\n\t\tctx: Pick<FileValidationErrorContextEach, \"message\"> & {\n\t\t\tfile?: FileValidationErrorContextEach[\"file\"];\n\t\t}\n\t) {\n\t\tconst { file, message } = ctx;\n\n\t\tsuper(message);\n\n\t\tthis.file = file;\n\t}\n\n\tstatic override isError(error: unknown): error is DropZoneError {\n\t\tif (!isObject<DropZoneError>(error)) {\n\t\t\treturn false;\n\t\t}\n\n\t\tif (error instanceof DropZoneError) {\n\t\t\treturn true;\n\t\t}\n\n\t\tconst actualError = error as DropZoneError;\n\n\t\treturn (\n\t\t\tactualError.dropZoneErrorSymbol === dropZoneErrorSymbol\n\t\t\t// eslint-disable-next-line ts-eslint/no-unnecessary-condition -- Allow\n\t\t\t&& actualError.name === \"DropZoneError\"\n\t\t);\n\t}\n}\n\nexport const getErrorContext = (error: DropZoneError | Error): NonNullable<FileState[\"error\"]> => {\n\tif (DropZoneError.isError(error)) {\n\t\treturn {\n\t\t\tcause: \"custom-error\",\n\t\t\tcode: \"upload-error\",\n\t\t\tfile: error.file ?? ({} as never),\n\t\t\tmessage: error.message,\n\t\t\toriginalError: error.cause ?? error,\n\t\t};\n\t}\n\n\tconst actualError = Error.isError(error) ? error : new Error(\"File upload failed\", { cause: error });\n\n\treturn {\n\t\tcause: \"custom-error\",\n\t\tcode: \"upload-error\",\n\t\tfile: isFile(actualError.cause) ? actualError.cause : ({} as never),\n\t\tmessage: Error.isError(error) ? actualError.message : String(actualError),\n\t\toriginalError: actualError,\n\t};\n};\n","import { createStore, handleFileValidationAsync, toArray } from \"@zayne-labs/toolkit-core\";\nimport { isString } from \"@zayne-labs/toolkit-type-helpers\";\nimport type { DropZoneActions, DropZoneState, UseDropZoneProps } from \"./types\";\nimport { clearObjectURL, createObjectURL, generateFileID, getErrorContext, isMatchingFile } from \"./utils\";\n\nexport type DropZoneStore = DropZoneActions & DropZoneState;\n\ntype RequiredUseDropZoneProps = {\n\t[Key in keyof Required<UseDropZoneProps>]: UseDropZoneProps[Key] | undefined;\n};\n\ntype InitStoreValues = Omit<\n\tRequiredUseDropZoneProps,\n\t\"disabled\" | \"disableInternalStateSubscription\" | \"extraProps\" | \"shouldOpenFilePickerOnAreaClick\"\n> & { inputRef: React.RefObject<HTMLInputElement | null> };\n\nexport const createDropZoneStore = (initStoreValues: InitStoreValues) => {\n\tconst {\n\t\tallowedFileTypes,\n\t\tdisablePreviewForNonImageFiles,\n\t\tinitialFiles,\n\t\tinputRef,\n\t\tmaxFileCount,\n\t\tmaxFileSize,\n\t\tmultiple,\n\t\tonFilesChange,\n\t\tonUpload,\n\t\tonValidationError,\n\t\tonValidationSuccess,\n\t\trejectDuplicateFiles,\n\t\tvalidator,\n\t} = initStoreValues;\n\n\tconst initialFileArray = toArray(initialFiles).filter(Boolean);\n\n\tconst clearInputValue = () => {\n\t\tif (!inputRef.current) return;\n\n\t\tinputRef.current.value = \"\";\n\t};\n\n\tconst initFileStateArray: DropZoneState[\"fileStateArray\"] = initialFileArray.map((fileMeta) => ({\n\t\tfile: fileMeta,\n\t\tid: fileMeta.id,\n\t\tpreview: isString(fileMeta.url) ? fileMeta.url : undefined,\n\t\tprogress: 0,\n\t\tstatus: \"idle\",\n\t}));\n\n\tconst store = createStore<DropZoneStore>((set, get) => ({\n\t\tdisabled: false,\n\t\terrors: [],\n\t\tfileStateArray: initFileStateArray,\n\t\tisDraggingOver: false,\n\t\tisInvalid: false,\n\n\t\t// eslint-disable-next-line perfectionist/sort-objects -- ignore\n\t\tactions: {\n\t\t\taddFiles: async (files) => {\n\t\t\t\tif (!files || files.length === 0) {\n\t\t\t\t\tconsole.warn(\"No file selected!\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst { actions, fileStateArray } = get();\n\n\t\t\t\t// == In single file mode, only use the first file\n\t\t\t\tconst resolvedNewFiles = !multiple ? [files[0]] : files;\n\n\t\t\t\tconst { errors, validFiles } = await handleFileValidationAsync({\n\t\t\t\t\texistingFiles: fileStateArray.map((fileWithPreview) => fileWithPreview.file),\n\t\t\t\t\thooks: {\n\t\t\t\t\t\tonErrorEach: onValidationError,\n\t\t\t\t\t\tonSuccessBatch: onValidationSuccess,\n\t\t\t\t\t},\n\t\t\t\t\tnewFiles: resolvedNewFiles,\n\t\t\t\t\tsettings: {\n\t\t\t\t\t\tallowedFileTypes,\n\t\t\t\t\t\tmaxFileCount,\n\t\t\t\t\t\tmaxFileSize,\n\t\t\t\t\t\trejectDuplicateFiles,\n\t\t\t\t\t\tvalidator,\n\t\t\t\t\t},\n\t\t\t\t});\n\n\t\t\t\tif (validFiles.length === 0) {\n\t\t\t\t\tset({ errors, isDraggingOver: false });\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst newFileStateArray: DropZoneState[\"fileStateArray\"] = validFiles.map((file) => ({\n\t\t\t\t\tfile,\n\t\t\t\t\tid: generateFileID(file),\n\t\t\t\t\tpreview: createObjectURL(file, disablePreviewForNonImageFiles),\n\t\t\t\t\tprogress: 0,\n\t\t\t\t\tstatus: \"idle\",\n\t\t\t\t}));\n\n\t\t\t\tset({\n\t\t\t\t\terrors,\n\t\t\t\t\tfileStateArray: !multiple ? newFileStateArray : [...fileStateArray, ...newFileStateArray],\n\t\t\t\t\tisDraggingOver: false,\n\t\t\t\t});\n\n\t\t\t\tawait actions.handleFileUpload({ newFileStateArray });\n\t\t\t},\n\n\t\t\tclearErrors: () => {\n\t\t\t\tset({ errors: [], isInvalid: false });\n\t\t\t},\n\n\t\t\tclearFiles: () => {\n\t\t\t\tconst { actions } = get();\n\n\t\t\t\tactions.clearObjectURLs();\n\n\t\t\t\tset({ errors: [], fileStateArray: [], isInvalid: false });\n\t\t\t},\n\n\t\t\tclearObjectURLs: () => {\n\t\t\t\tconst { fileStateArray } = get();\n\n\t\t\t\tfor (const fileState of fileStateArray) {\n\t\t\t\t\tclearObjectURL(fileState, disablePreviewForNonImageFiles);\n\t\t\t\t}\n\t\t\t},\n\n\t\t\thandleChange: async (event) => {\n\t\t\t\tconst fileList = event.target.files;\n\n\t\t\t\tconst { actions } = get();\n\n\t\t\t\tawait actions.addFiles(fileList);\n\n\t\t\t\tclearInputValue();\n\t\t\t},\n\n\t\t\thandleDragEnter: (event) => {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tevent.stopPropagation();\n\n\t\t\t\tset({ isDraggingOver: true });\n\t\t\t},\n\n\t\t\thandleDragLeave: (event) => {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tevent.stopPropagation();\n\n\t\t\t\tset({ isDraggingOver: false });\n\t\t\t},\n\n\t\t\thandleDragOver: (event) => {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tevent.stopPropagation();\n\t\t\t},\n\n\t\t\thandleDrop: async (event) => {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tevent.stopPropagation();\n\n\t\t\t\tconst { actions } = get();\n\n\t\t\t\tconst fileList = event.dataTransfer.files;\n\n\t\t\t\tawait actions.addFiles(fileList);\n\t\t\t},\n\n\t\t\thandleFileUpload: async (context) => {\n\t\t\t\tconst { newFileStateArray } = context;\n\n\t\t\t\tconst { actions } = get();\n\n\t\t\t\tif (!onUpload) {\n\t\t\t\t\tfor (const fileState of newFileStateArray) {\n\t\t\t\t\t\tactions.updateFileState({ fileStateOrID: fileState, progress: 100, status: \"success\" });\n\t\t\t\t\t}\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\ttry {\n\t\t\t\t\tawait onUpload({\n\t\t\t\t\t\tfileStateArray: newFileStateArray,\n\t\t\t\t\t\tonError: (ctx) => {\n\t\t\t\t\t\t\tconst { error, fileStateOrID } = ctx;\n\n\t\t\t\t\t\t\tconst errorContext = getErrorContext(error);\n\n\t\t\t\t\t\t\tactions.updateFileState({ error: errorContext, fileStateOrID, status: \"error\" });\n\t\t\t\t\t\t},\n\t\t\t\t\t\tonProgress: (ctx) => {\n\t\t\t\t\t\t\tconst { fileStateOrID, progress } = ctx;\n\n\t\t\t\t\t\t\tactions.updateFileState({ fileStateOrID, progress });\n\t\t\t\t\t\t},\n\t\t\t\t\t\tonSuccess: (ctx) => {\n\t\t\t\t\t\t\tconst { fileStateOrID } = ctx;\n\n\t\t\t\t\t\t\tactions.updateFileState({ fileStateOrID, progress: 100, status: \"success\" });\n\t\t\t\t\t\t},\n\t\t\t\t\t});\n\n\t\t\t\t\t// Handle Errors\n\t\t\t\t} catch (error) {\n\t\t\t\t\tconst errorContext = getErrorContext(error as Error);\n\n\t\t\t\t\tfor (const fileState of newFileStateArray) {\n\t\t\t\t\t\tactions.updateFileState({\n\t\t\t\t\t\t\terror: errorContext,\n\t\t\t\t\t\t\tfileStateOrID: fileState,\n\t\t\t\t\t\t\tstatus: \"error\",\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\n\t\t\t\t\t// set((prevState) => ({ errors: [...prevState.errors, errorContext] }));\n\t\t\t\t}\n\t\t\t},\n\n\t\t\thandleKeyDown: (event) => {\n\t\t\t\tconst isEnterKey = event.key === \"Enter\";\n\t\t\t\tconst isSpaceKey = event.key === \" \";\n\n\t\t\t\tconst isAllowedKey = isEnterKey || isSpaceKey;\n\n\t\t\t\tif (!isAllowedKey) return;\n\n\t\t\t\tevent.preventDefault();\n\n\t\t\t\tconst { actions } = get();\n\n\t\t\t\tactions.openFilePicker();\n\t\t\t},\n\n\t\t\thandlePaste: async (event) => {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tevent.stopPropagation();\n\n\t\t\t\tconst { actions } = get();\n\n\t\t\t\tconst fileList = event.clipboardData.files;\n\n\t\t\t\tawait actions.addFiles(fileList);\n\t\t\t},\n\n\t\t\topenFilePicker: () => {\n\t\t\t\tinputRef.current?.click();\n\t\t\t},\n\n\t\t\tremoveFile: (ctx) => {\n\t\t\t\tconst { fileStateOrID } = ctx;\n\n\t\t\t\tconst { fileStateArray } = get();\n\n\t\t\t\tconst updatedFileStateArray = fileStateArray.flatMap((fileState) => {\n\t\t\t\t\tif (isMatchingFile({ fileState, fileStateOrID })) {\n\t\t\t\t\t\tclearObjectURL(fileState, disablePreviewForNonImageFiles);\n\n\t\t\t\t\t\treturn [];\n\t\t\t\t\t}\n\n\t\t\t\t\treturn fileState;\n\t\t\t\t});\n\n\t\t\t\tset({ errors: [], fileStateArray: updatedFileStateArray });\n\t\t\t},\n\n\t\t\tupdateFileState: (ctx) => {\n\t\t\t\tconst { fileStateOrID, ...updatedFileState } = ctx;\n\n\t\t\t\tconst { fileStateArray } = get();\n\n\t\t\t\tconst updatedFileStateArray: DropZoneState[\"fileStateArray\"] = fileStateArray.map(\n\t\t\t\t\t(fileState) => {\n\t\t\t\t\t\tif (isMatchingFile({ fileState, fileStateOrID })) {\n\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t...fileState,\n\t\t\t\t\t\t\t\t...updatedFileState,\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn fileState;\n\t\t\t\t\t}\n\t\t\t\t);\n\n\t\t\t\t// const updatedErrorsState =\n\t\t\t\t// \tupdatedFileState.error ?\n\t\t\t\t// \t\t{ errors: [...errors, updatedFileState.error] satisfies DropZoneState[\"errors\"] }\n\t\t\t\t// \t:\tnull;\n\n\t\t\t\tset({ fileStateArray: updatedFileStateArray });\n\t\t\t},\n\t\t},\n\t}));\n\n\t// == File change subscription\n\tstore.subscribe.withSelector(\n\t\t(state) => state.fileStateArray,\n\t\t(fileStateArray) => onFilesChange?.({ fileStateArray })\n\t);\n\n\t// == Set `isInvalid` to true if there are errors\n\tstore.subscribe.withSelector(\n\t\t(state) => state.errors,\n\t\t(errors) => {\n\t\t\tif (errors.length === 0) return;\n\n\t\t\tstore.setState({ isInvalid: true });\n\t\t}\n\t);\n\n\t// == Update `isInvalid` to false after 1.5 seconds\n\tstore.subscribe.withSelector(\n\t\t(state) => state.isInvalid,\n\t\t(isInvalid) => {\n\t\t\tif (!isInvalid) return;\n\n\t\t\tsetTimeout(() => store.setState({ isInvalid: !isInvalid }), 1500);\n\t\t}\n\t);\n\n\treturn store;\n};\n","import { dataAttr } from \"@zayne-labs/toolkit-core\";\nimport {\n\tuseCallbackRef,\n\tuseConstant,\n\tuseShallowCompValue,\n\tuseStore,\n\tuseUnmountEffect,\n} from \"@zayne-labs/toolkit-react\";\nimport { composeRefs, composeTwoEventHandlers } from \"@zayne-labs/toolkit-react/utils\";\nimport { useCallback, useMemo, useRef } from \"react\";\nimport { cnMerge } from \"@/lib/utils/cn\";\nimport { createDropZoneStore } from \"./drop-zone-store\";\nimport type { DropZonePropGetters, UseDropZoneProps, UseDropZoneResult } from \"./types\";\nimport { getScopeAttrs } from \"./utils\";\n\nexport const useDropZone = (props?: UseDropZoneProps): UseDropZoneResult => {\n\tconst {\n\t\tallowedFileTypes,\n\t\tdisabled = false,\n\t\tdisableInternalStateSubscription = false,\n\t\tdisablePreviewForNonImageFiles = true,\n\t\tinitialFiles,\n\t\tmaxFileCount,\n\t\tmaxFileSize,\n\t\tmultiple,\n\t\tonFilesChange,\n\t\tonUpload,\n\t\tonValidationError,\n\t\tonValidationSuccess,\n\t\trejectDuplicateFiles = true,\n\t\tshouldOpenFilePickerOnAreaClick = true,\n\t\tvalidator,\n\t} = props ?? {};\n\n\tconst inputRef = useRef<HTMLInputElement>(null);\n\n\tconst savedOnFilesChange = useCallbackRef(onFilesChange);\n\tconst savedOnUpload = useCallbackRef(onUpload);\n\tconst savedOnUploadError = useCallbackRef(onValidationError);\n\tconst savedOnUploadSuccess = useCallbackRef(onValidationSuccess);\n\tconst savedValidator = useCallbackRef(validator);\n\n\tconst constantInitialFiles = useConstant(() => initialFiles);\n\tconst shallowComparedMaxFileSize = useShallowCompValue(maxFileSize);\n\tconst shallowComparedAllowedFileTypes = useShallowCompValue(allowedFileTypes);\n\n\tconst storeApi = useMemo(() => {\n\t\treturn createDropZoneStore({\n\t\t\tallowedFileTypes: shallowComparedAllowedFileTypes,\n\t\t\tdisablePreviewForNonImageFiles,\n\t\t\tinitialFiles: constantInitialFiles,\n\t\t\tinputRef,\n\t\t\tmaxFileCount,\n\t\t\tmaxFileSize: shallowComparedMaxFileSize,\n\t\t\tmultiple,\n\t\t\tonFilesChange: savedOnFilesChange,\n\t\t\tonUpload: savedOnUpload,\n\t\t\tonValidationError: savedOnUploadError,\n\t\t\tonValidationSuccess: savedOnUploadSuccess,\n\t\t\trejectDuplicateFiles,\n\t\t\tvalidator: savedValidator,\n\t\t});\n\t}, [\n\t\tshallowComparedAllowedFileTypes,\n\t\tdisablePreviewForNonImageFiles,\n\t\tconstantInitialFiles,\n\t\tmaxFileCount,\n\t\tshallowComparedMaxFileSize,\n\t\tmultiple,\n\t\tsavedOnFilesChange,\n\t\tsavedOnUpload,\n\t\tsavedOnUploadError,\n\t\tsavedOnUploadSuccess,\n\t\trejectDuplicateFiles,\n\t\tsavedValidator,\n\t]);\n\n\tconst actions = storeApi.getState().actions;\n\n\tuseUnmountEffect(() => {\n\t\tactions.clearObjectURLs();\n\t});\n\n\tconst useDropZoneStore: UseDropZoneResult[\"useDropZoneStore\"] = (selector) => {\n\t\treturn useStore(storeApi, selector);\n\t};\n\n\tconst isDraggingOver = useDropZoneStore((state) =>\n\t\t!disableInternalStateSubscription ? state.isDraggingOver : null\n\t);\n\n\tconst hasFiles = useDropZoneStore((state) =>\n\t\t!disableInternalStateSubscription ? state.fileStateArray.length > 0 : null\n\t);\n\n\tconst isInvalid = useDropZoneStore((state) =>\n\t\t!disableInternalStateSubscription ? state.isInvalid : null\n\t);\n\n\tconst getContainerProps: UseDropZoneResult[\"propGetters\"][\"getContainerProps\"] = useCallback(\n\t\t(innerProps) => {\n\t\t\tconst isDisabled = disabled;\n\t\t\tconst onFileDrop = !isDisabled ? actions.handleDrop : undefined;\n\t\t\tconst onFilePaste = !isDisabled ? actions.handlePaste : undefined;\n\t\t\tconst onKeyDown = !isDisabled ? actions.handleKeyDown : undefined;\n\t\t\tconst tabIndex = !isDisabled ? 0 : undefined;\n\t\t\tconst onAreaClick =\n\t\t\t\t!isDisabled && shouldOpenFilePickerOnAreaClick ? actions.openFilePicker : undefined;\n\n\t\t\treturn {\n\t\t\t\t...getScopeAttrs(\"container\"),\n\t\t\t\trole: \"region\",\n\t\t\t\t...(!disableInternalStateSubscription && {\n\t\t\t\t\t\"data-drag-over\": dataAttr(isDraggingOver),\n\t\t\t\t\t\"data-invalid\": dataAttr(isInvalid),\n\t\t\t\t}),\n\t\t\t\t...innerProps,\n\t\t\t\tclassName: cnMerge(\n\t\t\t\t\t`relative flex flex-col items-center justify-center gap-2 rounded-lg border-2 border-dashed\n\t\t\t\t\tp-6 transition-colors duration-250 ease-out outline-none select-none hover:bg-zu-accent/30\n\t\t\t\t\tfocus-visible:border-zu-ring/50`,\n\t\t\t\t\t`data-[disabled]:pointer-events-none data-[drag-over]:border-zu-primary/30\n\t\t\t\t\tdata-[drag-over]:bg-zu-accent/30 data-[dragging]:bg-zu-accent/30\n\t\t\t\t\tdata-[invalid]:border-zu-destructive data-[invalid]:ring-zu-destructive/20`,\n\t\t\t\t\tinnerProps.className\n\t\t\t\t),\n\t\t\t\t\"data-disabled\": dataAttr(isDisabled),\n\t\t\t\tonClick: composeTwoEventHandlers(onAreaClick, innerProps.onClick),\n\t\t\t\tonDragEnter: composeTwoEventHandlers(actions.handleDragEnter, innerProps.onDragEnter),\n\t\t\t\tonDragLeave: composeTwoEventHandlers(actions.handleDragLeave, innerProps.onDragLeave),\n\t\t\t\tonDragOver: composeTwoEventHandlers(actions.handleDragOver, innerProps.onDragOver),\n\t\t\t\tonDrop: composeTwoEventHandlers(onFileDrop, innerProps.onDrop),\n\t\t\t\tonKeyDown: composeTwoEventHandlers(onKeyDown, innerProps.onKeyDown),\n\t\t\t\tonPaste: composeTwoEventHandlers(onFilePaste, innerProps.onPaste),\n\t\t\t\ttabIndex,\n\t\t\t};\n\t\t},\n\t\t[\n\t\t\tactions.handleDragEnter,\n\t\t\tactions.handleDragLeave,\n\t\t\tactions.handleDragOver,\n\t\t\tactions.handleDrop,\n\t\t\tactions.handleKeyDown,\n\t\t\tactions.handlePaste,\n\t\t\tactions.openFilePicker,\n\t\t\tdisableInternalStateSubscription,\n\t\t\tdisabled,\n\t\t\tisDraggingOver,\n\t\t\tisInvalid,\n\t\t\tshouldOpenFilePickerOnAreaClick,\n\t\t]\n\t);\n\n\tconst getInputProps: UseDropZoneResult[\"propGetters\"][\"getInputProps\"] = useCallback(\n\t\t(innerProps) => {\n\t\t\tconst isDisabled = innerProps.disabled ?? disabled;\n\n\t\t\tconst onFileChange = !isDisabled ? actions.handleChange : undefined;\n\n\t\t\treturn {\n\t\t\t\t...getScopeAttrs(\"input\"),\n\t\t\t\t...(!disableInternalStateSubscription && { \"data-drag-over\": dataAttr(isDraggingOver) }),\n\t\t\t\t...innerProps,\n\t\t\t\taccept: allowedFileTypes ? allowedFileTypes.join(\", \") : innerProps.accept,\n\t\t\t\tclassName: cnMerge(\"hidden\", innerProps.className),\n\t\t\t\t\"data-disabled\": dataAttr(isDisabled),\n\t\t\t\tdisabled: isDisabled,\n\t\t\t\tmultiple: multiple ?? innerProps.multiple,\n\t\t\t\tonChange: composeTwoEventHandlers(onFileChange, innerProps.onChange),\n\t\t\t\tref: composeRefs(inputRef, innerProps.ref),\n\t\t\t\ttype: \"file\",\n\t\t\t};\n\t\t},\n\t\t[\n\t\t\tactions.handleChange,\n\t\t\tallowedFileTypes,\n\t\t\tdisableInternalStateSubscription,\n\t\t\tdisabled,\n\t\t\tisDraggingOver,\n\t\t\tmultiple,\n\t\t]\n\t);\n\n\tconst getTriggerProps: UseDropZoneResult[\"propGetters\"][\"getTriggerProps\"] = useCallback(\n\t\t(innerProps) => {\n\t\t\tconst isDisabled = innerProps.disabled ?? disabled;\n\n\t\t\treturn {\n\t\t\t\t...getScopeAttrs(\"trigger\"),\n\t\t\t\ttype: \"button\",\n\t\t\t\t...innerProps,\n\t\t\t\t\"data-disabled\": dataAttr(isDisabled),\n\t\t\t\tdisabled: isDisabled,\n\t\t\t\tonClick: composeTwoEventHandlers(actions.openFilePicker, innerProps.onClick),\n\t\t\t};\n\t\t},\n\t\t[actions.openFilePicker, disabled]\n\t);\n\n\tconst getFileListProps: UseDropZoneResult[\"propGetters\"][\"getFileListProps\"] = useCallback(\n\t\t(innerProps) => {\n\t\t\tconst { orientation = \"vertical\", ...restOfInnerProps } = innerProps;\n\n\t\t\treturn {\n\t\t\t\t...getScopeAttrs(\"file-list\"),\n\t\t\t\t\"data-orientation\": orientation,\n\t\t\t\t...(!disableInternalStateSubscription && { \"data-state\": hasFiles ? \"active\" : \"inactive\" }),\n\t\t\t\t...restOfInnerProps,\n\t\t\t\tclassName: cnMerge(\n\t\t\t\t\t`flex flex-col gap-2 data-[state=active]:animate-files-in data-[state=inactive]:animate-out\n\t\t\t\t\tdata-[state=inactive]:fade-out-0 data-[state=inactive]:slide-out-to-top-2`,\n\t\t\t\t\torientation === \"horizontal\" && \"flex-row overflow-x-auto p-1.5\",\n\t\t\t\t\tinnerProps.className\n\t\t\t\t),\n\t\t\t};\n\t\t},\n\t\t[disableInternalStateSubscription, hasFiles]\n\t);\n\n\tconst getFileItemProps: UseDropZoneResult[\"propGetters\"][\"getFileItemProps\"] = useCallbackRef(\n\t\t(innerProps) => {\n\t\t\treturn {\n\t\t\t\t...getScopeAttrs(\"file-item\"),\n\t\t\t\t...innerProps,\n\t\t\t\tclassName: cnMerge(\n\t\t\t\t\t\"relative flex items-center gap-2.5 rounded-md border p-2\",\n\t\t\t\t\tinnerProps.className\n\t\t\t\t),\n\t\t\t};\n\t\t}\n\t);\n\n\tconst getFileItemProgressProps: UseDropZoneResult[\"propGetters\"][\"getFileItemProgressProps\"] =\n\t\tuseCallbackRef((innerProps) => {\n\t\t\tconst { variant = \"linear\", ...restOfInnerProps } = innerProps;\n\n\t\t\treturn {\n\t\t\t\t...getScopeAttrs(\"file-item-progress\"),\n\t\t\t\trole: \"progressbar\",\n\t\t\t\t...restOfInnerProps,\n\t\t\t\tclassName: cnMerge(\n\t\t\t\t\t\"inline-flex\",\n\t\t\t\t\tvariant === \"circular\" && \"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2\",\n\t\t\t\t\tvariant === \"fill\"\n\t\t\t\t\t\t&& `absolute inset-0 bg-zu-primary/50 transition-[clip-path] duration-300 ease-linear\n\t\t\t\t\t\t[clip-path:var(--clip-path)]`,\n\t\t\t\t\tvariant === \"linear\"\n\t\t\t\t\t\t&& \"relative h-1.5 w-full overflow-hidden rounded-full bg-zu-primary/20\",\n\t\t\t\t\trestOfInnerProps.className\n\t\t\t\t),\n\t\t\t};\n\t\t});\n\n\tconst getFileItemDeleteProps: UseDropZoneResult[\"propGetters\"][\"getFileItemDeleteProps\"] = useCallback(\n\t\t(innerProps) => {\n\t\t\tconst { fileStateOrID, ...restOfInnerProps } = innerProps;\n\n\t\t\tconst isDisabled = innerProps.disabled ?? disabled;\n\n\t\t\tconst onRemoveFile = () => fileStateOrID && actions.removeFile({ fileStateOrID });\n\n\t\t\treturn {\n\t\t\t\t...getScopeAttrs(\"file-item-delete\"),\n\t\t\t\ttype: \"button\",\n\t\t\t\t...restOfInnerProps,\n\t\t\t\t\"data-disabled\": dataAttr(isDisabled),\n\t\t\t\tdisabled: isDisabled,\n\t\t\t\tonClick: composeTwoEventHandlers(onRemoveFile, restOfInnerProps.onClick),\n\t\t\t};\n\t\t},\n\t\t[actions, disabled]\n\t);\n\n\tconst getFileItemPreviewProps: UseDropZoneResult[\"propGetters\"][\"getFileItemPreviewProps\"] =\n\t\tuseCallbackRef((innerProps) => {\n\t\t\treturn {\n\t\t\t\t...getScopeAttrs(\"file-item-preview\"),\n\t\t\t\t...innerProps,\n\t\t\t\tclassName: cnMerge(\n\t\t\t\t\t`relative flex size-10 shrink-0 items-center justify-center overflow-hidden rounded-md\n\t\t\t\t\tbg-zu-accent/50 [&>svg]:size-10`,\n\t\t\t\t\tinnerProps.className\n\t\t\t\t),\n\t\t\t};\n\t\t});\n\n\tconst getFileItemMetadataProps: UseDropZoneResult[\"propGetters\"][\"getFileItemMetadataProps\"] =\n\t\tuseCallbackRef((innerProps) => {\n\t\t\treturn {\n\t\t\t\t...getScopeAttrs(\"file-item-metadata\"),\n\t\t\t\t...innerProps,\n\t\t\t\tclassName: cnMerge(\"flex min-w-0 grow flex-col\", innerProps.className),\n\t\t\t};\n\t\t});\n\n\tconst getFileItemClearProps: UseDropZoneResult[\"propGetters\"][\"getFileItemClearProps\"] = useCallback(\n\t\t(innerProps) => {\n\t\t\tconst isDisabled = innerProps.disabled ?? disabled;\n\n\t\t\treturn {\n\t\t\t\t...getScopeAttrs(\"file-item-clear\"),\n\t\t\t\ttype: \"button\",\n\t\t\t\t...innerProps,\n\t\t\t\t\"data-disabled\": dataAttr(isDisabled),\n\t\t\t\tdisabled: isDisabled,\n\t\t\t\tonClick: composeTwoEventHandlers(actions.clearFiles, innerProps.onClick),\n\t\t\t};\n\t\t},\n\t\t[actions.clearFiles, disabled]\n\t);\n\n\tconst propGetters = useMemo<DropZonePropGetters>(\n\t\t() =>\n\t\t\t({\n\t\t\t\tgetContainerProps,\n\t\t\t\tgetFileItemClearProps,\n\t\t\t\tgetFileItemDeleteProps,\n\t\t\t\tgetFileItemMetadataProps,\n\t\t\t\tgetFileItemPreviewProps,\n\t\t\t\tgetFileItemProgressProps,\n\t\t\t\tgetFileItemProps,\n\t\t\t\tgetFileListProps,\n\t\t\t\tgetInputProps,\n\t\t\t\tgetTriggerProps,\n\t\t\t}) satisfies DropZonePropGetters,\n\t\t[\n\t\t\tgetContainerProps,\n\t\t\tgetFileListProps,\n\t\t\tgetFileItemClearProps,\n\t\t\tgetFileItemDeleteProps,\n\t\t\tgetFileItemMetadataProps,\n\t\t\tgetFileItemPreviewProps,\n\t\t\tgetFileItemProgressProps,\n\t\t\tgetFileItemProps,\n\t\t\tgetInputProps,\n\t\t\tgetTriggerProps,\n\t\t]\n\t);\n\n\tconst savedUseDropZoneStore = useCallbackRef(useDropZoneStore);\n\n\tconst result = useMemo<UseDropZoneResult>(\n\t\t() =>\n\t\t\t({\n\t\t\t\tdisabled,\n\t\t\t\tdisableInternalStateSubscription,\n\t\t\t\tinputRef,\n\t\t\t\tpropGetters,\n\t\t\t\tstoreApi,\n\t\t\t\tuseDropZoneStore: savedUseDropZoneStore,\n\t\t\t}) satisfies UseDropZoneResult,\n\t\t[disabled, disableInternalStateSubscription, propGetters, storeApi, savedUseDropZoneStore]\n\t);\n\n\treturn result;\n};\n","\"use client\";\n\nimport { dataAttr, formatBytes } from \"@zayne-labs/toolkit-core\";\nimport { useShallowCompSelector } from \"@zayne-labs/toolkit-react\";\nimport type { CssWithCustomProperties, PolymorphicPropsStrict } from \"@zayne-labs/toolkit-react/utils\";\nimport { type AnyFunction, isFunction, isNumber, type SelectorFn } from \"@zayne-labs/toolkit-type-helpers\";\nimport * as React from \"react\";\nimport { useMemo } from \"react\";\nimport { For } from \"@/components/common\";\nimport { Presence } from \"@/components/common/presence\";\nimport { Slot } from \"@/components/common/slot\";\nimport { cnMerge } from \"@/lib/utils/cn\";\nimport {\n\tDropZoneRootContextProvider,\n\ttype DropZoneRootContextType,\n\tDropZoneStoreContextProvider,\n\tFileItemContextProvider,\n\ttype FileItemContextType,\n\tuseDropZoneRootContext,\n\tuseDropZoneStoreContext,\n\tuseFileItemContext,\n} from \"./drop-zone-context\";\nimport type { DropZoneStore } from \"./drop-zone-store\";\nimport {\n\tFileArchiveIcon,\n\tFileAudioIcon,\n\tFileCodeIcon,\n\tFileCogIcon,\n\tFileIcon,\n\tFileTextIcon,\n\tFileVideoIcon,\n} from \"./icons\";\nimport type { PartInputProps, UseDropZoneProps } from \"./types\";\nimport { useDropZone } from \"./use-drop-zone\";\n\ntype DropZoneRootProps = UseDropZoneProps & { children: React.ReactNode };\n\nexport function DropZoneRoot(props: DropZoneRootProps) {\n\tconst { children, ...restOfProps } = props;\n\n\tconst { disabled, disableInternalStateSubscription, inputRef, propGetters, storeApi } =\n\t\tuseDropZone(restOfProps);\n\n\tconst rootContextValue = useMemo<DropZoneRootContextType>(\n\t\t() =>\n\t\t\t({\n\t\t\t\tdisabled,\n\t\t\t\tdisableInternalStateSubscription,\n\t\t\t\tinputRef,\n\t\t\t\tpropGetters,\n\t\t\t}) satisfies DropZoneRootContextType,\n\t\t[disableInternalStateSubscription, disabled, inputRef, propGetters]\n\t);\n\n\treturn (\n\t\t<DropZoneStoreContextProvider store={storeApi}>\n\t\t\t<DropZoneRootContextProvider value={rootContextValue}>{children}</DropZoneRootContextProvider>\n\t\t</DropZoneStoreContextProvider>\n\t);\n}\n\ntype DropZoneContextProps<TSlice> = {\n\tchildren: React.ReactNode | ((props: TSlice) => React.ReactNode);\n\tselector?: SelectorFn<DropZoneStore, TSlice>;\n};\n\nexport function DropZoneContext<TSlice = DropZoneStore>(props: DropZoneContextProps<TSlice>) {\n\tconst { children, selector } = props;\n\n\tconst dropZoneCtx = useDropZoneStoreContext(useShallowCompSelector(selector));\n\n\tconst resolvedChildren = isFunction(children) ? children(dropZoneCtx) : children;\n\n\treturn resolvedChildren;\n}\n\ntype DropZoneContainerProps = PartInputProps[\"container\"] & { asChild?: boolean };\n\nexport function DropZoneContainer<TElement extends React.ElementType = \"div\">(\n\tprops: PolymorphicPropsStrict<TElement, DropZoneContainerProps>\n) {\n\tconst { as: Element = \"div\", asChild, ...restOfProps } = props;\n\n\tconst { disableInternalStateSubscription, propGetters } = useDropZoneRootContext();\n\n\tconst isDraggingOver = useDropZoneStoreContext((store) =>\n\t\tdisableInternalStateSubscription ? store.isDraggingOver : null\n\t);\n\n\tconst isInvalid = useDropZoneStoreContext((store) =>\n\t\tdisableInternalStateSubscription ? store.isInvalid : null\n\t);\n\n\tconst Component = asChild ? Slot.Root : Element;\n\n\treturn (\n\t\t<Component\n\t\t\t{...propGetters.getContainerProps({\n\t\t\t\t...(disableInternalStateSubscription && {\n\t\t\t\t\t\"data-drag-over\": dataAttr(isDraggingOver),\n\t\t\t\t\t\"data-invalid\": dataAttr(isInvalid),\n\t\t\t\t}),\n\t\t\t\t...restOfProps,\n\t\t\t})}\n\t\t/>\n\t);\n}\n\ntype DropZoneInputProps = PartInputProps[\"input\"] & { asChild?: boolean };\n\nexport function DropZoneInput(props: DropZoneInputProps) {\n\tconst { asChild, ...restOfProps } = props;\n\n\tconst { disableInternalStateSubscription, propGetters } = useDropZoneRootContext();\n\n\tconst isDraggingOver = useDropZoneStoreContext((store) =>\n\t\tdisableInternalStateSubscription ? store.isDraggingOver : null\n\t);\n\n\tconst Component = asChild ? Slot.Root : \"input\";\n\n\treturn (\n\t\t<Component\n\t\t\t{...propGetters.getInputProps({\n\t\t\t\t...(disableInternalStateSubscription && { \"data-drag-over\": dataAttr(isDraggingOver) }),\n\t\t\t\t...restOfProps,\n\t\t\t})}\n\t\t/>\n\t);\n}\n\ntype DropZoneAreaProps<TSlice> = {\n\tchildren: React.ReactNode | ((props: TSlice) => React.ReactNode);\n\tclassNames?: Partial<Record<Extract<keyof PartInputProps, \"container\" | \"input\">, string>>;\n\textraProps?: Pick<PartInputProps, \"container\" | \"input\">;\n\tselector?: SelectorFn<DropZoneStore, TSlice>;\n};\n\nexport function DropZoneArea<TSlice = DropZoneStore>(props: DropZoneAreaProps<TSlice>) {\n\tconst { children, classNames, extraProps, selector } = props;\n\n\treturn (\n\t\t<DropZoneContainer {...extraProps?.container} className={classNames?.container}>\n\t\t\t<DropZoneInput {...extraProps?.input} className={classNames?.input} />\n\n\t\t\t<DropZoneContext selector={selector}>{children}</DropZoneContext>\n\t\t</DropZoneContainer>\n\t);\n}\n\ntype DropZoneTriggerProps = PartInputProps[\"trigger\"] & { asChild?: boolean };\n\nexport function DropZoneTrigger(props: DropZoneTriggerProps) {\n\tconst { asChild, ...restOfProps } = props;\n\n\tconst { propGetters } = useDropZoneRootContext();\n\n\tconst Component = asChild ? Slot.Root : \"button\";\n\n\treturn <Component {...propGetters.getTriggerProps(restOfProps)} />;\n}\n\ntype FileListPerItemVariant = {\n\tchildren:\n\t\t| React.ReactNode\n\t\t| ((props: {\n\t\t\t\tactions: DropZoneStore[\"actions\"];\n\t\t\t\tarray: DropZoneStore[\"fileStateArray\"];\n\t\t\t\tfileState: DropZoneStore[\"fileStateArray\"][number];\n\t\t\t\tindex: number;\n\t\t }) => React.ReactNode);\n\trenderMode?: \"per-item\";\n};\n\ntype FileListManualListVariant = {\n\tchildren:\n\t\t| React.ReactNode\n\t\t| ((props: Pick<DropZoneStore, \"actions\" | \"fileStateArray\">) => React.ReactNode);\n\trenderMode: \"manual-list\";\n};\n\ntype DropZoneFileListProps = Omit<PartInputProps[\"fileList\"], \"children\"> & {\n\tasChild?: boolean;\n\tforceMount?: boolean;\n} & (FileListManualListVariant | FileListPerItemVariant);\n\nexport function DropZoneFileList<TElement extends React.ElementType = \"ul\">(\n\tprops: PolymorphicPropsStrict<TElement, DropZoneFileListProps>\n) {\n\tconst {\n\t\tas: Element = \"ul\",\n\t\tasChild,\n\t\tchildren,\n\t\tforceMount = false,\n\t\trenderMode = \"per-item\",\n\t\t...restOfProps\n\t} = props;\n\n\tconst fileStateArray = useDropZoneStoreContext((store) => store.fileStateArray);\n\tconst actions = useDropZoneStoreContext((store) => store.actions);\n\n\tconst { disableInternalStateSubscription, propGetters } = useDropZoneRootContext();\n\n\tconst childrenMap = {\n\t\t\"manual-list\": () => {\n\t\t\tconst childrenFn = children as Extract<FileListManualListVariant[\"children\"], AnyFunction>;\n\t\t\treturn childrenFn({ actions, fileStateArray });\n\t\t},\n\t\t\"per-item\": () => {\n\t\t\tconst childrenFn = children as Extract<FileListPerItemVariant[\"children\"], AnyFunction>;\n\n\t\t\treturn (\n\t\t\t\t<For\n\t\t\t\t\teach={fileStateArray}\n\t\t\t\t\trenderItem={(fileState, index, array) => childrenFn({ actions, array, fileState, index })}\n\t\t\t\t/>\n\t\t\t);\n\t\t},\n\t} satisfies Record<typeof renderMode, () => React.ReactNode>;\n\n\tconst hasFiles = fileStateArray.length > 0;\n\n\tconst Component = asChild ? Slot.Root : Element;\n\n\treturn (\n\t\t<Presence present={hasFiles} forceMount={forceMount}>\n\t\t\t<Component\n\t\t\t\t{...propGetters.getFileListProps({\n\t\t\t\t\t...(disableInternalStateSubscription && { \"data-state\": hasFiles ? \"active\" : \"inactive\" }),\n\t\t\t\t\t...restOfProps,\n\t\t\t\t})}\n\t\t\t>\n\t\t\t\t{isFunction(children) ? childrenMap[renderMode]() : children}\n\t\t\t</Component>\n\t\t</Presence>\n\t);\n}\n\ntype DropZoneFileItemProps = FileItemContextType & PartInputProps[\"fileItem\"] & { asChild?: boolean };\n\nexport function DropZoneFileItem<TElement extends React.ElementType = \"li\">(\n\tprops: PolymorphicPropsStrict<TElement, DropZoneFileItemProps>\n) {\n\tconst { as: Element = \"li\", asChild, fileState, ...restOfProps } = props;\n\n\tconst { propGetters } = useDropZoneRootContext();\n\n\tconst Component = asChild ? Slot.Root : Element;\n\n\tconst contextValue = useMemo<FileItemContextType>(\n\t\t() => ({ fileState }) satisfies FileItemContextType,\n\t\t[fileState]\n\t);\n\n\treturn (\n\t\t<FileItemContextProvider value={contextValue}>\n\t\t\t<Component {...propGetters.getFileItemProps(restOfProps)} />\n\t\t</FileItemContextProvider>\n\t);\n}\n\ntype DropZoneFileItemDeleteProps = PartInputProps[\"fileItemDelete\"] & { asChild?: boolean };\n\nexport function DropZoneFileItemDelete(props: DropZoneFileItemDeleteProps) {\n\tconst { asChild, fileStateOrID, ...restOfProps } = props;\n\n\tconst { propGetters } = useDropZoneRootContext();\n\n\tconst fileItemContextValue = useFileItemContext();\n\n\tconst Component = asChild ? Slot.Root : \"button\";\n\n\tconst resolvedFileStateOrID = fileStateOrID ?? fileItemContextValue?.fileState;\n\n\treturn (\n\t\t<Component\n\t\t\t{...propGetters.getFileItemDeleteProps({ fileStateOrID: resolvedFileStateOrID, ...restOfProps })}\n\t\t/>\n\t);\n}\n\ntype DropZoneFileItemProgressProps = PartInputProps[\"fileItemProgress\"] & {\n\tasChild?: boolean;\n\tforceMount?: boolean;\n\tsize?: number;\n};\n\nexport function DropZoneFileItemProgress<TElement extends React.ElementType = \"span\">(\n\tprops: PolymorphicPropsStrict<TElement, DropZoneFileItemProgressProps>\n) {\n\tconst {\n\t\tas: Element = \"span\",\n\t\tasChild,\n\t\tforceMount = false,\n\t\tsize = 40,\n\t\tvariant = \"linear\",\n\t\t...restOfProps\n\t} = props;\n\n\tconst fileItemContextValue = useFileItemContext();\n\n\tconst fileState = fileItemContextValue?.fileState;\n\n\tconst { propGetters } = useDropZoneRootContext();\n\n\tif (!fileState) {\n\t\treturn null;\n\t}\n\n\tconst currentProgress = fileState.progress;\n\n\tconst shouldRender = forceMount || fileState.progress !== 100;\n\n\tif (!shouldRender) {\n\t\treturn null;\n\t}\n\n\tconst Component = asChild ? Slot.Root : Element;\n\n\tconst componentProps = propGetters.getFileItemProgressProps({ variant, ...restOfProps });\n\n\tswitch (variant) {\n\t\tcase \"circular\": {\n\t\t\tconst circumference = 2 * Math.PI * ((size - 4) / 2);\n\t\t\tconst strokeDashoffset = circumference - (currentProgress / 100) * circumference;\n\n\t\t\treturn (\n\t\t\t\t<Component {...componentProps}>\n\t\t\t\t\t<svg\n\t\t\t\t\t\tclassName=\"-rotate-90\"\n\t\t\t\t\t\twidth={size}\n\t\t\t\t\t\theight={size}\n\t\t\t\t\t\tviewBox={`0 0 ${size} ${size}`}\n\t\t\t\t\t\tfill=\"none\"\n\t\t\t\t\t\tstroke=\"currentColor\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<circle\n\t\t\t\t\t\t\tclassName=\"text-zu-primary/20\"\n\t\t\t\t\t\t\tstrokeWidth=\"2\"\n\t\t\t\t\t\t\tcx={size / 2}\n\t\t\t\t\t\t\tcy={size / 2}\n\t\t\t\t\t\t\tr={(size - 4) / 2}\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<circle\n\t\t\t\t\t\t\tclassName=\"text-zu-primary transition-[stroke-dashoffset] duration-300 ease-linear\"\n\t\t\t\t\t\t\tstrokeWidth=\"2\"\n\t\t\t\t\t\t\tstrokeLinecap=\"round\"\n\t\t\t\t\t\t\tstrokeDasharray={circumference}\n\t\t\t\t\t\t\tstrokeDashoffset={strokeDashoffset}\n\t\t\t\t\t\t\tcx={size / 2}\n\t\t\t\t\t\t\tcy={size / 2}\n\t\t\t\t\t\t\tr={(size - 4) / 2}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</svg>\n\t\t\t\t</Component>\n\t\t\t);\n\t\t}\n\n\t\tcase \"fill\": {\n\t\t\tconst topInset = 100 - currentProgress;\n\n\t\t\treturn (\n\t\t\t\t<Component\n\t\t\t\t\t{...componentProps}\n\t\t\t\t\tstyle={\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"--clip-path\": `inset(${topInset}% 0% 0% 0%)`,\n\t\t\t\t\t\t} satisfies CssWithCustomProperties as CssWithCustomProperties\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t);\n\t\t}\n\n\t\tcase \"linear\": {\n\t\t\treturn (\n\t\t\t\t<Component {...componentProps}>\n\t\t\t\t\t<span\n\t\t\t\t\t\tclassName=\"inline-block size-full grow translate-x-(--translate-distance) bg-zu-primary transition-transform duration-300 ease-linear\"\n\t\t\t\t\t\tstyle={\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\"--translate-distance\": `-${100 - currentProgress}%`,\n\t\t\t\t\t\t\t} satisfies CssWithCustomProperties as CssWithCustomProperties\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t</Component>\n\t\t\t);\n\t\t}\n\n\t\tdefault: {\n\t\t\tvariant satisfies never;\n\t\t\treturn null;\n\t\t}\n\t}\n}\n\ntype RenderPreviewDetails = { className?: string; node?: React.ReactNode };\n\ntype RenderPreviewProp = (props: Pick<FileItemContextType, \"fileState\">) => {\n\tarchive?: RenderPreviewDetails;\n\taudio?: RenderPreviewDetails;\n\tcode?: RenderPreviewDetails;\n\tdefault?: RenderPreviewDetails;\n\texecutable?: RenderPreviewDetails;\n\timage?: RenderPreviewDetails;\n\ttext?: RenderPreviewDetails;\n\tvideo?: RenderPreviewDetails;\n};\n\ntype DropZoneFileItemPreviewProps = Omit<PartInputProps[\"fileItemPreview\"], \"children\">\n\t& Partial<Pick<FileItemContextType, \"fileState\">> & {\n\t\tasChild?: boolean;\n\t\tchildren?: React.ReactNode | ((props: Pick<FileItemContextType, \"fileState\">) => React.ReactNode);\n\t\trenderPreview?: boolean | RenderPreviewProp;\n\t};\n\nexport function DropZoneFileItemPreview<TElement extends React.ElementType>(\n\tprops: PolymorphicPropsStrict<TElement, DropZoneFileItemPreviewProps>\n) {\n\tconst {\n\t\tas: Element = \"span\",\n\t\tasChild,\n\t\tchildren,\n\t\tfileState: fileStateProp,\n\t\trenderPreview = true,\n\t\t...restOfProps\n\t} = props;\n\n\tconst fileItemContextValue = useFileItemContext();\n\n\tconst { propGetters } = useDropZoneRootContext();\n\n\tconst fileState = fileStateProp ?? fileItemContextValue?.fileState;\n\n\tif (!fileState) {\n\t\treturn null;\n\t}\n\n\tconst Component = asChild ? Slot.Root : Element;\n\n\tconst resolvedChildren = isFunction(children) ? children({ fileState }) : children;\n\n\treturn (\n\t\t<Component {...propGetters.getFileItemPreviewProps(restOfProps)}>\n\t\t\t{renderPreview && getFilePreviewOrIcon({ fileState, renderPreview })}\n\t\t\t{resolvedChildren}\n\t\t</Component>\n\t);\n}\n\nconst getFilePreviewOrIcon = (\n\tcontext: Pick<DropZoneFileItemPreviewProps, \"fileState\" | \"renderPreview\">\n) => {\n\tconst { fileState, renderPreview } = context;\n\n\tconst type = fileState?.file.type;\n\tconst extension = fileState?.file.name?.split(\".\").pop()?.toLowerCase() ?? \"\";\n\n\tconst renderPreviewObject = isFunction(renderPreview) ? renderPreview({ fileState }) : {};\n\n\tconst getDefaultPreview = () => {\n\t\treturn (\n\t\t\trenderPreviewObject.default?.node ?? (\n\t\t\t\t<FileIcon className={renderPreviewObject.default?.className} />\n\t\t\t)\n\t\t);\n\t};\n\n\tif (!type) {\n\t\treturn getDefaultPreview();\n\t}\n\n\tswitch (true) {\n\t\tcase type.startsWith(\"image/\"): {\n\t\t\treturn (\n\t\t\t\trenderPreviewObject.image?.node ?? (\n\t\t\t\t\t<img\n\t\t\t\t\t\tsrc={fileState.preview}\n\t\t\t\t\t\talt={fileState.file.name}\n\t\t\t\t\t\tclassName={cnMerge(\"size-full object-cover\", renderPreviewObject.image?.className)}\n\t\t\t\t\t/>\n\t\t\t\t)\n\t\t\t);\n\t\t}\n\n\t\tcase type.startsWith(\"video/\"): {\n\t\t\treturn (\n\t\t\t\trenderPreviewObject.video?.node ?? (\n\t\t\t\t\t<FileVideoIcon\n\t\t\t\t\t\tclassName={cnMerge(\"size-full object-cover\", renderPreviewObject.video?.className)}\n\t\t\t\t\t/>\n\t\t\t\t)\n\t\t\t);\n\t\t}\n\n\t\tcase type.startsWith(\"audio/\"): {\n\t\t\treturn (\n\t\t\t\trenderPreviewObject.audio?.node ?? (\n\t\t\t\t\t<FileAudioIcon\n\t\t\t\t\t\tclassName={cnMerge(\"size-full object-cover\", renderPreviewObject.audio?.className)}\n\t\t\t\t\t/>\n\t\t\t\t)\n\t\t\t);\n\t\t}\n\n\t\tcase type.startsWith(\"text/\") || [\"md\", \"pdf\", \"rtf\", \"txt\"].includes(extension): {\n\t\t\treturn (\n\t\t\t\trenderPreviewObject.text?.node ?? (\n\t\t\t\t\t<FileTextIcon className={renderPreviewObject.text?.className} />\n\t\t\t\t)\n\t\t\t);\n\t\t}\n\n\t\tcase [\n\t\t\t\"c\",\n\t\t\t\"cpp\",\n\t\t\t\"cs\",\n\t\t\t\"css\",\n\t\t\t\"html\",\n\t\t\t\"java\",\n\t\t\t\"js\",\n\t\t\t\"json\",\n\t\t\t\"jsx\",\n\t\t\t\"php\",\n\t\t\t\"py\",\n\t\t\t\"rb\",\n\t\t\t\"ts\",\n\t\t\t\"tsx\",\n\t\t\t\"xml\",\n\t\t].includes(extension): {\n\t\t\treturn (\n\t\t\t\trenderPreviewObject.code?.node ?? (\n\t\t\t\t\t<FileCodeIcon className={renderPreviewObject.code?.className} />\n\t\t\t\t)\n\t\t\t);\n\t\t}\n\n\t\tcase [\"7z\", \"bz2\", \"gz\", \"rar\", \"tar\", \"zip\"].includes(extension): {\n\t\t\treturn (\n\t\t\t\trenderPreviewObject.archive?.node ?? (\n\t\t\t\t\t<FileArchiveIcon className={renderPreviewObject.archive?.className} />\n\t\t\t\t)\n\t\t\t);\n\t\t}\n\n\t\tcase [\"apk\", \"app\", \"deb\", \"exe\", \"msi\", \"rpm\"].includes(extension): {\n\t\t\treturn (\n\t\t\t\trenderPreviewObject.executable?.node ?? (\n\t\t\t\t\t<FileCogIcon className={renderPreviewObject.executable?.className} />\n\t\t\t\t)\n\t\t\t);\n\t\t}\n\n\t\tdefault: {\n\t\t\treturn getDefaultPreview();\n\t\t}\n\t}\n};\n\ntype DropZoneFileItemMetadataProps = Omit<PartInputProps[\"fileItemMetadata\"], \"children\">\n\t& Partial<Pick<FileItemContextType, \"fileState\">> & {\n\t\tasChild?: boolean;\n\t\tchildren?: React.ReactNode | ((props: Pick<FileItemContextType, \"fileState\">) => React.ReactNode);\n\t\tclassNames?: {\n\t\t\tname?: string;\n\t\t\tsize?: string;\n\t\t};\n\t\tsize?: \"default\" | \"sm\";\n\t};\n\nexport function DropZoneFileItemMetadata(props: DropZoneFileItemMetadataProps) {\n\tconst {\n\t\tasChild,\n\t\tchildren,\n\t\tclassNames,\n\t\tfileState: fileStateProp,\n\t\tsize = \"default\",\n\t\t...restOfProps\n\t} = props;\n\n\tconst fileItemContextValue = useFileItemContext();\n\n\tconst { propGetters } = useDropZoneRootContext();\n\n\tconst fileState = fileStateProp ?? fileItemContextValue?.fileState;\n\n\tif (!fileState) {\n\t\treturn null;\n\t}\n\n\tconst Component = asChild ? Slot.Root : \"div\";\n\n\tconst resolvedChildren = isFunction(children) ? children({ fileState }) : children;\n\n\tconst getDefaultMetadataChildren = () => {\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<p\n\t\t\t\t\tclassName={cnMerge(\n\t\t\t\t\t\t\"truncate\",\n\t\t\t\t\t\tsize === \"default\" && \"text-[14px] font-medium\",\n\t\t\t\t\t\tsize === \"sm\" && \"text-[13px] leading-snug\",\n\t\t\t\t\t\tclassNames?.name\n\t\t\t\t\t)}\n\t\t\t\t>\n\t\t\t\t\t{fileState.file.name}\n\t\t\t\t</p>\n\t\t\t\t<p\n\t\t\t\t\tclassName={cnMerge(\n\t\t\t\t\t\t\"truncate text-zu-muted-foreground\",\n\t\t\t\t\t\tsize === \"default\" && \"text-[12px]\",\n\t\t\t\t\t\tsize === \"sm\" && \"text-[11px] leading-snug\",\n\t\t\t\t\t\tclassNames?.size\n\t\t\t\t\t)}\n\t\t\t\t>\n\t\t\t\t\t{isNumber(fileState.file.size) && formatBytes(fileState.file.size)}\n\t\t\t\t</p>\n\t\t\t\t{fileState.error && (\n\t\t\t\t\t<p className=\"text-[12px] text-zu-destructive\">{fileState.error.message}</p>\n\t\t\t\t)}\n\t\t\t</>\n\t\t);\n\t};\n\n\treturn (\n\t\t<Component {...propGetters.getFileItemMetadataProps(restOfProps)}>\n\t\t\t{resolvedChildren ?? getDefaultMetadataChildren()}\n\t\t</Component>\n\t);\n}\n\ntype DropZoneFileClearProps = PartInputProps[\"fileItemClear\"] & {\n\tasChild?: boolean;\n\tforceMount?: boolean;\n};\n\nexport function DropZoneFileClear(props: DropZoneFileClearProps) {\n\tconst { asChild, forceMount = false, ...restOfProps } = props;\n\n\tconst { propGetters } = useDropZoneRootContext();\n\n\tconst fileCount = useDropZoneStoreContext((state) => state.fileStateArray.length);\n\n\tconst shouldRender = forceMount || fileCount > 0;\n\n\tif (!shouldRender) {\n\t\treturn null;\n\t}\n\n\tconst Component = asChild ? Slot.Root : \"button\";\n\n\treturn <Component {...propGetters.getFileItemClearProps(restOfProps)} />;\n}\n","export {\n\tDropZoneArea as Area,\n\tDropZoneContainer as Container,\n\tDropZoneContext as Context,\n\tDropZoneFileClear as FileClear,\n\tDropZoneFileItem as FileItem,\n\tDropZoneFileItemDelete as FileItemDelete,\n\tDropZoneFileItemMetadata as FileItemMetadata,\n\tDropZoneFileItemPreview as FileItemPreview,\n\tDropZoneFileItemProgress as FileItemProgress,\n\tDropZoneFileList as FileList,\n\tDropZone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,OAAO;AAIjF,KAAI,EAFiB,cAAc,YAAY,GAG9C,QAAO;CAGR,MAAMA,cAAY,UAAUC,WAAY;AAExC,QAAO,oBAACD,eAAU,GAAI,YAAY,sBAAsB,YAAY,GAAI"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error-boundary-y9Samt_s.js","names":["initialState: ErrorBoundaryState","#resetErrorBoundary"],"sources":["../../src/components/common/error-boundary/error-boundary-context.ts","../../src/components/common/error-boundary/error-boundary.tsx","../../src/components/common/error-boundary/useErrorBoundary.ts"],"sourcesContent":["import { createCustomContext } from \"@zayne-labs/toolkit-react\";\n\nexport type ErrorBoundaryContextType = {\n\terror: unknown;\n\thasError: boolean;\n\tresetErrorBoundary: (...args: unknown[]) => void;\n};\n\nexport const [ErrorBoundaryContext, useErrorBoundaryContext] =\n\tcreateCustomContext<ErrorBoundaryContextType>({\n\t\thookName: \"useErrorBoundaryContext\",\n\t\tname: \"ErrorBoundaryContext\",\n\t\tproviderName: \"ErrorBoundaryContextProvider\",\n\t});\n","import { isFunction } from \"@zayne-labs/toolkit-type-helpers\";\nimport * as React from \"react\";\nimport { Component } from \"react\";\nimport { ErrorBoundaryContext, type ErrorBoundaryContextType } from \"./error-boundary-context\";\nimport type { ErrorBoundaryProps, FallbackProps } from \"./types\";\n\ntype ErrorBoundaryState =\n\t| {\n\t\t\terror: Error;\n\t\t\thasError: true;\n\t }\n\t| {\n\t\t\terror: null;\n\t\t\thasError: false;\n\t };\n\nconst initialState: ErrorBoundaryState = {\n\terror: null,\n\thasError: false,\n};\n\nconst hasArrayChanged = (arrayOne: unknown[] = [], arrayTwo: unknown[] = []) => {\n\treturn (\n\t\tarrayOne.length !== arrayTwo.length\n\t\t|| arrayOne.some((item, index) => !Object.is(item, arrayTwo[index]))\n\t);\n};\n\n/**\n * Copied from react-error-boundary package\n * @see https://github.com/bvaughn/react-error-boundary\n */\n\nexport class ErrorBoundary extends Component<ErrorBoundaryProps, ErrorBoundaryState> {\n\tconstructor(props: ErrorBoundaryProps) {\n\t\tsuper(props);\n\n\t\tthis.state = initialState;\n\t}\n\n\tstatic getDerivedStateFromError(error: Error) {\n\t\treturn { error, hasError: true };\n\t}\n\n\toverride componentDidCatch(error: Error, info: React.ErrorInfo) {\n\t\tthis.props.onError?.({
|
|
1
|
+
{"version":3,"file":"error-boundary-y9Samt_s.js","names":["initialState: ErrorBoundaryState","#resetErrorBoundary"],"sources":["../../src/components/common/error-boundary/error-boundary-context.ts","../../src/components/common/error-boundary/error-boundary.tsx","../../src/components/common/error-boundary/useErrorBoundary.ts"],"sourcesContent":["import { createCustomContext } from \"@zayne-labs/toolkit-react\";\n\nexport type ErrorBoundaryContextType = {\n\terror: unknown;\n\thasError: boolean;\n\tresetErrorBoundary: (...args: unknown[]) => void;\n};\n\nexport const [ErrorBoundaryContext, useErrorBoundaryContext] =\n\tcreateCustomContext<ErrorBoundaryContextType>({\n\t\thookName: \"useErrorBoundaryContext\",\n\t\tname: \"ErrorBoundaryContext\",\n\t\tproviderName: \"ErrorBoundaryContextProvider\",\n\t});\n","import { isFunction } from \"@zayne-labs/toolkit-type-helpers\";\nimport * as React from \"react\";\nimport { Component } from \"react\";\nimport { ErrorBoundaryContext, type ErrorBoundaryContextType } from \"./error-boundary-context\";\nimport type { ErrorBoundaryProps, FallbackProps } from \"./types\";\n\ntype ErrorBoundaryState =\n\t| {\n\t\t\terror: Error;\n\t\t\thasError: true;\n\t }\n\t| {\n\t\t\terror: null;\n\t\t\thasError: false;\n\t };\n\nconst initialState: ErrorBoundaryState = {\n\terror: null,\n\thasError: false,\n};\n\nconst hasArrayChanged = (arrayOne: unknown[] = [], arrayTwo: unknown[] = []) => {\n\treturn (\n\t\tarrayOne.length !== arrayTwo.length\n\t\t|| arrayOne.some((item, index) => !Object.is(item, arrayTwo[index]))\n\t);\n};\n\n/**\n * Copied from react-error-boundary package\n * @see https://github.com/bvaughn/react-error-boundary\n */\n\nexport class ErrorBoundary extends Component<ErrorBoundaryProps, ErrorBoundaryState> {\n\tconstructor(props: ErrorBoundaryProps) {\n\t\tsuper(props);\n\n\t\tthis.state = initialState;\n\t}\n\n\tstatic getDerivedStateFromError(error: Error) {\n\t\treturn { error, hasError: true };\n\t}\n\n\toverride componentDidCatch(error: Error, info: React.ErrorInfo) {\n\t\tthis.props.onError?.({ error, info });\n\t}\n\n\toverride componentDidUpdate(prevProps: ErrorBoundaryProps, prevState: ErrorBoundaryState) {\n\t\tconst { hasError } = this.state;\n\t\tconst { resetKeys } = this.props;\n\n\t\t// == There's an edge case where if the thing that triggered the error happens to *also* be in the resetKeys array, we'd end up resetting the error boundary immediately.\n\t\t// == This would likely trigger a second error to be thrown.\n\t\t// == So we make sure that we don't check the resetKeys on the first call of cDU after the error is set.\n\n\t\tif (hasError && prevState.error !== null && hasArrayChanged(prevProps.resetKeys, resetKeys)) {\n\t\t\tthis.props.onReset?.({\n\t\t\t\tnext: resetKeys,\n\t\t\t\tprev: prevProps.resetKeys,\n\t\t\t\treason: \"keys\",\n\t\t\t});\n\n\t\t\tthis.setState(initialState);\n\t\t}\n\t}\n\n\toverride render() {\n\t\tconst { children, fallback } = this.props;\n\t\tconst { error, hasError } = this.state;\n\n\t\tlet childToRender = children;\n\n\t\tif (hasError) {\n\t\t\tswitch (true) {\n\t\t\t\tcase isFunction(fallback): {\n\t\t\t\t\tconst fallbackRenderProps = {\n\t\t\t\t\t\terror,\n\t\t\t\t\t\tresetErrorBoundary: this.#resetErrorBoundary,\n\t\t\t\t\t} satisfies FallbackProps;\n\n\t\t\t\t\tchildToRender = fallback(fallbackRenderProps);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase Boolean(fallback): {\n\t\t\t\t\tchildToRender = fallback;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tdefault: {\n\t\t\t\t\tconsole.warn(\"No fallback provided to error boundary\");\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tconst contextValue = {\n\t\t\terror,\n\t\t\thasError,\n\t\t\tresetErrorBoundary: this.#resetErrorBoundary,\n\t\t} satisfies ErrorBoundaryContextType;\n\n\t\treturn <ErrorBoundaryContext value={contextValue}>{childToRender}</ErrorBoundaryContext>;\n\t}\n\n\t#resetErrorBoundary = (...parameters: unknown[]) => {\n\t\tconst { error } = this.state;\n\n\t\tif (error !== null) {\n\t\t\tthis.props.onReset?.({\n\t\t\t\targs: parameters,\n\t\t\t\treason: \"imperative-api\",\n\t\t\t});\n\n\t\t\tthis.setState(initialState);\n\t\t}\n\t};\n}\n","import { useCallbackRef } from \"@zayne-labs/toolkit-react\";\nimport { useState } from \"react\";\nimport { useErrorBoundaryContext } from \"./error-boundary-context\";\n\ntype UseErrorBoundaryState<TError extends Error> =\n\t| {\n\t\t\terror: null;\n\t\t\thasError: false;\n\t }\n\t| {\n\t\t\terror: TError;\n\t\t\thasError: true;\n\t };\n\nexport const useErrorBoundary = <TError extends Error>() => {\n\tconst { resetErrorBoundary } = useErrorBoundaryContext();\n\n\tconst [state, setState] = useState<UseErrorBoundaryState<TError>>({\n\t\terror: null,\n\t\thasError: false,\n\t});\n\n\tif (state.hasError) {\n\t\tthrow state.error;\n\t}\n\n\tconst resetBoundary = useCallbackRef(() => {\n\t\tresetErrorBoundary();\n\n\t\tsetState({\n\t\t\terror: null,\n\t\t\thasError: false,\n\t\t});\n\t});\n\n\tconst showBoundary = useCallbackRef((error: TError) => {\n\t\tsetState({\n\t\t\terror,\n\t\t\thasError: true,\n\t\t});\n\t});\n\n\treturn { resetBoundary, showBoundary };\n};\n"],"mappings":";;;;;;AAQA,MAAa,CAAC,sBAAsB,2BACnC,oBAA8C;CAC7C,UAAU;CACV,MAAM;CACN,cAAc;CACd,CAAC;;;;ACGH,MAAMA,eAAmC;CACxC,OAAO;CACP,UAAU;CACV;AAED,MAAM,mBAAmB,WAAsB,EAAE,EAAE,WAAsB,EAAE,KAAK;AAC/E,QACC,SAAS,WAAW,SAAS,UAC1B,SAAS,MAAM,MAAM,UAAU,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uB,yBAAyB;CAExD,MAAM,CAAC,OAAO,YAAY,SAAwC;EACjE,OAAO;EACP,UAAU;EACV,CAAC;AAEF,KAAI,MAAM,SACT,OAAM,MAAM;CAGb,MAAM,gBAAgB,qBAAqB;AAC1C,sBAAoB;AAEpB,WAAS;GACR,OAAO;GACP,UAAU;GACV,CAAC;GACD;CAEF,MAAM,eAAe,gBAAgB,UAAkB;AACtD,WAAS;GACR;GACA,UAAU;GACV,CAAC;GACD;AAEF,QAAO;EAAE;EAAe;EAAc"}
|
|
@@ -8,15 +8,14 @@ function For(props) {
|
|
|
8
8
|
if (each == null || isNumber(each) && each === 0 || isArray(each) && each.length === 0) return fallback;
|
|
9
9
|
const resolvedArray = isNumber(each) ? [...Array(each).keys()] : each;
|
|
10
10
|
if (resolvedArray.length === 0) return fallback;
|
|
11
|
+
const selectedChildren = typeof children === "function" ? children : renderItem;
|
|
11
12
|
return resolvedArray.map((...params) => {
|
|
12
|
-
return
|
|
13
|
+
return selectedChildren(...params);
|
|
13
14
|
});
|
|
14
15
|
}
|
|
15
16
|
function ForWithWrapper(props) {
|
|
16
|
-
const { as: ListContainer = "ul", children,
|
|
17
|
+
const { as: ListContainer = "ul", children, each, renderItem,...restOfListProps } = props;
|
|
17
18
|
return /* @__PURE__ */ jsx(ListContainer, {
|
|
18
|
-
ref,
|
|
19
|
-
className,
|
|
20
19
|
...restOfListProps,
|
|
21
20
|
children: /* @__PURE__ */ jsx(For, {
|
|
22
21
|
children,
|
|
@@ -38,4 +37,4 @@ const getElementList = (variant) => {
|
|
|
38
37
|
|
|
39
38
|
//#endregion
|
|
40
39
|
export { For, ForWithWrapper, getElementList };
|
|
41
|
-
//# sourceMappingURL=for-
|
|
40
|
+
//# sourceMappingURL=for-DK5rEY_m.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"for-DK5rEY_m.js","names":[],"sources":["../../src/components/common/for/for.tsx","../../src/components/common/for/getElementList.ts"],"sourcesContent":["import type {\n\tDiscriminatedRenderItemProps,\n\tPolymorphicPropsStrict,\n} from \"@zayne-labs/toolkit-react/utils\";\nimport { isArray, isNumber, type Prettify } from \"@zayne-labs/toolkit-type-helpers\";\nimport * as React from \"react\";\n\ntype ArrayOrNumber = number | readonly unknown[];\n\ntype GetArrayItemType<TArray extends ArrayOrNumber> =\n\tTArray extends readonly unknown[] ? TArray[number]\n\t: TArray extends number ? number\n\t: unknown;\n\ntype RenderPropFn<TArray extends ArrayOrNumber> = (\n\titem: GetArrayItemType<TArray>,\n\tindex: number,\n\tarray: Array<GetArrayItemType<TArray>>\n) => React.ReactNode;\n\nexport type ForRenderProps<TArray extends ArrayOrNumber> = DiscriminatedRenderItemProps<\n\tRenderPropFn<TArray>\n>;\n\n/* eslint-disable perfectionist/sort-intersection-types -- Prefer the object to come first before the render props */\ntype ForProps<TArray extends ArrayOrNumber> = Prettify<\n\t{\n\t\teach: TArray;\n\t\tfallback?: React.ReactNode;\n\t} & ForRenderProps<TArray>\n>;\n/* eslint-enable perfectionist/sort-intersection-types -- Prefer the object to come first before the render props */\n\nexport function For<const TArray extends ArrayOrNumber>(props: ForProps<TArray>) {\n\tconst { children, each, fallback = null, renderItem } = props;\n\n\t// eslint-disable-next-line ts-eslint/no-unnecessary-condition -- Allow\n\tif (each == null || (isNumber(each) && each === 0) || (isArray(each) && each.length === 0)) {\n\t\treturn fallback;\n\t}\n\n\tconst resolvedArray = isNumber(each) ? [...Array(each).keys()] : (each as unknown[]);\n\n\tif (resolvedArray.length === 0) {\n\t\treturn fallback;\n\t}\n\n\tconst selectedChildren = typeof children === \"function\" ? children : renderItem;\n\n\tconst elementList = resolvedArray.map((...params) => {\n\t\ttype Params = Parameters<RenderPropFn<TArray>>;\n\n\t\treturn selectedChildren(...(params as Params));\n\t});\n\n\treturn elementList;\n}\n\nexport function ForWithWrapper<\n\tconst TArray extends ArrayOrNumber,\n\tTElement extends React.ElementType = \"ul\",\n>(props: PolymorphicPropsStrict<TElement, ForProps<TArray>>) {\n\tconst { as: ListContainer = \"ul\", children, each, renderItem, ...restOfListProps } = props;\n\n\treturn (\n\t\t<ListContainer {...restOfListProps}>\n\t\t\t<For {...({ children, each, renderItem } as ForProps<TArray>)} />\n\t\t</ListContainer>\n\t);\n}\n","import { For, ForWithWrapper } from \"./for\";\n\ntype GetElementListResult<TVariant extends \"base\" | \"withWrapper\"> =\n\tTVariant extends \"base\" ? [typeof For] : [typeof ForWithWrapper];\n\nconst getElementList = <TVariant extends \"base\" | \"withWrapper\" = \"withWrapper\">(\n\tvariant?: TVariant\n): GetElementListResult<TVariant> => {\n\tswitch (variant) {\n\t\tcase \"base\": {\n\t\t\treturn [For] as never;\n\t\t}\n\t\tcase \"withWrapper\": {\n\t\t\treturn [ForWithWrapper] as never;\n\t\t}\n\t\tdefault: {\n\t\t\treturn [ForWithWrapper] as never;\n\t\t}\n\t}\n};\n\nexport { getElementList };\n"],"mappings":";;;;;AAiCA,SAAgB,IAAwC,OAAyB;CAChF,MAAM,EAAE,UAAU,MAAM,WAAW,MAAM,eAAe;AAGxD,KAAI,QAAQ,QAAS,SAAS,KAAK,IAAI,SAAS,KAAO,QAAQ,KAAK,IAAI,KAAK,WAAW,EACvF,QAAO;CAGR,MAAM,gBAAgB,SAAS,KAAK,GAAG,CAAC,GAAG,MAAM,KAAK,CAAC,MAAM,CAAC,GAAI;AAElE,KAAI,cAAc,WAAW,EAC5B,QAAO;CAGR,MAAM,mBAAmB,OAAO,aAAa,aAAa,WAAW;AAQrE,QANoB,cAAc,KAAK,GAAG,WAAW;AAGpD,SAAO,iBAAiB,GAAI,OAAkB;GAC7C;;AAKH,SAAgB,eAGd,OAA2D;CAC5D,MAAM,EAAE,IAAI,gBAAgB,MAAM,UAAU,MAAM,WAAY,GAAG,oBAAoB;AAErF,QACC,oBAAC;EAAc,GAAI;YAClB,oBAAC;GAAW;GAAU;GAAM;IAAqC;GAClD;;;;;AC9DlB,MAAM,kBACL,YACoC;AACpC,SAAQ,SAAR;EACC,KAAK,OACJ,QAAO,CAAC,IAAI;EAEb,KAAK,cACJ,QAAO,CAAC,eAAe;EAExB,QACC,QAAO,CAAC,eAAe"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { __export } from "./chunk-CTAAG5j7.js";
|
|
2
2
|
import { SlotRoot } from "./slot-WVWfOlr3.js";
|
|
3
|
-
import { ForWithWrapper } from "./for-
|
|
3
|
+
import { ForWithWrapper } from "./for-DK5rEY_m.js";
|
|
4
4
|
import { cnMerge } from "./cn-s-D7vHW1.js";
|
|
5
5
|
import { composeRefs, composeTwoEventHandlers, getMultipleSlots } from "@zayne-labs/toolkit-react/utils";
|
|
6
6
|
import { defineEnum, isObject } from "@zayne-labs/toolkit-type-helpers";
|
|
@@ -571,4 +571,4 @@ var form_parts_exports = __export({
|
|
|
571
571
|
|
|
572
572
|
//#endregion
|
|
573
573
|
export { FormDescription, FormErrorMessage, FormErrorMessagePrimitive, FormField, FormFieldContext, FormFieldControlledField, FormFieldController, FormInput, FormInputGroup, FormInputLeftItem, FormInputPrimitive, FormInputRightItem, FormLabel, FormRoot, FormSelect, FormSelectPrimitive, FormSubmit, FormSubscribeToFieldValue, FormSubscribeToFormState, FormTextArea, FormTextAreaPrimitive, form_parts_exports, useFormRootContext, useStrictFormFieldContext };
|
|
574
|
-
//# sourceMappingURL=form-
|
|
574
|
+
//# sourceMappingURL=form-DyGy9LnA.js.map
|