@zayne-labs/ui-react 0.11.0 → 0.11.1

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.
Files changed (42) hide show
  1. package/css/animation.css +13 -0
  2. package/dist/esm/{cn-Bbh2G587.js → cn-CIbU5eI0.js} +1 -1
  3. package/dist/esm/{cn-Bbh2G587.js.map → cn-CIbU5eI0.js.map} +1 -1
  4. package/dist/esm/common/await/index.d.ts +2 -2
  5. package/dist/esm/common/await/index.js +3 -3
  6. package/dist/esm/common/error-boundary/index.d.ts +1 -1
  7. package/dist/esm/common/error-boundary/index.js +1 -1
  8. package/dist/esm/common/for/index.d.ts +1 -1
  9. package/dist/esm/common/presence/index.d.ts +7 -7
  10. package/dist/esm/common/presence/index.js +1 -1
  11. package/dist/esm/common/show/index.js +1 -1
  12. package/dist/esm/common/slot/index.js +1 -1
  13. package/dist/esm/common/suspense-with-boundary/index.d.ts +1 -1
  14. package/dist/esm/common/suspense-with-boundary/index.js +1 -1
  15. package/dist/esm/common/switch/index.js +1 -34
  16. package/dist/esm/common/teleport/index.js +2 -6
  17. package/dist/esm/common/teleport/index.js.map +1 -1
  18. package/dist/esm/{error-boundary-C4btQhu_.js → error-boundary-C9o5EzC9.js} +2 -2
  19. package/dist/esm/{error-boundary-C4btQhu_.js.map → error-boundary-C9o5EzC9.js.map} +1 -1
  20. package/dist/esm/{index-ClV6w6nv.d.ts → index-CaUmIQiv.d.ts} +2 -2
  21. package/dist/esm/{index-BUIvQ2wP.d.ts → index-DpVwG1sA.d.ts} +2 -2
  22. package/dist/esm/presence-DgJvW30C.js +225 -0
  23. package/dist/esm/presence-DgJvW30C.js.map +1 -0
  24. package/dist/esm/{show-BzfAw7y3.js → show-mvRnLPj8.js} +1 -1
  25. package/dist/esm/{show-BzfAw7y3.js.map → show-mvRnLPj8.js.map} +1 -1
  26. package/dist/esm/{slot-DuwoiC2C.js → slot-CHR5Li4r.js} +1 -1
  27. package/dist/esm/{slot-DuwoiC2C.js.map → slot-CHR5Li4r.js.map} +1 -1
  28. package/dist/esm/switch-Dwy5Gzsb.js +35 -0
  29. package/dist/esm/switch-Dwy5Gzsb.js.map +1 -0
  30. package/dist/esm/ui/card/index.js +2 -2
  31. package/dist/esm/ui/carousel/index.js +3 -3
  32. package/dist/esm/ui/drag-scroll/index.d.ts +0 -1
  33. package/dist/esm/ui/drag-scroll/index.js +3 -3
  34. package/dist/esm/ui/drop-zone/index.d.ts +19 -10
  35. package/dist/esm/ui/drop-zone/index.js +65 -62
  36. package/dist/esm/ui/drop-zone/index.js.map +1 -1
  37. package/dist/esm/ui/form/index.js +3 -3
  38. package/dist/style.css +16 -0
  39. package/package.json +6 -6
  40. package/dist/esm/common/switch/index.js.map +0 -1
  41. package/dist/esm/presence-CWOGx-be.js +0 -209
  42. package/dist/esm/presence-CWOGx-be.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"slot-DuwoiC2C.js","names":["ReactFragment"],"sources":["../../src/components/common/slot/slot.tsx","../../src/components/common/slot/slot-parts.ts"],"sourcesContent":["import { composeRefs, mergeProps, type InferProps } from \"@zayne-labs/toolkit-react/utils\";\nimport { isArray, type UnknownObject } from \"@zayne-labs/toolkit-type-helpers\";\nimport { Children, cloneElement, isValidElement, Fragment as ReactFragment } from \"react\";\n\ntype SlotProps = InferProps<HTMLElement> & { ref?: React.Ref<HTMLElement> };\n\n/* -------------------------------------------------------------------------------------------------\n * Slot\n * ----------------------------------------------------------------------------------------------- */\n\nexport function SlotRoot(props: SlotProps) {\n\tconst { children, ...restOfSlotProps } = props;\n\n\tconst childrenArray = isArray<React.ReactNode>(children) ? children : [children];\n\n\tconst slottable = childrenArray.find((element) => isSlottable(element));\n\n\tif (!slottable) {\n\t\treturn <SlotClone {...restOfSlotProps}>{children}</SlotClone>;\n\t}\n\n\tif (!isValidElement<SlotProps>(slottable)) {\n\t\treturn null;\n\t}\n\n\t// == The new element to render is the one passed as a child of `Slot.Slottable`\n\tconst childToRender = slottable.props.children;\n\n\tif (Children.count(childToRender) > 1) {\n\t\treturn Children.only(null);\n\t}\n\n\tconst resolvedChildToRender = isArray(childToRender) ? childToRender[0] : childToRender;\n\n\tif (!isValidElement(resolvedChildToRender)) {\n\t\t// eslint-disable-next-line react-x/purity -- Ignore\n\t\tconsole.error(\"Invalid element passed to Slottable:\", resolvedChildToRender);\n\t\treturn null;\n\t}\n\n\tconst childToRenderChildren = childrenArray.map((child) => {\n\t\tif (child === slottable) {\n\t\t\t// == Because the new element will be the one rendered, we are only interested in grabbing its children (`childToRender.props.children`)\n\t\t\treturn (resolvedChildToRender.props as SlotProps).children;\n\t\t}\n\n\t\treturn child;\n\t});\n\n\treturn (\n\t\t<SlotClone {...restOfSlotProps}>\n\t\t\t{cloneElement(resolvedChildToRender, undefined, childToRenderChildren)}\n\t\t</SlotClone>\n\t);\n}\n\n/* -------------------------------------------------------------------------------------------------\n * Slottable\n * ----------------------------------------------------------------------------------------------- */\n\nexport function SlotSlottable({ children }: Pick<SlotProps, \"children\">) {\n\treturn children;\n}\n\nconst isSlottable = (child: React.ReactNode): child is React.ReactElement => {\n\treturn isValidElement(child) && child.type === SlotSlottable;\n};\n\n/* -------------------------------------------------------------------------------------------------\n * SlotClone\n * ----------------------------------------------------------------------------------------------- */\ntype SlotCloneProps = Pick<SlotProps, \"children\" | \"ref\">;\n\nfunction SlotClone(props: SlotCloneProps) {\n\tconst { children, ref: forwardedRef, ...restOfSlotProps } = props;\n\n\tif (Children.count(children) > 1) {\n\t\treturn Children.only(null);\n\t}\n\n\tconst resolvedChild = isArray(children) ? children[0] : children;\n\n\tif (!isValidElement<UnknownObject>(resolvedChild)) {\n\t\t// eslint-disable-next-line react-x/purity -- Ignore\n\t\tconsole.error(\"Invalid element passed to Slot:\", resolvedChild);\n\t\treturn null;\n\t}\n\n\tconst childRef = resolvedChild.props.ref as React.Ref<HTMLElement>;\n\n\tconst ref = composeRefs(forwardedRef, childRef);\n\n\tconst clonedProps = {\n\t\t...mergeProps(restOfSlotProps, resolvedChild.props),\n\t\t...(resolvedChild.type !== ReactFragment && { ref }),\n\t};\n\n\treturn cloneElement(resolvedChild, clonedProps);\n}\n","export { SlotRoot as Root, SlotSlottable as Slottable } from \"./slot\";\n"],"mappings":";;;;;;AAUA,SAAgB,SAAS,OAAkB;CAC1C,MAAM,EAAE,UAAU,GAAG,oBAAoB;CAEzC,MAAM,gBAAgB,QAAyB,SAAS,GAAG,WAAW,CAAC,SAAS;CAEhF,MAAM,YAAY,cAAc,MAAM,YAAY,YAAY,QAAQ,CAAC;AAEvE,KAAI,CAAC,UACJ,QAAO,oBAAC,WAAD;EAAW,GAAI;EAAkB;EAAqB,CAAA;AAG9D,KAAI,CAAC,eAA0B,UAAU,CACxC,QAAO;CAIR,MAAM,gBAAgB,UAAU,MAAM;AAEtC,KAAI,SAAS,MAAM,cAAc,GAAG,EACnC,QAAO,SAAS,KAAK,KAAK;CAG3B,MAAM,wBAAwB,QAAQ,cAAc,GAAG,cAAc,KAAK;AAE1E,KAAI,CAAC,eAAe,sBAAsB,EAAE;AAE3C,UAAQ,MAAM,wCAAwC,sBAAsB;AAC5E,SAAO;;CAGR,MAAM,wBAAwB,cAAc,KAAK,UAAU;AAC1D,MAAI,UAAU,UAEb,QAAQ,sBAAsB,MAAoB;AAGnD,SAAO;GACN;AAEF,QACC,oBAAC,WAAD;EAAW,GAAI;YACb,aAAa,uBAAuB,KAAA,GAAW,sBAAsB;EAC3D,CAAA;;AAQd,SAAgB,cAAc,EAAE,YAAyC;AACxE,QAAO;;AAGR,MAAM,eAAe,UAAwD;AAC5E,QAAO,eAAe,MAAM,IAAI,MAAM,SAAS;;AAQhD,SAAS,UAAU,OAAuB;CACzC,MAAM,EAAE,UAAU,KAAK,cAAc,GAAG,oBAAoB;AAE5D,KAAI,SAAS,MAAM,SAAS,GAAG,EAC9B,QAAO,SAAS,KAAK,KAAK;CAG3B,MAAM,gBAAgB,QAAQ,SAAS,GAAG,SAAS,KAAK;AAExD,KAAI,CAAC,eAA8B,cAAc,EAAE;AAElD,UAAQ,MAAM,mCAAmC,cAAc;AAC/D,SAAO;;CAGR,MAAM,WAAW,cAAc,MAAM;CAErC,MAAM,MAAM,YAAY,cAAc,SAAS;AAO/C,QAAO,aAAa,eALA;EACnB,GAAG,WAAW,iBAAiB,cAAc,MAAM;EACnD,GAAI,cAAc,SAASA,YAAiB,EAAE,KAAK;EACnD,CAE8C"}
1
+ {"version":3,"file":"slot-CHR5Li4r.js","names":["ReactFragment"],"sources":["../../src/components/common/slot/slot.tsx","../../src/components/common/slot/slot-parts.ts"],"sourcesContent":["import { composeRefs, mergeProps, type InferProps } from \"@zayne-labs/toolkit-react/utils\";\nimport { isArray, type UnknownObject } from \"@zayne-labs/toolkit-type-helpers\";\nimport { Children, cloneElement, isValidElement, Fragment as ReactFragment } from \"react\";\n\ntype SlotProps = InferProps<HTMLElement> & { ref?: React.Ref<HTMLElement> };\n\n/* -------------------------------------------------------------------------------------------------\n * Slot\n * ----------------------------------------------------------------------------------------------- */\n\nexport function SlotRoot(props: SlotProps) {\n\tconst { children, ...restOfSlotProps } = props;\n\n\tconst childrenArray = isArray<React.ReactNode>(children) ? children : [children];\n\n\tconst slottable = childrenArray.find((element) => isSlottable(element));\n\n\tif (!slottable) {\n\t\treturn <SlotClone {...restOfSlotProps}>{children}</SlotClone>;\n\t}\n\n\tif (!isValidElement<SlotProps>(slottable)) {\n\t\treturn null;\n\t}\n\n\t// == The new element to render is the one passed as a child of `Slot.Slottable`\n\tconst childToRender = slottable.props.children;\n\n\tif (Children.count(childToRender) > 1) {\n\t\treturn Children.only(null);\n\t}\n\n\tconst resolvedChildToRender = isArray(childToRender) ? childToRender[0] : childToRender;\n\n\tif (!isValidElement(resolvedChildToRender)) {\n\t\t// eslint-disable-next-line react-x/purity -- Ignore\n\t\tconsole.error(\"Invalid element passed to Slottable:\", resolvedChildToRender);\n\t\treturn null;\n\t}\n\n\tconst childToRenderChildren = childrenArray.map((child) => {\n\t\tif (child === slottable) {\n\t\t\t// == Because the new element will be the one rendered, we are only interested in grabbing its children (`childToRender.props.children`)\n\t\t\treturn (resolvedChildToRender.props as SlotProps).children;\n\t\t}\n\n\t\treturn child;\n\t});\n\n\treturn (\n\t\t<SlotClone {...restOfSlotProps}>\n\t\t\t{cloneElement(resolvedChildToRender, undefined, childToRenderChildren)}\n\t\t</SlotClone>\n\t);\n}\n\n/* -------------------------------------------------------------------------------------------------\n * Slottable\n * ----------------------------------------------------------------------------------------------- */\n\nexport function SlotSlottable({ children }: Pick<SlotProps, \"children\">) {\n\treturn children;\n}\n\nconst isSlottable = (child: React.ReactNode): child is React.ReactElement => {\n\treturn isValidElement(child) && child.type === SlotSlottable;\n};\n\n/* -------------------------------------------------------------------------------------------------\n * SlotClone\n * ----------------------------------------------------------------------------------------------- */\ntype SlotCloneProps = Pick<SlotProps, \"children\" | \"ref\">;\n\nfunction SlotClone(props: SlotCloneProps) {\n\tconst { children, ref: forwardedRef, ...restOfSlotProps } = props;\n\n\tif (Children.count(children) > 1) {\n\t\treturn Children.only(null);\n\t}\n\n\tconst resolvedChild = isArray(children) ? children[0] : children;\n\n\tif (!isValidElement<UnknownObject>(resolvedChild)) {\n\t\t// eslint-disable-next-line react-x/purity -- Ignore\n\t\tconsole.error(\"Invalid element passed to Slot:\", resolvedChild);\n\t\treturn null;\n\t}\n\n\tconst childRef = resolvedChild.props.ref as React.Ref<HTMLElement>;\n\n\tconst ref = composeRefs(forwardedRef, childRef);\n\n\tconst clonedProps = {\n\t\t...mergeProps(restOfSlotProps, resolvedChild.props),\n\t\t...(resolvedChild.type !== ReactFragment && { ref }),\n\t};\n\n\treturn cloneElement(resolvedChild, clonedProps);\n}\n","export { SlotRoot as Root, SlotSlottable as Slottable } from \"./slot\";\n"],"mappings":";;;;;;AAUA,SAAgB,SAAS,OAAkB;CAC1C,MAAM,EAAE,UAAU,GAAG,oBAAoB;CAEzC,MAAM,gBAAgB,QAAyB,SAAS,GAAG,WAAW,CAAC,SAAS;CAEhF,MAAM,YAAY,cAAc,MAAM,YAAY,YAAY,QAAQ,CAAC;AAEvE,KAAI,CAAC,UACJ,QAAO,oBAAC,WAAD;EAAW,GAAI;EAAkB;EAAqB,CAAA;AAG9D,KAAI,CAAC,eAA0B,UAAU,CACxC,QAAO;CAIR,MAAM,gBAAgB,UAAU,MAAM;AAEtC,KAAI,SAAS,MAAM,cAAc,GAAG,EACnC,QAAO,SAAS,KAAK,KAAK;CAG3B,MAAM,wBAAwB,QAAQ,cAAc,GAAG,cAAc,KAAK;AAE1E,KAAI,CAAC,eAAe,sBAAsB,EAAE;AAE3C,UAAQ,MAAM,wCAAwC,sBAAsB;AAC5E,SAAO;;CAGR,MAAM,wBAAwB,cAAc,KAAK,UAAU;AAC1D,MAAI,UAAU,UAEb,QAAQ,sBAAsB,MAAoB;AAGnD,SAAO;GACN;AAEF,QACC,oBAAC,WAAD;EAAW,GAAI;YACb,aAAa,uBAAuB,KAAA,GAAW,sBAAsB;EAC3D,CAAA;;AAQd,SAAgB,cAAc,EAAE,YAAyC;AACxE,QAAO;;AAGR,MAAM,eAAe,UAAwD;AAC5E,QAAO,eAAe,MAAM,IAAI,MAAM,SAAS;;AAQhD,SAAS,UAAU,OAAuB;CACzC,MAAM,EAAE,UAAU,KAAK,cAAc,GAAG,oBAAoB;AAE5D,KAAI,SAAS,MAAM,SAAS,GAAG,EAC9B,QAAO,SAAS,KAAK,KAAK;CAG3B,MAAM,gBAAgB,QAAQ,SAAS,GAAG,SAAS,KAAK;AAExD,KAAI,CAAC,eAA8B,cAAc,EAAE;AAElD,UAAQ,MAAM,mCAAmC,cAAc;AAC/D,SAAO;;CAGR,MAAM,WAAW,cAAc,MAAM;CAErC,MAAM,MAAM,YAAY,cAAc,SAAS;AAO/C,QAAO,aAAa,eALA;EACnB,GAAG,WAAW,iBAAiB,cAAc,MAAM;EACnD,GAAI,cAAc,SAASA,YAAiB,EAAE,KAAK;EACnD,CAE8C"}
@@ -0,0 +1,35 @@
1
+ import { t as __exportAll } from "./chunk-pbuEa-1d.js";
2
+ import { getRegularChildren, getSingleSlot } from "@zayne-labs/toolkit-react/utils";
3
+ import { isFunction } from "@zayne-labs/toolkit-type-helpers";
4
+ //#region src/components/common/switch/switch.tsx
5
+ const defaultValueSymbol = Symbol("default-value");
6
+ function SwitchRoot(props) {
7
+ const { children, value = defaultValueSymbol } = props;
8
+ const defaultCase = getSingleSlot(children, SwitchDefault, {
9
+ errorMessage: "Only one <Switch.Default> component is allowed",
10
+ throwOnMultipleSlotMatch: true
11
+ });
12
+ return getRegularChildren(children, SwitchDefault).find((child) => {
13
+ if (value === defaultValueSymbol) return Boolean(child.props.when);
14
+ return child.props.when === value;
15
+ }) ?? defaultCase;
16
+ }
17
+ function SwitchMatch(props) {
18
+ const { children, when } = props;
19
+ return isFunction(children) ? children(when) : children;
20
+ }
21
+ function SwitchDefault({ children }) {
22
+ return children;
23
+ }
24
+ SwitchDefault.slotSymbol = Symbol("switch-default");
25
+ //#endregion
26
+ //#region src/components/common/switch/switch-parts.ts
27
+ var switch_parts_exports = /* @__PURE__ */ __exportAll({
28
+ Default: () => SwitchDefault,
29
+ Match: () => SwitchMatch,
30
+ Root: () => SwitchRoot
31
+ });
32
+ //#endregion
33
+ export { SwitchRoot as i, SwitchDefault as n, SwitchMatch as r, switch_parts_exports as t };
34
+
35
+ //# sourceMappingURL=switch-Dwy5Gzsb.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"switch-Dwy5Gzsb.js","names":[],"sources":["../../src/components/common/switch/switch.tsx","../../src/components/common/switch/switch-parts.ts"],"sourcesContent":["\"use client\";\n\nimport { getRegularChildren, getSingleSlot } from \"@zayne-labs/toolkit-react/utils\";\nimport { isFunction } from \"@zayne-labs/toolkit-type-helpers\";\n\ntype ValidSwitchComponentType = React.ReactElement<SwitchMatchProps<unknown>>;\n\nexport type SwitchRootProps<TValue> = {\n\tchildren: ValidSwitchComponentType | ValidSwitchComponentType[];\n\tvalue?: TValue;\n};\n\nconst defaultValueSymbol = Symbol(\"default-value\");\n\n// TODO - Add a factory to make this 'when' and 'value' type-safe later following the link below\n// LINK - https://tkdodo.eu/blog/building-type-safe-compound-components#component-factory-pattern\nexport function SwitchRoot<TValue>(props: SwitchRootProps<TValue>) {\n\tconst { children, value = defaultValueSymbol } = props;\n\n\tconst defaultCase = getSingleSlot(children, SwitchDefault, {\n\t\terrorMessage: \"Only one <Switch.Default> component is allowed\",\n\t\tthrowOnMultipleSlotMatch: true,\n\t});\n\n\tconst childrenCasesArray = getRegularChildren(children, SwitchDefault) as ValidSwitchComponentType[];\n\n\tconst matchedCase = childrenCasesArray.find((child) => {\n\t\t// == If value is defaultValueSymbol, match the cases in order like switch(true)\n\t\tif (value === defaultValueSymbol) {\n\t\t\treturn Boolean(child.props.when);\n\t\t}\n\n\t\t// == Otherwise, match the cases like switch(value)\n\t\treturn child.props.when === value;\n\t});\n\n\treturn matchedCase ?? defaultCase;\n}\n\nexport type SwitchMatchProps<TWhen> = {\n\tchildren: React.ReactNode | ((value: TWhen) => React.ReactNode);\n\twhen: false | TWhen | null | undefined;\n};\n\nexport function SwitchMatch<TWhen>(props: SwitchMatchProps<TWhen>) {\n\tconst { children, when } = props;\n\n\tconst resolvedChildren = isFunction(children) ? children(when as TWhen) : children;\n\n\treturn resolvedChildren;\n}\n\nexport function SwitchDefault({ children }: { children: React.ReactNode }) {\n\treturn children;\n}\nSwitchDefault.slotSymbol = Symbol(\"switch-default\");\n","export { SwitchDefault as Default, SwitchMatch as Match, SwitchRoot as Root } from \"./switch\";\n"],"mappings":";;;;AAYA,MAAM,qBAAqB,OAAO,gBAAgB;AAIlD,SAAgB,WAAmB,OAAgC;CAClE,MAAM,EAAE,UAAU,QAAQ,uBAAuB;CAEjD,MAAM,cAAc,cAAc,UAAU,eAAe;EAC1D,cAAc;EACd,0BAA0B;EAC1B,CAAC;AAcF,QAZ2B,mBAAmB,UAAU,cAAc,CAE/B,MAAM,UAAU;AAEtD,MAAI,UAAU,mBACb,QAAO,QAAQ,MAAM,MAAM,KAAK;AAIjC,SAAO,MAAM,MAAM,SAAS;GAC3B,IAEoB;;AAQvB,SAAgB,YAAmB,OAAgC;CAClE,MAAM,EAAE,UAAU,SAAS;AAI3B,QAFyB,WAAW,SAAS,GAAG,SAAS,KAAc,GAAG;;AAK3E,SAAgB,cAAc,EAAE,YAA2C;AAC1E,QAAO;;AAER,cAAc,aAAa,OAAO,iBAAiB"}
@@ -1,6 +1,6 @@
1
1
  import { t as __exportAll } from "../../chunk-pbuEa-1d.js";
2
- import { n as SlotRoot } from "../../slot-DuwoiC2C.js";
3
- import { t as cnMerge } from "../../cn-Bbh2G587.js";
2
+ import { n as SlotRoot } from "../../slot-CHR5Li4r.js";
3
+ import { t as cnMerge } from "../../cn-CIbU5eI0.js";
4
4
  import { jsx } from "react/jsx-runtime";
5
5
  //#region src/components/ui/card/card.tsx
6
6
  function CardRoot(props) {
@@ -1,13 +1,13 @@
1
1
  "use client";
2
2
  import { t as __exportAll } from "../../chunk-pbuEa-1d.js";
3
+ import { t as cnMerge } from "../../cn-CIbU5eI0.js";
3
4
  import { n as For } from "../../for-DGTMIS0w.js";
4
- import { i as ShowRoot, n as ShowContent, r as ShowFallback } from "../../show-BzfAw7y3.js";
5
- import { t as cnMerge } from "../../cn-Bbh2G587.js";
5
+ import { i as ShowRoot, n as ShowContent, r as ShowFallback } from "../../show-mvRnLPj8.js";
6
6
  import { isFunction } from "@zayne-labs/toolkit-type-helpers";
7
7
  import { useMemo, useState } from "react";
8
- import { useAnimationInterval, useCallbackRef, useStore } from "@zayne-labs/toolkit-react";
9
8
  import { jsx, jsxs } from "react/jsx-runtime";
10
9
  import { createStore } from "@zayne-labs/toolkit-core";
10
+ import { useAnimationInterval, useCallbackRef, useStore } from "@zayne-labs/toolkit-react";
11
11
  import { createReactStoreContext } from "@zayne-labs/toolkit-react/zustand";
12
12
  //#region src/components/ui/carousel/carousel-store-context.ts
13
13
  const [CarouselStoreContextProvider, useCarouselStoreContext] = createReactStoreContext({
@@ -4,7 +4,6 @@ import { SelectorFn } from "@zayne-labs/toolkit-type-helpers";
4
4
  import * as react from "react";
5
5
  import * as react_jsx_runtime0 from "react/jsx-runtime";
6
6
  import * as _zayne_labs_toolkit_core0 from "@zayne-labs/toolkit-core";
7
-
8
7
  //#region src/components/ui/drag-scroll/drag-scroll-context.d.ts
9
8
  declare const DragScrollStoreContextProvider: (props: {
10
9
  children: React.ReactNode;
@@ -1,13 +1,13 @@
1
1
  "use client";
2
2
  import { t as __exportAll } from "../../chunk-pbuEa-1d.js";
3
- import { n as SlotRoot } from "../../slot-DuwoiC2C.js";
4
- import { t as cnMerge } from "../../cn-Bbh2G587.js";
3
+ import { n as SlotRoot } from "../../slot-CHR5Li4r.js";
4
+ import { t as cnMerge } from "../../cn-CIbU5eI0.js";
5
5
  import { composeRefs, composeTwoEventHandlers } from "@zayne-labs/toolkit-react/utils";
6
6
  import { isFunction, isNumber } from "@zayne-labs/toolkit-type-helpers";
7
7
  import { useCallback, useEffect, useMemo, useRef } from "react";
8
- import { createCustomContext, useCallbackRef, useCompareSelector, useStore } from "@zayne-labs/toolkit-react";
9
8
  import { jsx } from "react/jsx-runtime";
10
9
  import { checkIsDeviceMobile, createStore, dataAttr, on, throttleByFrame } from "@zayne-labs/toolkit-core";
10
+ import { createCustomContext, useCallbackRef, useCompareSelector, useStore } from "@zayne-labs/toolkit-react";
11
11
  import { createReactStoreContext } from "@zayne-labs/toolkit-react/zustand";
12
12
  //#region src/components/ui/drag-scroll/utils.ts
13
13
  const updateCursor = (element) => {
@@ -5,7 +5,6 @@ import * as react from "react";
5
5
  import * as react_jsx_runtime0 from "react/jsx-runtime";
6
6
  import * as _zayne_labs_toolkit_core0 from "@zayne-labs/toolkit-core";
7
7
  import { FileMeta, FileOrFileMeta, FileValidationErrorContextEach, FileValidationHooksAsync, FileValidationSettingsAsync } from "@zayne-labs/toolkit-core";
8
-
9
8
  //#region src/components/ui/drop-zone/drop-zone-store.d.ts
10
9
  type RequiredUseDropZoneProps = { [Key in keyof Required<UseDropZoneProps>]: UseDropZoneProps[Key] | undefined };
11
10
  type StoreContext = Pick<RequiredUseDropZoneProps, "allowedFileTypes" | "disablePreviewGenForNonImageFiles" | "initialFiles" | "maxFileCount" | "maxFileSize" | "multiple" | "onFilesChange" | "onUpload" | "onValidationError" | "onValidationSuccess" | "rejectDuplicateFiles" | "validator">;
@@ -352,19 +351,29 @@ type DropZoneFileItemDeleteProps = {
352
351
  asChild?: boolean;
353
352
  } & PartInputProps["fileItemDelete"];
354
353
  declare function DropZoneFileItemDelete(props: DropZoneFileItemDeleteProps): react_jsx_runtime0.JSX.Element;
354
+ type StrictExtract<TUnion, TPick extends TUnion> = Extract<TUnion, TPick>;
355
355
  type DropZoneFileItemProgressProps = {
356
356
  asChild?: boolean;
357
- classNames?: {
358
- circular?: {
359
- root?: string;
360
- svgCircleOne?: string;
361
- svgCircleTwo?: string;
362
- svgRoot?: string;
363
- };
364
- };
365
357
  forceMount?: boolean;
366
358
  size?: number;
367
- } & PartInputProps["fileItemProgress"];
359
+ } & PartInputProps["fileItemProgress"] & ({
360
+ classNames?: {
361
+ svgCircleOne?: string;
362
+ svgCircleTwo?: string;
363
+ svgRoot?: string;
364
+ };
365
+ variant: StrictExtract<PartInputProps["fileItemProgress"]["variant"], "circular">;
366
+ } | {
367
+ classNames?: {
368
+ track?: string;
369
+ };
370
+ variant: StrictExtract<PartInputProps["fileItemProgress"]["variant"], "fill">;
371
+ } | {
372
+ classNames?: {
373
+ track?: string;
374
+ };
375
+ variant?: StrictExtract<PartInputProps["fileItemProgress"]["variant"], "linear">;
376
+ });
368
377
  declare function DropZoneFileItemProgress<TElement extends React.ElementType = "span">(props: PolymorphicPropsStrict<TElement, DropZoneFileItemProgressProps>): react_jsx_runtime0.JSX.Element | null;
369
378
  type NodeCtx<TElement extends React.ElementType> = {
370
379
  getProps: (innerProps: Partial<InferProps<TElement>>) => InferProps<TElement>;
@@ -1,15 +1,16 @@
1
1
  "use client";
2
2
  import { t as __exportAll } from "../../chunk-pbuEa-1d.js";
3
- import { n as SlotRoot } from "../../slot-DuwoiC2C.js";
3
+ import { n as SlotRoot } from "../../slot-CHR5Li4r.js";
4
+ import { t as cnMerge } from "../../cn-CIbU5eI0.js";
4
5
  import { n as For } from "../../for-DGTMIS0w.js";
5
- import { t as Presence } from "../../presence-CWOGx-be.js";
6
- import { t as cnMerge } from "../../cn-Bbh2G587.js";
6
+ import { t as Presence } from "../../presence-DgJvW30C.js";
7
+ import { i as SwitchRoot, r as SwitchMatch } from "../../switch-Dwy5Gzsb.js";
7
8
  import { composeRefs, composeTwoEventHandlers } from "@zayne-labs/toolkit-react/utils";
8
9
  import { isBoolean, isFile, isFunction, isNumber, isObject, isString } from "@zayne-labs/toolkit-type-helpers";
9
10
  import { useCallback, useMemo, useRef } from "react";
10
- import { createCustomContext, useCallbackRef, useCompareSelector, useCompareValue, useStore, useUnmountEffect } from "@zayne-labs/toolkit-react";
11
11
  import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
12
12
  import { createFileURL, createStore, dataAttr, formatBytes, generateFileID, handleFileValidationAsync, toArray } from "@zayne-labs/toolkit-core";
13
+ import { createCustomContext, useCallbackRef, useCompareSelector, useCompareValue, useStore, useUnmountEffect } from "@zayne-labs/toolkit-react";
13
14
  import { createReactStoreContext } from "@zayne-labs/toolkit-react/zustand";
14
15
  //#region src/components/ui/drop-zone/drop-zone-context.ts
15
16
  const [DropZoneStoreContextProvider, useDropZoneStoreContext] = createReactStoreContext({
@@ -592,7 +593,7 @@ const useDropZone = (props) => {
592
593
  ...getDropZoneScopeAttrs("file-item-progress"),
593
594
  role: "progressbar",
594
595
  ...restOfInnerProps,
595
- ...!unstyled && { className: cnMerge("inline-flex", variant === "circular" && "absolute top-1/2 left-1/2 -translate-1/2", variant === "fill" && `absolute inset-0 bg-zu-primary/50 transition-[clip-path] duration-300 ease-linear [clip-path:var(--clip-path)]`, variant === "linear" && "relative h-1.5 w-full overflow-hidden rounded-full bg-zu-primary/20", restOfInnerProps.className) }
596
+ ...!unstyled && { className: cnMerge("inline-flex", variant === "circular" && "absolute top-1/2 left-1/2 -translate-1/2", variant === "fill" && `absolute inset-0`, variant === "linear" && "relative h-1.5 w-full overflow-hidden rounded-full bg-zu-primary/20", restOfInnerProps.className) }
596
597
  };
597
598
  }, [globalUnstyled]);
598
599
  const getFileItemDeleteProps = useCallback((innerProps) => {
@@ -803,72 +804,74 @@ function DropZoneFileItemDelete(props) {
803
804
  }) });
804
805
  }
805
806
  function DropZoneFileItemProgress(props) {
806
- const { as: Element = "span", asChild, className, classNames, forceMount = false, size = 40, variant = "linear", ...restOfProps } = props;
807
+ const { as: Element = "span", asChild, className, classNames: classNamesProp, forceMount = false, size = 40, variant = "linear", ...restOfProps } = props;
808
+ const classNames = classNamesProp;
807
809
  const fileState = useFileItemContext()?.fileState;
808
810
  const { propGetters } = useDropZoneRootContext();
809
811
  if (!fileState) return null;
810
- const currentProgress = fileState.progress;
811
- if (!(forceMount || fileState.progress !== 100)) return null;
812
812
  const Component = asChild ? SlotRoot : Element;
813
813
  const componentProps = propGetters.getFileItemProgressProps({
814
814
  variant,
815
815
  ...restOfProps
816
816
  });
817
- switch (variant) {
818
- case "circular": {
819
- const circumference = 2 * Math.PI * ((size - 4) / 2);
820
- const strokeDashoffset = circumference - currentProgress / 100 * circumference;
821
- return /* @__PURE__ */ jsx(Component, {
822
- className: cnMerge(className, classNames?.circular?.root),
823
- ...componentProps,
824
- children: /* @__PURE__ */ jsxs("svg", {
825
- className: cnMerge("-rotate-90", classNames?.circular?.svgRoot),
826
- width: size,
827
- height: size,
828
- viewBox: `0 0 ${size} ${size}`,
829
- fill: "none",
830
- stroke: "currentColor",
831
- children: [/* @__PURE__ */ jsx("circle", {
832
- className: cnMerge("text-zu-primary/20", classNames?.circular?.svgCircleOne),
833
- strokeWidth: "2",
834
- cx: size / 2,
835
- cy: size / 2,
836
- r: (size - 4) / 2
837
- }), /* @__PURE__ */ jsx("circle", {
838
- className: cnMerge("text-zu-primary transition-[stroke-dashoffset] duration-300 ease-linear", classNames?.circular?.svgCircleTwo),
839
- strokeWidth: "2",
840
- strokeLinecap: "round",
841
- strokeDasharray: circumference,
842
- strokeDashoffset,
843
- cx: size / 2,
844
- cy: size / 2,
845
- r: (size - 4) / 2
846
- })]
847
- })
848
- });
849
- }
850
- case "fill": {
851
- const topInset = 100 - currentProgress;
852
- return /* @__PURE__ */ jsx(Component, {
853
- className,
854
- ...componentProps,
855
- style: {
856
- "--clip-path": `inset(${topInset}% 0% 0% 0%)`,
857
- ...componentProps.style
858
- }
859
- });
860
- }
861
- case "linear": return /* @__PURE__ */ jsx(Component, {
862
- className: cnMerge("inline-block size-full grow translate-x-(--translate-distance) bg-zu-primary transition-transform duration-300 ease-linear", className),
817
+ return /* @__PURE__ */ jsx(Presence, {
818
+ present: fileState.progress !== 100,
819
+ forceMount,
820
+ className: "data-[animation-phase=exit]:animate-progress-out",
821
+ children: /* @__PURE__ */ jsx(Component, {
822
+ className: cnMerge("inline-block", className),
863
823
  ...componentProps,
864
- style: {
865
- "--translate-distance": `-${100 - currentProgress}%`,
866
- ...componentProps.style
867
- },
868
- children: /* @__PURE__ */ jsx("span", {})
869
- });
870
- default: return null;
871
- }
824
+ children: /* @__PURE__ */ jsxs(SwitchRoot, { children: [
825
+ /* @__PURE__ */ jsx(SwitchMatch, {
826
+ when: variant === "circular",
827
+ children: () => {
828
+ const circumference = 2 * Math.PI * ((size - 4) / 2);
829
+ const strokeDashoffset = circumference - fileState.progress / 100 * circumference;
830
+ return /* @__PURE__ */ jsxs("svg", {
831
+ className: cnMerge("-rotate-90", classNames?.svgRoot),
832
+ width: size,
833
+ height: size,
834
+ viewBox: `0 0 ${size} ${size}`,
835
+ fill: "none",
836
+ stroke: "currentColor",
837
+ children: [/* @__PURE__ */ jsx("circle", {
838
+ className: cnMerge("text-zu-primary/20", classNames?.svgCircleOne),
839
+ strokeWidth: "2",
840
+ cx: size / 2,
841
+ cy: size / 2,
842
+ r: (size - 4) / 2
843
+ }), /* @__PURE__ */ jsx("circle", {
844
+ className: cnMerge("text-zu-primary transition-[stroke-dashoffset] duration-300 ease-linear", classNames?.svgCircleTwo),
845
+ strokeWidth: "2",
846
+ strokeLinecap: "round",
847
+ strokeDasharray: 2 * Math.PI * ((size - 4) / 2),
848
+ strokeDashoffset,
849
+ cx: size / 2,
850
+ cy: size / 2,
851
+ r: (size - 4) / 2
852
+ })]
853
+ });
854
+ }
855
+ }),
856
+ /* @__PURE__ */ jsx(SwitchMatch, {
857
+ when: variant === "fill",
858
+ children: /* @__PURE__ */ jsx("span", {
859
+ className: cnMerge(`size-full bg-zu-primary/50 transition-[clip-path] duration-300 ease-linear
860
+ [clip-path:var(--clip-path)]`, classNames?.track),
861
+ style: { "--clip-path": `inset(${100 - fileState.progress}% 0% 0% 0%)` }
862
+ })
863
+ }),
864
+ /* @__PURE__ */ jsx(SwitchMatch, {
865
+ when: variant === "linear",
866
+ children: /* @__PURE__ */ jsx("span", {
867
+ className: cnMerge(`inline-block size-full grow translate-x-(--translate-distance) bg-zu-primary
868
+ transition-transform duration-300 ease-linear`, classNames?.track),
869
+ style: { "--translate-distance": `-${100 - fileState.progress}%` }
870
+ })
871
+ })
872
+ ] })
873
+ })
874
+ });
872
875
  }
873
876
  function DropZoneFileItemPreview(props) {
874
877
  const { as: Element = "span", asChild, children, fileState: fileStateProp, renderPreview = true, ...restOfProps } = props;